func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005, MAXT = 500, INF = 0x3f3f3f3f;   int mx[MAXT], add[MAXT], sz[MAXT], num[MAXT][MAXT], A[MAXN];   int N, T = 314;   void upd(int p) {     if (add[p]) {       for (int i = 0; i < sz[p]; ++i) num[p][i] += add[p];       add[p] = 0;     }   }   void ins(int x, int k) {     int p = x / T;     x = x % T;     for (int i = 0; i < p; ++i) add[i] += k, mx[i] += k;     upd(p);     for (int i = 0; i <= x; ++i) num[p][i] += k;     mx[p] = -INF;     for (int i = 0; i < sz[p]; ++i) mx[p] = max(mx[p], num[p][i]);   }   int query() {     int p = (N - 1) / T;     while (p >= 0 && mx[p] <= 0) p--;     if (p < 0) return -1;     upd(p);     int x = sz[p] - 1;     while (num[p][x] <= 0) x--;     return A[p * T + x];   }   int main() {     scanf( %d , &N);     int p = (N - 1) / T;     for (int i = 0; i < p; ++i) sz[i] = T;     sz[p] = (N - 1) % T + 1;     for (int i = 0; i < N; ++i) {       int a, b, c;       scanf( %d%d , &a, &b);       if (b) {         scanf( %d , &c);         A[a - 1] = c;         ins(a - 1, 1);         printf( %d n , query());       } else {         ins(a - 1, -1);         printf( %d n , query());       }     }     return 0;   }   