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

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")

int knapsack(vector<int>& wt, vector<int>& val, int n, int Weight){
    vector<vector<long long>> dp(n+1,vector<long long>(Weight+1));
    for(int v=0; v<=n; v++){
        for(int w=0; w<=Weight; w++){
            if(v==0 || w==0)
                dp[v][w] = 0;
            else if (wt[i-1]<=w)
                dp[v][w] = max(val[v-1] + dp[v-1][w-wt[v-1]], dp[v-1][w]);
            else
                dp[v][w] = dp[v-1][w]
        }
    }
    return dp[n][Weight];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin>>n>>w;
    vector<int> wt(n), val(n);
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    cout<<knapsack(wt, val, n, w)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)':
a.cc:11:25: error: 'i' was not declared in this scope
   11 |             else if (wt[i-1]<=w)
      |                         ^
a.cc:14:38: error: expected ';' before '}' token
   14 |                 dp[v][w] = dp[v-1][w]
      |                                      ^
      |                                      ;
   15 |         }
      |         ~
Language: Java

import java.util.Scanner;
​
public class Main {
	
	public static void main(String args[]) {
		Scanner kb = new Scanner(System.in);
		
		int numitems = kb.nextInt(), maxw = kb.nextInt();
		int[] v = new int[numitems];
		int[] w = new int[numitems];
		
		for(int i = 0; i < numitems; i++) {
			w[i] = kb.nextInt();
			v[i] = kb.nextInt();
		}
		System.out.println(knapsack(maxw, v, w));
	}
	static long knapsack(int maxw, int[] v, int[] w) {
		long[][] cache = new long[w.length+1][maxw+1];
		
		for(int i = 1; i<= w.length; i++) {
			for(int x = 1; x <= maxw; x++) {
				if(w[i-1] > x) {
					cache[i][x] = cache[i-1][x];
				}else {
					cache[i][x] = Math.max(cache[i-1][x], cache[i-1][x-w[i-1]] + v[i-1]);
				}
			}
		}
		return cache[v.length][maxw];
		
	}
}

Compiler output:
Main.java:2: error: illegal character: '\u200b'
?
^
1 error
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int w=s.nextInt();
    int[] weights=new int[n];
    int[] value=new int[n];
    for(int i=0;i<n;i++){
      weights[i]=s.nextInt();
      value[i]=s.nextInt();
    }
    int[][] dp=new int[n+1][w+1];
    for(int i=1;i<=n;i++){
      for(int j=1;j<=w;j++){
        if(weights[i]>j){
          dp[i][j]=dp[i-1][j];
        }
        else{
          dp[i][j]=Math.max(dp[i-1][j],value[j]+dp[i-1][j-weights[i]]);
        }
      }
      System.out.println(dp[n][w]);
    }
  }
  
        
        
    
    
      

Compiler output:
Main.java:25: error: reached end of file while parsing
  }
   ^
1 error
Language: C++

#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N = 105, mxW = 1e5 + 5;
int dp[N][mxW];
ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
{
	if(x>n-1||ctr>l)
	{
		return 0;
	}
  	if (dp[c][ctr] != -1)
		return dp[x][ctr];
	if(ctr+v[x].first>l)
	{
		return fun(x+1,l,n,ctr,v);
	}
	return dp[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
}
int main()
{
  		ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  	memset(&dp, -1, sizeof(dp));
		ll n,l;
		cin>>n>>l;
		vector<pair<ll,ll> > v;
		for(ll i=0;i<n;i++)
		{
			ll x,y;
			cin>>x>>y;
			v.push_back(make_pair(x,y));
		}
		ll ans=fun(0,l,n,0,v);
		cout<<ans<<"\n";
}


Compiler output:
a.cc: In function 'long long int fun(long long int, long long int, long long int, long long int, std::vector<std::pair<long long int, long long int> >)':
a.cc:12:16: error: 'c' was not declared in this scope
   12 |         if (dp[c][ctr] != -1)
      |                ^
Language: C++

include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=1e4;
long long arr[N][N];
ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
{
	if(x>n-1)
	{
		return 0;
	}
	if(ctr+v[x].first>l)
	{
		return fun(x+1,l,n,ctr,v);
	}
	if(arr[x][ctr]!=0)
	{
		return arr[x][ctr];
	}
	arr[x][ctr]=1;
	return arr[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
}
int main()
{
		ll n,l;
		cin>>n>>l;
		ll arr[n+1][l];
		vector<pair<ll,ll> > v;
		for(ll i=0;i<n;i++)
		{
			ll x,y;
			cin>>x>>y;
			v.push_back(make_pair(x,y));
		}
		ll ans=fun(0,l,n,0,v);
		cout<<ans<<"\n";
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc:6:30: error: 'vector' has not been declared
    6 | ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
      |                              ^~~~~~
a.cc:6:36: error: expected ',' or '...' before '<' token
    6 | ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
      |                                    ^
a.cc: In function 'long long int fun(long long int, long long int, long long int, long long int, int)':
a.cc:12:16: error: 'v' was not declared in this scope
   12 |         if(ctr+v[x].first>l)
      |                ^
a.cc:21:32: error: 'v' was not declared in this scope
   21 |         return arr[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
      |                                ^
a.cc:21:28: error: 'max' was not declared in this scope
   21 |         return arr[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
      |                            ^~~
a.cc: In function 'int main()':
a.cc:26:17: error: 'cin' was not declared in this scope
   26 |                 cin>>n>>l;
      |                 ^~~
a.cc:28:17: error: 'vector' was not declared in this scope
   28 |                 vector<pair<ll,ll> > v;
      |                 ^~~~~~
a.cc:28:24: error: 'pair' was not declared in this scope
   28 |                 vector<pair<ll,ll> > v;
      |                        ^~~~
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:28:29: note: in expansion of macro 'll'
   28 |                 vector<pair<ll,ll> > v;
      |                             ^~
a.cc:33:25: error: 'v' was not declared in this scope
   33 |                         v.push_back(make_pair(x,y));
      |                         ^
a.cc:33:37: error: 'make_pair' was not declared in this scope
   33 |                         v.push_back(make_pair(x,y));
      |                                     ^~~~~~~~~
a.cc:35:36: error: 'v' was not declared in this scope
   35 |                 ll ans=fun(0,l,n,0,v);
      |                                    ^
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout<<ans<<"\n";
      |                 ^~~~
Language: C++

lude<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=1e4;
long long arr[N][N];
ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
{
	if(x>n-1)
	{
		return 0;
	}
	if(ctr+v[x].first>l)
	{
		return fun(x+1,l,n,ctr,v);
	}
	if(arr[x][ctr]!=0)
	{
		return arr[x][ctr];
	}
	arr[x][ctr]=1;
	return arr[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
}
int main()
{
		ll n,l;
		cin>>n>>l;
		ll arr[n+1][l];
		vector<pair<ll,ll> > v;
		for(ll i=0;i<n;i++)
		{
			ll x,y;
			cin>>x>>y;
			v.push_back(make_pair(x,y));
		}
		ll ans=fun(0,l,n,0,v);
		cout<<ans<<"\n";
}

Compiler output:
a.cc:1:1: error: 'lude' does not name a type
    1 | lude<bits/stdc++.h>
      | ^~~~
a.cc:6:30: error: 'vector' has not been declared
    6 | ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
      |                              ^~~~~~
a.cc:6:36: error: expected ',' or '...' before '<' token
    6 | ll fun(ll x,ll l,ll n,ll ctr,vector<pair<ll,ll> > v)
      |                                    ^
a.cc: In function 'long long int fun(long long int, long long int, long long int, long long int, int)':
a.cc:12:16: error: 'v' was not declared in this scope
   12 |         if(ctr+v[x].first>l)
      |                ^
a.cc:21:32: error: 'v' was not declared in this scope
   21 |         return arr[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
      |                                ^
a.cc:21:28: error: 'max' was not declared in this scope
   21 |         return arr[x][ctr]=max(v[x].second+fun(x+1,l,n,ctr+v[x].first,v),fun(x+1,l,n,ctr,v));
      |                            ^~~
a.cc: In function 'int main()':
a.cc:26:17: error: 'cin' was not declared in this scope
   26 |                 cin>>n>>l;
      |                 ^~~
a.cc:28:17: error: 'vector' was not declared in this scope
   28 |                 vector<pair<ll,ll> > v;
      |                 ^~~~~~
a.cc:28:24: error: 'pair' was not declared in this scope
   28 |                 vector<pair<ll,ll> > v;
      |                        ^~~~
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:28:29: note: in expansion of macro 'll'
   28 |                 vector<pair<ll,ll> > v;
      |                             ^~
a.cc:33:25: error: 'v' was not declared in this scope
   33 |                         v.push_back(make_pair(x,y));
      |                         ^
a.cc:33:37: error: 'make_pair' was not declared in this scope
   33 |                         v.push_back(make_pair(x,y));
      |                                     ^~~~~~~~~
a.cc:35:36: error: 'v' was not declared in this scope
   35 |                 ll ans=fun(0,l,n,0,v);
      |                                    ^
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout<<ans<<"\n";
      |                 ^~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

long long knapsackRecursive(vector<vector<long long>> &dp, vector<int> &profits,
                        vector<int> &weights, int capacity, int currentIndex) {
    // base checks
    if (capacity <= 0 || currentIndex >= profits.size()) {
      return 0;
    }

    // if we have already solved a similar problem, return the result from memory
    if (dp[currentIndex][capacity] != -1) {
      return dp[currentIndex][capacity];
    }

    // recursive call after choosing the element at the currentIndex
    // if the weight of the element at currentIndex exceeds the capacity, we shouldn't process this
    long long  profit1 = 0;
    if (weights[currentIndex] <= capacity) {
      profit1 = profits[currentIndex] + knapsackRecursive(dp, profits, weights,
                                                          capacity - weights[currentIndex],
                                                          currentIndex + 1);
    }

    // recursive call after excluding the element at the currentIndex
    long long  profit2 = knapsackRecursive(dp, profits, weights, capacity, currentIndex + 1);

    dp[currentIndex][capacity] = max(profit1, profit2);
    return dp[currentIndex][capacity];
  }

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
 vector<vector<long long>> memo(N, vector<long longa>(W+1, -1));
  long long res = knapsackRecursive(memo, v, w, W, 0);
  cout << res << endl; 
  
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:44:53: error: template argument 1 is invalid
   44 |  vector<vector<long long>> memo(N, vector<long longa>(W+1, -1));
      |                                                     ^
a.cc:44:53: error: template argument 2 is invalid
Language: C++

#include <iostream>
#include <vector>

using namespace std;

long long solveKnapsack(vector<int> &profits, vector<int> &weights, int capacity) {
    // basic checks
    if (capacity <= 0 || profits.empty() || weights.size() != profits.size()) {
      return 0;
    }

    int n = profits.size();
    vector<vector<long long >> dp(n, vector<long long >(capacity + 1));

    // populate the capacity=0 columns, with '0' capacity we have '0' profit
    for (int i = 0; i < n; i++) {
      dp[i][0] = 0;
    }

    // if we have only one weight, we will take it if it is not more than the capacity
    for (int c = 0; c <= capacity; c++) {
      if (weights[0] <= c) {
        dp[0][c] = profits[0];
      }
    }

    // process all sub-arrays for all the capacities
    for (int i = 1; i < n; i++) {
      for (int c = 1; c <= capacity; c++) {
        long long  profit1 = 0, profit2 = 0;
        // include the item, if it is not more than the capacity
        if (weights[i] <= c) {
          profit1 = profits[i] + dp[i - 1][c - weights[i]];
        }
        // exclude the item
        profit2 = dp[i - 1][c];
        // take maximum
        dp[i][c] = max(profit1, profit2);
      }
    }

    // maximum profit will be at the bottom-right corner.
    return dp[n - 1][capacity];
  }

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
 // vector<vector<long long>> memo(N, vector<long longa>(W+1, 0));
  long long res = knapSack(w, v, W);
  cout << res << endl; 
  
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:57:19: error: 'knapSack' was not declared in this scope
   57 |   long long res = knapSack(w, v, W);
      |                   ^~~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

long long knapSack(vector<int>& wt, vector<int>& v, int W) 
{ 
   int i, w; 
   int n = w.size();
   long long  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(v[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]; 
} 

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
 // vector<vector<long long>> memo(N, vector<long long>(W+1, 0));
  long long res = knapSack(w, v, W);
  cout << res << endl; 
  
}
  


Compiler output:
a.cc: In function 'long long int knapSack(std::vector<int>&, std::vector<int>&, int)':
a.cc:9:14: error: request for member 'size' in 'w', which is of non-class type 'int'
    9 |    int n = w.size();
      |              ^~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

long long knapSack(vector<int>& w, vector<int>& v, int W) 
{ 
   int i, w; 
   int n = w.size();
   long long  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]; 
       } 
   } 
  
   return K[n][W]; 
} 

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
 // vector<vector<long long>> memo(N, vector<long long>(W+1, 0));
  long long res = knapSack(w, v, W);
  cout << res << endl; 
  
}
  


Compiler output:
a.cc: In function 'long long int knapSack(std::vector<int>&, std::vector<int>&, int)':
a.cc:8:11: error: declaration of 'int w' shadows a parameter
    8 |    int i, w;
      |           ^
a.cc:6:33: note: 'std::vector<int>& w' previously declared here
    6 | long long knapSack(vector<int>& w, vector<int>& v, int W)
      |                    ~~~~~~~~~~~~~^
a.cc:9:14: error: request for member 'size' in 'w', which is of non-class type 'int'
    9 |    int n = w.size();
      |              ^~~~
a.cc:19:21: error: 'wt' was not declared in this scope; did you mean 'w'?
   19 |            else if (wt[i-1] <= w)
      |                     ^~
      |                     w
a.cc:20:32: error: 'val' was not declared in this scope
   20 |                  K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
      |                                ^~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
	
  if(index == v.size() or W <= 0)return 0;
  
  if(memo[index][W] != 0)return memo[index][W];
  
  if(w[index] <= W){
  	memo[index][W] = max(v[index] + helper(v, w, W - w[index], memo, index + 1),
                         helper(v, w, W, memo, index + 1));
  }
  return memo[index][W];
}

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
  
  vector<vector<int>> memo(N, vector<int>(W+1, 0));
  inr res = helper(v, w, W, memo, 0);
  cout << res << endl;
  return 
  
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: 'inr' was not declared in this scope; did you mean 'int'?
   30 |   inr res = helper(v, w, W, memo, 0);
      |   ^~~
      |   int
a.cc:31:11: error: 'res' was not declared in this scope
   31 |   cout << res << endl;
      |           ^~~
a.cc:34:1: error: expected primary-expression before '}' token
   34 | }
      | ^
a.cc:32:9: error: expected ';' before '}' token
   32 |   return
      |         ^
      |         ;
   33 | 
   34 | }
      | ~
Language: C++

#include <iostream>
#include<string>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include <cctype>
#include <cstdio>
#define endl '\n'
#define Bedoazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const long long N = 1e5 + 5, mod = 1e9 + 7;
 
pair<long long, long long>bag[N];

long long dp[105][N];
    
int main() {

    Bedoazim

    int bagsize, n;

    cin >> n >> bagsize;

    

    for (int i = 1; i <= n; i++) {

        cin >> bag[i].first >> bag[i].second;

    }
    
    memset(dp, 0, sizeof dp);
    
    for (int i = 1; i <= n; i++) {

        for (int j = 0; j <= bagsize; j++) {

            long long a = 0, b = 0;

            if (i-1>=0)
                a = dp[i-1][j];

            if (j >= bag[i].first) {

                b = dp[i-1][j - bag[i].first]+bag[i].second;
            
            }

            dp[i][j] = max(a, b);
        }
    }
   
    cout << dp[n][bagsize];

}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: 'memset' was not declared in this scope
   39 |     memset(dp, 0, sizeof dp);
      |     ^~~~~~
a.cc:13:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   12 | #include <cstdio>
  +++ |+#include <cstring>
   13 | #define endl '\n'
Language: C++

#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 5;
long long weigh[N], val[N], dp[105][N];

int main()
{
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> weigh[i] >> val[i];
	for (int it = 1; it <= n; it++)
	{
		for (int rem = 1; rem <= w; rem++)
		{
			long long op1, op2=0;
			op1 = dp[it - 1][rem];
			if (rem >= weigh[it])
				op2 = val[it] + dp[it][rem - weigh[it]];
			dp = [it][rem] = max(op1, op2);
		}
	}
	cout << dp[n][w] << "\n";

	return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:21:34: error: expected '{' before '[' token
   21 |                         dp = [it][rem] = max(op1, op2);
      |                                  ^
a.cc: In function 'int main()':
a.cc:21:34: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
Language: C++

#include <sstream>
#include <fstream>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <cstdio>
 
 
#include <stdlib.h>
#include <iostream>
#include <chrono> //clock
#include <vector>
#include <string>
#include <iomanip>  //setprecision function
#include <cmath>	//math
#include <cstdio>
#include <vector>	//vector array
#include <algorithm>	//STL algorithm
#include <set> //STL library set
#include <sstream> // for stringstream
 
 
using namespace std;
using namespace std::chrono; 
 
 
int main() {
	stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
 
 
	int n,k;
	cin>>n>>k;
	int vec[n][2];
	for(int i=0;i<n;i++){
		cin>>vec[i][0];
		cin>>vec[i][1];
	}
	
	vector<vector<long long>> dp(n+1,vector<long long>(k+1,0));
 
	
	//int dp[n][k];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(j-vec[i-1][0]>-1){
				if(i==3 and j==3) deb(dp[i-1][j-vec[i-1][0]]+vec[i-1][1]);
				dp[i][j]=max(vec[i-1][1]+dp[i-1][j-vec[i-1][0]],dp[i][j-1]);
			}else dp[i][j]=dp[i-1][j];
		}
	}
	
	cout<<dp[n][k]<<endl;
	
	return 0;
}
 
 

Compiler output:
a.cc: In function 'int main()':
a.cc:71:51: error: 'deb' was not declared in this scope
   71 |                                 if(i==3 and j==3) deb(dp[i-1][j-vec[i-1][0]]+vec[i-1][1]);
      |                                                   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll dp[105][100005];
ll fun(ll wt[],ll v[],ll n,ll w)
{
    if(dp[n][w]!=-1)
    return dp[n][w];
    if(n==0 || w==0)
    return dp[n][w]=0;
    if(wt[n-1]>w)
    return dp[n][w]=fun(wt,v,n-1,w);
    return dp[n][w]=max(fun(wt,v,n-1,w),(v[n-1]+fun(wt,v,n-1,w-wt[n-1])));
}
int main()
{
    ll t,n,w;
        cin>>n;
        cin>>w;
        int wt[n],v[n];
        for(int i=0;i<n;i++)
        cin>>v[i];
        for(int i=0;i<105;i++)
        {
            for(int j=0;j<100005;j++)
            dp[i][j]=-1;
        }
        for(int i=0;i<n;i++)
        cin>>wt[i];
        cout<<fun(wt,v,n,w)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:19: error: cannot convert 'int*' to 'long long int*'
   30 |         cout<<fun(wt,v,n,w)<<endl;
      |                   ^~
      |                   |
      |                   int*
a.cc:5:11: note:   initializing argument 1 of 'long long int fun(long long int*, long long int*, long long int, long long int)'
    5 | ll fun(ll wt[],ll v[],ll n,ll w)
      |           ^
Language: Java

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), w = sc.nextInt();
        int[] ws = new int[n];
        long[] vs = new long[n];

        long[][] dp = new long[n][w + 1];
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        //System.out.println(maxKnapsack(ws, vs, 0, w, dp));
        System.out.println(maxKnapsack(ws, vs, w));
    }


    private static long maxKnapsack(int[] ws, long[] vs, int w) {
        long[][] dp = new long[ws.length+1][w + 1];

        for (int i = 1; i <= ws.length; i++) {
            for (int s = w; s >= ws[i-1]; s--) {
                dp[i][s] = Math.max(dp[i-1][s - ws[i-1]] + vs[i-1], dp[i-1][s]);
            }
        }
        return dp[ws.length][w];
    }
}



Compiler output:
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
int w[105],v[105];
int dp[105][100005];
int N;
int fun(int i,int W)
{
  if(i>=N)
    return 0;
  if(w[i]<=W)
  {
    if(dp[i+1][W-w[i]]==-1)
      dp[i+1][W-w[i]]=fun(i+1,W-w[i]);
    if(dp[i+1][W]==-1)
      dp[i+1][W]=fun(i+1,W);
    dp[i][W]=(v[i]+dp[i+1][W-w[i]])>=(dp[i+1][W])?(v[i]+dp[i+1][W-w[i]]):(dp[i+1][W]);
  }
  else
  {
    if(dp[i+1][W]==-1)
      dp[i+1][W]=fun(i+1,W);
    dp[i][W]=dp[i+1][W];
  }
  return dp[i][W];
}
int main()
{
  int i,j;
  cin>>N>>W;
  for(i=0;i<N;i++)
  {
    cin>>w[i]>>v[i];
  }
  for(i=0;i<100;i++)
  {
    for(j=0;j<100005;i++)
      dp[i][j]=-1;
  }
  dp[0][W]=fun(0,W);
  cout<<dp[0][W]<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:11: error: 'W' was not declared in this scope
   34 |   cin>>N>>W;
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
int w[105],v[105];
int dp[105][100005];
int fun(int i,int W)
{
  if(i>=N)
    return 0;
  if(w[i]<=W)
  {
    if(dp[i+1][W-w[i]]==-1)
      dp[i+1][W-w[i]]=fun(i+1,W-w[i]);
    if(dp[i+1][W]==-1)
      dp[i+1][W]=fun(i+1,W);
    dp[i][W]=(v[i]+dp[i+1][W-w[i]])>=(dp[i+1][W])?(v[i]+dp[i+1][W-w[i]]):(dp[i+1][W]);
  }
  else
  {
    if(dp[i+1][W]==-1)
      dp[i+1][W]=fun(i+1,W);
    dp[i][W]=dp[i+1][W];
  }
  return dp[i][W];
}
int main()
{
  int i,j;
  cin>>N>>W;
  for(i=0;i<N;i++)
  {
    cin>>w[i]>>v[i];
  }
  for(i=0;i<100;i++)
  {
    for(j=0;j<100005;i++)
      dp[i][j]=-1;
  }
  dp[0][W]=fun(0,W);
  cout<<dp[0][W]<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int fun(int, int)':
a.cc:12:9: error: 'N' was not declared in this scope
   12 |   if(i>=N)
      |         ^
a.cc: In function 'int main()':
a.cc:33:8: error: 'N' was not declared in this scope
   33 |   cin>>N>>W;
      |        ^
a.cc:33:11: error: 'W' was not declared in this scope
   33 |   cin>>N>>W;
      |           ^
Language: C++

using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>

#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;

ll Knapsack_Memoize(vi& w, vll& p, int idx, int wt, vvi& dp)
{
	//it is important to put this weight as first statement for base case
	//if not : if wt becomes -ve and idx is last index and this statement is 2nd
	// it will return 0 and counted as a valid case rather than a invalid case
	if (wt < 0)
		return INT_MIN;

	if (idx == w.size() || wt == 0)
		return 0;

	if (dp[idx][wt] != -1)
		return dp[idx][wt];
	// Case 1. include current item n in knapSack (v[n]) and recur for
	// remaining items (n - 1) with decreased capacity (W - w[n])
	ll include = p[idx] + Knapsack_naive(w, p, idx + 1, wt - w[idx]);

	// Case 2. exclude current item n from knapSack and recur for
	// remaining items (n - 1)
	ll exclude = Knapsack_naive(w, p, idx + 1, wt);

	// return maximum value we get by including or excluding current item
	dp[idx][wt] = max(include, exclude);
	return dp[idx][wt];
}
int main()
{
	int n, w;
	cin >> n >> w;
	vi wts(n);
	vll price(n);
	rep(n)
	{
		cin >> wts[i] >> price[i];
	}
	//auto ans = Knapsack_naive(wts, price, 0, w);
	//cout << ans;
	vvi dp(n);
	for (int i = 0; i < n; ++i)
	{
		dp[i].resize(w + 1, -1);
	}
	auto ans = Knapsack_Memoize(wts, price, 0, w , dp);
	cout << ans;
	ret(0);
}

Compiler output:
a.cc: In function 'll Knapsack_Memoize(vi&, vll&, int, int, vvi&)':
a.cc:50:31: error: 'Knapsack_naive' was not declared in this scope; did you mean 'Knapsack_Memoize'?
   50 |         ll include = p[idx] + Knapsack_naive(w, p, idx + 1, wt - w[idx]);
      |                               ^~~~~~~~~~~~~~
      |                               Knapsack_Memoize
Language: C++

#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define MOD 1000000007
using namespace std;
int dp[100000][100];
int fun(,int w,int a[],int b[],int n ){
    if(w==0 || n==0){
        return 0;
    }
    else if(dp[n][w]!=-1){
        return dp[n][w];
    }
    else if(a[n]>w){
        dp[w][n]=fun(w,a,b,n-1);
    }
    else{
        int c=n-1;
        return dp[w][n]=max(fun(w-a[n]+b[n],a,b,c),fun(w,a,b,c));
    }
}
int32_t main(){
    int n,w;
    cin>>n>>w;
    int a[n],b[n];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    mem(dp,-1);
    cout<<fun(w,a,b,n-1);
}


Compiler output:
a.cc:9:9: error: expected primary-expression before ',' token
    9 | int fun(,int w,int a[],int b[],int n ){
      |         ^
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long int
      |             ^~~~
a.cc:9:10: note: in expansion of macro 'int'
    9 | int fun(,int w,int a[],int b[],int n ){
      |          ^~~
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long int
      |             ^~~~
a.cc:9:16: note: in expansion of macro 'int'
    9 | int fun(,int w,int a[],int b[],int n ){
      |                ^~~
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long int
      |             ^~~~
a.cc:9:24: note: in expansion of macro 'int'
    9 | int fun(,int w,int a[],int b[],int n ){
      |                        ^~~
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long int
      |             ^~~~
a.cc:9:32: note: in expansion of macro 'int'
    9 | int fun(,int w,int a[],int b[],int n ){
      |                                ^~~
a.cc:9:38: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | int fun(,int w,int a[],int b[],int n ){
      |                                      ^
a.cc: In function 'int32_t main()':
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     for(i=0;i<n;i++){
      |         ^
a.cc:32:14: error: 'fun' cannot be used as a function
   32 |     cout<<fun(w,a,b,n-1);
      |           ~~~^~~~~~~~~~~
Language: C++


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

ll dp[10002][10002]={-1};

ll knapsack(ll *wt, ll *val, ll a, ll sum){
	if(a==0 || sum==0) return 0;
	if(sum-wt[a-1]>=0){
		if(dp[a][sum]==-1){
			return dp[a][sum]=max(val[a-1]+knapsack(wt,val,a-1,sum-wt[a-1]),knapsack(wt,val,a-1,sum));
			}
	    else {
	    	return dp[a][sum];
	    }
	}
	else {
		if(dp[a][sum]==-1){
			return dp[a][sum]=knapsack(wt,val,a-1,sum);
		}
		else return dp[a][sum];}
}

int main() {
	fast;
	read(a)
	read(b)
	ll val[a]={0};
	ll arr[a]={0};
	loop(i,0,a){
		cin>>arr[i]>>val[i];
	}
	cout<<knapsack(arr,val,a,b)<<endl;
	return 0;
}


Compiler output:
g++: internal compiler error: File size limit exceeded signal terminated program as
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
Language: C++

#include<bits/stdc++.h>
#define ll          long long int
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() 
{   
  ios
  ll n , W ;
  cin>> n>> W ;
  ll wt[n] ;
  ll v[n] ;
  for(int i=0;i<n;i++)
  {
    cin>> wt[i] >> v[i] ;
  }
  int i, w; 
  int K[n+1][W+1];  
  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(v[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  cout<< K[n][W] ;
  return 0 ;
}


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

#include<bits/stdc++.h>
#define ll          long long int
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() 
{   
  ios
  ll n , W ;
  cin>> n>> W ;
  ll wt[n] ;
  ll v[n] ;
  for(int i=0;i<n;i++)
  {
    cin>> wt[i] >> v[i] ;
  }
  int i, w; 
  int K[n+1][W+1];  
  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<< K[n][W] ;
  return 0 ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:32: error: 'val' was not declared in this scope
   27 |                  K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
      |                                ^~~
Language: Java

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

public class Practice1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int W = scanner.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int i = 0; i < n; ++i) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }
        System.out.println(knapsack(W, w, v));
    }

    private static long knapsack(int W, int[] w, int[] v) {
        long[][] dp = new long[w.length][W + 1];
        for (long[] dpRow : dp) {
            Arrays.fill(dpRow, -1);
        }
        return calcMaxValue(0, w, v, W, dp);
    }

    private static long calcMaxValue(int curInd, int[] w, int[] v, int W, long[][] dp) {
        if (curInd >= w.length || w[curInd] > W)
            return 0;
        if (dp[curInd][W] != -1)
            return dp[curInd][W];
        long maxValue = Math.max(
                calcMaxValue(curInd + 1, w, v, W, dp),
                v[curInd] + calcMaxValue(curInd + 1, w, v, W - w[curInd], dp));
        dp[curInd][W] = maxValue;
        return maxValue;
    }
}


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

#include <bits/stdc++.h>

using namespace std;

struct Item
{
  int w;
  int v;
};

int main()
{
  ios_base::sync_with_stdio(false);
  cint.tie(nullptr);
  
  int N, W;
  cin >> N >> W;
  vector<Item> items(N);
  for(auto& item : items)
  {
    cin >> item.w >> item.v;
  }
  
  vector<vector<int64_t> > dp(N + 1, vector<int64_t>(W + 1));
  
  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)
    {
      dp[i][j] = max(dp[i - 1][j], dp[i][max(j - items[i - 1].w, 0)] + items[i - 1].v);
    }
  }
  
  cout << dp[N][W] << "\n";
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'cint' was not declared in this scope; did you mean 'uint'?
   14 |   cint.tie(nullptr);
      |   ^~~~
      |   uint
Language: C++

#include <bits/stdc++.h>
#define whatis(x) cout << #x << " is " << x << endl;
#define MOD 1000000007
#define endl "\n"
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAX 100001
#define N 101
using namespace std;

vector<int> weight(MAX);
vector<int> value(MAX);
ll k[N][MAX];

ll knapsack(int n, int wmax)
{
    for (int i = 0; i <= n; i++)
    {
        for (int w = 0; w <= wmax; w++)
        {
            if (i = 0 || w = 0)
                k[i][w] = 0;
            else if (weight[i]<=wmax)
            {
                ll consider = 0;
                consider = value[i - 1] + k[i - 1][wmax - weight[i - 1]];
                ll not_consider = k(i-1,w);
                k[i][w] = max(not_consider, consider);
            }
            else
                k[i][w]=k[i-1][w];
        }
    }
    return k[n][wmax];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, i, j, wmax;
    cin >> n >> wmax;
    for (i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    ll ans = knapsack(n, wmax);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int knapsack(int, int)':
a.cc:25:23: error: lvalue required as left operand of assignment
   25 |             if (i = 0 || w = 0)
      |                     ~~^~~~
a.cc:31:36: error: 'k' cannot be used as a function
   31 |                 ll not_consider = k(i-1,w);
      |                                   ~^~~~~~~
Language: C++

import sys

input = sys.stdin.readline

N, W = map(int, input().split())
 
dpi = [[0 for i in range(W+1)] for j in range(N+1)]
 
for i in range(1, N+1):
  w, v = map(int, input().split())
  
  for j in range(W+1):
    if j < w:
      dpi[i][j] = dpi[i-1][j]
    else:
      dpi[i][j] = max(dpi[i-1][j-w] + v, dpi[i-1][j])
print(dpi[N][W])

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

#include<bits/stdc++.h>
using namesapce std;
int knapsack(int a[],int b[],w,n){
  if(n==0 || w==0)
    return 0;
  if(w<b[n-1])
    return knapsack(a,b,w,n-1);
  else
    return max(a[n-1]+knapsack(a,b,w-b[n-1],n-1),knapsack(a,b,w,n-1));
}
int main(){
  int n,w;
  cin>>n>>w;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  int ans;
  ans=knapsack(a,b,w,n);
  cout<<ans<<"\n";
  
}  

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namesapce'
    2 | using namesapce std;
      |       ^~~~~~~~~
a.cc:3:30: error: 'w' has not been declared
    3 | int knapsack(int a[],int b[],w,n){
      |                              ^
a.cc:3:32: error: 'n' has not been declared
    3 | int knapsack(int a[],int b[],w,n){
      |                                ^
a.cc: In function 'int knapsack(int*, int*, int, int)':
a.cc:4:6: error: 'n' was not declared in this scope
    4 |   if(n==0 || w==0)
      |      ^
a.cc:4:14: error: 'w' was not declared in this scope
    4 |   if(n==0 || w==0)
      |              ^
a.cc:6:6: error: 'w' was not declared in this scope
    6 |   if(w<b[n-1])
      |      ^
a.cc:6:10: error: 'n' was not declared in this scope
    6 |   if(w<b[n-1])
      |          ^
a.cc:9:12: error: 'max' was not declared in this scope; did you mean 'std::max'?
    9 |     return max(a[n-1]+knapsack(a,b,w-b[n-1],n-1),knapsack(a,b,w,n-1));
      |            ^~~
      |            std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:13:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   13 |   cin>>n>>w;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:21:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |   cout<<ans<<"\n";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

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

using namespace std;

typedef long long LL;
const int N = 101;
const int V = 100001;

LL dp[N][V], w[N], v[N];

int main() {
    // freopen("a.txt", "r", stdin);
    int n, wl;
    cin >> n >> wl;
    for(int i = 1; i <= n; ++i) cin >> w[i] >> v[i];

    memset(dp, 0x7f, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= V; ++j) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if(j >= v[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
        }
    }
    int res = 0;
    for(int i = V - 1; i >= 0; --i) {
        if(dp[n][i] <= wl) {
            res = i; break;
        }
    }
    cout << res << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'memset' was not declared in this scope
   19 |     memset(dp, 0x7f, sizeof(dp));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <memory>
  +++ |+#include <cstring>
    4 |
Language: Java

import java.util.Scanner;

public class Knapsack1 {
    private static long maxKnapsack(int[] ws, long[] vs, int idx, int total, long[] dp) {
        if(idx < ws.length && ws[idx] > total) return 0;
        if( total == 0) return 0;
        if(idx == ws.length ||total < 0) return -1;
        long max = Long.MIN_VALUE;

        if(dp[idx] != 0)
            return dp[idx];
        for(int i = idx; i < ws.length; i++){
            long res = maxKnapsack(ws, vs, i + 1, total - ws[i], dp);
            if(res == -1) continue;
            else
                max = Long.max(max, vs[i] + res);
        }
        dp[idx] = max;
        return max;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), w = sc.nextInt();
        int[] ws = new int[n];
        long[] vs = new long[n];

        long[] dp = new long[n];
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        System.out.println(maxKnapsack(ws, vs, 0, w, dp));
    }
}



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

import java.util.Scanner;
public class Knapsack {
    private static long maxKnapsack(int[] ws, long[] vs, int idx, int total, long[] dp) {
        if(idx < ws.length && ws[idx] > total) return 0;
        if( total == 0) return 0;
        if(idx == ws.length ||total < 0) return -1;
        long max = Long.MIN_VALUE;

        if(dp[idx] != 0)
            return dp[idx];
        for(int i = idx; i < ws.length; i++){
            long res = maxKnapsack(ws, vs, i + 1, total - ws[i], dp);
            if(res == -1) continue;
            else
                max = Long.max(max, vs[i] + res);
        }
        dp[idx] = max;
        return max;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), w = sc.nextInt();
        int[] ws = new int[n];
        long[] vs = new long[n];

        long[] dp = new long[n];
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        System.out.println(maxKnapsack(ws, vs, 0, w, dp));
    }
}

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