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

#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll d[101][1000000005];
ll w[105];
ll v[105];

int main(){
    int n,W;
    cin >> n>>W;
    int l=0;
    rep(i,n){
        cin >> w[i]>>v[i];
        //l=(w[0]+3)*(i+2);
        if(i==0){
            rep(j,w[0]){
                d[0][j]=0;
            }
            reps(j,w[0],W){
                d[0][j]=v[0];
            }
        }else{
            rep(j,W+1){
                if(j-w[i]>=0){
                    d[i][j]=max(d[i-1][j],d[i-1][j-w[i]]+v[i]);
                }else{
                    d[i][j]=d[i-1][j];
                }
            }
        }
    }
    rep(i,n){
        rep(j,W){
            cerr<<d[i][j]<<' ';
        }
        cerr<<endl;
    }
    cout<<d[n-1][W]<<endl;
    return 0;
}

Compiler output:
/tmp/ccrsXajT.o: in function `main':
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0x7f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0xc3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0xcf): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0x12b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0x15b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccrsXajT.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrsXajT.o
collect2: error: ld returned 1 exit status
Language: C++

#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll d[101][1000000005];
ll w[105];
ll v[105];

int main(){
    int n,W;
    cin >> n>>W;
    int l=0;
    rep(i,n){
        cin >> w[i]>>v[i];
        //l=(w[0]+3)*(i+2);
        if(i==0){
            rep(j,w[0]){
                d[0][j]=0;
            }
            reps(j,w[0],W){
                d[0][j]=v[0];
            }
        }else{
            rep(j,W+1){
                if(j-w[i]>=0){
                    d[i][j]=max(d[i-1][j],d[i-1][j-w[i]]+v[i]);
                }else{
                    d[i][j]=d[i-1][j];
                }
            }
        }
    }
    rep(i,n){
        rep(j,W){
            cerr<<d[i][j]<<' ';
        }
        cerr<<endl;
    }
    cout<<d[n-1][W]<<endl;
    return 0;
}

Compiler output:
/tmp/ccd7C4UI.o: in function `main':
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0x7f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0xc3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0xcf): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0x12b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0x15b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccd7C4UI.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccd7C4UI.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n, w;
    cin >> n >> w;
    vector<vector<ll>> v(4);
    ll w1, v1;
    cin >> w1 >> v1;
    v[0].push_back(v1);
    rep(i, n-1){
        ll x, y;
        cin >> x >> y;
        v[x-w1].push_back(y);
    }
    rep(i, 4)sort(v[i].rbegin(),v[i].rend()));

    ll dp[4][101] = {};
    rep(i, 4)rep(j, v[i].size())dp[i][j+1] = dp[i][j] + v[i][j];
 
    int ans = 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 weight = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
        if(weight > w) continue;
        int res = dp[0][i] + dp[1][j] + dp[2][k] + dp[3][l];
        ans = max(ans,res);
    }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:45: error: expected ';' before ')' token
   28 |     rep(i, 4)sort(v[i].rbegin(),v[i].rend()));
      |                                             ^
      |                                             ;
Language: C++

#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

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

int main(int argc, char const *argv[])
{
    cin >> n >> W;
    for (ll i = 0; i < n; i++)
    {
        ll _w, _v;
        cin >> _w >> _v;
        w.push_back(_w);
        v.push_back(_v);
    }

    solve();
}

Compiler output:
/tmp/ccIrONfo.o: in function `solve()':
a.cc:(.text+0xc): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0xb3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x18e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccIrONfo.o
/tmp/ccIrONfo.o: in function `main':
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x1fe): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x249): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x25f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccIrONfo.o
a.cc:(.text+0x273): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

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

int main(int argc, char const *argv[])
{
    cin >> n >> W;
    for (ll i = 0; i < n; i++)
    {
        ll _w, _v;
        cin >> _w >> _v;
        w.push_back(_w);
        v.push_back(_v);
    }

    solve();
}

Compiler output:
/tmp/ccn3qSA8.o: in function `solve()':
a.cc:(.text+0xc): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0xb3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x18e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccn3qSA8.o
/tmp/ccn3qSA8.o: in function `main':
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x1fe): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x249): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x25f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccn3qSA8.o
a.cc:(.text+0x273): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<ll>())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  ll W;

  cin>>N>>W;

  ll w[N];
  ll v[N];


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

  vector<vector<ll>> se(4);

  rep(i,N){
    se[w[i]-w[0]].emplace_back(v[i]);
  }

  SORT(se[0]);
  SORT(se[1]);
  SORT(se[2]);
  SORT(se[3]);
a
  int ses[4];
  rep(i,4){
    ses[i]=se[i].size()+1;
  }

  ll ct=0;

  rep(i,ses[0]){
    rep(j,ses[1]){
      rep(k,ses[2]){
        rep(l,ses[3]){
          ll weight=0;
          ll value=0;

          rep(x1,i){
            weight+=w[0];
            value+=se[0][x1];
          }

          rep(x2,j){
            weight+=w[0]+1;
            value+=se[1][x2];
          }
          rep(x3,k){
            weight+=w[0]+2;
            value+=se[2][x3];
          }
          rep(x4,l){
            weight+=w[0]+3;
            value+=se[3][x4];
          }

          if(weight<=W){
            ct=max(ct,value);
          }

        }
      }
    }
  }

  cout<< ct<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Compiler output:
a.cc: In function 'void Main()':
a.cc:41:1: error: 'a' was not declared in this scope
   41 | a
      | ^
a.cc:44:5: error: 'ses' was not declared in this scope; did you mean 'se'?
   44 |     ses[i]=se[i].size()+1;
      |     ^~~
      |     se
a.cc:49:9: error: 'ses' was not declared in this scope; did you mean 'se'?
   49 |   rep(i,ses[0]){
      |         ^~~
a.cc:5:38: note: in definition of macro 'rep'
    5 | #define rep(i, n) for(int i = 0; i < n; i++)
      |                                      ^
Language: C++

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

vector<pair<int,int> > items;
int knapsack(int w)
{
    vector<int> dp(w+4,0);
    for(int i=0 ; i<items.size() ; ++i)
    {
        for(int j=w ; j>=items[i].first ; --j)
        {
            dp[j]=max(dp[j],dp[j-items[i].first]+items[i].second);
        }
    }
    return dp[w];
}
 
int main()
{
  	int n,w;
  	cin>>n>>w;
  	for(int i=0 ; i<n ; ++i)
    {
    	int x,y;
      	cin>>x>>y;
      	items.push_back({x,y});
    }
    cout<<knapsack(w,items)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:19: error: too many arguments to function 'int knapsack(int)'
   28 |     cout<<knapsack(w,items)<<endl;
      |           ~~~~~~~~^~~~~~~~~
a.cc:5:5: note: declared here
    5 | int knapsack(int w)
      |     ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>d;
int w[100],v[100],N,W;
int dp(int i,int j){
	pair<int,int> p=make_pair(i,j);
	if(d.count(p)) return d[p];
	long res;
	if(i==n)res=0;
	else if(j<w[i])res=dp(i+1,j);
	else res=max(dp(i+1,j),dp(i+1,j-w[i])+v[i]);
	return d[p]=res;
}
int main(){
	cin>>N>>W;
	for(int i=0;i<N;i++)cin>>w[i]>>v[i];
	cout<<dp(0,W)<<endl;
}


Compiler output:
a.cc: In function 'int dp(int, int)':
a.cc:9:15: error: 'n' was not declared in this scope
    9 |         if(i==n)res=0;
      |               ^
Language: C++

from collections import *

N,W=map(int,input().split())
d=defaultdict(int)
d[0]=0
for i in range(N):
    v,w=map(int,input().split())
    c=d.copy()
    for p,q in c.items():
        if p+w<=W:
            d[p+w]=max(d[p+w],q+v)
print(max(d.values()))

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import *
      | ^~~~
Language: C++

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
  int N,W;
  cin >> N >> W;
  vector<pair<int,int>> wv(N);
  for (int i=0; i<N; i++) {
    cin >> wv[i].first >> wv[i].second;
  }
  int smallw = wv[0].first;
  //cerr << smallw << endl;
  
  sort(wv.begin(),wv.end());
  
  /*for (int i=0; i<N; i++) {
    cerr << wv[i].first << " " << wv[i].second << endl;
  }*/
  
  int cc0 = 0;
  int cc1 = 0;
  int cc2 = 0;
  int cc3 = 0;
  for (int i=0; i<N; i++) {
    if (wv[i].first == smallw) {
      cc0++;
      continue;
    }
    if (wv[i].first == smallw+1) {
      cc1++;
      continue;
    }
    if (wv[i].first == smallw+2) {
      cc2++;
      continue;
    }
    cc3++;
  }
  
  vector<long> vv0(cc0+1,0);
  vector<long> vv1(cc1+1,0);
  vector<long> vv2(cc2+1,0);
  vector<long> vv3(cc3+1,0);
  for (int i=cc0-1; i>=0; i--) {
    vv0[cc0-i] = vv0[cc0-1-i] + wv[i].second;
    cerr << vv0[cc0-i] << ' ';
  }
  cerr << endl;
  for (int i=cc1-1; i>=0; i--) {
    vv1[cc1-i] = vv1[cc1-1-i] + wv[i+cc0].second;
    cerr << vv1[cc1-i] << ' ';
  }
  cerr << endl;
  for (int i=cc2-1; i>=0; i--) {
    vv2[cc2-i] = vv2[cc2-1-i] + wv[i+cc0+cc1].second;
    cerr << vv2[cc2-i] << ' ';
  }
  cerr << endl;
  for (int i=cc3-1; i>=0; i--) {
    vv3[cc3-i] = vv3[cc3-1-i] + wv[i+cc0+cc1+cc2].second;
    cerr << vv3[cc3-i] << ' ';
  }
  cerr << endl;
  long ans = 0;
  long term = 0;
  for(int i=0; i<cc0+1; i++) {
    for(int j=0; j<cc1+1; j++) {
      for(int k=0; k<cc2+1; k++) {
        for(int l=0; l<cc3+1; l++) {
          if ((i+j+k+l)*smallw+j+k*2+l*3 > W) {
            continue;
          }
          term = vv0[i] + vv1[j] + vv2[k] + vv3[l];
          ans = max(term,ans);
          term = 0;
        }
      }
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'cin' was not declared in this scope
    9 |   cin >> N >> W;
      |   ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <map>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:49:5: error: 'cerr' was not declared in this scope
   49 |     cerr << vv0[cc0-i] << ' ';
      |     ^~~~
a.cc:49:5: note: 'std::cerr' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:51:3: error: 'cerr' was not declared in this scope
   51 |   cerr << endl;
      |   ^~~~
a.cc:51:3: note: 'std::cerr' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:51:11: error: 'endl' was not declared in this scope
   51 |   cerr << endl;
      |           ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include <map>
  +++ |+#include <ostream>
    5 | using namespace std;
a.cc:83:3: error: 'cout' was not declared in this scope
   83 |   cout << ans << endl;
      |   ^~~~
a.cc:83:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

void Sort(int*, int*, int)

int main() {
  int n,w;
  cin >> n >> w;
  int a[n],b[n];
  for(int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  Sort(a,b,n);
  int sum = 0;
  for(int i=0;i<n;i++) {
    if(w >= a[i]) {
      w -= a[i];
      sum += b[i];
    }
  }
  cout << sum << endl;
}

void Sort(int* a, int* b, int size) {
  for(int i=0;i<size;i++) {
    for(int j=i+1;j<size;j++) {
      if(b[i]<b[j]) {
        int num1 = a[i];
        a[i] = a[j];
        a[j] = num1;

        int num2 = b[i];
        b[i] = b[j];
        b[j] = num2;
      }
    }
  }
}


Compiler output:
a.cc:6:1: error: expected initializer before 'int'
    6 | int main() {
      | ^~~
Language: C++

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

void Sort(int*, int*, int)

int main() {
  int n,w;
  cin >> n >> w;
  int a[n],b[n]
  for(int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  Sort(a,b,n);
  int sum = 0;
  for(int i=0;i<n;i++) {
    if(w >= a[i]) {
      w -= a[i];
      sum += b[i];
    }
  }
  cout << sum << endl;
}

void Sort(int* a, int* b, int size) {
  for(int i=0;i<size;i++) {
    for(int j=i+1;j<size;j++) {
      if(b[i]<b[j]) {
        int num1 = a[i];
        a[i] = a[j];
        a[j] = num1;

        int num2 = b[i];
        b[i] = b[j];
        b[j] = num2;
      }
    }
  }
}


Compiler output:
a.cc:6:1: error: expected initializer before 'int'
    6 | int main() {
      | ^~~
Language: C++

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

// 入力
int n, W;
int weight[1000000010], value[110];

// DPテーブル
int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

  // DP初期条件: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DPループ
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

  cout << dp[n][W] << endl;
}

Compiler output:
/tmp/cc9hKyX1.o: in function `main':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x127): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x168): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x17f): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x1c0): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x1ef): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
a.cc:(.text+0x267): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc9hKyX1.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const int INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    int n,w;
    cin>>n>>w;
    vector<LL> v[4];

    int w1;
    for(int i=0;i<n;++i){
        int w2,v;
        cin>>w2>>v;
        if(i==0)w1=w2;
        v[w2-w1].push_back(v);
    }
    for(int i=0;i<4;++i){
        sort(v[i].begin(),v[i].end());
        v[i].push_back(0);
        reverse(v[i].begin(),v[i].end());
        for(int j=1;j<v[i].size();++j){
            v[i][j]+=v[i][j-1];
        }
    }
    LL ans=0;
    for(int i=0;i<v[0].size();++i){
        for(int j=0;j<v[1].size();++j){
            for(int k=0;k<v[2].size();++k){
                for(int l=0;l<v[3].size();++l){
                    if(w>= (i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3))){
                        ans=max(ans,(v[0][i]+v[1][j]+v[2][k]+v[3][l]));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:10: error: invalid types 'int[int]' for array subscript
   36 |         v[w2-w1].push_back(v);
      |          ^
Language: C++

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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(int argc, const char * argv[]) {
  ll N, W;
  cin >> N >> W;
  vector<ll> v1, v2, v3, v4;
  
  ll w1 = 0;
  for (int i = 0; i < N; i++) {
    ll wi, vi;
    cin >> wi >> vi;
    if (i == 0) {
      w1 = wi;
    }
    if (wi == w1 + 0) {
      v1.push_back(vi);
    }
    if (wi == w1 + 1) {
      v2.push_back(vi);
    }
    if (wi == w1 + 2) {
      v3.push_back(vi);
    }
    if (wi == w1 + 3) {
      v4.push_back(vi);
    }
  }
  sort(v1.begin(), v1.end(), greater<ll>());
  sort(v2.begin(), v2.end(), greater<ll>());
  sort(v3.begin(), v3.end(), greater<ll>());
  sort(v4.begin(), v4.end(), greater<ll>());
  
  int l1, l2, l3, l4;
  l1 = v1.size();
  l2 = v2.size();
  l3 = v3.size();
  l4 = v4.size();
  
  ll a1[l1 + 1];
  ll a2[l2 + 1];
  ll a3[l3 + 1];
  ll a4[l4 + 1];
  memset(a1, 0, sizeof(a1));
  memset(a2, 0, sizeof(a2));
  memset(a3, 0, sizeof(a3));
  memset(a4, 0, sizeof(a4));
  a1[1] = (l1 > 0) ? v1[0] : 0;
  a2[1] = (l2 > 0) ? v2[0] : 0;
  a3[1] = (l3 > 0) ? v3[0] : 0;
  a4[1] = (l4 > 0) ? v4[0] : 0;
  for (int i = 2; i < l1 + 1; i++) {
    a1[i] += (v1[i - 1] + a1[i - 1]);
  }
  for (int i = 2; i < l2 + 1; i++) {
    a2[i] += (v2[i - 1] + a2[i - 1]);
  }
  for (int i = 2; i < l3 + 1; i++) {
    a3[i] += (v3[i - 1] + a3[i - 1]);
  }
  for (int i = 2; i < l4 + 1; i++) {
    a4[i] += (v4[i - 1] + a4[i - 1]);
  }

  ll maxv= 0;
  for (int i1 = 0; i1 < l1 + 1; i1++) {
    for (int i2 = 0; i2 < l2 + 1; i2++) {
      for (int i3 = 0; i3 < l3 + 1; i3++) {
        for (int i4 = 0; i4 < l4 + 1; i4++) {
          ll w = w1 * i1 + (w1 + 1) * i2 + (w1 + 2) * i3 + (w1 + 3) * i4;
          if (w > W) {
            continue;
          }
          ll v = a1[i1] + a2[i2] + a3[i3] + a4[i4];
          maxv = max(maxv, v);
        }
      }
    }
  }

  cout << maxv << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:51:3: error: 'memset' was not declared in this scope
   51 |   memset(a1, 0, sizeof(a1));
      |   ^~~~~~
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++

#include<bits/stdc++.h>
using namespace std;
int n,m,a[111],b[111],f[111][111][310];
int main()
{
	
	cin>>n>>m;
	for (int i=0;i<n;i++)
	 cin>>a[i]>>b[i];
	for (int i=0;i<n;i++)
	 for (int j=0;j<=i;j++)
	  for (int k=0;k<=3*j;k++)
	  {
	  	f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]);
	  	f[i+1][j+1][k+a[i]-a[0]]=max(f[i+1][j+1][k+a[i]-a[0]],f[i][j][k]+b[i]);
	  }
	int ans=0;
	for (int i=0;i<=n;i++)
	 for (int j=0;j<=3*i;j++)
	 {
	 	long long W=(long long)a[0]*i+j;
	 	if (W<=m) ans=max(ans,f[n][i][j]);
	 }
	cout<<ans;
	return 0;
}
}

Compiler output:
a.cc:27:1: error: expected declaration before '}' token
   27 | }
      | ^
Language: C++

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	
	int n, w;
	cin >> n >> w;
	vector<vector<int>> a(4);
	int sw;
	for(int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if(i == 0) sw = x;
		a[x -sw].push_back(y);
	}
	for(int i = 0; i < 4; i++) {
		sort(a[i].rbegin(), a[i].rend());
	}
	long long ans = 0;
	for(int i = 0; i <= a[0].size(); i++) {
		for(int j = 0; j <= a[1].size(); j++) {
			for(int k = 0; k <= a[2].size(); k++) {
				for(int l = 0; l <= a[3].size(); l++) {
					long long val = 0;
					long long ww = 1LL * i * sw + 1LL * j * (ws + 1) + 1LL * k * (ws + 2) + 1LL * l * (ws + 3);
					if(ww > w) continue;
					for(int m = 0; m < i; m++) {
						val += a[0][m];
					}
					for(int m = 0; m < j; m++) {
						val += a[1][m];
					}
					for(int m = 0; m < k; m++) {
						val += a[2][m];
					}
					for(int m = 0; m < l; m++) {
						val += a[3][m];
					}
					ans = max(val, ans);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:85: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   27 |                                         long long ww = 1LL * i * sw + 1LL * j * (ws + 1) + 1LL * k * (ws + 2) + 1LL * l * (ws + 3);
      |                                                                                  ~~~^~~
a.cc:27:106: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   27 |                                         long long ww = 1LL * i * sw + 1LL * j * (ws + 1) + 1LL * k * (ws + 2) + 1LL * l * (ws + 3);
      |                                                                                                       ~~~^~~
a.cc:27:127: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   27 |                                         long long ww = 1LL * i * sw + 1LL * j * (ws + 1) + 1LL * k * (ws + 2) + 1LL * l * (ws + 3);
      |                                                                                                                            ~~~^~~
Language: Java

import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for(int i = 0; i < N; i++){
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        int[][] dp = new int[W+1][N];

        Arrays.fill(dp[0], 0);
        for(int j = 1; j < W; j++){
            dp[j][0] = (w[0] > j) ? 0 : v[0];
        }
        dp[0][0] = (w[0] > 1)? 0 : v[0];
        for(int i = 1; i < W+1; i++){
            for(int j = 1; j < N; j++){
                long x = (i-w[j] >= 0) ? dp[i-w[j]][j-1] + v[j] : dp[0][j-1];
                dp[i][j] = Math.max(dp[i][j-1], x);
            }
        }
        System.out.println(dp[W][N-1]);
    }
}

Compiler output:
Main.java:27: error: incompatible types: possible lossy conversion from long to int
                dp[i][j] = Math.max(dp[i][j-1], x);
                                   ^
1 error
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i == 0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*
#include <limits.a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int N,W,w[100],v[100];
int dp[101][400][101];
int main() {
	cin>>N>>W;
	rep(i,n)cin>>w[i]>>v[i];
	for(int i=1;i<n;i++){
		for(int j=0;j<=300;j++){
			for(int k=0;k<n;k++){
				//あーあーあーあーあーあーあーあーあーあーあーあーあー
			}
		}
	}
	return 0;
}


Compiler output:
a.cc:35:24: error: missing terminating > character
   35 | #include <limits.a%MOD;
      |                        ^
a.cc:35:10: fatal error: limits.a%1000000007;: No such file or directory
   35 | #include <limits.a%MOD;
      |          ^
compilation terminated.
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 575;

// dp[見てるとこ][重さ]
ll dp[MAX_N][MAX_N * MAX_Nx];

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

  CIN(N, W);
  vector< ll > w(N);
  vector< ll > v(N);
  REP(i, N) {
    cin >> w[i] >> v[i];
  }
  vector< ll > diff_w(N);
  REP(i, N) {
    diff_w[i] = w[i] - w[0];
  }

  ll sm = 0;
  // 見ているとこ
  REP(i, N) {
    RREP(j, N) {
      if (j > i) {
	// iまでで作るので
	continue;
      }
      RREP(k, sm + 1) {
	dp[j + 1][k + diff_w[i]] = max(dp[j + 1][k + diff_w[i]],
				       dp[j][k] + v[i]);
      }
    }
    sm += diff_w[i];
  }

  ll ans = 0ll;
  REP(i, N + 1) {
    REP(j, 3 * N) {
      if (w[0] * i + j > W) {
	// 重さがWを超えた時には入れない
	continue;
      }
      debug(dp[i][j]);
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
  
  return 0;
}



Compiler output:
a.cc:29:22: error: 'MAX_Nx' was not declared in this scope; did you mean 'MAX_N'?
   29 | ll dp[MAX_N][MAX_N * MAX_Nx];
      |                      ^~~~~~
      |                      MAX_N
a.cc: In function 'int main()':
a.cc:56:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   56 |         dp[j + 1][k + diff_w[i]] = max(dp[j + 1][k + diff_w[i]],
      |         ^~
      |         dup
a.cc:70:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
   70 |       debug(dp[i][j]);
      |             ^~
a.cc:11:39: note: in definition of macro 'debug'
   11 | #define debug(x) cerr << #x << ":" << x << endl;
      |                                       ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, W, v, w;
	cin >> n >> W;
	int *dp = new int[W+2];
	memset(dp, 0, sizeof(int)*(W+2));

	while(n--){
		cin >> w >> v;
		for (int i = W; i >= w; --i) {
			if(i >= w) dp[i] = max(dp[i - w] + v, dp[i]);
			else dp[i] = dp[i-1];
		}
	}
	cout << dp[W];
	delete[] dp;
}

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

#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {

	memset(dp, 0, sizeof(int)*(W+2));

}

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

#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
	memset(dp, 0, sizeof(int)*(W+2));

}

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

#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
	int n, W, v, w;
	scanf("%d %d", &n, &W);
	int *dp = new int[W+2];
	memset(dp, 0, sizeof(int)*(W+2));

	while(n--){
		scanf("%d %d", &w, &v);
		for (int i = W; i >= w; --i) {
			if(i >= w) dp[i] = max(dp[i - w] + v, dp[i]);
			else dp[i] = dp[i-1];
		}
	}
	printf("%d\n", dp[W]);
	delete[] dp;
}

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

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

using namespace std;

long long N, W;
long long nap(long long, long long, vector <long long>, vector <long long>, vector <vector <long long> >&);

int main(){
    cin>>N>>W;
    vector <long long>w(N);
    vector <long long>v(N);
    vector <vector <long long> >dp(N+1, vector <long long>(W+1, -1));
    for(int i = 0 ; i < N ; i++){
        cin>>w[i]>>v[i];
    }
    
    cout<<nap(0, W, w, v, dp)<<endl;

    return 0;
}

long long nap(long long i, long long j, vector <long long>w, vector <long long>v,  vector <vector <long long> >&dp) {
    if (dp[i][j] != -1) return dp[i][j];
    long long ans = 0;
    if (i == N) ans = 0;
    else if (j < w[i]) {
        ans = nap(i + 1, j, w, v, dp);
    } else {
        ans = max(nap(i + 1, j, w, v, dp), (nap(i + 1, j - w[i], w, v, dp) + v[i]));
    }
    dp[i][j] = ans
    return ans;
}

Compiler output:
a.cc: In function 'long long int nap(long long int, long long int, std::vector<long long int>, std::vector<long long int>, std::vector<std::vector<long long int> >&)':
a.cc:33:19: error: expected ';' before 'return'
   33 |     dp[i][j] = ans
      |                   ^
      |                   ;
   34 |     return ans;
      |     ~~~~~~         
a.cc:33:14: warning: control reaches end of non-void function [-Wreturn-type]
   33 |     dp[i][j] = ans
Language: C++

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

int main(){

    long long N, W; cin >> N >> W;
    vector<long long> w(N);
    vector<long long> v(N);
    for(long long i = 0; i < N; i++) cin >> w[i] >> v[i];
    vector<long long> a(1, 0LL);
    vector<long long> b(1, 0LL);    
    vector<long long> c(1, 0LL);    
    vector<long long> d(1, 0LL);
    a.push_back(v[0]);
    for(long long i = 1; i < N; i++){
        if(w[i] == w[0]) a.push_back(v[i]);
        else if(w[i] == w[0] + 1LL) b.push_back(v[i]);
        else if(w[i] == w[0] + 2LL) c.push_back(v[i]);
        else d.push_back(v[i]);
    }

    sort(a.begin() + 1, a.end(), greater<long long>);
    sort(b.begin() + 1, b.end(), greater<long long>);
    sort(c.begin() + 1, c.end(), greater<long long>);
    sort(d.begin() + 1, d.end(), greater<long long>);

    
    

    for(long long i = 1; i < (long long)a.size(); i++) a[i] += a[i - 1];
    for(long long i = 1; i < (long long)b.size(); i++) b[i] += b[i - 1];
    for(long long i = 1; i < (long long)c.size(); i++) c[i] += c[i - 1];
    for(long long i = 1; i < (long long)d.size(); i++) d[i] += d[i - 1];
    

    long long ans = 0LL;
    //全探索
    for(long long i = 0; i < (long long)a.size(); i++){
        for(long long j = 0; j < (long long)b.size(); j++){
            for(long long k = 0; k < (long long)c.size(); k++){
                for(long long l = 0; l < (long long)d.size(); l++){
                    long long tmp_w = i * w[0] + j * (w[0] + 1LL) + k * (w[0] + 2LL) + l * (w[0] + 3LL);
                    //cout << i << " " << j << " " << k << " " << l << endl;                    

                    if(tmp_w > W) continue;
                    long long tmp_v = a[i] + b[j] + c[k] + d[l];

                    ans = max(ans, tmp_v);
                    //cout << i << " " << j << " " << k << " " << l << " " << tmp_w << " " << tmp_v << endl;
                }
            }
        }
    }
    
    cout << ans << endl;    
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:52: error: expected primary-expression before ')' token
   22 |     sort(a.begin() + 1, a.end(), greater<long long>);
      |                                                    ^
a.cc:23:52: error: expected primary-expression before ')' token
   23 |     sort(b.begin() + 1, b.end(), greater<long long>);
      |                                                    ^
a.cc:24:52: error: expected primary-expression before ')' token
   24 |     sort(c.begin() + 1, c.end(), greater<long long>);
      |                                                    ^
a.cc:25:52: error: expected primary-expression before ')' token
   25 |     sort(d.begin() + 1, d.end(), greater<long long>);
      |                                                    ^
Language: C++

#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
const int MAXN=110;
const int N=400;
int f[MAXN][MAXN][N*2+10],w[MAXN],v[MAXN];
int main()
{
	int n,W;
	scanf("%d%d",&n,&W);
/*	for (int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]);
	memset(f,-1,sizeof(f));
	f[0][0][0]=0;
	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++)
			for (int k=0;k<=3*j;k++)
			{
				if (f[i][j][k]==-1) continue;
				f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]);
				f[i+1][j+1][k+w[i+1]-w[1]]=max(f[i+1][j+1][k+w[i+1]-w[1]],f[i][j][k]+v[i+1]);
			}*/
	for (int i=0;i<n;i++)
		scanf("%d%d",&w[i],&v[i]);

	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++)
			for (int k=0;k<=3*j;k++)
			{
				if (f[i][j][k]==-1) continue;
				f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]);
				f[i+1][j+1][k+w[i]-w[0]]=max(f[i+1][j+1][k+w[i]-w[0]],f[i][j][k]+v[i]);
	int ans=0;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=3*i;j++)
		{
			ll k=i*w[0]+j;
			if (k<=W)
				ans=max(ans,f[n][i][j]);	
		}
	cout<<ans;
	return 0;
}


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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int a[105],b[105];
LL f[105][305];
int main(void)
{
	int i,j,k,n,m,a1;LL ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]);
	a1=a[1];
	for(i=1;i<=n;++i)a[i]-=a1;
	for(i=0;i<=n;++i)
	{
		for(j=0;j<=300;++j)f[i][j]=-0x3F3F3F3F3F3F3F3F;
	}
	f[0][0]=0;
	for(i=1;i<=n;++i)
	{
		for(j=i;j>=1;--j)
		{
			for(k=300;k>=a[i];--k)f[j][k]=max(f[j][k],f[j-1][k-a[i]]+b[i]);
		}
	}
	for(i=1;i<=n;++i)
	{
		if(m-1LL*i*a1<0)break;
		for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]);
	}
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:31: error: no matching function for call to 'min(int, long long int)'
   31 |                 for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]);
      |                            ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:31:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |                 for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]);
      |                            ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |                 for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]);
      |                            ~~~^~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[100][1000000000];
int w[1000000000],v[10000000];

int main(){
  int n,W;
  cin>>n>>W;
  for(int i=0;i<n;++i) cin>>w[i]>>v[i];

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



Compiler output:
/tmp/ccy80oWN.o: in function `main':
a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccy80oWN.o
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccy80oWN.o
a.cc:(.text+0xbe): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccy80oWN.o
a.cc:(.text+0x116): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccy80oWN.o
a.cc:(.text+0x157): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccy80oWN.o
collect2: error: ld returned 1 exit status
Language: C++

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

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

void f(int a,int b,int c,int d,int ans){
    ans = max(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]);
    if(a==0 && b==0 && c==0){
        printf("%d\n",ans);
        return;
    }
    if(d==0){

    }
}

int main(){
    
    scanf("%d%d",&N,&W);
    for(int i=0;i<4;i++){
        v[i].push_back(0);
    }
    for(int i=0,x,y;i<N;i++){
        scanf("%d%d",&x,&y);
        if(i==0)w1 = x;
        v[x-w1].push_back(y);
    }
    for(int i=0;i<4;i++){
        sort(v[i].begin(),v[i].end());
        reverse(v[i].begin()+1,v[i].end());
        for(int j=1;j<v[i].size();j++){
            v[i][j] += v[i][j-1];
        }
    }

    int ans = 0;
    for(int i=0;i<v[0].size();i++){
        for(int j=0;j<v[1].size();j++){
            for(int k=0;k<v[2].size();k++){
                for(int l=0;l<v[3].size();l++){
                    if(w1*(i+j+k+l)+j+2*k+3*l <= W){
                        ans = max(ans, v[0][i]+v[1][j]+v[2][k]+v[3][l]);
                    }
                }
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}


Compiler output:
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<int> v[4];
      | ^~~~~~
a.cc: In function 'void f(int, int, int, int, int)':
a.cc:10:20: error: 'v' was not declared in this scope
   10 |     ans = max(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]);
      |                    ^
a.cc: In function 'int main()':
a.cc:24:9: error: 'v' was not declared in this scope
   24 |         v[i].push_back(0);
      |         ^
a.cc:29:9: error: 'v' was not declared in this scope
   29 |         v[x-w1].push_back(y);
      |         ^
a.cc:32:14: error: 'v' was not declared in this scope
   32 |         sort(v[i].begin(),v[i].end());
      |              ^
a.cc:40:19: error: 'v' was not declared in this scope
   40 |     for(int i=0;i<v[0].size();i++){
      |                   ^