func_code_string: #include <bits/stdc++.h>   using namespace std;   struct ii {     string zl;     int x, id;   } zl[1000005];   bool cmp1(ii a, ii b) {     if (a.x < b.x) return 1;     if (a.x > b.x) return 0;     return a.zl < b.zl;   }   bool cmp2(ii a, ii b) { return a.id < b.id; }   int n, cnt, zhi[1000005], sz[1000005], i;   long long sum[1000005][5], ans;   map<int, int> mp;   void update(int id, int le, int ri, int pos) {     sz[id]++;     if (le == pos && ri == pos) {       sum[id][1] += zhi[pos];       return;     }     if (pos > (le + ri) / 2)       update(id * 2 + 1, (le + ri) / 2 + 1, ri, pos);     else       update(id * 2, le, (le + ri) / 2, pos);     int i;     for (i = 0; i < 5; i++) {       sum[id][i] =           sum[id * 2][i] + sum[id * 2 + 1][((i - sz[id * 2] % 5) + 5) % 5];     }   }   void erase(int id, int le, int ri, int pos) {     sz[id]--;     if (le == pos && ri == pos) {       sum[id][1] -= zhi[pos];       return;     }     if (pos > (le + ri) / 2)       erase(id * 2 + 1, (le + ri) / 2 + 1, ri, pos);     else       erase(id * 2, le, (le + ri) / 2, pos);     int i;     for (i = 0; i < 5; i++) {       sum[id][i] =           sum[id * 2][i] + sum[id * 2 + 1][((i - sz[id * 2] % 5) + 5) % 5];     }   }   int main() {     ios::sync_with_stdio(0);     cin >> n;     for (i = 1; i <= n; i++) {       cin >> zl[i].zl;       if (zl[i].zl[0] ==  s )         zl[i].x = 0;       else         cin >> zl[i].x;       zl[i].id = i;     }     sort(zl + 1, zl + n + 1, cmp1);     cnt = 1;     for (i = 1; i <= n; i++) {       if (zl[i].zl[0] ==  a ) {         if (!mp[zl[i].x]) mp[zl[i].x] = cnt++;         zhi[mp[zl[i].x]] = zl[i].x;         zl[i].x = mp[zl[i].x];       } else if (zl[i].zl[0] ==  d ) {         zl[i].x = mp[zl[i].x];       }     }     sort(zl + 1, zl + n + 1, cmp2);     for (i = 1; i <= n; i++) {       if (zl[i].zl ==  add ) update(1, 1, cnt, zl[i].x);       if (zl[i].zl ==  del ) erase(1, 1, cnt, zl[i].x);       if (zl[i].zl ==  sum ) cout << sum[1][3] << endl;     }     return 0;   }   