func_code_string: #include <bits/stdc++.h>   using namespace std;   int const inf = 1000 * 1000 * 1000;   long long const inf64 = 1ll * inf * inf;   struct Fenwick {     int n;     vector<long long> fen;     Fenwick() { n = 0; }     Fenwick(int nn) {       n = nn;       fen.resize(n + 1);     }     void put(int pos, int val) {       for (int cur = pos; cur <= n; cur |= (cur + 1)) fen[cur] += val;     }     long long get(int pos) {       long long res = 0;       for (int cur = pos; cur > 0; cur = (cur & (cur + 1)) - 1) res += fen[cur];       return res;     }     long long get(int l, int r) { return get(r) - get(l - 1); }   };   bool solve() {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     vector<vector<pair<pair<int, int>, int> > > add(m + 1);     for (int i = 1; i <= m; i++) add[i].reserve(n);     for (int len, i, j, w, iter = 0; iter < k; iter++) {       scanf( %d , &len);       for (int iter2 = 0; iter2 < len; iter2++) {         scanf( %d %d %d , &i, &j, &w);         add[j].push_back({{i, w}, iter});       }     }     int q;     scanf( %d , &q);     vector<char> type(q);     vector<int> sw(q);     vector<pair<int, int> > ask(q);     vector<vector<long long> > res(2005, vector<long long>(k));     vector<vector<int> > era(m + 1), ins(m + 1);     vector<int> ide(q);     char buffer[10];     for (int i, x1, y1, x2, y2, iter = 0; iter < q; iter++) {       scanf( %s , buffer);       if (string(buffer) ==  SWITCH ) {         scanf( %d , &i);         type[iter] = 0;         sw[iter] = i - 1;       } else {         scanf( %d %d %d %d , &x1, &y1, &x2, &y2);         type[iter] = 1;         ask[iter] = {x1, x2};         ins[y1].push_back(iter);         era[y2].push_back(iter);         static int rectange_size = 0;         ide[iter] = rectange_size++;       }     }     vector<Fenwick> fen(k, Fenwick(n));     for (int pos, value, id, l, r, j = 1; j <= m; j++) {       for (int iter : ins[j]) {         tie(l, r) = ask[iter];         for (int kk = 0; kk < k; kk++) {           res[ide[iter]][kk] -= fen[kk].get(l, r);         }       }       for (auto _iter : add[j]) {         tie(pos, value) = _iter.first;         id = _iter.second;         fen[id].put(pos, value);       }       for (int iter : era[j]) {         tie(l, r) = ask[iter];         for (int kk = 0; kk < k; kk++) {           res[ide[iter]][kk] += fen[kk].get(l, r);         }       }     }     vector<char> state(k, 1);     for (int iter = 0; iter < q; iter++) {       if (type[iter] == 0) {         state[sw[iter]] ^= 1;       } else {         long long result = 0;         for (int i = 0; i < k; i++) {           if (state[i]) result += res[ide[iter]][i];         }         printf( %I64d n , result);       }     }     return true;   }   int main() {     solve();     return 0;   }   