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

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 2147483647
#define LINF 92233720370000000000

int n, w;
llint dp[110000][110000];
int we[110000], v[110000];

int main() {
    cin >> n >> w;

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

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

    llint ans = 0;
    for (int i = 1; i <= w; i++) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
/tmp/ccCByPgf.o: in function `main':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `we' defined in .bss section in /tmp/ccCByPgf.o
a.cc:(.text+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccCByPgf.o
a.cc:(.text+0x118): relocation truncated to fit: R_X86_64_PC32 against symbol `we' defined in .bss section in /tmp/ccCByPgf.o
a.cc:(.text+0x142): relocation truncated to fit: R_X86_64_PC32 against symbol `we' defined in .bss section in /tmp/ccCByPgf.o
a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccCByPgf.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 2147483647
#define LINF 92233720370000000000

int n, w;
llint dp[110000][110000], we[110000], v[110000];

int main() {
    cin >> n >> w;

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

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

    llint ans = 0;
    for (int i = 1; i <= w; i++) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
/tmp/ccBIGTFY.o: in function `main':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `we' defined in .bss section in /tmp/ccBIGTFY.o
a.cc:(.text+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccBIGTFY.o
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `we' defined in .bss section in /tmp/ccBIGTFY.o
a.cc:(.text+0x14e): relocation truncated to fit: R_X86_64_PC32 against symbol `we' defined in .bss section in /tmp/ccBIGTFY.o
a.cc:(.text+0x189): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccBIGTFY.o
collect2: error: ld returned 1 exit status
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];
  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++)
  {
      int w1
      long long int c;
      cin>>w1>>c;
      
    for(int j=1;j<=w;j++)
    {
     
      if(w1<=j)
      {
        dp[i][j]=max(c+dp[i-1][j-w1],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:20:7: error: expected initializer before 'long'
   20 |       long long int c;
      |       ^~~~
a.cc:21:12: error: 'w1' was not declared in this scope; did you mean 'w'?
   21 |       cin>>w1>>c;
      |            ^~
      |            w
a.cc:21:16: error: 'c' was not declared in this scope
   21 |       cin>>w1>>c;
      |                ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std;
int main(){
	int n,maxw;
	cin >>n>>maxw;
	multimap<int,int>m;
	for(int i=0;i<n;i++){
		int v,w;cin >>w>>v;
		m.insert({v,w})
		}
	multimap<int,int>iterator itr;
	itr=m.end();
	for(;itr>=itr.begin();itr--){
		if((maxw-itr->second)>=0){
			cost=cost+itr->first;
			maxw=maxw-itr->second;
			}
		else { cout << cost;return 0;}
		}
	return 0;
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:15:32: error: expected ';' before '}' token
   15 |                 m.insert({v,w})
      |                                ^
      |                                ;
   16 |                 }
      |                 ~               
a.cc:17:35: error: expected initializer before 'itr'
   17 |         multimap<int,int>iterator itr;
      |                                   ^~~
a.cc:18:9: error: 'itr' was not declared in this scope
   18 |         itr=m.end();
      |         ^~~
a.cc:21:25: error: 'cost' was not declared in this scope; did you mean 'const'?
   21 |                         cost=cost+itr->first;
      |                         ^~~~
      |                         const
a.cc:24:32: error: 'cost' was not declared in this scope; did you mean 'const'?
   24 |                 else { cout << cost;return 0;}
      |                                ^~~~
      |                                const
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std;
int main(){
	int n,maxw;
	cin >>n>>maxw;
	multimap<int,int>m;
	for(int i=0;i<n;i++){
		int v,w;cin >>w>>v;
		m.insert({v,w})
		}
	multimap<int,int>iterator itr;
	itr=m.end();
	for(;itr>=itr.begin();itr--){
		if((maxw-itr->second)>=0){
			cost=cost+itr->first;
			maxw=maxw-itr->second;
			}
		else { cout << cost;return 0;}
		}
	return 0;
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'multimap' was not declared in this scope
   11 |         multimap<int,int>m;
      |         ^~~~~~~~
a.cc:7:1: note: 'std::multimap' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    6 | #include <bitset>
  +++ |+#include <map>
    7 | using namespace std;
a.cc:11:18: error: expected primary-expression before 'int'
   11 |         multimap<int,int>m;
      |                  ^~~
a.cc:14:17: error: 'm' was not declared in this scope
   14 |                 m.insert({v,w})
      |                 ^
a.cc:16:18: error: expected primary-expression before 'int'
   16 |         multimap<int,int>iterator itr;
      |                  ^~~
a.cc:17:9: error: 'itr' was not declared in this scope
   17 |         itr=m.end();
      |         ^~~
a.cc:17:13: error: 'm' was not declared in this scope
   17 |         itr=m.end();
      |             ^
a.cc:20:25: error: 'cost' was not declared in this scope; did you mean 'const'?
   20 |                         cost=cost+itr->first;
      |                         ^~~~
      |                         const
a.cc:23:32: error: 'cost' was not declared in this scope; did you mean 'const'?
   23 |                 else { cout << cost;return 0;}
      |                                ^~~~
      |                                const
Language: Java

import java.util.*;

public class atcoder{
	public static void main(String args[]) {
		Scanner input  = new Scanner(System.in);
		int n = input.nextInt();
		int W = input.nextInt();
		long arr[][] = new long[n][3];
		for(int i=0;i<n;i++) {
			long w = input.nextInt();
			long v = input.nextInt();
			arr[i] = new long[]{w,v};
		}
		System.out.println(dp(arr,n,W));
	}
	
	static long knap_sack(long arr[][],int n,long W) {
		if(n==-1 || W==0) {
			return 0;
		}
		
		long w = arr[n][0];
		long v = arr[n][1];
		if(W<w) {
			return knap_sack(arr,n-1,W);
		}
		long r_max = v+knap_sack(arr,n-1,W-w);
		long l_max = knap_sack(arr,n-1,W);
		return Math.max(r_max, l_max);
	}
	static long dp(long arr[][],int n,int W) {
		long dp[][] = new long[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>=arr[i-1][0]) {
					dp[i][j] = Math.max(dp[i-1][(int)(j-arr[i-1][0])]+arr[i-1][1], dp[i-1][j]);
				}
				else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		return dp[n][W];
	}
}


Compiler output:
Main.java:3: 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>
#define ll long long int
#define maxim 1e5+10
using namespace std;
ll val[101], wt[101], dp[110][maxim];
     
ll solve(int ith, int cwt, int n) {
    if(ith == n) return 0;
    
    if(dp[ith][cwt] != 0) return dp[ith][cwt];
    
    ll sml = 0;
    
    if(cwt - wt[ith] >= 0) sml = solve(ith + 1, cwt - wt[ith], n) + val[ith];
    
    ll sml1 = solve(ith + 1, cwt, n);
    
    return dp[ith][cwt] = max(sml, sml1);
}
int main() {
    int n, w; cin >> n >> w;
    for(int i=0; i<n; ++i) {
        cin >> wt[i] >> val[i];
    }
    cout << solve(0, w, n);
    return 0;
}

Compiler output:
a.cc:3:18: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxim 1e5+10
      |               ~~~^~~
a.cc:5:31: note: in expansion of macro 'maxim'
    5 | ll val[101], wt[101], dp[110][maxim];
      |                               ^~~~~
a.cc:3:18: error: could not convert '(1.0e+5 + (double)10)' from 'double' to 'long unsigned int'
    3 | #define maxim 1e5+10
      |               ~~~^~~
      |                  |
      |                  double
a.cc:5:31: note: in expansion of macro 'maxim'
    5 | ll val[101], wt[101], dp[110][maxim];
      |                               ^~~~~
a.cc:3:18: error: size of array 'dp' has non-integral type 'double'
    3 | #define maxim 1e5+10
      |               ~~~^~~
a.cc:5:31: note: in expansion of macro 'maxim'
    5 | ll val[101], wt[101], dp[110][maxim];
      |                               ^~~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long int
#defing maxim 1e5+10
using namespace std;
ll val[101], wt[101], dp[110][maxim];
     
ll solve(int ith, int cwt, int n) {
    if(ith == n) return 0;
    
    if(dp[ith][cwt] != 0) return dp[ith][cwt];
    
    ll sml = 0;
    
    if(cwt - wt[ith] >= 0) sml = solve(ith + 1, cwt - wt[ith], n) + val[ith];
    
    ll sml1 = solve(ith + 1, cwt, n);
    
    return dp[ith][cwt] = max(sml, sml1);
}
int main() {
    int n, w; cin >> n >> w;
    for(int i=0; i<n; ++i) {
        cin >> wt[i] >> val[i];
    }
    cout << solve(0, w, n);
    return 0;
}

Compiler output:
a.cc:3:2: error: invalid preprocessing directive #defing; did you mean #define?
    3 | #defing maxim 1e5+10
      |  ^~~~~~
      |  define
a.cc:5:31: error: 'maxim' was not declared in this scope
    5 | ll val[101], wt[101], dp[110][maxim];
      |                               ^~~~~
a.cc: In function 'long long int solve(int, int, int)':
a.cc:10:8: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |     if(dp[ith][cwt] != 0) return dp[ith][cwt];
      |        ^~
      |        dup
a.cc:18:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   18 |     return dp[ith][cwt] = max(sml, sml1);
      |            ^~
      |            dup
Language: C++

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

vector<vector<int> > dp(2001,vector<int>(2001,-1));
int dfs(vector<int> &weight,vector<int> &value, int index, int rem){
	if(rem<0) return INT_MIN;
		if(dp[index][rem]!=-1) return dp[index][rem];
	if(rem==0) return 0;
	if(index==weight.size()) return 0;
	int consider=value[index]+dfs(weight,value,index+1,rem-weight[index]);
	int notConsider=dfs(weight,value,index+1,rem);
	
	dp[index][rem]=max(consider,notConsider);
	return dp[index][rem];
}
int main() {
int S,n;

cin>>S;
cin>>n;
vector<int> weight(n,0);
vector<int> value(n,0);
for(int i=0; i<n; i++)
	cin>>weight[i]>>value[i];
	
	cout<<dfs(weight,value,0,s);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:34: error: 's' was not declared in this scope
   26 |         cout<<dfs(weight,value,0,s);
      |                                  ^
Language: C++

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

vector<vector<int> > dp(2001,vector<int>(2001,-1));
int Dfs(vector<int> &weight,vector<int> &value, int index, int rem){
	if(rem<0) return INT_MIN;
		if(dp[index][rem]!=-1) return dp[index][rem];
	if(rem==0) return 0;
	if(index==weight.size()) return 0;
	int consider=value[index]+dfs(weight,value,index+1,rem-weight[index]);
	int notConsider=dfs(weight,value,index+1,rem);
	
	dp[index][rem]=max(consider,notConsider);
	return dp[index][rem];
}

int main() {
int s,n;
cin>>s;
cin>>n;
vector<int> weight(n,0);
vector<int> value(n,0);
for(int i=0; i<n; i++)
	cin>>weight[i]>>value[i];
	
	cout<<Dfs(weight,value,0,s);
}

Compiler output:
a.cc: In function 'int Dfs(std::vector<int>&, std::vector<int>&, int, int)':
a.cc:10:35: error: 'dfs' was not declared in this scope; did you mean 'Dfs'?
   10 |         int consider=value[index]+dfs(weight,value,index+1,rem-weight[index]);
      |                                   ^~~
      |                                   Dfs
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
 unsigned  long long int wt[101],cost[101];
  for(int i=0;i<n;i++)
  {
   cin>>wt[i]>>cost[i]; 
  }
 unsigned long long int dp[100001][101];
  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(wt[i-1]<=j)
      {
        dp[i][j] = max(cost[i-1] + dp[i-1][j-wt[i-1]],dp[i-1][j]);
        //cout<<dp[i][j]<<" ";
      }
      else
      {
        dp[i][j] = dp[i-1][j];
      }
    }
  }
 long long int ans = 0;
  for(int i =0;i<=w;i++)
  {
    ans = max(dp[n][i],ans);
  }
  cout<<ans;
 return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: no matching function for call to 'max(long long unsigned int&, long long int&)'
   34 |     ans = max(dp[n][i],ans);
      |           ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:34:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   34 |     ans = max(dp[n][i],ans);
      |           ~~~^~~~~~~~~~~~~~
/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
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,w;
 unsigned long long  cin>>n>>w;
 unsigned  long long int wt[101],cost[101];
  for(int i=0;i<n;i++)
  {
   cin>>wt[i]>>cost[i]; 
  }
 unsigned long long  long long int dp[100001][101];
  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(wt[i-1]<=j)
      {
        dp[i][j] = max(cost[i-1] + dp[i-1][j-wt[i-1]],dp[i-1][j]);
        //cout<<dp[i][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:5:25: error: expected initializer before '>>' token
    5 |  unsigned long long  cin>>n>>w;
      |                         ^~
a.cc:11:22: error: 'long long long' is too long for GCC
   11 |  unsigned long long  long long int dp[100001][101];
      |                      ^~~~
a.cc:11:27: error: 'long long long' is too long for GCC
   11 |  unsigned long long  long long int dp[100001][101];
      |                           ^~~~
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class atcoderdpcontest {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int w = Integer.parseInt(in[1]);

        int[] W = new int[n];
        int[] V = new int[n];

        for(int i=0;i<n;i++){
            in = br.readLine().split(" ");
            W[i] = Integer.parseInt(in[0]);
            V[i] = Integer.parseInt(in[1]);
        }
        int[][] dp = new int[n][w+1];

        for(int i=0;i<n;i++){
            for(int j=1;j<w+1;j++){
                if(i==0){
                    if(j>=W[0])
                        dp[i][j] = V[0];
                    continue;
                }
                dp[i][j] = dp[i-1][j];
                if(j-W[i]>=0){
                    dp[i][j] = Math.max(dp[i][j],V[i]+dp[i-1][j-W[i]]);
                }
            }
        }
//        for(int i=0;i<n;i++){
//            for(int j=0;j<w+1;j++){
//                System.out.print(dp[i][j]+" ");
//            }
//            System.out.println();
//        }
        System.out.println(dp[n-1][w]);
    }
}


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

#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n, w;
    cin >> n >> w;
    pair<long long, long long> arr [n];
    for (int i = 0 ; i < n; ++i) 
    {
        int a, b;
        cin >> a >> b;
        arr[i] = make_pair(a, b);
    }
    for (int i = 0; i <= n; ++i)
    {
        dp[i][0] = 0;
    }
    for (int i = 0; i <= w; ++i)
    {
        dp[0][i] = 0;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            if (j - arr[i - 1].first >= 0) {
                dp[i][j] = max(arr[i - 1].second + dp[i - 1][j - arr[i - 1].first], dp[i - 1][j]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    // long long val = 0;
    // for (int i = 0; i < n + 1; ++i) {
    //     for (int j = 0; j <= w; ++j)
    //     {
    //         val = max(val, dp[i][j]);
    //         cout << dp[i][j] << "\t";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][w] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'dp' was not declared in this scope
   20 |         dp[i][0] = 0;
      |         ^~
a.cc:24:9: error: 'dp' was not declared in this scope
   24 |         dp[0][i] = 0;
      |         ^~
a.cc:31:17: error: 'dp' was not declared in this scope
   31 |                 dp[i][j] = max(arr[i - 1].second + dp[i - 1][j - arr[i - 1].first], dp[i - 1][j]);
      |                 ^~
a.cc:33:17: error: 'dp' was not declared in this scope
   33 |                 dp[i][j] = dp[i - 1][j];
      |                 ^~
a.cc:46:13: error: 'dp' was not declared in this scope
   46 |     cout << dp[n][w] << endl;
      |             ^~
Language: C++

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

#define ll long long 
ll maxsum(ll n,ll w,ll wts[],ll value[])
{ 
    ll dp[101][100001]={0};
     for(i=0;i<=n;i++)
     {
       for(j=0;j<=w;j++)
       {
         if(i==0 || j==0)
         {dp[i][j]=0;}
         else
         {ll inc=0,enc=0;
          if(wts[i-1]<=w)
          {
            inc=value[i-1]+dp[i-1][w-wts[i-1]];
          }
           exc=dp[i-1][j];
           
         }
        }
      }
      return dp[n][w];
  
}
int main()
{
    
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,w;
    cin>>n>>w;
    ll wts[n],value[n],i;

    for(i=0;i<n;i++)
    {
    	cin>>wts[i]>>value[i];
    }
    cout<<maxsum(n,w,wts,value)<<endl;
	
}

Compiler output:
a.cc: In function 'long long int maxsum(long long int, long long int, long long int*, long long int*)':
a.cc:8:10: error: 'i' was not declared in this scope
    8 |      for(i=0;i<=n;i++)
      |          ^
a.cc:10:12: error: 'j' was not declared in this scope
   10 |        for(j=0;j<=w;j++)
      |            ^
a.cc:20:12: error: 'exc' was not declared in this scope; did you mean 'enc'?
   20 |            exc=dp[i-1][j];
      |            ^~~
      |            enc
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N,W;
  cin>>N>>W;
  vector<int>w(N);
  vector<int64_t>v(N);
  for(int i=0;i<N;i++){
  cin>>w.at(i);
    cin>>v.at(i);
  
  }
  vector<vector<int64_t>>dp(N+1,vector<int64_t>(W+1,0));
   for(int i=1;i<=N;i++){
   for(int j=1;j<=W;j++){
   if(w.at(i-1)<=j){
   dp[i][j]=max(dp[i-1][j],dp[i-1][j-w.at(i-1)]+v.at(i-1);
   }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:17:58: error: expected ')' before ';' token
   17 |    dp[i][j]=max(dp[i-1][j],dp[i-1][j-w.at(i-1)]+v.at(i-1);
      |                ~                                         ^
      |                                                          )
Language: C++

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

unsigned long long knapsack(vector<unsigned long long>&weight,vector<unsigned long long>&value,int n,int W)
{   vector<vector<unsigned long long>>dp(n+1,vector<unsigned long long>(W+1,0));
    for(int i=1;i<=n;i++)
    {
      for(unsigned long long wr = 1;wr<=W;wr++)
      {   if(wr>=weight[i-1])
        dp[i][wr] = max(value[i-1]+dp[i-1][w-weight[i-1]],dp[i-1][wr]);
          else dp[i][wr] = dp[i-1][wr];
      }
         
    }
    return dp[weight.size()][W];
}
int main()
{
     int n,W;
  cin>>n>>W;
  vector<unsigned long long>weight(n),value(n);
  for(int i =0;i<n;i++)
  {
    cin>>weight[i]>>value[i];
  }
  cout<<knapsack(weight,value,n,W)<<endl;
	
}

Compiler output:
a.cc: In function 'long long unsigned int knapsack(std::vector<long long unsigned int>&, std::vector<long long unsigned int>&, int, int)':
a.cc:10:44: error: 'w' was not declared in this scope
   10 |         dp[i][wr] = max(value[i-1]+dp[i-1][w-weight[i-1]],dp[i-1][wr]);
      |                                            ^
Language: C++

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

unsigned long long knapsack(vector<unsigned long long>&weight,vector<unsigned long long>&value,int n,int W)
{   vector<vector<unsigned long long>>dp(n+1,vector<unsigned long long>(W+1,0));
    for(int i=1;i<=n;i++)
    {
      for(unsigned long long w = 1;w<=W;w++){
	    if(w>=weight[i-1])
        dp[i][w] = max(value[i-1]+dp[i-1][w-weight[i-1]],dp[i-1][w]);
        
		else dp[i][w] = dp[i-1][w];
      }
         
    }
    return dp[weight.size()][W];
}
int main()
{
     int n,W;
  cin>>n>>W;
  vector<unsigned long long>weight(n),value(n);
  for(int i =0;i<n;i++)
  {
    cin>>weight[i]>>value[i];
  }
  co

Compiler output:
a.cc: In function 'int main()':
a.cc:27:3: error: 'co' was not declared in this scope; did you mean 'cos'?
   27 |   co
      |   ^~
      |   cos
a.cc:27:5: error: expected '}' at end of input
   27 |   co
      |     ^
a.cc:19:1: note: to match this '{'
   19 | {
      | ^
Language: C++

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

unsigned long long knapsack(vector<unsigned long long>&weight,vector<unsigned long long>&value,int n,int W)
{   vector<vector<unsigned long long>>dp(n+1,vector<unsigned long long>(W+1,0));
    for(int i=1;i<=n;i++)
    {
      for(unsigned long long w = 1;w<=W;w++)
      {   if(w>=weight[i-1])
        dp[i][w] = max(value[i-1]+dp[i-1][w-weight[i-1]],dp[i-1][w]);
          else dp[i][w] = dp[i-1][w];
      }
         
    }
    return dp[weight.size()][W];
}
int main()
{
     int n,W;
  cin>>n>>W;
  vector<unsigned long long>weight(n),value(n);
  for(int i =0;i<n;i++)
  {
    cin>>weight[i]>>value[i];
  }
  cout<<knapsack(weight,value,n,W)<<endl;

Compiler output:
a.cc:31:20: error: redefinition of 'long long unsigned int knapsack(std::vector<long long unsigned int>&, std::vector<long long unsigned int>&, int, int)'
   31 | unsigned long long knapsack(vector<unsigned long long>&weight,vector<unsigned long long>&value,int n,int W)
      |                    ^~~~~~~~
a.cc:4:20: note: 'long long unsigned int knapsack(std::vector<long long unsigned int>&, std::vector<long long unsigned int>&, int, int)' previously defined here
    4 | unsigned long long knapsack(vector<unsigned long long>&weight,vector<unsigned long long>&value,int n,int W)
      |                    ^~~~~~~~
a.cc:44:5: error: redefinition of 'int main()'
   44 | int main()
      |     ^~~~
a.cc:17:5: note: 'int main()' previously defined here
   17 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:53:42: error: expected '}' at end of input
   53 |   cout<<knapsack(weight,value,n,W)<<endl;
      |                                          ^
a.cc:45:1: note: to match this '{'
   45 | {
      | ^
Language: C++

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


// map<pair<int,int>,long long> mp;
int N;
long long maxKVal(vector<int> &value,vector<int> &weight, int w,int start,vector<vector<long long>> &dp )
{

    if(start==N-1 )
    {
    // cout<<N<<" "<<start<<endl ;
    // cout<<w<< " "<<weight[start]<<endl;
        if(w>=weight[start])
        {
            // cout<<"BOYO"<<endl;
            return value[start];
            
        }
        else
        {
            return 0;
        }
    }

    // pair<int,int> p=make_pair(w,start);

    if(dp[start][w]>0)
    {
        // cout<<"BAM REUSE!!!"<<endl;
        return dp[start][w];
    }
    long long with=0;
    long long without=0;

    long long ans=0;
    if(w>=weight[start] && start<N)
    {
        with=value[start]+maxKVal(value,weight,w-weight[start],start+1,dp);
        // cout<<"With :"<<with<<" Start :"<<start<<" W:" <<w-weight[start]<<endl;
        
    }
    without=maxKVal(value,weight,w,start+1,dp);

    ans=max(with,without);

    dp[start][w]=ans;

    return ans;

}


int main()
{
    int n;
    int w;
    cin>>n>>w;
    N=n;
    vector<int> value(n);
    vector<int> weight(n);
    long long mw=0;

    for(int x=0;x<n;x++)
    {
        int a,b;
        cin>>a>>b;
        value[x]=b;
        weight[x]=a;
        if(mw<a)
        {
            mw=a;
        }
    }
    vector<vector<int>> dp(n,vector<int>(mw,-1));

    // for(int x=0;x<n;x++)
    // {
    //     cout<<value[x]<<" "<<weight[x]<<endl;
    // }

    // cout<<endl;
    long long ans=maxKVal(value,weight,w,0,dp);

    cout<<ans;   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:44: error: invalid initialization of reference of type 'std::vector<std::vector<long long int> >&' from expression of type 'std::vector<std::vector<int> >'
   83 |     long long ans=maxKVal(value,weight,w,0,dp);
      |                                            ^~
a.cc:7:102: note: in passing argument 5 of 'long long int maxKVal(std::vector<int>&, std::vector<int>&, int, int, std::vector<std::vector<long long int> >&)'
    7 | long long maxKVal(vector<int> &value,vector<int> &weight, int w,int start,vector<vector<long long>> &dp )
      |                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
Language: C


#include <cstdio>

#define RANG 5010
using namespace std;

int l, m, T[RANG], V[RANG], S[RANG];
bool M[RANG];

main () {
  

    scanf ("%d %d", &m, &l);
    for (int i = 0; i < l; i++)
        scanf ("%d %d", &S[i], &V[i]);

	M[0] = true;
    for (int i = 0; i < l; i++)
        for (int j = m; j >= S[i]; j--)
			if (M[j - S[i]] && T[j] < T[j - S[i]] + V[i]) {
				M[j] = true;
				T[j] = T[j - S[i]] + V[i];
			}

    printf ("%d\n", T[m]);
}

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

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

long long dp[MAXN][MAXN];
long long peso[MAXN],valor[MAXN];

long long mochila(int i,long long libre)

    if(libre < 0)return -INT_MAX;
    if(i == 0)return 0;

    if(dp[i][libre] != -1)
        return dp[i][libre];

    long long op1 = mochila(i-1,libre);
    long long op2 = valor[i] + mochila(i-1,libre - peso[i]);

    return dp[i][libre] = max(op1,op2);
}

int main()
{
    long long n,w;

    cin>>n>>w;

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

    for(int i=1;i<=n;i++)
        cin>>peso[i]>>valor[i];

    cout<<mochila(n,w);


    return 0;
}

#include <cstdio>

#define RANG 5010
using namespace std;

int l, m, T[RANG], V[RANG], S[RANG];
bool M[RANG];

main () {
  

    scanf ("%d %d", &m, &l);
    for (int i = 0; i < l; i++)
        scanf ("%d %d", &S[i], &V[i]);

	M[0] = true;
    for (int i = 0; i < l; i++)
        for (int j = m; j >= S[i]; j--)
			if (M[j - S[i]] && T[j] < T[j - S[i]] + V[i]) {
				M[j] = true;
				T[j] = T[j - S[i]] + V[i];
			}

    printf ("%d\n", T[m]);

#include <cstdio>

#define RANG 5010
using namespace std;

int l, m, T[RANG], V[RANG], S[RANG];
bool M[RANG];

main () {
  

    scanf ("%d %d", &m, &l);
    for (int i = 0; i < l; i++)
        scanf ("%d %d", &S[i], &V[i]);

	M[0] = true;
    for (int i = 0; i < l; i++)
        for (int j = m; j >= S[i]; j--)
			if (M[j - S[i]] && T[j] < T[j - S[i]] + V[i]) {
				M[j] = true;
				T[j] = T[j - S[i]] + V[i];
			}

    printf ("%d\n", T[m]);
}

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

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

long long dp[MAXN][MAXN];
long long peso[MAXN],valor[MAXN];

long long mochila(int i,long long libre)
{
    if(libre < 0)return -INT_MAX;
    if(i == 0)return 0;

    if(dp[i][libre] != -1)
        return dp[i][libre];

    long long op1 = mochila(i-1,libre);
    long long op2 = valor[i] + mochila(i-1,libre - peso[i]);

    return dp[i][libre] = max(op1,op2);
}

int main()
{
    long long n,w;

    cin>>n>>w;

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

    for(int i=1;i<=n;i++)
        cin>>peso[i]>>valor[i];

    cout<<mochila(n,w);


    return 0;
}

#include <cstdio>

#define RANG 5010
using namespace std;

int l, m, T[RANG], V[RANG], S[RANG];
bool M[RANG];

main () {
  

    scanf ("%d %d", &m, &l);
    for (int i = 0; i < l; i++)
        scanf ("%d %d", &S[i], &V[i]);

	M[0] = true;
    for (int i = 0; i < l; i++)
        for (int j = m; j >= S[i]; j--)
			if (M[j - S[i]] && T[j] < T[j - S[i]] + V[i]) {
				M[j] = true;
				T[j] = T[j - S[i]] + V[i];
			}

    printf ("%d\n", T[m]);
}

Compiler output:
a.cc:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   47 | main () {
      | ^~~~
a.cc:47:1: error: redefinition of 'int main()'
a.cc:22:5: note: 'int main()' previously defined here
   22 | int main()
      |     ^~~~
Language: C++

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

typedef std::unique_ptr<long long[]> smart_array;

long long knapsack(std::pair<long long, long long>* pairs, smart_array* temp, int n, int w, int index = 0) {
	if (index >= n || w <= 0)
		return 0;

	if (temp[index][w] == 0) {
		long long tmp = 0;
		if (pairs[index].first <= w)
		tmp = pairs[index].second + knapsack(pairs, temp, n, w - pairs[index].first, index + 1);

		long long tmp2 = knapsack(pairs, temp, n, w, index + 1);
		
		temp[index][w] = std::max(tmp, tmp2);
	}
	return temp[index][w];
}

int main() {
	using std::cin; using std::cout; using std::endl;
	int n = 0, w = 0; cin >> n >> w;
	std::pair<long long, long long>* pairs = new std::pair<long long, long long>[n] {};

	for (size_t i = 0; i < n; i++)
		cin >> pairs[i].first >> pairs[i].second;

	auto tempArr = std::unique_ptr<smart_array[]>(new smart_array[n + 1]{});
	for (size_t i = 0; i <= n; i++)
		tempArr[i] = smart_array(new long long[__int64(w) + 1]{});

	cout << knapsack(pairs, tempArr.get(), n, w) << endl;

	delete[] pairs;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:56: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   34 |                 tempArr[i] = smart_array(new long long[__int64(w) + 1]{});
      |                                                        ^~~~~~~
      |                                                        __int64_t
Language: C++

#include<iostream>
#define ll long long
#include<algorithm>
using namespace std;

int main()
{
    ll n,w;
    cin>>n>>w;
    vector<vector<ll>> knapsack(n);
    ll temp;
    for(ll i=0; i<n; ++i)
    {
        cin>>temp;
        knapsack[i].push_back(temp);
        cin>>temp;
        knapsack[i].push_back(temp);

    }
    sort(knapsack.begin(), knapsack.end());

    ll arr1[w+1], arr2[w+1];
    ll *ptr1;
    ll *ptr2;
    ptr1 = arr1;
    ptr2 = arr2;
    for(ll i=0; i<=w; ++i)
    {
        ptr1[i] = 0;
    }

    for(ll i=0; i<n; ++i)
    {
        ptr2[0] = 0;
        for(ll j=1; j<=w; ++j)
        {
            if(knapsack[i][0] <= j)
            {
                ptr2[j] = max(ptr1[j], knapsack[i][1] + ptr1[j-knapsack[i][0]]);
            }
            else
            {
                ptr2[j] = ptr1[j];
            }
        }
        if(i != n-1)
        {
            ll *temp = ptr1;
            ptr1 = ptr2;
            ptr2 = temp;
        }
    }
    cout<<ptr2[w];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'vector' was not declared in this scope
   10 |     vector<vector<ll>> knapsack(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:10:19: note: in expansion of macro 'll'
   10 |     vector<vector<ll>> knapsack(n);
      |                   ^~
a.cc:15:9: error: 'knapsack' was not declared in this scope
   15 |         knapsack[i].push_back(temp);
      |         ^~~~~~~~
a.cc:20:10: error: 'knapsack' was not declared in this scope
   20 |     sort(knapsack.begin(), knapsack.end());
      |          ^~~~~~~~
Language: C++

#include <bits/stdc++.h>
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]={};

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:23:36: error: 'sum_w' was not declared in this scope
   23 |     else chmax(dp[i+1][wsum],dp[i][sum_w]);
      |                                    ^~~~~
Language: C++

#include <bits/stdc++.h>
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]={}

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

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


Compiler output:
a.cc:14:1: error: expected ',' or ';' before 'int'
   14 | int main() {
      | ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int knapsack01(int weight [], intvalue [], int W, int N) { 
  int dp[N+1][W+1];
		dp[0][0] = 0;
		for (int idx = 1; idx < dp.length; idx++) {
			for (int w = 0; w <= W; w++) {

				int pick = 0;
				if (w - weight[idx - 1] >= 0) {
					pick = dp[idx - 1][w - weight[idx - 1]] + value[idx - 1];
				}

				int notPicked = dp[idx - 1][w];

				dp[idx][w] = Math.max(pick, notPicked);
			}
		}

		return dp[dp.length - 1][dp[0].length - 1];
	}

int main(){
  int N=0;
  int W=0;
  cin>>N;
  cin>>W;
  int weight[N];
  int value[W];
 
  
  for(int i=0;i<N;i++){
    cin>>weight[i];
    cin>>value[i];
  }
  cout<<knapsack01(weight,value,W,N);
}


Compiler output:
a.cc:3:31: error: 'intvalue' has not been declared
    3 | int knapsack01(int weight [], intvalue [], int W, int N) {
      |                               ^~~~~~~~
a.cc: In function 'int knapsack01(int*, int*, int, int)':
a.cc:6:44: error: request for member 'length' in 'dp', which is of non-class type 'int [(N + 1)][(W + 1)]'
    6 |                 for (int idx = 1; idx < dp.length; idx++) {
      |                                            ^~~~~~
a.cc:11:83: error: 'value' was not declared in this scope
   11 |                                         pick = dp[idx - 1][w - weight[idx - 1]] + value[idx - 1];
      |                                                                                   ^~~~~
a.cc:16:46: error: 'Math' was not declared in this scope
   16 |                                 dp[idx][w] = Math.max(pick, notPicked);
      |                                              ^~~~
a.cc:20:30: error: request for member 'length' in 'dp', which is of non-class type 'int [(N + 1)][(W + 1)]'
   20 |                 return dp[dp.length - 1][dp[0].length - 1];
      |                              ^~~~~~
a.cc:20:48: error: request for member 'length' in 'dp[0]', which is of non-class type 'int [(W + 1)]'
   20 |                 return dp[dp.length - 1][dp[0].length - 1];
      |                                                ^~~~~~
Language: C++

int knapsack_01_rec_DP(int[] weight, int[] value, int W, int[][] dp) { // dp: weight X W, n is size of weight
		dp[0][0] = 0;
		for (int idx = 1; idx < dp.length; idx++) {
			for (int w = 0; w <= W; w++) {

				int pick = 0;
				if (w - weight[idx - 1] >= 0) {
					pick = dp[idx - 1][w - weight[idx - 1]] + value[idx - 1];
				}

				int notPicked = dp[idx - 1][w];

				dp[idx][w] = Math.max(pick, notPicked);
			}
		}

		return dp[dp.length - 1][dp[0].length - 1];
	}

Compiler output:
a.cc:1:30: error: expected ',' or '...' before 'weight'
    1 | int knapsack_01_rec_DP(int[] weight, int[] value, int W, int[][] dp) { // dp: weight X W, n is size of weight
      |                              ^~~~~~
a.cc: In function 'int knapsack_01_rec_DP(int*)':
a.cc:2:17: error: 'dp' was not declared in this scope
    2 |                 dp[0][0] = 0;
      |                 ^~
a.cc:4:46: error: 'W' was not declared in this scope
    4 |                         for (int w = 0; w <= W; w++) {
      |                                              ^
a.cc:7:41: error: 'weight' was not declared in this scope
    7 |                                 if (w - weight[idx - 1] >= 0) {
      |                                         ^~~~~~
a.cc:8:83: error: 'value' was not declared in this scope
    8 |                                         pick = dp[idx - 1][w - weight[idx - 1]] + value[idx - 1];
      |                                                                                   ^~~~~
a.cc:13:46: error: 'Math' was not declared in this scope
   13 |                                 dp[idx][w] = Math.max(pick, notPicked);
      |                                              ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int knapsack01(int weight [], int value [], int w, int idx, long dp [1000000][1000000],int size) { 
		if (w == 0 || idx == size) {
			return 0;
		}
		if (dp[idx][w] != 0) return dp[idx][w];

		int pick = 0;
		if (w - weight[idx] >= 0) {
			pick = knapsack_01_rec(weight, value, w - weight[idx], idx + 1, dp,size) + value[idx];
		}

		int notPicked = knapsack01(weight, value, w, idx + 1, dp,size);

		return dp[idx][w] = max(pick, notPicked);
	}
int main(){
  int N=0;
  int W=0;
  cin>>N;
  cin>>W;
  int weight[N];
  int value[W];
  long dp[1000000][1000000];
  
  for(int i=0;i<N;i++){
    cin>>weight[i];
    cin>>value[i];
  }
  cout<<knapsack01(weight,value,W,0,dp,N);
}


Compiler output:
a.cc: In function 'int knapsack01(int*, int*, int, int, long int (*)[1000000], int)':
a.cc:11:32: error: 'knapsack_01_rec' was not declared in this scope; did you mean 'knapsack01'?
   11 |                         pick = knapsack_01_rec(weight, value, w - weight[idx], idx + 1, dp,size) + value[idx];
      |                                ^~~~~~~~~~~~~~~
      |                                knapsack01
Language: C++

#include<bits/stdc++.h>
using namespace std;
int knapsack01(int weight [], int value [], int w, int idx, long dp [size+1][w+1],int size) { 
		if (w == 0 || idx == size) {
			return 0;
		}
		if (dp[idx][w] != 0) return dp[idx][w];

		int pick = 0;
		if (w - weight[idx] >= 0) {
			pick = knapsack_01_rec(weight, value, w - weight[idx], idx + 1, dp,size) + value[idx];
		}

		int notPicked = knapsack01(weight, value, w, idx + 1, dp,size);

		return dp[idx][w] = max(pick, notPicked);
	}
int main(){
  int N=0;
  int W=0;
  cin>>N;
  cin>>W;
  int weight[N];
  int value[W];
  long dp[N+1][W+1];
  for(int i=0;i<N+1;i++){
  for(int j=0;j<W+1;j++){
  dp[i][j]=0;
  }}
  for(int i=0;i<N;i++){
    cin>>weight[i];
    cin>>value[i];
  }
  cout<<knapsack01(weight,value,W,0,dp,N);
}


Compiler output:
a.cc:3:74: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [size+1][w+1],int size) {
      |                                                                      ~~~~^~
a.cc:3:79: error: use of parameter outside function body before '+' token
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [size+1][w+1],int size) {
      |                                                                               ^
a.cc:3:82: error: expected ')' before ',' token
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [size+1][w+1],int size) {
      |               ~                                                                  ^
      |                                                                                  )
a.cc:3:83: error: expected unqualified-id before 'int'
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [size+1][w+1],int size) {
      |                                                                                   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int knapsack01(int weight [], int value [], int w, int idx, long dp [N+1][W+1],int size) { 
		if (w == 0 || idx == size) {
			return 0;
		}
		if (dp[idx][w] != 0) return dp[idx][w];

		int pick = 0;
		if (w - weight[idx] >= 0) {
			pick = knapsack_01_rec(weight, value, w - weight[idx], idx + 1, dp,size) + value[idx];
		}

		int notPicked = knapsack01(weight, value, w, idx + 1, dp,size);

		return dp[idx][w] = max(pick, notPicked);
	}
int main(){
  int N=0;
  int W=0;
  cin>>N;
  cin>>W;
  int weight[N];
  int value[W];
  long dp[N+1][W+1];
  for(int i=0;i<N+1;i++){
  for(int j=0;j<W+1;j++){
  dp[i][j]=0;
  }}
  for(int i=0;i<N;i++){
    cin>>weight[i];
    cin>>value[i];
  }
  cout<<knapsack01(weight,value,W,0,dp,N);
}


Compiler output:
a.cc:3:70: error: 'N' was not declared in this scope
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [N+1][W+1],int size) {
      |                                                                      ^
a.cc:3:75: error: 'W' was not declared in this scope
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [N+1][W+1],int size) {
      |                                                                           ^
a.cc:3:79: error: expected ')' before ',' token
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [N+1][W+1],int size) {
      |               ~                                                               ^
      |                                                                               )
a.cc:3:80: error: expected unqualified-id before 'int'
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [N+1][W+1],int size) {
      |                                                                                ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int knapsack01(int weight [], int value [], int w, int idx, long dp [][],int size) { 
		if (w == 0 || idx == size) {
			return 0;
		}
		if (dp[idx][w] != 0) return dp[idx][w];

		int pick = 0;
		if (w - weight[idx] >= 0) {
			pick = knapsack_01_rec(weight, value, w - weight[idx], idx + 1, dp,size) + value[idx];
		}

		int notPicked = knapsack01(weight, value, w, idx + 1, dp,size);

		return dp[idx][w] = max(pick, notPicked);
	}
int main(){
  int N=0;
  int W=0;
  cin>>N;
  cin>>W;
  int weight[N];
  int value[W];
  long dp[N+1][W+1];
  for(int i=0;i<N+1;i++){
  for(int j=0;j<W+1;j++){
  dp[i][j]=0;
  }}
  for(int i=0;i<N;i++){
    cin>>weight[i];
    cin>>value[i];
  }
  cout<<knapsack01(weight,value,W,0,dp,N);
}


Compiler output:
a.cc:3:66: error: declaration of 'dp' as multidimensional array must have bounds for all dimensions except the first
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [][],int size) {
      |                                                                  ^~
a.cc:3:73: error: expected ')' before ',' token
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [][],int size) {
      |               ~                                                         ^
      |                                                                         )
a.cc:3:74: error: expected unqualified-id before 'int'
    3 | int knapsack01(int weight [], int value [], int w, int idx, long dp [][],int size) {
      |                                                                          ^~~