func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 2e5 + 5;   int n, q;   ll a[N], tree[N << 2], lz[N << 2];   void push(int node, int s, int e) {     tree[node] += lz[node];     if (s != e) {       lz[node << 1] += lz[node];       lz[node << 1 | 1] += lz[node];     }     lz[node] = 0;   }   void upd(int node, int s, int e, int l, int r, ll v) {     push(node, s, e);     if (r < s || e < l || l > r) return;     if (l <= s && e <= r) {       lz[node] += v;       push(node, s, e);       return;     }     int md = (s + e) >> 1;     upd(node << 1, s, md, l, r, v);     upd(node << 1 | 1, md + 1, e, l, r, v);     tree[node] = max(tree[node << 1], tree[node << 1 | 1]);   }   int get(int node, int s, int e) {     push(node, s, e);     if (tree[node] < 0) return -1;     if (s == e) return tree[node] != 0 ? -1 : s + 1;     int md = (s + e) >> 1;     int x = get(node << 1, s, md);     if (~x) return x;     return get(node << 1 | 1, md + 1, e);   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 0; i < n; i++) {       scanf( %lld , a + i);       upd(1, 0, n - 1, i, i, a[i]);       upd(1, 0, n - 1, i + 1, n - 1, -a[i]);     }     while (q--) {       int x, v;       scanf( %d%d , &x, &v);       upd(1, 0, n - 1, x - 1, x - 1, -a[x - 1] + v);       upd(1, 0, n - 1, x, n - 1, a[x - 1] - v);       a[x - 1] = v;       printf( %d n , get(1, 0, n - 1));     }     return 0;   }   