func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int tree[1000005 << 2];   int mn[1000005 << 2];   int mx[1000005 << 2];   int pos;   char s[1000005];   void pushup(int rt) {     tree[rt] = tree[(2 * rt)] + tree[(2 * rt + 1)];     mn[rt] = min(mn[(2 * rt)], tree[(2 * rt)] + mn[(2 * rt + 1)]);     mx[rt] = max(mx[(2 * rt)], tree[(2 * rt)] + mx[(2 * rt + 1)]);   }   void update(int rt, int l, int r, int x, int v) {     if (l == r) {       tree[rt] = mn[rt] = mx[rt] = v;       return;     }     if (x <= ((l + r) / 2))       update((2 * rt), l, ((l + r) / 2), x, v);     else       update((2 * rt + 1), ((l + r) / 2) + 1, r, x, v);     pushup(rt);   }   int main() {     scanf( %d , &n);     pos = 1;     scanf( %s , s + 1);     char opt[5];     for (int i = 1; i <= n; ++i) {       opt[1] = s[i];       if (opt[1] ==  R )         ++pos;       else if (opt[1] ==  L ) {         if (pos > 1) --pos;       } else {         if (opt[1] ==  ( )           update(1, 1, n, pos, 1);         else if (opt[1] ==  ) )           update(1, 1, n, pos, -1);         else           update(1, 1, n, pos, 0);       }       if (tree[1] != 0 || mn[1] < 0)         printf( -1  );       else         printf( %d  , mx[1]);     }     printf(  n );     return 0;   }   