func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using ull = unsigned long long;   using pii = pair<int, int>;   using C = complex<double>;   const double PI = 3.14159265;   const double eps = 1e-8;   const int N = 1 << 17;   const int M = 1e9 + 7;   const int inf = 1e9 + 7;   const ll INF = 1e18;   ll pw(ll a, ll b) {     ll t = 1;     a %= M;     for (; b; b >>= 1) {       if (b & 1) {         t = t * a % M;       }       a = a * a % M;     }     return t;   }   ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }   int n;   int num[N];   int mx[N << 1];   int seg[N << 1];   int find() {     int u = 1, w = 0;     while (u < N) {       if (mx[u << 1 | 1] + w > 0) {         u = u << 1 | 1;       } else {         w += seg[u << 1 | 1];         u <<= 1;       }     }     return u - N;   }   void add(int p, int v) {     p += N;     seg[p] += v;     mx[p] = seg[p] == 1;     for (p >>= 1; p; p >>= 1) {       seg[p] = seg[p << 1] + seg[p << 1 | 1];       mx[p] = max(mx[p << 1 | 1], mx[p << 1] + seg[p << 1 | 1]);     }   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     int p, t, x;     for (int i = 0; i < n; i++) {       cin >> p >> t;       if (t == 1) {         cin >> num[p];         add(p, 1);       } else {         add(p, -1);       }       int ps = find();       if (mx[1] <= 0) {         puts( -1 );       } else {         printf( %d n , num[ps]);       }     }   }   