func_code_string: #include <bits/stdc++.h>   using namespace std;   struct __timestamper {};   struct change {     int s, t, u;   };   vector<long long> solve(vector<int> a, vector<change> b) {     long long sum = 0;     for (auto x : a) sum += x;     vector<long long> ans;     int n = a.size();     vector<int> cntr(n);     auto change_counter = [&](int i, int delta) {       sum -= max(0, a[i] - cntr[i]);       cntr[i] += delta;       sum += max(0, a[i] - cntr[i]);     };     map<pair<int, int>, int> mp;     for (auto c : b) {       auto it = mp.find({c.s, c.t});       if (it != mp.end()) {         change_counter(it->second, -1);         mp.erase(it);       }       if (c.u != -1) {         mp[{c.s, c.t}] = c.u;         change_counter(c.u, +1);       }       ans.push_back(sum);     }     return ans;   }   int main() {     int n;     while (scanf( %d , &n) == 1) {       vector<int> a(n);       for (int i = 0; i < n; i++) {         scanf( %d , &a[i]);       }       int q;       scanf( %d , &q);       vector<change> b(q);       for (int i = 0; i < q; i++) {         scanf( %d%d%d , &b[i].s, &b[i].t, &b[i].u);         b[i].s--;         b[i].u--;       }       auto ans = solve(a, b);       for (auto x : ans) printf( %lld n , x);     }     return 0;   }   