func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 101010 * 2;   int a[maxn], n, m;   int b[maxn];   int p[maxn];   int query(int poin, long long l, bool dir) {     int tv;     int cir;     int las;     if (dir) {       tv = upper_bound(b + 1, b + 1 + n, b[poin] + l) - b - 1;       if (tv == poin) return p[poin];       cir = l / (b[tv] - b[poin]);       las = l % (b[tv] - b[poin]);       if (cir & 1)         return query(tv, las, !dir);       else         return query(poin, las, dir);     } else {       tv = lower_bound(b + 1, b + 1 + n, b[poin] - l) - b;       if (tv == poin) return p[poin];       cir = l / (b[poin] - b[tv]);       las = l % (b[poin] - b[tv]);       if (cir & 1)         return query(tv, las, !dir);       else         return query(poin, las, dir);     }     return 0;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     sort(b + 1, b + 1 + n);     for (int i = 1; i <= n; i++) {       p[lower_bound(b + 1, b + 1 + n, a[i]) - b] = i;     }     while (m--) {       int poin, l;       scanf( %d%d , &poin, &l);       poin = lower_bound(b + 1, b + 1 + n, a[poin]) - b;       int tv = upper_bound(b + 1, b + 1 + n, b[poin] + l) - b - 1;       printf( %d n , query(tv, l - (b[tv] - b[poin]), 0));     }   }   