func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int lb, rb, l_max, r_max, s_max;   };   int n, m, l, r, k, offset = 1 << 19, a[300004], z, t;   long long d[600004];   node trn[1100000];   int sgn(long long x) {     if (x > 0) return 1;     if (x < 0) return -1;     return 0;   }   void update(int pos) {     if (pos < 0) return;     if (d[pos + 1] == 0) {       trn[pos + offset].l_max = 0;       trn[pos + offset].r_max = 0;       trn[pos + offset].s_max = 0;     } else {       trn[pos + offset].l_max = 1;       trn[pos + offset].r_max = 1;       trn[pos + offset].s_max = 1;     }     pos = (pos + offset) >> 1;     while (pos > 0) {       z = 2 * pos;       trn[pos].s_max = max(trn[z].s_max, trn[z + 1].s_max);       trn[pos].l_max = trn[z].l_max;       trn[pos].r_max = trn[z + 1].r_max;       if (sgn(d[trn[z].rb]) >= sgn(d[trn[z + 1].lb])) {         int len = trn[z].r_max + trn[z + 1].l_max;         trn[pos].s_max = max(len, trn[pos].s_max);         if (trn[z].l_max == trn[z].rb - trn[z].lb + 1)           trn[pos].l_max += trn[z + 1].l_max;         if (trn[z + 1].r_max == trn[z + 1].rb - trn[z + 1].lb + 1)           trn[pos].r_max += trn[z].r_max;       }       pos = pos >> 1;     }   }   int readInt() {     bool mnus = false;     int result = 0;     char ch;     ch = getchar();     while (true) {       if (ch ==  - ) break;       if (ch >=  0  && ch <=  9 ) break;       ch = getchar();     }     if (ch ==  - )       mnus = true;     else       result = ch -  0 ;     while (true) {       ch = getchar();       if (ch <  0  || ch >  9 ) break;       result = result * 10 + (ch -  0 );     }     if (mnus)       return -result;     else       return result;   }   int main() {     std::ios::sync_with_stdio(false);     n = readInt();     for (int i = 1; i <= n; ++i) a[i] = readInt();     for (int i = 1; i < n; ++i) d[i] = a[i + 1] - a[i];     for (int i = 0; i < offset; ++i) {       trn[i + offset].lb = i + 1;       trn[i + offset].rb = i + 1;       if (d[i + 1] == 0) {         trn[i + offset].l_max = 0;         trn[i + offset].r_max = 0;         trn[i + offset].s_max = 0;       } else {         trn[i + offset].l_max = 1;         trn[i + offset].r_max = 1;         trn[i + offset].s_max = 1;       }     }     for (int i = offset - 1; i >= 1; --i) {       t = 2 * i;       trn[i].lb = trn[t].lb;       trn[i].rb = trn[t + 1].rb;       trn[i].s_max = max(trn[t].s_max, trn[t + 1].s_max);       trn[i].l_max = trn[t].l_max;       trn[i].r_max = trn[t + 1].r_max;       if (sgn(d[trn[t].rb]) >= sgn(d[trn[t + 1].lb])) {         int len = trn[t].r_max + trn[t + 1].l_max;         trn[i].s_max = max(len, trn[i].s_max);         if (trn[t].l_max == trn[t].rb - trn[t].lb + 1)           trn[i].l_max += trn[t + 1].l_max;         if (trn[t + 1].r_max == trn[t + 1].rb - trn[t + 1].lb + 1)           trn[i].r_max += trn[t].r_max;       }     }     m = readInt();     for (int i = 0; i < m; ++i) {       l = readInt();       r = readInt();       k = readInt();       d[l - 1] += k;       d[r] -= k;       d[0] = 0;       d[n] = 0;       update(l - 2);       update(r - 1);       cout << trn[1].s_max + 1 << endl;     }     return 0;   }   