func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000005;   int N;   char S[2 * MAXN];   int ord[2 * MAXN];   pair<pair<int, int>, int> E[2 * MAXN];   int step = 1;   int pre[MAXN];   int minp[MAXN];   int mins[MAXN];   char ans[MAXN];   void build() {     for (int i = 0; i < N; i++) ord[i] = (S[i] ==  ) );     for (int jump = 1; jump < N; step++, jump *= 2) {       for (int i = 0; i < N; i++)         E[i] = make_pair(             pair<int, int>(ord[i], (i + jump < N) ? ord[i + jump] : N), i);       sort(E, E + N);       int ind = -1;       pair<int, int> prev(-1, -1);       for (int i = 0; i < N; i++) {         int idx = E[i].second;         pair<int, int> cur = E[i].first;         if (cur != prev) {           ind++;           prev = cur;         }         ord[idx] = ind;       }     }   }   int main() {     scanf( %s , &S);     N = (int)(strlen(S));     memcpy(S + N, S, N);     N += N;     S[N] =  | ;     S[N + 1] = 0;     build();     N /= 2;     for (int i = 1; i <= N; i++)       pre[i] = pre[i - 1] + ((S[i - 1] ==  ( ) ? 1 : -1);     minp[0] = pre[0] + pre[N];     for (int i = 1; i < N; i++) minp[i] = min(minp[i - 1], pre[i] + pre[N]);     mins[N - 1] = pre[N - 1];     for (int i = N - 2; i >= 0; i--) mins[i] = min(mins[i + 1], pre[i]);     int best = -1, x = min(0, pre[N]);     for (int i = 0; i < N; i++)       if (min(minp[i], mins[i]) - pre[i] >= x)         if (best == -1 || ord[i] < ord[best]) best = i;     int ind = 0;     for (int i = 0; i < -pre[N]; i++) ans[ind++] =  ( ;     for (int i = 0; i < N; i++) ans[ind++] = S[best + i];     for (int i = 0; i < pre[N]; i++) ans[ind++] =  ) ;     ans[ind] = 0;     printf( %s n , ans);     return 0;   }   