func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6;   int n, seg[MAXN], r[MAXN], v[MAXN], resp;   void update(int ini, int fim, int cur, int id, int aux) {     if (id < ini || fim < id) return;     if (ini == fim) {       seg[cur] = aux;       r[cur] = aux;       return;     }     int m = (ini + fim) / 2;     update(ini, m, 2 * cur, id, aux);     update(m + 1, fim, 2 * cur + 1, id, aux);     seg[cur] = seg[2 * cur] + seg[2 * cur + 1];     r[cur] = max(r[2 * cur + 1], seg[2 * cur + 1] + r[2 * cur]);   }   int BB(int ini, int fim, int cur, int k) {     if (ini == fim) return ini;     int m = (ini + fim) / 2;     if (r[2 * cur + 1] < k) return BB(ini, m, 2 * cur, k - seg[2 * cur + 1]);     return BB(m + 1, fim, 2 * cur + 1, k);   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     ;     cin >> n;     for (int i = 0; i < n; i++) {       int auxid, auxx, aux;       cin >> auxid >> auxx;       if (!auxx)         update(1, n, 1, auxid, -1);       else {         cin >> aux;         v[auxid] = aux;         update(1, n, 1, auxid, 1);       }       resp = v[BB(1, n, 1, 1)];       if (r[1] < 1)         cout << -1 <<   n ;       else         cout << resp <<   n ;     }   }   