func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)2e5 + 10;   vector<pair<int, int> > a, b;   vector<int> L;   int n, m, q[MAXN], id[MAXN], Tohka[MAXN], l[MAXN], r[MAXN], t[MAXN], fa[MAXN],       T[MAXN];   bool cmp(int first, int second) { return q[first] < q[second]; }   bool cmp1(int first, int second) { return t[first] < t[second]; }   int Getp(int a) { return lower_bound(L.begin(), L.end(), a) - L.begin(); }   int getf(int first) {     if (fa[first] == first) return first;     fa[first] = getf(fa[first]);     return fa[first];   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       scanf( %d%d%d , &l[i], &r[i], &t[i]);       L.push_back(l[i]), L.push_back(r[i]);       id[i] = i;     }     sort(L.begin(), L.end());     L.erase(unique(L.begin(), L.end()), L.end());     for (int i = 0; i < ((int)(L).size()); ++i) fa[i] = i;     sort(id + 1, id + m + 1, cmp1);     memset(T, -1, sizeof(T));     for (int i = 1; i <= m; ++i) {       int tl = Getp(l[id[i]]), tr = Getp(r[id[i]]), tT = t[id[i]];       for (tl = getf(tl); tl < tr; T[tl] = tT, fa[tl] = tl + 1, tl = getf(tl))         ;     }     for (int i = 0; i + 1 < ((int)(L).size()); ++i) {       int l = L[i], r = L[i + 1], t = T[i];       if (T[i] == -1) continue;       a.push_back(make_pair(t - r, 1)), a.push_back(make_pair(t - l, -1));       b.push_back(make_pair(t - r, -(t - r))),           b.push_back(make_pair(t - l, (t - r)));       b.push_back(make_pair(t - l, (r - l)));     }     sort(a.begin(), a.end());     sort(b.begin(), b.end());     for (int i = 1; i <= n; ++i) scanf( %d , &q[i]), id[i] = i;     sort(id + 1, id + n + 1, cmp);     long long s1 = 0, s2 = 0;     for (int i = 1, p1 = 0, p2 = 0; i <= n; ++i) {       for (; p1 < ((int)(a).size()) && a[p1].first <= q[id[i]];            s1 += a[p1].second, ++p1)         ;       for (; p2 < ((int)(b).size()) && b[p2].first <= q[id[i]];            s2 += b[p2].second, ++p2)         ;       Tohka[id[i]] = s1 * q[id[i]] + s2;     }     for (int i = 1; i <= n; ++i) printf( %d n , Tohka[i]);     fclose(stdin);     fclose(stdout);     return 0;   }   