func_code_string: #include <bits/stdc++.h>   using namespace std;   void maximize(int &a, int b) { a = max(a, b); }   int absolut(int x) {     if (x < 0) return -x;     return x;   }   const int tope = 1 << 19;   const int first = 1 << 18;   struct elem {     int ls, lH, lh, lb;     int rs, rH, rh, rb;     int sol;   };   elem v[tope];   void recompute(int pos) {     elem &e = v[pos];     elem &e0 = v[2 * pos];     elem &e1 = v[2 * pos + 1];     e.ls = e0.ls + e1.ls;     e.lH = max(e0.lH, e0.ls + e1.lH);     e.lh = min(e0.lh, e0.ls + e1.lh);     e.lb = max(e0.lb, -e0.ls + e1.lb);     if (e0.lh < e0.ls + e1.lH) maximize(e.lb, -2 * e0.lh + e0.ls + e1.lH);     e.rs = e0.rs + e1.rs;     e.rH = max(e1.rH, e0.rH + e1.rs);     e.rh = min(e1.rh, e0.rh + e1.rs);     e.rb = max(e1.rb, e0.rb - e1.rs);     if (e1.rh < e0.rH + e1.rs) maximize(e.rb, -2 * e1.rh + e1.rs + e0.rH);     e.sol = max(max(e0.sol, e1.sol), max(e0.rb + e1.lH, e0.rH + e1.lb));   }   void insert(int pos, int val) {     pos += first;     elem &e = v[pos];     e.ls = val;     e.lH = max(0, val);     e.lh = min(0, val);     e.lb = absolut(val);     val *= -1;     e.rs = val;     e.rH = max(0, val);     e.rh = min(0, val);     e.rb = absolut(val);     e.sol = absolut(val);     while (pos > 1) {       pos /= 2;       recompute(pos);     }   }   int n, cases;   string s;   void insert(int pos) { insert(pos, s[pos] ==  (  ? 1 : -1); }   int main() {     cin >> n >> cases >> s;     s =     + s;     for (int i = 1; i < int(s.size()); i++) insert(i);     cout << v[1].sol << endl;     for (int cas = 0; cas < cases; cas++) {       int pos0, pos1;       cin >> pos0 >> pos1;       swap(s[pos0], s[pos1]);       insert(pos0);       insert(pos1);       cout << v[1].sol << endl;     }   }   