criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.io.*; 
import java.util.*;
import java.util.Map.Entry;

public class Hey {

	

	public static void main(String[] args) throws IOException {
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int  n =Integer.parseInt(ana.nextToken()) ; 
		int siz = Integer.parseInt(ana.nextToken())  ;
		long v[]= new long[n] ; int w []=new int[n] ; 
		for(int i=0 ; i<n ;i++)
		{
			ana = new StringTokenizer(jk.readLine()) ;
			w[i] = Integer.parseInt(ana.nextToken()) ; 
			v[i]= Long.parseLong(ana.nextToken())  ;
		}
		long dp[][]= new long[n][siz+1]  ;
		for(int i=0 ;i<n ;i++)
		{
			for(int j=0 ; j<siz+1 ;j++) dp[i][j]=-1 ; 
		}
		
		dp[0][0]=0 ; dp[0][w[0]]= v[0] ; 
		for(int i=1 ; i<n ;i++)
		{
			for(int we=0 ;we<=siz ;we++ )
			{
				long y = dp[i-1][we] ; 
				if(y!=-1)
				{
					dp[i][we]= Long.max(dp[i][we], dp[i-1][we]) ;
					if(we+w[i]<=siz) dp[i][we+w[i]] = Long.max(dp[i][we+w[i]], dp[i-1][we]+v[i]) ; 
				}
			}
		}
		long res = 0 ;
		for(int j=0 ; j<=siz ;j++) res = Long.max(res, dp[n-1][j]) ;
		out.println(res);
		
		out.flush(); 
	}

}




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

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, W;
  cin >> N >> W;
  int w[105], v[105];
  int a[100005][101];
  rep(i, N){
    cin >> w[i] >> v[i];
  }

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

  cout << dp[W][N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   26 |         dp[0][j] = 0;
      |         ^~
      |         dup
a.cc:29:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   29 |           dp[i][j] = max(dp[i-w[j]][j-1]+v[j], dp[i][j-1]);
      |           ^~
      |           dup
a.cc:31:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   31 |           dp[i][j] = dp[i][j-1];
      |           ^~
      |           dup
a.cc:37:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   37 |   cout << dp[W][N-1] << endl;
      |           ^~
      |           dup
Language: C

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <cstring>
#include <string>

using namespace std;
#define long long long

const int N = 1e2 + 10;
const long INF = 1e9 + 7;

int n;
long total, v[N], w[N], f[N][(int) 1e5 + 10];

int main()
{
//    freopen(".INP", "r", stdin);
//    freopen(".OUT", "w", stdout);
    cin.tie(NULL); ios_base::sync_with_stdio(false);

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

    for (int i = 1; i <= n; ++i)
        for (long j = 1; j <= total; ++j) {
            f[i][j] = f[i - 1][j];
            if (w[i] <= j) f[i][j] = max(f[i][j], f[i - 1][j - w[i]] + v[i]);
        }
    cout << f[n][total];

    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;

public class Knapsack {
	static int n, w;
	static int[] wt, val;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		w = sc.nextInt();
		wt = new int[n];
		val = new int[n];
		long [][] dp = new long[n][w+1];
		for(int i = 0; i < n; i++) {
			wt[i] = sc.nextInt();
			val[i] = sc.nextInt();
			Arrays.fill(dp[i], -1);
		}
		dp[n-1][w] = solve(w, n-1, dp);
		System.out.println(dp[n-1][w]);
		for(int i = 0; i < n; i++) {
			System.out.println(Arrays.toString(dp[i]));
		}
	}

	public static long solve(int awt, int item, long[][] dp) {
		if(dp[item][awt] != -1) {
			return dp[item][awt];
		}
		if(item == 0) {
			if(awt >= wt[item]) {
				return dp[item][awt] = val[item];
			} else {
				return dp[item][awt] = 0;
			}
		} else if(awt <= 0) {
			return ((dp[item][awt]=0));
		} else if(awt >= wt[item]) {
			return dp[item][awt] = max(
					solve(awt-wt[item], item-1, dp) + val[item],
					solve(awt, item-1, dp)
			);
		} else {
			return dp[item][awt] = solve(awt, item-1, dp);
		}
	}
	public static long max(long a, long b) {
		return Math.max(a, b);
	}
}

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

import numpy as np

n, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for i in range(n)])

dp = np.zeros((n + 1, W + 1))


def chmax(a, b):
    if a > b:
        return a
    else:
        return b


for i in range(n):
    for sum_w in range(W + 1):
        if sum_w >= wv[i, 0]:
            dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w - wv[i, 0]] + wv[i, 1])
        else:
            dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w])

print(int(dp[n , W]))


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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

using namespace std;


int N, W;
vector<int> w;
vector<int> v;


int memo[101][100001];


long long get_max_value(int i, int maxW) {
    if (i == N) {
        return 0;
    } else {
        long long a = v[i] + get_max_value(i+1, maxW - w[i]);
        long long b = get_max_value(i+1, maxW);

        if (w[i] > maxW) {
            return b;
        } else {
            return max(a, b);
        }
    }
}



long long get_max_value_using_memo_cache(int i, int maxW) {
    if (memo[i][maxW] != -1) {
        return memo[i][maxW];
    }

    if (i == N) {
        return 0;
    } else {
        long long ans;
        long long b = get_max_value_using_memo_cache(i+1, maxW);

        if (w[i] > maxW) {
            ans = b;
        } else {
            long long a = v[i] + get_max_value_using_memo_cache(i+1, maxW - w[i]);
            ans = max(a, b);
        }

        memo[i][maxW] = ans;
        return ans;
    }
}



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

    // recursive
    // long long ans = get_max_value(0, W);


    // memo
    memset(memo, -1, sizeof(memo));
    long long ans = get_max_value_using_memo_cache(0, W);
    
   
    // DP

    cout << ans;
    return 0;
}




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

import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w = sc.nextInt();
    long dp = new long[w+1];
    dp[0] = 0;
    int wt[] = new int[n];
    int v[] = new int[n];
    long ans = 0;
    for (int i=0; i<n; i++) {
      for (int W=w; W-wt[i]>=0; W--) {
        dp[W] = Math.max(dp[W], dp[W-wt[i]] + v[i]);
        ans = Math.max(ans, dp[W]);
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:8: error: incompatible types: long[] cannot be converted to long
    long dp = new long[w+1];
              ^
Main.java:9: error: array required, but long found
    dp[0] = 0;
      ^
Main.java:15: error: array required, but long found
        dp[W] = Math.max(dp[W], dp[W-wt[i]] + v[i]);
          ^
Main.java:15: error: array required, but long found
        dp[W] = Math.max(dp[W], dp[W-wt[i]] + v[i]);
                           ^
Main.java:15: error: array required, but long found
        dp[W] = Math.max(dp[W], dp[W-wt[i]] + v[i]);
                                  ^
Main.java:16: error: array required, but long found
        ans = Math.max(ans, dp[W]);
                              ^
6 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n;i++)
#define REP(i, n) for (int i = 0; i <= n;i++)
ll dp[105][100005];

void DP(j){
    if(j>W)
        break;
    
}
int main(){
    int n,W;
    cin >> n >> W;
    ll sina[n][2];
    rep(i,n) cin>>sina[i][0]>>sina[i][1];
    REP(i,n)
        REP(j, W)
            dp[i][j] = -INF;
    dp[0][0] = 0;
    rep(i, n){
       REP(j,W){
           if(j<sina[i][1])
               dp[i + 1][j] = dp[i][j];
            else{
                dp[i + 1][j] = max(dp[i][j], dp[i][j - sina[i][1]] + sina[i][0]);
            }
       }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Compiler output:
a.cc:9:6: error: variable or field 'DP' declared void
    9 | void DP(j){
      |      ^~
a.cc:9:9: error: 'j' was not declared in this scope; did you mean 'jn'?
    9 | void DP(j){
      |         ^
      |         jn
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
  long long int dp[n+1][w+1];
  
  
  vector<int>wt(n);
  vector<int>value(n);
  for(int i=0;i<n;i++)
    cin>>wt[i]>>v[i];
   for(int i=0;i<=n;i++)
     for(int j=0;j<=w;j++){
       if(i==0||j==0)
         dp[i][j]=0;
       else if(j>=wt[i-1])
         dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
       else
         dp[i][j]=dp[i-1][j];
     }
  cout<<dp[n][w];
  return 0;
}
       
 
 
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'v' was not declared in this scope
   12 |     cin>>wt[i]>>v[i];
      |                 ^
a.cc:18:53: error: 'val' was not declared in this scope; did you mean 'value'?
   18 |          dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
      |                                                     ^~~
      |                                                     value
Language: C

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



int main(){
    int i, j, k;
    int maxWeight, Items;
    scanf("%d %d",&Items, &maxWeight);
    int weight[Items+10], value[Items+10];
    for(i = 1; i <= Items; i++)
    {
        scanf("%d %d",&weight[i],&value[i]);
    }
    int DP[Items+100][maxWeight+100000];
    memset(DP, 0, sizeof(DP));

    for(i = 1; i <= Items; i++)
    {
        for(j = 0; j <= maxWeight; j++)
        {
            //SKIP
            DP[i][j] = DP[i-1][j];

            //Take
            if(weight[i] <= j)
            {
                DP[i][j] = max( DP[i][j], value[i] + DP[i-1][j - weight[i]] );
            }
        }
    }
    printf("%d\n",DP[Items][maxWeight]);


    return 0;
}



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

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



int main(){
    int i, j, k;
    int maxWeight, Items;
    scanf("%d %d",&Items, &maxWeight);
    int weight[Items+10], value[Items+10];
    for(i = 1; i <= Items; i++)
    {
        scanf("%d %d",&weight[i],&value[i]);
    }
    int DP[Items+10][maxWeight+10];
    memset(DP, 0, sizeof(DP));

    for(i = 1; i <= Items; i++)
    {
        for(j = 0; j <= maxWeight; j++)
        {
            //SKIP
            DP[i][j] = DP[i-1][j];

            //Take
            if(weight[i] <= j)
            {
                DP[i][j] = max( DP[i][j], value[i] + DP[i-1][j - weight[i]] );
            }
        }
    }
    printf("%d\n",DP[Items][maxWeight]);


    return 0;
}



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

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

public class Knapsack1 {


    public static long getMaxValue(int[] weights, int[] values, int numWeights, int weightPossible) {
        long[] memo = new long[numWeights];
        Arrays.fill(memo, -1);
        return getMaxValueHelper(0, weights, values, numWeights, weightPossible, memo);
    }

    private static long getMaxValueHelper(int i, int[] weights, int[] values, int numWeights, int weightPossible, long[] memo) {
        if(i == numWeights) {
            return 0;
        }

        if(weightPossible == 0) {
            return 0;
        }

        if(memo[i] != -1) {
            return memo[i];
        }

        long poss1 = (weightPossible - weights[i] >= 0) ? (long) values[i] + getMaxValueHelper(i+1, weights, values, numWeights, weightPossible - weights[i], memo) : 0;
        long poss2 = getMaxValueHelper(i+1, weights, values, numWeights, weightPossible, memo);
        return memo[i] = Math.max(poss1, poss2);
    }


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

        int numWeights = scanner.nextInt();
        int bagSize = scanner.nextInt();

        int[] weights = new int[numWeights];
        int[] value = new int[numWeights];

        for(int i=0; i<numWeights; i++) {
            weights[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }

        System.out.println(getMaxValue(weights, value, numWeights, bagSize));

    }
}

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

#include <bits/stdc++.h>
 
using namespace std;
int main()
{
 int n,w;
  cin>>n>>w;
  int a[n][2];
  for(int i=0;i<n;i++)
  cin>>a[i][0]>>a[i][1];
 int dp[n+1][w+1];
  
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=m;j++)
    {
      if(i==0 ||j==0)
       dp[i][j]=0;
      else if(j>=a[i-1][0])
       dp[i][j]=max(a[i-1][1]+dp[i-1][j-a[i-1][0]],dp[i-1][j]);
      else
        dp[i][j]=dp[i-1][j];
    }
   }
  
  
  cout<<dp[n][w];
  return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: 'm' was not declared in this scope
   15 |     for(int j=0;j<=m;j++)
      |                    ^
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
int main()
{
 int n,w;
  cin>>n>>w;
  int a[n][2];
  for(int i=0;i<n;i++)
  cin>>a[i][0]>>a[i][1];
 int dp[n+1][w+1];
  
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=m;j++)
    {
      if(i==0 ||j==0)
       dp[i][j]=0;
      else if(j>=a[i-1][0])
       dp[i][j]=max(a[i-1][1]+dp[i-1][j-a[i-1][0]],dp[i-1][j]);
      else
        d[i][j]=dp[i-1][j];
    }
   }
  
  
  cout<<dp[n][w];
  return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: 'm' was not declared in this scope
   15 |     for(int j=0;j<=m;j++)
      |                    ^
a.cc:22:9: error: 'd' was not declared in this scope
   22 |         d[i][j]=dp[i-1][j];
      |         ^
Language: Java

import java.util.Scanner;

public class test {
	static int N;
	static int W;
	static int[] w;
	static int[] v;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		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();
		}

		long value = dp(0, W);

		System.out.println(value);
	}
	static long dp(int i, int u) {
		if(i >= N)
			return 0;
		long value;
		long v1 = 0;
		long v2 = 0;
		if(u >= w[i]) {
			v1 = dp(i + 1, u - w[i]) + v[i];
		}
		value = v2 = dp(i + 1, u);
		if(v1 > v2) {
			value = v1;
		}
		return value;
	}
}


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

#include <bits/stdc++.h>

using namespace std;

class DKnapsack1 {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n, w;
        cin >> n >> w;
        vector<vector<int>> wv_vec(n, vector<int>(2, 0));
        for (int i = 0; i < n; ++i) {
            cin >> wv_vec[i][0];
            cin >> wv_vec[i][1];
        }
        vector<vector<long long>> dp(n + 1, vector<long long>(w + 1, 0));
        dp[0][0] = 0;
        for (int i = 0; i < n; ++i) {
            long long now_w = wv_vec[i][0];
            long long now_v = wv_vec[i][1];
            for (int j = 0; j < w + 1; ++j) {
                if (j >= now_w)dp[i + 1][j] = max(dp[i][j - now_w] + now_v, dp[i][j]);
                else dp[i + 1][j] = dp[i][j];
            }
        }
        long long ans = *max_element(dp[n].begin(), dp[n].end());
        cout << ans << endl;
    }
};

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

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll dp[110][100100];
int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,w;
    cin >> n >> w;
    vector<ll> W(n),v(n);
    rep(i,n){
      cin >> W[i] >> v[i];
    }
    rep(i,n){
      rep(j,w+1){
        if(w[i] > j) continue;
        chmax(dp[i+1][j], dp[i][j-W[i]] + v[i]);
        chmax(dp[i+1][j], dp[i][j]);
      }
    }
    print(dp[n][w]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:13: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   52 |         if(w[i] > j) continue;
      |             ^
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll dp[110][100100];
int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,w;
    cin >> n >> w;
    vector<ll> w(n);
    vector<ll> v(n);
    rep(i,n){
      cin >> w[i] >> v[i];
    }
    rep(i,n){
      rep(j,w+1){
        if(w[i] > j) continue;
        chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
        chmax(dp[i+1][j], dp[i][j]);
      }
    }
    print(dp[n][w]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:16: error: conflicting declaration 'std::vector<long long int> w'
   46 |     vector<ll> w(n);
      |                ^
a.cc:44:10: note: previous declaration as 'll w'
   44 |     ll n,w;
      |          ^
a.cc:49:15: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   49 |       cin >> w[i] >> v[i];
      |               ^
a.cc:53:13: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   53 |         if(w[i] > j) continue;
      |             ^
a.cc:54:36: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   54 |         chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
      |                                    ^
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll dp[110][100100];
int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,w;
    cin >> n >> w;
    vector<ll> w(n),v(n);
    rep(i,n){
      cin >> w[i] >> v[i];
    }
    rep(i,n){
      rep(j,w+1){
        if(w[i] > j) continue;
        chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
        chmax(dp[i+1][j], dp[i][j]);
      }
    }
    print(dp[n][w]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:16: error: conflicting declaration 'std::vector<long long int> w'
   46 |     vector<ll> w(n),v(n);
      |                ^
a.cc:44:10: note: previous declaration as 'll w'
   44 |     ll n,w;
      |          ^
a.cc:48:15: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   48 |       cin >> w[i] >> v[i];
      |               ^
a.cc:52:13: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   52 |         if(w[i] > j) continue;
      |             ^
a.cc:53:36: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   53 |         chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
      |                                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define	pii pair<int,int>
#define vi vector<int>
 
 
 
int solve(int n, int wt, int v[], int w[])
{
	int dp[wt+1];
  	for(int i=0;i<=wt;i++)	dp[i]=0;
	for(int i=0;i<n;i++){
		for(int j=wt;j>=w[i];j--)
			dp[j] = max(v[i]+dp[j-w[i]], dp[j]);
	}
	return d[wt];
}
 
int main()
{
	int n,wt;	cin>>n>>wt;
	int w[n],v[n];
	for(int i=0;i<n;i++)	cin>>w[i]>>v[i];
	cout<<solve(n,wt,v,w)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve(int, int, int*, int*)':
a.cc:18:16: error: 'd' was not declared in this scope; did you mean 'dp'?
   18 |         return d[wt];
      |                ^
      |                dp
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define	pii pair<int,int>
#define vi vector<int>
 
 
 
int solve(int n, int wt, int v[], int w[])
{
	int dp[wt+1];
	for(int i=0;i<n;i++){
		for(int j=wt;j>=w[i];j--)
			dp[j] = max(v[i]+dp[j-w[i]], dp[j]);
	}
	return d[wt];
}
 
int main()
{
	int n,wt;	cin>>n>>wt;
	int w[n],v[n];
	for(int i=0;i<n;i++)	cin>>w[i]>>v[i];
	cout<<solve(n,wt,v,w)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve(int, int, int*, int*)':
a.cc:17:16: error: 'd' was not declared in this scope; did you mean 'dp'?
   17 |         return d[wt];
      |                ^
      |                dp
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define	pii pair<int,int>
#define vi vector<int>
 
 
 
int solve(int n, int wt, int v[], int w[])
{
	int dp[wt+1];
	for(int i=0;i<n;i++){
		for(int j=wt;j>=w[i];j--)
			dp[j] = max(v[i]+dp[j-w[i]], dp[i]);
	}
	return d[wt];
}
 
int main()
{
	int n,wt;	cin>>n>>wt;
	int w[n],v[n];
	for(int i=0;i<n;i++)	cin>>w[i]>>v[i];
	cout<<solve(n,wt,v,w)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve(int, int, int*, int*)':
a.cc:17:16: error: 'd' was not declared in this scope; did you mean 'dp'?
   17 |         return d[wt];
      |                ^
      |                dp
Language: C++

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

int N, W, w[100], v[100] dp[100][100001];
int main(){
    scanf("%d%d", &N, &W);
    for(int i=0; i<N; i++) scanf("%d%d", w+i, v+i);
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            dp[i][j] = max(i!=0 ? dp[i-1][j] : 0, i!=0 && j >= w[i] ? dp[i-1][j-w[i]]+v[i] : 0);
        }
    }
    printf("%d\n", dp[N-1][W]);
}

Compiler output:
a.cc:4:26: error: expected initializer before 'dp'
    4 | int N, W, w[100], v[100] dp[100][100001];
      |                          ^~
a.cc: In function 'int main()':
a.cc:7:47: error: 'v' was not declared in this scope
    7 |     for(int i=0; i<N; i++) scanf("%d%d", w+i, v+i);
      |                                               ^
a.cc:10:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |             dp[i][j] = max(i!=0 ? dp[i-1][j] : 0, i!=0 && j >= w[i] ? dp[i-1][j-w[i]]+v[i] : 0);
      |             ^~
      |             dup
a.cc:10:87: error: 'v' was not declared in this scope
   10 |             dp[i][j] = max(i!=0 ? dp[i-1][j] : 0, i!=0 && j >= w[i] ? dp[i-1][j-w[i]]+v[i] : 0);
      |                                                                                       ^
a.cc:13:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |     printf("%d\n", dp[N-1][W]);
      |                    ^~
      |                    dup
Language: C++

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

int N, W, w[100], v[100] dp[100][100001];
int main(){
    scanf("%d%d", &N, &W);
    for(int i=0; i<N; i++) scanf("%d%d", w+i, v+i);
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            dp[i][j] = max(i!=0 ? dp[i-1][j] : 0, i!=0 && j >= w[i] ? dp[i-1][j-w[i]]+v[i] : 0);
        }
    }
    cout << dp[N-1][W] << endl;
}

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Atcoder {

	static int n, k;
	static int[][] arr;
	static long[][] memo;
	static boolean f = false;
	static boolean t = false;
	static int OO = (int) 1e18;

	static long dp(int i, int k) {
		if (k < 0)
			return -OO;
		if (i == n) {
			return 0;
		}

		if (memo[k][i] != -1)
			return memo[k][i];

		long take = arr[i][1] + dp(i + 1, k - arr[i][0]);
		long leave = dp(i + 1, k);

		return memo[k][i] = Math.max(take, leave);
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);

		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());

		arr = new int[n + 1][2];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			arr[i][0] = Integer.parseInt(st.nextToken());
			arr[i][1] = Integer.parseInt(st.nextToken());
		}
		memo = new long[k+1][n+1];

		for (int i = 0; i < k+1; i++)
			Arrays.fill(memo[i], -1);
		long ans = -1;

		for(int i = 0;i<n;i++)
			ans= Math.max(ans, dp(i, k));
		pw.print(ans);
		pw.close();
	}
}


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

#include<bits/stdc++.h>
using namespace std;
int fnc(int we[],int v[],int i,int val,int n,int w)
{
  if(i==n-1)
  {
    if(w<we[i])
      return val;
    else
      return val+v[i];
  }
  else if(i<n)
  {
    if(w>=we[i])
    return max(fnc(we,v,i+1,val+v[i],n,w-we[i]),fnc(we,v,i+1,val,n,w));
    else
      return fnc(we,v,i+1,val,n,w);
  }
}
int main()
{
 int n,w;
  cin>>n>>w;
  int i=0;
  int we[n];
  int val[n];
  while(i<n)
  {
    cin>>we[i]>>val[i];
    i++;
  }
  int x[][];
  int v=0;
  cout<<fnc(we,val,0,v,n,w)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:7: error: declaration of 'x' as multidimensional array must have bounds for all dimensions except the first
   32 |   int x[][];
      |       ^
a.cc: In function 'int fnc(int*, int*, int, int, int, int)':
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const ll INF = 1e9;

int W[101];
int V[101];
ll dp[101][1000001] = {0};
ll sumW[101][1000001] = {0};


int main() {
    int N, limW; cin >> N >> limW;

    REP(i, N) {
        cin >> W[i] >> V[i];
    }

    REP(i, N) {
        ll score = 0;
        REP(sumW, limW+1) {
            if (sumW >= W[i]) { // pickup this item
                chmax(score, dp[i][sumW-W[i]] + V[i]);

            } else { // not pickup
                chmax(score, dp[i][sumW]);
            }
            dp[i+1][sumW] = score;
        }
    }

    // REP(i, N+1) {
    //     REP(w, limW+1) {
    //         cout << dp[i][w] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[N][limitW] << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:19: error: 'limitW' was not declared in this scope; did you mean 'limW'?
   43 |     cout << dp[N][limitW] << endl;
      |                   ^~~~~~
      |                   limW
Language: C++

#include <bits/stdc++.h>
using namespace std;
void chmax(long long& a,long long b){
  if(a < b){
    a = b;
  }
}

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> weight(N), value(N);
  for(int i = 0; i < N; i++){
    cin >> weight.at(i) >> value.at(i);
  }
  vector<vector<int64_t>> dp(N + 10, vector<int64_t>(10000000, 0));
  for(int i = 0; i < N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(weight.at(i) <= sum_w){
        chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight.at(i)) + value.at(i));
      }
      chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'}
   20 |         chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight.at(i)) + value.at(i));
      |               ~~~~~~~~~~~~~~~^~~~~~~
a.cc:3:23: note:   initializing argument 1 of 'void chmax(long long int&, long long int)'
    3 | void chmax(long long& a,long long b){
      |            ~~~~~~~~~~~^
a.cc:22:28: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'}
   22 |       chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
      |             ~~~~~~~~~~~~~~~^~~~~~~
a.cc:3:23: note:   initializing argument 1 of 'void chmax(long long int&, long long int)'
    3 | void chmax(long long& a,long long b){
      |            ~~~~~~~~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
void chmax(int& a,int b){
  if(a < b){
    a = b;
  }
}

int main(){
  int N, W;
  cin >> N >> W;
  vector<long long> weight(N), value(N);
  for(int i = 0; i < N; i++){
    cin >> weight.at(i) >> value.at(i);
  }
  vector<vector<long long>> dp(N + 10, vector<long long>(10000000, 0));
  for(long long i = 0; i < N; i++){
    for(long long sum_w = 0; sum_w <= W; sum_w++){
      if(weight.at(i) <= sum_w){
        chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight.at(i)) + value.at(i));
      }
      chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   20 |         chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight.at(i)) + value.at(i));
      |               ~~~~~~~~~~~~~~~^~~~~~~
a.cc:3:17: note:   initializing argument 1 of 'void chmax(int&, int)'
    3 | void chmax(int& a,int b){
      |            ~~~~~^
a.cc:22:28: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   22 |       chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
      |             ~~~~~~~~~~~~~~~^~~~~~~
a.cc:3:17: note:   initializing argument 1 of 'void chmax(int&, int)'
    3 | void chmax(int& a,int b){
      |            ~~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
void chmax(int& a,int b){
  if(a < b){
    a = b;
  }
}

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> weight(N), value(N);
  for(int i = 0; i < N; i++){
    cin >> weight.at(i) >> value.at(i);
  }
  vector<vector<long long>> dp(N + 10, vector<long long>(10000000, 0));
  for(int i = 0; i < N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(weight.at(i) <= sum_w){
        chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight.at(i)) + value.at(i));
      }
      chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   20 |         chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight.at(i)) + value.at(i));
      |               ~~~~~~~~~~~~~~~^~~~~~~
a.cc:3:17: note:   initializing argument 1 of 'void chmax(int&, int)'
    3 | void chmax(int& a,int b){
      |            ~~~~~^
a.cc:22:28: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   22 |       chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
      |             ~~~~~~~~~~~~~~~^~~~~~~
a.cc:3:17: note:   initializing argument 1 of 'void chmax(int&, int)'
    3 | void chmax(int& a,int b){
      |            ~~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
void chmax(int& a,int b){
  if(a < b){
    a = b;
  }
}

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> weight(N), value(N);
  for(int i = 0; i < N; i++){
    cin >> weight(i) >> value(i);
  }
  vector<vector<int>> dp(N + 10, vector<int>(10000000, 0));
  for(i = 0; i < N; i++){
    for(sum_w; sum_w <= W; sum_w++){
      if(weight(i) <= sum_w){
        chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight(i)) + value(i));
      }
      chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: no match for call to '(std::vector<int>) (int&)'
   14 |     cin >> weight(i) >> value(i);
      |            ~~~~~~^~~
a.cc:14:30: error: no match for call to '(std::vector<int>) (int&)'
   14 |     cin >> weight(i) >> value(i);
      |                         ~~~~~^~~
a.cc:17:7: error: 'i' was not declared in this scope
   17 |   for(i = 0; i < N; i++){
      |       ^
a.cc:18:9: error: 'sum_w' was not declared in this scope
   18 |     for(sum_w; sum_w <= W; sum_w++){
      |         ^~~~~
Language: C++

#include <bits/stdc+.h>
using namespace std;
void chmax(int& a,int b){
  if(a < b){
    a = b;
  }
}

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> weight(N), value(N);
  for(int i = 0; i < N; i++){
    cin >> weight(i) >> value(i);
  }
  vector<vector<int>> dp(N + 10, vector<int>(10000000, 0));
  for(i = 0; i < N; i++){
    for(sum_w; sum_w <= W; sum_w++){
      if(weight(i) <= sum_w){
        chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - weight(i)) + value(i));
      }
      chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
    }
  }
  cout << dp.at(N).at(W) << endl;
}

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

import java.util.*;
public class Solution01{
	public static void main(String args[]) {
      Scanner scan = new Scanner(System.in);
      int noOfElements = scan.nextInt();
      int knapsackCapacity = scan.nextInt();
      int[] weight = new int[noOfElements+1];
      int[] value = new int[noOfElements+1];
      // items at i,j defines weight i, value j.
      weight[0]=0;
      value[0]=0;
      for(int i=1; i<noOfElements+1; i++){
        weight[i]=scan.nextInt();
        value[i]=scan.nextInt();
      }
      System.out.println(knapscak01(weight,value,knapsackCapacity));
      
	}
  
  	public static int knapscak01(int[] weight, int[] value ,int knapsackCapacity) {
      int[][] dp= new int[value.length][knapsackCapacity+1];
      for(int i=1; i<weight.length; i++) {
        for(int j=0; j<=knapsackCapacity; j++) {
          if(j-weight[i]>=0) {
            dp[i][j]=Math.max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j]);
          }else {
        	dp[i][j]=dp[i-1][j];
          }
        }
      }
      print(dp);
      return dp[value.length-1][knapsackCapacity];
    }
  	
  	public static void print(int[][] dp) {
  		for(int i=0; i<dp.length; i++) {
  			for(int j=0; j<dp[i].length; j++) {
  				System.out.print(dp[i][j]);
  			}
  			System.out.println();
  		}
  	}
  
}


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

#include<bits/stdc++.h>
using namespace std;
int  main()
{
	int N,W;
  	cin >> N >> W;
  	int weight[N];
  	int value[N];
  	for(int i=0;i<N;i++)
      cin >> weight[i] >> value[i];
  
  	int dp[N+1][W+1];
  	for(int i=0;i<=N;i++)
    {
    	for(int j=0;j<=W;j++)
        {
          if(i==0 || j==0)
            dp[i][j]=0;
          else if(j>=weight[i-1])
          {
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]]+value[i-1]);
          }
          else
            dp[i][j]=dp[i-1][j];
        }
    }
  
  cout << dp[N][W];

Compiler output:
a.cc: In function 'int main()':
a.cc:28:20: error: expected '}' at end of input
   28 |   cout << dp[N][W];
      |                    ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

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

long long dp[110][100010];//i-1 番目までの品物から重さが sum_w を超えないように選んだときの、価値の総和の最大値

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: 'NN' was not declared in this scope; did you mean 'N'?
   23 | for(int i = 0; i < NN; i++){
      |                    ^~
      |                    N
Language: C++

// Knapsack 1
#include <climits>
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll n, w;
ll dp[INT_MAX];
ll arr[INT_MAX][2];

ll value(ll x, ll w)
{
    if (dp[x] != -1)
        return dp[x];
    if (x == n - 1)
    {
        if (arr[x][0] <= w)
            return arr[x][1];
        else
            return 0;
    }
    dp[x] = max(value(x + 1, w - arr[x][0]) + arr[x][1], value(x + 1, w));
    return dp[x];
}

int main()
{
    cin >> n >> w;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i][0] >> arr[i][1];
    }
    for (int i = 0; i < INT_MAX; i++)
    {
        dp[i] = -1;
    }
    cout << value(0, w);
}

Compiler output:
/tmp/ccJ8B3Hp.o: in function `value(long long, long long)':
a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccJ8B3Hp.o
a.cc:(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccJ8B3Hp.o
a.cc:(.text+0xc4): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccJ8B3Hp.o
a.cc:(.text+0xf4): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccJ8B3Hp.o
/tmp/ccJ8B3Hp.o: in function `main':
a.cc:(.text+0x197): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccJ8B3Hp.o
a.cc:(.text+0x1c3): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccJ8B3Hp.o
collect2: error: ld returned 1 exit status
Language: C++

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

#define ll                      long long int
#define rloopl(i,a,b)           for(ll i=(ll)a;i<=(ll)b;++i)

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

    ll n,W;
    cin>>n>>W;
    vector<ll> v(n+1);
    vector<ll> w(n+1);
    // int dp[n+5];
    loopl(i,0,n)
    {
        cin>>w[i]>>v[i];
    }    
    ll dp[n+1][W+1];
    rloopl(i,0,n)
    {
        rloopl(j,0,W)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(w[i-1]<=j)
                dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
            else 
                dp[i][j] = dp[i-1][j];
        }
    }


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


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: 'i' was not declared in this scope
   16 |     loopl(i,0,n)
      |           ^
a.cc:16:5: error: 'loopl' was not declared in this scope; did you mean 'rloopl'?
   16 |     loopl(i,0,n)
      |     ^~~~~
      |     rloopl
Language: C++

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int ans;
void knapsack(int i, int k, vector<pair<int, int>>&v, long long int val){
    if(k>=0)
        ans=max(ans, val);
    
    if(i==v.size()||k<0)
        return;
    
    knapsack(i+1, k-v[i].first, v, val+v[i].second);
    knapsack(i+1, k, v, val);
}
int main() {
    int n,k;
    ans=INT_MIN;
    cin>>n>>k;
    vector<pair<int,int>>vec;
    for(int i=0;i<n;i++){
        pair<int,int>p;
        cin>>p.first;
        cin>>p.second;
        vec.push_back(p);
    }
    knapsack(0,k,vec,0LL);
    cout<<ans;
}


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

#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int N;
long long W,weight[110],value[110];

long long dp[110][100100] = {0};

int main(){
  cin >> N >> W;
  for(int i=0;i<N;i++){
    cin >> weight[i] >> value[i];
  }
  for(int i=0;i<N;i++){
    for(int sum_w = 0;sum_w <= W;sum_w++;){
      
      if(sum_w - weight[i] >= 0){
        chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      
      chmax(dp[i + 1][sum_w],dp[i][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:41: error: expected ')' before ';' token
   18 |     for(int sum_w = 0;sum_w <= W;sum_w++;){
      |        ~                                ^
      |                                         )
a.cc:18:42: error: expected primary-expression before ')' token
   18 |     for(int sum_w = 0;sum_w <= W;sum_w++;){
      |                                          ^