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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

#include<iostream>
using namespce std;
int knapsack01(int weights[],int values[],int W,int idx,int dp[][],int size){
  if(W==0 || idx==size){
  return 0;
  }
  if(dp[idx][W]!=0)return dp[idx][W];
  int pick=0;
  if(W-weights[idx]>=0){
    pick=knapsack01(weights,values,W-weights[idx],idx+1,dp,size);
  }
  int unpick=knapsack01(weights,values,W,idx+1,dp,size);
  return dp[idx][W]=max(pick,unpick);
    
}
int main(){
  int N=0;
  int W=0;
  cin>>N;
  cin>>W;
  int weights[N];
  int values[N];
  int dp[N+1][W+1];
  for(int i=0;i<N;i++){
    cin>>weights[i];
    cin>>values[N];
  }
  return knapsack01(weights,values,W,0,dp,N);
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namespce'
    2 | using namespce std;
      |       ^~~~~~~~
a.cc:3:61: error: declaration of 'dp' as multidimensional array must have bounds for all dimensions except the first
    3 | int knapsack01(int weights[],int values[],int W,int idx,int dp[][],int size){
      |                                                             ^~
a.cc:3:67: error: expected ')' before ',' token
    3 | int knapsack01(int weights[],int values[],int W,int idx,int dp[][],int size){
      |               ~                                                   ^
      |                                                                   )
a.cc:3:68: error: expected unqualified-id before 'int'
    3 | int knapsack01(int weights[],int values[],int W,int idx,int dp[][],int size){
      |                                                                    ^~~
a.cc: In function 'int main()':
a.cc:19:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   19 |   cin>>N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<stack>
#include<random>
using namespace std;



void lcs(string a, string b){
    int dp[1000][1000];
    int as = a.size(),bs = b.size();
    for(int i=1;i<=as;i++){
        for(int j=1;j<=bs;j++){
            if(a[i-1] == b[j-1]){
                chmax(dp[i][j],dp[i-1][j-1] + 1);
            }
            chmax(dp[i][j],dp[i-1][j]);
            chmax(dp[i][j],dp[i][j-1]);
        }
    }
    cout << dp[as][bs]<< endl;
}

template <typename T>
void chmax(T& a,const T& b){if(b > a)a = b;}

int main(){
    int N,W;
    long long int w[100],v[100];
    cin >> N >> W;
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
    } 
    long long int dp[100001];
    for(int i=0;i<N;i++){
        for(long long int j = W ;j>= w[i];j--){
            chmax(dp[j],dp[j-w[i]] + v[i]);
        }
    }
    cout << dp[W] << endl;
    return 0;
}
/*
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main(){
	ll n,W,i,j;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1), dp(W+1);
	for(i=1; i<=n; ++i){
		cin>>w[i]>>v[i];
		for(j=W-w[i]; j>=0; --j){
			dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
		}
	}
	cout<<dp[W]<<"\n";
	return 0;
}
*/

Compiler output:
a.cc: In function 'void lcs(std::string, std::string)':
a.cc:20:17: error: 'chmax' was not declared in this scope
   20 |                 chmax(dp[i][j],dp[i-1][j-1] + 1);
      |                 ^~~~~
a.cc:22:13: error: 'chmax' was not declared in this scope
   22 |             chmax(dp[i][j],dp[i-1][j]);
      |             ^~~~~
Language: C

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

long long dpres(int i, int w, vector<vector<long long>> &dp,vector<vector<long long>> l){
  if(dp.at(i).at(w) == -1){
    if(w < l.at(i-1).at(0)){
      dp.at(i).at(w) = dpres(i-1,w,dp,l);
    }else{
      dp.at(i).at(w) = max(dpres(i-1,w-l.at(i-1).at(0),dp,l) + l.at(i-1).at(1),dpres(i-1,w,dp,l));
    }
  }
  return dp.at(i).at(w);
}

int main() {
  int n,w;
  cin >> n >> w;
  vector<vector<long long>> l(n, vector<long long>(2));
  
  for (int i = 0; i < n; i++){
    for(int j = 0; j < 2; j++){
      cin >> l.at(i).at(j);
    }
  }
  vector<vector<long long>> dp(n+1, vector<long long>(w+1,-1));
  for(int i = 0; i < w+1; i++){
    dp.at(0).at(i) = 0;
  }
  
  
  cout << dpres(n,w,dp,l);
}

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;

long long dpres(int i, int w, vector<vector<long long>> &dp,vector<vector<long long>> l){
  if(dp.at(i).at(w) == -1){
    if(w < l.at(i-1).at(0)){
      dp.at(i).at(w) = dpres(i-1,w,dp,l);

    }else{
   
      dp.at(i).at(w) = max(dpres(i-1,w-l.at(i-1).at(0),dp,l) + l.at(i-1).at(1),dpres(i-1,w,dp,l));
         }
  }
  return dp.at(i).at(w);
}

int main() {
  int n,w;
  cin >> n >> w;
  vector<vector<long long>> l(n, vector<long long>(2));
  
  for (int i = 0; i < n; i++){
    for(int j = 0; j < 2; j++){
      cin >> l.at(i).at(j);
    }
  }
  vector<vector<long long>> dp(n+1, vector<long long>(w+1,-1));
  for(int i = 0; i < w+1; i++){
    dp.at(0).at(i) = 0;
  }
   
  for (int i = 0; i < n+1; i++) {
    for (int j = 0; j < w+1; j++) {
    }
  }
  
  cout << dpres(n,w,dp,l)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:26: error: expected ';' before '}' token
   37 |   cout << dpres(n,w,dp,l)
      |                          ^
      |                          ;
   38 | }
      | ~
Language: C++

#include<iostream>
using namespace std;
long long int dp[102][100003];
long long int n;
long long int w[103], v[103];
long long int ks(long long int idx, long long int u)
{
	if(u < 0)
	return INT_MIN;
	if(u == 0)
	return 0;
	if(idx == n)
	return 0;
	if(dp[idx][u] != -1)
	return dp[idx][u];
	
long long int p1 = v[idx]+ks(idx+1, u-w[idx]);
long long int p2 = ks(idx+1, u);

return dp[idx][u] = max(p1, p2); 
}
main(){

long long int u;
cin >> n >> u;
long long int i;
for(i=0;i<n;i++)
cin >> w[i] >> v[i] ;
for(i=0;i<100002;i++)
for(long long int j=0;j<102;j++)
dp[j][i] = -1;
cout << ks(0, u);

return 0;
}


Compiler output:
a.cc: In function 'long long int ks(long long int, long long int)':
a.cc:9:16: error: 'INT_MIN' was not declared in this scope
    9 |         return INT_MIN;
      |                ^~~~~~~
a.cc:2:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | using namespace std;
a.cc: At global scope:
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
Language: Java

/*package whatever //do not write package name here */

import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;

class Main {
    static long dp[][];
    public static long knapsack(int i,int v[],int w[],int C,long value){
         if(i==0||C==0)return value;
         if(dp[i][C]!=-1)return dp[i][C] ;
         if(C<w[i-1])dp[i][C]= knapsack(i-1, v, w, C, value);
         else dp[i][C]= Math.max(knapsack(i-1, v, w, C-w[i-1],value+v[i-1]),knapsack(i-1, v, w, C, value));
         return dp[i][C];
    }
	public static void main (String[] args)throws IOException{
		//code
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String[]s=br.readLine().split("\\s+");
		
            int n=Integer.parseInt(s[0]);
            int C=Integer.parseInt(s[1]);
            int []v=new int[n];
            int []w=new int[n];
		   
		    for(int i=0;i<n;i++){
                s=br.readLine().split("\\s+");
                w[i]=Integer.parseInt(s[0]);
                v[i]=Integer.parseInt(s[1]);
            }
            dp=new long[n+1][C+1];
            for(int i=0;i<=n;i++)
            Arrays.fill(dp[i],-1);
            long res=knapsack(n, v, w, C,0);
            for(int i=0;i<n;i++)
             System.out.println(Arrays.toString(dp[i]));
            System.out.print(res);
		
		    
	
		
	}
}
/*package whatever //do not write package name here */

import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;

class Main {
    static long dp[][];
    public static long knapsack(int i,int v[],int w[],int C,long value){
         if(i==0||C==0)return value;
         if(dp[i][C]!=-1)return dp[i][C] ;
         if(C<w[i-1])dp[i][C]= knapsack(i-1, v, w, C, value);
         else dp[i][C]= Math.max(knapsack(i-1, v, w, C-w[i-1],value+v[i-1]),knapsack(i-1, v, w, C, value));
         return dp[i][C];
    }
	public static void main (String[] args)throws IOException{
		//code
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String[]s=br.readLine().split("\\s+");
		
            int n=Integer.parseInt(s[0]);
            int C=Integer.parseInt(s[1]);
            int []v=new int[n];
            int []w=new int[n];
		   
		    for(int i=0;i<n;i++){
                s=br.readLine().split("\\s+");
                w[i]=Integer.parseInt(s[0]);
                v[i]=Integer.parseInt(s[1]);
            }
            dp=new long[n+1][C+1];
            for(int i=0;i<=n;i++)
            Arrays.fill(dp[i],-1);
            long res=knapsack(n, v, w, C,0);
            for(int i=0;i<n;i++)
             System.out.println(Arrays.toString(dp[i]));
            System.out.print(res);
		
		    
	
		
	}
}


Compiler output:
Main.java:48: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:49: error: class, interface, enum, or record expected
import java.lang.*;
^
Main.java:50: error: class, interface, enum, or record expected
import java.lang.reflect.Array;
^
Main.java:51: error: class, interface, enum, or record expected
import java.io.*;
^
4 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N,W;
int v[110],w[110];
int dp[110][110000];
int main() {
    cin >> N >> W;
    for(int i = 1;i <= N;i++)cin >> w[i] >> v[i];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:77: error: expected ')' before ']' token
   19 |             if (j-w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]]);
      |                                            ~                                ^
      |                                                                             )
Language: C++

#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// 入力
int n, W;
int weight[n+10], value[n+10];

// DPテーブル
int dp[110][100010];

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

  // DP初期条件: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DPループ
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

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

Compiler output:
a.cc:8:13: error: size of array 'weight' is not an integral constant-expression
    8 | int weight[n+10], value[n+10];
      |            ~^~~
a.cc:8:26: error: size of array 'value' is not an integral constant-expression
    8 | int weight[n+10], value[n+10];
      |                         ~^~~
Language: C++

#include <bits/stdc++.h>
#define L "\n"
#define S " "
#define ll long long
#define pb push_back
#define mp make_pair
#define vi std::vector<int>
#define si std::set<int>
#define vl std::vector<long long>
#define qi std::queue<int>
#define de(a) cout << #a << "  ------>  " << a << "\n"
#define SIZE 100002
#define INF INT_MAX
#define FOR(i, n) for (i = 1; i <= n; i++)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;
ll n, p[SIZE], w[SIZE];
ll dp[101][SIZE];
bool flag[101][SIZE];

ll f(ll i, ll weight)
{
    ll prof1, prof2, unc = weight;
    flag[i][unc] = 1;

    if (i == n)
    {
        if (w[i] <= weight)
            return dp[i][weight] = p[i];
        else
            return dp[i][weight] = 0;
    }
    if (w[i] <= weight)
    {
        if (flag[i + 1][weight]){
            prof1 = dp[i + 1][weight];}
        else
            prof1 = f(i + 1, weight);
        weight -= w[i];
        if (flag[i + 1][weight]){
            prof2 = dp[i + 1][weight];}
        else
            prof2 = p[i] + f(i + 1, weight);
        return dp[i][unc] = max(prof1, prof2);
    }
    else
    {
        if (flag[i + 1][unc]){
            prof1 = dp[i + 1][unc];}
        else
            prof1 = f(i + 1, weight);
        return dp[i][unc] = prof1;
    }
}

void solve()
{
    ll i, W;
    cin >> n >> W;
    FOR(i, n)
    {
        cin >> w[i];
        cin >> p[i];
    }
    cout << f(1, W) << L;
    de(cont);
}
int main()
{
    FASTIO;
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:70:8: error: 'cont' was not declared in this scope; did you mean 'const'?
   70 |     de(cont);
      |        ^~~~
a.cc:11:46: note: in definition of macro 'de'
   11 | #define de(a) cout << #a << "  ------>  " << a << "\n"
      |                                              ^
Language: C++

#include <iostream>

using namespace std;

int main()
{
    int n,w;
    cin>>n>>w;
    int weight[n];
    int value[n];
    for(int i=0;i<n;i++)
        cin>>weight[i]>>value[i];
    int dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0||j==0) dp[i][j]=0;
            else if(weight[i-1]>j) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j-1],value[i-1]+dp[i-1][j-weight[i-1]]);
        }
    }
   /* for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;*/
    }
    cout<<dp[n][w];
    return 0;
}


Compiler output:
a.cc:26:5: error: 'cout' does not name a type
   26 |     cout<<dp[n][w];
      |     ^~~~
a.cc:27:5: error: expected unqualified-id before 'return'
   27 |     return 0;
      |     ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
   28 | }
      | ^
Language: Java

import java.util.*;
public class Main{
  static long aa[][];
	static int maxx(int[] ww,int[] v,int ind,int w){
    	  if(ind>=v.length || w==0 ){return 0;}
            if(aa[ind][w]!=-1){return aa[ind][w];}
          if(w-ww[ind]<0){
          	return aa[ind][w]=maxx(ww,v,ind+1,w); 
          }
          else{
          return aa[ind][w]=Math.max( maxx(ww,v,ind+1,w-w[ind])+(long)v[ind],
                                     maxx(ww,v,ind+1,w));
          }
      
    }
  public static void main(String[] args){
  	Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int w=s.nextInt();
    int[] ww=new int[n],v=new int[n];
    aa=new long[n][w+1];
    for(int j=0;j<n;j++){
    	ww[j]=s.nextInt();
        v[j]=s.nextInt();
      for(int i=0;i<=w;i++){aa[j][i]=-1; }
    }
    System.out.println(maxx(ww,v,0,w)); 
  
  }

}

Compiler output:
Main.java:6: error: incompatible types: possible lossy conversion from long to int
            if(aa[ind][w]!=-1){return aa[ind][w];}
                                             ^
Main.java:8: error: incompatible types: possible lossy conversion from long to int
          	return aa[ind][w]=maxx(ww,v,ind+1,w); 
          	                 ^
Main.java:11: error: array required, but int found
          return aa[ind][w]=Math.max( maxx(ww,v,ind+1,w-w[ind])+(long)v[ind],
                                                         ^
Main.java:11: error: incompatible types: possible lossy conversion from long to int
          return aa[ind][w]=Math.max( maxx(ww,v,ind+1,w-w[ind])+(long)v[ind],
                           ^
4 errors
Language: Java

import java.util.*;
public class Main{
  static long aa[][];
	static int maxx(int[] ww,int[] v,int ind,int w){
    	  if(ind>=v.length || w==0 ){return 0;)
            if(aa[ind][w]!=-1){return aa[ind][w];}
          if(w-ww[ind]<0){
          	return aa[ind][w]=maxx(ww,v,ind+1,w); 
          }
          else{
          return aa[ind][w]=Math.max( maxx(ww,v,ind+1,w-w[ind])+(long)v[ind],
                                     maxx(ww,v,ind+1,w));
          }
      
    }
  public static void main(String[] args){
  	Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int w=s.nextInt();
    int[] ww=new int[n],v=new int[n];
    aa=new long[n][w+1];
    for(int j=0;j<n;j++){
    	ww[j]=s.nextInt();
        v[j]=s.nextInt();
      for(int i=0;i<=w;i++){aa[j][i]=-1; }
    }
    System.out.println(maxx(ww,v,0,w)); 
  
  }

}

Compiler output:
Main.java:5: error: illegal start of expression
    	  if(ind>=v.length || w==0 ){return 0;)
    	                                      ^
Main.java:16: error: illegal start of expression
  public static void main(String[] args){
  ^
2 errors
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
int dp[102][100005];
vector<pair<int,int>>v;
int n, W;
int solve(int i, int w){
  if(i==n)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    int ans = 0;
    if(v[i].first<=w)
        ans = v[i].second + solve(i+1,w-v[i].first);
    ans = max(ans,solve(i+1,w));
    return dp[i][w]=ans;
 
}
int main(){
  ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
  
  cin>>n>>W;
    for(int i=0;i<n;i++){
        pair<int,int> p;
        cin>>p.first>>p.second;
        v.push_back(p);
    }
    // ans = max(v[i] + dp[i+1][W-w[i]],dp[i+1][W]);
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,W);
 
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: Java


※ Your source cod	import java.util.*;
	import java.io.*;
	public class Main {
		static int n,wi[],W;
		static long dp[][],vi[];
		public static void main(String[] args) throws IOException{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			int t=1;
	//		Integer.parseInt(br.readLine().trim());
			StringBuilder printans=new StringBuilder();
			while(t-->0)
			{
				StringTokenizer tok=new StringTokenizer(br.readLine()," ");
				n=Integer.parseInt(tok.nextToken());
				W=Integer.parseInt(tok.nextToken());
				
				wi=new int[n];
				vi=new long[n];
				int sm=0;
				for(int i=0;i<n;i++) {
					tok=new StringTokenizer(br.readLine()," ");
					wi[i]=Integer.parseInt(tok.nextToken());
					vi[i]=Long.parseLong(tok.nextToken());
				
				}
				dp=new long[n+1][W+1];
				memset();
				printans.append(call(0,0,0));
			    
			}
			System.out.println(printans);
			
		}
		static void memset() {
			for(long a[]:dp) {
				Arrays.fill(a, -1);
			}
		}
		static long call(int i,long v,int w) {
			
			if(i==n && w<=W)return v;
			
			if(w>W)return 0;
			if(dp[i][w]!=-1) {
				return dp[i][w];
			}
			
			dp[i][w]=Math.max(call(i+1,v,w), call(i+1,v+vi[i],w+wi[i]));
		
			return dp[i][w];
			
		}
			
			
	}


Compiler output:
Main.java:2: error: illegal character: '\u203b'
? Your source cod	import java.util.*;
^
Main.java:2: error: class, interface, enum, or record expected
? Your source cod	import java.util.*;
       ^
Main.java:3: error: class, interface, enum, or record expected
	import java.io.*;
	^
3 errors
Language: C++


#include<iostream>
#define ull long long
using namespace std;
ull knapsack01(ull *weight, ull *value, int i, int n, int w, ull **dp){
    if (i==n) return 0;
    if (dp[i][w]!=-1) return dp[i][w];
    ull inc=INT_MIN, exc=INT_MIN;
    if (w>=weight[i])
        inc = value[i] + knapsack01(weight, value, i+1, n, w-weight[i], dp);
    exc = knapsack01(weight, value, i+1, n, w, dp);
    return dp[i][w] = max(inc, exc);
}
int main(){
  cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int n, w;
    cin>>n>>w;
    ull weight[n], value[n];
    ull ** dp = new ull* [n];
    for (int i=0; i<n;i++){
        dp[i] = new ull[w+1];
        for (int j=0;j<=w;j++){
            dp[i][j]=-1;
        }
    }
    for (int i=0; i<n; i++)
        cin>>weight[i]>>value[i];

    cout<<knapsack01(weight, value, 0, n, w, dp);
    return 0;
   }
  

Compiler output:
a.cc: In function 'long long int knapsack01(long long int*, long long int*, int, int, int, long long int**)':
a.cc:8:13: error: 'INT_MIN' was not declared in this scope
    8 |     ull inc=INT_MIN, exc=INT_MIN;
      |             ^~~~~~~
a.cc:3:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<iostream>
  +++ |+#include <climits>
    3 | #define ull long long
a.cc:11:5: error: 'exc' was not declared in this scope
   11 |     exc = knapsack01(weight, value, i+1, n, w, dp);
      |     ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define ll long long 

void chmax (ll&a, ll b) {
  if (a < b) a = b;
}  


int main() {
  int N, W;
  cin >> N >> W;
  
  int w[N+1] = {0};
  int v[N+1] = {0};
  
  for (int i = 0; i < N; i++)  cin >> w[i+1] >> v[i+1];
  
  ll dp[N+1][W+1] = {0} ; // dp[i][j] i番目までの商品で，合計j[g]のときの価値の最大値
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < W; j++) {
      if (j + v[i+1] <= W) {
        chmax(dp[i+1][j + v[i+1]], dp[i][j] + v[i+1]);
      } else {
        chmax(dp[i+1][j], dp[i][j]);
      }
    }
  }
  cout << max(dp[N]) << endl;
              
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:14: error: no matching function for call to 'max(long long int [(W + 1)])'
   32 |   cout << max(dp[N]) << endl;
      |           ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:32:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int*'
   32 |   cout << max(dp[N]) << endl;
      |           ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)

using namespace std;
int main(){
	long N,W,i,j;
	long w[100],v[100],dp[100001]={};

	cin >> N >> W;
	myfor(i,N){
		cin >> w[i]>>v[i];
	}
	myfor(j,W+1)dp2[j] = -1;
	myfor(i,N)myforFLInv(j,W,w-1){
		dp[j] = max(dp[j-w[i]] + v[i],dp[j])
	}
	cout << dp[W] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:21: error: 'dp2' was not declared in this scope; did you mean 'dp'?
   24 |         myfor(j,W+1)dp2[j] = -1;
      |                     ^~~
      |                     dp
a.cc:13:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 | #define myforFLInv(i,f,l) for(i=f;i>l;i--)
      |                                    ^
a.cc:25:19: note: in expansion of macro 'myforFLInv'
   25 |         myfor(i,N)myforFLInv(j,W,w-1){
      |                   ^~~~~~~~~~
a.cc:26:53: error: expected ';' before '}' token
   26 |                 dp[j] = max(dp[j-w[i]] + v[i],dp[j])
      |                                                     ^
      |                                                     ;
   27 |         }
      |         ~
Language: Java

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

class Main {
  
  	public static long maxVal(int n, int w, int wi[], int vi[]) {
      	long dp[][] = new long[n+1][w+1];
      	for (int i = 0 ; i <= w ; ++i) {
         	dp[0][i] = 0;
        }
      
      	for (int i = 1 ; i <= n ; ++i) {
         	dp[i][0] = 0;
        }
      
      	for (int i = 1 ; i <= n ; ++i) {
         	for (int j = 1 ; j <= w ; ++j) {
             	if (wi[i-1] <= j) {
                 	dp[i][j] = Math.max(vi[i-1] + dp[i-1][j-wi[i-1]], dp[i-1][j]); 
                } else {
                	dp[i][j] = dp[i-1][j];
                }
            }
        }
      	return dp[n+1][w+1];
    }
      
	public static void main(String args[]) {
     	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	String nw[] = br.readLine().split(" ");
      	int n = Integer.parseInt(nw[0]);
      	int w = Integer.parseInt(nw[1]);
      	int wi[] = new int[n];
      	int vi[] = new int[n];
      	
        for (int i = 0 ; i < n ; ++i) {
         	String in[] = br.readLine().split(" ");
          	wi[i] = Integer.parseInt(in[0]);
          	vi[i] = Integer.parseInt(in[1]);
        }
      	
      	long val = maxVal(n, w, wi, vi);
      	System.out.println(val);
    }
}

Compiler output:
Main.java:30: error: unreported exception IOException; must be caught or declared to be thrown
      	String nw[] = br.readLine().split(" ");
      	                         ^
Main.java:37: error: unreported exception IOException; must be caught or declared to be thrown
         	String in[] = br.readLine().split(" ");
         	                         ^
2 errors
Language: Java

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

class Main {
  
  	public static long maxVal(int n, int w, int wi[], int vi[]) {
      	long dp[][] = new long[n+1][w+1];
      	for (int i = 0 ; i <= w ; ++i) {
         	dp[0][i] = 0;
        }
      
      	for (int i = 1 ; i <= n ; ++i) {
         	dp[i][0] = 0;
        }
      
      	for (int i = 1 ; i <= n ; ++i) {
         	for (int j = 1 ; j <= w ; ++j) {
             	if (wi[i-1] <= j) {
                 	dp[i][j] = Math.max(vi[i-1] + dp[i-1][j-wi[i-1]], dp[i-1][j]); 
                } else {
                	dp[i][j] = dp[i-1][j];
                }
            }
        }
      	return dp[n+1][w+1];
    }
      
	public static void main(String args[]) {
     	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	String nw[] = br.readLine().split(" ");
      	int n = Integer.parseInt(nw[0]);
      	int w = Integer.parseInt(nw[1]);
      	int wi[] = new int[n];
      	int vi[] = new int[n];
      	int i = 0;
        for (int i = 0 ; i < n ; ++i) {
         	String in[] = br.readLine().split(" ");
          	wi[i] = Integer.parseInt(in[0]);
          	vi[i] = Integer.parseInt(in[1]);
        }
      	
      	long val = maxVal(n, w, wi, vi);
      	System.out.println(val);
    }
}

Compiler output:
Main.java:36: error: variable i is already defined in method main(String[])
        for (int i = 0 ; i < n ; ++i) {
                 ^
1 error
Language: C++

//
//  main.cpp
//  rough
//
//  Created by abhishek kumar on 22/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

#include <iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;

bool fun(pair<ll,ll>& a,pair<ll,ll>& b)
{
    if(a.first<b.first) return true;
    if(a.first==b.first && a.second > b.second) return true;
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll items,weight,value,target;
    cin>>items>>target;
    vector<pair<ll,ll>> arr;
    arr.push_back(make_pair(0, 0));
    for(auto i=1;i<=items;i++)
    {
        cin>>weight>>value;
        arr.push_back(make_pair(weight,value));
    }
    
    sort(arr.begin(),arr.end(),fun);
    vector<vector<ll>> knapsack(items+1,vector<ll>(target+1,0));
    
    for(auto i=1;i<=items;i++)
    {
        for(auto j=1;j<=target;j++)
        {
            if(arr[i].first > j)
                knapsack[i][j]=knapsack[i-1][j];
            else
            {
                knapsack[i][j]=max(knapsack[i-1][j],arr[i].second + knapsack[i-1][j-arr[i].first]);
            }
                
        }
    }
    
    cout<<knapsack[items][target];
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   36 |     sort(arr.begin(),arr.end(),fun);
      |     ^~~~
      |     short
Language: C++

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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n;
ll dp[MAX][101];
ll w[MAX];
ll v[MAX];


ll solve(int i,ll we){
       if(i==n){
           return 0;
       }

       ll &res=dp[i][we];
       if(res!=-1){
        return res;
       }

       res1=0;
       if(we>=w[i]){
          res1=solve(i+1,we-w[i])+v[i];
       }
       ll res2=solve(i+1,we);
       

       return res=max(res1,res2);

}




int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);





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

    mem(dp,-1);
    cout<<solve(0,k);








     return 0;

}


Compiler output:
a.cc: In function 'long long int solve(int, long long int)':
a.cc:47:8: error: 'res1' was not declared in this scope; did you mean 'res'?
   47 |        res1=0;
      |        ^~~~
      |        res
Language: C++

#include <iostream>
#include<vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
typedef long long int lld;
typedef unsigned long long int llu;
using namespace std;
const int m=1e9+7;
int knapsack(lld w,lld wt[],lld v[],lld n)
{
	lld i,j;
	int k[n+1][w+1];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0||j==0) k[i][j]=0;
			else if(wt[i-1]<=j)
			k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-wt[i-1]]);
			else
			k[i][j]=k[i-1][j];
		}
	}
	return k[n][w];
}

int main()
{ 
   lld n,w,i;
   cin>>n>>w;
   lld wt[n],v[n];
   for(i=0;i<n;i++) cin>>wt[i]>>v[i];
   cout<<knapsack(w,wt,v,n);
}


Compiler output:
a.cc: In function 'int knapsack(lld, lld*, lld*, lld)':
a.cc:21:36: error: no matching function for call to 'max(int&, lld)'
   21 |                         k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-wt[i-1]]);
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:21:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'lld' {aka 'long long int'})
   21 |                         k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-wt[i-1]]);
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:6:
/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:21:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |                         k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-wt[i-1]]);
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
   
   int n,W;
   cin>>n>>W;
   
   int w[n],v[n];
   for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    
   int dp[n+1][W+1];
   memset(dp,0,sizeof(dp));

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

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

   cout<<dp[n][w];

return 0;	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |             for(int j=1;j<=w;j++){
      |                         ~^~~
a.cc:23:15: error: invalid types 'int [(W + 1)][int [n]]' for array subscript
   23 |    cout<<dp[n][w];
      |               ^
Language: C++

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

using namespace std;

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> w(N, 0);
    vector<int> v(N, 0);

    vector< vector<long long> > dp(N+1, vector<long long>(W+1, 0));

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

    dp[0][0] = 1;

    for(int i=1; i<N+1; i++){
        for(int j=0; j<W+1; j++){
            /* 新しい品物を取る */
            if((dp[i-1][j]>0) && ((j+w[i-1]) <= W)){
                /* i番目の品物を選ぶ */
                long long a = dp[i-1][j] + v[i-1];
                chmax(dp[i][j+w[i-1]], a);
            }

            else{
                /* 何もしない */
            }

            /* 新しい品物を取らない */
            chmax(dp[i][j], dp[i-1][j]);
        }

    }

    /* 出力時は-1する */
    int max = *max_element(dp[N].begin(), dp[N].end());
    cout << (max -1) << endl;

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: 'chmax' was not declared in this scope
   29 |                 chmax(dp[i][j+w[i-1]], a);
      |                 ^~~~~
a.cc:37:13: error: 'chmax' was not declared in this scope
   37 |             chmax(dp[i][j], dp[i-1][j]);
      |             ^~~~~
Language: C++

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

int main(){
   
   int n,W;
   cin>>n>>W;
   
   int w[n],v[n];
   for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    
   int dp[n+1][w+1];
   memset(dp,0,sizeof(dp));

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

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

   cout<<dp[n][w];

return 0;	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: conversion from 'int*' to 'long unsigned int' in a converted constant expression
   12 |    int dp[n+1][w+1];
      |                ~^~
a.cc:12:17: error: could not convert '(((int*)(& w)) + 4)' from 'int*' to 'long unsigned int'
   12 |    int dp[n+1][w+1];
      |                ~^~
      |                 |
      |                 int*
a.cc:12:17: error: size of array 'dp' has non-integral type 'int*'
a.cc:17:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |             for(int j=1;j<=w;j++){
      |                         ~^~~
a.cc:23:15: error: invalid types 'int [1][int [n]]' for array subscript
   23 |    cout<<dp[n][w];
      |               ^
Language: C++

import numpy as np

n, max_weight = map(int, input().split())
WV = np.array([input().split() for _ in range(n)], np.int64)

W, V = zip(*WV)
dp = np.zeros((n + 1, max_weight + 1), np.int64)

# O(NW)
for i in range(n):
    for w in range(1, max_weight + 1):
        if w >= W[i]:
            dp[i + 1, w] = max(dp[i, w], dp[i, w - W[i]] + V[i])
        else:
            dp[i + 1, w] = dp[i, w]

print(dp[n, max_weight])


Compiler output:
a.cc:9:3: error: invalid preprocessing directive #O
    9 | # O(NW)
      |   ^
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
int arr[100][100001]={-1};

long long sum(int *w,int *v,int i,int t,int n)
{   if (arr[i][t]!=-1) return arr[i][t];
    if (t==0 || i==n-1)
        rarr[i][t]=0;
    if (w[i]>t)
       arr[i][t]= sum(w,v,i+1,t,n);
    else
    arr[i][t]=max(sum(w,v,i+1,t,n),sum(w,v,i+1,t-w[i],n)+v[i]);
    return arr[i][t];
}

signed main()
{
   faster;
   #ifndef ONLINE_JUDGE
     freopen("ip.txt", "r", stdin);
     freopen("op.txt", "w", stdout);
   #endif
     // int t;cin>>t;
     // while(t--)
     {
        int n,t;
        cin>>n>>t;
        int v[n],w[n];
        for (int i=0;i<n;i++)
            cin>>w[i]>>v[i];
        cout<<sum(w,v,0,t,n);
     }
}

Compiler output:
a.cc: In function 'long long int sum(int*, int*, int, int, int)':
a.cc:10:9: error: 'rarr' was not declared in this scope; did you mean 'arr'?
   10 |         rarr[i][t]=0;
      |         ^~~~
      |         arr
Language: Java

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

Compiler output:
Main.java:34: error: cannot find symbol
		s.close();
		^
  symbol:   variable s
  location: class Main
1 error
Language: C++

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{   long long r,n,w,i,j,sum=0,r,maxy=-1000000007;
    cin>>n>>w;
    long long wt[n],vl[n];
    for(i=0;i<n;i++){cin>>wt[i]>>vl[i];sum+=wt[i];}
    long long bl[sum+2][n];
    for(i=0;i<=sum;i++){for(j=0;j<n;j++){bl[i][j]=false;}}
    long long dp[sum+2];
    for(i=0;i<=sum;i++){dp[i]=-1000000007;}
    dp[0]=0;
    for(i=0;i<n;i++){d=500;
        for(j=wt[i];j<=w;j++)
        {if(dp[j-wt[i]]+vl[i]>dp[j]&&bl[j-wt[i]][i]==false)
        {d=0;r=j;dp[j]=dp[j-wt[i]]+vl[i];}
        }
        maxy=max(maxy,dp[j]);
        if(d==0)bl[r][i]=true;
    }
    cout<<maxy;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:31: error: redeclaration of 'long long int r'
   14 | {   long long r,n,w,i,j,sum=0,r,maxy=-1000000007;
      |                               ^
a.cc:14:15: note: 'long long int r' previously declared here
   14 | {   long long r,n,w,i,j,sum=0,r,maxy=-1000000007;
      |               ^
a.cc:23:22: error: 'd' was not declared in this scope; did you mean 'dp'?
   23 |     for(i=0;i<n;i++){d=500;
      |                      ^
      |                      dp
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long dp[100005],chk[105];
long long knapsack(long long wt,long long v[],long long w[],long long n)
{
    if(wt==0)
    return 0;
    if(dp[wt])
    return dp[wt];
    for(int i=0;i<n;i++)
    {
        if((wt-w[i])>=0)
        {
            if(chk[i]==0)
            {
                chk[i]=1;
                dp[wt]=max(dp[wt],max(knapsack(wt-w[i],v,w,n)+v[i],knapsack(wt-w[i],v,w,n));
                chk[i]=0;
            }
        }
    }
    return dp[wt];
}
int main()
{
    memset(dp,0,sizeof(dp));
    memset(chk,0,sizeof(chk));
    long long n,wt,i;
    cin>>n>>wt;
    long long w[n],v[n];
    for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
    long long ans=knapsack(wt,v,w,n);
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'long long int knapsack(long long int, long long int*, long long int*, long long int)':
a.cc:17:92: error: expected ')' before ';' token
   17 |                 dp[wt]=max(dp[wt],max(knapsack(wt-w[i],v,w,n)+v[i],knapsack(wt-w[i],v,w,n));
      |                           ~                                                                ^
      |                                                                                            )