func_code_string: #include <iostream>   #include <algorithm>   using namespace std;      int INF = 2e9;      int pre[200001];   struct node{       int l, r, max, min;   } segtree[800001];      void build(int ind, int l, int r){       if (l == r){           segtree[ind] = (node){l, r, pre[l], pre[l]};       } else {           build(2*ind, l, (l+r)/2);           build(2*ind+1, (l+r)/2+1, r);           segtree[ind] = (node){l, r, max(segtree[2*ind].max, segtree[2*ind+1].max),                min(segtree[2*ind].min, segtree[2*ind+1].min)};       }   }      int find_min(int ind, int l, int r){       if (segtree[ind].l >= l && segtree[ind].r <= r) return segtree[ind].min;       if (segtree[ind].r < l || segtree[ind].l > r) return INF;       return min(find_min(ind*2, l, r), find_min(ind*2+1,l,r));   }         int find_max(int ind, int l, int r){       if (segtree[ind].l >= l && segtree[ind].r <= r) return segtree[ind].max;       if (segtree[ind].r < l || segtree[ind].l > r) return -INF;       return max(find_max(ind*2, l, r), find_max(ind*2+1,l,r));   }   int main(){       int t; cin >> t;       for (int i=0;i<t;i++){           int n,m; string s; cin >> n >> m; cin >> s;           pre[0] = 0;           for (int j=0;j<n;j++){               if (s[j] ==  + ) pre[j+1] = pre[j] + 1; else pre[j+1] = pre[j] - 1;           }           build(1, 0, n);           for (int j=0;j<m;j++){               int l,r; cin >> l >> r;               int M = find_max(1, 0, l-1), m = find_min(1, 0, l-1);               //cout << M <<     << m << endl;               int subsum = pre[r] - pre[l-1];               M = max(M, find_max(1, r+1, n) - subsum);               m = min(m, find_min(1, r+1, n) - subsum);               cout << M-m+1 << endl;           }                  }                }