func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const int N = 1e6 + 100;   pair<int, int> seg[4 * N];   int lazy[4 * N];   void shift(int nod) {     lazy[nod * 2] += lazy[nod];     lazy[nod * 2 + 1] += lazy[nod];     seg[nod * 2].first += lazy[nod];     seg[nod * 2 + 1].first += lazy[nod];     seg[nod * 2].second += lazy[nod];     seg[nod * 2 + 1].second += lazy[nod];     lazy[nod] = 0;   }   void upd(int nod, int l, int r, int L, int R, int val) {     if (l >= R || L >= r) {       return;     }     if (l >= L && r <= R) {       seg[nod].first += val;       seg[nod].second += val;       lazy[nod] += val;       return;     }     shift(nod);     int mid = (r + l) / 2;     upd(nod * 2, l, mid, L, R, val);     upd(nod * 2 + 1, mid, r, L, R, val);     seg[nod].first = max(seg[nod * 2].first, seg[nod * 2 + 1].first);     seg[nod].second = min(seg[nod * 2].second, seg[nod * 2 + 1].second);   }   int a[N];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int cnt = 1;     int to = 0, tc = 0;     for (int i = 0; i < n; i++) {       char c;       cin >> c;       if (c ==  ( ) {         if (a[cnt] == 1) {           if (to != tc || seg[1].second < 0) {             cout << -1 <<   n ;           } else {             cout << seg[1].first <<   n ;           }           continue;         }         if (a[cnt] == 2) {           upd(1, 1, N, cnt, N, +2);           tc--;         } else {           upd(1, 1, N, cnt, N, 1);         }         a[cnt] = 1;         to++;       }       if (c ==  ) ) {         if (a[cnt] == 2) {           if (to != tc || seg[1].second < 0) {             cout << -1 <<   n ;           } else {             cout << seg[1].first <<   n ;           }           continue;         }         if (a[cnt] == 1) {           upd(1, 1, N, cnt, N, -2);           to--;         } else {           upd(1, 1, N, cnt, N, -1);         }         tc++;         a[cnt] = 2;       }       if (c ==  R ) {         cnt++;       }       if (c ==  L ) {         cnt--;       }       if (c >=  a  && c <=  z ) {         if (a[cnt] == 1) {           a[cnt] = 0;           upd(1, 1, N, cnt, N, -1);           to--;         }         if (a[cnt] == 2) {           a[cnt] = 0;           upd(1, 1, N, cnt, N, +1);           tc--;         }       }       cnt = max(cnt, (int)1);       if (to != tc || seg[1].second < 0) {         cout << -1 <<   n ;       } else {         cout << seg[1].first <<   n ;       }     }   }   