func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   using vec = vector<T>;   template <typename Iter>   ostream &_IterOutput_(ostream &o, Iter b, Iter e, const string ss =   ,                         const string se =   ) {     o << ss;     for (auto it = b; it != e; it++) o << (it == b ?    :  ,  ) << *it;     return o << se;   }   template <typename T1, typename T2>   ostream &operator<<(ostream &o, const pair<T1, T2> &pair) {     return o <<  (  << pair.first <<  ,   << pair.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &o, const vector<T> &vec) {     return _IterOutput_(o, begin(vec), end(vec),  [ ,  ] );   }   template <typename T>   ostream &operator<<(ostream &o, const set<T> &st) {     return _IterOutput_(o, begin(st), end(st),  { ,  } );   }   template <typename T, size_t N>   ostream &operator<<(ostream &o, const array<T, N> &arr) {     return _IterOutput_(o, begin(arr), end(arr),  | ,  | );   }   template <typename T1, typename T2>   ostream &operator<<(ostream &o, const map<T1, T2> &mp) {     o <<  { ;     for (auto it = mp.begin(); it != mp.end(); it++) {       o << (it == mp.begin() ?    :  ,  ) << it->first <<  :  << it->second;     }     o <<  } ;     return o;   }   void lucky_test() {     std::random_device rd;     std::mt19937 gen_(rd());     std::normal_distribution<double> dist_(0.0, 1.0);     if (dist_(gen_) >= 4.44444444) {       cout <<  Not lucky  << endl;       exit(0);     }   }   int N;   const int MX = 131072 * 4;   const int INF = 1e9;   int ZZ = 0;   struct Seg {     int val[MX];     int nl[MX], nr[MX];     int lz[MX];     void init(int id, int ql, int qr) {       nl[id] = ql;       nr[id] = qr;       val[id] = -INF;       if (ql == qr - 1) {         return;       }       int md = (ql + qr) / 2;       init(id * 2, ql, md);       init(id * 2 + 1, md, qr);     }     void push(int id) {       ZZ++;       int l = nl[id], r = nr[id];       int v = lz[id];       lz[id] = 0;       if (l == r - 1) {         return;       }       adj(id * 2, v);       adj(id * 2 + 1, v);       return;     }     void pull(int id) {       ZZ++;       int l = nl[id], r = nr[id];       if (l == r - 1) return;       val[id] = max(val[id * 2], val[id * 2 + 1]);     }     void adj(int id, int v) {       lz[id] += v;       val[id] += v;     }     void add(int id, int ql, int qr, int v) {       push(id);       int l = nl[id], r = nr[id];       if (l == ql and r == qr) {         adj(id, v);         return;       }       int md = (l + r) / 2;       if (qr <= md)         add(id * 2, ql, qr, v);       else if (ql >= md)         add(id * 2 + 1, ql, qr, v);       else {         add(id * 2, ql, md, v);         add(id * 2 + 1, md, qr, v);       }       pull(id);     }     int walk(int id) {       push(id);       if (val[id] < 0) return -1;       int l = nl[id], r = nr[id];       if (l == r - 1) {         return val[id] >= 0 ? l : -1;       }       if (val[id * 2 + 1] >= 0)         return walk(id * 2 + 1);       else         return walk(id * 2);     }   } tree;   struct Hao {     int val[MX];     int n;     void init(int id, int l, int r) {       n = r;       for (int i = l; i < r; i++) val[i] = -INF;     }     void add(int id, int l, int r, int v) {       for (int i = l; i < r; i++) val[i] += v;     }     int walk(int id) {       for (int i = n - 1; i >= 0; i--)         if (val[i] >= 0) return i;       return -1;     }     void dmp() {       for (int i = 0; i < n; i++) cout << val[i] <<    ;       cout << endl;     }   };   int V[MX];   int32_t main() {     do {       ios_base::sync_with_stdio(0);       cin.tie(0);     } while (0);     cin >> N;     tree.init(1, 0, N + 5);     for (int i = 0; i < N; i++) {       int p, t;       cin >> p >> t;       if (t == 0) {         tree.add(1, 0, p, -1);       } else {         cin >> V[p];         tree.add(1, p, p + 1, INF);         tree.add(1, 0, p, 1);       }       int pos = tree.walk(1);       if (pos == -1)         cout << -1 <<   n ;       else         cout << V[pos] <<   n ;     }     return 0;   }   