criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<stdio.h>
#include<stack>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int>> S2;
	char slope;
	int i = 0;
	int sum = 0;
	while (scanf("%s", slope) != EOF){
		if (slope == '\\'){
			S1.push(i);
		}
		else if (slope == '/' &&S1.size() > 0){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	int t = 0;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), and.end());
	cout << sum << endl;
	cout << and.size();
	for (int i = 0; i < ans.size(); i++){
		cout << " ";
		t += ans[i];
		cout << and[i];
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:33: error: expected identifier before '.' token
   35 |         reverse(ans.begin(), and.end());
      |                                 ^
a.cc:37:20: error: expected identifier before '.' token
   37 |         cout << and.size();
      |                    ^
a.cc:41:28: error: expected identifier before '[' token
   41 |                 cout << and[i];
      |                            ^
Language: C++

#include<stdio.h>
#include<stack>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char slope;
	int i = 0;
	int sum = 0;
	while (scanf("%s", slope) != EOF){
		if (slope == '\\'){
			S1.push(i);
		}
		else if (slope == '/' &&S1.size() > 0){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	int t = 0;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), and.end());
	cout << sum << endl;
	cout << and.size();
	for (int i = 0; i < ans.size(); i++){
		cout << " ";
		t += ans[i];
		cout << and[i];
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:33: error: expected identifier before '.' token
   35 |         reverse(ans.begin(), and.end());
      |                                 ^
a.cc:37:20: error: expected identifier before '.' token
   37 |         cout << and.size();
      |                    ^
a.cc:41:28: error: expected identifier before '[' token
   41 |                 cout << and[i];
      |                            ^
Language: C++

#include<stdio.h>
#include<stack>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char slope;
	int i = 0;
	int sum = 0;
	while (scanf("%s", slope) != EOF){
		if (slope == '\\'){
			S1.push(i);
		}
		else if (slope == '/' &&S1.size() > 0){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	int t = 0;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << and.size();
	for (int i = 0; i < ans.size(); i++){
		cout << " ";
		t += ans[i];
		cout << and[i];
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:20: error: expected identifier before '.' token
   37 |         cout << and.size();
      |                    ^
a.cc:41:28: error: expected identifier before '[' token
   41 |                 cout << and[i];
      |                            ^
Language: C++

#include<stdio.h>
#include<stack>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char slope;
	int i = 0;
	int sum = 0;
	while (scanf("%s", slope) != EOF){
		if (slope == '\\'){
			S1.push(i);
		}
		else if (slope == '/' &&S1.size() > 0){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
		i++;
	}
	vector<int> ans;
	int t = 0;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << and.size();
	for (int i = 0; i < ans.size(); i++){
		cout << " ";
		t += ans[i];
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: expected identifier before '.' token
   38 |         cout << and.size();
      |                    ^
Language: C++

#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
int main() {
	stack<int> s1;
	stack<pair<int, int> > s2;
	char ch;
	int sum = 0;
	for(int i=0; cin>>ch; i++){
		if(ch == '\\') s1.push(i);
		else if(ch == '/' && s1.size()>0){
			int j = s1.top();
			s1.pop();
			sum += i - j;
			int a = i - j;
			while(s2.size()>0 && s2.top().first > j){
				a += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (s2.size()>0) {
		ans.push_back(s2.top().second);
		s2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for(int i=0; i<ans.size(); i++){
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'reverse' was not declared in this scope
   31 |         reverse(ans.begin(), ans.end());
      |         ^~~~~~~
Language: C++

#include <iostream>
#include <utility>
#include <stack>
#include <algorithm>
using namespace std;

int main(void){
    stack<int> sDowns;
    int i;
    char input;
    int init;
    int lake;
    int sum = 0;
    stack< pair<int,int> > sPools;
    vector<int> answer;
    
    for(i = 0; cin >> input; i++){
        if(input == '\\') sDowns.push(i);
        if(input == '/' && !sDowns.empty()){
            init = sDowns.top(); sDowns.pop();
            lake = i - init;
            sum += lake;
            while(!sPools.empty() && sPools.top().first > init){
                lake += sPools.top().second; sPools.pop();
            }
            sPools.push(make_pair(init, lake));
        }
        
    }
    
    while(!sPools.empty()){
        answer.push_back(sPools.top().second);
        sPools.pop();
    }
    reverse(answer.begin(), answer.end());
    
    cout << sum << endl;
    cout << answer.size();
    
    for(i = 0; i < answer.size(); i++){
        cout << " " << answer[i];
    }
    
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'vector' was not declared in this scope
   15 |     vector<int> answer;
      |     ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <algorithm>
  +++ |+#include <vector>
    5 | using namespace std;
a.cc:15:12: error: expected primary-expression before 'int'
   15 |     vector<int> answer;
      |            ^~~
a.cc:32:9: error: 'answer' was not declared in this scope
   32 |         answer.push_back(sPools.top().second);
      |         ^~~~~~
a.cc:35:13: error: 'answer' was not declared in this scope
   35 |     reverse(answer.begin(), answer.end());
      |             ^~~~~~
Language: C++

#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;

int main(void){
    stack<int> sDowns;
    int i;
    char input;
    int init;
    int lake;
    int sum = 0;
    stack< pair<int,int> > sPools;
    vector<int> answer;
    
    for(i = 0; cin >> input; i++){
        if(input == '\\') sDowns.push(i);
        if(input == '/' && !sDowns.empty()){
            init = sDowns.top(); sDowns.pop();
            lake = i - init;
            sum += lake;
            while(!sPools.empty() && sPools.top().first > init){
                lake += sPools.top().second; sPools.pop();
            }
            sPools.push(make_pair(init, lake));
        }
        
    }
    
    while(!sPools.empty()){
        answer.push_back(sPools.top().second);
        sPools.pop();
    }
    reverse(answer.begin(), answer.end());
    
    cout << sum << endl;
    cout << answer.size();
    
    for(i = 0; i < answer.size(); i++){
        cout << " " << answer[i];
    }
    
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'vector' was not declared in this scope
   14 |     vector<int> answer;
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:14:12: error: expected primary-expression before 'int'
   14 |     vector<int> answer;
      |            ^~~
a.cc:31:9: error: 'answer' was not declared in this scope
   31 |         answer.push_back(sPools.top().second);
      |         ^~~~~~
a.cc:34:13: error: 'answer' was not declared in this scope
   34 |     reverse(answer.begin(), answer.end());
      |             ^~~~~~
Language: C++

#include <iostream>
#include <utility>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
    stack<int> sDowns;
    int i;
    char input;
    int init;
    int lake;
    int sum = 0;
    stack< pair<int,int> > sPools;
    vector<int> answer;
    
    for(i = 0; cin >> input; i++){
        if(input == '\\') sDowns.push(i);
        if(input == '/' && !sDowns.empty()){
            init = sDowns.top(); sDowns.pop();
            lake = i - init;
            sum += lake;
            while(!sPools.empty() && sPools.top().first > init){
                lake += sPools.top().second; sPools.pop();
            }
            sPools.push(make_pair(init, lake));
        }
        
    }
    
    while(!sPools.empty()){
        answer.push_back(sPools.top().second);
        sPools.pop();
    }
    reverse(answer.begin(), answer.end());
    
    cout << sum << endl;
    cout << answer.size();
    
    for(i = 0; i < answer.size(); i++){
        cout << " " << answer[i];
    }
    
    cout <<
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:5: error: expected primary-expression before 'return'
   46 |     return 0;
      |     ^~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;

int main(void){
    stack<int> sDowns;
    int i;
    char input;
    int init;
    int lake;
    int sum = 0;
    stack< pair<int,int> > sPools;
    vector<int> answer;
    
    for(i = 0; cin >> input; i++){
        if(input == '\\') sDowns.push(i);
        if(input == '/' && !sDowns.empty()){
            init = sDowns.top(); sDowns.pop();
            lake = i - init;
            sum += lake;
            while(!sPools.empty() && sPools.top().first > init){
                lake += sPools.top().second; sPools.pop();
            }
            sPools.push(make_pair(init, lake));
        }
        
    }
    
    while(!sPools.empty()){
        answer.push_back(sPools.top().second);
        sPools.pop();
    }
    reverse(answer.begin(), answer.end());
    
    cout << sum << endl;
    cout << answer.size();
    
    for(i = 0; i < answer.size(); i++){
        cout << " " << answer[i];
    }
    
    cout <<
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:5: error: expected primary-expression before 'return'
   48 |     return 0;
      |     ^~~~~~
Language: C++

#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <memory>
#include <cstdlib>
#include <vector>
#include <stack>
using namespace std;

stack<int> idx;
stack<pair<int, int>> tmp_water;
vector<int> ans;

int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    string a;
    cin>>a;
    int all_sum=0;
    for (int i=0; i<(int)a.length(); i++) {
        if (a[i]=='\\') {
            idx.push(i);
        }
        if (a[i]=='/') {
            if (!idx.empty()) {
                int last=idx.top();
                idx.pop();
                all_sum+=i-last;
                int tmp_sum=0;
                while (tmp_water.size()&&tmp_water.top().first>last) {
                    tmp_sum+=tmp_water.top().second;
                    tmp_water.pop();
                }
                tmp_sum+=i-last;
                tmp_water.push(make_pair(last, tmp_sum));
                
            }
        }
    }
    cout<<all_sum<<endl;
    cout<<tmp_water.size();
    for (; tmp_water.size(); ) {
        ans.push_back(tmp_water.top().second);
        tmp_water.pop();
    }
    reverse(ans.begin(), ans.end());
    for (int i=0; i<ans.size(); i++) {
        cout<<' '<<ans[i];
    }
    cout<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:5: error: 'reverse' was not declared in this scope
   47 |     reverse(ans.begin(), ans.end());
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
string s;
stack<int> s;
int sum;
int t=0;
int main(){
  cin >> s;
  stack<int> s1;
  stack<pair<int,int> > s2;
  int sum=0;
  for(int i=0;s.length();i++){
    if(s[i]=='\\')s1.push(i);
    else if(s[i]=='/' && s1.size()>0){
      int j=s1.top();
      s1.pop();
      sum+=(i-j);
      int a=j-i;
      while(s2.size()>0 && s2.top().first>j){
	a+=s2.top().second;s2.pop();
      }
      s2.push(make_par(j,a));
    }
  }
  vector<int> ans;
  int t=0;
  while(s2.size()>0){ans.push_back(s2.top().second);s2.pop();}
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i=0;i<ans.size();i++){
    cout << " ";
    t+=ans[i];
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}

Compiler output:
a.cc:9:12: error: conflicting declaration 'std::stack<int> s'
    9 | stack<int> s;
      |            ^
a.cc:8:8: note: previous declaration as 'std::string s'
    8 | string s;
      |        ^
a.cc: In function 'int main()':
a.cc:27:15: error: 'make_par' was not declared in this scope
   27 |       s2.push(make_par(j,a));
      |               ^~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum=0;
  for(int i=0;cin >> ch;i++){
    if(ch=='\\')S1.push(i);
    else if(ch=='/' && S1.size()>0){
      int j=S1.top();
      S1.pop();
      sum+=i-j;
      int a=i-j;
      while(S2.size()>0 && S2.top().first>j){
	a+=S2.top().second;
	S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  vector<int> ans;
  while(S2.size()>0){
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i=0;i<ans.size();i++){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: 'reverse' was not declared in this scope
   30 |   reverse(ans.begin(),ans.end());
      |   ^~~~~~~
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    stack<int> S1;
    stach<pair<int,int>> S2;
    char ch;
    int sum=0;
    for (i=0;cin>>ch;i++){
        if(ch == '\\'){
            S1.push(i);
        }
        else if(ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            int h = i-j;
            sum = sum + h;
            while(S2.size()>0 && S2.top().first > j){
                h = h + S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,h))
        }
    }
    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum <<endl;
    cout<<ans.size();
    for (int i=0;i<ans.size();i++){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'stach' was not declared in this scope
   10 |     stach<pair<int,int>> S2;
      |     ^~~~~
a.cc:10:23: error: expected primary-expression before '>' token
   10 |     stach<pair<int,int>> S2;
      |                       ^~
a.cc:10:26: error: 'S2' was not declared in this scope; did you mean 'S1'?
   10 |     stach<pair<int,int>> S2;
      |                          ^~
      |                          S1
a.cc:13:10: error: 'i' was not declared in this scope
   13 |     for (i=0;cin>>ch;i++){
      |          ^
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    stack<int> S1;
    stack<pair<int,int>> S2;
    char ch;
    int sum=0;
    for (i=0;cin>>ch;i++){
        if(ch == '\\'){
            S1.push(i);
        }
        else if(ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            int h = i-j;
            sum = sum + h;
            while(S2.size()>0 && S2.top().first > j){
                h = h + S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,h))
        }
    }
    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum <<endl;
    cout<<ans.size();
    for (int i=0;i<ans.size();i++){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: 'i' was not declared in this scope
   13 |     for (i=0;cin>>ch;i++){
      |          ^
a.cc:25:36: error: expected ';' before '}' token
   25 |             S2.push(make_pair(j,h))
      |                                    ^
      |                                    ;
   26 |         }
      |         ~
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[], int n, int edge[]);
int calcArea(const int a[], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			int area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= n - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k << " ";
	for (int i = 0; i < k; i++) {
		cout << area[k];
		if (i < k - 1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] + 1;
	for (int i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (i >= n) return false;
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];	
	for (int i = edge[1]; i < n; i++) {
		if (a[i][1] == height) {
			edge[1] = i;
			break;
		}
	}
	if (i >= n) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0][0]];
	int area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		if (a[i][0] < max || a[i][1] < max) {
			area += (-(a[i][0] - max));
			area += (-(a[i][1] -a[i][0]) / 2);
		}
	}
	
	return area;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:32: error: cannot convert 'int (*)[2]' to 'const int*'
   28 |                 if (searchEdge(a, cnt, edge)) {
      |                                ^
      |                                |
      |                                int (*)[2]
a.cc:5:27: note:   initializing argument 1 of 'bool searchEdge(const int*, int, int*)'
    5 | bool searchEdge(const int a[], int n, int edge[]);
      |                 ~~~~~~~~~~^~~
a.cc:29:48: error: cannot convert 'int (*)[2]' to 'const int*'
   29 |                         int area[k] = calcArea(a, edge);
      |                                                ^
      |                                                |
      |                                                int (*)[2]
a.cc:6:24: note:   initializing argument 1 of 'int calcArea(const int*, const int*)'
    6 | int calcArea(const int a[], const int edge[]);
      |              ~~~~~~~~~~^~~
a.cc:32:32: error: 'n' was not declared in this scope
   32 |                 if (edge[1] >= n - 1) break;
      |                                ^
a.cc: In function 'bool searchEdge(const int (*)[2], int, int*)':
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         if (i >= n) return false;
      |             ^
a.cc:70:13: error: 'i' was not declared in this scope
   70 |         if (i >= n) return false;
      |             ^
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:77:28: error: invalid types 'const int[int]' for array subscript
   77 |         int max = a[edge[0][0]];
      |                            ^
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			int area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= n - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k << " ";
	for (int i = 0; i < k; i++) {
		cout << area[k];
		if (i < k - 1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] + 1;
	for (int i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (i >= n) return false;
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];	
	for (int i = edge[1]; i < n; i++) {
		if (a[i][1] == height) {
			edge[1] = i;
			break;
		}
	}
	if (i >= n) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0][0]];
	int area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		if (a[i][0] < max || a[i][1] < max) {
			area += (-(a[i][0] - max));
			area += (-(a[i][1] -a[i][0]) / 2);
		}
	}
	
	return area;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:47: error: array must be initialized with a brace-enclosed initializer
   29 |                         int area[k] = calcArea(a, edge);
      |                                       ~~~~~~~~^~~~~~~~~
a.cc:32:32: error: 'n' was not declared in this scope
   32 |                 if (edge[1] >= n - 1) break;
      |                                ^
a.cc: In function 'bool searchEdge(const int (*)[2], int, int*)':
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         if (i >= n) return false;
      |             ^
a.cc:70:13: error: 'i' was not declared in this scope
   70 |         if (i >= n) return false;
      |             ^
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:77:28: error: invalid types 'const int[int]' for array subscript
   77 |         int max = a[edge[0][0]];
      |                            ^
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= n - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k << " ";
	for (int i = 0; i < k; i++) {
		cout << area[k];
		if (i < k - 1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] + 1;
	for (int i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (i >= n) return false;
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];	
	for (int i = edge[1]; i < n; i++) {
		if (a[i][1] == height) {
			edge[1] = i;
			break;
		}
	}
	if (i >= n) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0][0]];
	int area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		if (a[i][0] < max || a[i][1] < max) {
			area += (-(a[i][0] - max));
			area += (-(a[i][1] -a[i][0]) / 2);
		}
	}
	
	return area;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:32: error: 'n' was not declared in this scope
   32 |                 if (edge[1] >= n - 1) break;
      |                                ^
a.cc: In function 'bool searchEdge(const int (*)[2], int, int*)':
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         if (i >= n) return false;
      |             ^
a.cc:70:13: error: 'i' was not declared in this scope
   70 |         if (i >= n) return false;
      |             ^
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:77:28: error: invalid types 'const int[int]' for array subscript
   77 |         int max = a[edge[0][0]];
      |                            ^
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= cnt - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k << " ";
	for (int i = 0; i < k; i++) {
		cout << area[k];
		if (i < k - 1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] + 1;
	for (int i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (i >= n) return false;
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];	
	for (int i = edge[1]; i < n; i++) {
		if (a[i][1] == height) {
			edge[1] = i;
			break;
		}
	}
	if (i >= n) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0][0]];
	int area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		if (a[i][0] < max || a[i][1] < max) {
			area += (-(a[i][0] - max));
			area += (-(a[i][1] -a[i][0]) / 2);
		}
	}
	
	return area;
}

Compiler output:
a.cc: In function 'bool searchEdge(const int (*)[2], int, int*)':
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         if (i >= n) return false;
      |             ^
a.cc:70:13: error: 'i' was not declared in this scope
   70 |         if (i >= n) return false;
      |             ^
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:77:28: error: invalid types 'const int[int]' for array subscript
   77 |         int max = a[edge[0][0]];
      |                            ^
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= cnt - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k << " ";
	for (int i = 0; i < k; i++) {
		cout << area[k];
		if (i < k - 1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] + 1;
	int i;
	for (i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (i >= n) return false;
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];
	int j;
	for (j = edge[1]; j < n; j++) {
		if (a[j][1] == height) {
			edge[1] = j;
			break;
		}
	}
	if (j >= n) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0][0]];
	int area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		if (a[i][0] < max || a[i][1] < max) {
			area += (-(a[i][0] - max));
			area += (-(a[i][1] -a[i][0]) / 2);
		}
	}
	
	return area;
}

Compiler output:
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:79:28: error: invalid types 'const int[int]' for array subscript
   79 |         int max = a[edge[0][0]];
      |                            ^
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= cnt - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k;
	for (int i = 0; i < k; i++) {
		cout << " " << area[k];
	}
	cout << endl;
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] = edge[1] + 1;
	for (int i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (edge[0] == edge[1]) {
		edge[1] = n - 1;
		return false;
	}
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];
	for (int j = edge[1]; j < n; j++) {
		if (a[j][1] == height) {
			edge[1] = j;
			break;
		}
	}
	if (edge[0] == edge[1]) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0]][0];
	double area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		area += (-(a[i][0] - max));
		area += (-(a[i][1] -a[i][0]) / 2.0);
	}
	
	return (int)sarea;
}

Compiler output:
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:86:21: error: 'sarea' was not declared in this scope; did you mean 'area'?
   86 |         return (int)sarea;
      |                     ^~~~~
      |                     area
Language: C++

#include <stdio.h>
#include <stdlib.h>

struct node {
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer insert(int);
NodePointer delete(int);
NodePointer deleteFirst(void);
NodePointer deleteLast(void);
void        init(void);
void        listPrint(void);
NodePointer nil;


int main () {
  int i, n, x;
  char str[15];
  nil = malloc(sizeof(struct node));
  init();

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", str);
    if (str[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    }
    else if (str[0] == 'd') {
      if(str[6] == '\0') {
        scanf("%d", &x);
        delete(x);
      }
      else if(str[6] == 'F') {
        deleteFirst();
      }
      else {
        deleteLast();
      }
    }
  }
  listPrint();
  return 0;
}

NodePointer insert(int keydata) {
  NodePointer newnode;

  newnode = malloc(sizeof(struct node));
  newnode->key = keydata;
  newnode->next = nil->next;
  newnode->prev = nil;
  newnode->next->prev = newnode;
  return newnode;
}

NodePointer delete(int keydata) {
  NodePointer delnode;
  delnode = nil->next;

  while (delnode != nil && delnode->key != keydata) {
    delnode = delnode->next;
  }
  if(delnode == nil) return nil;
  else {
    delnode->prev->next = delnode->next;
    delnode->next->prev = delnode->prev;
    free(delnode);
    return delnode;
  }
}

NodePointer deleteFirst(void) {
  NodePointer delnode;

  delnode = nil->next;
  nil->next = delnode->next;
  delnode->next->prev = nil;
  free(delnode);
  return delnode;
}


NodePointer deleteLast(void) {
  NodePointer delnode;

  delnode = nil->prev;
  delnode->prev->next = nil;
  nil->prev = delnode->prev;
  free(delnode);
  return delnode;
}

void listPrint(void) {
  NodePointer n;

  for(n = nil->next; n != nil->prev; n = n->next) {
    printf("%d ", n->key);
  }
  printf("%d\n", n->key);
  free(nil);
}

void init(void) {
  nil->next = nil;
  nil->prev = nil;
}

Compiler output:
a.cc:13:13: error: expected unqualified-id before 'delete'
   13 | NodePointer delete(int);
      |             ^~~~~~
a.cc: In function 'int main()':
a.cc:24:15: error: invalid conversion from 'void*' to 'NodePointer' {aka 'node*'} [-fpermissive]
   24 |   nil = malloc(sizeof(struct node));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |               |
      |               void*
a.cc:37:16: error: type 'int' argument given to 'delete', expected pointer
   37 |         delete(x);
      |               ~^~
a.cc: In function 'node* insert(int)':
a.cc:54:19: error: invalid conversion from 'void*' to 'NodePointer' {aka 'node*'} [-fpermissive]
   54 |   newnode = malloc(sizeof(struct node));
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                   |
      |                   void*
a.cc: At global scope:
a.cc:62:13: error: expected unqualified-id before 'delete'
   62 | NodePointer delete(int keydata) {
      |             ^~~~~~
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int>> S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0)
		{
			int J = S1.top(); S1.top;
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().secondl; S2.top;
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0)
	{
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size; i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: statement cannot resolve address of overloaded function
   18 |                         int J = S1.top(); S1.top;
      |                                           ~~~^~~
a.cc:19:36: error: 'j' was not declared in this scope
   19 |                         sum += i - j;
      |                                    ^
a.cc:23:47: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'secondl'; did you mean 'second'?
   23 |                                 a += S2.top().secondl; S2.top;
      |                                               ^~~~~~~
      |                                               second
a.cc:23:59: error: statement cannot resolve address of overloaded function
   23 |                                 a += S2.top().secondl; S2.top;
      |                                                        ~~~^~~
a.cc:36:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   36 |         for (int i = 0; i < ans.size; i++)
      |                             ~~~~^~~~
      |                                     ()
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int>> S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0)
		{
			int J = S1.top(); S1.top;
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().second; S2.top;
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0)
	{
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size; i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: statement cannot resolve address of overloaded function
   18 |                         int J = S1.top(); S1.top;
      |                                           ~~~^~~
a.cc:19:36: error: 'j' was not declared in this scope
   19 |                         sum += i - j;
      |                                    ^
a.cc:23:58: error: statement cannot resolve address of overloaded function
   23 |                                 a += S2.top().second; S2.top;
      |                                                       ~~~^~~
a.cc:36:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   36 |         for (int i = 0; i < ans.size; i++)
      |                             ~~~~^~~~
      |                                     ()
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int>> S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0)
		{
			int j = S1.top(); S1.top;
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().second; S2.top;
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0)
	{
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size; i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: statement cannot resolve address of overloaded function
   18 |                         int j = S1.top(); S1.top;
      |                                           ~~~^~~
a.cc:23:58: error: statement cannot resolve address of overloaded function
   23 |                                 a += S2.top().second; S2.top;
      |                                                       ~~~^~~
a.cc:36:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   36 |         for (int i = 0; i < ans.size; i++)
      |                             ~~~~^~~~
      |                                     ()
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0)
		{
			int j = S1.top(); S1.top;
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().second; S2.top;
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0)
	{
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size; i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: statement cannot resolve address of overloaded function
   18 |                         int j = S1.top(); S1.top;
      |                                           ~~~^~~
a.cc:23:58: error: statement cannot resolve address of overloaded function
   23 |                                 a += S2.top().second; S2.top;
      |                                                       ~~~^~~
a.cc:36:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   36 |         for (int i = 0; i < ans.size; i++)
      |                             ~~~~^~~~
      |                                     ()
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0)
		{
			int j = S1.top(); S1.pop;
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().second; S2.pop;
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0)
	{
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size; i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
   18 |                         int j = S1.top(); S1.pop;
      |                                           ~~~^~~
In file included from /usr/include/c++/14/stack:63,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:23:58: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >]'
   23 |                                 a += S2.top().second; S2.pop;
      |                                                       ~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:36:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   36 |         for (int i = 0; i < ans.size; i++)
      |                             ~~~~^~~~
      |                                     ()
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int, int>> S2;
  char ch;
  int sum = 0;
  for(int i = 0 ; cin >> ch ; i++){
    if(ch == '\\') S1.push(i);
    else if(ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while(S2.size() > 0 && S2.top().first > j){
	a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while(S2.size() > 0){ans.push_back(S2.top().second); S2.pop();}
  reverse(ans.begin(), ans.end());
  cout << sum endl;
  cout << ans.size();
  for(int i = 0 ; i < ans.size(); i++){
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:14: error: expected ';' before 'endl'
   30 |   cout << sum endl;
      |              ^~~~~
      |              ;
Language: C++

#include <stdio.h>
 

#define MAX 20001
 

struct pair {
  int x;
  int ar;
};
 

void push_stack1(int);
void push_stack2(int, int);
int returnTopElement(void);
int pop_stack1(void);
struct pair pop_stack2(void);
 

int top_stack1 = 0, top_stack2 = 0;
 

int stack1[MAX];
struct pair stack2[MAX];
 
int main() {
  int i, j;
  int sum = 0, a;
  struct pair c;
  char input[MAX];
 
 
  scanf("%s", input);
 

  for (i = 0; input[i] != '\0'; i++) {
    if(input[i] == '\\') push_stack1(i);
    else if((input[i] == '/') && (top_stack1 > 0)) {
      j = pop_stack1();
      sum += i - j;
      a = i - j;
      while ((top_stack2 > 0) && stack2[top_stack2 - 1].x > j) {
        a += stack2[top_stack2 - 1].ar ;
        c = pop_stack2();
      }
      push_stack2(j, a);
    }
  }
 

  printf("%d\n", sum);
  printf("%d", top_stack2);
  for(i = 0; i < top_stack2; i++) {
    if(i < top_stack2) printf(" ");
    printf("%d", stack2[i].ar);
  }
  printf("\n");
 
 
  return 0;
}
 
void push_stack1(int x) {
  stack1[top_stack1] = x;
  top_stack1++;
}
 
void push_stack2(int j, int a) {
  stack2[top_stack2].x = j;
  stack2[top_stack2].ar = a;
  top_stack2++;
}
 
int pop_stack1(void) {
  int r = 0;
 
  top_stack1--;
   
  if(top_stack1 < 0) {
    top_stack1 = 0;
    return 0;
  }
  r = stack1[top_stack1];
  return r;
 
}
 
struct pair pop_stack2(void) {
  struct pair s;
 
  top_stack2--;
   
  if(top_stack2 < 0) {
    top_stack2 = 0;
    return;
  }
  s = stack2[top_stack2];
  return s;
 
}

Compiler output:
a.cc: In function 'pair pop_stack2()':
a.cc:95:5: error: return-statement with no value, in function returning 'pair' [-fpermissive]
   95 |     return;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int,int> > S2;
  char ch;
  int sum = 0;
  int i,j,a;
  for( i = 0; cin >> ch ; i++){
    if(ch == '\\'){
      S1.push(i);
    }
    else if( ch == '/' && S1.size() > 0){
      j = S1.top();
      S1.pop();
      sum += i - j;
      a = i - j;
      while(S2.size() > 0 && S2.top().first > j){
        a += S2.top().second;
        S2.pop();
      }
      S2.push( make_pair(j,a) );
    }
  }

  vector<int> ans;
  int t = 0;
  while(S2.size() > 0){
    ans.push_back( S2.top().second );
    S2.pop();
  }
  reverse( ans.begin(), ans.end() );
  cout << sum << endl;
  cout << ans.size();
  for( i = 0; i < ans.size(); i++){
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;
  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:42:12: error: expected '}' at end of input
   42 |   return 0;
      |            ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^