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

#include <iostream>
using namespace std;

char ans[1024];
int number[4];

int usednum[4];
int num[4];
int ope[3];

int solve(int c, int o);
int check();
void makeEx();

int main() {
	int i, count = 0;

	while (1) {
		memset(usednum, 0, sizeof(usednum));
		for (i = 0; i < 4; i++) {
			cin >> number[i];
			if (number[i] == 0)
				count++;
		}
		if (count == 4)
			break;
		solve(0, 0);
		cout << ans << endl;
	}
	return 0;
}

int solve(int c, int o) {
	int i;

	if (c == 4 && o == 3) {
		if (check()) {
			return 1;
		}
	} else {
		if (c - o == 1) {
			for (i = 0; i < 3; i++) {
				ope[o] = i;
				if (solve(c, o + 1))
					return 1;
			}
		} else {
			for (i = 0; i < 4; i++) {
				if (!usednum[i]) {
					num[c] = number[i];
					usednum[i] = 1;
					if (solve(c + 1, o))
						return 1;
					usednum[i] = 0;
				}
			}
		}
	}
	return 0;
}

int check() {
	int ans, i;

	for (ans = num[0], i = 0; i < 3; i++) {
		switch (ope[i]) {
		case 0:
			ans += num[i+1];
			break;
		case 1:
			ans -= num[i+1];
			break;
		case 2:
			ans *= num[i+1];
			break;
		}
	}
	if (ans == 10) {
		makeEx();
		return 1;
	}
	return 0;
}

void makeEx() {

	int i = 0, j = 0, k = 0, kakko = -1;

	if ((ope[0] != 2 && (ope[1] == 2 || ope[2] == 2)) || (ope[0] == 2 && ope[1] != 2 && ope[2] == 2)) {
		ans[i++] = '(';
		if (ope[1] == 2)
			kakko = 6;
		else {
			kakko = 10;
		}
	}
	while (j != 4 || k != 3) {
		if (i == kakko) {
			ans[i++] = ')';
			continue;
		}
		if (((kakko != -1 && i >= 2) || (kakko == -1 && i >= 1)) && (j != 4 || k != 3))
			ans[i++] = ' ';
		if (j <= k) {
			ans[i++] = num[j++] + '0';
		} else {
			switch (ope[k++]) {
			case 0:
				ans[i] = '+';
				break;
			case 1:
				ans[i] = '-';
				break;
			case 2:
				ans[i] = '*';
				break;
			}
			i++;
		}
	}
	ans[i] = '\0';
	
}

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

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

char ans[1024];
int number[4];

int usednum[4];
int num[4];
int ope[3];

int solve(int c, int o);
int check();
void makeEx();

int main() {
	int i, count = 0;

	while (1) {
		memset(usednum, 0, sizeof(usednum));
		for (i = 0; i < 4; i++) {
			cin >> number[i];
			if (number[i] == 0)
				count++;
		}
		if (count == 4)
			break;
		if (solve(0, 0))
			cout << ans << endl;
		else
			cout << "0" << endl;
	}
	return 0;
}

int solve(int c, int o) {
	int i;

	if (c == 4 && o == 3) {
		if (check()) {
			return 1;
		}
	} else {
		if (c - o == 1) {
			for (i = 0; i < 3; i++) {
				ope[o] = i;
				if (solve(c, o + 1))
					return 1;
			}
		} else {
			for (i = 0; i < 4; i++) {
				if (!usednum[i]) {
					num[c] = number[i];
					usednum[i] = 1;
					if (solve(c + 1, o))
						return 1;
					usednum[i] = 0;
				}
			}
		}
	}
	return 0;
}

int check() {
	int ans, i;

	for (ans = num[0], i = 0; i < 3; i++) {
		switch (ope[i]) {
		case 0:
			ans += num[i+1];
			break;
		case 1:
			ans -= num[i+1];
			break;
		case 2:
			ans *= num[i+1];
			break;
		}
	}
	if (ans == 10) {
		makeEx();
		return 1;
	}
	return 0;
}

void makeEx() {

	int i = 0, j = 0, k = 0, kakko = -1;

	if ((ope[0] != 2 && (ope[1] == 2 || ope[2] == 2)) || (ope[0] == 2 && ope[1] != 2 && ope[2] == 2)) {
		ans[i++] = '(';
		if (ope[1] == 2)
			kakko = 6;
		else {
			kakko = 10;
		}
	}
	while (j != 4 || k != 3) {
		if (i == kakko) {
			ans[i++] = ')';
			continue;
		}
		if (((kakko != -1 && i >= 2) || (kakko == -1 && i >= 1)) && (j != 4 || k != 3))
			ans[i++] = ' ';
		if (j <= k) {
			ans[i++] = num[j++] + '0';
		} else {
			switch (ope[k++]) {
			case 0:
				ans[i] = '+';
				break;
			case 1:
				ans[i] = '-';
				break;
			case 2:
				ans[i] = '*';
				break;
			}
			i++;
		}
	}
	ans[i] = '\0';
	
}

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

#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
int d[4];
bool f=0;
const char *op="+-*";

int cal(int a,int o,int b){
    if(o==0) return a+b;
    if(o==1) return a-b;
    return a*b;
}

bool sol(int a,int b,int c) {
    f++;
    if (cal(cal(cal(d[0],a,d[1]),b,d[2]),c,d[3])==10) {
        printf("(((%d %c %d) %c %d) %c %d)\n",d[0],op[a],d[1],op[b],d[2],op[c],d[3]);
        return true;
    }
    if (cal(cal(d[0],a,d[1]),b, cal(d[2],c,d[3]))==10) {
        printf("((%d %c %d) %c (%d %c %d))\n",d[0],op[a],d[1],op[b],d[2],op[c],d[3]);
        reeturn true;
    }
    if (cal(cal(d[0],a, cal(d[1],b,d[2])),c,d[3])==10) {
        printf("((%d %c (%d %c %d)) %c %d)\n",d[0],op[a],d[1],op[b],d[2],op[c],d[3]);
        return true;
    }
    return f=0;
}

bool jg() {
    for (int i=0;i<3;++i) {
        for (int j=0;j<3;++j) {
            for (int k=0;k<3;++k) {
                if (sol(i,j,k)) return true;
            }
        }
    }
}


int main(){
    int mod=1000000007;
    for (;;) {
        scanf("%d %d %d %d",&d[0],&d[1],&d[2],&d[3]);
        if (d[0]==d[1] && d[1]==d[2] && d[2]==d[3] && d[0]==0) break;
        sort(d,d+4);
        do {
            if (jg()) break;
        } while (next_permutation(d,d+4));
        if (f==0) printf("0\n");
    }
    return 0;
}

Compiler output:
a.cc: In function 'bool sol(int, int, int)':
a.cc:27:5: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
   27 |     f++;
      |     ^
a.cc:34:9: error: 'reeturn' was not declared in this scope
   34 |         reeturn true;
      |         ^~~~~~~
a.cc: In function 'bool jg()':
a.cc:51:1: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      | ^
Language: C++

#include<stdio.h>
#include<ctype.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef vector<char>V;
int a[4];
string P(V&v,int&i)
{
	int f=isdigit(v[i]);
	string s;
	s+=v[i--];
	if(!f)
	{
		s+=" "+P(v,i)+')';
		s='('+P(v,i)+' '+s;
	}
	return s;
}
int F(V v,int i,int n)
{
	if(v.size()-7)
	{
		char*p,s[9]={},f=0;
		p=s;
		if(i<4)*s=a[i]+'0';
		if(n>1)strcat(s,"+-*");
		for(p=s;*p;++p)
		{
			V t(v);
			t.push_back(*p);
			if(isdigit(*p))f=F(t,i+1,n+1);
			else f=F(t,i,n-1);
			if(f)return 1;
		}
	}
	else
	{
		int x[4],c;
		for(n=i=0;i<7;++i)
		{
			if(isdigit(c=v[i]))x[n++]=v[i]-'0';
			else
			{
				int l=x[n-2],r=x[n-1],t;
				if(c=='+')t=l+r;
				if(c=='-')t=l-r;
				if(c=='*')t=l*r;
				x[n-2]=t;
				--n;
			}
		}
		if(*x==10)
		{
			puts(P(v,i=6).c_str());
			return 1;
		}
	}
	return 0;
}
int main()
{
	for(;;)
	{
		int i,f;
		for(f=i=0;i<4;++i)if(scanf("%d",a+i),!a[i])return 0;
		sort(a,a+4);
		do
		{
			f=F(V(),0,0);
			if(f)break;
		}while(next_permutation(a,a+4));
		if(!f)puts("0");
	}
}

Compiler output:
a.cc: In function 'int F(V, int, int)':
a.cc:28:24: error: 'strcat' was not declared in this scope
   28 |                 if(n>1)strcat(s,"+-*");
      |                        ^~~~~~
a.cc:6:1: note: 'strcat' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include<algorithm>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

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

char conv(int o)
{
	if(o==0) return '+';
	if(o==1) return '-';
	if(o==2) return '*';
}


int calc(int m,int n,int o)
{
	if(o==0) return m+n;
	if(o==1) return m-n;
	if(o==2) return m*n;
}


int main()
{
	int nums[4];
	while(cin>>nums[0]>>nums[1]>>nums[2]>>nums[3],nums[0])
	{
		bool flag=false;
		do {
			int o1=0,o2=0,o3=-1;
			for(int i = 0; i < 27; ++i)
			{
				o3++;
				if (o3==3)
				{
					o3=0;
					o2++;
					if (o2==3)
					{
						o1++;
						o2=0;
					}
				}
				
				if( calc(calc(nums[0],nums[1],o1),calc(nums[2],nums[3],o3),o2)==10 )
				{
					printf("(%d %c %d) %c (%d %c %d)\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]);
					flag=true; break;
				}
				if( calc(calc(calc(nums[0],nums[1],o1),nums[2],o2),nums[3],o3)==10 )
				{
					printf("((%d %c %d) %c %d) %c %d\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]);
					flag=true; break;
				}
				if( calc(nums[0],calc(calc(nums[1],nums[2],o2),nums[3],o3),o1)==10 )
				{
					printf("%d %c ((%d %c %d) %c %d)\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]);
					flag=true; break;
				}
				if( calc(calc(nums[0],calc(nums[1],nums[2],o2),o1),nums[3],o3)==10 )
				{
					printf("(%d %c (%d %c %d)) %c %d\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]);
					flag=true; break;
				}
				if( calc(nums[0],calc(nums[1],calc(nums[2],nums[3],o3),o2),o1)==10 )
				{
					printf("%d %c (%d %c (%d %c %d))\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]);
					flag=true; break;
				}
			}
			
		} while (!flag&&next_permutation(nums,nums+4));
		if(!flag) cout<<0<<endl;
	}
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:33: error: 'next_permutation' was not declared in this scope
   70 |                 } while (!flag&&next_permutation(nums,nums+4));
      |                                 ^~~~~~~~~~~~~~~~
a.cc: In function 'char conv(int)':
a.cc:10:1: warning: control reaches end of non-void function [-Wreturn-type]
   10 | }
      | ^
a.cc: In function 'int calc(int, int, int)':
a.cc:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^
Language: C++

main(a){for(;++a<2e5;)printf("(");for(;gets(&a);)puts(&a);}

Compiler output:
a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token
    1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a);)puts(&a);}
      |     ^
Language: C++

#include <stdio.h>
 
int main(){
    int a[4];
    for(int i = 0; i < 100000; ++i) putchar('(');
    while(1){
        for(int i = 0; i < 4; ++i){
            scanf_s("%d", &a[i]);
        }
        if(a[0] == 0){ break; }
         
        printf("%d+%d+%d+%d", a[0], a[1], a[2], a[3]);
        putchar('\n');
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
    8 |             scanf_s("%d", &a[i]);
      |             ^~~~~~~
      |             scanf
Language: C++

#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
#define REP(i,n) for (int i=0; i<n; i++)
#define I2S(i) to_string(i)

vvi permutations(vi x){
	vvi buf;
	int n=x.size(), i=0;
	sort(x.begin(),x.end());
	do{
		vi buf0(n);
		REP(i,n)
			buf0[i]=x[i];
		buf.push_back(buf0);
		buf0.clear();
	}while (next_permutation(x.begin(), x.end()));
	return buf;
}

vvi products(vi x, int n){
	int n2=x.size(), n3=(int)pow(n2,n);
	vvi buf(n3);
	REP(i,n3){
		vi buf0(n);
		int tmp = i;
		REP(i2,n){
			buf0[i2] = x[tmp%n2];
			tmp /= n2;
		}
		buf[i] = buf0;
	}
	return buf;
}

int op(int x, int y, int mode){
	switch (mode){
	case 0:
		return x+y;
	case 1:
		return x-y;
	case 2:
		return x*y;
	}
}

string check(vi x, int n){
	int x0=x[0], x1=x[1], x2=x[2], x3=x[3];
	string s0=I2S(x[0]), s1=I2S(x[1]), s2=I2S(x[2]), s3=I2S(x[3]);
	string ops="+-*", eq1, eq2;
	int n1 = ops.size();
	REP(i1, n1){
		int a1 = op(x0, x1, i1);
		eq1 = "("+s0+" "+ops[i1]+" "+s1+")";
		REP(i2, n1){
			int a2 = op(a1, x2, i2);
			eq2 = "("+eq1+" "+ops[i2]+" "+s2+")";
			REP(i3, n1)
				if (op(a2, x3, i3)==n) return "("+eq2+" "+ops[i3]+" "+s3+")";
			a2 = op(x2, x3, i2);
			eq2 = "("+s2+" "+ops[i2]+" "+s3+")";
			REP(i3,n1)
				if (op(a1, a2, i3)==n) return "("+eq1+" "+ops[i3]+" "+eq2+")";
		}
	}
	return "";
}

vi getx(){
	string line;
	getline(cin,line);
	istringstream is(line);
	vi x;
	int tmp;
	bool end = true;
	while(is>>tmp){
		if (tmp!=0) end = false;
		x.push_back(tmp);
	}
	if (end) x.clear();
	return x;
}

int f0041(){
	int n=10;
	while (true){
		vi x = getx();
		if (x.empty()) return 0;

		vvi xx = permutations(x);
		bool f = true;
		REP(i,(int)xx.size()){
			string s = check(xx[i],n);
			if (s != ""){
				cout<<s<<endl;
				f = false;
				break;
			}
		}
		if (f) cout<<"0"<<endl;
	}
}

int main(void){
	f0041();
}

Compiler output:
a.cc: In function 'vvi products(vi, int)':
a.cc:27:34: error: 'pow' was not declared in this scope
   27 |         int n2=x.size(), n3=(int)pow(n2,n);
      |                                  ^~~
a.cc: In function 'int op(int, int, int)':
a.cc:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
#define REP(i,n) for (int i=0; i<n; i++)
#define ALL(x) x.begin(), x.end()

string i2s(int n)
{
  stringstream ss;
  ss << n;
  return ss.str();
}

vvi permutations(vi x){
	vvi buf;
	int n=x.size(), i=0;
	sort(ALL(x));
	do{
		vi buf0(n);
		REP(i,n)
			buf0[i]=x[i];
		buf.push_back(buf0);
		buf0.clear();
	}while (next_permutation(ALL(x)));
	return buf;
}

vvi products(vi x, int n){
	int n2=x.size(), n3=(int)pow(n2,n);
	vvi buf(n3);
	REP(i,n3){
		vi buf0(n);
		int tmp = i;
		REP(i2,n){
			buf0[i2] = x[tmp%n2];
			tmp /= n2;
		}
		buf[i] = buf0;
	}
	return buf;
}

int op(int x, int y, int mode){
	switch (mode){
	case 0:
		return x+y;
	case 1:
		return x-y;
	case 2:
		return x*y;
	}
}

string check(vi x, int n){
	int x0=x[0], x1=x[1], x2=x[2], x3=x[3];
	string s0=i2s(x0), s1=i2s(x1), s2=i2s(x2), s3=i2s(x3);
	string ops="+-*", eq1, eq2;
	int n1 = ops.size();
	REP(i1, n1){
		int a1 = op(x0, x1, i1);
		eq1 = "("+s0+" "+ops[i1]+" "+s1+")";
		REP(i2, n1){
			int a2 = op(a1, x2, i2);
			eq2 = "("+eq1+" "+ops[i2]+" "+s2+")";
			REP(i3, n1)
				if (op(a2, x3, i3)==n) return "("+eq2+" "+ops[i3]+" "+s3+")";
			a2 = op(x2, x3, i2);
			eq2 = "("+s2+" "+ops[i2]+" "+s3+")";
			REP(i3,n1)
				if (op(a1, a2, i3)==n) return "("+eq1+" "+ops[i3]+" "+eq2+")";
		}
	}
	return "";
}

vi getx(){
	string line;
	getline(cin,line);
	istringstream is(line);
	vi x;
	int tmp;
	bool end = true;
	while(is>>tmp){
		if (tmp!=0) end = false;
		x.push_back(tmp);
	}
	if (end) x.clear();
	return x;
}

int f0041(){
	int n=10;
	while (true){
		vi x = getx();
		if (x.empty()) return 0;

		vvi xx = permutations(x);
		bool f = true;
		REP(i,(int)xx.size()){
			string s = check(xx[i],n);
			if (s != ""){
				cout<<s<<endl;
				f = false;
				break;
			}
		}
		if (f) cout<<"0"<<endl;
	}
}

int main(void){
	f0041();
}

Compiler output:
a.cc: In function 'vvi products(vi, int)':
a.cc:34:34: error: 'pow' was not declared in this scope
   34 |         int n2=x.size(), n3=(int)pow(n2,n);
      |                                  ^~~
a.cc: In function 'int op(int, int, int)':
a.cc:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
Language: Java

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

class Item {
	int cost,weight;

	Item(int c,int w) {
		this.cost = c;
		this.weight = w;
	}
}

class Main {
	private static final int NOT_ADD = -1;

	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
 
		try {
			long long count = 1;
			while (true) {
				int W = Integer.parseInt(br.readLine());
				if (W==0) break;

				int N = Integer.parseInt(br.readLine());
				Item item[] = new Item[N];
				for (int i=0;i<N;i++) {
					StringTokenizer st = new StringTokenizer(br.readLine(),",");
					int c = Integer.parseInt(st.nextToken());
					int w = Integer.parseInt(st.nextToken());
					item[i] = new Item(c,w);
				}
				int T[][] = new int[N][W+1];
				for (int i=0;i<N;i++) {
					for (int j=0;j<=W;j++) T[i][j] = NOT_ADD;
				}
				T[0][0] = 0;
				T[0][item[0].weight] = item[0].cost;
				for (int i=1;i<N;i++) {
					for (int k=0;k<=W;k++) T[i][k] = T[i-1][k];
					for (int k=item[i].weight;k<=W;k++) {
						if (T[i-1][k-item[i].weight]!=NOT_ADD&&T[i-1][k-item[i].weight]+item[i].cost>T[i][k]) {
							T[i][k] = T[i-1][k-item[i].weight]+item[i].cost;
						} else if (T[i-1][k-item[i].weight]==NOT_ADD) {
							T[i][k] = item[i].cost;
						}
					}
				}
				int MaxCost = T[N-1][0];
				int MaxWeight = 0;
				for (int i=0;i<=W;i++) {
					if (MaxCost<T[N-1][i]) {
						MaxCost = T[N-1][i];
						MaxWeight = i;
					}
				}
				System.out.println("Case "+count+":");
				System.out.println((long)MaxCost);
				System.out.println(MaxWeight);
				count++;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Compiler output:
Main.java:22: error: not a statement
			long long count = 1;
			^
Main.java:22: error: ';' expected
			long long count = 1;
			    ^
2 errors
Language: Java

import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int count=1;
while(!(line=br.readLine()).equals("0")){
int weight=0;
static int W=Integer.parseInt(line);
static int n=Integer.parseInt(br.readLine());
static int[] v=new int[n];
static int[] w=new int[n];
static int[][] dp=new int[n+1][W+1];
static boolean[] use=new boolean[n];
for(int i=0;i<n;i++){
String[] str=br.readLine().split(",");
v[i]=Integer.parseInt(str[0]);
w[i]=Integer.parseInt(str[1]);
}
System.out.println("Case "+count+":");
System.out.println(MaxValue(0,W));
for(int i=0;i<n;i++){
if(use[i]){
weight+=w[i];
}
System.out.println(weigght);
}
}
private static int MaxValue(int i,int j){
if(dp[i][j]!=0){
return dp[i][j];
}
else if(i==n){
return 0;
}
else if(j>w[i]){
use[i]=false;
return dp[i][j]=MaxValue(i+1,j);
}
else{
int p=MaxValue(i+1,j);
int q=MaxValue(i+1,j-w[i])+v[i];
int r=Math.max(MaxValue(i+1,j),MaxValue(i+1,j-w[i])+v[i]);
use[i]=(p==r)?false:true;
return dp[i][j]=r;
}
}
}

Compiler output:
Main.java:10: error: illegal start of expression
static int W=Integer.parseInt(line);
^
Main.java:16: error: illegal start of type
for(int i=0;i<n;i++){
^
Main.java:16: error: > or ',' expected
for(int i=0;i<n;i++){
               ^
Main.java:16: error: <identifier> expected
for(int i=0;i<n;i++){
                 ^
Main.java:21: error: <identifier> expected
System.out.println("Case "+count+":");
                  ^
Main.java:21: error: illegal start of type
System.out.println("Case "+count+":");
                   ^
Main.java:22: error: <identifier> expected
System.out.println(MaxValue(0,W));
                  ^
Main.java:22: error: <identifier> expected
System.out.println(MaxValue(0,W));
                           ^
Main.java:23: error: illegal start of type
for(int i=0;i<n;i++){
^
Main.java:23: error: > or ',' expected
for(int i=0;i<n;i++){
               ^
Main.java:23: error: <identifier> expected
for(int i=0;i<n;i++){
                 ^
Main.java:30: error: unnamed classes are a preview feature and are disabled by default.
private static int MaxValue(int i,int j){
               ^
  (use --enable-preview to enable unnamed classes)
Main.java:49: error: class, interface, enum, or record expected
}
^
13 errors
Language: Java

import java.io.*;
  
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int count=1;
while(!(line=br.readLine()).equals("0")){
int weight=0;
int W=Integer.parseInt(line);
int n=Integer.parseInt(br.readLine());
int[] v=new int[n];
int[] w=new int[n];
int[][] dp=new int[n+1][W+1];
boolean[] use=new boolean[n];
for(int i=0;i<n;i++){
String[] str=br.readLine().split(",");
v[i]=Integer.parseInt(str[0]);
w[i]=Integer.parseInt(str[1]);
}
System.out.println("Case "+count+":");
System.out.println(MaxValue(W,n,v,w,dp,use,0,W));
for(int i=0;i<n;i++){
if(use[i]){
weight+=w[i];
}
System.out.println(weight);
count++;
}
}
private static int MaxValue(int W,int n,int[] v,int[] w,int[][] dp,boolean[] use,int i,int j){
if(dp[i][j]!=0){
return dp[i][j];
}
else if(i==n){
return 0;
}
else if(j>w[i]){
use[i]=false;
return dp[i][j]=MaxValue(W,n,v,w,dp,use,i+1,j);
}
else{
int p=MaxValue(W,n,v,w,dp,use,i+1,j);
int q=MaxValue(W,n,v,w,dp,use,i+1,j-w[i])+v[i];
int r=Math.max(p,q);
use[i]=(p==r)?false:true;
return dp[i][j]=r;
}
}
}

Compiler output:
Main.java:31: error: illegal start of expression
private static int MaxValue(int W,int n,int[] v,int[] w,int[][] dp,boolean[] use,int i,int j){
^
1 error
Language: Java

import java.util.Scanner;

public class AOJ_0042 {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (int T = 1;; T++) {
			int W = sc.nextInt();
			if (W == 0) return;
			int N = sc.nextInt();
			int[] v = new int[N];
			int[] w = new int[N];
			for (int i = 0; i < N; i++) {
				String[] in = sc.next().split(",");
				v[i] = Integer.valueOf(in[0]);
				w[i] = Integer.valueOf(in[1]);
			}

			int maxCost = 0;
			int minWeight = Integer.MAX_VALUE / 2;
			int[][] dp = new int[2][W + 1];
			for (int i = 0; i < N; i++) {
				for (int j = 0; j <= W; j++) {
					if (j - w[i] >= 0) dp[(i + 1) & 1][j] = Math.max(dp[i & 1][j], dp[i & 1][j - w[i]] + v[i]);
					else dp[(i + 1) & 1][j] = dp[i & 1][j];

					if (dp[(i + 1) & 1][j] == maxCost && j < minWeight) {
						minWeight = j;
					} else if (dp[(i + 1) & 1][j] > maxCost) {
						maxCost = dp[(i + 1) & 1][j];
						minWeight = j;
					}
				}
			}
			System.out.println("Case " + T + ":");
			System.out.println(maxCost + "\n" + minWeight);
		}
	}

	public static void main(String[] args) {
		new AOJ_0042().run();
	}
}

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

public class Main {
	Scanner sc = new Scanner(System.in);

	class t implements Comparable<t> {
		int worth;
		int weight;

		t(String s) {
			Scanner sc = new Scanner(s.replace(',', ' '));
			worth = sc.nextInt();
			weight = sc.nextInt();
		}

		public int compareTo(t o) {
			return this.weight - o.weight;
		}
	}

	void run() {
		for (int casea = 1;; casea++) {
			int w = sc.nextInt();
			if (w == 0) {
				break;
			}
			w+=1;
			int n = sc.nextInt();
			t[] d = new t[n];
			for (int i = 0; i < n; i++) {
				d[i] = new t(sc.next());
			}
		//	Arrays.sort(d);
			int[] dp = new int[w];
			for (int i = 0; i < n; i++) {
				int[] dp2 = dp.clone();
				if (d[i].weight == 0) {
					for (int j = 0; j < w; j++) {
						dp[j] = dp2[j] + d[i].worth;
					}
					continue;
				}
				for (int j = 0; j + d[i].weight < w; j++) {
					dp[j + d[i].weight] = Math.max(dp2[j + d[i].weight], dp2[j]
							+ d[i].worth);
				}
			}
			int trig = 0;
			int max = 0;
			for (int i = 0; i < w; i++) {
				if (max < dp[i]) {
					max = dp[i];
					trig = i;
				} else if (max == dp[i]) {
					if (trig > i)
						trig = i;
				}
			}
			System.out.println("Case " + casea + ":");
			System.out.println(max);
			System.out.println(trig);
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Compiler output:
Main.java:2: error: cannot find symbol
	Scanner sc = new Scanner(System.in);
	^
  symbol:   class Scanner
  location: class Main
Main.java:2: error: cannot find symbol
	Scanner sc = new Scanner(System.in);
	                 ^
  symbol:   class Scanner
  location: class Main
Main.java:9: error: cannot find symbol
			Scanner sc = new Scanner(s.replace(',', ' '));
			^
  symbol:   class Scanner
  location: class Main.t
Main.java:9: error: cannot find symbol
			Scanner sc = new Scanner(s.replace(',', ' '));
			                 ^
  symbol:   class Scanner
  location: class Main.t
4 errors
Language: Java

import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main2 {

	static int W,N;
	static int[][] dp;
	static int[][] a;
	static int max,minw;
	static Stack<Integer>stack;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int T=0;
		for(;;){
			T++;
			W=cin.nextInt();
			if(W==0)break;
			
			max=-(1<<30);
			minw=1<<30;
			
			stack=new Stack<Integer>();
			N=cin.nextInt();
			dp=new int[N+1][W+1];
			a=new int[N][2];
			for(int i=0;i<N;i++){
				Arrays.fill(dp[i], 1<<30);
				String[] s=cin.next().split(",");
				a[i][0]=Integer.parseInt(s[0]);
				a[i][1]=Integer.parseInt(s[1]);
			}
			
			dp(0,W);
			System.out.println("Case "+T+":");
			System.out.println(max+"\n"+(minw-1));
		}
	}
	static int dp(int t,int w){
		int re=0;
		if(t==N){
			return 0;
		}
		if(dp[t][w]!=1<<30)return dp[t][w];
		if(w-a[t][1]<0){
			re=dp(t+1,w);
		}
		else{
			re=Math.max(dp(t+1,w), dp(t+1,w-a[t][1])+a[t][0]);
			if(re>max){
				max=re;
				minw=w;
			}
			else if(re==max){
				minw=Math.min(minw, w);
			}
				
		}
		return dp[t][w]=re;
	}
}

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

import java.util.*;

public class AOJ_0042{

    void run(){
        Scanner sc = new Scanner(System.in);
        int case_cnt = 1;
        while(true){
            int W = sc.nextInt();
            if(W == 0){
                break;
            }
            int N = sc.nextInt();
            int[] value = new int[N];
            int[] weight = new int[N];
            for(int i = 0; i < N; i++){
                String[] s = sc.next().split(",");
                value[i] = Integer.parseInt(s[0]);
                weight[i] = Integer.parseInt(s[1]);
            }
            int[] dp = new int[W+1];
            for(int i = 0; i < N; i++){
                for(int w = W; w >= 0 ; w--){
                    if( w + weight[i] <= W){
                        dp[w + weight[i]] = Math.max(dp[w + weight[i]], dp[w] + value[i]);
                    }
                }
            }
            int max = 0;
            for(int w: dp){
                max = Math.max(max,w);
            }
            int index = 0;
            for(int i = 0; i <= W; i++){
                if(dp[i] == max){
                    index = i;
                    break;
                }
            }
            System.out.println("Case " + case_cnt + ":");
            System.out.println(max);
            System.out.println(index);
            case_cnt++;
        }
        
    }

    public static void main(String[] args){
        new AOJ_0042().run();
    }
}

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

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

int main(void)
{
  int count = 0;
  int W;
  int N;
  while(scanf("%d",&W)){
    if(W==0) break;
    count++;
    scanf("%d",&N);
    char c;
    int va;//お宝の価値
    int wi;//お宝の重さ
    int li[W+1];//袋の限界
    int i,j;
    for(i=0;i<=W;i++)
      li[i]=0;//お宝が入っていない
    
    for(i=0;i<N;i++){
      scanf("%d%c%d",&va,&c,&wi);
      for(j=W;j>=0;j--){
	if(li[j]!=0 && wi+j<=W){
	  if(li[j]+va > li[wi+j])
	    li[wi+j]=li[j]+va;
	}
	if(j==0 && wi <= W){
	  if(va > li[wi])
	    li[wi]=va;
	}
      }
    }
    int ansva=0;
    int answi=0;
    for(i=0;i<=W;i++){
      if(li[i]>ansva){
	ansva = li[i];
	answi = i;
      }
    }
    printf("Case %d:\n",count);
    printf("%d\n%d\n",ansva,answi);
  }

Compiler output:
main.c: In function 'main':
main.c:44:3: error: expected declaration or statement at end of input
   44 |   }
      |   ^
Language: C

#include<stdio.h>
int w, n, value[1000], weight[1000];

int search(int i, int w, int value_s) {
	if (i == n) {  
		return value_s;
	}
	else if (w < weight[i]) {
		return search(i + 1, w, value_s);
	}
	else {
		int result1 = search(i + 1, w, value_s);
		int result2 = search(i + 1, w - weight[i], value_s + value[i]);
		return max(result1, result2);
	}
}
int main(void) {
	int i,j=0;
	int value_s;

	while (1) {
		scanf("%d", &w);
		if (w == 0)break;
		scanf("%d", &n);
		j++;
		for (i = 0; i < n; i++)
			scanf("%d,%d", &value[i], &weight[i]);

		value_s = search(0, w,0);
		printf("Case %d:\n",j);
		printf("%d\n", value_s);
	}
	return 0;
}

Compiler output:
main.c: In function 'search':
main.c:14:24: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   14 |                 return max(result1, result2);
      |                        ^~~
Language: C

#include<stdio.h>
#define max(a,b)(((a)>(b))>(a):(b))
int w, n, value[1001], weight[1001];
int weight_s,dp[1001][1001];

void search() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= w; j++) {
			if (j < weight[i]) {
				dp[i + 1][j] = dp[i][j];
			}else{
				dp[i + 1][j] = max(dp[i][j],dp[i][j-weight[i]]+value[i]);
			}
		}
	}
	for (int j = 0; j <= w; j++) {
		if (dp[n][j] == dp[n][w]) {
			weight_s = j;
			break;
		}
	}
}
int main(void) {
	int i,j,k=0;

	while (1) {
		scanf("%d", &w);
		if (w == 0)break;
		scanf("%d", &n);
		k++;
		for (i = 0; i < 1001; i++) {
			for (j = 0; j < 1001; j++) {
				dp[i][j] = 0;
 			}
		}
		for (i = 0; i < n; i++)
			scanf("%d,%d", &value[i], &weight[i]);

		search();
		printf("Case %d:\n",k);
		printf("%d\n", dp[n][w]);
		printf("%d\n",weight_s);
	}
	return 0;
}

Compiler output:
main.c: In function 'search':
main.c:2:31: error: expected ')' before ':' token
    2 | #define max(a,b)(((a)>(b))>(a):(b))
      |                 ~             ^
main.c:12:48: note: in expansion of macro 'max'
   12 |                                 dp[i + 1][j] = max(dp[i][j],dp[i][j-weight[i]]+value[i]);
      |                                                ^~~
Language: C

const int MAX_N = 1000; // n????????§???
const int MAX_W = 5000; // W????????§???

// ??\???
int n, W;
int w[MAX_N], v[MAX_N];

// DP????????????
// dp[i][j]???i????????\?????????????????????????????????j??\?????????????????????????????¨??????????????????????????§????????¨??????
int dp[MAX_N + 1][MAX_W + 1];

void solve_dp2() {
  for (int j = 0; j <= W; j++) {
    dp[n][j] = 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i])
        dp[i][j] = dp[i + 1][j];
      else
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
    }
  }
  cout << dp[0][W] << endl;
}

Compiler output:
main.c:6:5: error: variably modified 'w' at file scope
    6 | int w[MAX_N], v[MAX_N];
      |     ^
main.c:6:15: error: variably modified 'v' at file scope
    6 | int w[MAX_N], v[MAX_N];
      |               ^
main.c:10:5: error: variably modified 'dp' at file scope
   10 | int dp[MAX_N + 1][MAX_W + 1];
      |     ^~
main.c:10:5: error: variably modified 'dp' at file scope
main.c: In function 'solve_dp2':
main.c:21:20: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   21 |         dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      |                    ^~~
main.c:24:3: error: 'cout' undeclared (first use in this function)
   24 |   cout << dp[0][W] << endl;
      |   ^~~~
main.c:24:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:24:23: error: 'endl' undeclared (first use in this function)
   24 |   cout << dp[0][W] << endl;
      |                       ^~~~
Language: C

t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--){
			for(j=0;j<=W;j++){
				t[c-1][j]=(j<a)?t[c][j]:(t[c][j]>t[c][j-a]+b)?t[c][j]:(t[c][j-a]+b);
			}
		}
		for(j=0;t[0][j]==t[0][W];j++)
	}
}

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | t[9999][9999],j;main(p,W,a,b,c){
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:1:15: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | t[9999][9999],j;main(p,W,a,b,c){
      |               ^
main.c:1:17: error: return type defaults to 'int' [-Wimplicit-int]
    1 | t[9999][9999],j;main(p,W,a,b,c){
      |                 ^~~~
main.c: In function 'main':
main.c:1:17: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:2:6: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | t[9999][9999],j;main(p,W,a,b,c){
main.c:2:6: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:2:6: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:2:23: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |                       ^~~~~~
main.c:2:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:2:23: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:2:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:9:9: error: expected expression before '}' token
    9 |         }
      |         ^
Language: C

t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--){
			for(j=0;j<=W;j++){
				t[c-1][j]=(j<a)?t[c][j]:(t[c][j]>t[c][j-a]+b)?t[c][j]:(t[c][j-a]+b);
			}
		}
		for(j=0;t[0][j]==t[0][W];j++)
	}
return 0;
}

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | t[9999][9999],j;main(p,W,a,b,c){
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:1:15: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | t[9999][9999],j;main(p,W,a,b,c){
      |               ^
main.c:1:17: error: return type defaults to 'int' [-Wimplicit-int]
    1 | t[9999][9999],j;main(p,W,a,b,c){
      |                 ^~~~
main.c: In function 'main':
main.c:1:17: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:2:6: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | t[9999][9999],j;main(p,W,a,b,c){
main.c:2:6: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:2:6: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:2:23: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |                       ^~~~~~
main.c:2:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:2:23: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:2:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:9:9: error: expected expression before '}' token
    9 |         }
      |         ^
Language: C

table[9999][9999],j;
main(p,W,a,b,c){
	for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--){
			for(j=0;j<=W;j++){
				table[c-1][j]=(j<a)?table[c][j]:(table[c][j]>table[c][j-a]+b)?table[c][j]:(table[c][j-a]+b);
			}
		}
		for(j=0;table[0][j]==table[0][W];j++)
	}
}                

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | table[9999][9999],j;
      | ^~~~~
main.c:1:1: error: type defaults to 'int' in declaration of 'table' [-Wimplicit-int]
main.c:1:19: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | table[9999][9999],j;
      |                   ^
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | main(p,W,a,b,c){
      | ^~~~
main.c: In function 'main':
main.c:2:1: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:3:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |              ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | table[9999][9999],j;
main.c:3:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |              ^~~~~
main.c:3:14: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:3:31: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |                               ^~~~~~
main.c:3:31: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:31: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:3:31: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:10:9: error: expected expression before '}' token
   10 |         }
      |         ^
Language: C

table[9999][9999],j;
main(p,W,a,b,c){
	for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--){
			for(j=0;j<=W;j++){
				table[c-1][j]=(j<a)?table[c][j]:(table[c][j]>table[c][j-a]+b)?table[c][j]:(table[c][j-a]+b);
			}
		}
		for(j=0;table[0][j]==table[0][W];j++)
	}
return 0;
}                

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | table[9999][9999],j;
      | ^~~~~
main.c:1:1: error: type defaults to 'int' in declaration of 'table' [-Wimplicit-int]
main.c:1:19: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | table[9999][9999],j;
      |                   ^
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | main(p,W,a,b,c){
      | ^~~~
main.c: In function 'main':
main.c:2:1: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:3:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |              ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | table[9999][9999],j;
main.c:3:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |              ^~~~~
main.c:3:14: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:3:31: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |                               ^~~~~~
main.c:3:31: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:31: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:3:31: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:10:9: error: expected expression before '}' token
   10 |         }
      |         ^
Language: C

table[9999][9999],j;
main(p,W,a,b,c){
	for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--){
			for(j=0;j<=W;j++){
				table[c-1][j]=(j<a)?table[c][j]:(table[c][j]>table[c][j-a]+b)?table[c][j]:(table[c][j-a]+b);
			}
		}
		for(j=0;table[0][j]!=table[0][W];j++)
	}
return 0;
}                

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | table[9999][9999],j;
      | ^~~~~
main.c:1:1: error: type defaults to 'int' in declaration of 'table' [-Wimplicit-int]
main.c:1:19: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | table[9999][9999],j;
      |                   ^
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | main(p,W,a,b,c){
      | ^~~~
main.c: In function 'main':
main.c:2:1: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:3:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |              ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | table[9999][9999],j;
main.c:3:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |              ^~~~~
main.c:3:14: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:3:31: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    3 |         for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){
      |                               ^~~~~~
main.c:3:31: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:31: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:3:31: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:10:9: error: expected expression before '}' token
   10 |         }
      |         ^
Language: C

t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]fmax(t[c][j],(t[c][j-a]+b));
		for(j=0;t[0][j]==t[0][W];j++);
	}
} 

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | t[9999][9999],j;main(p,W,a,b,c){
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:1:15: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | t[9999][9999],j;main(p,W,a,b,c){
      |               ^
main.c:1:17: error: return type defaults to 'int' [-Wimplicit-int]
    1 | t[9999][9999],j;main(p,W,a,b,c){
      |                 ^~~~
main.c: In function 'main':
main.c:1:17: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:2:6: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | t[9999][9999],j;main(p,W,a,b,c){
main.c:2:6: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:2:6: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:2:23: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    2 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |                       ^~~~~~
main.c:2:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:2:23: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:2:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:102: error: expected ':' before 'fmax'
    3 |                 for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]fmax(t[c][j],(t[c][j-a]+b));
      |                                                                                                      ^~~~
      |                                                                                                      :
Language: C


t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);j=c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]fmax(t[c][j],(t[c][j-a]+b));
		for(;t[0][++j]!=t[0][W];);
	}
} 

Compiler output:
main.c:2:1: warning: data definition has no type or storage class
    2 | t[9999][9999],j;main(p,W,a,b,c){
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:2:15: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    2 | t[9999][9999],j;main(p,W,a,b,c){
      |               ^
main.c:2:17: error: return type defaults to 'int' [-Wimplicit-int]
    2 | t[9999][9999],j;main(p,W,a,b,c){
      |                 ^~~~
main.c: In function 'main':
main.c:2:17: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:2:17: error: type of 'W' defaults to 'int' [-Wimplicit-int]
main.c:2:17: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:2:17: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:2:17: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:3:6: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | 
main.c:3:6: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |      ^~~~~
main.c:3:6: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:3:23: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    3 | for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
      |                       ^~~~~~
main.c:3:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:23: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:3:23: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:4:104: error: expected ':' before 'fmax'
    4 |                 for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);j=c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]fmax(t[c][j],(t[c][j-a]+b));
      |                                                                                                        ^~~~
      |                                                                                                        :