func_code_string: #include <bits/stdc++.h>   using namespace std;   struct query {     int k, pos, ind;   } queries[200005];   struct arr {     int val, ind;   } a[200005];   long long n, q, cnt, res[200005], fw[200005], it[4 * 200005], len, b[200005];   bool cmp(arr a, arr b) {     if (a.val != b.val) return a.val > b.val;     return a.ind < b.ind;   }   bool que(query a, query b) { return a.k < b.k; }   void update(long long k, long long l, long long r, long long id) {     if (l == r) {       it[k] = 1;       return;     }     long long mid = (l + r) / 2;     if (id <= mid)       update(k * 2, l, mid, id);     else       update(k * 2 + 1, mid + 1, r, id);     it[k] = it[k * 2] + it[k * 2 + 1];   }   long long get(long long k, long long l, long long r, long long id) {     if (id > it[k]) return -1;     if (l == r) return l;     long long mid = (l + r) / 2;     if (id <= it[k * 2])       return get(k * 2, l, mid, id);     else       return get(k * 2 + 1, mid + 1, r, id - it[k * 2]);   }   int main() {     cin.tie(NULL);     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i].val;       a[i].ind = i;       b[i] = a[i].val;     }     sort(a + 1, a + 1 + n, cmp);     cin >> q;     for (int i = 1; i <= q; i++) {       cin >> queries[i].k >> queries[i].pos;       queries[i].ind = i;     }     sort(queries + 1, queries + 1 + q, que);     for (int i = 1; i <= q; i++) {       while (len != queries[i].k) {         len++;         update(1, 1, n, a[len].ind);       }       res[queries[i].ind] = b[get(1, 1, n, queries[i].pos)];     }     for (int i = 1; i <= q; i++) cout << res[i] << endl;   }   