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

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define INF ((1LL<<62)-(1LL<<31))
using namespace std;

int main(){
  long long int a,b;
  cin>>a>>b;
  long long int W[a+1],V[a+1],DP[a+1][1000001];
  //DP[i][j] i番目までの品物を、価値がj以上になるように選んだ時の最小の重さ
  
  for(int i=0; i<=a; ++i){
    if(i>0) cin>>W[i]>>V[i];
    for(int j=0; j<1000001; ++j){
      DP[i][j]=INF;
    }
  }
  
  DP[0][0]=0;
  
  for(int i=1; i<=a; ++i){
    for(int j=0; j<1000001; ++j){
      if(j>=V[i]) DP[i][j]=min(DP[i-1][j],DP[i-1][j-V[i]]+W[i]);
      else DP[i][j]=DP[i-1][j];
    }
  }
  
  int ans=1000000;
  while(dp[N][ans]>W)ans--;
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'dp' was not declared in this scope; did you mean 'DP'?
   34 |   while(dp[N][ans]>W)ans--;
      |         ^~
      |         DP
a.cc:34:12: error: 'N' was not declared in this scope
   34 |   while(dp[N][ans]>W)ans--;
      |            ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define INF ((1LL<<62)-(1LL<<31))
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  long long int W[a+1],V[a+1],DP[a+1][b+1];
  //DP[i][j] i番目までの品物を、価値がj以上になるように選んだ時の最小の重さ
  
  for(int i=0; i<=a; ++i){
    if(i>0) cin>>W[i]>>V[i];
    for(int j=0; j<1000001; ++j){
      DP[i][j]=INF;
    }
  }
  
  DP[0][0]=0;
  
  for(int i=1; i<=a; ++i){
    for(int j=0; j<1000001; ++j){
      if(j>=W[i]) DP[i][j]=max(DP[i-1][j],DP[i-1][j-V[i]]+W[i]);
      else DP[i][j]=DP[i-1][j];
    }
  }
  
  for(int i=1000001; i>=0; --i){
    if(DP[N][i]<=W){
      cout<<i<<endl;
      break;
    }
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:11: error: 'N' was not declared in this scope
   34 |     if(DP[N][i]<=W){
      |           ^
Language: C++

#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
int n,W; 
cin>>n>>W;
vector<short int>v(n),w(n);
vector<short int> first(W+1,0);
for(int i=0; i<n; i++) cin>>w[i]>>v[i];
for(int i=0; i<n; i++){ for(int k=W; k>=w[i]; k--) first[k]=max(first[k-w[i]]+v[i],first[k]); 
                      }//DEBUG: for(int i=0; i<=n; i++){ for(int k=0; k<=W; k++) cout<<dp[i][k]<<" "; cout<<endl; }
cout<<first[W];
return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:10:64: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<short int>, short int>::value_type&)'
   10 | for(int i=0; i<n; i++){ for(int k=W; k>=w[i]; k--) first[k]=max(first[k-w[i]]+v[i],first[k]);
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:10:64: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<short int>, short int>::value_type' {aka 'short int'})
   10 | for(int i=0; i<n; i++){ for(int k=W; k>=w[i]; k--) first[k]=max(first[k-w[i]]+v[i],first[k]);
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:10:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 | for(int i=0; i<n; i++){ for(int k=W; k>=w[i]; k--) first[k]=max(first[k-w[i]]+v[i],first[k]);
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: Java

import java.util.Scanner;
public class knapSack{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int W = input.nextInt();

		int[] weights = new int[N];
		int[] values = new int[N];

		for(int i = 0; i < N; i++){
			weights[i] = input.nextInt();
			values[i] = input.nextInt();
		}

		long[][] memo = new long[N+1][W+1];

		for(int i = 1; i < N+1; i++){
			for(int j = 0; j <= W; j++){
				if(weights[i-1] <= j) memo[i][j] = Math.max(memo[i-1][j], memo[i-1][j-weights[i-1]] + values[i-1]);
				else memo[i][j] = memo[i-1][j];
			}
		}

		System.out.println(memo[N][W]);
	}
}

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

ll dp[105][MAX] = {0}; //このMAXに10000000000とか入れるとエラーでる。
int main(){
cin.tie(0);
ios::sync_with_stdio(0); //この2行はより速度を向上させる
// 追加２, 以降 cin の入力元が 'input.txt' になる
//提出時に消す！！
//std::ifstream in("sample.txt");
//std::cin.rdbuf(in.rdbuf());

int N,W;
cin >> N >> W;

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

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

return 0;
}

Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll dp[105][MAX] = {0}; //このMAXに10000000000とか入れるとエラーでる。
      | ^~
a.cc: In function 'int main()':
a.cc:3:1: error: 'cin' was not declared in this scope
    3 | cin.tie(0);
      | ^~~
a.cc:4:1: error: 'ios' has not been declared
    4 | ios::sync_with_stdio(0); //この2行はより速度を向上させる
      | ^~~
a.cc:13:1: error: 'vector' was not declared in this scope
   13 | vector<ll> w(N),v(N);
      | ^~~~~~
a.cc:13:8: error: 'll' was not declared in this scope
   13 | vector<ll> w(N),v(N);
      |        ^~
a.cc:13:12: error: 'w' was not declared in this scope
   13 | vector<ll> w(N),v(N);
      |            ^
a.cc:13:17: error: 'v' was not declared in this scope
   13 | vector<ll> w(N),v(N);
      |                 ^
a.cc:14:5: error: 'i' was not declared in this scope
   14 | rep(i,N) cin >> w[i] >> v[i];
      |     ^
a.cc:14:1: error: 'rep' was not declared in this scope
   14 | rep(i,N) cin >> w[i] >> v[i];
      | ^~~
a.cc:18:17: error: 'dp' was not declared in this scope
   18 |                 dp[i+1][j]=dp[i][j];
      |                 ^~
a.cc:20:38: error: 'max' was not declared in this scope
   20 |                         dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
      |                                      ^~~
a.cc:24:1: error: 'cout' was not declared in this scope
   24 | cout << dp[N][W] << endl;
      | ^~~~
a.cc:24:9: error: 'dp' was not declared in this scope
   24 | cout << dp[N][W] << endl;
      |         ^~
a.cc:24:21: error: 'endl' was not declared in this scope
   24 | cout << dp[N][W] << endl;
      |                     ^~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

int N;
ll W, weight[MAX_N], value[MAX_N];
ll dp[MAX_N][MAX_V];
 
int main() {
    cin >> N >> W;
    rep(i, N) {
        cin >> weight[i] >> value[i];
    }

    rep(i, MAX_N) {
        rep(j, MAX_V) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    rep(i, N) {
        for(int sum_v = 0; sum_v < MAX_V; sum_v++) {
            if(sum_v - value[i] >= 0) {
                chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            }

            chmax(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    ll ans = 0;
    for(int sum_v = 0; sim_v < MAX_V; sum_v++) {
        if(dp[N][sum_v] <= W) {
            ans = sum_v;
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:46:24: error: 'sim_v' was not declared in this scope; did you mean 'sum_v'?
   46 |     for(int sum_v = 0; sim_v < MAX_V; sum_v++) {
      |                        ^~~~~
      |                        sum_v
Language: C++

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

vector <vector <ll> > dp;
int main()
{
    ll w, n;
    cin>>n>>w;
    vector <ll> wt(n + 1), val(n + 1);
    for(ll i = 1; i <= n; i++)
    cin>>wt[i]>>val[i];
    dp.resize(n + 1);
    for(i = 0; i <= n; i++)
    dp[i].resize(w + 1);
    //vector <vector <ll> > dp(n + 1, vector <ll> (w + 1, 0));
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= w; j++)
        {
            if(j >= wt[i])
            dp[i][j] = max(val[i] + dp[i - 1][j - wt[i]], dp[i - 1][j]);
            else
            dp[i][j] = dp[i - 1][j];
        }
    }
    cout<<dp[n][w]<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'i' was not declared in this scope
   14 |     for(i = 0; i <= n; i++)
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(1e5+5)
int main(){
	int n;
  long long w;
  cin>>n>>w;
  vector<long long> dp(MAXN,LLONG_MAX);
  for(int i=0;i<n;i++){
  	long long val,wt;cin>>wt>>val;
    vector<long long>newdp(MAXN,LLONG_MAX)
      for(int j=0;j<MAXN;j++){
		if(i==0){
        	if(j==val){
            	newdp[j]=wt;	
            }
        }
        else{
          	newdp[j]=dp[j];
        	if(val<=j && dp[j-val]!=LLONG_MAX){
    	      	newdp[j]=min(newdp[j],dp[j-val]+wt);
	          }	
        	}
  		}
    	dp=newdp;
	}
	long long ans=0;
	for(int i=0;i<MAXN;i++){
		if(dp[i]<=w)ans=max(ans,i);
	}
	cout<<ans<<endl;
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: expected ',' or ';' before 'for'
   12 |       for(int j=0;j<MAXN;j++){
      |       ^~~
a.cc:12:19: error: 'j' was not declared in this scope
   12 |       for(int j=0;j<MAXN;j++){
      |                   ^
a.cc:29:36: error: no matching function for call to 'max(long long int&, int&)'
   29 |                 if(dp[i]<=w)ans=max(ans,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:29:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |                 if(dp[i]<=w)ans=max(ans,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:29:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |                 if(dp[i]<=w)ans=max(ans,i);
      |                                 ~~~^~~~~~~
Language: C++

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

int main()
{
    long long n,w;
    cin >> n >> w;
    vector<vector<long long>> dp(105,vector<long long>(100005,1000000000000000000)),x(n+1,vector<long long>(2));
    for(int i = 1 ; i <= n ; i += 1){
        cin >> x[i][0] >> x[i][1];
    }
    for(int i = 0 ; i <= n ; i += 1){
        dp[i][0] = 0;
    }
    long long max_sum = n * 1000,ans=0;
    for(int i = 1 ; i <= n ; i += 1){
        for(int v = 0 ; v <= max_sum ; v += 1){
            dp[i][v] = dp[i-1][v];
            if(v - x[i][1] >= 0){
                dp[i][v] = min(dp[i][v],dp[i-1][v-x[i][1]] + x[i][0]);
            }
            if(dp[i][v] <= w){
                ans = max(ans,v);
            }
        }
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:26: error: no matching function for call to 'max(long long int&, int&)'
   23 |                 ans = max(ans,v);
      |                       ~~~^~~~~~~
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:23:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |                 ans = max(ans,v);
      |                       ~~~^~~~~~~
/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:23:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |                 ans = max(ans,v);
      |                       ~~~^~~~~~~
Language: C++

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

public class Main {
	public final int MOD = (int)1e9 + 7;
	int[] weight;
	int[] value;
	public void solve(BufferedReader br) throws IOException {
		int[] nw = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int N = nw[0];
		int W = nw[1];
		weight = new int[N + 1];
		value = new int[N + 1];
		for (int i = 0; i < N; i++) {
			int[] wv = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			weight[i + 1] = wv[0];
		   	value[i + 1] = wv[1];
		}
		int sum_of_value = 0;
		for (int i = 1; i <= N; i++) sum_of_value += value[i];
		//System.out.println(sum_of_value);
		System.out.println(findZeroOneKanpsack(N, W, sum_of_value));	
	}	

	public long findZeroOneKanpsack(int n, int w, int size) {
		// dp[i] stores the minimum weight that we can have with size exactly value i
		long[] dp = new long[size + 1];
		Arrays.fill(dp, (long) 1e18 + 7);
		dp[0] = 0;		
		for (int i = 1; i <= n; i++) {
			for (int j = size; j >= value[i]; j--) {
				dp[j] = Math.min(dp[j], weight[i] + dp[j - value[i]]);
			}	
		}
		long ans = 0;
		for (int i = 0; i <= size; i++) {
			if (dp[i] <= w) ans = Math.max(ans, i);
		}
		//for (int i = 0; i <= size; i++) System.out.println(i + " " +dp[i]);
		return ans;
	}
	
	public long mathPow(long base, long exp, long mod) {
		long res = 1;
		base = base % mod;
		while (exp > 0) {
			if ((exp & 1) == 1) res = (res * base ) % mod;
			exp = exp >> 1;
			base = (base * base) % mod;
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
	}
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.function.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,w;
map<pair<int,int>,int>m;
long long int a[1000000001][101];
long long int knap(int x,int y)
{
	if(y==n)
	{
		return 0;
	}
	if(m.find({x,y})!=m.end())
	return m[{x,y}];
 
		
		if(v[y].first<=x)
		{
			m[{x,y}]=max(v[y].second+knap(x-v[y].first,y+1),knap(x,y+1));
			return m[{x,y}];
		}
	
	else
	{
		knap(x,y+1);
	}
	
}
int main()
{
	cin>>n>>w;
	int x,y;
	long long int res;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		v.push_back(make_pair(x,y));
	}
	res=knap(w,0);
	cout<<res<<endl;
}


Compiler output:
a.cc: In function 'long long int knap(int, int)':
a.cc:16:20: error: 'v' was not declared in this scope
   16 |                 if(v[y].first<=x)
      |                    ^
a.cc: In function 'int main()':
a.cc:36:17: error: 'v' was not declared in this scope
   36 |                 v.push_back(make_pair(x,y));
      |                 ^
a.cc: In function 'long long int knap(int, int)':
a.cc:27:1: warning: control reaches end of non-void function [-Wreturn-type]
   27 | }
      | ^
Language: C++

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

using namespace std;

typedef long long ll;

const ll inf = 1LL << 60;

ll dp[110][100100];

int main(){
  ll N,W; cin >> N >> W;
  vector<ll> w(N); vector<ll> v(N);

  for(ll i = 0; i < N; i++){
    cin >> w[i] >> v[i]; }
  
  for(ll i = 0; i < 110; i++){
    for(ll j = 0; j < 100100; j++){
      dp[i][j] = inf;}}
  
  dp[0][0] = 0;
                                     
  for(ll i = 0; i < N; i++){
    for(ll sum_v = 0; sum_v <= 100100; sum_v++){
      if( sum_v >= v[i]){
        dp[i+1][sum_v] = min( dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);}
        dp[i+1][sum_v] = min( dp[i+1][sum_v], dp[i][sum_v]);}}
  
  ll res = 0;
  for(ll sum_v = 0; sum_v <= Max_V ; sum_v++){
    if( dp[N][sum_v] <= W){ res = sum_v;} }
  
  cout << res << endl; return 0;}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:30: error: 'Max_V' was not declared in this scope
   34 |   for(ll sum_v = 0; sum_v <= Max_V ; sum_v++){
      |                              ^~~~~
Language: C++

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

using namespace std;

typedef long long ll;

const ll inf = 1<< 29;

ll dp[110][100100];

int main(){
  ll N,W; cin >> N >> W;
  vector<ll> w(N); vector<ll> v(N);
  ll Max_V = 100100;
  for(ll i = 0; i < N; i++){
    cin >> w[i] >> v[i]; Max_V += v[i];}
  
  for(ll i = 0; i < 110; i++){
    for(ll j = 0; j < 100100; j++){
      dp[i][j] = inf;}}
  
  dp[0][0] = 0;
                                     
  for(ll i = 0; i < N; i++){
    for(ll sum_v = 0; sum_v <= 100100; sum_v++){
      if( sum_v >= v[i]){
        dp[i+1][sum_v] = min( dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);}
        dp[i+1][sum_v] = min( dp[i+1][sum_v], dp[i][sum_v]);}}
  
  ll res = 0;
  for(ll sum_v = 0; sum_v <= Max_V ; sum_v++){
    if( dp[N][sum_v] <= W){ res = sum_v;} }
  

Compiler output:
a.cc: In function 'int main()':
a.cc:35:44: error: expected '}' at end of input
   35 |     if( dp[N][sum_v] <= W){ res = sum_v;} }
      |                                            ^
a.cc:14:11: note: to match this '{'
   14 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<queue>
#include<algorithm>
#include<utility>
#include<cmath>

using namespace std;

const int maxn = 1e2 + 5;
int n, w, b[maxn];
pair<int, int> a[maxn];

double h(int idx, int wt) {
	long long curw = wt;
	int curv = 0;
	for(int i = idx + 1; i <= n; i++) {
		int diff = w - curw;
		if(diff >= a[i].first) {
			curv += a[i].second;
			curw += a[i].first;
		} else {
			curv += ((double) a[i].second) / a[i].first * diff;
			break;
		}
	}
	return curv;
}

int bab() {
	queue< tuple<double, int, long long, int> > pq;
	for(int i = 1; i <= n; i++) {
		if(a[i].first <= w) {
			pq.push({a[i].second + h(i, a[i].first), a[i].second, a[i].first, i});
		}
	}
	int ans = 0;
	while(!pq.empty()) {
		auto e = pq.front();
		pq.pop();
		int ev = get<1>(e); long long ew = get<2>(e); int ei = get<3>(e);
		bool leaf = true;
		for(int i = ei + 1; i <= n; i++) {
			double cv = ev + a[i].second + h(i, ew + a[i].first);
			if(ew + a[i].first <= w && ev + a[i].second > ans) {
				pq.push({cv, ev + a[i].second, ew + a[i].first, i});
			}
		}
		ans = max(ans, ev);
	}
	return ans;
}

bool cmp(pair<int, int> &i, pair<int, int> &j) {
	return ((double) i.second) / i.first > ((double) j.second) / j.first;
}

int brute() {
	int ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		long long curw = 0;
		int curv = 0;
		for(int j = 0; j < n; j++) {
			if((i >> j) & 1) {
				curw += a[j + 1].first;
				curv += a[j + 1].second;
				if(curw > w) goto hell;
			}
		}
		ans = max(ans, curv);
		hell:;
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> w;
	assert(n <= 20);
	for(int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a + 1, a + 1 + n, cmp);
	//cout << bab() << " " << brute() << '\n';
	cout << brute() << '\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:9: error: 'assert' was not declared in this scope
   79 |         assert(n <= 20);
      |         ^~~~~~
a.cc:6:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    5 | #include<cmath>
  +++ |+#include <cassert>
    6 |
Language: C++

//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする
 
using namespace std;
typedef long long int ll;
typedef pair< long long int , long long int> P;

 
//int dy[5] = { 0,0,1,-1,0 };
//int dx[5] = { 1,-1,0,0,0 };

int dy[5] = { -1,0,1,0,0 };
int dx[5] = { 0,-1,0,1,0 };

struct edge{long long int to;
long long int cost;};

 
int main(void){

	long long int n,W;
	long long int w[101],v[101];
	long long int maxi=-1;

	vector< vector<long long int > >dp(101,vector<long long int > (100001,LINF));

	cin>>n>>W;
s
	LFOR(i,1,n){
		cin>>w[i]>>v[i];
	}

	dp[0][0]=0;

	LFOR(i,1,n){
		FOR(j,0,1000*n){
			if(j-v[i]>=0){
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}

	LFOR(i,0,1000*n){
		if(dp[n][i]<=W){
			maxi=max(maxi,i);
		}
	}

	cout<<maxi<<endl;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:59:1: error: 's' was not declared in this scope
   59 | s
      | ^
a.cc:60:14: error: 'i' was not declared in this scope
   60 |         LFOR(i,1,n){
      |              ^
a.cc:24:48: note: in definition of macro 'LFOR'
   24 | #define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
      |                                                ^
Language: C++

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

long long p[105];
long long w[105];
long long dp[105][1000000005];
long long n, k;

long long f(long long i, long long k){
    if(k < 0) return 1;
    if(i == n) return 0;
    long long &r = dp[i][k];
    if(r == -1){
        r = f(i + 1, k);
        if(w[i] <= k){
            r = max(r, f(i + 1, k - w[i]) + p[i]);
        }
    }
    return r;
}

main(){
    ios::sync_with_stdio(0); cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(long long i = 0; i < n; i++){
        cin >> w[i] >> p[i];
    }
    cout << f(0, k);
}


Compiler output:
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
/tmp/ccwnhMF6.o: in function `f(long long, long long)':
a.cc:(.text+0x24): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccwnhMF6.o
/tmp/ccwnhMF6.o: in function `main':
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccwnhMF6.o
a.cc:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccwnhMF6.o
a.cc:(.text+0x1f4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccwnhMF6.o
a.cc:(.text+0x201): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccwnhMF6.o
collect2: error: ld returned 1 exit status
Language: C++

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

void min_self(long long &x,long long y)
{
    x=min(x,y);
}
long long inf=1e18+1;
int main()
{
    int  n;
    int w;
    scanf("%d %d",&n,&w);
    vector<int>weight(n+1),value(n+1);
    for( int i=0;i<n;i++)
    {
        scanf("%d%d",&weight[i],&value[i]);
    }
    int sum_value=0;
    for(int x:value)
    {   
        sum_value+=x;
    }
    vector<long long>dp(sum_value+1,inf);
    dp[0]=0;
    for(int item=0;item<n;item++)
    {
        for(int value_already=sum_value-value[item];value_already>=0;value_already--)
        {
            min_self(dp[value_already+value[item]],dp[value_already]+weight[item]);
        }
    }
    long long answer=0;
    for(int i=0;i<sum_value;i++)
    {
        if(dp[i]<=w)
        {
            answer=max(answer,i);
        }
    }
    cout<<answer<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:23: error: no matching function for call to 'max(long long int&, int&)'
   38 |             answer=max(answer,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:38:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   38 |             answer=max(answer,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:38:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   38 |             answer=max(answer,i);
      |                    ~~~^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<algorithm>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
int128_t knapsack(vector< pair<int128_t,int128_t> > &item,vector< vector<int128_t> > &dp,int128_t ele,int128_t w,int128_t n)
{
  if(ele==n)
    return 0;
  if(item[ele].first>w)
  {
    dp[w][ele]=0;
    return 0;
  }
  if(dp[w][ele]==-1)
    return dp[w][ele];
  dp[w][ele]=max((item[ele].second+knapsack(item,dp,ele+1,w-item[ele].first,n)),knapsack(item,dp,ele+1,w,n));
  return dp[w][ele];
}
bool compare(const pair<int128_t,int128_t> &a,const pair<int128_t,int128_t> &b)
{
  return a.first<b.first;
}
int main(void)
{
  int128_t n,i,j;
  int128_t w;
  cin>>n>>w;
  vector< pair<int128_t,int128_t> > item;
  vector< vector<int128_t> > dp;
  for(i=0;i<w+1;i++)
  {
    vector<int128_t>temp(n);
    for(j=0;j<n;j++)
    {
      temp.push_back(-1);
    }
    dp.push_back(temp);
  }
  for(i=0;i<n;i++)
  {
    pair<int128_t,int128_t>temp;
    cin>>temp.first>>temp.second;
    item.push_back(temp);
  }
  sort(item.begin(),item.end(),compare);
  cout<<knapsack(item,dp,0,w,n);
  return 0;
}


Compiler output:
a.cc:5:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    5 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>

using namespace std;

#pragma GCC oprimize("Ofast")
#define rep(i,a,b) for(__typeof(b)i=a;i<b;++i)
#define fs first
#define sc second
#define pb emplace_back

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
typedef pair<ll,ll> pl;

ll n,w;
ll mem[110][1000000010];

vector<pl> l;

ll dp(ll at, ll cw)
{
    if(cw >= w || at == n)return 0;
    if(mem[at][cw]!=-1)return mem[at][cw];
    ll ans = 0;
    if(l[at].fs + cw <= w)ans = max(ans,l[at].sc + dp(at+1,l[at].fs+cw));
    ans = max(ans,dp(at+1,cw));
    return mem[at][cw] = ans;
}


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

    memset(mem,-1,sizeof(mem));

	cin >> n >> w;
	l.resize(n);
	rep(i,0,n)
	{
		cin >> l[i].fs >> l[i].sc;
	}
	cout << dp(0,0);
	return 0;
}


Compiler output:
/tmp/cc6ckCXD.o: in function `dp(long long, long long)':
a.cc:(.text+0x9c): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
a.cc:(.text+0xcd): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
a.cc:(.text+0xe7): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
/tmp/cc6ckCXD.o: in function `main':
a.cc:(.text+0x23d): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
a.cc:(.text+0x25d): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
a.cc:(.text+0x288): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
/tmp/cc6ckCXD.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2e8): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
a.cc:(.text+0x301): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6ckCXD.o
collect2: error: ld returned 1 exit status
Language: C++

  #include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      ll n,W;
      cin>>n>>W;
      ll w[n+1],v[n+1],sum=0;
      for(int i=1;i<=n;i++)
      {
      	  cin>>w[i]>>v[i];
      	  sum+=v[i];
      }
      ll dp[n+1][sum+1];
      ll ans=0;

      for(int i=0;i<=sum;i++)
      {
      	  dp[0][i]=1e18;                  // with no element no chance for any sum 
      }
      for(int i=0;i<=n;i++) dp[i][0]=0;   // minimum weight required to have cost 0 for each i;
      for(int i=1;i<=n;i++)
      {
      	  for(int j=1;j<=sum;j++)
      	  {   
      	  	  if(j>=v[i])
      	  	  dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]); 
      	  	  else
      	  	  dp[i][j]=dp[i-1][j]   // to take it or not 
      	  }
      	 
      }

      for(int i=0;i<=sum;i++) 
      {
      	 if(dp[n][i]<=W)
      	 {
      	 	ans=i;
      	 }
      }
       
      cout<<ans<<endl; 


        
  }




Compiler output:
a.cc: In function 'int main()':
a.cc:42:38: error: expected ';' before '}' token
   42 |                   dp[i][j]=dp[i-1][j]   // to take it or not
      |                                      ^
      |                                      ;
   43 |           }
      |           ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e9+7;
vector<vector<int>> dp(102,vector<int>(lim,0));

int main(){
    int n;
    ll cap;
    cin>>n;
    cin>>cap;
    vector<ll> w(n+1,0),
    vector<int> v(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=cap;j++){
            dp[i][j]=dp[i-1][j];
            if(j>=w[i]) dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
        }
    }
    cout<<dp[n][cap];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: invalid declarator before 'v'
   13 |     vector<int> v(n+1,0);
      |                 ^
a.cc:15:20: error: 'v' was not declared in this scope
   15 |         cin>>w[i]>>v[i];
      |                    ^
a.cc:20:56: error: 'v' was not declared in this scope
   20 |             if(j>=w[i]) dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
      |                                                        ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N, W;
  cin >> N >> W;
  vector<vector<int>>dp(N + 1, vector<int>(1000 * N + 1, 0));
  //dp[i][j] = i番目まで処理、価値jとなる重さの最小値
  vector<bool>>exi(1000 * N + 1, false));
  //i番目まで処理、価値jのバッグはある？
  exi[0] = true;
  for (int i = 1; i <= N; i ++) {
    int w, v;
    cin >> w >> v;
    for (int j = 0; j <= 1000 * N; j ++) dp[i][j] = dp[i - 1][j];
    for (int j = 0; j <= 1000 * N - v; j ++) {
      if (exi[j]) {
        int k = dp[i - 1][j] + w;
        if (k < dp[i][j + v]) dp[i][j + v] = k;
        exi[j + v] = true;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= 1000 * N; i ++) {
    if (exi[i] && dp[N][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: expected unqualified-id before '>' token
    9 |   vector<bool>>exi(1000 * N + 1, false));
      |              ^~
a.cc:11:3: error: 'exi' was not declared in this scope; did you mean 'exit'?
   11 |   exi[0] = true;
      |   ^~~
      |   exit
Language: C++

/*
Abdul bari and GFG
*/
#include<bits/stdc++.h>
#define maverick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int unsigned long long int 
using namespace std;

int main()
{
		maverick;
		int n,w;
		cin>>n>>w;
		int values[n+1]={},weights[n+1]={},t[n+1][w+1]={};
		
		for(int i=1;i<=n;i++)
		{
			cin>>weights[i];
			cin>>values[i];
		}
		
		
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=w;j++)
			{
				if(i==0||j==0)t[i][j]=0;
				else if(weights[i]>j)t[i][j]=t[i-1][j];
				else t[i][j]=max(t[i-1][j],values[i]+t[i-1][j-weights[i]]);
			}
		}
		
		/*for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=w;j++)
				cout<<t[i][j]<<" ";
			cout<<"\n";
		}*/
		
		cout<<"\n"<<t[n][w];
	return 0;
}


Compiler output:
a.cc:6:32: error: '::main' must return 'int'
    6 | #define int unsigned long long int
      |                                ^~~
a.cc:9:1: note: in expansion of macro 'int'
    9 | int main()
      | ^~~
Language: C++

#include<bits/stc++.h>
using namespace std;
typedef long long ll;

int main()
{
  int n,W;
  
  cin>>n>>W;
  ll w[n],v[n];
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  
  int V=100005;
  ll dp[V];
  ll inf=1e10;
  
  for(int i=0;i<V;i++)dp[i]=inf;
  
  dp[0]=0;
  
  for(int i=0;i<n;i++)
    for(int j=V-1;j>=0;j--){
      if(j>=v[i])
        dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
  ll ans=0;
  for(int i=0;i<V;i++)
    if(dp[i]<=W)ans=i;
  
  
  cout<<ans<<endl;
  
  return 0;
}
  

Compiler output:
a.cc:1:9: fatal error: bits/stc++.h: No such file or directory
    1 | #include<bits/stc++.h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define MAXN 1000000001
#define INF INT_MAX
using namespace std;

int n, k;
int abc[3][MAXN];
int dp[3][MAXN];

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
    	cin >> abc[0][i] >> abc[1][i] >> abc[2][i];
    	dp[0][i] = dp[1][i] = dp[2][i] = INF;
    }
    
    dp[0][n-1] = abc[0][n-1];
    dp[1][n-1] = abc[1][n-1];
    dp[2][n-1] = abc[2][n-1];

	for(int i = n-2; i >= 0; i--){
		dp[0][i] = abc[0][i] + max(dp[1][i+1],dp[2][i+1]);
		dp[1][i] = abc[1][i] + max(dp[0][i+1],dp[2][i+1]);
		dp[2][i] = abc[2][i] + max(dp[1][i+1],dp[0][i+1]);
	}
    
    cout << max(max(dp[0][0],dp[1][0]),dp[2][0]) << "\n";
    
    return 0;
}


Compiler output:
/tmp/cceAISJs.o: in function `main':
a.cc:(.text+0xe1): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x121): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x13e): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x1ee): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x27f): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x29f): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cceAISJs.o
a.cc:(.text+0x2c6): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		ll n,w;
		cin>>n>>w;
		ll v[n],w[n];
		ll m=0;
		lr(n){
			cin>>w[i]>>v[i];
			m+=v[i];
		}
		ve<ll>p(1e6),c(1e6,1e10);
		p[0]=1;
		for(ll i=0;i<n;i++){
			for(ll j=m;j>=0;j--){
				if(p[j]){
					p[j+v[i]]=1;
					c[j+v[i]]=min(c[j+v[i]],c[j]+w[i]);
				}
			}
		}
		for(ll i=m;i>=0;i--){
			if((p[i] & c[i]) && c[i]<=w){
				cout << i << "\n";
				return 0;
			}
		}
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:25: error: conflicting declaration 'long long int w [n]'
   24 |                 ll v[n],w[n];
      |                         ^
a.cc:22:22: note: previous declaration as 'long long int w'
   22 |                 ll n,w;
      |                      ^
a.cc:27:31: error: invalid types 'long long int[long long int]' for array subscript
   27 |                         cin>>w[i]>>v[i];
      |                               ^
a.cc:36:71: error: invalid types 'long long int[long long int]' for array subscript
   36 |                                         c[j+v[i]]=min(c[j+v[i]],c[j]+w[i]);
      |                                                                       ^
Language: C++

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int N,W;cin>>N>>W;
    const int MAX_V=100001;
    V w(N),v(N);rep(i,N)cin>>w[i]>>v[i];
    vector<vector<ll>>dp(N+1,vector<ll>(MAX_V));//INFで初期化
    rep(i,N+1)rep(j,MAX_V)dp[i][j]=MAXX;
    //dp[i][sum_v]はi-1番目までの商品を使ってvalueがsum_v以上になるように選んだ時の重量の最小
    dp[0][0]=0;//初期条件
    REP(i,N){
        rep(sum_v,MAX_V){
            if(sum_v-v[i]>=0)dp[i][sum_v]=min(dp[i-1][sum_v],dp[i-1][sum_v-v[i-1]]+w[i-1]);//i-1番目を使う
            dp[i][sum_v]=min(dp[i-1][sum_v],dp[i][sum_v]);//i-1番目を使わない
            //printf("dp[%d][%d]=%lld\n",i+1,sum_v,dp[i+1][sum_v]);
        }
    }
    ll ans=0;
    for(int i=MAX_V;i>=0,i--){//dpの値がW以下のうちでsum_vの最大を保存
        if(dp[N][i]<=W)ans=i;
    }
    cout<<ans<<endl;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:44:29: error: expected ';' before ')' token
   44 |     for(int i=MAX_V;i>=0,i--){//dpの値がW以下のうちでsum_vの最大を保存
      |                             ^
      |                             ;
Language: C++

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

using namespace std;

int main(){
    int N;
    int napW;

    cin >> N;
    cin >> napW;

    vector<int> w(N);
    vector<long long> v(N);

    vector<vector<long long>>  dp(N+1,vector<long long>(napW+1,0));



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



    for (int i = 0; i <N; ++i) {
        for (int W = 0; W <= napW ; ++W) {
            if(W - w[i] >= 0){
                dp[i+1][W] = max(dp[i][W],dp[i][W-w[i]] + v[i]);
            }else{
                dp[i+1][W] = dp[i][W];
            }
        }
    }

    cout << dp[N][napW] <<endl;#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int napW;

    cin >> N;
    cin >> napW;

    vector<int> w(N);
    vector<long long> v(N);

    vector<vector<long long>>  dp(N+1,vector<long long>(napW+1,0));



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



    for (int i = 0; i <N; ++i) {
        for (int W = 0; W <= napW ; ++W) {
            if(W - w[i] >= 0){
                dp[i+1][W] = max(dp[i][W],dp[i][W-w[i]] + v[i]);
            }else{
                dp[i+1][W] = dp[i][W];
            }
        }
    }

    cout << dp[N][napW] <<endl;


}



    for (int i = 0; i <N+1; ++i) {
        for (int w = 0; w <napW+1; ++w) {
            cout << dp[i][w] << " ";
        }
        cout << "\n";
    }

}



Compiler output:
a.cc:38:32: error: stray '#' in program
   38 |     cout << dp[N][napW] <<endl;#include <iostream>
      |                                ^
a.cc: In function 'int main()':
a.cc:38:33: error: 'include' was not declared in this scope
   38 |     cout << dp[N][napW] <<endl;#include <iostream>
      |                                 ^~~~~~~
a.cc:38:50: error: expected primary-expression before '>' token
   38 |     cout << dp[N][napW] <<endl;#include <iostream>
      |                                                  ^
a.cc:42:1: error: expected primary-expression before 'using'
   42 | using namespace std;
      | ^~~~~
a.cc:44:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   44 | int main(){
      |         ^~
a.cc:44:9: note: remove parentheses to default-initialize a variable
   44 | int main(){
      |         ^~
      |         --
a.cc:44:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:44:11: error: a function-definition is not allowed here before '{' token
   44 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define F(i,n) for(int i=0;i<n;i++)
#define VE(i,v) for(int i = 0;i < (v).size();i++)
using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned int ui;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef pair<ll,ll> pll;
typedef vector<pll> vpll; 


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T=1;
	
	
	

	for(int tc = 0; tc < T; tc++)
	{
		int N;
		ll W;
		cin>> N>>W;
		vector<pair<ll, int> > items(N);
		for(int i =0; i < N; i++)
		{
			cin>>items[i].first>>items[i].second;
		}
		sort(all(items));
		int ans = 0;
		map<<ll, int> hm;
		hm[0] = 0;
		set<ll> dp;
		dp.insert(0);
		for(int i =0; i < N; i++)
		{
			set temp(all(dp));
			for(ll x: dp)
			{
				temp.insert(x);
				temp.insert(x+items[i].first);
				hm[x+items[i].first] = max(hm[x+items[i].first], hm[x] + items[i].second);
				if(x+items[i].first<= W)
					ans = max(ans, hm[x+items[i].first]);
			}
			dp = temp;
			/*cout<<i<<": ";
			for(auto z:dp)
				cout<<z<<" ";
			cout<<"\n";*/
		}




		
		cout<<ans<<"\n";
	}

 
 
 
	return 0;
}
 
 


Compiler output:
a.cc: In function 'int main()':
a.cc:44:20: error: expected unqualified-id before '<<' token
   44 |                 map<<ll, int> hm;
      |                    ^~
a.cc:45:17: error: 'hm' was not declared in this scope; did you mean 'tm'?
   45 |                 hm[0] = 0;
      |                 ^~
      |                 tm