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

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define const INF 10000000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, w, wtmp;
    cin >> n >> w;

    vector<ll> st[4];
    rep(i, n){
        ll weight, value;
        cin >> weight >> value;
        if(i == 0){
            wtmp = weight;
        }
        st[w - wtmp].push_back(value);
    }
    for(i, 4) {
        sort(all(st[i]));
        st[i].push_back(0);
        reverse(all(st[i]));
        rep(j, 1, st[i].size()){
            st[i][j] += st[i][j - 1];
        }
    }

    ll ans = 0;
    rep(i, st[0].size()){
        rep(j, st[1].size()){
            rep(k, st[2].size()){
                rep(l, st[3].size()){
                    ll fact = wtmp * i + (wtmp + 1) * j + (wtmp + 2) * k + (wtmp + 3) * l;
                    if(fact <= w) {
                        ans = max(ans, st[0][i] + st[1][j] + st[2][k] + st[3][l]);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'i' was not declared in this scope
   48 |     for(i, 4) {
      |         ^
a.cc:26:23: error: expected primary-expression before 'for'
   26 | #define repi(i, a, b) for(ll i = int(a); i < int(b); i++)
      |                       ^~~
a.cc:25:20: note: in expansion of macro 'repi'
   25 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:24:43: note: in expansion of macro '_rep'
   24 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:27:18: note: in expansion of macro '_overload3'
   27 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:58:5: note: in expansion of macro 'rep'
   58 |     rep(i, st[0].size()){
      |     ^~~
a.cc:57:16: error: expected ')' before 'for'
   57 |     ll ans = 0;
      |                ^
      |                )
a.cc:48:8: note: to match this '('
   48 |     for(i, 4) {
      |        ^
a.cc:71:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define sp cout<<"---------------------------------------------------"<<endl
int dp[110][110][310],w[110],v[110];
int main(){
      int n,m,i,j,k;
      cin>>n>>m;
      for(i=1;i<=n;i++)
        scanf("%d%d",&w[i],&v[i]);
      for(i=1;i<=n;i++)
        for(j=1;j<=i;j++)
          for(k=0;k<=3*i;k++){
          	dp[i][j][k]=mak(dp[i][j][k],dp[i-1][j][k]);
            if(k>=w[i]-w[1])
			  dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k-(w[i]-w[1])]+v[i]);
		  }
	  int ans=0;
	  for(i=1;i<=n;i++)
	    for(j=0;j<=i*3;j++)
	      if(i*w[1]+j<=m)
	        ans=max(ans,dp[n][i][j]);
	  cout<<ans<<endl;
	  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:29: error: 'mak' was not declared in this scope
   26 |                 dp[i][j][k]=mak(dp[i][j][k],dp[i-1][j][k]);
      |                             ^~~
Language: C++

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

int dp(int, int);
int n, w;
int* ws2;
int* vs2;
int* d;
int** vis;
int main() {
  cin >> n >> w;
  ws2 = new int[n];
  vs2 = new int[n];
  d = new int[w+1];
  for (int i = 0; i < n; i++) {
    cin >> ws2[i] >> vs2[i];
  }
  for (int i = 0; i < w+1; i++) {
    d[i] = -1;
  }
  vis = new int*[w];
  for (int i = 0; i < w; i++) {
    vis[i] = new int[n];
    for (int j = 0; j < n; j++) {
      vis[i][j] = 0;
    }
  }
  
  int ans = dp(n, w);
  cout << ans << endl;

}

int dp(int layer, int curw) {
  int& ans = d[curw];
  if (ans >= 0) { return ans; }
  if (layer < 0) { return 0;}
  ans = 0;
  for (int i = 0; i < n; i++) {
    if (curw - ws2[i] >= 0) {
      if (vis[curw - ws2[i]][i] == 0) {
      vis[curw-ws[i]][i]] = 1;
      ans = max(dp(layer-1, curw), dp(layer-1, curw - ws2[i]) + vs2[i]);
    }
  }
  return ans;
}
  


Compiler output:
a.cc: In function 'int dp(int, int)':
a.cc:43:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   43 |       vis[curw-ws[i]][i]] = 1;
      |                  ^
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:35:29: note: to match this '{'
   35 | int dp(int layer, int curw) {
      |                             ^
a.cc:48:2: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      |  ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;
 
int n,W,v[101],w[101],dp[101][100000001];
 
int solve(int i,int sum){
    if(sum<0)return 0;
    if(i==n)return 0;
    if(dp[i][W-sum]!=0)return dp[i][W-sum];
    else{
        dp[i][W-sum]=solve(i+1,sum);
        if(sum-w[i]>=0){
            dp[i][W-sum]=max(solve(i+1,sum),solve(i+1,sum-w[i])+v[i]);
        }
        return dp[i][W-sum];
    }
}
 
int main(void){
    cin>>n>>W;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<solve(0,W)<<endl;
    return 0;
}

Compiler output:
a.cc:9:1: error: extended character   is not valid in an identifier
    9 |  
      | ^
a.cc:11:1: error: extended character   is not valid in an identifier
   11 |  
      | ^
a.cc:24:1: error: extended character   is not valid in an identifier
   24 |  
      | ^
a.cc:9:1: error: '\U000000a0' does not name a type
    9 |  
      | ^
a.cc:11:1: error: '\U000000a0' does not name a type
   11 |  
      | ^
a.cc:24:1: error: '\U000000a0' does not name a type
   24 |  
      | ^
Language: C++

#include <iostream>

 

using namespace std;

 

// A utility function that returns maximum of two integers

int max(int a, int b)

{

    return (a > b) ? a : b;

}

 

// Returns the maximum value that can be put in a knapsack of capacity W

int knapSack(int W, int wt[], int val[], int n)

{

    int i, w;

    int K[n + 1][W + 1];

 

    // Build table K[][] in bottom up manner

    for (i = 0; i <= n; i++)

    {

        for (w = 0; w <= W; w++)

        {


Compiler output:
a.cc: In function 'int knapSack(int, int*, int*, int)':
a.cc:41:10: error: expected '}' at end of input
   41 |         {
      |         ~^
a.cc:41:10: error: expected '}' at end of input
a.cc:37:5: note: to match this '{'
   37 |     {
      |     ^
a.cc:41:10: error: expected '}' at end of input
   41 |         {
      |          ^
a.cc:25:1: note: to match this '{'
   25 | {
      | ^
a.cc:41:10: warning: no return statement in function returning non-void [-Wreturn-type]
   41 |         {
      |          ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	ll out=0;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	ll t=in[0].first;
	rep(i,n)in[i].first-=t;
	rep(i,n+1){
		ll w=m-i*t;
		if(w<0)continue;
		vvi dp(i+1,vi(500));
		rep(j,n)for(int k=i-1;k>=0;k--)rep(l,500)if(l+in[j].first<500)
			dp[k+1][l+in[j].first]=max(dp[k+1][l+in[j].first],dp[k][l]+in[j].second);
		ll ma=0;
//		rep(j,w+1)cout<<" "<<dp[j];cout<<endl;
		rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]);
		out=max(out,ma);
	}
	cout<<out<<endl;
}







Compiler output:
a.cc:70:1: error: unterminated argument list invoking macro "rep"
   70 | 
      | ^
a.cc: In function 'int main()':
a.cc:61:17: error: 'rep' was not declared in this scope
   61 |                 rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]);
      |                 ^~~
a.cc:61:20: error: expected '}' at end of input
   61 |                 rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]);
      |                    ^
a.cc:53:19: note: to match this '{'
   53 |         rep(i,n+1){
      |                   ^
a.cc:61:20: error: expected '}' at end of input
   61 |                 rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]);
      |                    ^
a.cc:45:11: note: to match this '{'
   45 | int main(){
      |           ^
Language: C++


1.#include<iostream>
2.#include<algorithm>
3.#include<vector>
4.using LL = long long;
5.LL N,w;
6.LL W, V;
7.LL size[4],ww[4];
8.LL ans;
9.std::vector<LL> dp[4];
10.void value(LL x, LL y, LL z, LL q) {
11.	LL sum = 0;
12.	for (LL aa = 0; aa < x; aa++) {
13.		sum += dp[0][aa];
14.	}
15.	for (LL aa = 0; aa < y; aa++) {
16.		sum += dp[1][aa];
17.	}
18.	for (LL aa = 0; aa < z; aa++) {
19.		sum += dp[2][aa];
20.	}
21.	for (LL aa = 0; aa < q; aa++) {
22.		sum += dp[3][aa];
23.	}
24.	ans = std::max(ans, sum);
25.	sum = 0;
26.}
27.void solve() {
28.	for (LL i = 0; i <= size[0]; i++) {
29.		for (LL j = 0; j <= size[1]; j++) {
30.			for (LL k = 0; k <= size[2]; k++) {
31.				for (LL l = 0; l <= size[3]; l++) {
32.					ww[0] = i*w;
33.					ww[1] = j*(w + 1);
34.					ww[2] = k*(w + 2);
35.					ww[3] = l*(w + 3);
36.					if ((ww[0] + ww[1] + ww[2] + ww[3]) <= W) {
37.						value(i, j, k, l);
38.					}
39.				}
40.			}
41.		}
42.	}
43.}
44.int main() {
45.	std::cin >> N >> W;
46.	std::cin >> w>> V;
47.	dp[0].push_back(V);
48.	for (LL i = 1; i < N; i++) {
49.		LL tmp,Q;
50.		std::cin >> tmp >> Q;
51.		dp[tmp-w].push_back(Q);
52.	}
53.	for (LL i = 0;  i < 4; i++) {
54.		std::sort(dp[i].begin(), dp[i].end());
55.		size[i] = dp[i].size();
56.	}
57.	solve();
58.	std::cout << ans;
59.	return 0;
60.}



Compiler output:
a.cc:2:3: error: stray '#' in program
    2 | 1.#include<iostream>
      |   ^
a.cc:3:3: error: stray '#' in program
    3 | 2.#include<algorithm>
      |   ^
a.cc:4:3: error: stray '#' in program
    4 | 3.#include<vector>
      |   ^
a.cc:2:1: error: expected unqualified-id before numeric constant
    2 | 1.#include<iostream>
      | ^~
a.cc:6:1: error: expected unqualified-id before numeric constant
    6 | 5.LL N,w;
      | ^~~~
a.cc:7:1: error: expected unqualified-id before numeric constant
    7 | 6.LL W, V;
      | ^~~~
a.cc:8:1: error: expected unqualified-id before numeric constant
    8 | 7.LL size[4],ww[4];
      | ^~~~
a.cc:9:1: error: expected unqualified-id before numeric constant
    9 | 8.LL ans;
      | ^~~~
a.cc:10:1: error: expected unqualified-id before numeric constant
   10 | 9.std::vector<LL> dp[4];
      | ^~~~~
a.cc:11:1: error: expected unqualified-id before numeric constant
   11 | 10.void value(LL x, LL y, LL z, LL q) {
      | ^~~~~~~
a.cc:28:1: error: expected unqualified-id before numeric constant
   28 | 27.void solve() {
      | ^~~~~~~
a.cc:45:1: error: expected unqualified-id before numeric constant
   45 | 44.int main() {
      | ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using LL = long long;
LL N,w;
LL W, V;
LL size[4];
LL ans;
std::vector<LL> dp1,dp2,dp3,dp4;
void value(LL x, LL y, LL z, LL q) {
	LL sum = 0;
	for (LL aa = 0; aa < x; aa++) {
		sum += dp1[aa];
	}
	for (LL aa = 0; aa < y; aa++) {
		sum += dp2[aa];
	}
	for (LL aa = 0; aa < z; aa++) {
		sum += dp3[aa];
	}
	for (LL aa = 0; aa < q; aa++) {
		sum += dp4[aa];
	}
	ans = std::max(ans, sum);
}
void solve() {
	for (LL i = 0; i <= dp1.size; i++) {
		for (LL j = 0; j <= dp2.size(); j++) {
			for (LL k = 0;k <= dp3.size(); k++) {
				for (LL l = 0; l <= dp4.size(); l++) {
					LL ww=0;
					ww += i*w;
					ww += j*(w + 1);
					ww += k*(w + 2);
					ww += l*(w + 3);
					if (ww <= W) {
						value(i, j, k, l);
					}
				}
			}
		}
	}
}
int main() {
	std::cin >> N >> W;
	std::cin >> w>> V;
	dp1.push_back(V);
	for (LL i = 1; i < N; i++) {
		LL tmp,Q;
		std::cin >> tmp >> Q;
		if (tmp - w == 0) dp1.push_back(Q);
		if (tmp - w == 1) dp2.push_back(Q);
		if (tmp - w == 2) dp3.push_back(Q);
		if (tmp - w == 3) dp4.push_back(Q);

	}
	std::sort(dp1.begin(), dp1.end());
	std::sort(dp2.begin(), dp2.end());
	std::sort(dp3.begin(), dp3.end());
	std::sort(dp4.begin(), dp4.end());
	solve();
	std::cout << ans << std::endl;
	return 0;
}
 

Compiler output:
a.cc: In function 'void solve()':
a.cc:27:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   27 |         for (LL i = 0; i <= dp1.size; i++) {
      |                             ~~~~^~~~
      |                                     ()
Language: C

#include<cstdio>
#include<deque>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int SIZEN=1010,inf =0x7fffffff/2;
int N,W;
int w[SIZEN],v[SIZEN];
int pos[4][SIZEN]={0},he[4][SIZEN];
int cnt[4];
int a[4][SIZEN];
bool cmp(int a,int b)
{
	return a>b;
}
void work()
{
	int lim[4];
	for(int i=0;i<4;i++)
	{
		lim[i]=min(cnt[i],W/(w[1]+i));
		for(int j=1;j<=lim[i];j++) pos[i][j]=pos[i][j-1]+a[i][j];
	}
	int ans=0;
	for(int i=0;i<=lim[0];i++)
	{
		for(int j=0;j<=lim[1];j++)
		{
			if(w[1]*i+(w[1]+1)*j>W) break;
			for(int k=0;k<=lim[2];k++)
			{
				if(w[1]*i+(w[1]+1)*j+(w[1]+2)*k>W) break;
				for(int p=0;p<=lim[3];p++)
				{
					if(w[1]*i+(w[1]+1)*j+(w[1]+2)*k+(w[1]+3)*p>W) break;
					ans=max(ans,pos[0][i]+pos[1][j]+pos[2][k]+pos[3][p]);
				}
			}
		}
	}
	cout<<ans<<endl;
}
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	scanf("%d%d",&N,&W);
	for(int i=1;i<=N;i++)
	{
	scanf("%d%d",&w[i],&v[i]);
	int t=w[i]-w[1];a[t][++cnt[t]]=v[i];
    }
    for(int i=0;i<4;i++) sort(a[i]+1,a[i]+1+cnt[i],cmp);
    work();
	return 0;
}

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

#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define DEBUG(i) cout << #i << ": " << i << endl;
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int N, W;
pll P[100];
vector<ll> q[4];

int main(void) {
  cin >> N >> W;
  REP(i, 0, N) cin >> P[i].fi >> P[i].se;

  ll m = min_element(P, P + N)->fi;
  sort(P, P + N);
  reverse(P, P + N);
  REP(i, 0, 4) q[i].push_back(0);
  REP(i, 0, N) q[P[i].fi - m].push_back(P[i].se);
  REP(i, 0, 4) REP(j, 1, q[i].size()) q[i][j] += q[i][j - 1];

  ll ans = 0;
  REP(i, 0, q[0].size() + 1) {
    REP(j, 0, q[1].size() + 1) {
      REP(k, 0, q[2].size() + 1) {
        REP(l, 0, q[3].size() + 1) {
          if(i * m + j * (m + 1) + k * (m + 2) + l * (m + 3) <= W) {
            ans = max(ans, q[0][i] + q[1][j] + q[2][k] + q[3][l]);
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: 'min_element' was not declared in this scope
   19 |   ll m = min_element(P, P + N)->fi;
      |          ^~~~~~~~~~~
a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |   sort(P, P + N);
      |   ^~~~
      |   short
a.cc:21:3: error: 'reverse' was not declared in this scope
   21 |   reverse(P, P + N);
      |   ^~~~~~~
Language: C++

#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#define NW 100000000005
typedef long long ll;
using namespace std;
ll dp[105][NW],w[105],v[105],N,W;
const ll INF=1000000005;  
int main()  
{    
	cin>>N>>W;
    fill(dp[0],dp[0]+W+1,INF);
	dp[0][0]=0;
	for (int i=0;i<N;i++)  
        cin>>w[i]>>v[i];  
    for (int i=0;i<N;i++)  
        for (int j=0;W;j++)  
            if (j<v[i])  
                dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
    ll res=0;
    for (int i=0;i<W;i++) if (dp[N][i]<=W) res=i;
	cout<<res;
} 

Compiler output:
/tmp/ccDtYmrF.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x90): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x19c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x1e3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccDtYmrF.o
a.cc:(.text+0x286): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n, k;
ll w[110], v[110], wb;
ll knap[110][110][310];
ll INF = 1LL<<40;

int main() {
    int i, j, l;

    scanf("%lld%lld",&n,&k);
    for (i=1;i<=n;i++) scanf("%lld%lld",&w[i],&v[i]);
    wb = w[1];
    for (i=1;i<=n;i++) w[i] -= wb;
    for (i=0;i<=n;i++) for (l=0;l<=3*n;l++) knap[i][0][] = -INF;
    knap[0][0][0] = 0;
    for (i=0;i<=n;i++) {
        for (j=1;j<=n;j++) {
            for (l=0;l<=3*n;l++) {
                knap[i][j][l] = max(knap[i][j-1][l],((l>=w[j]&&i>=1)?knap[i-1][j-1][l-w[j]]+v[j]:(-INF)));
            }
        }
    }
    ll res = 0;
    for (i=0;i<=n;i++) {
        for (l=0;l<=min(k-wb*i,3*n);l++) {
            res = max(res,knap[i][n][l]);
        }
    }
    printf("%lld\n",res);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:56: error: expected primary-expression before ']' token
   19 |     for (i=0;i<=n;i++) for (l=0;l<=3*n;l++) knap[i][0][] = -INF;
      |                                                        ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

struct solver {
  vector<long> ws;
  vector<long> vs;

  solver(vector<long> ws_, vector<long> vs_) : ws(ws_), vs(vs_) {}

  long solve(int n, long wlimit) {
    if (n == 0) {
      return 0;
    }
    if (*min_element(ws.begin(), ws.end()) > wlimit) {
      return 0;
    }
    if (ws[n-1] > wlimit) return solve(n-1, wlimit);
    return max(vs[n-1] + solve(n-1, wlimit - ws[n-1]), solve(n-1, wlimit));
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, w;
  cin >> n >> w;

  vector<long> ws(n), vs(n);
  for (int i = 0; i < n; i++) {
    cin >> ws[i];
    cin >> vs[i];
  }
  solver s{ws, vs};
  cout << s.solve(n, w) << endl;
  return 0;
}



Compiler output:
a.cc: In member function 'long int solver::solve(int, long int)':
a.cc:16:10: error: 'min_element' was not declared in this scope
   16 |     if (*min_element(ws.begin(), ws.end()) > wlimit) {
      |          ^~~~~~~~~~~
Language: C

#include <stdio.h>
#define MAXN 110
#define MAXW 500
int solve(int* w, int* v, int N, int W) {
    static int m[MAXN][MAXW];
    int mi = w[0];
    for(int i = 0; i < N; i++) W -= mi, w[i] -= mi;
    for(int i = 1; i < N; i++)
        for(int j = 0; j < W; j++)
            if(w[i] > j) m[i][j] = m[i - 1][j];
            else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]);
    return m[N][W];
}
int main(void) {
    int N, W, v[MAXN], w[MAXN];
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d%d", &w[i], &v[i]);
    printf("%d", solve(w, v, N, W));
    return 0;
}

Compiler output:
main.c: In function 'solve':
main.c:11:28: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   11 |             else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]);
      |                            ^~~
Language: C

#include <stdio.h>
#define MAXN 110
#define MAXW 500
int solve(int* w, int* v, int N, int W) {
    static int m[MAXN][MAXW];
    int mi = w[0];
    for(int i = 0; i < n; i++) W -= mi, w[i] -= mi;
    for(int i = 1; i < n; i++)
        for(int j = 0; j < W; j++)
            if(w[i] > j) m[i][j] = m[i - 1][j];
            else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]);
    return m[N][W];
}
int main(void) {
    int N, W, v[MAXN], w[MAXN];
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d%d", &w[i], &v[i]);
    printf("%d", solve(w, v, N, W));
    return 0;
}

Compiler output:
main.c: In function 'solve':
main.c:7:24: error: 'n' undeclared (first use in this function)
    7 |     for(int i = 0; i < n; i++) W -= mi, w[i] -= mi;
      |                        ^
main.c:7:24: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:28: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   11 |             else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]);
      |                            ^~~
Language: C++

#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long ll;
int n;
ll W;
vector<ll> v[4];
int w0;

int input(){
  int x;cin>>x;return x;
}

ll s[4][101];

int main(){
  cin >> n >> W;
  w0=input();
  v[0].push_back(input());
  for(int i=0;i<n-1;++i){
    v[input()-w0].push_back(input());
  }
  int m[4]={};
  for(int i=0;i<4;++i){
    m[i]=v[i].size();
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
    s[i][0]=0;
    for(int j=1;j<=m[i];++j)
      s[i][j]=s[i][j-1]+v[i][j-1];
  }

  ll ans = 0;

  for(int a=0;a<=m[0];++a){
    for(int b=0;b<=m[1];++b){
      for(int c=0;c<=m[2];++c){
	if(w0*a+(w0+1)*b+(w0+2)*c>W)
	  continue;
	int d = min(m[3],(int)((W-(w0*a+(w0+1)*b+(w0+2)*c))/(w0+3)));
	ans = max(ans, s[0][a]+s[1][b]+s[2][c]+s[3][d]);
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |     sort(v[i].begin(), v[i].end());
      |     ^~~~
      |     short
a.cc:31:5: error: 'reverse' was not declared in this scope
   31 |     reverse(v[i].begin(), v[i].end());
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int N;
    int W;
    cin >> N >> W;

    int w_i[N],v_i[N];

    int dp[N+1][401];
    int tmp_i;
    
    cin >> w_i[0] >> v_i[0];

    for(int i=1;i<N;i++){
        cin >> tmp_i >> v_i[i];
        w_i[i] = tmp_i - w_i[0] + 1;
    }
    w_i[0] = 1
    for(int i=0;i<=400;i++){
        dp[N][i] = 0;
    }

    for(int i=N-1;i>=0;i--){
        for(int w=0;w<=401;w++){
            if(w < w_i[i]){
                dp[i][w] = dp[i+1][w];
            }
            else{
                dp[i][w] = max(dp[i+1][w], dp[i+1][w - w_i[i]] + v_i[i]);
            }
        }
    }
    cout << dp[0][W] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: expected ';' before 'for'
   22 |     w_i[0] = 1
      |               ^
      |               ;
   23 |     for(int i=0;i<=400;i++){
      |     ~~~        
a.cc:23:17: error: 'i' was not declared in this scope
   23 |     for(int i=0;i<=400;i++){
      |                 ^
Language: C++

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

vector<int> weight(105);
vector<int> value(105);
vector<vector<int>> select(105+1, vector<int>(1000000000+1,0));

int zeroOnePack(int N, int C, const vector<int>& weight, const vector<int>& value)
{
    vector<vector<int>> select(N+1, vector<int>(C+1,0));
    for(int i = 1; i <= N; ++i)
    {
        for(int j = 1; j <= C; ++j)
        {
            if (weight[i - 1] > j)
                select[i][j] = select[i - 1][j];
            else
                select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
        }
    }
    return select[N][C];
}
int main()
{
    int n, c;
    scanf("%d %d", &n, &c);
    for(int i = 0; i < n; i++){
            int tw, tv;
        scanf("%d %d", &weight[i], &value[i]);
    }
    cout << zeroOnePack(n, c, weight, value) << endl;
    return 0;
}

Compiler output:
a.cc:7:27: error: 'std::vector<std::vector<int> > select' redeclared as different kind of entity
    7 | vector<vector<int>> select(105+1, vector<int>(1000000000+1,0));
      |                           ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 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/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  102 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
Language: C++

D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max

Compiler output:
a.cc:1:14: warning: missing terminating ' character
    1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max
      |              ^
a.cc:1:14: error: missing terminating ' character
    1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:1:1: error: 'D' does not name a type
    1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max
      | ^
a.cc:1:8: error: expected ')' before '=' token
    1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max
      |      ~ ^
      |        )
Language: C++

#include<cstdio>
#include<cstring>
#include<vector>
#include<map>


using namespace std;

typedef long long ll;


struct x_t
{
	int w, v;
};


struct f_t
{
	unsigned f[4];
//	f_t(){f[0]=f[1]=f[2]=f[3]=0;}
	operator < (const f_t& rhs) const {
		return memcmp(f, rhs.f, 16)<0;
	}
};


int N, W;
vector<x_t> x;
map<f_t,x_t> m;


int max(int a, int b)
{
	if(a>b) return a;
	return b;
}


int max_u(int &m, int v)
{
	if(m<v) m=v;
	return m;
}


x_t solve(int n, f_t f, int w, int v)
{
	x_t a, b;

	if(w>W) return (x_t){w, 0};
	if(n<0) return (x_t){w, v};
	if(m.find(f)!=m.end()) return m[f];

	a=solve(n-1, f, w, v);
	m[f]=a;

	f.f[n/32]|=(1<<(n%32));
	b=solve(n-1, f, w+x[n].w, v+x[n].v);
	m[f]=b;

	if(a.v>b.v) return a;
	return b;
}


int main(void)
{
	int i;
	f_t f={{0}};

	while(scanf("%d%d", &N, &W)==2)
	{
		x.resize(N);
		m.clear();
		for(i=0;i<N;i++) scanf("%d%d", &x[i].w, &x[i].v);

		printf("%d\n", solve(N-1, f, 0, 0).v);
	}

	return 0;
}


Compiler output:
a.cc:22:9: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
   22 |         operator < (const f_t& rhs) const {
      |         ^~~~~~~~
Language: C++

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

long long dp[105][405][105];
long long www[405];
long long vvv[405];


long long main(){
    long long n,w;
    cin>>n>>w;
    memset(dp,0,sizeof(dp));
    for(long long i=0;i<n;i++){
        cin>>www[i]>>vvv[i];
    }
    long long tmp=www[0]-1;
    for(long long i=1;i<n;i++){
        www[i]-=www[0];
    }
    www[0]=0;
    for(long long i=1;i<405;i++)
        dp[0][i][1]=vvv[0];
    for(long long i=0;i<n;i++) www[i]++;
    for(long long i=1;i<n;i++){
        for(long long j=0;j<402;j++){
            for(long long k=1;k<=n;k++){
                //if(i==1&&j==1&&k==1) cout<<"~~~~~~~~~~ "<<dp[i-1][j][k]<<endl;
                if(j>=www[i])
                    dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j-www[i]][k-1]+vvv[i]);
                else
                    dp[i][j][k]=dp[i-1][j][k];
            }
        }
    }
    long long ans=0;
        for(long long j=0;j<405;j++){
            for(long long k=0;k<=n;k++){
                if(k*tmp+j<=w){
                  //  cout<<k*tmp+j<<' '<<dp[n-1][j][k]<<endl;
                 //   cout<<dp[n-1][j][k]<<endl;
                    ans=max(ans,dp[n-1][j][k]);
                }
            }
        }
        cout<<ans<<endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

int n, W;
int w[105];
int v[105];

ll dp[105][105][305];

ll solve(int idx, int left, int wt)
{
    if(left == 0)
        return 0;
    if(idx > n)
    {
        if(left != 0)
            return INT_MIN;
        else
           return 0;
    }
    if(dp[idx][left][wt] != -1)
        return dp[idx][left][wt];
    if(w[idx] > wt)
        return dp[idx][left][wt] = solve(idx + 1, left, wt);
    else
        return dp[idx][left][wt] = max(v[idx] + solve(idx + 1, left - 1, wt - w[idx]), solve(idx + 1, left, wt));
}

int main()
{
    scanf("%d %d", &n, &W);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d %d", &w[i], &v[i]);
    int x = w[1];
    for(int i = 1 ; i <= n ; i++)
        w[i] -= x;
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if((W - i*x) < 0 )
            continue;
        int wgt = min(3*i, W - i*x);
        memset(dp, -1, sizeof(dp));
        ans = max(ans, solve(1, i, wgt));
    }
    printf("%lld", ans);
    return 0;
}


Compiler output:
a.cc:8:1: error: 'll' does not name a type
    8 | ll dp[105][105][305];
      | ^~
a.cc:10:1: error: 'll' does not name a type
   10 | ll solve(int idx, int left, int wt)
      | ^~
a.cc: In function 'int main()':
a.cc:37:5: error: 'll' was not declared in this scope
   37 |     ll ans = 0;
      |     ^~
a.cc:43:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   43 |         memset(dp, -1, sizeof(dp));
      |                ^~
      |                dup
a.cc:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |         ans = max(ans, solve(1, i, wgt));
      |         ^~~
      |         abs
a.cc:44:24: error: 'solve' was not declared in this scope
   44 |         ans = max(ans, solve(1, i, wgt));
      |                        ^~~~~
a.cc:46:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |     printf("%lld", ans);
      |                    ^~~
      |                    abs
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	ll W;
	cin >> N >> W;

	ll w[N],v[N];
	rep(i,N) cin >> w[i] >> v[i];

	if(W <= 10000){
		ll dp[N+1][W+1] = {};
		rep(i,N){
			rep(j,W+1){
				if(j >= w[i]) dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
			}
		}
		cout << dp[N][W] << endl;
	}else{
		if(W < w[0]) {
			cout << 0 << endl;
			return 0;
		}

		ll dp[N+1][N+1][3*N] = {};
		rep(i,N){
			FOR(j,1,i+1){
				rep(k,3*(i+1)){
					int d = w[i] - w[0];
					if(k >= d) dp[i+1][j][k] = max(dp[i][j][k],dp[i][j-1][k-d])
				}
			}
		}

		int a = W / w[0];
		int b = W - w[0] * a;

		cout << dp[N][a][b] << endl;
	}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:100: error: expected ';' before '}' token
   61 |                                         if(k >= d) dp[i+1][j][k] = max(dp[i][j][k],dp[i][j-1][k-d])
      |                                                                                                    ^
      |                                                                                                    ;
   62 |                                 }
      |                                 ~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

struct Data{
   int w, v, id;
   bool operator<(const Data &r)const{
      return v!=r.v ? v>r.v : w<r.w;
   }
};

int N, W;
vector<int> w, v;
int used[101];

int calc(int i, int rest){

   if(i==N) return 0;
   int ret=0;
   ret=calc(i+1, rest);
   if(rest-w[i]>=0) ret=max(ret, rec(i+1, rest-w[i])+v[i]);
   return ret;

}

int main(){

   cin>> N>> W;
   w.resize(N);
   v.resize(N);
   repeat(i, N) cin>> w[i]>> v[i];

   vector<Data> item;
   repeat(i, N) item.push_back(Data{w[i], v[i], i});
   sort(item.begin(), item.end());

   int s=0;
   int r=w[0];
   int X=(r+3)*N;
   int jj=0;
   int u=N;

   while(u>15){
      auto e=item[jj];
      if(W-e.w>=0){
         s+=e.v;
         W-=e.w;
         u--;
      }
      used[jj]=1;
      jj+=1;
   }

   cout<< s+calc(jj, W)<< endl;


   return 0;
}


Compiler output:
a.cc: In function 'int calc(int, int)':
a.cc:25:34: error: 'rec' was not declared in this scope; did you mean 'ret'?
   25 |    if(rest-w[i]>=0) ret=max(ret, rec(i+1, rest-w[i])+v[i]);
      |                                  ^~~
      |                                  ret
Language: C

#include <stdio.h>
#include <math.h>

const int MAX_N = 1000; // nの最大値
const int MAX_W = 1000000000; // Wの最大値
void solve_dp2();

// 入力
int n, W;
int w[MAX_N], v[MAX_N];

// DPテーブル
// dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。
int dp[MAX_N + 1][MAX_W + 1];

int main(){
  int i,a,b;

  scanf("%d%d",&n,&W);

  for (i = 0; i < n; i++){
    scanf("%d%d",&a,&b);
    w[i] = a;
    v[i] = b;
  }

  solve_dp2();

  return 0;
}

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] = fmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
    }
  }
  printf("%d\n", dp[0][W]);
  return 0;
}

Compiler output:
main.c:10:5: error: variably modified 'w' at file scope
   10 | int w[MAX_N], v[MAX_N];
      |     ^
main.c:10:15: error: variably modified 'v' at file scope
   10 | int w[MAX_N], v[MAX_N];
      |               ^
main.c:14:5: error: variably modified 'dp' at file scope
   14 | int dp[MAX_N + 1][MAX_W + 1];
      |     ^~
main.c:14:5: error: variably modified 'dp' at file scope
main.c: In function 'solve_dp2':
main.c:45:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   45 |   return 0;
      |          ^
main.c:32:6: note: declared here
   32 | void solve_dp2() {
      |      ^~~~~~~~~
Language: C

#include <stdio.h>
#include <math.h>

const int MAX_N = 100; // nの最大値
const int MAX_W = 1000000000; // Wの最大値
void solve_dp2();

// 入力
int n, W;
int w[MAX_N], v[MAX_N];

// DPテーブル
// dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。
int dp[MAX_N + 1][MAX_W + 1];

int main(){
  int i,a,b;

  scanf("%d%d",&n,&W);

  for (i = 0; i < n; i++){
    scanf("%d%d",&a,&b);
    w[i] = a;
    v[i] = b;
  }

  solve_dp2();

  return 0;
}

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] = fmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
    }
  }
  printf("%d", dp[0][W]);
}

Compiler output:
main.c:10:5: error: variably modified 'w' at file scope
   10 | int w[MAX_N], v[MAX_N];
      |     ^
main.c:10:15: error: variably modified 'v' at file scope
   10 | int w[MAX_N], v[MAX_N];
      |               ^
main.c:14:5: error: variably modified 'dp' at file scope
   14 | int dp[MAX_N + 1][MAX_W + 1];
      |     ^~
main.c:14:5: error: variably modified 'dp' at file scope
Language: Java

import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicLong;

public class Main {

	static long first = -1;
	static int w = -1;

	// 14:33-
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedInputStream(System.in));
		int n = sc.nextInt();
		w = sc.nextInt();

		ArrayList[] ws = new ArrayList[4];
		for (int i = 0; i < ws.length; i++) ws[i] = new ArrayList();

		for (int i = 0; i < n; i++) {
			int wi = sc.nextInt();
			if (i == 0) first = wi;
			int vi = sc.nextInt();

			ws[wi - first].add(vi);
		}

		for (int i = 0; i < ws.length; i++) Collections.sort(ws[i]);

		ArrayList[] prf = new ArrayList[4];
		for (int i = 0; i < prf.length; i++) {
			prf[i] = new ArrayList();
			prf[i].add(0L);
		}

		for (int i = 0; i < ws.length; i++) {
			int k = 1;
			int lastElem = ws[i].size() - 1;
			for (int j = lastElem; j >= 0; j--) {
				long val = (Integer) ws[i].get(j);
				val += (long) prf[i].get(k-1);
				prf[i].add(val);
				k++;
			}
		}


		AtomicLong max = new AtomicLong();
		int[] choice = new int[4];
		doit(choice, ws, prf, 0, max);

		System.out.println(max.get());
	}

	private static void doit(int[] choice, ArrayList[] ws, ArrayList[] prf, int pos, AtomicLong max) {
		if (pos == ws.length) {
			long avail = w;
			long worth = 0;
			for (int i = 0; i < choice.length; i++) {
				avail -= choice[i] * (first + i);
				if (avail < 0) break;
//				for (int j = 0; j < choice[i]; j++) worth += (Integer) ws[i].get(ws[i].size() - 1 - j);
				worth += (long) prf[i].get(choice[i]);
			}
			if (avail >= 0) max.set(Math.max(worth, max.get()));
			return;
		}

		for (int i = 0; i <= ws[pos].size(); i++) {
			choice[pos] = i;
			doit(choice, ws, prf, pos + 1, max);
		}
	}
}


Compiler output:
Main.java:26: error: incompatible types: possible lossy conversion from long to int
			ws[wi - first].add(vi);
			      ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include <bits/stdc++.h>

using namespace std;

int ans;
int n,W;
vector<int> w(100,0),v(100,0);


void dfs(int wsum,int vsum,int i){
    if(i == n){
        if(ans < vsum)
            ans = vsum;
    }
    else{
        dfs(wsum,vsum,i+1);
        if(wsum+w[i] <= W){
            dfs(wsum+w[i],vsum+v[i],i+1);
        }
        else{
            if(ans < vsum)
                ans = vsum;
        }
    }
}

void sol(){
    if(w[0]<=W)
        dfs(0,0,0);
}

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

#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <algorithm>
#define int long long
using namespace std;
 
const int maxn = 1000 + 5;
 
int T;
int N, V;
map<int,int> value;
map<int,int> volume;
map<int,int> dp;
 
void input()
{
    std::ios::sync_with_stdio(false);
    scanf("%lld%lld", &N, &V);
    for(int i = 0; i < N; ++i)
    {
        cin >> volume[i];
        cin >> value[i];
    }
}
 
void solve()
{
    std::ios::sync_with_stdio(false);
    dp.clear();
    for(int i = 0; i < N; ++i)
    {
        for(int j = V; j >= volume[i]; --j)
        {
            dp[j] = max(dp[j - volume[i]] + value[i], dp[j]);
        }
    }
    cout << dp[V] << endl;
}
int main()
{
    input();
    solve();
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <cstdio>
 
int Num=0;
long int WCap=0;
long int Weight[100]={};
long int Value[100]={};
 
inline int Max(int L,int R){
	return L>=R?L:R;
}
 
int Search(int Depth,int RemCap);
 
int main(){
	scanf(" %d %ld",&Num,&WCap);
	for(int i=0;i<Num;i++){
		scanf(" %ld %ld",&Weight[i],&Value[i]);
	}
	printf("%d\n",Search(0,WCap));
}
 
int Search(int Depth,int RemCap){
	//printf("Start:%d,%d\n",Depth,RemCap);
	if(Depth==Num){
		return 0;
	}
	if(Weight[Depth]>RemCap){
		return Search(Depth+1,RemCap);
	}
	return Max(Search(Depth+1,RemCap),Search(Depth+1,RemCap-Weight[Depth])+Value[Depth]);
}v

Compiler output:
a.cc:31:2: error: 'v' does not name a type
   31 | }v
      |  ^
Language: C++


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long;
Int N, W;
const Int N_MAX = 101;
const Int W_MAX = 1000000004;
Int dp[N_MAX][W_MAX];
Int w[N_MAX];
Int v[N_MAX];

void solve() {
    cin >> N >> W;
    REP(i, N){
        cin >> w[i + 1] >> v[i + 1];
    }
    REP(i, W + 1) {
        dp[0][i] = 0;
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= W; j++) {
            Int v0 = dp[i-1][j];
            Int v1 = (w[i] <= j) ? dp[i-1][j - w[i]] + v[i] : 0;
            dp[i][j] = max(v0, v1);
        }
    }
    
    cout << dp[N][W] << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Compiler output:
/tmp/ccZQKjap.o: in function `solve()':
a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZQKjap.o
a.cc:(.text+0x81): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZQKjap.o
a.cc:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZQKjap.o
a.cc:(.text+0x169): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZQKjap.o
a.cc:(.text+0x1a4): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZQKjap.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main(){
    int N,
    long long W,v,w;
    scanf("%d %lld",&N,&W);
    vector<long long> dp(W+1);
    fill(dp.begin(), dp.end(), 0);
    for(int i=0;i<N;i++){
        scanf("%lld %lld",&w,&v);
        dp[w]=max(dp[w],v);
        for(int j=0;j<W-w+1;j++){
            if(dp[j]!=0){
                dp[j+w]=max(dp[j+w],dp[j]+v);
            }
        }
    }
    printf("%lld\n",*max_element(dp.begin(),dp.end()));
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: expected unqualified-id before 'long'
   11 |     long long W,v,w;
      |     ^~~~
a.cc:12:25: error: 'W' was not declared in this scope
   12 |     scanf("%d %lld",&N,&W);
      |                         ^
a.cc:16:28: error: 'w' was not declared in this scope
   16 |         scanf("%lld %lld",&w,&v);
      |                            ^
a.cc:16:31: error: 'v' was not declared in this scope
   16 |         scanf("%lld %lld",&w,&v);
      |                               ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define ll long long
#define ld long double
#define pdd pair<double,double>
#define pll pair<ll, ll>
#define pii pair<int,int>

#define mod 1000000007
#define infinity (ll)1e18+1
#define PI 3.14159265358979

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()

int f(int a, int b)
{
	return a > b;
}

int main()
{
	int n; cin >> n;
	ll W;
	cin >> W;

	vll w(n), v(n);
	FOR(i, 0, n)
		cin >> w[i] >> v[i];

	ll best = 0;

	vi w0, w1, w2, w3;
	FOR(i, 0, n)
	{
		if (w[i] - w[0] == 0) w0.push_back(v[i]);
		if (w[i] - w[0] == 1) w1.push_back(v[i]);
		if (w[i] - w[0] == 2) w2.push_back(v[i]);
		if (w[i] - w[0] == 3) w3.push_back(v[i]);
	}
	
	sort(ALL(w0), f);
	sort(ALL(w1), f);
	sort(ALL(w2, f));
	sort(ALL(w3), f);

	
	ll curr = 0;
	FOR(x1, 0, w0.size() + 1)
		FOR(x2, 0, w1.size() + 1)
		FOR(x3, 0, w2.size() + 1)
		FOR(x4, 0, w3.size() + 1)
	{
		if (x1*w[0] + x2*(w[0] + 1) + x3*(w[0] + 2) + x4*(w[0] + 3) <= W)
		{
			curr = 0;
			FOR(i, 0, x1)
				curr += w0[i];
			FOR(i, 0, x2)
				curr += w1[i];
			FOR(i, 0, x3)
				curr += w2[i];
			FOR(i, 0, x4)
				curr += w3[i];

			best = max(best, curr);
		}
	}



	cout << best;
	return 0;
}

Compiler output:
a.cc:77:23: error: macro "ALL" passed 2 arguments, but takes just 1
   77 |         sort(ALL(w2, f));
      |                       ^
a.cc:47:9: note: macro "ALL" defined here
   47 | #define ALL(a) a.begin(), a.end()
      |         ^~~
a.cc: In function 'int main()':
a.cc:77:14: error: 'ALL' was not declared in this scope
   77 |         sort(ALL(w2, f));
      |              ^~~