func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxh = 200 * 1000 + 5;   struct item {     int pos, hash;     item(int pos, int hash) : pos(pos), hash(hash) {}   };   bool operator<(item a, item b) { return a.pos < b.pos; }   int n, m, h;   set<item> S[maxh];   map<int, int> M;   int pos[maxh];   int Len[maxh];   int Base[maxh];   bool used[maxh];   long long add(int x, int hash) {     int base = Base[hash];     set<item>::iterator it = S[base].lower_bound(item(pos[hash], hash));     if (it == S[base].end()) {       it = S[base].begin();     }     int nhash = it->hash;     M[x] = nhash;     S[base].erase(it);     long long res = pos[nhash] - pos[hash];     if (res < 0) {       res += Len[base];     }     return res;   }   void del(int x) {     int base = Base[M[x]];     S[base].insert(item(pos[M[x]], M[x]));   }   int main() {     scanf( %d%d%d , &h, &m, &n);     for (int i = 0; i < h; ++i) {       if (used[i]) {         continue;       }       for (int j = i, p = 0; !used[j]; j += m, j %= h, ++p) {         S[i].insert(item(p, j));         pos[j] = p;         Base[j] = i;         used[j] = 1;       }       Len[i] = (int)S[i].size();     }     long long res = 0;     for (int i = 0; i < n; ++i) {       char op;       int id;       scanf(  n%c %d , &op, &id);       if (op ==  + ) {         int hash;         scanf( %d , &hash);         res += add(id, hash);       } else {         del(id);       }     }     printf( %I64d n , res);     return 0;   }   