func_code_string: #include <bits/stdc++.h>   using namespace std;   const int sz = 4e6 + 50;   int n, m;   string str;   int s[sz], e[sz], four[sz], seven[sz], non_dec[sz], non_inc[sz];   vector<bool> lazy(sz, 0);   void calculate(int node) {     int lc = node * 2;     int rc = lc + 1;     int f1 = four[lc], s1 = seven[lc], nd1 = non_dec[lc], ni1 = non_inc[lc];     int f2 = four[rc], s2 = seven[rc], nd2 = non_dec[rc], ni2 = non_inc[rc];     if (lazy[lc]) {       swap(f1, s1);       swap(nd1, ni1);     }     if (lazy[rc]) {       swap(f2, s2);       swap(nd2, ni2);     }     four[node] = f1 + f2;     seven[node] = s1 + s2;     non_dec[node] = max(f1 + nd2, nd1 + s2);     non_inc[node] = max(s1 + ni2, ni1 + f2);   }   void modify(int node) {     int lc = node * 2;     int rc = lc + 1;     four[node] = four[lc] + four[rc];     seven[node] = seven[lc] + seven[rc];     non_dec[node] = max(four[lc] + non_dec[rc], non_dec[lc] + seven[rc]);     non_inc[node] = max(seven[lc] + non_inc[rc], non_inc[lc] + four[rc]);   }   void lazyPropagation(int node) {     if (lazy[node]) {       lazy[2 * node] = !lazy[2 * node];       lazy[2 * node + 1] = !lazy[2 * node + 1];     }     lazy[node] = 0;   }   void build(int node, int l, int r) {     s[node] = l;     e[node] = r;     if (l == r) {       if (str[l] ==  4 ) {         four[node] = 1;         seven[node] = 0;         non_dec[node] = 1;         non_inc[node] = 1;       } else {         four[node] = 0;         seven[node] = 1;         non_dec[node] = 1;         non_inc[node] = 1;       }       return;     }     int mid = (l + r) / 2;     build(2 * node, l, mid);     build(2 * node + 1, mid + 1, r);     modify(node);   }   void update(int node, int l, int r) {     if (s[node] > r || e[node] < l) return;     if (l <= s[node] && e[node] <= r) {       lazy[node] = !lazy[node];       return;     }     lazyPropagation(node);     update(2 * node, l, r);     update(2 * node + 1, l, r);     calculate(node);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string tt;     int x, y;     cin >> n >> m;     cin >> str;     str =  0  + str;     build(1, 1, n);     while (m--) {       cin >> tt;       if (tt[0] ==  c ) {         if (!lazy[1])           cout << non_dec[1] <<   n ;         else           cout << non_inc[1] <<   n ;       } else {         cin >> x >> y;         update(1, x, y);       }     }     return 0;   }   