func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 20;   int h[maxn], n, q, cnt;   string s;   struct Node {     int ans, mx, mn, l, r, lazy;     Node(int a = 0) { ans = mn = mx = l = r = lazy = a; }     void update(Node a, Node b) {       ans = max({a.ans, b.ans, a.l + b.mx, b.r + a.mx});       mx = max({a.mx, b.mx});       mn = min({a.mn, b.mn});       l = max({a.l, b.l, a.mx - 2 * b.mn});       r = max({a.r, b.r, b.mx - 2 * a.mn});     }   } sg[4 * maxn];   void add(int qval, int id) {     sg[id].l -= qval;     sg[id].r -= qval;     sg[id].mn += qval;     sg[id].mx += qval;     sg[id].lazy += qval;   }   void shift(int id) {     add(sg[id].lazy, id * 2);     add(sg[id].lazy, id * 2 + 1);     sg[id].lazy = 0;   }   void update(int l, int r, int ql, int qr, int qval, int id) {     if (l >= ql && r <= qr)       add(qval, id);     else if (l > qr || r < ql)       return;     else {       int mid = (l + r) / 2;       shift(id);       update(l, mid, ql, qr, qval, id * 2);       update(mid + 1, r, ql, qr, qval, id * 2 + 1);       sg[id].update(sg[id * 2], sg[id * 2 + 1]);     }   }   void build(int l, int r, int id) {     if (l == r) {       sg[id].mn = sg[id].mx = h[r];       sg[id].l = sg[id].r = -h[r];     } else {       int mid = (l + r) / 2;       build(l, mid, id * 2);       build(mid + 1, r, id * 2 + 1);       sg[id].update(sg[id * 2], sg[id * 2 + 1]);     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> q >> s;     for (int i = 0; i < 2 * n - 2; i++) {       if (s[i] ==  ( )         cnt++;       else         cnt--;       h[i + 2] = cnt;     }     build(1, 2 * n - 1, 1);     int a, b, tmp;     cout << sg[1].ans << endl;     while (q--) {       cin >> a >> b;       if (a > b) swap(a, b);       tmp = 0;       if (s[a - 1] ==  (  && s[b - 1] ==  ) ) tmp = -2;       if (s[a - 1] ==  )  && s[b - 1] ==  ( ) tmp = 2;       update(1, 2 * n - 1, a + 1, b, tmp, 1);       cout << sg[1].ans << endl;       swap(s[a - 1], s[b - 1]);     }   }   