func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline void amin(T &x, const T &y) {     if (y < x) x = y;   }   template <class T>   inline void amax(T &x, const T &y) {     if (x < y) x = y;   }   template <class Iter>   void rprintf(const char *fmt, Iter begin, Iter end) {     for (bool sp = 0; begin != end; ++begin) {       if (sp)         putchar(   );       else         sp = true;       printf(fmt, *begin);     }     putchar(  n );   }   int N;   int A[200011];   int B[200011];   using Tuple = tuple<int, int, int>;   Tuple X[100011];   void MAIN() {     scanf( %d , &N);     for (int i = 0, i_len = (N); i < i_len; ++i) scanf( %d , A + i);     int Q;     scanf( %d , &Q);     vector<Tuple> sortedX;     sortedX.reserve(Q);     for (int i = 0, i_len = (Q); i < i_len; ++i) {       int s, t, u;       scanf( %d%d%d , &s, &t, &u);       s--;       u--;       X[i] = Tuple(s, t, u);       sortedX.emplace_back(s, t, -1);     }     sort(sortedX.begin(), sortedX.end());     sortedX.erase(unique(sortedX.begin(), sortedX.end()), sortedX.end());     long long sum = 0;     for (int i = 0, i_len = (N); i < i_len; ++i) sum += A[i];     for (int i = 0, i_len = (Q); i < i_len; ++i) {       int s, t, u;       tie(s, t, u) = X[i];       auto it = lower_bound(sortedX.begin(), sortedX.end(), Tuple(s, t, -1));       int s0, t0, u0;       tie(s0, t0, u0) = *it;       if (0 <= u0) {         sum -= max(0, A[u0] - B[u0]);         B[u0]--;         sum += max(0, A[u0] - B[u0]);       }       if (0 <= u) {         sum -= max(0, A[u] - B[u]);         B[u]++;         sum += max(0, A[u] - B[u]);       }       *it = Tuple(s, t, u);       printf( %lld n , sum);     }   }   int main() {     int TC = 1;     for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();     return 0;   }   