func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = (1ll << 45);   long long bit[1000006];   void update(long long from, long long val) {     for (long long i = from; i < 1000006; i += i & -i) bit[i] += val;   }   long long query(long long from) {     if (from == 0) return 0;     long long cnt = 0;     for (long long i = from; i > 0; i -= i & -i) cnt += bit[i];     return cnt;   }   long long query(long long l, long long r) { return query(r) - query(l - 1); }   struct Node {     Node *lc, *rc;     long long mx, tag;     Node() : lc(NULL), rc(NULL), mx(-INF), tag(0) {}     void pull() { mx = max(lc->mx, rc->mx); }   };   const long long N = 1000002;   Node* Build(long long L, long long R) {     Node* node = new Node();     if (L == R) {       node->mx = -N + L;       return node;     }     long long mid = (L + R) >> 1;     node->lc = Build(L, mid);     node->rc = Build(mid + 1, R);     node->pull();     return node;   }   void push(Node* node, long long L, long long R) {     if (L == R) node->tag = 0;     if (node->tag == 0) return;     node->lc->mx += node->tag;     node->rc->mx += node->tag;     node->lc->tag += node->tag;     node->rc->tag += node->tag;     node->tag = 0;     return;   }   void modify(Node* node, long long L, long long R, long long l, long long r,               long long val) {     if (l > R || L > r)       return;     else if (l <= L && R <= r) {       node->mx += val;       node->tag += val;       return;     }     push(node, L, R);     long long mid = (L + R) >> 1;     modify(node->lc, L, mid, l, r, val);     modify(node->rc, mid + 1, R, l, r, val);     node->pull();     return;   }   long long query(Node* node, long long L, long long R, long long l,                   long long r) {     if (l > R || L > r)       return -INF;     else if (l <= L && R <= r)       return node->mx;     push(node, L, R);     long long mid = (L + R) >> 1;     return max(query(node->lc, L, mid, l, r), query(node->rc, mid + 1, R, l, r));   }   long long n, x[N][2];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     Node* root = Build(1, N);     string in;     long long v1, v2;     for (long long i = 1; i < n + 1; ++i) {       cin >> in;       if (in ==  ? ) {         cin >> v1;         cout << query(root, 1, N, 1, v1) + (N - v1) - query(v1 + 1, 1000006 - 1)              <<   n ;       } else if (in ==  + ) {         cin >> v1 >> v2;         x[i][0] = v1;         x[i][1] = v2;         modify(root, 1, N, 1, x[i][0], x[i][1]);         update(v1, v2);       } else if (in ==  - ) {         cin >> v1;         modify(root, 1, N, 1, x[v1][0], -x[v1][1]);         update(x[v1][0], -x[v1][1]);       }     }     return 0;   }   