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

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int ans[2][12]={};
        for(int i=0;i<n;i++){
                cin>>ans[0][i];
                ans[1][i]=ans[0][i];
        }
        for(int i=0;;i++){
            int num[100]={};
            for(int j=0;j<n;j++)num[ans[0][j]]++;
            bool rever=1;
            for(int j=0;j<n;j++){
                ans[0][j]=num[kawa[j]];
                if(ans[0][j]!=ans[1][j])rever=0;
            }
            if(rever){
                cout<<i<<endl;
                for(int j=0;j<n-1;j++)cout<<ans[0][j]<<" ";
                cout<<ans[0][n-1]<<endl;
                break;
            }
            for(int j=0;j<n;j++)ans[1][j]=ans[0][j];
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:31: error: 'kawa' was not declared in this scope
   17 |                 ans[0][j]=num[kawa[j]];
      |                               ^~~~
Language: C++

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

bool check(vector<int> &a,vector<int> &b)
{
	if(a.size()!=b.size())return true;
	for(int i=0;i<a.size();i++)if(a[i]!=b[i])return true;
	return false;
}

int main()
{
	int n;
	while(cin>>n&&n)
	{
		vector<int> a,b;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			a.push_back(x);
		}
		int ans;
		for(ans=-1;check(a,b);ans++)
		{
			b.clear();
			for(int i=0;i<a.size();i++)
			{
				b.push_back(count(a.begin(),a.end(),a[i]));
			}
			swap(a,b);
		}
		cout<<ans<<endl;
		for(int i=0;i<a.size();i++)
		{
			cout<<(i==0?"":" ")<<a[i];
		}
		cout<<endl;
	}
}

Compiler output:
a.cc:6:12: error: 'vector' was not declared in this scope
    6 | bool check(vector<int> &a,vector<int> &b)
      |            ^~~~~~
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:6:19: error: expected primary-expression before 'int'
    6 | bool check(vector<int> &a,vector<int> &b)
      |                   ^~~
a.cc:6:27: error: 'vector' was not declared in this scope
    6 | bool check(vector<int> &a,vector<int> &b)
      |                           ^~~~~~
a.cc:6:27: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:6:34: error: expected primary-expression before 'int'
    6 | bool check(vector<int> &a,vector<int> &b)
      |                                  ^~~
a.cc:6:41: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | bool check(vector<int> &a,vector<int> &b)
      |                                         ^
a.cc: In function 'int main()':
a.cc:18:17: error: 'vector' was not declared in this scope
   18 |                 vector<int> a,b;
      |                 ^~~~~~
a.cc:18:17: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:18:24: error: expected primary-expression before 'int'
   18 |                 vector<int> a,b;
      |                        ^~~
a.cc:23:25: error: 'a' was not declared in this scope
   23 |                         a.push_back(x);
      |                         ^
a.cc:26:34: error: 'a' was not declared in this scope
   26 |                 for(ans=-1;check(a,b);ans++)
      |                                  ^
a.cc:26:36: error: 'b' was not declared in this scope
   26 |                 for(ans=-1;check(a,b);ans++)
      |                                    ^
a.cc:26:37: error: 'check' cannot be used as a function
   26 |                 for(ans=-1;check(a,b);ans++)
      |                                     ^
a.cc:36:31: error: 'a' was not declared in this scope
   36 |                 for(int i=0;i<a.size();i++)
      |                               ^
Language: C++

#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;


bool mani(int a[12], int n)
{
	int b[12];
	fill(b, b + 12, 0);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (a[i] == a[j])
				b[i]++;
	bool f = true;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
		{
			f = false;
			break;
		}
	}
	for (int i = 0; i < n; i++)
		a[i] = b[i];
	return f;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
	while(true){
	cin>>n;
	if(n==0){break;}
	int *a=new int[n];
	map<int,int>Map;
	rep(i,n){
		cin>>a[i];
	}
	for(int count=0;;count++){
		rep(i,n){
			Map[a[i]]++;
		}
		int *s=new int[n];
		rep(i,n){
			s[i]=Map[a[i]];
		}
		if(a==s){cout<<count<<endl;break;}
		rep(i,n){	
			s[i]=a[0];
		}
		  
	}
	for(int i=0;i<n;i++){
		if(i!=0){
		cout<<" ";
		}
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'map' was not declared in this scope
   12 |         map<int,int>Map;
      |         ^~~
a.cc:4:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    3 | #include <algorithm>
  +++ |+#include <map>
    4 | using namespace std;
a.cc:12:13: error: expected primary-expression before 'int'
   12 |         map<int,int>Map;
      |             ^~~
a.cc:18:25: error: 'Map' was not declared in this scope
   18 |                         Map[a[i]]++;
      |                         ^~~
a.cc:22:30: error: 'Map' was not declared in this scope
   22 |                         s[i]=Map[a[i]];
      |                              ^~~
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
	while(true){
	cin>>n;
	if(n==0){break;}
	int *a=new int[n];
	map<int,int>Map;
	rep(i,n){
		cin>>a[i];
	}
	for(int count=0;;count++){
		rep(i,n){
			Map[a[i]]++;
		}
		int *s=new int[n];
		rep(i,n){
			s[i]=Map[a[i]];
		}
		if(a==s){cout<<count<<endl;break;}
		rep(i,n){	
			s[i]=a[0];
		}
		  
	}
	for(int i=0;i<n;i++){
		if(i!=0){
		cout<<" ";
		}
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
	while(true){
	cin>>n;
	if(n==0){break;}
	int *a=new int[n];
	map<int,int>Map;
	rep(i,n){
		cin>>a[i];
	}
	for(int count=0;;count++){
		rep(i,n){
			Map[a[i]]++;
		}
		int *s=new int[n];
		rep(i,n){
			s[i]=Map[a[i]];
		}
		if(a==s){cout<<count<<endl;break;}
		rep(i,n){	
			s[i]=a[0];
		}
		  
	}
	}
	  for(int i=0;i<n;i++){
		if(i!=0){
		cout<<" ";
		}
		cout<<a[i];
	}
	cout<<endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:23: error: 'a' was not declared in this scope
   37 |                 cout<<a[i];
      |                       ^
Language: C++

#include <iostream>]
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
int main()
{
  int n;
  while(true){
    cin>>n;
    if(n==0){break;}
    int *a=new int[n];
    map<int,int>Map;
    rep(i,n){
      cin>>a[i];
    }
    for(int cnt=0;;cnt++)
    {
      rep(i,n){
        Map[a[i]]++;
      }
      int *s=new int[a[i]];
      rep(i,n)
      {
        s[i]=Map[a[i]];
      }
      if(a==s)
      {
        cout<<cnt<<endl;
        rep(i,n){
          if(i!=0){
            cout<<" ";
          }
          cout<<a[i];
        }
        cout<<endl;
        break;
      }
      rep(i,n){
        s[i]=a[i];
      }
    }
  }
  return 0;
}



Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include <iostream>]
      |                    ^
a.cc: In function 'int main()':
a.cc:7:22: error: 'll' was not declared in this scope
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                      ^~
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,n){
      |     ^~~
a.cc:16:9: error: 'i' was not declared in this scope
   16 |     rep(i,n){
      |         ^
a.cc:7:29: note: in definition of macro 'rep'
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                             ^
a.cc:7:22: error: 'll' was not declared in this scope
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                      ^~
a.cc:21:7: note: in expansion of macro 'rep'
   21 |       rep(i,n){
      |       ^~~
a.cc:21:11: error: 'i' was not declared in this scope
   21 |       rep(i,n){
      |           ^
a.cc:7:29: note: in definition of macro 'rep'
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                             ^
a.cc:24:24: error: 'i' was not declared in this scope
   24 |       int *s=new int[a[i]];
      |                        ^
a.cc:7:22: error: 'll' was not declared in this scope
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                      ^~
a.cc:25:7: note: in expansion of macro 'rep'
   25 |       rep(i,n)
      |       ^~~
a.cc:7:22: error: 'll' was not declared in this scope
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                      ^~
a.cc:32:9: note: in expansion of macro 'rep'
   32 |         rep(i,n){
      |         ^~~
a.cc:7:22: error: 'll' was not declared in this scope
    7 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                      ^~
a.cc:41:7: note: in expansion of macro 'rep'
   41 |       rep(i,n){
      |       ^~~
Language: C++

#include <iostream>]
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <map>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
int main()
{
  int n;
  while(true){
    cin>>n;
    if(n==0){break;}
    int *a=new int[n];
    map<int,int>Map;
    rep(i,n){
      cin>>a[i];
    }
    for(int cnt=0;;cnt++)
    {
      rep(i,n){
        Map[a[i]]++;
      }
      int *s=new int[a[i]];
      rep(i,n)
      {
        s[i]=Map[a[i]];
      }
      if(a==s)
      {
        cout<<cnt<<endl;
        rep(i,n){
          if(i!=0){
            cout<<" ";
          }
          cout<<a[i];
        }
        cout<<endl;
        break;
      }
      rep(i,n){
        s[i]=a[i];
      }
    }
  }
  return 0;
}



Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include <iostream>]
      |                    ^
a.cc: In function 'int main()':
a.cc:25:24: error: 'i' was not declared in this scope
   25 |       int *s=new int[a[i]];
      |                        ^
Language: C++

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

int main ( void )
{
	int n; // ツ青板療アツづ個陳キツつウ
	while ( cin >> n && n != 0 )
	{
		vector <int> S(n);
		for ( int i = 0; i < n; i++ )
			cin >> S[i];

		vector <int> V(n);
		vector <int> V_next(n);
		V = S;

		int cnt = 0;
		while ( 1 )
		{
			for ( int i = 0; i < n; i++ )
			{
				V_next[i] = count( V.begin(), V.end(), V[i] );
			}
			cnt++;

			if ( V == V_next )
			{
				cnt--;
				break;
			}

			V = V_next;

		}

		cout << cnt << endl;
		for ( int i = 0; i < n; i++ )
		{
			cout << V[i];
			if ( i < n-1 )
				cout << " ";
		}
		cout << endl;

	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:45: error: 'count' was not declared in this scope; did you mean 'cnt'?
   23 |                                 V_next[i] = count( V.begin(), V.end(), V[i] );
      |                                             ^~~~~
      |                                             cnt
Language: C++

#include <stdio.h>
#include <string.h>
void cpy(int src[],int dst[],int n){
	for(int i=0;i<n;i++) dst[i]=src[i];
}
void OFA(int S[],int n){
	int num[100];
	memset(num,0,sizeof(num));
	for(int i=0;i<n;i++) num[S[i]]++;
	for(int i=0;i<n;i++) S[i]=num[S[i]];
}

bool check(int S[],int tmp[],int n){
	for(int i=0;i<n;i++) if(S[i]!=tmp[i]) return false;
	return true;
}

int main(){
	int S[12],tmp[12],n,count;
	while(1){
		scanf("%d",&n);
		if(!n) break;
		count=-1;
		for(int i=0;i<n;i++) scanf("%d",&S[i]);
		cpy(S,tmp,n);
		do{
			cpy(tmp,S,n);
			OFA(tmp,n);
			//for(int i=0;i<n;i++) printf("%d ",tmp[i]);
			count++;
		}while(!check(S,tmp,n));
		printf("%d\n",count);
		for(int i=0;i<n-1;i++) printf("%d ",S[i]);
		printf("%d\n",S[i]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:33: error: 'i' was not declared in this scope
   34 |                 printf("%d\n",S[i]);
      |                                 ^
Language: C++

#include<algorithm>
#include<iostream>
#include<map>

int n;
int a[12], prv[12];
std::map<int, int> cnt, tmp;
int ans;

int main()
{
	while( std::cin >> n, n )
	{
		ans = 0;
		memset( a, 0, sizeof( a ) );
		memset( prv, 0, sizeof( prv ) );
		cnt.clear();
		tmp.clear();

		for( int i = 0; i != n; ++i )
		{
			std::cin >> a[i];
			++cnt[a[i]];
		}

		while( true )
		{
			std::copy( a, a + 12, prv );

			for( int i = 0; i != n; ++i )
			{
				a[i] = cnt[a[i]];
				++tmp[a[i]];
			}

			if( std::equal( a, a + 12, prv ) )
				break;

			++ans;

			cnt = tmp;
			tmp.clear();
		}

		std::cout << ans << std::endl;
		for( int i = 0; i != n; ++i )
			std::cout << a[i] << ( i == n - 1 ? '\n' : ' ' );
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
   15 |                 memset( a, 0, sizeof( a ) );
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<map>
  +++ |+#include <cstring>
    4 |
Language: C++

#include<iostream>

int main(){
	int n,ans=0,data[12],back[12];
	while(std::cin>>n){
		if(n==0)break;
		for(int i=0;i<n;i++)std::cin>>data[i],back[i]=data[i];
		while(true){
			for(int i=0;i<n;i++){
				int count=0;
				for(int j=0;j<n;j++){
					if(back[i]==back[j])count++;
				}
				data[i]=count;
			}
			bool f=true;
			for(int i=0;i<n;i++){
				if(data[i]!=back[i])f=false;
			}
			if(f)break;
			memcpy(back,data,sizeof(data));
			ans++;
		}
		std::cout<<ans<<std::endl;
		for(int i=0;i<n;i++)std::cout<<data[i]<<" ";
		std::cout<<std::endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: 'memcpy' was not declared in this scope
   21 |                         memcpy(back,data,sizeof(data));
      |                         ^~~~~~
a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

#include<iostream>

int main(){
	int n;
	while(std::cin>>n){
		int ans=0,data[12],back[12];
		if(n==0)break;
		for(int i=0;i<n;i++)std::cin>>data[i],back[i]=data[i];
		while(true){
			for(int i=0;i<n;i++){
				int count=0;
				for(int j=0;j<n;j++){
					if(back[i]==back[j])count++;
				}
				data[i]=count;
			}
			bool f=true;
			for(int i=0;i<n;i++){
				if(data[i]!=back[i])f=false;
			}
			if(f)break;
			for(int i=0;i<n;i++)back[i]=data[i];
			ans++;
		}
		std::cout<<ans<<std::endl;
		for(int i=0;i<n;i++){
			if(i!=n-1)std::cout<<data[i]<<" ";
			else std::cout<<data[i];
		std::cout<<std::endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: Java

import java.util.Scanner;

public class SmartCalculator {
	static String str;
	static int pos;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			str = sc.next();
			pos = 0;
			System.out.println(expression());
		}
		sc.close();
	}

	static int expression() {
		int ret = term();
		while (pos < str.length()) {
			if (str.charAt(pos) == '+') {
				pos++;
				ret += term();
			} else if (str.charAt(pos) == '-') {
				pos++;
				ret -= term();
			} else {
				break;
			}
		}
		return ret;
	}

	static int term() {
		int ret = factor();
		while (pos < str.length()) {
			if (str.charAt(pos) == '*') {
				pos++;
				ret *= factor();
			} else if (str.charAt(pos) == '/') {
				pos++;
				ret /= term();
			} else {
				break;
			}
		}
		return ret;
	}

	static int factor() {
		if (str.charAt(pos) == '(') {
			pos++;
			return expression();
		} else {
			return number();
		}
	}

	static int number() {
		int ret = 0;
		while (Character.isDigit(str.charAt(pos))) {
			ret *= 10;
			ret += str.charAt(pos) - '0';
			pos++;
		}
		return ret;
	}

}

Compiler output:
Main.java:3: error: class SmartCalculator is public, should be declared in a file named SmartCalculator.java
public class SmartCalculator {
       ^
1 error
Language: Java

import java.util.Scanner;

public class SmartCalculator {
	static String str;
	static int pos;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			str = sc.next();
			pos = 0;
			System.out.println(expression());
		}
		sc.close();
	}

	static int expression() {
		int ret = term();
		while (str.charAt(pos) != '=') {
			if (str.charAt(pos) == '+') {
				pos++;
				ret += term();
			} else if (str.charAt(pos) == '-') {
				pos++;
				ret -= term();
			} else {
				break;
			}
		}
		return ret;
	}

	static int term() {
		int ret = factor();
		while (str.charAt(pos) != '=') {
			if (str.charAt(pos) == '*') {
				pos++;
				ret *= factor();
			} else if (str.charAt(pos) == '/') {
				pos++;
				ret /= term();
			} else {
				break;
			}
		}
		return ret;
	}

	static int factor() {
		if (str.charAt(pos) == '(') {
			pos++;
			int temp = expression();
			pos++;
			return temp;
		} else {
			return number();
		}
	}

	static int number() {
		int ret = 0;
		while (Character.isDigit(str.charAt(pos))) {
			ret *= 10;
			ret += str.charAt(pos) - '0';
			pos++;
		}
		return ret;
	}

}

Compiler output:
Main.java:3: error: class SmartCalculator is public, should be declared in a file named SmartCalculator.java
public class SmartCalculator {
       ^
1 error
Language: Java

def calc(array):
	while not len(array) == 1:
		if '*' in array:
			x = array.index('*')
			array[x + 1] = str(int(array[x - 1]) * int(array[x + 1]))
			del array[x - 1:x + 1]
			continue
		if '/' in array:
			x = array.index('/')
			array[x + 1] = str(int(array[x - 1]) / int(array[x + 1]))
			del array[x - 1:x + 1]
			continue
		if '-' in array:
			x = array.index('-')
			array[x + 1] = str(int(array[x - 1]) - int(array[x + 1]))
			del array[x - 1:x + 1]
			continue
		if '+' in array:
			x = array.index('+')
			array[x + 1] = str(int(array[x - 1]) + int(array[x + 1]))
			del array[x - 1:x + 1]
			continue
	return str(array[0])

n = input()
for i in xrange(n):
	array = list(raw_input())
	
	while '(' in array:
		x1 = array.index('(') + 1
		x2 = array.index(')')
		jon = array[x1:x2]
		array[x2] = calc(jon)
		del array[x1 - 1:x2]
	print calc(array[0:len(array) - 1])

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
def calc(array):
^
  (use --enable-preview to enable unnamed classes)
Main.java:1: error: <identifier> expected
def calc(array):
              ^
Main.java:1: error: ';' expected
def calc(array):
               ^
Main.java:5: error: class, interface, enum, or record expected
			array[x + 1] = str(int(array[x - 1]) * int(array[x + 1]))
			                   ^
4 errors
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

import static java.lang.Integer.parseInt;

/**
 * Smart Calculator
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		//skip first line
		br.readLine();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			Deque<String> queue = new ArrayDeque<>();
			Deque<Character> stack = new ArrayDeque<>();

			char _c = 0;
			for (char c : line.toCharArray()) {
				switch (c) {
					case '+':
					case '-':
						if (!stack.isEmpty()) {
							while (stack.peek() == '*' || stack.peek() == '/')){
								queue.offer(String.valueOf(stack.pop()));
							}
						}
						stack.push(c);
						break;
					case '*':
					case '/':
					case '(':
						stack.push(c);
						break;
					case ')':
						while (stack.peek() != '(') {
							queue.offer(String.valueOf(stack.pop()));
						}
						stack.pop();
						break;
					case '=':
						while (!stack.isEmpty()) {
							queue.offer(String.valueOf(stack.pop()));
						}
						break;
					default:
						if ('0' <= _c && _c <= '9') {
							String s = queue.pollLast();
							queue.offer(s + c);
						} else {
							queue.offer(String.valueOf(c));
						}
				}
				_c = c;
			}

			//solve
			Deque<Integer> ans = new ArrayDeque<>();
			for (String s : queue) {
				if ("+-*/".indexOf(s) != -1) {
					int a, b;
					b = ans.pop();
					a = ans.pop();
					switch (s) {
						case "+":
							ans.push(a + b);
							break;
						case "-":
							ans.push(a - b);
							break;
						case "*":
							ans.push(a * b);
							break;
						case "/":
							ans.push(a / b);
							break;
					}
				} else {
					ans.push(parseInt(s));
				}
			}
			System.out.println(ans.peek());

		}//end while
	}//end main
}

Compiler output:
Main.java:33: error: illegal start of expression
							while (stack.peek() == '*' || stack.peek() == '/')){
							                                                  ^
1 error
Language: Java

import javax.script.*;

public class EvalScript {
    public static void main(String[] args) throws Exception {
        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("JavaScript");
       
        engine.eval("println('Hello JavaScript from Java.')");
       
        engine.eval("var str1 = 'JavaScript String'");
        engine.eval("println(str1);");
        engine.eval("var str2 = new java.lang.String('Java String');");
        engine.eval("println(str2);");
       
        engine.eval("var array = ['JavaScript', 'Array'];");
        engine.eval("println(array);");
        engine.eval("var list = new java.util.ArrayList();");
        engine.eval("list.add('Java');");
        engine.eval("list.add('ArrayList');");
        engine.eval("println(list);");
       
        engine.eval("var obj = {'JavaScript':'Object'};");
        engine.eval("println(obj);");
        engine.eval("var map = new java.util.HashMap();");
        engine.eval("map.put('Java', 'HashMap');");
        engine.eval("println(map);");
       
        Runtime r = Runtime.getRuntime();
        engine.put("r", r);
        engine.eval("print('Max:   ' + r.maxMemory() + ' Bytes\\n');");
        engine.eval("print('Total: ' + r.totalMemory() + ' Bytes\\n');");
        engine.eval("print('Free:  ' + r.freeMemory() + ' Bytes\\n');");
    }
}

Compiler output:
Main.java:3: error: class EvalScript is public, should be declared in a file named EvalScript.java
public class EvalScript {
       ^
1 error
Language: Java

import javax.script.*;
class Main{
	public static void main(String[]z){
        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("JavaScript");
       
        engine.eval("println('Hello JavaScript from Java.')");
       

	}
}

Compiler output:
Main.java:7: error: unreported exception ScriptException; must be caught or declared to be thrown
        engine.eval("println('Hello JavaScript from Java.')");
                   ^
1 error
Language: C

#include <iostream>
#include <string>
using namespace std;

string s;

int single(int& pos);

int figure(int& pos);

int solve(int& pos);

int main(){
	int T;
	cin>>T;
	for(int i = 0; i < T; i++){
		cin>>s;
		int pos = 0;
		cout<<solve(pos)<<endl;
	}
	
	return 0;
}

int single(int& pos){//??°??????????????????????????¢??°
	if(s[pos]!='('){
		int res = 0;
		while('0'<=s[pos] && s[pos]<='9'){
			res *= 10;
			res += s[pos]-48;
			pos++;
		}
		return res;
	}else{
		return solve(++pos);
	}
}

int figure(int& pos){//????????????????????????????????¢??°
	int res = single(pos);
	while(1){
		if(s[pos]=='*'){
			res *= single(++pos);
		}else if(s[pos]=='/'){
			res /= single(++pos);
		}else {
			return res;
		}
	}
}

int solve(int& pos){//?????¨???????¨????????????¢??°(????????????????¨?????????????????????¨?????????)
	int res = figure(pos);
	while(s[pos]!='=' && s[pos]!=')'){
		if(s[pos]=='+') res += figure(++pos);
		else if(s[pos]=='-') res -= figure(++pos);
	}
	pos++;
	return res;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <string>
using namespace std;
 
int calc1();
int calc2();
int calc3();
 
int p;
string eq;
 
int calc1() {
  int a = calc2();
  while (eq[p]=='+' || eq[p]=='-') {
    if (eq[p]=='+') {
      p++;
      a += calc2();
    } else if (eq[p]=='-') {
      p++;
      a -= calc2();
    }
  }
  return a;
}
 
int calc2() {
  int a = calc3();
  while (eq[p]=='*' || eq[p]=='/') {
    if (eq[p]=='*') {
      p++;
      a *= calc3();
    } else if (eq[p]=='/') {
      p++;
      a /= calc3();
    }
  }
  return a;
}
 
int calc3() {
  int a;
  if (eq[p]=='(') {
    p++;
    a = calc1();
    p++;
  } else {
    a = 0;
    while (eq[p]>='0'&&eq[p]<='9') {
      a *= 10;
      a += eq[p++] - '0';
    }
  }
  return a;
}
 
int main() {
  int n, r;
 
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> eq;
    p = 0;
    r = calc1();
    cout << r << endl;
  }
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<string>
#include<sstream>
 
typedef std::stringstream sst;
 
int ToInt(std::string str){
    int i;
    sst ss;
    ss<<str;
    ss>>i;
    return i;
}
std::string ToStr(int i){
    std::string str;
    sst ss;
    ss<<i;
    ss>>str;
    return str;
}
 
std::string SubStr(std::string str,int x,int y){
    return str.substr(x,y-x+1);
}
int Third(std::string str){
    int fres,Ans;
    while( ( fres=str.find_first_of("+-",1) ) != std::string::npos ){
        int aRes;
         
        if( (aRes=str.find_first_of("+-",fres+2)) == std::string::npos )
            aRes=str.size()-1;
        else --aRes;
         
        if( str[fres] =='+' ){
            Ans=ToInt(SubStr(str,0,fres-1))+ToInt(SubStr(str,fres+1,aRes));
            str.replace(0,SubStr(str,0,aRes).size(),ToStr(Ans).c_str());
        }else{
            Ans=ToInt(SubStr(str,0,fres-1))-ToInt(SubStr(str,fres+1,aRes));
            str.replace(0,SubStr(str,0,aRes).size(),ToStr(Ans).c_str());
        }
    }
    return ToInt(str);
}
 
int Second(std::string str){
    int fres,Ans;
    while( ( fres=str.find_first_of("*/") ) != std::string::npos ){
        int bRes,aRes;
        if( (bRes=str.find_last_of("+-",fres)) == std::string::npos  || bRes==0 )
            bRes=0;
        else ++bRes;
         
        if( (aRes=str.find_first_of("+-*/",fres+2)) == std::string::npos )
            aRes=str.size()-1;
        else --aRes;
         
        if( str[fres] =='*' ){
            Ans=ToInt(SubStr(str,bRes,fres-1))*ToInt(SubStr(str,fres+1,aRes));
            str.replace(bRes,SubStr(str,bRes,aRes).size(),ToStr(Ans).c_str());
        }else{
            Ans=ToInt(SubStr(str,bRes,fres-1))/ToInt(SubStr(str,fres+1,aRes));
            str.replace(bRes,SubStr(str,bRes,aRes).size(),ToStr(Ans).c_str());
        }
    }
    Ans=Third(str);
    return Ans;
}
 
int First(std::string str){
    int fres;
    while( (fres = str.find(")") ) != std::string::npos ){
        int rfres=str.rfind("(",fres);
        std::string Next=SubStr(str,rfres+1,fres-1);
        int cRes=Second(Next);
        str.replace(rfres,Next.size()+2,ToStr(cRes).c_str());
    }
    int lRes = Second(str);
     
    return lRes;
}
 
int main(){
    int n;
  std::string str;
    std::cin>>n;
    while( n-- ){
        std::cin>>str;
      std::cout<<First(str)<<std::endl;
    }
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int i;
string str;
int Expression();
int Term();
int Factor();
int No(int);
int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> str;
    i = 0;
    cout << Expression() << endl;
  }
}
int Expression(){
  int res = Term();
  while(1){
    switch(str[i]){
    case '+':
      i++;
      res += Term();
      break;
    case '-':
      i++;
      res -= Term();
      break;
    default:
      return res;
    }
  }
}
int Term(){
  int res = Factor();
  while(true){
    switch(str[i]){
    case '(':
      i++;
      res += Factor();
      break;
    case '*':
      i++;
      res *= Factor();
      break;
    case '/':
      i++;
      res /= Factor();
      break;
    default:
      return res;
    }
  }
}
int Factor(){
  int res = 0;
  switch(str[i]){
  case '(':
    i++;
    res = Expression();
    i++;
    return res;
  default:
    return No(i);
  }
}
int No(int old){
  while(isdigit(str[i])) i++;
  return atoi((str.substr(old,i)).c_str());
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

l=[eval(raw_input()[:-1]) for i in range(int(input()))]
for i in l:
    print i


Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | l=[eval(raw_input()[:-1]) for i in range(int(input()))]
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'l' [-Wimplicit-int]
main.c:1:3: error: expected expression before '[' token
    1 | l=[eval(raw_input()[:-1]) for i in range(int(input()))]
      |   ^
main.c:1:4: error: implicit declaration of function 'eval' [-Wimplicit-function-declaration]
    1 | l=[eval(raw_input()[:-1]) for i in range(int(input()))]
      |    ^~~~
main.c:1:9: error: implicit declaration of function 'raw_input' [-Wimplicit-function-declaration]
    1 | l=[eval(raw_input()[:-1]) for i in range(int(input()))]
      |         ^~~~~~~~~
main.c:1:26: error: expected ']' before 'for'
    1 | l=[eval(raw_input()[:-1]) for i in range(int(input()))]
      |                          ^~~~
      |                          ]
main.c:2:1: error: expected ',' or ';' before 'for'
    2 | for i in l:
      | ^~~
Language: C

i = 0

def number(begin):
	global i
	
	if begin[i] == "(":
		i += 1
		res = expression(begin)
		i += 1 
		return res
	
	res = 0
	
	while begin[i].isdigit():
		res *= 10
		res += int(begin[i])
		i+=1
	
	return res
	
def term(begin):# your code goes here

	global i
	res = number(begin)
	
	while True:
		if begin[i] == "*":
			i += 1
			res *= number(begin)
		elif begin[i] == "/":
			i += 1
			res /= number(begin)
		else:
			break
	return res
	
def expression(begin):
	
	global i
	res = term(begin)
	
	while True:
		if begin[i] == "+":
			i += 1
			res += term(begin)
			
		elif begin[i] == "-":
			i += 1
			res -= term(begin)
		else:
			break
	return res
	

def main():
	ex = raw_input() +"="
	ans = expression(ex)
	
	print ans
	
main()

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | i = 0
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:3:1: error: expected ',' or ';' before 'def'
    3 | def number(begin):
      | ^~~
main.c:21:17: error: stray '#' in program
   21 | def term(begin):# your code goes here
      |                 ^
Language: C

#include <iostream>
#include <cctype>
using namespace std;
int expr(string& s,int& i);
int term(string& s,int& i);
int factor(string& s,int& i);
int number(string& s,int& i);


int expr(string& s,int& i){
  int val = term(s,i);
  while(s[i]=='+' || s[i]=='-'){
    char op = s[i];
    i++;
    int val2 = term(s,i);
    if(op=='+')val += val2;
    else val -= val2;
  }
  return val;
}

int term(string& s,int& i){
  int val = factor(s,i);
  while(s[i]=='*' || s[i]=='/'){
    char op = s[i];
    i++;
    int val2 = factor(s,i);
    if(op=='*')val *= val2;
    else val /= val2;
  }
  return val;
}

int factor(string& s,int& i){
  if(isdigit(s[i]))return number(s,i);


  i++;
  int ret = expr(s,i);
  i++;
  return ret;
}

int number(string& s,int& i){
  int n = s[i++] - '0';
  while(isdigit(s[i])) n=n*10 + s[i++] - '0';
  return n;
}

int main(void)
{
  int n;
  cin >> n;
  
  for(int i=0;i<n;i++){
    string str;
    cin >> str;
    int j=0;
    cout << expr(str,j) << endl;
  }

}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include "pch.h"
#include <iostream>
#include <string>
#include <cctype>
#include <vector>
using namespace std;

inline bool is_op(string &in) {
	if (in.size() == 1 && !isdigit(in[0]))
	{
		return true;
	}
	else
	{
		return false;
	}
}
inline bool is_num(string &in)
{
	for (auto i : in)
	{
		if (!isdigit(i))
			return false;
	}
	return true;
}
inline bool is_expr(string &in)
{
	if (!is_num(in) && !is_op(in)) { return true; }
	else { return false; }
}
vector<string> split(string in)
{
	vector<string> spl;
	int pos = 0;
	if (in[pos] == '-') 
	{
		pos++;
		while (pos < in.size()) {
			if (isdigit(in[pos])) {
				pos++;
			}
			else {
				break;
			}
		}
		spl.push_back(in.substr(0, pos));
		in.erase(0, pos);
		pos = 0;
	}
	while ( pos < in.size())
	{
		if (!isdigit(in[pos]))
		{
			if (pos != 0)
			{
				spl.push_back(in.substr(0, pos));
				in.erase(0, pos);
				pos = 0;
			}
			else
			{
				if (in[0] == '(')
				{
					int cnt = 1;
					int r_pos = 1;
					for (r_pos = 1; r_pos < in.size(); r_pos++)
					{
						if (in[r_pos] == '(')
							cnt++;
						if (in[r_pos] == ')')
							cnt--;
						if (cnt == 0)
							break;
					}
					spl.push_back(in.substr(pos + 1, r_pos - 0 - 1));
					in.erase(0, r_pos + 1);
					pos = 0;
					continue;
				}
				else if (in[0] == '+' || in[0] == '-' || in[0] == '*' || in[0] == '/')
				{
					spl.push_back(in.substr(0, 1));
					in.erase(0, 1);
					pos = 0;
				}
			}
		}
		else {
			pos++;
		}
	}
	if (in.size() != 0) spl.push_back(in);
	return spl;
}
int cal(string &in_str) {
	auto in = split(in_str);
	while (in.size() != 1) {
		auto pos = in.begin();
		while (pos != in.end()) 
		{
			if (*pos == "*") {
				pos--;
				*pos = to_string(cal(*pos)*cal(*(pos + 2)));
				in.erase(pos+1 , pos + 3);
			}
			else if (*pos == "/") {
				pos--;
				*pos = to_string(cal(*pos)/cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if (pos != in.end()) pos++;
		}
		pos = in.begin();
		while (pos != in.end()) {
			if (*pos == "+") {
				pos--;
				*pos = to_string(cal(*pos)+cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			else if (*pos == "-") {
				pos--;
				*pos = to_string(cal(*pos) - cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if(pos != in.end()) pos++;
		}
	}
	return(stoi(in[0]));
}
int main()
{
	/*string tmp = "(-2*2)*5+(1+2)*(3+4)";
	auto out=split(tmp);
	for (auto i : out) {
		cout << i << endl;
	}
	cout << cal(tmp) << endl;*/
	string input;
	int n;
	cin >> n;
	while (n--) {
		cin >> input;
		input.erase(input.end() - 1);
		cout << cal(input) << endl;
	}
	return 0;
}



Compiler output:
a.cc:1:10: fatal error: pch.h: No such file or directory
    1 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

#include <iostream>

#include <cassert>
#include <cctype>
using namespace std;
string S;
size_t cur = 0;
int term();
int factor();
int expression();
int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0'; 
	cur = cur + 1;
	return n;
}
int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur]))
		n = n*10 + digit();
	return n;
}
int expression(){
	int a =term();
	while (cur < S.size()) && (S[cur] == '+' || S[cur] == '-')){
		char op = S[cur++];
		int b = term();
		if (op == '+') a += b;
		else a -= b;
	}
	return a;
}
int term(){
	int a =factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if (op == '*') a *= b; else a /= b;
	}
	return a;
}
int factor(){
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur +=1;
	return n;
}
int main() {

	int N;
	cin >> N;
	for (int i=0; i<N;++i){
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;

}

Compiler output:
a.cc: In function 'int expression()':
a.cc:25:35: error: expected identifier before '(' token
   25 |         while (cur < S.size()) && (S[cur] == '+' || S[cur] == '-')){
      |                                   ^
Language: C++

#include <cmath>
#include <cassert>
#include <iostream>

using namespace std;

string S;
size_t cur = 0;

int digit() {
	int n;
	assert(isdigit(S[cur]));
	n = S[cur] -'0';
	++cur;
	return n;
}

int number() {
	int n = digit();
	while (cur < S.size() && isdigit(S[cur])) {
		n = n*10 + digit();
	}
	return n;
}

int expression();
int factor() {
	int n;
	if (S[cur] != '(') n = number();
	else {
		++cur;
		n = expression();
		assert(S[cur] == ')');
	}
	return n;
}

int term() {
	int t = factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
		char op = S[cur++];
		int b = factor();
		if(op == '*') t *= b; else t = (int)trunk(1.0*t/b);
	}
	return t;
}


/*int expression() {
	int sum = number();
	while (S[cur] == '+' || S[cur] == '-') {
		char op = S[cur++];
		int b = number();
		if(op == +) sum += b;	else return sum -= b;
	}
	return sum;
}*/

int expression() {
	int sum = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
		char op = S[cur++];
		int b = term();
		if(op == '+') sum += b; else sum -= b;
	}
	return sum;
}


int main() {
	int N;
	cin >> N;
	for (int i=0; i<N; ++i) {
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int term()':
a.cc:43:53: error: 'trunk' was not declared in this scope; did you mean 'trunc'?
   43 |                 if(op == '*') t *= b; else t = (int)trunk(1.0*t/b);
      |                                                     ^~~~~
      |                                                     trunc
Language: C++

#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
class ParseError{};

int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

int term(State &begin) {
    int ret = number(begin);

    for (;;) {
        if (*begin == '*') {
            begin++;
            ret *= number(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= number(begin);
        } else {
            break;
        }
    }

    return ret;
}

int expression(State &begin) {
    int ret = term(begin);

    for (;;) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }

    return ret;
}


int main(void){
	int N;
    cin >> N;
    cin.ignore()
    for (int i = 0; i < N; i++) {
        string s;
        getline(cin, s);

        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:17: error: expected ';' before 'for'
   61 |     cin.ignore()
      |                 ^
      |                 ;
   62 |     for (int i = 0; i < N; i++) {
      |     ~~~          
a.cc:62:21: error: 'i' was not declared in this scope
   62 |     for (int i = 0; i < N; i++) {
      |                     ^
Language: C++

gets;$<.each_line.map{|s|p eval(s[0..-3])}

Compiler output:
a.cc:1:35: error: too many decimal points in number
    1 | gets;$<.each_line.map{|s|p eval(s[0..-3])}
      |                                   ^~~
a.cc:1:1: error: 'gets' does not name a type
    1 | gets;$<.each_line.map{|s|p eval(s[0..-3])}
      | ^~~~
a.cc:1:6: error: '$' does not name a type
    1 | gets;$<.each_line.map{|s|p eval(s[0..-3])}
      |      ^
Language: C++

#!/usr/bin/python3

import re
n = int(input())
for _ in range(n):
    print(eval(re.sub(r'(\d+/\d+)', r'int(\1)', input()[0:-1])))

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/python3
      |  ^
a.cc:6:24: warning: unknown escape sequence: '\d'
    6 |     print(eval(re.sub(r'(\d+/\d+)', r'int(\1)', input()[0:-1])))
      |                        ^~~~~~~~~~~
a.cc:6:24: warning: unknown escape sequence: '\d'
a.cc:6:24: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
a.cc:6:38: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
    6 |     print(eval(re.sub(r'(\d+/\d+)', r'int(\1)', input()[0:-1])))
      |                                      ^~~~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import re
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

//?????????
//??????00-440415D???Smart_Calculator.cpp

#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <stdio.h>

using namespace std;

string S = "1+2*(3+4)";
size_t cur = 0;

int expression();

int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur++]-'0';
	return n;
}

int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur])){
		n = n*10 + digit();
	}
	return n;
}

int factor(){
	if(S[cur] != '('){
		return number();
	}else{
		cur++;
		int n = expression();
		assert(S[cur])==')');
		cur++;
		return n;
	}
}

//??????????????????????????????
int term(){
	int a = factor();
	while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if(op == '*'){
			a *= b;
		}else if(op == '/'){
			a /= b;
		}
	}
	return a;
}

int expression(){
	int sum = term();
	while(S[cur] == '+' || S[cur] == '-'){
		char op = S[cur++];
		int b = term();
		if(op == '+'){
			sum += b;
		}else if(op == '-'){
			sum -= b;
		}
	}
	return sum;
}

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		cur = 0;
		cin >> S;
		S.resize(S.size-1);
		cout << expression() << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int factor()':
a.cc:37:31: error: invalid operands of types 'void' and 'char' to binary 'operator=='
   37 |                 assert(S[cur])==')');
      |                               ^~~~~
      |                                 |
      |                                 char
a.cc: In function 'int main()':
a.cc:78:28: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   78 |                 S.resize(S.size-1);
      |                          ~~^~~~
      |                                ()
Language: C++

#include <iostream>
#include <string>
using namespace std;
string str;
int p;

int exp();
int factor();
int term();

int factor() {
  int num=0;
  while('0' <= str[p] && str[p] <= '9') {
    num*=10;
    num += str[p] - '0';
    p++;
  }

  else if (str[p] == '('){
    p++;
    num = exp();
  }
  if(str[p] == ')')  p++;

   
  return num;
}

int term(){
 int val = factor();
  while(str[p] == '*' || str[p] == '/') {
    if(str[p] == '*') {
      p++;
      val *= factor();
    } else if(str[p] == '/'){
      p++;
      val /= factor();
    }
  }

  return val;
}
 
int exp() {
  int val = term();
  while(str[p] == '+' || str[p] == '-') {
    if(str[p] == '+') {
      p++;
      val += term();
    } else if(str[p] == '-'){
      p++;
      val -= term();
    }
  }

  return val;
}

int main() {
  int n;

  cin >> n;
  
  for(int i=0;i<n;i++) {
    p = 0;
  cin >> str;
  cout << exp() << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int factor()':
a.cc:19:3: error: 'else' without a previous 'if'
   19 |   else if (str[p] == '('){
      |   ^~~~
Language: C++

#include <string>
#include <cctype>
#include <iostream>
typedef std::string::const_iterator State;
class ParseError {};

int number(State &begin){
	int ret = 0;

	while(isdigit(*begin)){
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}

	return ret;
}

int factor(State &begin){
	if(*begin == '('){
		begin++;
		int ret = expression(begin);
		begin++;
	}else{
		return number(begin);
	}
}

int term(State &begin){
	int ret = factor(begin);

	for(;;){
		if(*begin == '*'){
			begin++;
			ret *= factor(begin);
		}else if(*begin == '/'){
			begin++;
			ret /= factor(begin);
		}else{
			break;
		}
	}
	return ret;
}

int expression(State &begin){
	int ret = term(begin);

	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		} else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}else {
			break;
		}
	}
	return ret;
}

int main(){
	int N;
	std::cin >> N;
	std::cin.ignore();
	for(int i = 0; i < N; ++i){
		std::string s;
		std::getline(std::cin, s);
		State begin = s.begin();
		int ans = expression(begin);
		std::cout << ans << std::endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int factor(State&)':
a.cc:22:27: error: 'expression' was not declared in this scope
   22 |                 int ret = expression(begin);
      |                           ^~~~~~~~~~
a.cc:27:1: warning: control reaches end of non-void function [-Wreturn-type]
   27 | }
      | ^
Language: C++

//https://gist.github.com/draftcode/1357281
#include <string>
#include <cctype>
#include <iostream>
typedef std::string::iterator State;
class ParseError {};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int expression(State &begin);
void consume(State &begin, char expected){
	if(*begin == expected){
		begin++;
	}else{
		std::cerr << "Expected '" << expected << "' but got '"<<*begin << "'"<<std::endl;
		std::cerr << "Rest string is '";
		while(*begin){
			std::cerr << *begin++;
		}
		std::cerr<<"'"<<std::endl;
		throw ParseError();
	}
}

int main(void){
	int N;
	std::cin >> N;
	std::cin.ignore();
	while(N--){
		std::string s;
		std::getline(std::cin, s);
		//std::cin>>s;
		State begin = s.begin();
		int ans = expression(begin);
		//consume(begin, '=');
		std::cout << ans << std::endl;
	}
	return 0;
}

int number(State &begin){
	int ret = 0;

	while(isdigit(*begin)){
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}

	return ret;
}

int factor(State &begin){
	if(*begin == '('){
		//consume(begin,'(');
		begin++;
		int ret = expression(begin);
		//consume(begin,')');
		begin++;
	}else{
		return number(begin);
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);

	for(;;){
		if(*begin == '*'){
			begin++;
			ret *= factor(begin);
		}else if(*begin == '/'){
			begin++;
			ret /= factor(begin);
		}else{
			break;
		}
	}
	return ret;
}

int expression(State &begin){
	int ret = term(begin);

	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		} else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}else {
			break;
		}
	}
	return ret;
}

Compiler output:
a.cc: In function 'int factor(State&)':
a.cc:64:16: error: 'ret' was not declared in this scope
   64 |         return ret;
      |                ^~~