func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   struct row {     long long base, limit;     row(long long t = 0, long long d = 0) : base(t + d), limit(t) {}     long long push(long long t) const {       return t <= limit ? base : base + (t - limit);     }     row operator*(const row &o) const {       row ans;       ans.base = o.push(base);       ans.limit = limit;       if (o.limit > base) ans.limit += o.limit - base;       return ans;     }   };   struct query {     char op;     int t, d;   } qs[N];   row ZERO(0, 0);   row st[1 << 20];   vector<int> ts;   int sz;   void init() {     for (int i = sz - 1; i >= 1; i--) st[i] = st[i + i] * st[i + i + 1];   }   void upd(int t, int d) {     int pos = lower_bound(ts.begin(), ts.end(), t) - ts.begin();     int u = sz + pos;     st[u] = row(t, d);     while (u > 1) {       u /= 2;       st[u] = st[u + u] * st[u + u + 1];     }   }   void del(int t) {     int pos = lower_bound(ts.begin(), ts.end(), t) - ts.begin();     int u = sz + pos;     st[u] = ZERO;     while (u > 1) {       u /= 2;       st[u] = st[u + u] * st[u + u + 1];     }   }   long long query(long long t) {     int l = 0, r = upper_bound(ts.begin(), ts.end(), t) - ts.begin();     l += sz;     r += sz;     auto L = ZERO, R = ZERO;     while (l < r) {       if (l & 1) L = L * st[l++];       if (r & 1) R = st[--r] * R;       l /= 2;       r /= 2;     }     return max(0LL, (L * R).push(0) - t);   }   int main() {     int q;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> qs[i].op >> qs[i].t;       if (qs[i].op ==  + ) {         cin >> qs[i].d;         ts.push_back(qs[i].t);       }     }     sort(ts.begin(), ts.end());     ts.erase(unique(ts.begin(), ts.end()), ts.end());     sz = ts.size();     while (sz & (sz - 1)) sz++;     fill_n(st, sz, ZERO);     for (int i = 0; i < q; i++) {       auto qi = qs[i];       if (qi.op ==  + )         upd(qi.t, qi.d);       else if (qi.op ==  - ) {         auto prev = qs[qi.t - 1];         del(prev.t);       } else         cout << query(qi.t) <<   n ;     }     return 0;   }   