Language: C++


int main(){
    ios::sync_with_stdio(false);
    unsigned int S;
    cin >> S;

    pair<string,unsigned int> brackets;
    std::vector<pair<unsigned int,unsigned int>> offsets;
    bool opening = false;
    for(int i = 0; i < S; ++i){
        string s;
        cin >> s;
        pair<unsigned int,unsigned int> eff(0,0);
        for(unsigned int j = 0; j < s.size(); ++j) {
            if(s[j]==')'){
                if(eff.second == 0){
                    eff.first++;
                }else{
                    eff.second--;
                }
            }else{
                eff.second++;
            }
        }
        if(eff.first == 0){
            opening = true;
        }
        if(eff.first!=0||eff.second!=0){
            offsets.push_back(eff);
        }
    }

    if(!opening){
        cout << "No";
        return 0;
    }
    sort(&offsets[0],&offsets[offsets.size()-1] ,[](const pair<int,int> &p1 ,const pair<int,int> &p2){
        return p2.second<p1.second;
    });

    unsigned long openBrackets = 0;
    for(unsigned int i = 0; i < offsets.size(); ++i){
        openBrackets += offsets[i].second-offsets[i].first;
    }
    if(!openBrackets){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'ios' has not been declared
    3 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> S;
      |     ^~~
a.cc:7:5: error: 'pair' was not declared in this scope
    7 |     pair<string,unsigned int> brackets;
      |     ^~~~
a.cc:7:10: error: 'string' was not declared in this scope
    7 |     pair<string,unsigned int> brackets;
      |          ^~~~~~
a.cc:7:17: error: expected primary-expression before 'unsigned'
    7 |     pair<string,unsigned int> brackets;
      |                 ^~~~~~~~
a.cc:8:10: error: 'vector' is not a member of 'std'
    8 |     std::vector<pair<unsigned int,unsigned int>> offsets;
      |          ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | 
a.cc:8:22: error: expected primary-expression before 'unsigned'
    8 |     std::vector<pair<unsigned int,unsigned int>> offsets;
      |                      ^~~~~~~~
a.cc:11:15: error: expected ';' before 's'
   11 |         string s;
      |               ^~
      |               ;
a.cc:12:16: error: 's' was not declared in this scope
   12 |         cin >> s;
      |                ^
a.cc:13:14: error: expected primary-expression before 'unsigned'
   13 |         pair<unsigned int,unsigned int> eff(0,0);
      |              ^~~~~~~~
a.cc:16:20: error: 'eff' was not declared in this scope
   16 |                 if(eff.second == 0){
      |                    ^~~
a.cc:22:17: error: 'eff' was not declared in this scope
   22 |                 eff.second++;
      |                 ^~~
a.cc:25:12: error: 'eff' was not declared in this scope
   25 |         if(eff.first == 0){
      |            ^~~
a.cc:28:12: error: 'eff' was not declared in this scope
   28 |         if(eff.first!=0||eff.second!=0){
      |            ^~~
a.cc:29:13: error: 'offsets' was not declared in this scope
   29 |             offsets.push_back(eff);
      |             ^~~~~~~
a.cc:34:9: error: 'cout' was not declared in this scope
   34 |         cout << "No";
      |         ^~~~
a.cc:37:11: error: 'offsets' was not declared in this scope
   37 |     sort(&offsets[0],&offsets[offsets.size()-1] ,[](const pair<int,int> &p1 ,const pair<int,int> &p2){
      |           ^~~~~~~
a.cc:37:59: error: 'pair' does not name a type
   37 |     sort(&offsets[0],&offsets[offsets.size()-1] ,[](const pair<int,int> &p1 ,const pair<int,int> &p2){
      |                                                           ^~~~
a.cc: In lambda function:
a.cc:39:7: error: expected '{' before ';' token
   39 |     });
      |       ^
a.cc: In function 'int main()':
a.cc:39:7: error: expected ')' before ';' token
   39 |     });
      |       ^
      |       )
a.cc:37:9: note: to match this '('
   37 |     sort(&offsets[0],&offsets[offsets.size()-1] ,[](const pair<int,int> &p1 ,const pair<int,int> &p2){
      |         ^
a.cc:46:9: error: 'cout' was not declared in this scope
   46 |         cout << "Yes";
      |         ^~~~
a.cc:48:9: error: 'cout' was not declared in this scope
   48 |         cout << "No";
      |         ^~~~
a.cc:50:14: error: expected '}' at end of input
   50 |     return 0;
      |              ^
a.cc:2:11: note: to match this '{'
    2 | int main(){
      |           ^