func_code_string: #include <bits/stdc++.h>   const int mod = 1000000007;   const int inf = 1000000009;   const long long INF = 1000000000000000009;   const long long big = 1000000000000000;   const long double eps = 0.000000000000000000001;   using namespace std;   vector<pair<int, int> > W;   int T[200005];   int s, l, last = -1;   bool czy = 0;   vector<int> R;   void make_move(int r) {     R.push_back(s);     if (r == 0) {       last = s;       auto x = upper_bound(W.begin(), W.end(), make_pair(W[s].first + l, inf)) -                W.begin() - 1;       l -= W[x].first - W[s].first;       s = x;     } else {       auto x = lower_bound(W.begin(), W.end(), make_pair(W[s].first - l, -inf)) -                W.begin();       long long d = W[s].first - W[x].first;       l -= d;       if (s == x) {         czy = 1;         return;       }       s = x;       if (s == last) l = l % (d * 2);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     int n, q;     cin >> n >> q;     for (int i = 1; i <= n; i++) {       int a;       cin >> a;       W.push_back(make_pair(a, i));     }     sort(W.begin(), W.end());     for (int i = 0; i < W.size(); i++) T[W[i].second] = i;     for (int i = 1; i <= q; i++) {       cin >> s >> l;       s = T[s];       while (!czy) {         make_move(0);         make_move(1);       }       czy = 0;       last = -1;       cout << W[s].second <<   n ;       R.clear();     }     return 0;   }   