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

#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e2+5;
const int mxM = 1e5+5;
long long dp[mxN][mxM];
int n,w,wei[mxN],val[mxN];
int main(){
	cin >> n >> w;
	for(int i = 1; i<=n; i++){
		cin >> wei[i] >> val[i];
	}
	for(int i = 0; i<=n; i++){
		for(int j = 0;j<=w; j++){
			dp[i][j] = 0;
		}
	}
	for(int i = 1; i<=n; i++){
		for(int j = 1;j<=w; j++){
			if(j-wei[i]>=0&&i-1>=0) dp[i][j] = max(dp[i-1][j],dp[i-1][j-wei[i]]+val[i]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	int ans = 0;
//	for(int i =1; i<=n; i++){
//		for(int j = 1; j<=w; j++){
//			cout << dp[i][j] << " ";
//		}
//		cout << endl;
//	}
	for(int i = 0; i<=n; i++){
		ans = max(ans,dp[i][w]);
	}
	cout << ans << endl;
}

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

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,W;
 
 
int32_t main()
{
    cin>>n>>W;
    int w[n+2];
    int v[n+2];
    int dp[n+1][W+1];
    for(int i=1;i<=n;i++){cin>>w[i]>>v[i];}
    for(int wi=0;wi<=W;wi++){
        dp[1][wi] = 0;
    }
    
        dp[1][w[1] = v[1];
    
    for(int i=2;i<=n;i++){
        for(int wi = 0; wi<=W;wi++){
            dp[i][wi] = dp[i-1][wi];
            if(wi>=w[i])
            {
                dp[i][wi] = max(dp[i][wi], v[i]+dp[i-1][wi-w[i]]);
            }
        }
    }
    cout<<dp[n][W];
 
 
 
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:19:26: error: expected ']' before ';' token
   19 |         dp[1][w[1] = v[1];
      |                          ^
      |                          ]
Language: Java

import java.util.*;
import java.io.*;
public class ok{
	public static long knapsack(int[] weights,int[] values,int capacity,int n,long[][] memo){
		if(memo[n][capacity]!=-1){
			return memo[n][capacity];
		}
		if(n==0 || capacity==0){
			return 0l;
		}
		if(weights[n-1]<=capacity){
			memo[n][capacity]=Math.max(values[n-1]+knapsack(weights,values,capacity-weights[n-1],n-1,memo),knapsack(weights,values,capacity,n-1,memo));
			return memo[n][capacity];
		}
		memo[n][capacity]=knapsack(weights,values,capacity,n-1,memo);
		return memo[n][capacity];

	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int capacity=Integer.parseInt(st.nextToken());
		int[] weights=new int[n];
		int[] values=new int[n];
		for(int i=0;i<n;i++){
			st = new StringTokenizer(br.readLine());
			weights[i]=Integer.parseInt(st.nextToken());
			values[i]=Integer.parseInt(st.nextToken());
		}
		long[][] memo=new long[n+1][capacity+1];
		for(int i=0;i<n+1;i++){
			Arrays.fill(memo[i],-1l);
		}
		System.out.println(knapsack(weights,values,capacity,n,memo));
	}
}

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

#include<bits/stdc++.h>
using namespace std;
int maxValue(int n,int c,int weights[],int values[])
{
  	int dp[n+1][w+1];
  	for(int i=0;i<=n;i++)
    {
      for(int w=0;w<=capacity;w++)
      {
        if(i==0||w==0)
          dp[i][w]=0;
        else if(w>=weights[i-1])
        {
          dp[i][w]=max(dp[i-1][w],values[i-1]+dp[i-1][w-weights[i-1]]);
        }
        else
          dp[i][w]=dp[i-1][w];
      }
    }
  return dp[n][w];
}
int main(){
  int n,capacity;
  cin>>n>>capacity;
  int weights[n],values[n];
  for(int i=0;i<n;i++)
  {
    cin>>weights[i]>>values[i];
  }
  cout<<maxValue(n,capacity,weights,values)<<"\n";
}

Compiler output:
a.cc: In function 'int maxValue(int, int, int*, int*)':
a.cc:5:21: error: 'w' was not declared in this scope
    5 |         int dp[n+1][w+1];
      |                     ^
a.cc:8:22: error: 'capacity' was not declared in this scope
    8 |       for(int w=0;w<=capacity;w++)
      |                      ^~~~~~~~
a.cc:11:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |           dp[i][w]=0;
      |           ^~
      |           dup
a.cc:14:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   14 |           dp[i][w]=max(dp[i-1][w],values[i-1]+dp[i-1][w-weights[i-1]]);
      |           ^~
      |           dup
a.cc:17:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |           dp[i][w]=dp[i-1][w];
      |           ^~
      |           dup
a.cc:20:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |   return dp[n][w];
      |          ^~
      |          dup
Language: C++

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

Compiler output:
a.cc: In function 'int knapsack(int*, int*, int, int)':
a.cc:11:63: error: expected ']' before ')' token
   11 |           l[i][j] = max(val[i-1] + l[i-1][j-wt[i-1], l[i-1][j]);
      |                                                               ^
      |                                                               ]
a.cc:11:24: error: no matching function for call to 'max(int)'
   11 |           l[i][j] = max(val[i-1] + l[i-1][j-wt[i-1], l[i-1][j]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:11:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |           l[i][j] = max(val[i-1] + l[i-1][j-wt[i-1], l[i-1][j]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
Language: C++

//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

void solve()
  {
	int n,w;
	cin>>n>>w;
	int wt[n],val[n];
	rep(i,n)cin>>wt[i]>>val[i];
	int dp[w+1];
	memset(dp,0,sizeof dp);
	
	rep(i,n)
	{
		repD(j,w,wt[i])
		{
			dp[j]=max(dp[j],dp[j-wt[i]]+val[i]);
			cout<<"dp "<<j<<" : "<<dp[j]<<e/ndl;
		}
	}
	// long long best = 0;
	// for(int i = 0;i<=w;i++) best = max(best,dp[i]);
	cout << dp[w] << endl;
	
	


  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:51:55: error: 'e' was not declared in this scope
   51 |                         cout<<"dp "<<j<<" : "<<dp[j]<<e/ndl;
      |                                                       ^
a.cc:51:57: error: 'ndl' was not declared in this scope; did you mean 'endl'?
   51 |                         cout<<"dp "<<j<<" : "<<dp[j]<<e/ndl;
      |                                                         ^~~
      |                                                         endl
Language: C++

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

void knapsack(ll n, ll W, ll w[], ll v[]){
  ll dp[n+1][W+1];
  for(ll i=0; i<n+1; i++){
  	for(ll j=0; j<W+1; j++){
      if(j == 0 || i==0){
        dp[i][j] =0;
      }
      else if(w[i-1] > j){
      	dp[i][j] = dp[i][j-1];
      }
      else{
        dp[i][j] = max(dp[i][j-1], v[i-1]+dp[i][j-w[i-1]]);
      }
    
    }
  }
  return dp[n][W];

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  for(ll i=0; i<n; i++){
    cin>>w[i]>>v[i];
  }
  ll ans = knapsack(n, W, w, v);
  cout<<ans<<"\n";   
  return 0;
}


Compiler output:
a.cc: In function 'void knapsack(ll, ll, ll*, ll*)':
a.cc:21:17: error: return-statement with a value, in function returning 'void' [-fpermissive]
   21 |   return dp[n][W];
      |          ~~~~~~~^
a.cc: In function 'int main()':
a.cc:35:20: error: void value not ignored as it ought to be
   35 |   ll ans = knapsack(n, W, w, v);
      |            ~~~~~~~~^~~~~~~~~~~~
Language: C++

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

void knapsack(ll n, ll W, ll w[], ll v[]){
  dp[n+1][W+1];
  for(ll i=0; i<n+1; i++){
  	for(ll j=0; j<W+1; j++){
      if(j == 0 || i==0){
        dp[i][j] =0;
      }
      else if(w[i-1] > j){
      	dp[i][j] = dp[i][j-1];
      }
      else{
        dp[i][j] = max(dp[i][j-1], v[i-1]+dp[i][j-w[i-1]]);
      }
    
    }
  }
  return dp[n][W];

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  for(ll i=0; i<n; i++){
    cin>>w[i]>>v[i];
  }
  ll ans = knapsack(n, W, w, v);
  cout<<ans<<"\n";   
  return 0;
}

Compiler output:
a.cc: In function 'void knapsack(ll, ll, ll*, ll*)':
a.cc:6:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
    6 |   dp[n+1][W+1];
      |   ^~
      |   dup
a.cc: In function 'int main()':
a.cc:35:20: error: void value not ignored as it ought to be
   35 |   ll ans = knapsack(n, W, w, v);
      |            ~~~~~~~~^~~~~~~~~~~~
Language: Java

import java.util.*;

class Main{
  static final Scanner in = new Scanner(System.in);
  static int knapSack(int W, int wt[], int val[], int n) 
    { 
        int i, w; 
        int K[][] = new int[n + 1][W + 1]; 
  
        // Build table K[][] in bottom up manner 
        for (i = 0; i <= n; i++) { 
            for (w = 0; w <= W; w++) { 
                if (i == 0 || w == 0) 
                    K[i][w] = 0; 
                else if (wt[i - 1] <= w) 
                    K[i][w] = Math.max( 
                        val[i - 1] + K[i - 1][w - wt[i - 1]], 
                        K[i - 1][w]); 
                else
                    K[i][w] = K[i - 1][w]; 
            } 
        } 
  
        return K[n][W]; 
    }
  
   public static void main(String[] args) throws Exception {
        int N = in.nextInt();
        int W = in.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

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

        for (int i = 0; i < N; i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
            
        }
     System.out.println(knapSack(W, wt, v, N));
   }
}


Compiler output:
Main.java:40: error: cannot find symbol
     System.out.println(knapSack(W, wt, v, N));
                                    ^
  symbol:   variable wt
  location: class Main
1 error
Language: Java

import java.util.*;

class Main{
  static final Scanner in = new Scanner(System.in);
  static int knapSack(int W, int wt[], int val[], int n) 
    { 
        int i, w; 
        int K[][] = new int[n + 1][W + 1]; 
  
        // Build table K[][] in bottom up manner 
        for (i = 0; i <= n; i++) { 
            for (w = 0; w <= W; w++) { 
                if (i == 0 || w == 0) 
                    K[i][w] = 0; 
                else if (wt[i - 1] <= w) 
                    K[i][w] = Math.max( 
                        val[i - 1] + K[i - 1][w - wt[i - 1]], 
                        K[i - 1][w]); 
                else
                    K[i][w] = K[i - 1][w]; 
            } 
        } 
  
        return K[n][W]; 
    }
  
   public static void main(String[] args) throws Exception {
        int N = in.nextInt();
        int W = in.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

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

        for (int i = 0; i < N; i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
            items_set.add(i);
        }
     System.out.println(knapSack(W, wt, v, N));
   }
}


Compiler output:
Main.java:38: error: cannot find symbol
            items_set.add(i);
            ^
  symbol:   variable items_set
  location: class Main
Main.java:40: error: cannot find symbol
     System.out.println(knapSack(W, wt, v, N));
                                    ^
  symbol:   variable wt
  location: class Main
2 errors
Language: Java

import java.util.*;

class Main{
  
  static int knapSack(int W, int wt[], int val[], int n) 
    { 
        int i, w; 
        int K[][] = new int[n + 1][W + 1]; 
  
        // Build table K[][] in bottom up manner 
        for (i = 0; i <= n; i++) { 
            for (w = 0; w <= W; w++) { 
                if (i == 0 || w == 0) 
                    K[i][w] = 0; 
                else if (wt[i - 1] <= w) 
                    K[i][w] = Math.max( 
                        val[i - 1] + K[i - 1][w - wt[i - 1]], 
                        K[i - 1][w]); 
                else
                    K[i][w] = K[i - 1][w]; 
            } 
        } 
  
        return K[n][W]; 
    }
  
   public static void main(String[] args) throws Exception {
        int N = in.nextInt();
        int W = in.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

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

        for (int i = 0; i < N; i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
            items_set.add(i);
        }
     System.out.println(knapSack(W, wt, v, N));
   }
}

Compiler output:
Main.java:28: error: cannot find symbol
        int N = in.nextInt();
                ^
  symbol:   variable in
  location: class Main
Main.java:29: error: cannot find symbol
        int W = in.nextInt();
                ^
  symbol:   variable in
  location: class Main
Main.java:36: error: cannot find symbol
            w[i] = in.nextInt();
                   ^
  symbol:   variable in
  location: class Main
Main.java:37: error: cannot find symbol
            v[i] = in.nextInt();
                   ^
  symbol:   variable in
  location: class Main
Main.java:38: error: cannot find symbol
            items_set.add(i);
            ^
  symbol:   variable items_set
  location: class Main
Main.java:40: error: cannot find symbol
     System.out.println(knapSack(W, wt, v, N));
                                    ^
  symbol:   variable wt
  location: class Main
6 errors
Language: C++

#include<iostream>
#define fast  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long int
using namespace std;
const int N=1e5+1;
ll n, w, values[N], Weight[N], dp[101][N];
ll calc(int i, ll W){
    if(i==n){
        if(W>w){
            return -1e3;
        }
        return 0;
    }
    if(dp[i][W]!=-1)return dp[i][W];
    return dp[i][W]=max(calc(i+1,W),calc(i+1, W+Weight[i])+values[i]);
}
int main()
{
    fast;
    cin>>n;cin>>w;
    for(int i=0;i<n;i++){
        cin>>Weight[i]>>values[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<calc(0,0);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'memset' was not declared in this scope
   24 |     memset(dp,-1,sizeof dp);
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #define fast  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
Language: Java

import java.util.*;
class Main{
  static Integer[][]cache;
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int w=sc.nextInt();
    int []x=new int[n];
    int []v=new int[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextInt();
      v[i]=sc.nextInt();
    }
    cache=new Integer[n+1][w+1];
    System.out.println(dfs(x,v,w,0));
    
  }
  public static long dfs(int []x,int []v,int W,int index){
 
        if(index==x.length || W==0) return 0;
        if(cache[index][W]!=null)return cache[index][W];
        long include=0,exclude;
        if(x[index]<=W){
            include=v[index]+dfs(x,v,W-x[index],index+1);
            exclude=dfs(x,v,W,index+1);
        }
        else{
            exclude=dfs(x,v,W,index+1);
        }
        return cache[index][W]=Math.max(include,exclude);
    }
}

Compiler output:
Main.java:30: error: incompatible types: long cannot be converted to Integer
        return cache[index][W]=Math.max(include,exclude);
                                       ^
1 error
Language: Java

ort java.util.*;
class Main{
  static Integer[][]cache;
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int w=sc.nextInt();
    int []x=new int[n];
    int []v=new int[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextInt();
      v[i]=sc.nextInt();
    }
    cache=new Integer[n+1][w+1];
    System.out.println(dfs(x,v,w,0));
    
  }
  public static long dfs(int []x,int []v,int W,int index){
 
        if(index==x.length || W==0) return 0;
        if(cache[index][W]!=null)return cache[index][W];
        long include=0,exclude;
        if(x[index]<=W){
            include=v[index]+dfs(x,v,W-x[index],index+1);
            exclude=dfs(x,v,W,index+1);
        }
        else{
            exclude=dfs(x,v,W,index+1);
        }
        return cache[index][W]=Math.max(include,exclude);
    }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
ort java.util.*;
^
1 error
Language: C++

// A Dynamic Programming based solution for Knapsack problem 
#include<iostream> 
#include <iomanip> 
using namespace std;
  
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack01(int W, int weight[], int val[], int n) 
{ 
   int k, w; 
   int F[n+1][W+1]; 
    Build table K[][] in bottom up manner 
   for (k = 0; k <= n; k++) 
   { 
       for (w = 0; w <= W; w++) 
       	{ 
			if (k==0 || w==0) 
			   F[k][w] = 0; 
			else if (weight[k-1] <= w) 
			     F[k][w] = max(F[k-1][w], F[k-1][w-weight[k-1]]+val[k-1]); 
			else
			     F[k][w] = F[k-1][w]; 
       	} 
   } 
   return F[n][W]; 
} 

int main() 
{ 
	std::ios::sync_with_stdio(false);
	int n, W;
	std::cin>>W>>n;
	int *val=new int[n];
	int *wt = new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
    std::cout<< knapSack01(W, wt, val, n)<<endl; 
    delete []val;
	delete []wt;
    return 0; 
} 

Compiler output:
a.cc: In function 'int knapSack01(int, int*, int*, int)':
a.cc:14:5: error: 'Build' was not declared in this scope
   14 |     Build table K[][] in bottom up manner
      |     ^~~~~
a.cc:15:27: error: expected ';' before ')' token
   15 |    for (k = 0; k <= n; k++)
      |                           ^
      |                           ;
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}


using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y//be careful from the multiplication while using this define 
#define TC int t;cin>>t;while(t--)

int main() {
	Fast(), File();
	int n, cpcty;
	cin >> n >> cpcty;
	vector<vector<ll>>dp(n, vector<ll>(cpcty + 1));
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	for (int i = v[n - 1].first; i <= cpcty; i++)dp[n - 1][i] = v[n - 1].second;
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 1; j <= cpcty; j++) {
			if (j >= v[i].first)dp[i][j] = max(dp[i + 1][j - v[i].first] + v[i].second, dp[i + 1][j]);
			else dp[i][j] = dp[i + 1][j];
		}
	}
	cout << dp[0][cpcty] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: 'File' was not declared in this scope
   26 |         Fast(), File();
      |                 ^~~~
Language: C++

int knapSack(int W, int wt[], int val[], int n) 
{ 

if (n == 0 || W == 0) 
	return 0; 
 
if (wt[n-1] > W) 
	return knapSack(W, wt, val, n-1); 
 

else return max( val[n-1] + knapSack(W-wt[n-1], wt, val, n-1), 
					knapSack(W, wt, val, n-1) 
				); 
} 
 

int main() 
{ 
	int n,W;
  cin>>n>>W;
  int val[n],wt[n];
  for(int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
	printf("%d", knapSack(W, wt, val, n)); 
	return 0; 
} 

Compiler output:
a.cc: In function 'int knapSack(int, int*, int*, int)':
a.cc:11:13: error: 'max' was not declared in this scope
   11 | else return max( val[n-1] + knapSack(W-wt[n-1], wt, val, n-1),
      |             ^~~
a.cc: In function 'int main()':
a.cc:20:3: error: 'cin' was not declared in this scope
   20 |   cin>>n>>W;
      |   ^~~
a.cc:24:9: error: 'printf' was not declared in this scope
   24 |         printf("%d", knapSack(W, wt, val, n));
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int knapSack(int W, int wt[], int val[], int n)
Language: C++

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

int check(){
  if(w==0 || n==0) return 0;
  if(dp[n][w] != -1) return dp[n][w];
  
  if(w < v[n-1][1]) dp[n][w] = check(dp,v,n-1,w);
  else dp[n][w] = max(check(dp,v,n-1,w-v[n-1][1]) + v[n-1][0] , check(dp,v,n-1,w));
  return dp[n][w];
}	
     
int main(){
  int n,w,vi,wi;
  cin >> n >> w;
  vector<vector<int>> v(n);
  for(int i=0;i<n;i++){
    cin >> vi >> wi;
    v[i].push_back(vi);
    v[i].push_back(wi);
  }
  
  vector<vector<int>> dp(n+1,vector<int>(w+1,-1));
  cout << check(dp,v,n,w) << endl;
  return 0; 
}

Compiler output:
a.cc: In function 'int check()':
a.cc:5:6: error: 'w' was not declared in this scope
    5 |   if(w==0 || n==0) return 0;
      |      ^
a.cc:5:14: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |   if(w==0 || n==0) return 0;
      |              ^
      |              yn
a.cc:6:6: error: 'dp' was not declared in this scope; did you mean 'dup'?
    6 |   if(dp[n][w] != -1) return dp[n][w];
      |      ^~
      |      dup
a.cc:6:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |   if(dp[n][w] != -1) return dp[n][w];
      |         ^
      |         yn
a.cc:6:12: error: 'w' was not declared in this scope
    6 |   if(dp[n][w] != -1) return dp[n][w];
      |            ^
a.cc:8:6: error: 'w' was not declared in this scope
    8 |   if(w < v[n-1][1]) dp[n][w] = check(dp,v,n-1,w);
      |      ^
a.cc:8:10: error: 'v' was not declared in this scope
    8 |   if(w < v[n-1][1]) dp[n][w] = check(dp,v,n-1,w);
      |          ^
a.cc:8:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   if(w < v[n-1][1]) dp[n][w] = check(dp,v,n-1,w);
      |            ^
      |            yn
a.cc:8:21: error: 'dp' was not declared in this scope; did you mean 'dup'?
    8 |   if(w < v[n-1][1]) dp[n][w] = check(dp,v,n-1,w);
      |                     ^~
      |                     dup
a.cc:9:8: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |   else dp[n][w] = max(check(dp,v,n-1,w-v[n-1][1]) + v[n-1][0] , check(dp,v,n-1,w));
      |        ^~
      |        dup
a.cc:10:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |   return dp[n][w];
      |          ^~
      |          dup
a.cc:10:13: error: 'n' was not declared in this scope; did you mean 'yn'?
   10 |   return dp[n][w];
      |             ^
      |             yn
a.cc:10:16: error: 'w' was not declared in this scope
   10 |   return dp[n][w];
      |                ^
a.cc: In function 'int main()':
a.cc:24:16: error: too many arguments to function 'int check()'
   24 |   cout << check(dp,v,n,w) << endl;
      |           ~~~~~^~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int check(){
      |     ^~~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
// KnapSack
int max_value(int N, int W, int*w , int* v)
{
    int dp[N+1][W+1];
    memset(dp,0,sizeof(dp));
    for(int i= 0 ;i<N ; ++i)
    {
        for(int j = 0 ;j<=W ; ++j)
        {
            dp[i+1][j] = max(dp[i+1][j] , dp[i][j]);
            if(j >= w[i])
                dp[i+1][j]  = max(dp[i+1][j] ,
                                dp[i][j-w[i]] + v[i]);
        }
    }
    return dp[N][W];
} 

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

    cout << max_value(N,W,w,v) <<endl;
    return 0;

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:31:14: error: expected '}' at end of input
   31 |     return 0;
      |              ^
a.cc:23:1: note: to match this '{'
   23 | {
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int actionFunction(vector<int> &weights, vector<long long> &values, int maxWeightCapacity) {
    if(weights.size()==0 || maxWeightCapacity<0)return 0;
    vector<long long> dp(maxWeightCapacity+1,0);
    for(int k=0;k<=maxWeightCapacity;k++) {
        dp[k]=(k>=weights[0])?long long(values[0]):long long(0);
    }
    for(int i=1;i<weights.size();i++) {
        vector<long long> cmp;//(maxWeightCapacity+1,0);
        for(int k=0;k<=maxWeightCapacity;k++) {
	      if(k-weights[i]>=0) {
	        cmp.push_back(max(long long(dp[k-weights[i]])+values[i],long long(dp[k])));
	      } else {
	      	cmp.push_back(long long(dp[k]));
	      }
	    }
	    /*
        for(int k=0;k<=maxWeightCapacity;k++) {
            cmp[k]=max(dp[k],(k>=weights[i])?values[i]+dp[k-weights[i]]:0);
        }
        */
        dp=cmp;
    }
    return dp[maxWeightCapacity];
}
int main(void){
    vector<int> weights;
    vector<long long> values;
    int n,k,tmp;
    long long tmpl;
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>tmp>>tmpl;
        weights.push_back(tmp);
        values.push_back(tmpl);
    }
    cout<<actionFunction(weights,values,k)<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int actionFunction(std::vector<int>&, std::vector<long long int>&, int)':
a.cc:8:31: error: expected primary-expression before 'long'
    8 |         dp[k]=(k>=weights[0])?long long(values[0]):long long(0);
      |                               ^~~~
a.cc:8:31: error: expected ':' before 'long'
    8 |         dp[k]=(k>=weights[0])?long long(values[0]):long long(0);
      |                               ^~~~
      |                               :
a.cc:8:31: error: expected primary-expression before 'long'
    8 |         dp[k]=(k>=weights[0])?long long(values[0]):long long(0);
      |                               ^~~~
a.cc:14:35: error: expected primary-expression before 'long'
   14 |                 cmp.push_back(max(long long(dp[k-weights[i]])+values[i],long long(dp[k])));
      |                                   ^~~~
a.cc:14:73: error: expected primary-expression before 'long'
   14 |                 cmp.push_back(max(long long(dp[k-weights[i]])+values[i],long long(dp[k])));
      |                                                                         ^~~~
a.cc:16:31: error: expected primary-expression before 'long'
   16 |                 cmp.push_back(long long(dp[k]));
      |                               ^~~~
Language: Java

import java.util.*;
class Main{
  public static long knapsack(long[] wt,long[] val,int w,int n)
  {
    long[][] t = new ilong[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
      for(int j=0;j<w+1;j++)
      {
        if(i==0||j==0)
          t[i][j]=0;
      }
    }
    
    for(int i=1;i<n+1;i++)
    {
      for(int j=1;j<w+1;j++)
      {
        if(wt[i-1]<=j)
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
        else
          t[i][j]=t[i-1][j];
      }
    }
    return t[n][w];
  }
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int w=sc.nextInt();
    int[] wt = new int[n];
    int[] val = new int[n];
    for(int i=0;i<n;i++)
    {
     wt[i]=sc.nextInt();
     val[i]=sc.nextInt();
    }
    System.out.println(knapsack(wt,val,w,n));
  }
}


Compiler output:
Main.java:5: error: cannot find symbol
    long[][] t = new ilong[n+1][w+1];
                     ^
  symbol:   class ilong
  location: class Main
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                            ^
Main.java:38: error: incompatible types: int[] cannot be converted to long[]
    System.out.println(knapsack(wt,val,w,n));
                                ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
Language: Java

import java.util.*;
class Main{
  public static long knapsack(long[] wt,long[] val,int w,int n)
  {
    long[][] t = new long[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
      for(int j=0;j<w+1;j++)
      {
        if(i==0||j==0)
          t[i][j]=0;
      }
    }
    
    for(long i=1;i<n+1;i++)
    {
      for(long j=1;j<w+1;j++)
      {
        if(wt[i-1]<=j)
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
        else
          t[i][j]=t[i-1][j];
      }
    }
    return t[n][w];
  }
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int w=sc.nextInt();
    long[] wt = new long[n];
    long[] val = new long[n];
    for(int i=0;i<n;i++)
    {
     wt[i]=sc.nextLong();
     val[i]=sc.nextLong();
    }
    System.out.println(knapsack(wt,val,w,n));
  }
}


Compiler output:
Main.java:19: error: incompatible types: possible lossy conversion from long to int
        if(wt[i-1]<=j)
               ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
            ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
               ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                       ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                                 ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                            ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                                         ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                                             ^
Main.java:22: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=t[i-1][j];
            ^
Main.java:22: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=t[i-1][j];
               ^
Main.java:22: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=t[i-1][j];
                     ^
Main.java:22: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=t[i-1][j];
                         ^
13 errors
Language: Java

import java.util.*;
class Main{
  public static int knapsack(long[] wt,long[] val,int w,int n)
  {
    int[][] t = new int[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
      for(int j=0;j<w+1;j++)
      {
        if(i==0||j==0)
          t[i][j]=0;
      }
    }
    
    for(int i=1;i<n+1;i++)
    {
      for(int j=1;j<w+1;j++)
      {
        if(wt[i-1]<=j)
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
        else
          t[i][j]=t[i-1][j];
      }
    }
    return t[n][w];
  }
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int w=sc.nextInt();
    long[] wt = new long[n];
    long[] val = new long[n];
    for(int i=0;i<n;i++)
    {
     wt[i]=sc.nextLong();
     val[i]=sc.nextLong();
    }
    System.out.println(knapsack(wt,val,w,n));
  }
}


Compiler output:
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                                            ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
                          ^
2 errors
Language: C++

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
}
int N;
int v[105];
int w[105];
int dp[110][110];
int cal(int i,int W)
{
    if(W<0)
        return INT_MIN;
    if(i<0 || w==0)
        return 0;
    if(dp[i][W]!=-1)
        return dp[i][W];    
    int notinclude=cal(i-1,W);
    include=v[i]+cal(i-1,W-w[i]);
    return dp[i][W]=max(include,notinclude);
}
int32_t main()
{
    IOS;
    int W;
    memset(dp,-1,sizeof(dp));
    cin>>N>>W;
    fori(0,N)
    {
        cin>>w[i]>>v[i];
    }
    cout<<cal(N-1,W);
    return 0;
}


Compiler output:
a.cc: In function 'long long int cal(long long int, long long int)':
a.cc:43:5: error: 'include' was not declared in this scope; did you mean 'notinclude'?
   43 |     include=v[i]+cal(i-1,W-w[i]);
      |     ^~~~~~~
      |     notinclude
a.cc: In function 'long long int fast(long long int, long long int)':
a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

long long func(int W[], int V[], int n, int w)
{
  long long dp[n + 1][w + 1];
  memset(dp, 0, sizeof(dp));
  
  for (auto i = 1; i <= n; i++) {
    for (auto j = 1; j <= w; j++) {
      if (j >= W[i - 1]) {
        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];
    }
  }
                                            
  return dp[n][w];
}

int main()
{
  int n, w;
  cin >> n >> w;
  
  int W[n], V[n];
  for (auto i = 0; i < n; i++) {
    cin >> W[i] >> V[i];
  }
  
  cout << func(W, V, n, w) << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'long long int func(int*, int*, int, int)':
a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   23 | int main()
      |         ^~
a.cc:23:9: note: remove parentheses to default-initialize a variable
   23 | int main()
      |         ^~
      |         --
a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:24:1: error: a function-definition is not allowed here before '{' token
   24 | {
      | ^
a.cc:36:2: error: expected '}' at end of input
   36 | }
      |  ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
a.cc:36:2: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      |  ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:22: error: 'n' was not declared in this scope
    8 |   for(int i = 0; i < n; i++){
      |                      ^
a.cc:19:14: error: 'n' was not declared in this scope
   19 |   cout << dp[n][w] << endl;
      |              ^
a.cc:19:17: error: 'w' was not declared in this scope
   19 |   cout << dp[n][w] << endl;
      |                 ^
Language: C++

#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
	int n,W;
	cin>>n>>W;
	int wt[n],val[n];
	for(int i=0;i<n;i++)
	{
	 cin>>wt[i]>>val[i];
		
	}
	int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
    cout<<dp[n][W];
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   30 |     cout<<dp[n][W];
      |           ^~
      |           dup
Language: C++

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

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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;

int main(){
    ll N, W;
    std::cin >> N >> W;

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

    const ll MAXV = 100*1000;
    ll dp[N+1][V+1];
    for(ll i=0; i<N; ++i){
        for(ll j=0; j<MAXV+1; ++j){
            dp[i][j] = 0;
        }
    }
    //i番まで価値jを超えないように選んだ時の重さの総和の最大値
    for(ll i=0; i<N; ++i){
        for(ll j=0; j<MAXV+1; ++j){
            if(j-v[i]>=0){
                chmax(dp[i+1][j], dp[i][j-v[i]]+w[i]);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }

    ll ans= 0 ;
    for(ll j=0; j<MAXV+1; ++j){
        if(dp[N][j]<=W){
            chmax(ans, dp[N][j]);
        }
    }

    std::cout << dp[N][W];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: 'V' was not declared in this scope
   22 |     ll dp[N+1][V+1];
      |                ^
a.cc:25:13: error: 'dp' was not declared in this scope
   25 |             dp[i][j] = 0;
      |             ^~
a.cc:32:23: error: 'dp' was not declared in this scope
   32 |                 chmax(dp[i+1][j], dp[i][j-v[i]]+w[i]);
      |                       ^~
a.cc:34:19: error: 'dp' was not declared in this scope
   34 |             chmax(dp[i+1][j], dp[i][j]);
      |                   ^~
a.cc:40:12: error: 'dp' was not declared in this scope
   40 |         if(dp[N][j]<=W){
      |            ^~
a.cc:45:18: error: 'dp' was not declared in this scope
   45 |     std::cout << dp[N][W];
      |                  ^~
Language: C++

#include <bits/stdc++.h>

using namespace std;
int n,w;
vector <int> dp;

int fun(int y){
	
	return fun()
	}

int main(){
	
	cin >> n>> w;
	dp.assign(n,-1);
	pair <int, int> arr[n];
	for(int t=0;t<n;t++){
		cin >> arr[t].first>>arr[t].second;	
		}
	
	return 0;
	}

Compiler output:
a.cc: In function 'int fun(int)':
a.cc:9:19: error: too few arguments to function 'int fun(int)'
    9 |         return fun()
      |                ~~~^~
a.cc:7:5: note: declared here
    7 | int fun(int y){
      |     ^~~
a.cc:9:21: error: expected ';' before '}' token
    9 |         return fun()
      |                     ^
      |                     ;
   10 |         }
      |         ~
Language: C++

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




lli knapsack(vector<int>wt, vector<lli>val, int n, int capacity) {
	lli dp[101][1001] = {0};
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= capacity; j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else {
				lli inc = 0, exc = 0;
				if (wt[i - 1] <= j)
					inc = val[i - 1] + dp[i - 1][capacity - wt[i - 1]];
				exc = dp[i - 1][capacity];

				dp[i][j] = max(inc, exc);
			}
		}

	}
	return dp[n][capacity];
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n, capacity;
	cin >> n >> capacity;

	vector<lli>wt;
	vector<lli>val;
	int w, v;
	for (int i = 0; i < n; i++) {
		cin >> w >> v;
		wt.push_back(w);
		val.push_back(v);
	}
	cout << knapsack(wt, val, n, capacity);

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:26: error: could not convert 'wt' from 'vector<long long int>' to 'vector<int>'
   46 |         cout << knapsack(wt, val, n, capacity);
      |                          ^~
      |                          |
      |                          vector<long long int>
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vi vector<int>
#define sl set<ll>
#define sc set<char>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mpi map<ll,ll>
#define mpc map<char,ll>
#define forn(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define inf        10000000

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

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   24 |         dp[w+1]={0};
      |         ^~
      |         dup
Language: C++

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

int main()
{
  ll n,W;
  cin>>n>>W;
  vector<pair<ll,ll>> v(n+1);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for (ll i=1;i<=n;i++)
  {
    for (ll w=0;w<=W;w++)
    {
      if (w>=v[i].first)
        dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      else 
        dp[i][w]=dp[i-1][w];
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}      

Compiler output:
a.cc: In function 'int main()':
a.cc:24:15: error: 'w' was not declared in this scope
   24 |   cout<<dp[n][w]<<endl;
      |               ^
Language: C++

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

int main()
{
  ll n,W;
  cin>>n>>W;
  vector<pair<ll,ll>> v(n+1);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for (ll i=1;i<=n;i++)
  {
    for (ll w=0;w<=W;w++)
    {
      if (w>=v[i].first)
        dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      else 
        dp[i][w]=dp[i-1][w];
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}
  return 0;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:24:15: error: 'w' was not declared in this scope
   24 |   cout<<dp[n][w]<<endl;
      |               ^
a.cc: At global scope:
a.cc:27:3: error: expected unqualified-id before 'return'
   27 |   return 0;
      |   ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
   28 | }
      | ^
Language: C++

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

int main()
{
  ll n,W;
  cin>>n>>W;
  vector<pair<ll,ll>> v(n);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for (ll i=1;i<=n;i++)
  {
    for (ll w=0;w<=W;w++)
    {
      if (w>=v[i].first)
        dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      else 
        dp[i][w]=dp[i-1][w];
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}
  return 0;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:24:15: error: 'w' was not declared in this scope
   24 |   cout<<dp[n][w]<<endl;
      |               ^
a.cc: At global scope:
a.cc:27:3: error: expected unqualified-id before 'return'
   27 |   return 0;
      |   ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
   28 | }
      | ^