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

#include <stdio.h>

int n,A[50];
int solve (int i,int m){
	if (m==0) return 1;
	if (i>=n) return 0;
	int res = solve(i+1,m)|| solve(i+1,m-A[i]);
	return res;
	]

int main(){
	int q,Mi;
	
	scanf("%d",&n);
	for(i=0,i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}



Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:9:9: error: expected primary-expression before ']' token
    9 |         ]
      |         ^
a.cc:24:2: error: expected '}' at end of input
   24 | }
      |  ^
a.cc:4:24: note: to match this '{'
    4 | int solve (int i,int m){
      |                        ^
Language: C++

#include <stdio.h>

int n,A[50];
int solve (int i,int m){
	if (m==0) return 1;
	if (i>=n) return 0;
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
	]

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0,i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}



Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:9:9: error: expected primary-expression before ']' token
    9 |         ]
      |         ^
a.cc:24:2: error: expected '}' at end of input
   24 | }
      |  ^
a.cc:4:24: note: to match this '{'
    4 | int solve (int i,int m){
      |                        ^
Language: C++

#include<stdio.h>

int n,A[50];
int solve (int i,int m){
	if (m==0) return 1;
	if (i>=n) return 0;
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
	]

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0,i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}



Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:9:9: error: expected primary-expression before ']' token
    9 |         ]
      |         ^
a.cc:24:2: error: expected '}' at end of input
   24 | }
      |  ^
a.cc:4:24: note: to match this '{'
    4 | int solve (int i,int m){
      |                        ^
Language: C++

#include <stdio.h>

int n,A[50];


int solve (int i,int m){
	if (m==0) return 1;
	if (i>=n) return 0;
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0,i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if( solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:24: error: expected ';' before ')' token
   17 |         for(i=0,i<n;i++) scanf("%d",&A[i]);
      |                        ^
      |                        ;
Language: C++


import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		int q = in.nextInt();
		int[] m = new int[q];
		for (int i = 0; i < q; i++) {
			m[i] = in.nextInt();
		}

		// solve
		boolean[][] dp = new boolean[n+1][2001];
		dp[0][0] = true;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2001; j++) {
				if (a[i] <= j) {
					dp[i+1][j] = dp[i][j-a[i]] | dp[i][j];
				} else {
					dp[i+1][j] = dp[i][j];
				}
			}
		}

		for (int i = 0; i < q; i++) {
			if (dp[n][m[i]]) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

	}

}



Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.IOException;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>

int b[30];
int n;
int solve(int i,int m){
	if(m==0)
		return 1;
	if(i>=n)
		return 0;
	int res;
	if(m-b[i]<0)
		res=solve(i+1,m)||solve(i+1,m-b[i]);
	else
		res=solve(i+1,m);
	return res;
}
int main()
{
	ios::sync_with_stdio(false);
	int m;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>b[i];
		}
		cin>>m;
		int te;
		for(int i=0;i<m;i++){
			cin>>te;
			if(solve(0,te))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}
	
	
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'ios' has not been declared
   28 |         ios::sync_with_stdio(false);
      |         ^~~
a.cc:30:15: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   30 |         while(cin>>n){
      |               ^~~
      |               std::cin
In file included from a.cc:5:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:39:33: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   39 |                                 cout<<"yes"<<endl;
      |                                 ^~~~
      |                                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:39:46: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   39 |                                 cout<<"yes"<<endl;
      |                                              ^~~~
      |                                              std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:41:33: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   41 |                                 cout<<"no"<<endl;
      |                                 ^~~~
      |                                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:41:45: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   41 |                                 cout<<"no"<<endl;
      |                                             ^~~~
      |                                             std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

n=gets.to_i
aa=gets.split.map!{|i|i.to_i}
aa.slice!(n..-1)
q=gets.to_i
m=gets.split.map!{|i|i.to_i}
m.slice!(q..-1)
aa.sort!
for x in m do
  str="no"
  n.times do |i|
    (i+1).upto(n-1) do |j|
      if x==aa[i]+aa[j] then
        str="yes"
      elsif x<aa[i]+aa[j] then
        break
      end
    end
  end
  print str+"\n"
end


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n=gets.to_i
      | ^
a.cc:3:1: error: 'aa' does not name a type
    3 | aa.slice!(n..-1)
      | ^~
a.cc:6:1: error: 'm' does not name a type
    6 | m.slice!(q..-1)
      | ^
Language: C++

#include<iostream>

int main()
{
  int n,q;
  int A[2000]={0};
  int m[2000]={0};
  int ans[2000]={0};

  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>A[i];
  }
  std::cin>>q;
  for(int i=0;i<q;i++){
    std::cin>>m[i];
  }

  for(int i=0;i<q;i++){
    for(int j=0;j<n-1;j++){
      for(int k=j+1;k<n;k++){
	int sum=A[j]+A[k];
	if(m[i]==sum){
	  ans[i]=1;
	  break;
	  //}else{
	  //sum+=A[k+i]
      }
    }
  }
  for(int i=0;i<q;i++){
    if(ans[i]==1){
      std::cout<<"yes"<<'\n';
    }else{
      std::cout<<"no"<<'\n';
    }
  }
  return 0;
}



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

#include<iostream>

int n,q;
int m,num;
int A[2000];
bool flg=false;

void cal(int x){
	if(num!=m){
		for(int i=x;i<n;i++){
			if(num+A[i]<=m){
				num+=A[i];
				if(num==m) flag=true;
				if((i+1)<n) cal(i+1);
				num-=A[i];
			}
		}
	}
}

int main(){
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>A[i];
	}
	std:cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>m;
		num=0;
		flg=false;
		cal(0);
		if(flg) std::cout<<"yes"<<'\n';
		if(!flg) std::cout<<"no"<<'\n';
	}
}


Compiler output:
a.cc: In function 'void cal(int)':
a.cc:13:44: error: 'flag' was not declared in this scope; did you mean 'flg'?
   13 |                                 if(num==m) flag=true;
      |                                            ^~~~
      |                                            flg
a.cc: In function 'int main()':
a.cc:26:13: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |         std:cin>>q;
      |             ^~~
      |             std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

#include<iostream>

int n,q;
int m,num;
int A[2000];
bool flg=false;

void cal(int x){
	if(num!=m){
		for(int i=x;i<n;i++){
			if(num+A[i]<=m){
				num+=A[i];
				if(num==m) flg=true;
				if((i+1)<n) cal(i+1);
				num-=A[i];
			}
		}
	}
}

int main(){
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>A[i];
	}
	std:cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>m;
		num=0;
		flg=false;
		cal(0);
		if(flg) std::cout<<"yes"<<'\n';
		if(!flg) std::cout<<"no"<<'\n';
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:13: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |         std:cin>>q;
      |             ^~~
      |             std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

def solve(i,m):
  if m==0:
      return True;
  if i>=n:
      return False;
  res=solve(i+1,m) or solve(i+1,m-a[i]);
  return res;


n=int(input())
a=input().split()
q=int(input())
m=input().split()
ans=[]
for i in range(n):
    a[i]=int(a[i])
for i in range(q):
    m[i]=int(m[i])
    ans=solve(0,m[i]);
    if ans==True:
        print("yes")
    else:
        print("no")



Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def solve(i,m):
      | ^~~
a.cc:4:3: error: expected unqualified-id before 'if'
    4 |   if i>=n:
      |   ^~
a.cc:6:3: error: 'res' does not name a type
    6 |   res=solve(i+1,m) or solve(i+1,m-a[i]);
      |   ^~~
a.cc:7:3: error: expected unqualified-id before 'return'
    7 |   return res;
      |   ^~~~~~
a.cc:10:1: error: 'n' does not name a type
   10 | n=int(input())
      | ^
a.cc:20:5: error: expected unqualified-id before 'if'
   20 |     if ans==True:
      |     ^~
Language: C++

#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
  int t;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = i; j < n; j++ ) {
      t = A[i] + A[j];
      if ( t == m ) return 1;
    }
  }
  return 0; 
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf ("no\n")
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: expected ';' before '}' token
   25 |     else printf ("no\n")
      |                         ^
      |                         ;
   26 |   }
      |   ~
Language: C++

#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  res = solve(i + 1, m) || solve (i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:8:3: error: 'res' was not declared in this scope
    8 |   res = solve(i + 1, m) || solve (i + 1, m - A[i]);
      |   ^~~
Language: C++

#include <iostream>
using namespace std;
 
int ans(int *A,int len,int i,int m,int sum){
  if (len==i){
	return 0;
	}
  if (sum+A[i] == m){
	 return 1;
	}
  if (ans(A,len,i+1,m,sum)){
	return 1;
	}
  return ans(A,len,i+1,m,sum + A[i]);
}
 
int main(){
  int n,A[30],q,m,i;
 
  cin >> n;
 
  for (i=0;i<n;i++)
    cin >> A[i];
 
    cin >> q;
 
  for (i=0;i<q;i++){
    cin >> m;
    if (es(A,n,0,m,0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'es' was not declared in this scope
   29 |     if (es(A,n,0,m,0))
      |         ^~
Language: C++

#include <iostream>
using namespace std;
 
int ans(int *A,int len,int i,int m,int sum){
  if (len==i){
	return 0;
	}
  if (sum+A[i] == m){
	 return 1;
	}
  if (ans(A,len,i+1,m,sum)){
	return 1;
	}else{
		return ans(A,len,i+1,m,sum + A[i]);
	}
}
 
int main(){
  int n,A[30],q,m,i;
 
  cin >> n;
 
  for (i=0;i<n;i++)
    cin >> A[i];
 
    cin >> q;
 
  for (i=0;i<q;i++){
    cin >> m;
    if (es(A,n,0,m,0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'es' was not declared in this scope
   30 |     if (es(A,n,0,m,0))
      |         ^~
Language: C++

#include <iostream>
using namespace std;
 
int ans(int *A,int len,int i,int m,int sum){
  if (len==i){
	return 0;
	}
  if (sum+A[i] == m){
	 return 1;
	}
  if (ans(A,len,i+1,m,sum)){
	return 1;
	}else{
		return ans(A,len,i+1,m,sum + A[i]);
		
}
 
int main(){
  int n,A[30],q,m,i;
 
  cin >> n;
 
  for (i=0;i<n;i++)
    cin >> A[i];
 
    cin >> q;
 
  for (i=0;i<q;i++){
    cin >> m;
    if (ans(A,n,0,m,0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int ans(int*, int, int, int, int)':
a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   18 | int main(){
      |         ^~
a.cc:18:9: note: remove parentheses to default-initialize a variable
   18 | int main(){
      |         ^~
      |         --
a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:11: error: a function-definition is not allowed here before '{' token
   18 | int main(){
      |           ^
a.cc:36:2: error: expected '}' at end of input
   36 | }
      |  ^
a.cc:4:44: note: to match this '{'
    4 | int ans(int *A,int len,int i,int m,int sum){
      |                                            ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c,d,n,m,num;
int t[2000];
bool flg=false;
void compute(int x){
	if(num != a){
		for(int i = x; i < n; i++){
			if(num+t[i] <= a){
				num += t[i];
				if(num == a){
					flg=true;
					if(i+1 < n) compute(i+1);
						num -= t[i];、
				}
			}
		}
	}
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t[i];
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		flg = false;
		cin >> a;
		num = 0;
		compute(0);
		if(flg) cout << "yes" << endl;
		if(!flg) cout << "no" << endl;
	}
}


Compiler output:
a.cc:15:61: error: extended character 、 is not valid in an identifier
   15 |                                                 num -= t[i];、
      |                                                             ^
a.cc: In function 'void compute(int)':
a.cc:15:61: error: '\U00003001' was not declared in this scope
   15 |                                                 num -= t[i];、
      |                                                             ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

int solve(int i,int x){
  if(x==0) return 1;
  if(i>=n) return 0;
  int ans=solve(i+1,m) ||solve(i+1,m-A[i]);
  return ans;
}

int main(){
  int a;
  cin >> a;
  int  A[21];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int q,t;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t
    if(solve(0,t)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:17:9: error: 'n' was not declared in this scope
   17 |   if(i>=n) return 0;
      |         ^
a.cc:18:21: error: 'm' was not declared in this scope
   18 |   int ans=solve(i+1,m) ||solve(i+1,m-A[i]);
      |                     ^
a.cc:18:38: error: 'A' was not declared in this scope
   18 |   int ans=solve(i+1,m) ||solve(i+1,m-A[i]);
      |                                      ^
a.cc: In function 'int main()':
a.cc:26:17: error: 'N' was not declared in this scope
   26 |   for(int i=0;i<N;i++){
      |                 ^
a.cc:32:13: error: expected ';' before 'if'
   32 |     cin >> t
      |             ^
      |             ;
   33 |     if(solve(0,t)) cout << "yes" << endl;
      |     ~~       
a.cc:34:5: error: 'else' without a previous 'if'
   34 |     else cout << "no" << endl;
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

int N ,A[21];

int solve(int i,int x){
  if(x==0) return 1;
  if(i>=N) return 0;
  int ans=solve(i+1,m) ||solve(i+1,m-A[i]);
  return ans;
}

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int q,t;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t
    if(solve(0,t)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:20:21: error: 'm' was not declared in this scope
   20 |   int ans=solve(i+1,m) ||solve(i+1,m-A[i]);
      |                     ^
a.cc: In function 'int main()':
a.cc:33:13: error: expected ';' before 'if'
   33 |     cin >> t
      |             ^
      |             ;
   34 |     if(solve(0,t)) cout << "yes" << endl;
      |     ~~       
a.cc:35:5: error: 'else' without a previous 'if'
   35 |     else cout << "no" << endl;
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

int N ,A[21];

int solve(int i,int x){
  if(x==0) return 1;
  if(i>=N) return 0;
  int ans=solve(i+1,x) ||solve(i+1,x-A[i]);
  return ans;
}

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int q,t;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t
    if(solve(0,t)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:13: error: expected ';' before 'if'
   33 |     cin >> t
      |             ^
      |             ;
   34 |     if(solve(0,t)) cout << "yes" << endl;
      |     ~~       
a.cc:35:5: error: 'else' without a previous 'if'
   35 |     else cout << "no" << endl;
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

int N ,A[21];

int solve(int i,int x){
  if(x==0) return 1;
  if(i>=N) return 0;
  int ans=solve(i+1,x) ||solve(i+1,x-A[i]);
  return ans;
}

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int q,t;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t
    if(solve(0,t)) {
      cout << "yes" << endl;
    }  else{
      cout << "no" << endl;
    } 
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:33:13: error: expected ';' before 'if'
   33 |     cin >> t
      |             ^
      |             ;
   34 |     if(solve(0,t)) {
      |     ~~       
a.cc:36:8: error: 'else' without a previous 'if'
   36 |     }  else{
      |        ^~~~
Language: C++

#include "stdafx.h"
#include<iostream>
#include<stdio.h>

using namespace std;

int n, A[50];

int solve(int i,int m) {
	if (m == 0)return 1;
	if (i >= n)return 0;
	int res = solve(i + 1, m) || solve(i+1,m-A[i]);
	return res;
}

int main()
{
	int q, M, i;

	scanf("%d",&n);
	for (i = 0;i < n;i++)scanf("%d",A);
	scanf("%d",q);
	for (i = 0;i < q;i++) {
		scanf("%d",&M);
		if (solve(0, M))printf("yes\n");
		else printf("no\n");
	}

    return 0;
}


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

#include <stdio.h>

int n, A[50];

int solve(int i, int m) {
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;
    
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++) {
        scanf("%d", &M) 
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:24: error: expected ';' before 'if'
   19 |         scanf("%d", &M)
      |                        ^
      |                        ;
   20 |         if (solve(0, M)) printf("yes\n");
      |         ~~              
a.cc:21:9: error: 'else' without a previous 'if'
   21 |         else printf("no\n");
      |         ^~~~
Language: C++

#include <iostream>
#include <vector>

void CheckCanMake( std::vector<int>& A, int m ){
    
    std::cout << "no\n";
}

bool solve( i, m, n ){
    if( m == 0 ){
        return true;
    }else if( i >= n ){
        return false;
    }
    return ( solve( i + 1, m, n ) || solve( i + 1, m - A[i], n ) );
    
}

int main(){
    std::cin.tie(0);

    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for( auto& a : A ){
        std::cin >> a;
    }

    int q;
    std::cin >> q;
    std::vector<int> M(n);
    for( auto& m : M ){
        std::cin >> m;
    }

    for( const auto& m : M ){
        for( int i = 0; i < A.size(); ++i ){
            if( solve( i, m, n ) ){
                std::cout << "yes\n";
                break;
            }
        }
        std::cout << "no\n";
    }

}


Compiler output:
a.cc:9:13: error: 'i' was not declared in this scope
    9 | bool solve( i, m, n ){
      |             ^
a.cc:9:16: error: 'm' was not declared in this scope; did you mean 'tm'?
    9 | bool solve( i, m, n ){
      |                ^
      |                tm
a.cc:9:19: error: 'n' was not declared in this scope
    9 | bool solve( i, m, n ){
      |                   ^
a.cc:9:21: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | bool solve( i, m, n ){
      |                     ^
a.cc: In function 'int main()':
a.cc:38:22: error: 'solve' cannot be used as a function
   38 |             if( solve( i, m, n ) ){
      |                 ~~~~~^~~~~~~~~~~
Language: C++

import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int i=0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_A = br.readLine();
	String str_q = br.readLine();
	String str_M = br.readLine();

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);

	int[] A = new int[n];
	int[] M = new int[q];

	Scanner sc_A = new Scanner(str_A).useDelimiter("\\s* \\s*");
	Scanner sc_M = new Scanner(str_M).useDelimiter("\\s* \\s*");

	while(sc_A.hasNext()){
	    A[i] = sc_A.nextInt();
	    i++;
	}

	i = 0;//カウント初期化

	while(sc_M.hasNext()){
	    M[i] = sc_M.nextInt();
	    i++;
	}

	for(i=0;i<q;i++){
	    int m = M[i];
	    System.out.println(exhausitiveSearch(n,A,q,m));
	}

	sc_A.close();
	sc_M.close();
    }
    
    private static String exhausitiveSearch(int n,int A[], int q, int m){
	int flag = 0;
	
	for(int i=0;i<n;i++){
	    int COUNT = 0;
	    
	    if(m == A[i]){
		flag = 1;
		break;
	    }
	    
	    for(int j=i+1;j<n;j++){
		if((m == A[j]) || (m == A[i] + A[j])){
		    flag = 1;
		    break;
		}
		COUNT++;
	    }
	    if(COUNT == 1) break; 
	}
	
	if(flag == 1) return "yes";
	else return "no";
    }
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:11: error: expected ':' before 'static'
    5 |     public static void main(String[] args) throws Exception{
      |           ^~~~~~~
      |           :
a.cc:5:29: error: 'String' has not been declared
    5 |     public static void main(String[] args) throws Exception{
      |                             ^~~~~~
a.cc:5:38: error: expected ',' or '...' before 'args'
    5 |     public static void main(String[] args) throws Exception{
      |                                      ^~~~
a.cc:5:42: error: expected ';' at end of member declaration
    5 |     public static void main(String[] args) throws Exception{
      |                                          ^
      |                                           ;
a.cc:5:44: error: 'throws' does not name a type
    5 |     public static void main(String[] args) throws Exception{
      |                                            ^~~~~~
a.cc:44:12: error: expected ':' before 'static'
   44 |     private static String exhausitiveSearch(int n,int A[], int q, int m){
      |            ^~~~~~~
      |            :
a.cc:44:20: error: 'String' does not name a type
   44 |     private static String exhausitiveSearch(int n,int A[], int q, int m){
      |                    ^~~~~~
a.cc:68:2: error: expected ';' after class definition
   68 | }
      |  ^
      |  ;
Language: C++

include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
  int n,q,A[3000],M[3000];
  int dp[3000];

  cin >> n;
  rep(i,n)cin >> A[i];
  cin >> q;
  rep(h,q){
    cin >> M[h];
    rep(i,M[h]+1)dp[i]=-1;
    dp[0] = 0;
    rep(i,n){
      for(int j=0;j<=M[h];j++){
	if(dp[j] >= 0){
	  dp[j] = 1;
	}
	else if(dp[j-A[i]] <= 0 || j<A[i]){
	  dp[j]=-1;
	}else{
	  dp[j] = dp[j-A[i]]-1;
	}
	//	cout << dp[j] << endl;
      }
    }
    if(dp[M[h]] >= 0)cout << "yes" << endl;
    else cout << "no" << endl;

  }

  return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:10:3: error: 'cin' was not declared in this scope
   10 |   cin >> n;
      |   ^~~
a.cc:30:22: error: 'cout' was not declared in this scope
   30 |     if(dp[M[h]] >= 0)cout << "yes" << endl;
      |                      ^~~~
a.cc:30:39: error: 'endl' was not declared in this scope
   30 |     if(dp[M[h]] >= 0)cout << "yes" << endl;
      |                                       ^~~~
a.cc:31:10: error: 'cout' was not declared in this scope
   31 |     else cout << "no" << endl;
      |          ^~~~
a.cc:31:26: error: 'endl' was not declared in this scope
   31 |     else cout << "no" << endl;
      |                          ^~~~
Language: C++

#include <iostream>
using namespace std;
bool solve(int p, int t);
int A[3000];
int main(){
  int n,q;
  cin >> n;
  for(int i=0; i<n; i++) cin >> A[i];	
  for(int i=0; i<n; i++) for(int j=i+1; j<n; j++)
	if(A[i]>A[j]) A[i] ^= A[j] ^= A[i] ^= A[j];
  cin >> q;
  for(int j=0, tmp; j<q; j++){
    cin >> tmp;
    for(int i=0,lim=n-1; i<n; i++)
  	if(tmp < A[i] && ((lim=(i-1>=0?i-1:0))?true:true)) break;
    if(solve(lim,tmp)) cout << "yes\n";
    else cout << "no\n";
  }
  return 0;
}
bool solve(int i, int t){
  if(t == A[i]) return true;
  if(t <= 0) return false;
  if(i == 0) return false;
  if(solve(i-1,t-A[i])) return true;
  if(solve(i-1,t)) return true;
  return false;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:14: error: 'lim' was not declared in this scope
   16 |     if(solve(lim,tmp)) cout << "yes\n";
      |              ^~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
vector<int> A;
string flag(string a,string b) return (a=="yes"||b=="yes")?"yes":"no";
string slove(int n,int sum)
{
	if(sum==0) return "yes";
	if(n<0) return "no";
	return flag(slove(n-1,sum),slove(n-1,sum-A[n]));
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	int n,q,m;
	cin >> n;
	A.resize(n);
	for(int i=0;i<n;i++) cin >> A[i];
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> m;
		cout << flag(slove(n-1,m),slove(n-1,m-A[n])) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'std::string flag(std::string, std::string)':
a.cc:5:39: error: expected identifier before '(' token
    5 | string flag(string a,string b) return (a=="yes"||b=="yes")?"yes":"no";
      |                                       ^
a.cc:5:32: error: named return values are no longer supported
    5 | string flag(string a,string b) return (a=="yes"||b=="yes")?"yes":"no";
      |                                ^~~~~~
a.cc:8:12: error: 'sum' was not declared in this scope
    8 |         if(sum==0) return "yes";
      |            ^~~
a.cc:9:12: error: 'n' was not declared in this scope
    9 |         if(n<0) return "no";
      |            ^
a.cc:10:27: error: 'n' was not declared in this scope
   10 |         return flag(slove(n-1,sum),slove(n-1,sum-A[n]));
      |                           ^
a.cc:10:31: error: 'sum' was not declared in this scope
   10 |         return flag(slove(n-1,sum),slove(n-1,sum-A[n]));
      |                               ^~~
a.cc:10:21: error: 'slove' was not declared in this scope
   10 |         return flag(slove(n-1,sum),slove(n-1,sum-A[n]));
      |                     ^~~~~
a.cc: In function 'int main()':
a.cc:22:30: error: 'slove' was not declared in this scope
   22 |                 cout << flag(slove(n-1,m),slove(n-1,m-A[n])) << endl;
      |                              ^~~~~
Language: C++

#include <iostream>
using namespace std;
int n,m,h;
bool solve(int n,int t){

	if(n==h) return true;
	if(n>h || t==m) return false;
	bool ret = solve(data[t]+n,t+1);
	if(!ret) ret = solve(n,t+1);
	return ret;
}
int data[21];
int main(){

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}

	cin>>m;
	for(int i=0;i<m;i++){
		
		cin>>h;
		cout<< (solve(0,0)? "yes" : "no")<<endl;

	}

		return 0;
}

Compiler output:
a.cc: In function 'bool solve(int, int)':
a.cc:8:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    8 |         bool ret = solve(data[t]+n,t+1);
      |                              ^
a.cc: In function 'int main()':
a.cc:17:22: error: reference to 'data' is ambiguous
   17 |                 cin>>data[i];
      |                      ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:12:5: note:                 'int data [21]'
   12 | int data[21];
      |     ^~~~
Language: Java


import java.util.*;

/**
 * B
 */
public class B {

    static final int INF = 500000;
    static int count = 0;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] S = new int[n];

        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }

        mergeSort(S, 0, n);

        System.out.print(S[0]);

        for (int i = 1; i < n; i++) {

            System.out.print(" " + S[i]);

            if (i == n - 1) {
                System.out.println();
                System.out.println(count);
            }
        }

        sc.close();

    }

    static void mergeSort(int[] A, int left, int right) {

        if (left+1 < right) {
            int mid = (left+right)/2;
            mergeSort(A, left, mid);
            mergeSort(A, mid, right);
            merge(A, left, mid, right);
        }

    }

    static void merge(int[] A, int left, int mid, int right) {

        int n1 = mid-left;
        int n2 = right-mid;
        int[] L = new int[n1+1];
        int[] R = new int[n2+1];

        for (int i=0; i<n1; i++) {
            L[i] = A[left+i];
        }

        for (int i=0; i<n2; i++) {
            R[i] = A[mid+i];
        }

        L[n1] = INF;
        R[n2] = INF;

        int i = 0;
        int j = 0;

        for (int k = left; k<right; k++) {

            count++;

            if (L[i] <= R[j]) {
                A[k] = L[i++];
            } else {
                A[k] = R[j++];
            }

        }
    }

}


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

import scala.Int;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            List<Integer> ns = Stream.of(sc.nextLine().split(" "))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());
            if (n != ns.size()) {
                return;
            }
            Integer cnt = 0;
            cnt = mergeSort(ns, 0, ns.size(), cnt);
            System.out.println(ns);
            System.out.println(cnt);
        } catch (NoSuchElementException | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static Integer mergeSort(
            List<Integer> ns,
            int left,
            int right,
            Integer cnt
    ) {
        if ((left + 1) < right) {
            int mid = (left + right) / 2;
            cnt = mergeSort(ns, left, mid, cnt);
            cnt = mergeSort(ns, mid, right, cnt);
            cnt = merge(ns, left, mid, right, cnt);
        }
        return cnt;
    }

    private static Integer merge(
            List<Integer> ns,
            int left,
            int mid,
            int right,
            Integer cnt
    ) {
        int n1 = mid - left;
        int n2 = right - mid;
        List<Integer> ll = new ArrayList<>();
        List<Integer> rl = new ArrayList<>();
        IntStream.rangeClosed(0, n1 - 1).forEach(i -> {
            ll.add(ns.get(left + i));
        });
        IntStream.rangeClosed(0, n2 - 1).forEach(i -> {
            rl.add(ns.get(mid + i));
        });
        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
            cnt++;
            if (i < ll.size() && (j >= rl.size() ||
                    ll.get(i) <= rl.get(j))) {
                ns.set(k, ll.get(i));
                i++;
            } else {
                ns.set(k, rl.get(j));
                j++;
            }
        }
        return cnt;
    }
}




Compiler output:
Main.java:1: error: package scala does not exist
import scala.Int;
            ^
1 error
Language: Java

class Main {
	static int count;
   public static void sort(int[] A,int left,int mid,int right){
	   int i,j,k;
	   int n1=mid-left;
	   int n2=right-mid;
	   int[] L=new int[n1+1];
	   int[] R=new int[n2+1];
	  
	   for(i=0;i<n1;i++){
	   L[i]=A[left+i];
	   }
	   for(i=0;i<n2;i++){
	   R[i]=A[mid+i];
	   }
	   L[n1]=Integer.MAX_VALUE;
	   R[n2]=Integer.MAX_VALUE;
	   i=0;
	   j=0;
	   
	   for(k=left;k<right;k++){
		   if(L[i]<=R[j]){
			   A[k]=L[i++];
		   }
		   else{
			   A[k]=R[j++];
		   }
		   count++;
	   }  
   }
   
   public static void margesort(int[] A,int left,int right){
	   if(left+1 < right){
		   int mid=(left+right)/2;
		   margesort(A,left,mid);
		   margesort(A,mid,right);
		   sort(A,left,mid,right);
	   }
   }
   
   public static void main(String[] args) throws IOException{
	   int[] A;
	   Scanner scan = new Scanner(System.in);
	   int a=scan.nextInt();
	   A=new int[a];
	   for(int i=0;i<a;i++){
		   A[i]=scan.nextInt();
	   }

	   margesort(A,0,a);
	   
	   for(int i=0;i<a;i++){
		   if(i<a-1) System.out.print(A[i]+" ");
		   else System.out.println(A[i]);
	   }
	   System.out.println(count);
   }   
}

Compiler output:
Main.java:41: error: cannot find symbol
   public static void main(String[] args) throws IOException{
                                                 ^
  symbol:   class IOException
  location: class Main
Main.java:43: error: cannot find symbol
	   Scanner scan = new Scanner(System.in);
	   ^
  symbol:   class Scanner
  location: class Main
Main.java:43: error: cannot find symbol
	   Scanner scan = new Scanner(System.in);
	                      ^
  symbol:   class Scanner
  location: class Main
3 errors
Language: Java

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
 
public class Main_merge_sort {

  static final int INF = 1000000001;
  static final int N = 500000;
  static int n, c;
  static int a[], L[], R[];

  public static void merge(int l, int m, int r) {
    int i, j, k;
    int nl = m - l;
    int nr = r - m;

    for (i=0; i<nl; i++) L[i] = a[l + i];
    for (i=0; i<nr; i++) R[i] = a[m + i];
    L[nl] = R[nr] = INF;

    i = j = 0;
    for (k=l; k<r; k++) {
      c++;
      if (L[i] <= R[j])
        a[k] = L[i++];
      else
        a[k] = R[j++];
    }
  }

  static void merge_sort(int l, int r) {
    if (l + 1 < r) {
      int m = (l+r)/2;
      merge_sort(l, m);
      merge_sort(m, r);
      merge(l, m, r);
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = Integer.parseInt(sc.next());
    a = new int[n];
    L = new int[n];
    R = new int[n];
    for (int i=0; i<n; i++)
      a[i] = Integer.parseInt(sc.next());

    merge_sort(0, n);
    for (int i=0; i<n; i++)
      System.out.print(String.valueOf(i) + ( (i==n-1) ? '\n' : ' ' ));
    System.out.println(c);
  }
}

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

import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static int[] buff;
static int ans=0;

static void __mergeSort(int[] a,int left,int right){
if(left<right){
int i;
int mid=(left+right)/2;
int p=0;
int j=0;
int k=0;
__mergeSort(a,left,mid);
__mergeSort(a,mid+1,right);
for(i=left;i<=mid;i++)
   buff[p++]=a[i];
while(i<=right&&j<p){
   a[k++]=(buff[j]<=a[i])?buff[j++]:a[i++];
   ans++;
}
while(j<p){
   a[k++]=buff[j++];
   ans++;
}
}

static void mergeSort(int[] a,int n){
buff=new int[n];
__mergeSort(a,0,n-1);
buff=null;
}

static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
mergeSort(a,n);
getValue(a);
out.println(ans);
}
}
}

Compiler output:
Main.java:31: error: illegal start of expression
static void mergeSort(int[] a,int n){
^
1 error
Language: Java

import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static int[] buff;
static int ans=0;

static void __mergeSort(int[] a,int left,int right){
if(left<right){
int i;
int mid=(left+right)/2;
int p=0;
int j=0;
int k=0;
__mergeSort(a,left,mid);
__mergeSort(a,mid+1,right);
for(i=left;i<=mid;i++)
   buff[p++]=a[i];
while(i<=right&&j<p){
   a[k++]=(buff[j]<=a[i])?buff[j++]:a[i++];
   ans++;
}
while(j<p){
   a[k++]=buff[j++];
   ans++;
}
}
}

static void mergeSort(int[] a,int n){
buff=new int[n];
__mergeSort(a,0,n-1);
buff=null;
}

static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
mergeSort(a,n);
getValue(a);
out.println(ans);
}
out.flush()
}
}

Compiler output:
Main.java:55: error: ';' expected
out.flush()
           ^
1 error
Language: Java

import java.io.*;
import java.util.StringTokenizer;
 
class Main{
 
static final PrintWriter out=new PrintWriter(System.out);
static int[] buff;
static int ans=0;
 
static void __mergeSort(int[] a,int left,int right){
if(left<right){
int i;
int mid=(left+right)/2;
int p=0;
int j=0;
int k=0;
__mergeSort(a,left,mid);
__mergeSort(a,mid+1,right);
for(i=left;i<=mid;i++)
   buff[p++]=a[i];
while(i<=right&&j<p){
   ans++;
   a[k++]=(buff[j]<=a[i])?buff[j++]:a[i++];
}
while(j<p){
   ans++;
   a[k++]=buff[j++];
}
}
 
static void mergeSort(int[] a,int n){
buff=new int[n];
__mergeSort(a,0,n-1);
buff=null;
}
 
static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
mergeSort(a,n);
getValue(a);
out.println(ans);
out.flush();
}
}
}

Compiler output:
Main.java:31: error: illegal start of expression
static void mergeSort(int[] a,int n){
^
1 error
Language: Java

import java.util.Scanner;


public class MergeSort {
	
	int n;
	int[] A;
	int cnt =0;
	
	public static void main(String[] args) {
		new MergeSort().solve();
		
	}
	
	public void solve(){
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		A = new int[n];
		
		for(int i=0;i<n;i++){
			A[i]= scanner.nextInt();
		}
		mergeSort(0, n);
		solvePrint();
	}
	
	public void merge(int left,int mid,int right){
		int n1 = mid -left;
		int n2 = right -mid;
		
		int[] L = new int[n1+1];
		int[] R = new int[n2+1];
		
		for(int i=0;i<n1;i++){
			L[i]=A[left +i];
		}
		for(int i=0;i<n2;i++){
			R[i]=A[mid+i];
		}
		L[n1]=Integer.MAX_VALUE;
		R[n2]=Integer.MAX_VALUE;
		int i=0,j=0;
		for(int k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i];
				i++;
			}
			else{
				A[k]=R[j];
				j++;
			}
			cnt++;
		}
	}
	
	public void mergeSort(int left,int right){
		if(left+1<right){
			int mid = (left+right)/2;
			mergeSort(left, mid);
			mergeSort(mid, right);
			merge(left,mid,right);
		}
	}
	
	public void solvePrint(){
		for(int i=0;i<A.length;i++){
			if(i>0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println("");
		System.out.println(cnt);
	}
}

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

import java.util.Scanner;


public class MergeSort {
	
	int n;
	int[] A;
	int[] L;
	int[] R;
	int cnt =0;
	
	
	public static void main(String[] args) {
		new MergeSort().solve();
		
	}
	
	public void solve(){
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		A = new int[n];
		L= new int[n/2+5];
		R= new int[n/2+5];
		
		for(int i=0;i<n;i++){
			A[i]= scanner.nextInt();
		}
		mergeSort(0, n);
		solvePrint();
	}
	
	public void merge(int left,int mid,int right){
		int n1 = mid -left;
		int n2 = right -mid;
		
		for(int i=0;i<n1;i++){
			L[i]=A[left +i];
		}
		for(int i=0;i<n2;i++){
			R[i]=A[mid+i];
		}
		L[n1]=Integer.MAX_VALUE;
		R[n2]=Integer.MAX_VALUE;
		int i=0,j=0;
		for(int k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i];
				i++;
			}
			else{
				A[k]=R[j];
				j++;
			}
			cnt++;
		}
	}
	
	public void mergeSort(int left,int right){
		if(left+1<right){
			int mid = (left+right)/2;
			mergeSort(left, mid);
			mergeSort(mid, right);
			merge(left,mid,right);
		}
	}
	
	public void solvePrint(){
		for(int i=0;i<A.length;i++){
			if(i>0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println("");
		System.out.println(cnt);
	}
}

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

Import java.util.Scanner;

class Main
{
    static int count = 0;
    static int INFTY = 990000;

    static void merge(int[]A,int left,int mid,int right)
    {
	int n1 = mid - left;
	int n2 = right - mid;
	int[]L = new int[500000];
	int[]R = new int[500000];

	int i;
	for( i = 0; i <= n1 - 1; i++) 
	    L[i] = A[left + i];

	for ( i = 0; i <= n2 - 1; i++)
	    R[i] = A[mid + i];

	L[n1] = INFTY;
	R[n2] = INFTY;
	
	i = 0;
	int j = 0;
	
	for(int k = left; k < right; k++)
	    if (L[i] <= R[j])
		{
		    A[k] = L[i];
		    i++;
		    
		}

	    else 
		{
		    A[k] = R[j];
		    j++;
		    
		}
	count += i + j;

    }
        
	
    static void mergeSort(int[]A,int left,int right)
    {
	int mid;

	if(left + 1 < right)
	    {
		mid = (left + right)/2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	    }
    }

    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int n = In.nextInt();
	int[]A = new int[n];

	for(int i = 0; i < n; i++)
	    A[i] = In.nextInt();

	mergeSort(A,0,n);

	for(int i = 0; i < n - 1; i++)
	    System.out.print(A[i] + " ");

	System.out.println(A[n - 1]);
	System.out.println(count);
    }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
Import java.util.Scanner;
^
1 error