func_code_string: #include <bits/stdc++.h>   using namespace std;   const int sq = (int)sqrt((int)1e6);   const int maxnb = (int)1e9 + 7;   const double pi = acos(-1.0);   const int maxnl = 100500;   const double eps = 1e-9;   set<pair<long long, int> > se;   int n, pos[50500];   char c[50500];   long long price;   string s;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> s;     int n = s.size(), bal = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  ( ) bal++;       if (s[i] ==  ) ) bal--;       if (s[i] ==  ? ) {         long long a, b;         cin >> a >> b;         se.insert(make_pair(a - b, i));         price += b;         s[i] =  ) ;         bal--;       }       while (bal < 0) {         if (!se.size()) {           cout << -1;           return 0;         }         pair<long long, int> p = *se.begin();         price += p.first;         s[p.second] =  ( ;         bal += 2;         se.erase(se.begin());       }     }     if (bal != 0) {       cout << -1;       return 0;     }     cout << price <<   n ;     for (int i = 0; i < n; i++) {       cout << s[i];     }     return 0;   }   