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

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;

typedef unsigned long long ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN = 110;
const int MAXW = 1e5 + 5;
const int MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

int add(int x, int y) { return ((x % MOD)  + (y % MOD)) % MOD;             }
int mul(int x, int y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;   }
int sub(int x, int y) { return add(x, -y + MOD);                           }

ll n, W, w[MAXN], v[MAXN], dp[MAXV];
bool vis[MAXN];

ll dp[MAXN][MAXV];

ll solve(ll x, ll curW) {
	if(curW > W) return -INF;
	if(x == 0) return 0;
	return max(v[x] + solve(x - 1, curW + w[x]), solve(x - 1, curW));
}


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

	cin >> n >> W;

	memset(vis, false, sizeof(vis));

	for(int i = 1 ; i <= n ; ++i) {
		cin >> w[i] >> v[i];
	}

	cout << solve(n, 0) << endl;



	return 0;
}




Compiler output:
a.cc:30:31: error: 'MAXV' was not declared in this scope; did you mean 'MAXW'?
   30 | ll n, W, w[MAXN], v[MAXN], dp[MAXV];
      |                               ^~~~
      |                               MAXW
a.cc:33:13: error: 'MAXV' was not declared in this scope; did you mean 'MAXW'?
   33 | ll dp[MAXN][MAXV];
      |             ^~~~
      |             MAXW
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 100+7;
const int W = 1e5+7;

ll mem[N][W];
ll w[N],v[N];
int n,maxw;

ll dp(int i,int sumw)
{
    ll &ret = mem[i][sumw];
  	if (ret ! -1) return ret;
  	if (i == n) return ret = 0;
  	ret = dp(i+1,sumw);
  	if (sumw+w[i] <= maxw) ret = max(ret,dp(i+1,sumw+w[i])+v[i]);
  	return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

	memset(mem,-1,sizeof mem);
  	cin >> n >> maxw;
  	REP(i,0,n-1) cin >> w[i] >> v[i];
	cout << dp(0,0) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'll dp(int, int)':
a.cc:28:16: error: expected ')' before '!' token
   28 |         if (ret ! -1) return ret;
      |            ~   ^~
      |                )
Language: Java


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

public class Main {

	public static void main(String[] args) {

		new SaikiMain2().solve();

	}

	private long getValue(int currentI, int currentWeight) {
		if (arrayMemo[currentI][currentWeight] != Integer.MIN_VALUE) {
			return arrayMemo[currentI][currentWeight];
		}
		long res = 0;
		if (currentI >= itemNum) {
			res = 0;
		} else if (currentWeight < arrayItem[currentI][0]) {
			res = getValue(currentI + 1, currentWeight);
		} else {
			res = Math.max(
					getValue(currentI + 1, currentWeight - (int) arrayItem[currentI][0]) + arrayItem[currentI][1],
					getValue(currentI + 1, currentWeight));
		}
		arrayMemo[currentI][currentWeight] = res;
		return res;
	}

	private long[][] arrayItem;
	private long[][] arrayMemo;
	private int itemNum = 0;
	private int weightTotalNum = 0;

	private void solve() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			itemNum = scanner.nextInt();
			weightTotalNum = scanner.nextInt();

			arrayItem = new long[itemNum][2];
			arrayMemo = new long[itemNum + 1][weightTotalNum + 1];
			for (int i = 0; i < arrayItem.length; i++) {
				arrayItem[i][0] = scanner.nextInt();
				arrayItem[i][1] = scanner.nextInt();
			}

			for (int i = 0; i < arrayMemo.length; i++) {
				Arrays.fill(arrayMemo[i], Integer.MIN_VALUE);
			}

			System.out.println(getValue(0, weightTotalNum));
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Compiler output:
Main.java:9: error: cannot find symbol
		new SaikiMain2().solve();
		    ^
  symbol:   class SaikiMain2
  location: class Main
1 error
Language: C++

#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, w;
    cin >> n >> w;
    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    ll dp[110][100100] = {0};

    rep(i, n) {
        rep(j, w + 1) {
            if (j - w[i] >= 0) chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:16: error: conflicting declaration 'std::vector<long long int> w'
   20 |     vector<ll> w(n), v(n);
      |                ^
a.cc:18:11: note: previous declaration as 'll w'
   18 |     ll n, w;
      |           ^
a.cc:21:23: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   21 |     rep(i, n) cin >> w[i] >> v[i];
      |                       ^
a.cc:26:22: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   26 |             if (j - w[i] >= 0) chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
      |                      ^
a.cc:26:61: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   26 |             if (j - w[i] >= 0) chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
      |                                                             ^
Language: C++

#include <iostream>
#include<algorithm>
using namespace std;
const  int MAX_N = 100;
 int N, W;
　int w[MAX_N], v[MAX_N];

int rec( int i, int j)
{
    int res;
    if (i == N)
    {
        //もう品物はない
        res = 0;
    }
    else if (j < w[i])
    {
        //この品物は入らない
        res = rec(i + 1, j);
    }
    else
    {
        res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
    }
    return res;
}
void solve()
{
    cout << rec(0, W) << endl;
}
int main()
{
    cin >> N; cin >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> w[i];
        cin >> v[i];
    }
    solve();
}


Compiler output:
a.cc:6:1: error: extended character 　 is not valid in an identifier
    6 | 　int w[MAX_N], v[MAX_N];
      | ^
a.cc:6:1: error: '\U00003000int' does not name a type
    6 | 　int w[MAX_N], v[MAX_N];
      | ^~~~~
a.cc: In function 'int rec(int, int)':
a.cc:16:18: error: 'w' was not declared in this scope
   16 |     else if (j < w[i])
      |                  ^
a.cc:23:57: error: 'v' was not declared in this scope
   23 |         res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
      |                                                         ^
a.cc: In function 'int main()':
a.cc:36:16: error: 'w' was not declared in this scope
   36 |         cin >> w[i];
      |                ^
a.cc:37:16: error: 'v' was not declared in this scope
   37 |         cin >> v[i];
      |                ^
Language: C++

    #include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    int backtrack(int,int);
    int M = 1000000007;
    std::map< pair<int,int> , ll> mpp;
    int n,w;
    std::vector< pair<int,int> > v;
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n>>w;
        fr(i,n)
        {
            int a,b;
            cin>>a>>b;
            v.pb(mp(a,b));
        }
        cout<<backtrack(0,w)<<endl;
        return 0; 
    }

    ll backtrack(int j,int we)
    {
        if(we<=0)
            return 0;
        else
            if(j>n-1)
                return 0;
            if(mpp.find(mp(j,we)) != mpp.end())
                return mpp[mp(j,we)];
            else
            if(v[j].f > we)
                return mpp[mp(j,we)]=backtrack(j+1,we);
            else
                return mpp[mp(j,we)]=max(backtrack(j+1,we),v[j].s + backtrack(j+1,we-v[j].f));
    }

Compiler output:
a.cc:38:8: error: ambiguating new declaration of 'long long int backtrack(int, int)'
   38 |     ll backtrack(int j,int we)
      |        ^~~~~~~~~
a.cc:18:9: note: old declaration 'int backtrack(int, int)'
   18 |     int backtrack(int,int);
      |         ^~~~~~~~~
Language: C++

/*
For the brave souls who are here: You are the chosen ones, the valiant 
knights of coding who toil away, without rest, fixing my most awful 
code. To you, true saviors, kings of men, I say this: 
never gonna give you up, never gonna let you down,
never gonna run around and desert you. Never gonna make you cry,
never gonna say goodbye. Never gonna tell a lie and hurt you.
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <unordered_map>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n, w;
    int wt[n + 1], val[n + 1], dp[MAX1];
    cin >> n >> w;
    REP(i, n){
        cin >> wt[i] >> val[i];
    }
    REP(i, n){
        REP(j, w + 1){
            dp[j] = max(dp[j], val[i] + dp[j - wt[i]);
                                           }
                                           }
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:92:53: error: expected ']' before ')' token
   92 |             dp[j] = max(dp[j], val[i] + dp[j - wt[i]);
      |                                                     ^
      |                                                     ]
Language: Java

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

public class Knapsack {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int w = s.nextInt();
		
		int[] values = new int[n];
		int[] weights = new int[n];
		
		for(int i = 0; i < n; i++) {
			weights[i] = s.nextInt();
			values[i] = s.nextInt();
		}
		
		int[][] knapsack = new int[n + 1][w + 1];

		for(int r = 1; r < knapsack.length; r++) {
			for(int c = 1; c < knapsack[0].length; c++) {
				int ifChosen = c < weights[r - 1] ? 0 : values[r - 1] + knapsack[r-1][c - weights[r - 1]];
				knapsack[r][c] = Math.max(knapsack[r - 1][c], ifChosen);
//				System.out.println(" hello " );
			}
		}
		System.out.println(knapsack[knapsack.length - 1][knapsack[0].length - 1]);
	}
}


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

#include <bits\stdc++.h>
using namespace std;
long long K[102][200002];
int main()
{
	int N, E;
	cin>>N>>E;
//	int x; 
//	scanf("%d", &x);
//	long long K[N][E+1];
	for(int i = 0; i <= N; i++)
		for(int j = 0; j <= E; ++j)
			K[i][j] = -1;
			
	K[0][0] = 0;
	long long out = 0;

	for(int i = 1; i <= N; i++)
	{
		int r, e;
		cin>>e>>r;
		for(int j = 0; j <= E; j++)
		{
			
			K[i][j] = K[i-1][j];
		//	cout<<K[i][j];
			if(j - e >= 0 && K[i-1][j-e] >= 0) K[i][j] = max(K[i][j], K[i - 1][j - e] + r);
			out = max(out, K[i][j]);
		}
	}
	cout<<out;
}

Compiler output:
a.cc: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;

int n,make,weight_and_profit[105][2];
long long int saved[105][100005];

long long int maxi_pro(int pos,int w){
    if(pos==n+1)
        return 0;

    if(saved[pos][w]!=-1)
       return saved[pos][w];

    long long int ans=0;

    if(w+weight_and_profit[pos][0]<=make){
        ans=weight_and_profit[pos][1]+maxi_pro(pos+1,w+weight_and_profit[pos][0]);
    }
    ans=max(ans,maxi_pro(pos+1,w));
    saved[pos][w]=ans;
    return ans;
}


int main(){
    int i,j;

    for(i=0;i<105;i++){
        memset(saved[i],-1,sizeof(saved[i]));
    }

    cin>>n>>make;

    for(i=1;i<=n;i++){
        scanf("%d %d",&weight_and_profit[i][0],&weight_and_profit[i][1]);
    }

    cout<<maxi_pro(1,0)<<endl;



    return 0;
}


Compiler output:
a.cc:1:9: 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;

int main()
{
    long long  n,w[101],v[101],i,M,f[101][101],j;
    cin>>n>>M;
    for(i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    long long f[n+1][M+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=M;j++)
        {
            f[i][j]=0;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=M;j++)
        {
            if(j<w[i])
            f[i][j]=f[i-1][j];
            else
            f[i][j]=max(f[i-1][j-w[i]]+v[i],f[i-1][j]);
        }
    }
    cout<<f[n][M];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: conflicting declaration 'long long int f [(n + 1)][(M + 1)]'
   11 |     long long f[n+1][M+1];
      |               ^
a.cc:7:36: note: previous declaration as 'long long int f [101][101]'
    7 |     long long  n,w[101],v[101],i,M,f[101][101],j;
      |                                    ^
Language: C++

#include <bits/stdc++.h>
#define int long long

using namespace std;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n,W,w,v;
    cin>>n>>W;
    int dp[W+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        cin>>w>>v;
        for(int j=W;j>=w;j--)
            dp[j] = max(dp[j],dp[j-w]+v);
    }
    cout<<dp[W];
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

long long a[100001],b[100001],c[100001][100001],n,m,i,j;
int main()
{
    cin>>n>>m;
    memset(c,0,sizeof(c));
    for (i=1; i<=n;i++) cin>>a[i]>>b[i];
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
            {
                c[i][j] = c[i - 1][j];
                if ((j>=a[i])&&(c[i][j]<(c[i - 1][j - a[i]]+b[i])))
                    c[i][j] = (c[i - 1][j - a[i]] + b[i]);
            }
    cout<<c[n][m]<<endl;
    return 0;
}


Compiler output:
/tmp/cclgLlRb.o: in function `main':
a.cc:(.text+0x7): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0x63): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0xc0): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0xce): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclgLlRb.o
a.cc:(.text+0xea): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define str string
#define vl vector<ll>
#define vs vector<string>

#define mapll map<ll,ll>
#define mapss map<string,string>
#define mapsl map<string,ll>
#define mapls map<ll,string>

#define pll pair<ll,ll>
#define pss pair<string,string>
#define psl pair<ll,string>
#define pls pair<string,ll>

#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll> ,greater<ll>>

#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
const ll mod=1e9 + 7;


ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}
ll dp[101][100000];
ll arr[100][2];
ll n,w;
ll finalans;
ll dpfunc(ll index,ll weight)
{
    //cout<<ans<<" "<<index<<endl;
    if(index==-1)
    {
        return 0;
    }
    else
    {
        if(dp[index][weight]!=0)
        {
            return dp[index][weight];
        }
        if(weight<arr[index][0])
            dp[index][weight]=dpfunc(index-1,weight);
        else
        {
            dp[index][weight]=max(dpfunc(index-1,weight),arr[index][1]+dpfunc(index-1,weight-arr[index][0]));
        }
        return dp[index][weight];
    }
}
signed main() 
{
    fast_cin();
    cin>>n>>w;
    finalans=0;
    For(i,0,n)
    {
        cin>>arr[i][0]>>arr[i][1];
    }
    memset(dp,-1,sizeof(dp));
    cout<<dpfunc(n,0,w)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:99:17: error: too many arguments to function 'long long int dpfunc(long long int, long long int)'
   99 |     cout<<dpfunc(n,0,w)<<endl;
      |           ~~~~~~^~~~~~~
a.cc:67:4: note: declared here
   67 | ll dpfunc(ll index,ll weight)
      |    ^~~~~~
Language: C++

#include <bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define int ll

using namespace std;

typedef long long ll;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	vector<pair<int, int> > items;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		if(a > w)	continue;
		items.PB({a,b});
	}

	int dp[w+1];
	dp[0] = 0;
	for(int i = 1; i <= w; i++){
		dp[i] = INT_MIN;
	}

	for(int i = 0; i < n; i++){
		for(int j = w; j >= items[i].F; j--){
			if(dp[j-items[i].F] == INT_MIN)	continue;
			dp[j] = max(dp[j], items[i].S + dp[j-items[i].F]);
		}
	}

	int mmax = -1;
	for(int i = 0; i <= w; i++){
		mmax = max(mmax, dp[i]);
	}

	cout << mmax << "\n";

	return 0;
}

Compiler output:
a.cc:6:13: error: '::main' must return 'int'
    6 | #define int ll
      |             ^~
a.cc:12:1: note: in expansion of macro 'int'
   12 | int main(){
      | ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int d[100010] = { };

int main(){
	int n, W;
	cin >> n >> W;
	ll w[n], v[n];
	REP(i, n) cin >> w[i] >> v[i];
	FOR(i, 1, W+1) d[i] = -1;
	REP(i, n){
		for(int j = W; j >= w[i]; j--){
			if(d[j-w[i]] >= 0) d[j] = max(d[j], d[j-w[i]]+v[i]);
		}
	}
	FOR(i, 1, W+1) d[i] = max(d[i], d[i-1]);
	cout << d[W] << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:25:54: error: no matching function for call to 'max(int&, long long int)'
   25 |                         if(d[j-w[i]] >= 0) d[j] = max(d[j], d[j-w[i]]+v[i]);
      |                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:25:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |                         if(d[j-w[i]] >= 0) d[j] = max(d[j], d[j-w[i]]+v[i]);
      |                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:25:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |                         if(d[j-w[i]] >= 0) d[j] = max(d[j], d[j-w[i]]+v[i]);
      |                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

<?php
$w = [];
$v = [];
fscanf(STDIN, "%d %d", $N, $W);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $w[$i], $v[$i]);
}
 
$current = new SplFixedArray($W+1);
$next = new SplFixedArray($W+1);
 
for ($j=0; $j <= $W; $j++) {
    $current[$j] = 0;
}
 
for ($i = 0; $i < $N; $i++) {
    for ($j = 0; $j <= $W; $j++) {
        if ($j >= $w[$i]) {
            $next[$j] = max($current[$j-$w[$i]] + $v[$i], $current[$j]);
        } else {
            $next[$j] = $current[$j];
        }
    }
    for ($j = 0; $j <= $W; $j++) {
        $current[$j] = $next[$j];
      $next[$j] = 0;
    }
}
 
$result = 0;
foreach ($current as $v) {
    if ($v >= $result) {
        $result = $v;
    }
}
echo $result."\n";

Compiler output:
a.cc:1:1: error: expected unqualified-id before '<' token
    1 | <?php
      | ^
a.cc:3:1: error: '$v' does not name a type
    3 | $v = [];
      | ^~
a.cc:4:7: error: expected constructor, destructor, or type conversion before '(' token
    4 | fscanf(STDIN, "%d %d", $N, $W);
      |       ^
a.cc:5:1: error: expected unqualified-id before 'for'
    5 | for ($i = 0; $i < $N; $i++) {
      | ^~~
a.cc:5:14: error: '$i' does not name a type
    5 | for ($i = 0; $i < $N; $i++) {
      |              ^~
a.cc:5:23: error: '$i' does not name a type
    5 | for ($i = 0; $i < $N; $i++) {
      |                       ^~
a.cc:9:1: error: '$current' does not name a type
    9 | $current = new SplFixedArray($W+1);
      | ^~~~~~~~
a.cc:10:1: error: '$next' does not name a type
   10 | $next = new SplFixedArray($W+1);
      | ^~~~~
a.cc:12:1: error: expected unqualified-id before 'for'
   12 | for ($j=0; $j <= $W; $j++) {
      | ^~~
a.cc:12:12: error: '$j' does not name a type
   12 | for ($j=0; $j <= $W; $j++) {
      |            ^~
a.cc:12:22: error: '$j' does not name a type
   12 | for ($j=0; $j <= $W; $j++) {
      |                      ^~
a.cc:16:1: error: expected unqualified-id before 'for'
   16 | for ($i = 0; $i < $N; $i++) {
      | ^~~
a.cc:16:14: error: '$i' does not name a type
   16 | for ($i = 0; $i < $N; $i++) {
      |              ^~
a.cc:16:23: error: '$i' does not name a type
   16 | for ($i = 0; $i < $N; $i++) {
      |                       ^~
a.cc:30:1: error: '$result' does not name a type
   30 | $result = 0;
      | ^~~~~~~
a.cc:31:9: error: expected constructor, destructor, or type conversion before '(' token
   31 | foreach ($current as $v) {
      |         ^
a.cc:36:1: error: 'echo' does not name a type
   36 | echo $result."\n";
      | ^~~~
Language: C++

#include <iostream>
#include <cmath>

using namespace std;

const int maxN = 110, maxW = 1e5 + 10;

int f[maxN][maxW], w[maxN], v[maxN], W;

// Max value chon tu i -> n with capacity weight
int calculate(int i, int weight) {
    if (i > n) return 0;
    if (f[i][weight] != -1) return f[i][weight];
    int ret = calculate(i + 1, weight);
    if (w[i] <= weight)
        ret = max(ret, calculate(i + 1, weight - w[i]));
    return f[i][weight] = ret;
}

int main() {
    cin >> n >> W;
    for (int i = 1; i <= n; ++i) scanf("%d", &w[i], &v[i]);
    memset(f, 255, sizeof(f));
    cout << calculate(1, W);
}


Compiler output:
a.cc: In function 'int calculate(int, int)':
a.cc:12:13: error: 'n' was not declared in this scope
   12 |     if (i > n) return 0;
      |             ^
a.cc: In function 'int main()':
a.cc:21:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   21 |     cin >> n >> W;
      |            ^
      |            yn
a.cc:23:5: error: 'memset' was not declared in this scope
   23 |     memset(f, 255, sizeof(f));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cmath>
  +++ |+#include <cstring>
    3 |
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;
typedef long long ll;
long long n,wmax;
map<ll,ll> mem[1e7];
ll we[MAXN],val[MAXN];

ll solve(ll w,ll i)
{
if(w > wmax) return -9223372036854775807;
if(i == n || w == wmax) return 0;

if(mem[i].count(w)) return mem[w][i];

ll ret = -9223372036854775807;

ret = max(solve(w  , i + 1) , solve(w + we[i] , i + 1) + val[i]);

mem[w][i] = ret;

return ret;



}

int main()
{
  cin >> n >> wmax;
  for(int i = 0 ; i < n ; i++) cin >> we[i] >> val[i];
  cout << solve(0,0) ;

}

Compiler output:
a.cc:8:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 | map<ll,ll> mem[1e7];
      |                ^~~
a.cc:8:16: error: could not convert '1.0e+7' from 'double' to 'long unsigned int'
    8 | map<ll,ll> mem[1e7];
      |                ^~~
      |                |
      |                double
a.cc:8:16: error: size of array 'mem' has non-integral type 'double'
Language: C++

//Knapsack problem
 
#include<bits/stdc++.h>
using namespace std;
 
long p[1000];
long w[1000];
long memo[1000000][1000];
 
long dp(long W,long i,long n)
{
	if(i==n)
		return 0;
	
	if(W==0)
		return 0;
		
	if(memo[W][i] != -1)
		return memo[W][i];
		
	long ans=dp(W,i+1,n);	
	if(w[i]<=W)
	{
		ans=max(ans,dp(W-w[i],i+1,n) + p[i]);	
	}
	memo[W][i]=ans;
	return memo[W][i];				
}
int main()
{
	long W,N;
	memset(memo,-1,sizeof(memo));
	//cout<<"\nEnter Weight: ";
	cin>>N;
	//cout<<"\nEnter N: ";
	cin>>W;
	//cout<<"\nEnter profit and weight arrays: ";
	for(long i=0;i<N;i++)
	{
      cin>>w[i]
		cin>>p[i];
		
	}
	
	long x=dp(W,0,N);
	
	cout<<x;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:16: error: expected ';' before 'cin'
   40 |       cin>>w[i]
      |                ^
      |                ;
   41 |                 cin>>p[i];
      |                 ~~~
Language: Java

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

public class Knapsack {
	static long[][] memo;
	static int n,W;
	static int[] w;
	static long[] v;

	public static long knap(int i, int remW)
	{
		if (i==n)
			return 0;
		if (memo[i][remW]!=-1)
			return memo[i][remW];
		long leave = knap(i+1,remW);
		long take =0;
		if(remW>=w[i]) take = knap(i+1,remW-w[i])+v[i];
		return memo[i][remW]=Math.max(take,leave);

	}

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

		n = sc.nextInt(); 
		v = new long[n];
		w = new int[n];
		W = sc.nextInt();
	
		
		for (int i =0 ; i<n;i++)
		{
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		
		
		memo = new long[n][W+1];
		for (long [] a: memo)
		{
			Arrays.fill(a, -1);
		}
		System.out.println(knap(0,W));
		
	}

}


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

#include <bits/stdc++.h>
using namespace std;
int n,W,dp[105][100005];
int main(){
	scanf("%d%d",&n,&W);
	for (int i=1;i<=n;i++)
		dp[i][0]=0
	for (int i=1;i<100005;i++)
		dp[0][i]=0
	for (int i=1;i<=n;i++){
		int w,v;
		scanf("%d%d",&w,&v);
		for (int j=1;j<=W;j++) {
			if (j<w) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v);
		}
	}
	printf("%d",dp[n][W]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:27: error: expected ';' before 'for'
    7 |                 dp[i][0]=0
      |                           ^
      |                           ;
    8 |         for (int i=1;i<100005;i++)
      |         ~~~                
a.cc:8:22: error: 'i' was not declared in this scope
    8 |         for (int i=1;i<100005;i++)
      |                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,W,dp[105][100005];
int main(){
	scanf("%d%d",&n,&W);
	for (int i=1;i<=n;i++)
		dp[i][0]=0
	for (int i=1;i<=n;i++)
		dp[0][100005]=0
	for (int i=1;i<=n;i++){
		int w,v;
		scanf("%d%d",&w,&v);
		for (int j=1;j<=W;j++) {
			if (j<w) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v);
		}
	}
	printf("%d",dp[n][W]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:27: error: expected ';' before 'for'
    7 |                 dp[i][0]=0
      |                           ^
      |                           ;
    8 |         for (int i=1;i<=n;i++)
      |         ~~~                
a.cc:8:22: error: 'i' was not declared in this scope
    8 |         for (int i=1;i<=n;i++)
      |                      ^
Language: Java

import java.util.Scanner;
public 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[2][W + 1];
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= W; j++) {
      	dp[i % 2][j] = dp[1 - i % 2][j];
        if (j >= w[i]) {
          dp[i % 2][j] = Math.max(dp[1 - i % 2][j - w[i]] + v[i], dp[i % 2][j]);
      }
    }
    System.out.println(dp[N % 2][W]);
  }
}

Compiler output:
Main.java:23: error: reached end of file while parsing
}
 ^
1 error
Language: Java

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

public class knapsack {
	static long[][] memo;
	static int []w,v;
	static int n;
	public static long dp(int i,int remW) {
		if(remW==0||i==n)
			return 0;
		if(memo[i][remW]!=-1)
			return memo[i][remW];
		long take=0;
		if(!(remW-w[i]<0))
		 take = dp(i+1,remW-w[i])+v[i];
		
		long  leave =dp(i+1,remW);
		return memo[i][remW]=Math.max(take, leave);
	}
	
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n=sc.nextInt();
       int W=sc.nextInt();
       memo=new long [n][W+1];
       for(int i=0;i<n;i++) {
    	   for(int j=0;j<memo[i].length;j++)
    		   memo[i][j]=-1;
       }
        w=new int[n];
       v=new int[n];
       for(int i=0;i<n;i++) {
    	   w[i]=sc.nextInt();
    	   v[i]=sc.nextInt();
       }
       out.println(dp(0,W));
        out.flush();
    }

    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {br = new BufferedReader(new InputStreamReader(system));}
        public Scanner(String file) throws Exception {br = new BufferedReader(new FileReader(file));}
        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public String nextLine()throws IOException{return br.readLine();}
        public int nextInt() throws IOException {return Integer.parseInt(next());}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
        public char nextChar()throws IOException{return next().charAt(0);}
        public Long nextLong()throws IOException{return Long.parseLong(next());}
        public boolean ready() throws IOException{return br.ready();}
        public void waitForInput() throws InterruptedException {Thread.sleep(3000);}
    }
}
    

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



import java.io.*;
import java.util.*;
public class test4 {
static long[][] memo;
static int N,W;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   N=sc.nextInt();
	   W=sc.nextInt();
	   w=new int[N];
	   v=new int[N];
	   for(int i=0;i<N;i++) {
		   w[i]=sc.nextInt();
		   v[i]=sc.nextInt();
	   }
	   memo=new long[N][W+1];
	   for(long[]a:memo)
		   Arrays.fill(a, -1);
	   dp(0,W);
	//   for(int[]a:memo)
		//   System.out.println(Arrays.toString(a));
	   System.out.println(memo[0][W]);
	}
	static int [] w,v;
	static long dp(int i,int remW) {
		if(remW<0)
			return -inf;
		if(N==i)
			return 0;
		if(memo[i][remW]!=-1)
			return memo[i][remW];
		long leave=dp(i+1,remW);
		long take=0;
	//	if(remW>w[i])
		 take=dp(i+1,remW-w[i])+v[i];
		//System.out.println(take);
		return memo[i][remW]=Math.max(take, leave);
	}
	static final long inf=(long) 1e17;
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class C {
    static int n;
    static int[]v,w;
    static long[][]memo;
    static long dp(int id,int W) {
        if (id == n) return 0;
        if (memo[id][W] != -1) {
            return memo[id][W];
        }
        long take = 0l;
        if (w[id] <= W){
             take = v[id]*1l+dp(id+1,W-w[id]);
    }
        return memo[id][W]=Math.max(dp(id+1,W),take);
    }
    public  static void main(String[]args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n= sc.nextInt();
        int remw = sc.nextInt();
        v= new int[n];
        w= new int[n];
        memo= new long[n][remw+1];
        for (long[]x:memo){
            Arrays.fill(x,-1);
        }
        for (int i =0;i<n;i++){
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
        }
        pw.println(dp(0,remw));
       // pw.println(Arrays.deepToString(memo));

      pw.flush();
    }
    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException
        {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if(x.charAt(0) == '-')
            {
                neg = true;
                start++;
            }
            for(int i = start; i < x.length(); i++)
                if(x.charAt(i) == '.')
                {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                }
                else
                {
                    sb.append(x.charAt(i));
                    if(dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg?-1:1);
        }

        public boolean ready() throws IOException {return br.ready();}


    }
}

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

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


public class CFR {
    static final int UNCALC = -1;
    static final long INF = (long) 1e18;
    static int n, w[], v[];
    static long memo[][];

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        int W = sc.nextInt();
        v = new int[n];
        w = new int[n];
        memo = new long[n][W + 1];
        for (long[] a : memo)
            Arrays.fill(a, UNCALC);
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        out.println(dp(0, W));
        out.flush();
        out.close();
    }

    static long dp(int i, int rem) {
        if (rem < 0) return -INF;
        if (i == n) return 0;
        if (memo[i][rem] != UNCALC) return memo[i][rem];
        long take = v[i] + dp(i + 1, rem - w[i]);
        long leave = dp(i + 1, rem);
        return Math.max(take, leave);
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }


    }

}

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

#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

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

    vector<ll> dp(w + 1, 0);
    vector<int> a(n + 1, 0);
    vector<ll> b(n + 1, 0);

    for(int i = 1; i <= n; i ++)
        cin >> a[i] >> b[i];

    int lim = 0;
    for(int i = 1; i <= n; i ++) {
        for(int s = lim; s >= 0; s --)
            if(s + a[i] <= w)
                dp[s + a[i]] = max(dp[s] + b[i], dp[s + a[i]]);

        lim += a[i];
    }
    int ans = 0;
    for(int i = 0; i <= w; i ++)
        ans = max(ans, dp[i]);
    cout << ans;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:18: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   33 |         ans = max(ans, dp[i]);
      |               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:33:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   33 |         ans = max(ans, dp[i]);
      |               ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |         ans = max(ans, dp[i]);
      |               ~~~^~~~~~~~~~~~
Language: C++

#include <iostream>
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];
    }
    long values[W + 1];
    for (int i = 0; i <= W; i++) {
        values[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        for (int j = W - w[i]; j >= 0; j--) {
            values[w[i] + j] = max(values[w[i] + j], values[j] + v[i]);
        }
    }
    cout << values[max_element(values, values + W + 1) - values] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: 'max_element' was not declared in this scope
   20 |     cout << values[max_element(values, values + W + 1) - values] << endl;
      |                    ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long memo[100005][100005];
long long w[100005],v[100005];
long long sum,pos;
long long N,W;
long long knap(long long pos, long long sum){
  if(memo[pos][sum] != -1 ) return memo[pos][sum];
  if(pos == N){
    return 0;
  }else if(sum + w[pos] > W){
    return memo[pos][sum] = knap(pos + 1 , sum);
  } else {
    return memo[pos][sum] = max(knap(pos + 1 , sum) , knap(pos + 1 , sum + w[pos] ) + v[pos]);
  }
}
int main()
{
  cin >> N >> W;
  for(int i=0; i<N; i++){
    cin >> w[i];
    cin >> v[i];
  }
  memset(memo,-1,sizeof(memo));
  sum = 0;
  pos = 0;
  cout << knap(pos,sum) << endl;
  return 0;
}


Compiler output:
/tmp/ccfgmd5Z.o: in function `knap(long long, long long)':
a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x8b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x11b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccfgmd5Z.o
/tmp/ccfgmd5Z.o: in function `main':
a.cc:(.text+0x1e3): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x1ff): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x250): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x276): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccfgmd5Z.o
a.cc:(.text+0x2a3): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status