func_code_string: #include <bits/stdc++.h>   using namespace std;   const int size = 100004;   char s[size][4];   struct node {     int l, r, cnt;     long long sum[6];   } tree[size * 4];   int tmp[size], q[size];   void pushup(int rt) {     int i;     for (i = 0; i < 5; ++i)       tree[rt].sum[i] =           tree[rt << 1].sum[i] +           tree[rt << 1 | 1].sum[(i - tree[rt << 1].cnt % 5 + 5) % 5];     return;   }   void build(int rt, int l, int r) {     int i, mid;     tree[rt].l = l;     tree[rt].r = r;     tree[rt].cnt = 0;     if (l == r) return;     for (i = 0; i < 5; ++i) tree[rt].sum[i] = 0;     mid = (l + r) >> 1;     build(rt << 1, l, mid);     build(rt << 1 | 1, mid + 1, r);   }   void update(int pos, int cnt, int rt, int add) {     tree[rt].cnt += cnt;     if (tree[rt].l == tree[rt].r) {       tree[rt].sum[0] += (long long)add;       return;     } else {       if (pos <= tree[rt << 1].r)         update(pos, cnt, rt << 1, add);       else         update(pos, cnt, rt << 1 | 1, add);       pushup(rt);     }   }   int main() {     int n, cnt, i, j, pos;     while (scanf( %d , &n) != EOF) {       cnt = 0;       for (i = 0; i < n; ++i) {         scanf( %s , s[i]);         if (s[i][0] !=  s ) {           scanf( %d , &q[i]);           tmp[cnt++] = q[i];         }       }       if (cnt > 0) {         sort(tmp, tmp + cnt);         cnt = unique(tmp, tmp + cnt) - tmp;         build(1, 1, cnt);       }       for (i = 0; i < n; ++i) {         if (s[i][0] ==  s ) {           cout << tree[1].sum[2] << endl;         } else {           pos = lower_bound(tmp, tmp + cnt, q[i]) - tmp;           if (s[i][0] ==  a )             update(pos, 1, 1, q[i]);           else             update(pos, -1, 1, -q[i]);         }       }     }     return 0;   }   