func_code_string: #include <bits/stdc++.h>   const long long oo = (long long)1e18 + 1;   using namespace std;   int n, q;   int b[200002];   pair<int, int> a[200002];   int T[200002];   vector<pair<int, int> > query[200002];   int k[200002], p[200002];   int res[200002];   void upd(int x) {     while (x < 200002) {       T[x]++;       x = x + (x & (x ^ (x - 1)));     }   }   int get(int x) {     int res = 0;     while (x > 0) {       res += T[x];       x = x - (x & (x ^ (x - 1)));     }     return res;   }   int find_kth(int cnt) {     int l = 1;     int r = n;     int res = n;     while (l <= r) {       int mid = (l + r) >> 1;       int count_value = get(mid);       if (count_value >= cnt) {         res = mid;         r = mid - 1;       } else         l = mid + 1;     }     return res;   }   bool cmp(pair<int, int> x, pair<int, int> y) {     return x.first > y.first || (x.first == y.first && x.second < y.second);   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       b[i] = x;       a[i] = make_pair(x, i);     }     sort(a + 1, a + n + 1, cmp);     cin >> q;     for (int i = 1; i <= q; i++) {       cin >> k[i] >> p[i];       query[k[i]].push_back(make_pair(p[i], i));     }     for (int i = 1; i <= n; i++) {       upd(a[i].second);       for (int j = 0; j < query[i].size(); j++) {         pair<int, int> cur_query = query[i][j];         int pos = cur_query.first;         int rpos = cur_query.second;         res[rpos] = b[find_kth(pos)];       }     }     for (int i = 1; i <= q; i++) cout << res[i] <<   n ;     return 0;   }   