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

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
const int N = 110;
int vis[N][N];
int t[100000];
ll a,b,c,d,n,w,sumv,sumw,maxx;
ll wa[1000],wb[1000],wc[1000],wd[1000];
ll va[1000],vb[1000],vc[1000],vd[1000];
struct node
{
    ll w,v;
}g[1000];

node aa[1000],bb[1000],cc[1000],dd[1000];
int cmp(node a,node b)
{
    return a.v>b.v;
}

void init()
{
    sort(aa+1,aa+a+1,cmp);
    sort(bb+1,bb+b+1,cmp);
    sort(cc+1,cc+c+1,cmp);
    sort(dd+1,dd+d+1,cmp);
}

void inv()
{

    wa[0]=0;
    va[0]=0;
    for(int i=1;i<=a;i++)
    {
        wa[i]=wa[i-1]+aa[i].w;
        va[i]=wa[i-1]+aa[i].v;
    }
    wb[0]=0;
    vb[0]=0;
    for(int i=1;i<=b;i++)
    {
        wb[i]=wb[i-1]+bb[i].w;
        vb[i]=vb[i-1]+bb[i].v;
    }
    wc[0]=0;
    vc[0]=0;
    for(int i=1;i<=c;i++)
    {
        wc[i]=wc[i-1]+cc[i].w;
        vc[i]=vc[i-1]+cc[i].v;
    }
    wd[0]=0;
    vd[0]=0;
    for(int i=1;i<=d;i++)
    {
        wd[i]=wd[i-1]+dd[i].w;
        vd[i]=vd[i-1]+dd[i].v;
    }
}
int main()
{
    a=0;
    b=0;
    c=0;
    d=0;
   for(int i=0;i<1000;i++)
   {
       wa[i]=wb[i]=wc[i]=wd[i]=0;
       va[i]=vb[i]=vc[i]=vd[i]=0;
   }
   for(int i=0;i<10000;i++)
   {
       t[i]=1;
   }
   for(int i=0;i<100;i++)
   {
       for(int j=0;j<100;j++)
       {
           vis[i][j]=-1;
       }
   }
   cin>>n>>w;
   for(int i=1;i<=n;i++)
   {
       cin>>g[i].w>>g[i].v;
       if(g[i].w==g[1].w)
       {
           a++;
           aa[a]=g[i];
       }
       if(g[i].w==g[1].w+1)
       {
           b++:
           bb[b]=g[i];
       }
       if(g[i].w==g[1].w+2)
       {
           c++;
           cc[c]=g[i];
       }
       if(g[i].w==g[1].w+3)
       {
           d++;
           dd[d]=g[i];
       }
   }
   init();
   inv();
   sumv=0;
   sumw=0;
   //cout<<a<<b<<c<<d<<endl;
   for(int i=0;i<=a;i++)
   {
       //cout<<1<<endl;
       for(int j=0;j<=b;j++)
       {
           for(int k=0;k<=c;k++)
           {
               for(int q=0;q<=d;q++)
               {
                   sumw=wa[i]+wb[j]+wc[k]+wd[q];
                   sumv=va[i]+vb[j]+vc[k]+vd[q];
                   //cout<<sumw<<sumv<<1<<endl;
                   if(sumw<=w)
                   {
                       maxx=max(maxx,sumv);
                   }
               }
           }
       }
   }
   cout<<maxx<<endl;
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:95:15: error: expected ';' before ':' token
   95 |            b++:
      |               ^
      |               ;
Language: C

#include <bits/stdc++.h>
#define inf (1<<29)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define MEMSET(a) memset(a,0,sizeof(a))
#define pb push_back
using namespace std;

int main(){
	int N,W;
	cin>>N>>W;
	int w,v,w1;
	vector<int> V[4];
	cin>>w1>>v;
	V[0].pb(v);
	rep(i,N-1){
		cin>>w>>v;
		V[w-w1].pb(v);
	}
	rep(i,4){
		sort(V[i].begin(),V[i].end());
		reverse(V[i].begin(),V[i].end());
		rep(j,(int)V[i].size()-1)V[i][j+1]+=V[i][j];
	}
	int a1,a2,a3,a4;
	long long max;
	a1=a2=a3=a4=max=0;
	rep(i,V[0].size()+1){
		rep(j,V[1].size()+1){
			rep(k,V[2].size()+1){
				rep(l,V[3].size()+1){
					int t=(i+j+k+l)*w1+j+2*k+3*l;
					long long r=0;
					if(i)r+=V[0][i-1];
					if(j)r+=V[1][j-1];
					if(k)r+=V[2][k-1];
					if(l)r+=V[3][l-1];
					if(t<=W&&r>max){
						max=r;
						a1=i;
						a2=j;
						a3=k;
						a4=l;
					}
				}
			}
		}
	}
	long long ans=0;
	if(a1)ans+=V[0][a1-1];
	if(a2)ans+=V[1][a2-1];
	if(a3)ans+=V[2][a3-1];
	if(a4)ans+=V[3][a4-1];
	cout<<ans<<endl;
	return 0;
}

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

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,j,a[4],m[4];
	ll w,v,ans=0ll,W,c[4],wsum,vsum;
	vector<ll> g[4];
	cin >> n >> W;
	cin >> c[0] >> v;
	g[0].push_back(v);
	for(i=1; i<n; ++i){
		cin >> w >> v;
		g[w-c[0]].push_back(v);
	}
	for(i=0; i<4; ++i){
		c[i] = c[0]+i;
		g[i].push_back(0ll);
		m[i] = g[i].l_ength();
		sort(g[i].begin(),g[i].end());
		for(j=1; j<m[i]; j++){
			g[i][j] += g[i][j-1];
		}
	}
	ans = 0ll;
	for(a[0]=0; a[0]<m[0]; ++a[0]){
		for(a[1]=0; a[1]<m[1]; ++a[1]){
			for(a[2]=0; a[2]<m[2]; ++a[2]){
				for(a[3]=0; a[3]<m[3]; ++a[3]){
					wsum = 0ll;
					for(i=0; i<4; i++){
						wsum += c[i]*a[i];
					}
					if(wsum>W){
						continue;
					}
					vsum = 0ll;
					for(i=0; i<4; i++){
						vsum += g[a[i]];
					}
					ans = max(ans,vsum);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:54: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::vector<long long int>')
   49 |                                                 vsum += g[a[i]];
      |                                                 ~~~~~^~~~~~~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,j,a[4],m[4];
	ll w,v,ans=0ll,W,c[4],wsum,vsum;
	vector<ll> g[4];
	cin >> n >> W;
	cin >> c[0] >> v;
	g[0].push_back(v);
	for(i=1; i<n; ++i){
		cin >> w >> v;
		g[w-c[0]].push_back(v);
	}
	for(i=0; i<4; ++i){
		c[i] = c[0]+i;
		g[i].push_back(0ll);
		m[i] = g[i].l_ength();
		sort(g[i].begin(),g[i].end());
		for(j=1; j<m[i]; j++){
			g[i] += g[i-1];
		}
	}
	ans = 0ll;
	for(a[0]=0; a[0]<m[0]; ++a[0]){
		for(a[1]=0; a[1]<m[1]; ++a[1]){
			for(a[2]=0; a[2]<m[2]; ++a[2]){
				for(a[3]=0; a[3]<m[3]; ++a[3]){
					wsum = 0ll;
					for(i=0; i<4; i++){
						wsum += c[i]*a[i];
					}
					if(wsum>W){
						continue;
					}
					vsum = 0ll;
					for(i=0; i<4; i++){
						vsum += g[a[i]];
					}
					ans = max(ans,vsum);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:30: error: no match for 'operator+=' (operand types are 'std::vector<long long int>' and 'std::vector<long long int>')
   32 |                         g[i] += g[i-1];
      |                         ~~~~~^~~~~~~~~
a.cc:49:54: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::vector<long long int>')
   49 |                                                 vsum += g[a[i]];
      |                                                 ~~~~~^~~~~~~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,j,a[4],m[4];
	ll w,v,ans=0ll,W,c[4],wsum,vsum;
	vector<ll> g[4];
	cin >> n >> W;
	cin >> c[0] >> v;
	g[0].push(v);
	for(i=1; i<n; ++i){
		cin >> w >> v;
		g[w-c[0]].push(v);
	}
	for(i=0; i<4; ++i){
		c[i] = c[0]+i;
		g[i].push_back(0ll);
		m[i] = g[i].l_ength();
		sort(g[i].begin(),g[i].end());
		for(j=1; j<m[i]; j++){
			g[i] += g[i-1];
		}
	}
	ans = 0ll;
	for(a[0]=0; a[0]<m[0]; ++a[0]){
		for(a[1]=0; a[1]<m[1]; ++a[1]){
			for(a[2]=0; a[2]<m[2]; ++a[2]){
				for(a[3]=0; a[3]<m[3]; ++a[3]){
					wsum = 0ll;
					for(i=0; i<4; i++){
						wsum += c[i]*a[i];
					}
					if(wsum>W){
						continue;
					}
					vsum = 0ll;
					for(i=0; i<4; i++){
						vsum += g[a[i]];
					}
					ans = max(ans,vsum);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: 'class std::vector<long long int>' has no member named 'push'
   21 |         g[0].push(v);
      |              ^~~~
a.cc:24:27: error: 'class std::vector<long long int>' has no member named 'push'
   24 |                 g[w-c[0]].push(v);
      |                           ^~~~
a.cc:32:30: error: no match for 'operator+=' (operand types are 'std::vector<long long int>' and 'std::vector<long long int>')
   32 |                         g[i] += g[i-1];
      |                         ~~~~~^~~~~~~~~
a.cc:49:54: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::vector<long long int>')
   49 |                                                 vsum += g[a[i]];
      |                                                 ~~~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void) {
  int n, w;
  cin >> n >> w;
  vector<int> v1, v2, v3, v4;
  int minw, iniv;
  cin >> minw >> iniv;
  v1.push_back(iniv);
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == minw) {
      v1.push_back(b);
    } else if (a == minw + 1) {
      v2.push_back(b);
    } else if (a == minw + 2) {
      v3.push_back(b);
    } else if (a == minw + 3) {
      v4.push_back(b);
    }
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  sort(v3.begin(), v3.end());
  sort(v4.begin(), v4.end());
  vector<int> sum1(v1.size() + 1, 0), sum2(v2.size() + 1, 0), sum3(v3.size() + 1, 0), sum4(v4.size() + 1, 0);
  for (int i = 1; i <= v1.size(); i++) {
    sum1[i] = sum1[i - 1] + v1[i - 1];
  }
  for (int i = 1; i <= v2.size(); i++) {
    sum2[i] = sum2[i - 1] + v2[i - 1];
  }
  for (int i = 1; i <= v3.size(); i++) {
    sum3[i] = sum3[i - 1] + v3[i - 1];
  }
  for (int i = 1; i <= v4.size(); i++) {
    sum4[i] = sum4[i - 1] + v4[i - 1];
  }
  ll ans = 0;
  for (int i = 0; i <= v4.size(); i++) {
    int wnow = (minw + 3) * i;
    if (wnow > w) break;
    for (int j = 0; j <= v3.size(); j++) {
      wnow = (minw + 3) * i + (minw + 2) * j;
      if (wnow > w) break;
      for (int k = 0; k <= v2.size(); k++) {
        wnow = (minw + 3) * i + (minw + 2) * j + (minw + 1) * k;
        if (wnow > w) break;
        int l = min((w - wnow) / minw, (int)v1.size());
        if (sum1[l] + sum2[k] + sum3[j] + sum4[i] > ans) ans = sum1[l] + sum2[k] + sum3[j] + sum4[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:3: error: 'll' was not declared in this scope
   42 |   ll ans = 0;
      |   ^~
a.cc:53:53: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |         if (sum1[l] + sum2[k] + sum3[j] + sum4[i] > ans) ans = sum1[l] + sum2[k] + sum3[j] + sum4[i];
      |                                                     ^~~
      |                                                     abs
a.cc:57:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   57 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;

using ll = long long;
const ll INF = ((1LL << 60) - 1);

int N, W, u, v, w0, a, b, c, d;
vector<ll> w[4];
//ll memo[101][101][101][101];

// メモ化再帰
ll solve(ll price = 0, ll sum = 0, int i = 0, int j = 0, int k = 0, int l = 0) {
  //if (memo[i][j][k][l] != 0) return memo[i][j][k][l];

  if (sum > W) return -INF;

  ll ret = 0;

  ret = max(ret, price);

  if (i != a) ret = max(ret, solve(price + w[0][i], sum + w0, i + 1, j, k, l));
  if (j != b) ret = max(ret, solve(price + w[1][j], sum + w0 + 1, i, j + 1, k, l));
  if (k != c) ret = max(ret, solve(price + w[2][k], sum + w0 + 2, i, j, k + 1, l));
  if (l != d) ret = max(ret, solve(price + w[3][l], sum + w0 + 3, i, j, k, l + 1));

  return memo[i][j][k][l] = ret;
}

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

  cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    cin >> u >> v;
    if (i == 0) {
      w0 = u;
      w[0].push_back(v);
    }
    else {
      for (int i = 0; i < 4; ++i) {
        if (w0 + i == u) {
          w[i].push_back(v);
          break;
        }
      }
    }
  }

  for (int i = 0; i < 4; ++i) {
    sort(w[i].begin(), w[i].end(), greater<int>());
  }

  a = w[0].size();
  b = w[1].size();
  c = w[2].size();
  d = w[3].size();

  ll ans = solve();

  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'll solve(ll, ll, int, int, int, int)':
a.cc:33:10: error: 'memo' was not declared in this scope
   33 |   return memo[i][j][k][l] = ret;
      |          ^~~~
Language: C++


#include <iostream>
using namespace std;
using ll = long long;

ll max(ll x,ll y){
	if(x>y){
		return x;
	}else{
		return y;
	}
}

int main(){
	ll dp[101][11];
	ll N,W;
	ll w[101]={},v[101]={};
	ll w_1;
	cin >> N >> W;
	
	for(int i=1;i<=N;i++){
		cin >> w[i] >> v[i];
		if(i==1){ //w[i] 0<=...<=3
			w_1=w[1]-1;
			w[1]=1;
		}else{
			w[i]=w[i]-w_1;
		}
	}
	
	for(int i=0;i<101;i++){
		for(int j=0;j<11;j++){
			dp[i][j]=0;
		}
	}
	
	bool check[5]={};
	check[0]=true;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<11;j++){
			if(check[j]){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				
				if(j+w[i+1]<=W-(w_1+1&&j+w[i+1]<11)){
					dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
					check[j+w[i+1]]=true;
				}
			}
		}
	}
	
	ll answer=0;
	
	for(int i=0;i<11;i++){
		answer = max(answer,dp[N][i]);
	}
	
	cout << answer << endl;
	
	return 0;
}


int main(){
	ll dp[101][11];
	ll N,W;
	ll w[101]={},v[101]={};
	ll w_1;
	cin >> N >> W;
	
	for(int i=1;i<=N;i++){
		cin >> w[i] >> v[i];
		if(i==1){ //w[i] 0<=...<=3
			w_1=w[1]-1;
			w[1]=1;
		}else{
			w[i]=w[i]-w_1;
		}
	}
	
	for(int i=0;i<101;i++){
		for(int j=0;j<11;j++){
			dp[i][j]=0;
		}
	}
	
	bool check[5]={};
	check[0]=true;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<11;j++){
			if(check[j]){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				
				if(j+w[i+1]<=W-(w_1+1)){
					dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
					check[j+w[i+1]]=true;
				}
			}
		}
	}
	
	ll answer=0;
	
	for(int i=0;i<11;i++){
		answer = max(answer,dp[N][i]);
	}
	
	cout << answer << endl;
	
	return 0;
}

Compiler output:
a.cc:65:5: error: redefinition of 'int main()'
   65 | int main(){
      |     ^~~~
a.cc:14:5: note: 'int main()' previously defined here
   14 | int main(){
      |     ^~~~
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
ll v[4][101];
int c[4];

int main() {
	int n,w;
	cin>>n>>w;
	int w0;
	cin >> w0 >> v[0][++c[0]];
	FOR(i,1,n){
		int r;
		cin >> r;
		cin >> v[r-w0][++c[r-w0]];
	}
	REP(i,4){
		sort(v[i] + 1, v[i] + 1 + c[i], greater<ll>());
		REP(j,c[i])v[i][j+1]+=v[i][j];
		c[i]++;
	}
	ll ans = 0;
	REP(i,c[0])REP(j,c[1])REP(k, c[2])REP(l,c[3]){
		ll a = (ll)v[0][i] + v[1][j] + v[2][k] + v[3][l];
		ll s = (ll)w0 * (i+j+k+l) + j + k*2 + l*3;
		if(s<=w)ans = max(ans, a);
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |                 sort(v[i] + 1, v[i] + 1 + c[i], greater<ll>());
      |                 ^~~~
      |                 short
Language: C++

// knapsack.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;


#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;

ll dp[100][100];
ll n;
ll w[100], v[100];
ll knapsack(int p, int W){
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--){
		rep(j, W + 1){
			if (i == n - 1){
				dp[i][j] = j >= w[i] ? v[i] : 0;
			} else{
				if (j < w[i]) dp[i][j] = dp[i + 1][j];
				else dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]);
			}
			ans = max(ans, dp[i][j]);
		}
		//cout << "@ ans:" << ans<<endl;
	}
	//cout << "@ dp[2][2]:" << dp[2][2] << endl;
	//cout << "@ dp[2][2-w[1]]+v[1]:" << dp[2][2-w[1]]+v[1] << endl;
	//cout << "@ dp[1][3]:" << dp[1][3] << endl;
	//cout << "@ v[1]:" << v[1] << endl;
	return ans;
}

int main(){
	ll W;
	cin >> n >> W;
	rep(i, n){
		cin >> w[i] >> v[i];
	}
	cout << knapsack(0, W) << endl;


	return 0;
}


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

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;


#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;

ll dp[100][100];
ll n;
ll w[100], v[100];
ll knapsack(int p, int W){
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--){
		rep(j, W + 1){
			if (i == n - 1){
				dp[i][j] = j >= w[i] ? v[i] : 0;
			} else{
				if (j < w[i]) dp[i][j] = dp[i + 1][j];
				else dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]);
			}
			ans = max(ans, dp[i][j]);
		}
		//cout << "@ ans:" << ans<<endl;
	}
	//cout << "@ dp[2][2]:" << dp[2][2] << endl;
	//cout << "@ dp[2][2-w[1]]+v[1]:" << dp[2][2-w[1]]+v[1] << endl;
	//cout << "@ dp[1][3]:" << dp[1][3] << endl;
	//cout << "@ v[1]:" << v[1] << endl;
	return ans;
}

int main(){
	memset(dp, 0, sizeof(dp));
	ll W;
	cin >> n >> W;
	rep(i, n){
		cin >> w[i] >> v[i];
	}
	cout << knapsack(0, W) << endl;


	return 0;
}


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

// knapsack.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;


#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;

ll dp[100][100];
ll n;
ll w[100], v[100];
ll knapsack(int p, int W){
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--){
		rep(j, W + 1){
			if (i == n - 1){
				dp[i][j] = j >= w[i] ? v[i] : 0;
			} else{
				if (j < w[i]) dp[i][j] = dp[i + 1][j];
				else dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]);
			}
			ans = max(ans, dp[i][j]);
		}
		//cout << "@ ans:" << ans<<endl;
	}
	//cout << "@ dp[2][2]:" << dp[2][2] << endl;
	//cout << "@ dp[2][2-w[1]]+v[1]:" << dp[2][2-w[1]]+v[1] << endl;
	//cout << "@ dp[1][3]:" << dp[1][3] << endl;
	//cout << "@ v[1]:" << v[1] << endl;
	return ans;
}

int main(){
	memset(dp, 0, sizeof(dp));
	ll W;
	cin >> n >> W;
	rep(i, n){
		cin >> w[i] >> v[i];
	}
	cout << knapsack(0, W) << endl;


	return 0;
}


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

#Simple Knapsack

N,W = list(map(int, input().split()))

w = []
v = []
for i in range(N):
    wi,vi = list(map(int, input().split()))
    w.append(wi)
    v.append(vi)

#メモ化再帰
dp = [[-1]*(W+1) for i in range(N+1)]
def rec(i, j):
    if dp[i][j] != -1:
        return dp[i][j]
    if i == N:
        res = 0
    elif j < w[i]:
        res = rec(i + 1, j)
    else: 
        res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]) 
        dp[i][j] = res 
    return res 
print(rec(0, W)) 

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #Simple
    1 | #Simple Knapsack
      |  ^~~~~~
a.cc:12:2: error: invalid preprocessing directive #\U000030e1\U000030e2\U00005316\U0000518d\U00005e30
   12 | #メモ化再帰
      |  ^~~~~~~~~~
a.cc:3:1: error: 'N' does not name a type
    3 | N,W = list(map(int, input().split()))
      | ^
Language: Java

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main2 {

	public static void main(String[] args) {
		new Main2().solve();
	}
	static int N,W;
	static int w0;
	static ArrayList<Integer>[] v=new ArrayList[4];
	
	static void solve(){
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		W = sc.nextInt();
		
		for (int i = 0; i < v.length; i++) {
			v[i]=new ArrayList<Integer>(N);
		}
		w0=sc.nextInt();
		v[0].add(sc.nextInt());
		
		for(int i=1;i<N;i++){
			int w=sc.nextInt();
			v[w-w0].add(sc.nextInt());
		}
		for(int i=0;i<v.length;i++){
			v[i].sort(Comparator.reverseOrder());
		}
		
		System.out.println(solve2(0,N,0));
	}
	static int solve2(int startIndex,int numLeft,int totalW){
		
		if(startIndex>=v.length){
			return 0;
		}
		
		int vi=0;
		int wi=totalW;
		int max_v=0;
		
		for(int n=0;n<=numLeft && n<=v[startIndex].size();n++){
			if(n>=1){
				vi+=v[startIndex].get(n-1);
				wi+=w0+startIndex;
			}
			if(wi>W)break;
			
			max_v=Integer.max(max_v, vi+solve2(startIndex+1,numLeft-n,wi));
		}
		return max_v;
	}
}


Compiler output:
Main.java:5: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C

#include <stdio.h>
#define ll long long int 

ll max(ll a, ll b){
	return a > b ? a : b;
}

int main(){
	llt N, W, i, j, w[101], v[101], C[101][10000000001];
	
	scanf("%lld%lld", &N, &W);
	
	for(i = 1; i <= N; i++){
		scanf("%lld%lld", &w[i], &v[i]);
	}
	
	for(i = 1; i <= N; i++) C[i][0] = 0;
	for(i = 1; i <= W; i++) C[0][i] = 0;
	
	for(i = 1; i <= N; i++){
		for(j = 1; j <= W; j++){
			if(j < w[i]) C[i][j] = C[i-1][j];
			else C[i][j] = max(C[i-1][j], C[i - 1][j - w[i]] + v[i]);
		}
	}

	printf("%lld\n", C[N][W]);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:9: error: unknown type name 'llt'; did you mean 'll'?
    9 |         llt N, W, i, j, w[101], v[101], C[101][10000000001];
      |         ^~~
      |         ll
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N, W;
  cin >> N >> W;
  int w[N], v[N];
  for(int i = 0; i < N; ++i){
    cin >> w[i] >> v[i];
  }
 
  int dp[N + 100][N + 100];
  for(int i = N - 1; i >= 0; --i){
    for(int j = 0; j <= W; ++j){    
      if(i == N - 1){
        dp[N - 1][j] = max(0, v[N - 1])
      }
      else 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;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:40: error: expected ';' before '}' token
   16 |         dp[N - 1][j] = max(0, v[N - 1])
      |                                        ^
      |                                        ;
   17 |       }
      |       ~
Language: C++

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


int N, W;
int w, w0, v;
vector<vector<int> > vv(4);

int value(int I, int J, int K, int L) {
  int result = 0;
  for (int i = 0; i < I; i++) result += -vv[0][i];
  for (int j = 0; j < J; j++) result += -vv[1][j];
  for (int k = 0; k < K; k++) result += -vv[2][k];
  for (int l = 0; l < L; l++) result += -vv[3][l];
  return result;
}

int main() {
  // 入力
  cin >> N >> W;
  cin >> w0 >> v;
  vv[0].push_back(-v);
  for (int i = 1; i < N; i++) {
    cin >> w >> v;
    vv[w - w0].push_back(-v);
  }
  for (int i = 0; i < 4; i++) {
    sort(vv[i].begin(), vv[i].end());
  }a
  int ans = 0;
  for (int i = 0; i <= vv[0].size(); i++) {
    for (int j = 0; j <= vv[1].size(); j++) {
      for (int k = 0; k <= vv[2].size(); k++) {
        for (int l = 0; l <= vv[3].size(); l++) {
          if (i * w0 + j * (w0 + 1) + k * (w0 + 2) + l * (w0 + 3) > W) continue;
          ans = max(ans, value(i, j, k, l));
        }
      }
    }
  }
  // 解答
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:4: error: 'a' was not declared in this scope
   31 |   }a
      |    ^
a.cc:38:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |           ans = max(ans, value(i, j, k, l));
      |           ^~~
      |           abs
a.cc:44:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

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

typedef struct data{
  long long int w,v;
  long long double p;
}Data;
void swap(Data *a,Data *b){
  Data tmp=*a;*a=*b;*b=tmp;
}
int main(){
  int N,ans=0;
  long long int W;
  cin>>N>>W;
  vector<Data> d(N);
  for(int i=0;i<N;i++){
    cin>>d[i].w>>d[i].v;
    d[i].p=d[i].v / d[i].w;
  }
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if((d[i]).p<(d[j]).p)swap(&d[i],&d[j]);
    }
  }
  for(int i=0;i<N;i++){
    if(W>=(d[i]).w){
      W-=(d[i]).w;ans+=d[i].v;
    }
    if(W<=0)break;
  }
  
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc:9:8: error: 'long long' specified with 'double'
    9 |   long long double p;
      |        ^~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>

#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)>(b)?(b):(a))

using namespace std;
#define int long

int main() {
	int N, W;
	cin >> N >> W;
	int w0, v0;
	int w[4] = {};
	vector<int> v[4];
	cin >> w0 >> v0;
	w[0]++;
	v[0].push_back(v0);
	for (int i = 1; i < N; i++) {
		int tw, tv;
		cin >> tw >> tv;
		w[tw - w0]++;
		v[tw - w0].push_back(tv);
	}
	for (int i = 0; i < 4; i++) {
		sort(v[i].rbegin(), v[i].rend());
	}

	int ans = 0;
	for (int i = 0; i < w[0]+1; i++) {
		if (w0*i > W)	break;
		for (int j = 0; j < w[1]+1; j++) {
			if (w0*(i + j) + j > W) break;
			for (int k = 0; k < w[2]+1; k++) {
				if (w0*(i + j + k) + j + 2 * k > W) break;
				int l = min((W - w0*(i + j + k) + j + 2 * k) / (w0 + 3), w[3]);
				int vsum = 0;
				for (int a = 0; a < i; a++) vsum += v[0][a];
				for (int a = 0; a < j; a++) vsum += v[1][a];
				for (int a = 0; a < k; a++) vsum += v[2][a];
				for (int a = 0; a < l; a++) vsum += v[3][a];
				ans = max(ans, vsum);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

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

#include <iostream>
typedef long long LL;
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	LL W;
	cin>>N>>W;
	LL **d = new LL*[N+1];
	LL *v = new LL[N];
	LL *w = new LL[N];
	LL i,j;
	for (i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	for (i=0;i<=N;i++){
		d[i] = new LL[(LL)(W+1)];
		memset(d[i],0,(W+1)*sizeof(LL));
	}
	//ダイナミック計画法で解を求める
	for (i=1;i<=N;++i){
		for (j=0;j<=W;++j){
			d[i][j]=d[i-1][j];
			if (j>=w[i-1]){
				d[i][j] = max(d[i][j],d[i-1][j-w[i-1]]+v[i-1]);
			}
		}
	}
	cout<<d[N][W]<<endl;
	for (i=0;i<N;i++){
		delete d[i];
	}
	delete d;
	delete v,w;
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:18:17: error: 'memset' was not declared in this scope
   18 |                 memset(d[i],0,(W+1)*sizeof(LL));
      |                 ^~~~~~
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 | typedef long long LL;
Language: C++

#include <cstdio>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int MaxN = 1e5;
typedef long long LL;
?
int sum;
int n, V;
int w[105], v[105];
int a[105];
int dp[105][105][405];
//表示前i个物品中选j个容量为k
int main()
{
	while(scanf("%d %d", &n, &V) != EOF)
	{
		sum = 0;
		memset(dp, 0, sizeof(dp));
		for(int i = 1; i <= n; i++)
		{
			scanf("%d %d", &w[i], &v[i]);
			a[i] = w[i] - w[1];
			sum = sum + a[i];
		}
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= i; j++)
			{
				for(int k = 0; k < a[i]; k++)
					dp[i][j][k] = dp[i - 1][j][k];
			}
			for(int j = 1; j <= i; j++)
			{
				for(int k = a[i]; k <= sum; k++)
					dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - a[i]] + v[i]);
			}
		}
		int ans = 0;
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= i; j++) {
				if(w[1] * j > V) break;
				for(int k = 0; k <= min(sum, V - w[1] * j); k++) ans = max(ans, dp[i][j][k]);
			}
		printf("%d\n", ans);
	}
}


Compiler output:
a.cc:10:1: error: expected unqualified-id before '?' token
   10 | ?
      | ^
a.cc: In function 'int main()':
a.cc:21:17: error: 'sum' was not declared in this scope
   21 |                 sum = 0;
      |                 ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll (i)=(0);(i)<(ll)(n);++(i))
typedef pair<int, int> P;
typedef long long ll;

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

int main() {
    cin >> N >> W;
    rep(i, N) {
        int wi, vi;
        cin >> wi >> vi;
        if (w.size() == 0) {
            w.push_back(wi);
            v[w.size()-1].push_back(vi);
        }
        else {
            bool f=true;
            rep(j, w.size()) {
                if (w[j] == wi) {
                    v[j].push_back(vi);
                    f=false;
                }
            }
            if (f) {
                w.push_back(wi);
                v[w.size()-1].push_back(vi);
            }
        }
    }
    rep(i, w.size()) {
        sort(v[i].begin(), v[i].end(), greater<int>());
    }

    for (int i=w.size(); i<4; ++i) w.push_back(0);
    for (int i=0; i<4; ++i) {
        res = max(res, v[i].size());
    }
    for (int i=0; i<4; ++i) {
        if (v[i].size() < res) for (int j=v[i].size(); j<res; ++j) v[i].push_back(0);
    }

    res = 0;
    int sum1=0;
    for (int i=0; i<v[0].size(); ++i) {
        sum1 += v[0][i];
        int sum2 = 0;
        for (int j=0; j<v[1].size(); ++j) {
            sum2 += v[1][j];
            int sum3 = 0;
            for (int k=0; k<v[2].size(); ++k) {
                sum3 += v[2][k];
                int sum4 = 0;
                for (int l=0; l<v[3].size(); ++l) {
                    sum4 += v[3][l];
                    int t = 0;
                    if (W >= w[0]*(i+1)+w[1]*(j+1)+w[2]*(k+1)+w[3]*(l+1)) {
                        res = max(res, sum1+sum2+sum3+sum4);
                    }
                }
            }
        }
    }

    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: 'res' was not declared in this scope; did you mean 'rep'?
   40 |         res = max(res, v[i].size());
      |         ^~~
      |         rep
a.cc:43:27: error: 'res' was not declared in this scope; did you mean 'rep'?
   43 |         if (v[i].size() < res) for (int j=v[i].size(); j<res; ++j) v[i].push_back(0);
      |                           ^~~
      |                           rep
a.cc:46:5: error: 'res' was not declared in this scope; did you mean 'rep'?
   46 |     res = 0;
      |     ^~~
      |     rep
Language: Java

import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static HashMap<Point,Integer> map = new HashMap<Point,Integer>();
	static int N,W;
	static int[] w,v;
	
//	static int count =0;
	
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);	
		N = io.nextInt();
		W = io.nextInt();
		w = new int[N+1];
		v = new int[N+1];
		
		for (int i = 0; i < N; i++) {
			w[i+1] = io.nextInt();
			v[i+1] = io.nextInt();
		}
		
//		long time1 = System.currentTimeMillis();
		System.out.println(value(N,W));
//		long time2;
//		time2 = System.currentTimeMillis();
//		System.out.println("\ntime02:"+(time2 -time1));
//		System.out.println("count:: "+count);
		
	}
	public static int value(int i,int wMax){
		Point p = new Point(i,wMax);
//		System.out.print("now i wMax: "+i+" "+wMax+" /");
		if(map.containsKey(p)){
//			System.out.println("ok!");
			return map.get(p);
		}
//		System.out.println("non");
		count ++;
		int val;
		if(i==0){
			val = 0;
		}else if(wMax<w[i]){
			val = value(i-1,wMax);
		}else{
			val = Math.max(value(i-1,wMax),value(i-1,wMax-w[i])+v[i]);
		}
		map.put(p,val);
		return val;
	}
}

class Point{
	int i;
	int w;
	public Point(int i, int w){
		this.i = i;
		this.w = w;
 	}
	@Override
	public boolean equals(Object p){
		return (i==((Point)p).i && w==((Point)p).w);
	}
	@Override
	public int hashCode(){
		return w % 10000;
	}
}

Compiler output:
Main.java:39: error: cannot find symbol
		count ++;
		^
  symbol:   variable count
  location: class Main
1 error
Language: C

#include<stdio.h>


int main(void){

	int lop,lop2,lop3,n,w,ndata[100][2],ans[100],taihi,sakai[4],npr=0,kte=0,hanbun;

	scanf("%d",&n);
	scanf("%d",&w);
	
	for(lop=0;lop<4;lop++){
		sakai[lop]=0;
	}
	for(lop=0;lop<n;lop++){
		scanf("%d",&ndata[lop][0]);
		scanf("%d",&ndata[lop][1]);
	}

	for(lop=0;lop<n;lop++){
		for(lop2=1;lop2<n;lop2++){
			if(ndata[lop2-1][0]<ndata[lop2][0]){
				taihi=ndata[lop2-1][0];
				ndata[lop2-1][0]=ndata[lop2][0];
				ndata[lop2][0]=taihi;

				taihi=ndata[lop2-1][1];
				ndata[lop2-1][1]=ndata[lop2][1];
				ndata[lop2][1]=taihi;
			}else if(ndata[lop-1][0]==ndata[lop][0] && ndata[lop-1][1]<ndata[lop][1]){
				taihi=ndata[lop2-1][0];
				ndata[lop2-1][0]=ndata[lop2][0];
				ndata[lop2][0]=taihi;

				taihi=ndata[lop2-1][1];
				ndata[lop2-1][1]=ndata[lop2][1];
				ndata[lop2][1]=taihi;
		}
	}

	lop2=1;
	sakai[0]=0;
	for(lop=1;lop<=n;lop++){
		if(ndata[lop-1][0]!=ndata[lop][0]){
			sakai[lop2]=lop;
			lop2++;
		}
	}

	/*for(lop=0;lop<n;lop++){
		printf("%d   ",ndata[lop][0]);
		printf("%d  \n",ndata[lop][1]);
	}
	
	for(lop3=0;lop3<4;lop3++){
		for(lop=0;lop<sakai[lop3];lop++){
			for(lop2=sakai[lop3]+1;lop2<sakai[lop3+1];lop2++){
				if(ndata[lop2-1][1]<ndata[lop2][1]){
					taihi=ndata[lop2-1][0];
					ndata[lop2-1][0]=ndata[lop2][0];
					ndata[lop2][0]=taihi;

					taihi=ndata[lop2-1][1];
					ndata[lop2-1][1]=ndata[lop2][1];
					ndata[lop2][1]=taihi;
				}
			}
		}
	}*/


	for(lop=0;lop<n;lop++){
		npr=w;
		ans[lop]=0;
		for(lop2=lop;lop2<n;lop2++){	
			if(npr-ndata[lop2][0]>=0){
				ans[lop]+=ndata[lop2][1];
				npr-=ndata[lop2][0];
			}
		}

	}

	
	for(lop=1;lop<n;lop++){
		if(ans[kte]<ans[lop]){
			kte=lop;	
		}
	}
	
	

	printf("%d\n",ans[kte]);

	return 0;
}

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

#include<stdio.h>


int main(void){

	int lop,lop2,lop3,n,w,ndata[100][2],ans[100],taihi,sakai[3],npr=0,kte=0,hanbun;

	scanf("%d",&n);
	scanf("%d",&w);
	
	for(lop=0;lop<3;lop++){
		sakai[lop]=0;
	}
	for(lop=0;lop<n;lop++){
		scanf("%d",&ndata[lop][0]);
		scanf("%d",&ndata[lop][1]);
	}

	for(lop=0;lop<n;lop++){
		for(lop2=1;lop2<n;lop2++){
			if(ndata[lop2-1][0]<ndata[lop2][0]){
				taihi=ndata[lop2-1][0];
				ndata[lop2-1][0]=ndata[lop2][0];
				ndata[lop2][0]=taihi;

				taihi=ndata[lop2-1][1];
				ndata[lop2-1][1]=ndata[lop2][1];
				ndata[lop2][1]=taihi;
			}
		}
	}
	lop2=0;
	for(lop=1;lop<n;lop++){
		if(ndata[lop-1][0]!=ndata[lop][0]){
			sakai[lop2]=lop-1;
			lop2++;
		}
	}
	
	for(lop3=0;lop3<3;lop3++){
		for(lop=0;lop<sakai[lop3];lop++){
			for(lop2=1;lop2<sakai[lop3];lop2++){
				if(ndata[lop2-1][1]<ndata[lop2][1]){
					taihi=ndata[lop2-1][0];
					ndata[lop2-1][0]=ndata[lop2][0];
					ndata[lop2][0]=taihi;

					taihi=ndata[lop2-1][1];
					ndata[lop2-1][1]=ndata[lop2][1];
					ndata[lop2][1]=taihi;
				}
			}
		}
	}



	for(lop=0;lop<n;lop++){
		npr=w;
		ans[lop]=0;
		for(lop2=lop;lop2<n;lop2++){	
			if(npr-ndata[lop2][0]>=0){
				ans[lop]+=ndata[lop2][1];
				npr-=ndata[lop2][0];
			}
		}

	}

	lop=hanubn;

	for(lop=0;lop<n;lop++){
		for(lop2=1;lop2<n;lop2++){
			if(ndata[lop2-1][0]<ndata[lop2][0]){
				taihi=ndata[lop2-1][0];
				ndata[lop2-1][0]=ndata[lop2][0];
				ndata[lop2][0]=taihi;

				taihi=ndata[lop2-1][1];
				ndata[lop2-1][1]=ndata[lop2][1];
				ndata[lop2][1]=taihi;
			}
		}
	}
	lop2=0;
	for(lop=1;lop<n;lop++){
		if(ndata[lop-1][0]!=ndata[lop][0]){
			sakai[lop2]=lop-1;
			lop2++;
		}
	}
	
	for(lop3=0;lop3<3;lop3++){
		for(lop=0;lop<sakai[lop3];lop++){
			for(lop2=1;lop2<sakai[lop3];lop2++){
				if(ndata[lop2-1][1]<ndata[lop2][1]){
					taihi=ndata[lop2-1][0];
					ndata[lop2-1][0]=ndata[lop2][0];
					ndata[lop2][0]=taihi;

					taihi=ndata[lop2-1][1];
					ndata[lop2-1][1]=ndata[lop2][1];
					ndata[lop2][1]=taihi;
				}
			}
		}
	}



	for(lop=0;lop<n;lop++){
		npr=w;
		ans[lop+hanubn]=0;
		for(lop2=lop;lop2<n;lop2++){	
			if(npr-ndata[lop2][0]>=0){
				ans[lop+hanubn]+=ndata[lop2][1];
				npr-=ndata[lop2][0];
			}
		}

	}
	
	

	//printf("%d\n",ans[0]);
	for(lop=1;lop<n;lop++){
		//printf("%d\n",ans[lop]);
		if(ans[kte]<ans[lop]){
			kte=lop;	
		}
	}
	//printf("\n\n\n");
	
	

	printf("%d\n",ans[kte]);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:70:13: error: 'hanubn' undeclared (first use in this function); did you mean 'hanbun'?
   70 |         lop=hanubn;
      |             ^~~~~~
      |             hanbun
main.c:70:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C

for(lop=0;lop<n;lop++){
		npr=w;
		ans[lop]=0;
		for(lop2=lop;lop2<n;lop2++){	
			if(npr-ndata[lop2][0]>=0){
				ans[lop]+=ndata[lop2][1];
				npr-=ndata[lop2][0];
			}
		}

	}

Compiler output:
main.c:1:1: error: expected identifier or '(' before 'for'
    1 | for(lop=0;lop<n;lop++){
      | ^~~
main.c:1:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | for(lop=0;lop<n;lop++){
      |              ^
main.c:1:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    1 | for(lop=0;lop<n;lop++){
      |                    ^~
Language: C++

#include <iostream>

int N, W;
int w[100];
int v[100];
int dp[101][101];

int rec(int i, int j) {
  if (dp[i][j] >= 0) {
    return dp[i][j];
  }
  int val;
  if (i == N) {
    val = 0;
  } else if (j < w[i]) {
    val = rec(i+1, j);
  } else {
    val = std::max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
  }
  dp[i][j] = val;
  return val;
}

int main() {
  std::cin >> N >> W;
  std::memset(dp, -1, sizeof(dp));

  for (int i = 0; i < N; i++) {
    std::cin >> w[i] >> v[i];
  }

  std::cout << rec(0, W) << std::endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:8: error: 'memset' is not a member of 'std'; did you mean 'wmemset'?
   26 |   std::memset(dp, -1, sizeof(dp));
      |        ^~~~~~
      |        wmemset
Language: C++

#include <iostream>

int N, W;
int w[100];
int v[100];
int dp[101][101];

int rec(int i, int j) {
  if (dp[i][j] >= 0) {
    return dp[i][j];
  }
  int val;
  if (i == N) {
    val = 0;
  } else if (j < w[i]) {
    val = rec(i+1, j);
  } else {
    val = std::max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
  }
  dp[i][j] = val;
  return val;
}

int main() {
  std::cin >> N >> W;
  memset(dp, -1, sizeof(dp));

  for (int i = 0; i < N; i++) {
    std::cin >> w[i] >> v[i];
  }

  std::cout << rec(0, W) << std::endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:3: error: 'memset' was not declared in this scope
   26 |   memset(dp, -1, sizeof(dp));
      |   ^~~~~~
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 |
Language: C++

#include <iostream>                                                                          
using namespace std;

int main(){
    int N;
    long long W;
    cin >> N >> W;
    long long w[N+1],v[N+1];
    for(int i=1;i<=N;i++){
        cin >> w[i] >> v[i];
    }   

    long long dp[N+1][W+1];
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<=W;i++) dp[0][i] =0; 

    for(int i=1;i<=N;i++){
        for(int j=0;j<=W;j++){ // the index?
            if(j >= w[i]){ 
                dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }   
        }   
    }   
    //for(int i=0;i<=N;i++){
    //    for(int j=0;j<=W;j++){
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    // }

    cout << dp[N][W] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'memset' was not declared in this scope
   14 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
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 <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <unordered_set>
#include <set>
const INT_MIN = -0x7fffffff - 1;
using namespace std;
int n, wei;
int main() {
    scanf("%d %d", &n, &wei);
    vector<int> w(n);
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &w[i], &v[i]);
    }
    vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int a = n; a >= 0; a--) {
            for(int b = 0; b <= 3 * n; b++) {
                if(dp[a][b] >= 0) {
                    int b2 = b+ w[i] - w[0];
                    dp[a + 1][b2] = max(dp[a][b] + v[i], dp[a + 1][b2]);
                }
            }
        }
    }
    int ans = INT_MIN;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= 3 *n; j++) {
            if(i * w[0] + j <= wei) {
                ans = max(ans, dp[i][j]);
            }
        }
    }
    printf("%d\n", ans);
    
    
    return 0;
}

Compiler output:
a.cc:9:7: error: 'INT_MIN' does not name a type
    9 | const INT_MIN = -0x7fffffff - 1;
      |       ^~~~~~~
a.cc:9:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <set>
  +++ |+#include <climits>
    9 | const INT_MIN = -0x7fffffff - 1;
a.cc: In function 'int main()':
a.cc:19:58: error: 'INT_MIN' was not declared in this scope
   19 |     vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN));
      |                                                          ^~~~~~~
a.cc:19:58: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <unordered_set>
#include <set>
using namespace std;
int n, wei;
int main() {
    scanf("%d %d", &n, &wei);
    vector<int> w(n);
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &w[i], &v[i]);
    }
    vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int a = n; a >= 0; a--) {
            for(int b = 0; b <= 3 * n; b++) {
                if(dp[a][b] >= 0) {
                    int b2 = b+ w[i] - w[0];
                    dp[a + 1][b2] = max(dp[a][b] + v[i], dp[a + 1][b2]);
                }
            }
        }
    }
    int ans = INT_MIN;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= 3 *n; j++) {
            if(i * w[0] + j <= wei) {
                ans = max(ans, dp[i][j]);
            }
        }
    }
    printf("%d\n", ans);
    
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:58: error: 'INT_MIN' was not declared in this scope
   18 |     vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN));
      |                                                          ^~~~~~~
a.cc:9:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <set>
  +++ |+#include <climits>
    9 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int N, W, w1;
int values[4][101];

void Solve(int num[4]){
  int best = 0;
  int n[4];
  for(n[0]=0; n[0]<=num[0]; n[0]++){
	for(n[1]=0; n[1]<=num[1]; n[1]++){
	  for(n[2]=0; n[2]<=num[2]; n[2]++){
		for(n[3]=0; n[3]<=num[3]; n[3]++){
		  int weight = 0;
		  for( i=0; i<=3; i++){
			weight += n[i]*(w1+i);
		  }
		  if(weight > W){
			break;
		  }
		  int v_sum = 0;
		  for(int i=0; i<=3; i++){
			for(int j=0; j<n[i]; j++){
			  v_sum += values[i][j];
			}
		  }
		  if(v_sum > best){
			best = v_sum;
		  }
		}
	  }
	}
  }

  cout << best << endl;
}

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

  cin >> N >> W;
  int v;
  cin >> w1 >> v;
  
  int num[4];
  values[0][0] = v;
  num[0] = 1;

  for(int i=1; i<N; i++){
	int w;
	cin >> w >> v;
	values[w-w1][num[w-w1]++] = v;
  }

  for(int i=0; i<4; i++){
  	sort(values[i], values[i] + num[i], greater<int>());
  }

  // for(int i=0; i<4; i++){
  // 	for(int j=0; j<num[i]; j++)
  // 	  cout << values[i][j] << " ";
  // 	cout << endl;
  // }
  Solve(num);
  
  return 0;
}


Compiler output:
a.cc: In function 'void Solve(int*)':
a.cc:19:24: error: 'i' was not declared in this scope
   19 |                   for( i=0; i<=3; i++){
      |                        ^
Language: C++

#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
#include "map"
using namespace std;
const int maxn=;
map<long long,long long>dp;
int n,c;
int main()
{
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++){
		int v,w;
		scanf("%d%d",&w,&v);
		for(int j=c;j>=0;j--){
			if(j>=v)
				dp[j]=max(dp[j],dp[j-v]+w);
		}
		cout<<dp[c]<<endl;
	}
}

Compiler output:
a.cc:7:16: error: expected primary-expression before ';' token
    7 | const int maxn=;
      |                ^