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

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

public class Knapsack {
	static int n;
	static int w;
	static int[] value;
	static int[] weight;
	static long[][] dp;

	public static long knapsack(int idx, int rweight) {
		if (rweight < 0) {
			return -(int) 1e9;
		}
		if (idx == n) {
			return 0;
		}
		if (dp[idx][rweight] != -1) {
			return dp[idx][rweight];
		}
		long take = value[idx] + knapsack(idx + 1, rweight - weight[idx]);
		long leave = knapsack(idx + 1, rweight);
		return dp[idx][rweight] = Math.max(take, leave);
	}

	public static void main(String[] args) throws IOException {

		PrintWriter out = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		w = Integer.parseInt(st.nextToken());
		value = new int[n];
		weight = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			weight[i] = Integer.parseInt(st.nextToken());
			value[i] = Integer.parseInt(st.nextToken());
		}
		dp = new long[n][w + 1];
		for (long[] i : dp) {
			Arrays.fill(i, -1);
		}
		out.println(knapsack(0, w));
		out.close();

	}
}


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

import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
	  int W = sc.nextInt();
      int w[]=new int[n];
      int v[] = new int[n];
      
      for(int i=0; i<n; i++){
         w[i] = sc.nextInt();
         v[i] = sc.nextInt();
      }
      
      long dp[][] =  new long[n][W+1];
      
      for(int i=0;i<n; i++)
      	Arrays.fill(dp[i], -1);
       
      System.out.println(maxSum(w, v, W, 0, dp));
      
    }
  
  public static long maxSum(int wt[], int v[], int W, int pos, int dp[][]){
    
  	if(pos >= wt.length || W == 0)
      return 0;
    
  //  if(prevSelected!=-1 && dp[pos][prevSelected] != Integer.MIN_VALUE)
    //  return dp[pos][prevSelected];
    
    if(dp[pos][W] != -1)
      return dp[pos][W];
    
    
    int sum = 0;
    if(wt[pos] > W)
      return dp[pos][W] = maxSum(wt, v, W, pos+1, dp);
    
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1, dp), maxSum(wt, v, W, pos+1, dp));
    
  }
}


Compiler output:
Main.java:28: error: incompatible types: long[][] cannot be converted to int[][]
      System.out.println(maxSum(w, v, W, 0, dp));
                                            ^
Main.java:46: error: incompatible types: possible lossy conversion from long to int
      return dp[pos][W] = maxSum(wt, v, W, pos+1, dp);
                                ^
Main.java:48: error: incompatible types: possible lossy conversion from long to int
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1, dp), maxSum(wt, v, W, pos+1, dp));
                                ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
	  int W = sc.nextInt();
      int w[]=new int[n];
      int v[] = new int[n];
      
      for(int i=0; i<n; i++){
         w[i] = sc.nextInt();
         v[i] = sc.nextInt();
      }
      
      int dp[][] =  new int[n][W+1];
      
      for(int i=0;i<n; i++)
      	Arrays.fill(dp[i], -1);
       
      System.out.println(maxSum(w, v, W, 0, dp));
      
    }
  
  public static long maxSum(int wt[], int v[], int W, int pos, int dp[][]){
    
  	if(pos >= wt.length || W == 0)
      return 0;
    
  //  if(prevSelected!=-1 && dp[pos][prevSelected] != Integer.MIN_VALUE)
    //  return dp[pos][prevSelected];
    
    if(dp[pos][W] != -1)
      return dp[pos][W];
    
    
    int sum = 0;
    if(wt[pos] > W)
      return dp[pos][W] = maxSum(wt, v, W, pos+1, dp);
    
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1, dp), maxSum(wt, v, W, pos+1, dp));
    
  }
}


Compiler output:
Main.java:46: error: incompatible types: possible lossy conversion from long to int
      return dp[pos][W] = maxSum(wt, v, W, pos+1, dp);
                                ^
Main.java:48: error: incompatible types: possible lossy conversion from long to int
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1, dp), maxSum(wt, v, W, pos+1, dp));
                                ^
2 errors
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
	  int W = sc.nextInt();
      int w[]=new int[n];
      int v[] = new int[n];
      
      for(int i=0; i<n; i++){
         w[i] = sc.nextInt();
         v[i] = sc.nextInt();
      }
      
      int dp[][] =  new int[n][W+1];
      
      for(int i=0;i<n; i++)
      	Arrays.fill(dp[i], -1);
       
      System.out.println(maxSum(w, v, W, 0, dp));
      
    }
  
  public static int maxSum(int wt[], int v[], int W, int pos, int dp[][]){
    
  	if(pos >= wt.length || W == 0)
      return 0;
    
  //  if(prevSelected!=-1 && dp[pos][prevSelected] != Integer.MIN_VALUE)
    //  return dp[pos][prevSelected];
    
    if(dp[pos][W] != -1)
      return dp[pos][W];
    
    
    int sum = 0;
    if(wt[pos] > W)
      return dp[pos][W] = maxSum(wt, v, W, pos+1);
    
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1), maxSum(wt, v, W, pos+1));
    
  }
}


Compiler output:
Main.java:46: error: method maxSum in class Main cannot be applied to given types;
      return dp[pos][W] = maxSum(wt, v, W, pos+1);
                          ^
  required: int[],int[],int,int,int[][]
  found:    int[],int[],int,int
  reason: actual and formal argument lists differ in length
Main.java:48: error: method maxSum in class Main cannot be applied to given types;
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1), maxSum(wt, v, W, pos+1));
                                         ^
  required: int[],int[],int,int,int[][]
  found:    int[],int[],int,int
  reason: actual and formal argument lists differ in length
Main.java:48: error: method maxSum in class Main cannot be applied to given types;
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1), maxSum(wt, v, W, pos+1));
                                                                          ^
  required: int[],int[],int,int,int[][]
  found:    int[],int[],int,int
  reason: actual and formal argument lists differ in length
3 errors
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
	  int W = sc.nextInt();
      int w[]=new int[n];
      int v[] = new int[n];
      
      for(int i=0; i<n; i++){
         w[i] = sc.nextInt();
         v[i] = sc.nextInt();
      }
      
      int dp[][] =  new int[n][3];
       
      for(int i=0; i<n; i++)
      Arrays.fill(dp[i], Integer.MIN_VALUE);
      
      System.out.println(maxSum(w, v, W, 0));
      
    }
  
  public static int maxSum(int wt[], int v[], int W, int pos){
    
  	if(pos >= wt.length)
      return 0;
    
  //  if(prevSelected!=-1 && dp[pos][prevSelected] != Integer.MIN_VALUE)
    //  return dp[pos][prevSelected];
    
    int sum = 0;
    if(wt[pos] > W)
      return maxSum(wt, v, W, pos+1);
    
    return Math.max(v[pos]+ maxSum(wt, v, W-wr[pos], pos+1), maxSum(wt, v, W, pos+1));
    
  }
}


Compiler output:
Main.java:44: error: cannot find symbol
    return Math.max(v[pos]+ maxSum(wt, v, W-wr[pos], pos+1), maxSum(wt, v, W, pos+1));
                                            ^
  symbol:   variable wr
  location: class Main
1 error
Language: C++

/* A Naive recursive implementation of 0-1 Knapsack problem */
#include<stdio.h> 

// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 

// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
// Base Case 
if (n == 0 || W == 0) 
	return 0; 

// If weight of the nth item is more than Knapsack capacity W, then 
// this item cannot be included in the optimal solution 
if (wt[n-1] > W) 
	return knapSack(W, wt, val, n-1); 

// Return the maximum of two cases: 
// (1) nth item included 
// (2) not included 
else return max( val[n-1] + knapSack(W-wt[n-1], wt, val, n-1), 
					knapSack(W, wt, val, n-1) 
				); 
} 

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


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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=1;i<n;i++)
int knapsack(int wt,int v[],int w[],int n)
{
	if(n==0||wt==0)
	return 0;
	if(w[n-1]>wt)
	return knapsack(wt,v,w,n-1);
	else
	return max(v[n-1]+knapsack(wt-w[n-1],v,w,n-1),knapsack(wt,v,w,n-1));
}
int main()
{
	int n,W;
	cin>>n>>W;
	ll v[n],w[n];
	for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];
	cout<<knapsack(W,v,w,n)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: cannot convert 'long long int*' to 'int*'
   21 |         cout<<knapsack(W,v,w,n)<<endl;
      |                          ^
      |                          |
      |                          long long int*
a.cc:5:25: note:   initializing argument 2 of 'int knapsack(int, int*, int*, int)'
    5 | int knapsack(int wt,int v[],int w[],int n)
      |                     ~~~~^~~
Language: C++

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

int knapsack(vector<vector<int>> &items, int weight, int n){
    if(n==0){
        if(weight >= items[n][0]) return items[n][1];
        else return 0;
    }
    return max(knapsack(items, weight - items[n][0], n-1) + items[n][1] , knapsack(items,weight, n-1));
} 
int main(){
    int num_items, weight;
    cin>>num_items>>weight;
    vector<vector<int>> items;
    for(int i=0;i<num_items ; i++){
        for(int j=0;j<2;j++{
            cin>>items[i][j];
        }
    }
    cout<<knapsack(items, weight, num_items-1);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:28: error: expected ')' before '{' token
   16 |         for(int j=0;j<2;j++{
      |            ~               ^
      |                            )
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
ll dp[105][100005]
int main()
{
	int N,W;
	cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i = 0; i < N; i++) {
        cin>>w[i]>>v[i];
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(i == 0) { if(j >= w[i]) dp[i][j] = v[i];}
            else if(j - w[i] >= 0) dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }

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

    return 0;
}


Compiler output:
a.cc:6:1: error: expected initializer before 'int'
    6 | int main()
      | ^~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define str string
#define fori(i,N) for(long long i=1;i<=N;++i)
#define forj(j,m) for(long long j=1;j<=m;++j)
#define fork(k,n) for(long long k=1;k<=n;++k)
#define fors(i,ssz) for(long long i=0;i<s.size();++i)
#define Need_for_Speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
ll N,W,w[101],v[101],dp[101][100001],s,i;
int main(){
	cin>>N>>W;
	fori(i,N)
	cin>>w[i]>>v[i];
	
	for(i=0;i<=W;++i)       
    A[0][i]=0;
    
	for(s=1;s<=N;++s){                   
    	for(i=0;i<=W;++i){
    		
        	dp[s][i]=dp[s-1][i];
			 
        	if(i >= w[s] && (dp[s - 1][ i - w[s] ] + v[s] > dp[s][i]))
            dp[s][i] = dp[s-1][i-w[s]]+v[s];
    	}
	}
	cout<<dp[N][W];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'A' was not declared in this scope
   18 |     A[0][i]=0;
      |     ^
Language: C++

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

void foo(vector<vector<int>> &vec, int w) {
  vector<vector<int>> dp(n + 1, vector<int>(w+1, 0));
  for (int i = 1; i < vec.size(); i++) {
    for (int j = 1; j <= w; j++) {
      if (j >= vec[i][0]) {
        dp[i][j] = max(vec[i][1] + dp[i-1][j - vec[i][0]], dp[i-1][j]);
      } else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  cout << dp[n][w];
}

int main() {
  int n, w;
  cin >> n >> w;
  vector<vector<int>> vec(n, vector<int>(2, 0));
  for (auto i = 0; i < vec.size(); i++) {
    for (auto j = 0; j < 2; j++) {
      cin >> vec[i][j];
    }
  }
  foo(vec, w);
  return 0;
}


Compiler output:
a.cc: In function 'void foo(std::vector<std::vector<int> >&, int)':
a.cc:5:26: error: 'n' was not declared in this scope
    5 |   vector<vector<int>> dp(n + 1, vector<int>(w+1, 0));
      |                          ^
Language: Java

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    long[] val = new long[n];
    long[] wt = new long[n];
    for(int i=0;i<n;i++){
      String[] str = br.readLine().split(" ");
      wt[i] = Long.parseLong(str[0]);
      val[i] = Long.parseLong(str[1]);
    }
    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>=wt[i-1])
          dp[i][j] = Math.max(dp[i-1][j], val[i-1] + dp[i-1][j-wt[i-1]]);
        else
          dp[i][j] = dp[i-1][j];
      }
    }
    long max = 0;
    for(int i=0;i<=W;i++)
      max = Math.max(max,dp[n][i]);
    System.out.println(max);
  }
}


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

#include<bits/stdc++.h>

using namespace std;

const int m=1e5+1;
long long dp[m],weight[100],profit[100];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,size;
	cin >> n >> size;
	
	for(int i=0;i<n;i++)
		cin >> weight[i] >> profit[i];
	memset(dp,0,sizeof(dp));
	
	for(int i=0;i<n;i++){
		for(int j=size;j >= weight[i];j--){
			dp[j]=max(dp[j],profit[i]+dp[j-weight[i]]);
		}
	}
	cout<<dp[size]<<"\n";
}

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<stdio.h>
#include<stdlib.h>

void main(){
	int n,size,i,j;
	long long *dp;
	int *profit,*weight;
	
	scanf("%d%d",&n,&size);
	
	profit=(int*)calloc(n,sizeof(int));
	weight=(int*)calloc(n,sizeof(int));
	for(i=0;i<n;i++){
		scanf("%d%d",weight+i,profit+i);
	}
	dp=(long long*)calloc(size+1,sizeof(long long));
	for(i=0;i<n;i++){
		for(j=size;j>=weight[i];j--)
			dp[j]=max(dp[j],profit[i]+dp[j-weight[i]]);
	}
	printf("%lld\n",dp[size]);
}

Compiler output:
main.c: In function 'main':
main.c:19:31: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   19 |                         dp[j]=max(dp[j],profit[i]+dp[j-weight[i]]);
      |                               ^~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

void main(){
	int n,size,i,j;
	long long *dp;
	int *profit,*weight;
	
	scanf("%d%d",&n,&size);
	
	profit=(int*)calloc(n,sizeof(int));
	weight=(int*)calloc(n,sizeof(int));
	for(i=0;i<n;i++){
		scanf("%d%d",weight+i,profit+i);
	}
	dp=(long long*)calloc(size+1,sizeof(long long));
	for(i=0;i<n;i++){
		for(j=size;j>=weight[i];j--)
			dp[j]=max(dp[j],profit[i]+dp[j-weight[i]]);
	}
	printf("%lld\n",dp[size]);
}

Compiler output:
main.c:3:9: fatal error: conio.h: No such file or directory
    3 | #include<conio.h>
      |         ^~~~~~~~~
compilation terminated.
Language: Java

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

class Item {
	int weight, val;
	public Item(int weight, int val) {
		this.weight = weight;
		this.val = val;
	}
}
public class Main {


	public static void main(String[] args) {
		Main answer = new Main();
		System.out.println(answer.solve());
	}

	private long solve() {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int maxWeight = sc.nextInt();
		Item[] array = new Item[N+1];
		for(int i=1;i<=N;i++) {
			array[i] = new Item(sc.nextInt(), sc.nextInt());
		}
		//dp[i][j] = max value of in bag holding i items of maximum weight j
		// required dp[N][W]
 		long [][] dp = new long[N+1][maxWeight+1];

		dp[0][0] = 0;
		 
 		for(int w=0;w<=maxWeight;w++){
			dp[1][w]=0;
		}

		dp[1][array[1].weight] = array[1].val;
		 
  
		for(int i=2;i<=N;i++){
			for(int w=0;w<=maxWeight;w++){
				dp[i][w] = dp[i-1][w];
				if (array[i].weight>w) continue;
				dp[i][w] = Math.max(dp[i-1][w], dp[i-1][w-array[i].weight] + array[i].val);
			}
		}
		/*
		for(int i=1;i<=N;i++){
			System.out.println(Arrays.toString(dp[i]));
		}*/

		return dp[N][maxWeight];

	}

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

#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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; }

ll dp[101][100001]; //dpテーブル
int v[100],w[100];
int N,W;


ll rec(int i,int j){
   
  if(dp[i][j]>-1){
    return dp[i][j];
  }
  ll res;
  if(i==N){
    res= 0;
  }
  else if(j<w[i]){
    res = rec(i+1,j);//入らない時
  }
  else{
    res = chmax(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
    }
  return dp[i][j]=res;
  }

int main() {
  
  cin >>N>>W; 
  rep(i,N)
    cin >> w[i] >> v[i];

  for(int i=0;i<101;i++){
    for(int j=0;j<100001;j++){
      dp[i][j]= -1;
    }
  }
  
  
  cout << rec(0,W)<< endl; // 標準出力
}




Compiler output:
a.cc: In function 'long long int rec(int, int)':
a.cc:35:20: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   35 |     res = chmax(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
      |                 ~~~^~~~~~~
a.cc:14:40: note:   initializing argument 1 of 'bool chmax(T&, T) [with T = long long int]'
   14 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |                                     ~~~^
Language: C++

#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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; }

 int rec(int i,int j){
    if(dp([i][j])>=0){
      return dp[i][j];
    }
    int res;
    if(j<w[j]){
      rec(i+1,j);
    }
    else{
      res = chmax(rec(i+1,j),rec(i+1,j-w[j])+v[i]));
    }
  return dp[i][j]=res;
  }

int main() {
  int N,W; // 変数の宣言
  cin >>N>>W; // 標準入力
  int v[N],w[N];
  rep(i,N)
    cin >> v[i] >> w[i];
  int dp[N+1][W+1]={-1}; //dpテーブル

  

  
  cout << rec(0,W)<< endl; // 標準出力
}


Compiler output:
a.cc: In lambda function:
a.cc:18:14: error: expected '{' before '[' token
   18 |     if(dp([i][j])>=0){
      |              ^
a.cc: In function 'int rec(int, int)':
a.cc:18:14: error: no match for 'operator[]' (operand types are 'rec(int, int)::<lambda()>' and 'int')
a.cc:18:8: error: 'dp' was not declared in this scope
   18 |     if(dp([i][j])>=0){
      |        ^~
a.cc:22:10: error: 'w' was not declared in this scope
   22 |     if(j<w[j]){
      |          ^
a.cc:26:46: error: 'v' was not declared in this scope
   26 |       res = chmax(rec(i+1,j),rec(i+1,j-w[j])+v[i]));
      |                                              ^
a.cc:28:10: error: 'dp' was not declared in this scope
   28 |   return dp[i][j]=res;
      |          ^~
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>

using namespace std;

#define int long long  

const int maxn = 100 ;
const int W = 1e7 + 5;
const int inf = 1e9 ;

int w[maxn];
int v[maxn];
int memo[W][maxn];
int n;

int dp(int weight, int idx) {

    if(idx >= n ) {
        return 0 * 1LL;
    }

    int &ans = memo[weight][idx];

    if(ans != -1 ) {
        return ans;
    }

    ans = dp(weight, idx+1);

    if(weight >= w[idx]) {
        ans = max(ans, v[idx] + dp(weight - w[idx], idx + 1));
    }


    return ans;


}



int32_t main(){

	// #ifndef ONLINE_JUDGE 
	//   freopen("input.txt", "r", stdin);
	//   freopen("output.txt", "w", stdout);
	// #endif
    
    memset(memo, -1, sizeof(memo));
  
   int weight;

   cin >> n >> weight ;

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


   

  cout<< dp(weight, 0) << endl;
    

    return 0;


}

Compiler output:
/tmp/cchgtML9.o: in function `dp(long long, long long)':
a.cc:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchgtML9.o
/tmp/cchgtML9.o: in function `main':
a.cc:(.text+0x15b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchgtML9.o
a.cc:(.text+0x1e1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchgtML9.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>

using namespace std;

#define int long long  

const int maxn = 100 ;
const int W = 1e5 + 5;
const int inf = 1e9 ;

int w[maxn];
int v[maxn];
int memo[W][maxn];
int n;

int dp(int weight, int idx) {

    if(idx >= n ) {
        return 0 * 1LL;
    }

    int &ans = memo[weight][idx];

    if(ans != -1 ) {
        return ans;
    }

    ans = dp(weight, idx+1);

    if(weight >= w[idx]) {
        ans = max(ans, v[idx] + dp(weight - w[idx], idx + 1));
    }


    return ans;


}



int32_t main(){

	// #ifndef ONLINE_JUDGE 
	//   freopen("input.txt", "r", stdin);
	//   freopen("output.txt", "w", stdout);
	// #endif
    
    memset(memo, -1, sizeof(memo));
  
   int weight;

   cin >> n >> weight ;

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


   

  cout<< dp(weight, 0) << endl;
    

    return 0;


}

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

import java.util.*;
class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
    int t,n,i,j,l;
    t=in.nextInt();
    while(t--!=0)
    {
        n=in.nextInt();
l=in.nextInt();

        int w[]=new int[n];
int v[]=new int[n];
int p[][]=new int[n+1][l+1] ;
        	for(i=0;i<n;i++)
            {
                w[i]=in.nextInt();
v[i]=in.nextInt();
            }
            for(i=0;i<=n;i++)
            {
                for(j=0;j<=l;j++)
                {
                    p[i][j]=-1;
                }
            }

ghkll ob=new ghkll();
System.out.println(ob.count(w,v,n-1,l,p));	

    }

	
}
int count(int w[],int v[],int n, int l,int p[][])
{
if(n+1==0||l==0)
return 0;
    if(p[n][l]!=-1)
        return p[n][l];

if(w[n]<=l)
{
        p[n][l]=Math.max(v[n]+count(w,v,n-1,l-w[n],p),count(w,v,n-1,l,p));
          return(p[n][l]);
}
else
    p[n][l]=count(w,v,n-1,l,p);
    return(p[n][l]);
}
}

Compiler output:
Main.java:30: error: cannot find symbol
ghkll ob=new ghkll();
^
  symbol:   class ghkll
  location: class Main
Main.java:30: error: cannot find symbol
ghkll ob=new ghkll();
             ^
  symbol:   class ghkll
  location: class Main
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void max_new(int& a,int b)
{
  a = max(a,b);
}
int main()
{
  ll n,w;
  cin >> n >> w;
  vector<ll> dp(w+1);
  for(int i=0;i<n;i++)
  {
    int weight,val; 
    cin >> weight >> val;
    for(int j = w - weight;j>=0;j--)
    {
      max_new(dp[j+weight],dp[j]+val);
    }
  }
  int ans = 0;
  for(int i=0;i<=w;i++)
  {
    max_new(ans,dp[i]);
  }
  
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:14: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   19 |       max_new(dp[j+weight],dp[j]+val);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:19: note:   initializing argument 1 of 'void max_new(int&, int)'
    4 | void max_new(int& a,int b)
      |              ~~~~~^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void max_new(ll& a,ll b)
{
  a = max(a,b);
}
int main()
{
  ll n,w;
  cin >> n >> w;
  vector<ll> dp(w+1);
  for(int i=0;i<n;i++)
  {
    int weight,val; 
    cin >> weight >> val;
    for(int j = w - weight;j>=0;j--)
    {
      max_new(dp[j+weight],dp[j]+val);
    }
  }
  int ans = 0;
  for(int i=0;i<=w;i++)
  {
    ans = max(dp[i],ans);
  }
  
  cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    long long n,w;
    cin >> n >> w;
    
    int dp[n+1][w+1] = {0};
    vector<long long> weight(n),value(n);

    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i]; 

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

    long long ans = dp[n][w];

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:33: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   19 |                 dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:19:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   19 |                 dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:19:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |                 dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
 
#define int                     long long
#define file(s)                 freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a)          for(int i = (b); i >=(a); i--)
#define forn(i, a, b)           for(int i = (a); i <= (b); i++)
#define speed                   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;
 
typedef long long ll;
typedef double db;
typedef long double ldb;
 
const ldb pi = 3.14159265358979323846264;
const int maxn = 2e5 + 1;
const int mod = 1e9 + 7;
    
int n, W, ans = -1;
int w[maxn], v[maxn];
int dp[101][1e5 + 1];
    
main(){
    //file("");
    speed;
    cin >> n >> W;
    forn(i, 1, n){
        int num1, num2;
        cin >> num1 >> num2;
        w[i] = num1;
        v[i] = num2;
    }
    forn(i, 1, n){
        forn(j, 0, W){
            if(j - w[i] >= 0){
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            }
            else{
                dp[i][j] = dp[i - 1][j];
            }
            //dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    forn(i, 1, n){
        forn(j, 1, W){
            if(dp[i][j] > ans)ans = dp[i][j];
        }
    }
    cout << ans;
    return 0;
}





Compiler output:
a.cc:46:17: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   46 | int dp[101][1e5 + 1];
      |             ~~~~^~~
a.cc:46:17: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
   46 | int dp[101][1e5 + 1];
      |             ~~~~^~~
      |                 |
      |                 double
a.cc:46:17: error: size of array 'dp' has non-integral type 'double'
a.cc:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
 
 
int check = 1000;
 
ll func(int n, int W, int wt[], ll val[]){
  check--;
  if(n == 0 || check==0){
    return 0;
  }
  if(W < wt[n - 1]){
    return func(n-1, W, wt, val);
  }else{
    return max(func(n-1, W, wt, val), val[n-1] + func(n-1, W - wt[n-1], wt, val));
  }
}
 
ll func2(int n, int W, int wt[], ll val[]){
  ll t[n+1][W+1];
  // init
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= W; j++){
      if(i == 0 || j == 0){
        t[i][j] = 0;
      }
    }
  }
  // logic
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= W; j++){
      if(j < wt[i-1]){
        t[i][j] = t[i-1][j];
      }else{
        t[i][j] = max(t[i-1][j], val[i-1] + t[i-1][j - wt[i-1]]);
      }
    }
  }
 
  // for(int i = 0; i <= n; i++){
  //   for(int j = 0; j <= W; j++){
  //     cout << t[i][j] << " ";
  //   }cout << endl;
  // }
  return t[n][W];
 
}
 
void solve() {
  int n,W;
  cin >> n >> W;
  int wt[n];
  ll val[n];
  for(int i = 0; i < n; i++){
    cin >> wt[i] >> val[i];
  }
  cout << func2(n, W, wt, val);
}
int main(){
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define sorta(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<>())
#define mkp make_pair
#define endl "\n"
#define tab " "
#define pb push_back
#define ff first
#define ss second
#define gcd __gcd
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define ff first
#define ss second
#define tc ll T;cin>>T;while(T--)
#define inf (long long)9e18
const ll mod = 1e9 + 7;
ll powm(ll x, ll y, ll p)  {  ll res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }
ll lcm(ll x,ll y){return (x*y*1LL)/gcd(x,y);}
ll pow(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); y = y >> 1; x = ((x) * (x)); } return res; }
void solve()
{
    ll n,we,i,j;
    cin>>n>>we;
    vll v(n,0),w(n,0);
    for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
    ll t[n+1][we+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=we;j++)
        t[i][j]=0;
    }
    //  for(i=0;i<n;i++)
    // {
    //     for(j=0;j<=we;j++)
    //     {
    //         cout<<t[i][j]<<tab;
    //     }cout<<endl;
    // }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=we;j++)
        {
            if(j<w[i-1])
            t[i][j]=t[i-1][j];
            else
            {
                t[i][j]=max(t[i-1][j],v[i-1]+t[i-1][j-w[i-1]]);
            }
            
        }
    }
    //  for(i=0;i<=n;i++)
    // {
    //     for(j=0;j<=we;j++)
    //     {
    //         cout<<t[i][j]<<tab;
    //     }cout<<endl;
    // }

    cout<<t[n][we];
}		
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif
	fast
	//tc
	solve();
}

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 <iostream>
#include <vector>
#include <string>
#include <intrin.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <chrono>  
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================


int n;
int knapsackWeight;
int weights[100+5];
long long  benfits[100 + 5];
long long dp  [100+5][10000+ 5];
long long knapsack(int index , int reminderWeight)
{

	if (index == n)
		return 0;

	if (dp[index][reminderWeight] != -1)
		return dp[index][reminderWeight];
	long long r;
	r = knapsack(index + 1 , reminderWeight);
	if (reminderWeight >= weights[index])
	{
		r = max(knapsack(index + 1, reminderWeight - weights[index])+ benfits[index] , r);
	}
	dp[index][reminderWeight] = r;
	return r;
}


int main()
{
	cin >> n >> knapsackWeight;
	for (size_t i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		long long b;
		cin >> b;
		weights[i] = a;
		benfits[i] = b;
	}
	for (size_t i = 0; i < 100+5; i++)
	{
		for (size_t x = 0; x < 100+5; x++)
		{
			dp[i][x] = -1;
		}
	}

	cout << knapsack(0 , knapsackWeight);
}



Compiler output:
a.cc:4:10: fatal error: intrin.h: No such file or directory
    4 | #include <intrin.h>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
long long m[111], k[111111];
long long dp[111][111111];
int main() {
	int n,w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> m[i] >> k[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			if (j >= m[i]) {
				dp[i][j] = max(dp[i - 1][j], dp[i-1][j - m[i]] + k [i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	int m=0;
	for (int i = 1; i <= w; i++) {
		m = max(m, dp[n][i]);
	}
	cout << m;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:24: error: no matching function for call to 'max(int&, long long int&)'
   24 |                 m = max(m, dp[n][i]);
      |                     ~~~^~~~~~~~~~~~~
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:24:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |                 m = max(m, dp[n][i]);
      |                     ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/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:24:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |                 m = max(m, dp[n][i]);
      |                     ~~~^~~~~~~~~~~~~
Language: C++

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


Compiler output:
a.cc:18:3: error: 'cout' does not name a type
   18 |   cout<<dp[w]<<endl;
      |   ^~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'long long int max(long long int, long long int)':
a.cc:6:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
    6 | int main(){
      |         ^~
a.cc:6:9: note: remove parentheses to default-initialize a variable
    6 | int main(){
      |         ^~
      |         --
a.cc:6:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:6:11: error: a function-definition is not allowed here before '{' token
    6 | int main(){
      |           ^
a.cc:18:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   18 |   cout<<dp[w]<<endl;
      |         ^~
      |         dup
a.cc:18:12: error: 'w' was not declared in this scope
   18 |   cout<<dp[w]<<endl;
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[105][100005];
ll N,W;
ll v[N],w[N];

ll knapsack(ll W,ll i){
    if(i>n-1){
        return 0;
    }
    if(W-w[i]<0){
        return knapsack(W,i+1);
    }
    //cout<<v[i]<<w[i];

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

    ll op1=knapsack(W-w[i],i+1)+v[i];
    ll op2=knapsack(W,i+1);
    return dp[i][W]=max(op1,op2);
    

    

}
int main()
{
    
    cin>>N>>W;
    for(ll i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    
    memset(dp,-1,sizeof(dp));
    cout<<knapsack(W,0);
    
}

Compiler output:
a.cc:6:6: error: size of array 'v' is not an integral constant-expression
    6 | ll v[N],w[N];
      |      ^
a.cc:6:11: error: size of array 'w' is not an integral constant-expression
    6 | ll v[N],w[N];
      |           ^
a.cc: In function 'long long int knapsack(long long int, long long int)':
a.cc:9:10: error: 'n' was not declared in this scope
    9 |     if(i>n-1){
      |          ^
Language: C++

// Here is the top-down approach of 
// dynamic programming 
#include <bits/stdc++.h> 
using namespace std; 
  
// Returns the value of maximum profit 
int knapSackRec(int W, int wt[], int val[], 
                int i, int** dp) 
{ 
    // base condition 
    if (i < 0) 
        return 0; 
    if (dp[i][W] != -1) 
        return dp[i][W]; 
  
    if (wt[i] > W) { 
  
        // Store the value of function call  
        // stack in table before return 
        dp[i][W] = knapSackRec( 
W, wt, val, i - 1, dp); 
        return dp[i][W]; 
    } 
    else { 
  
        // Store value in a table before return 
        dp[i][W] = max( 
            val[i] + knapSackRec( 
                         W - wt[i], wt, val, i - 1, dp), 
            knapSackRec(W, wt, val, i - 1, dp)); 
  
        // Return value of table after storing 
        return dp[i][W]; 
    } 
} 
  
int knapSack(int W, int wt[], int val[], int n) 
{ 
    // double pointer to declare the  
// table dynamically 
    int** dp; 
    dp = new int*[n]; 
  
    // loop to create the table dynamically 
    for (int i = 0; i < n; i++) 
        dp[i] = new int[W + 1]; 
  
    // loop to initially filled the  
// table with -1 
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < W + 1; j++) 
            dp[i][j] = -1; 
    return knapSackRec(W, wt, val, n - 1, dp); 
} 
  
int main() 
{ 
   ll n,W;
   cin>>n>>W;
   
   vector<ll>wt(n);
   vector<ll>val(n);
   for(ll i=0;i<n;i++) cin>>wt[i]>>val[i];
  
    cout << knapSack(W, wt, val, n); 
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:58:4: error: 'll' was not declared in this scope
   58 |    ll n,W;
      |    ^~
a.cc:59:9: error: 'n' was not declared in this scope; did you mean 'yn'?
   59 |    cin>>n>>W;
      |         ^
      |         yn
a.cc:59:12: error: 'W' was not declared in this scope
   59 |    cin>>n>>W;
      |            ^
a.cc:61:13: error: template argument 2 is invalid
   61 |    vector<ll>wt(n);
      |             ^
a.cc:62:13: error: template argument 2 is invalid
   62 |    vector<ll>val(n);
      |             ^
a.cc:63:10: error: expected ';' before 'i'
   63 |    for(ll i=0;i<n;i++) cin>>wt[i]>>val[i];
      |          ^~
      |          ;
a.cc:63:15: error: 'i' was not declared in this scope
   63 |    for(ll i=0;i<n;i++) cin>>wt[i]>>val[i];
      |               ^