func_code_string: #include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long su = 0, f = 1;     char c = getchar();     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) su = su * 10 + c -  0 ;     return su * f;   }   inline void wr(long long x) {     if (x < 0)       putchar( - ), wr(-x);     else {       if (x >= 10) wr(x / 10);       putchar(x % 10 +  0 );     }   }   inline void wri(long long x) {     wr(x);     putchar(   );   }   inline void wrn(long long x) {     wr(x);     putchar(  n );   }   inline void wrn(long long x, long long y) {     wri(x);     wrn(y);   }   inline void wrn(long long x, long long y, long long z) {     wri(x);     wrn(y, z);   }   int n, m, ans[600055], k, a[600055], x, y, ss[600055];   vector<pair<long long, long long> > q[600055];   pair<long long, long long> z[600055];   char str[600055];   int Next[600055 * 2], head[600055], to[600055 * 2], nedge, g[600055][4];   void add(int a, int b) {     Next[++nedge] = head[a];     head[a] = nedge;     to[nedge] = b;   }   void add_ne(int a, int b) {     add(a, b);     add(b, a);   }   void ad(int x, int k) {     for (; x <= n; x += x & -x) ss[x] += k;   }   int que(int x) {     int su = 0;     for (; x; x -= x & -x) su += ss[x];     return su;   }   signed main() {     n = read();     for (int i = 1; i <= n; i++)       a[i] = read(), z[i].first = a[i], z[i].second = n - i + 1;     sort(z + 1, z + n + 1);     for (int i = 1; i <= n; i++) z[i].second = n - z[i].second + 1;     m = read();     for (int i = 1; i <= m; i++) {       x = read();       y = read();       q[x].push_back(make_pair(y, i));     }     for (int i = 1; i <= n; i++) {       ad(z[n - i + 1].second, 1);       for (int j = 0; j < int(q[i].size()); j++) {         int l = 1, r = n, t = q[i][j].first;         while (l < r) {           int mid = (l + r) >> 1;           if (que(mid) < t)             l = mid + 1;           else             r = mid;         }         ans[q[i][j].second] = l;       }     }     for (int i = 1; i <= m; i++) wrn(a[ans[i]]);     return 0;   }   