func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 100;   char s[N];   int n, m, t[N];   int a[N * 4], b[N * 4], ab[N * 4], ba[N * 4], aba[N * 4], tag[N * 4];   void pushup(int now) {     a[now] = max(a[(now << 1)], a[(now << 1 | 1)]);     b[now] = min(b[(now << 1)], b[(now << 1 | 1)]);     ab[now] = max(ab[(now << 1)],                   max(ab[(now << 1 | 1)], a[(now << 1)] - 2 * b[(now << 1 | 1)]));     ba[now] = max(ba[(now << 1)],                   max(ba[(now << 1 | 1)], a[(now << 1 | 1)] - 2 * b[(now << 1)]));     aba[now] = max(max(aba[(now << 1)], aba[(now << 1 | 1)]),                    max(ab[(now << 1)] + a[(now << 1 | 1)],                        ba[(now << 1 | 1)] + a[(now << 1)]));   }   void build(int now, int l, int r) {     if (l + 1 == r) {       a[now] = b[now] = t[l];       ab[now] = ba[now] = -t[l];       return;     }     int mid = (l + r) >> 1;     build((now << 1), l, mid);     build((now << 1 | 1), mid, r);     pushup(now);   }   void down(int now, int val) {     a[now] += val;     b[now] += val;     ab[now] -= val;     ba[now] -= val;     tag[now] += val;   }   void pushdown(int now) {     down((now << 1), tag[now]);     down((now << 1 | 1), tag[now]);     tag[now] = 0;   }   void Insert(int now, int l, int r, int a, int b, int val) {     if (a <= l && b >= r - 1) {       down(now, val);       return;     }     int mid = (l + r) >> 1;     pushdown(now);     if (a < mid) Insert((now << 1), l, mid, a, b, val);     if (b >= mid) Insert((now << 1 | 1), mid, r, a, b, val);     pushup(now);   }   int main() {     int x, y, z;     scanf( %d%d , &n, &m);     n = n * 2 - 2;     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i)       if (s[i] ==  ( )         t[i] = t[i - 1] + 1;       else         t[i] = t[i - 1] - 1;     build(1, 1, n + 1);     printf( %d n , aba[1]);     for (int i = 0; i < m; ++i) {       scanf( %d%d , &x, &y);       if (x > y) swap(x, y);       if (s[x] ==  ( )         z = -2;       else         z = 2;       Insert(1, 1, n + 1, x, y - 1, z);       swap(s[x], s[y]);       printf( %d n , aba[1]);     }     return 0;   }   