func_code_string: #include <bits/stdc++.h>   using namespace std;   int H, M, N;   set<int> a[200005];   int p[200005], seq[200005], r = 0;   int u[200005];   map<int, pair<int, int> > history;   void release(pair<int, int> P) { a[P.first].insert(P.second); }   int main(void) {     scanf( %d%d%d , &H, &M, &N);     for (int i = 0; i < H; i++) {       if (!u[i]) {         for (int c = 0, j = i; !u[j]; j = (j + M) % H, ++c) {           p[j] = r;           seq[j] = c;           a[r].insert(c);           u[j] = 1;         }         ++r;       }     }     long long ans = 0;     while (N--) {       char x[10];       int id, hash;       scanf( %s%d , x, &id);       if (x[0] ==  - )         release(history[id]);       else {         scanf( %d , &hash);         hash %= H;         int A = p[hash], B = seq[hash];         set<int>::iterator it = a[A].lower_bound(B);         if (it == a[A].end()) {           it = a[A].begin();           ans += *it + H / r - B;         } else {           ans += *it - B;         }         history[id] = make_pair(A, *it);         a[A].erase(it);       }     }     printf( %I64d n , ans);     return 0;   }   