func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 4e18;   const long double pai = acos(-1);   int n, q, ans;   set<pair<pair<int, int>, int> > s;   int main() {     scanf( %d%d , &n, &q);     ans = n;     s.insert({{1, n}, 1});     while (q--) {       int l, r, x;       scanf( %d%d%d , &l, &r, &x), x--;       auto it = s.lower_bound({{l, -1}, -1});       if (it == s.end() || it->first.first > l) it--;       vector<pair<pair<int, int>, int> > add;       while (it != s.end()) {         int L = it->first.first, R = it->first.second, old = it->second;         if (L < l) add.push_back({{L, l - 1}, old});         if (R > r) add.push_back({{r + 1, R}, old});         it = s.erase(it);         ans -= (R - L + 1) * old;         if (it == s.end() || it->first.first > r) break;       }       for (auto u : add) {         int L = u.first.first, R = u.first.second, old = u.second;         ans += (R - L + 1) * old;         s.insert(u);       }       s.insert({{l, r}, x});       ans += (r - l + 1) * x;       printf( %d n , ans);     }   }   