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

#include <bits/stdc++.h> 
  using namespace std;
// A utility function that returns 
// maximum of two integers 
int max(int a, int b) 
{ 
    return (a > b) ? a : b; 
} 
  
// Returns the maximum value that 
// can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
    int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 
  
int main() 
{ 
   
int n,w;
   cin>>n>>w; 
   vector<int> wgt(n),val(n); 
   for(int i=0;i<n;i++)
   {
      cin>>wgt[i]>>val[i];  
   } 
    cout<<knapSack(W, wt, val, n)<<endl; 
    return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:44:20: error: 'W' was not declared in this scope
   44 |     cout<<knapSack(W, wt, val, n)<<endl;
      |                    ^
a.cc:44:23: error: 'wt' was not declared in this scope; did you mean 'wgt'?
   44 |     cout<<knapSack(W, wt, val, n)<<endl;
      |                       ^~
      |                       wgt
Language: C++

#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) 
{ 
    int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 
  
int main() 
{ int n,w;
   cin>>n>>w; 
   vector<int> wgt(n),val(n); 
   rep(i,0,n)
   {
      cin>>wgt[i]>>val[i];  
   }  
   cout<<knapSack(W, wt, val, n)<<endl; 
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:36:4: error: 'cin' was not declared in this scope
   36 |    cin>>n>>w;
      |    ^~~
a.cc:37:4: error: 'vector' was not declared in this scope
   37 |    vector<int> wgt(n),val(n);
      |    ^~~~~~
a.cc:37:11: error: expected primary-expression before 'int'
   37 |    vector<int> wgt(n),val(n);
      |           ^~~
a.cc:38:8: error: 'i' was not declared in this scope
   38 |    rep(i,0,n)
      |        ^
a.cc:38:4: error: 'rep' was not declared in this scope
   38 |    rep(i,0,n)
      |    ^~~
a.cc:42:4: error: 'cout' was not declared in this scope
   42 |    cout<<knapSack(W, wt, val, n)<<endl;
      |    ^~~~
a.cc:42:19: error: 'W' was not declared in this scope
   42 |    cout<<knapSack(W, wt, val, n)<<endl;
      |                   ^
a.cc:42:22: error: 'wt' was not declared in this scope; did you mean 'w'?
   42 |    cout<<knapSack(W, wt, val, n)<<endl;
      |                      ^~
      |                      w
a.cc:42:26: error: 'val' was not declared in this scope
   42 |    cout<<knapSack(W, wt, val, n)<<endl;
      |                          ^~~
a.cc:42:35: error: 'endl' was not declared in this scope
   42 |    cout<<knapSack(W, wt, val, n)<<endl;
      |                                   ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n, w; cin>>n>>w;
  	vector<ll> val(n), weight(n);
  	for(int i = 0 ; i < n; i++)
      cin>>weight[i]>>val[i];
	vector<ll> dp(w+1);
  	auto max_self = [](int& a, int b){
      a = max(a,b);
    };
  	for(int i = 0 ; i < n; i++)
      for(int w_so_far = 0 ; w_so_far <= w -weight[i]; w_so_far++)
        	max_self(dp[w_so_far+weight[i]], dp[w_so_far]+val[i]);
  
	cout<<*max_element(dp.begin(),dp.end())<<endl;
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: no match for call to '(main()::<lambda(int&, int)>) (__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   15 |                 max_self(dp[w_so_far+weight[i]], dp[w_so_far]+val[i]);
      |                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:25: note: candidate: 'void (*)(int&, int)' (conversion)
a.cc:15:25: note:   conversion of argument 2 would be ill-formed:
a.cc:15:25: 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'}
a.cc:10:25: note: candidate: 'main()::<lambda(int&, int)>' (near match)
   10 |         auto max_self = [](int& a, int b){
      |                         ^
a.cc:10:25: note:   conversion of argument 1 would be ill-formed:
a.cc:10:25: 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'}
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n, w; cin>>n>>w;
  	vector<ll> val(n), weight(n);
  	for(int i = 0 ; i < n; i++)
      cin>>weight[i]>>val[i];
	vector<ll> dp(w+1);
  	auto max_self = [&](int& a, int b){
      a = max(a,b);
    };
  	for(int i = 0 ; i < n; i++)
      for(int w_so_far = 0 ; w_so_far <= W -weight[i]; w_so_far++)
        	max_self(dp[w_so_far+weight[i]], dp[w_so_far]+val[i]);
  
	cout<<*max_element(dp.begin(),dp.end())<<endl;
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:42: error: 'W' was not declared in this scope
   14 |       for(int w_so_far = 0 ; w_so_far <= W -weight[i]; w_so_far++)
      |                                          ^
a.cc:15:25: error: no match for call to '(main()::<lambda(int&, int)>) (__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   15 |                 max_self(dp[w_so_far+weight[i]], dp[w_so_far]+val[i]);
      |                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:10:25: note: candidate: 'main()::<lambda(int&, int)>' (near match)
   10 |         auto max_self = [&](int& a, int b){
      |                         ^
a.cc:10:25: note:   conversion of argument 1 would be ill-formed:
a.cc:10:25: 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'}
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:20:29: error: 'W' was not declared in this scope
   20 |              for(int j=1;j<=W;j++)
      |                             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,w;
  cin>>n>>W;
  long long int dp[W+1]={0};
  for(int i=0;i<n;i++){
    int w,v;
    cin>>w>>v;
    for(int j=W-w;j>=0;j--){ // 5 k sath max pair
      dp[j+w]=max(dp[j+w],dp[j]+v); 
    }
  }
  cout<<*max_elements(dp,dp+W+1);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:11: error: 'W' was not declared in this scope
    5 |   cin>>n>>W;
      |           ^
a.cc:11:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |       dp[j+w]=max(dp[j+w],dp[j]+v);
      |       ^~
      |       dup
a.cc:14:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   14 |   cout<<*max_elements(dp,dp+W+1);
      |                       ^~
      |                       dup
a.cc:14:10: error: 'max_elements' was not declared in this scope
   14 |   cout<<*max_elements(dp,dp+W+1);
      |          ^~~~~~~~~~~~
Language: C++

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

long long int dp[101][100001], inf = 1e18; 


int main()
{
	fastio;
	int n, w;
	cin >> n >> w;
	vector<pair<int, int> > v(n+1);
	for(int i = 1; i <= n; i++) {
		cin >> v[i].first >> v[i].second;
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= w; j++) {
			if(v[i].first > j) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j], dp[i-1][j-v[i].first] + v[i].second);
		}
	}
	
	long long int ans = -inf;
	for(int i = 1; i <= w i++) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:30: error: expected ';' before 'i'
   26 |         for(int i = 1; i <= w i++) {
      |                              ^~
      |                              ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
// #define int long long
#define ff first
#define ss second
#define pb push_back
#define w(t) int t; cin >> t; while (t--)
#define MOD 10000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


ll dp[101][1e5 + 4];
// memset(dp, -1, sizeof(dp));

ll knapsack(int wt, int *w, int *v, int n)
{
	if (n == 0 || wt == 0)
		return 0;
	if (dp[n ][wt] != -1)
		return dp[n][wt];
	//cant include
	if (w[n - 1] > wt)
		dp[n][wt] = knapsack(wt, w, v, n - 1);
	//can include
	else
		return dp[n][wt] = max(v[n - 1] + knapsack(wt - w[n - 1], w, v, n - 1), knapsack(wt, w, v, n - 1));

}
int main()
{

	FIO
#ifndef ONLINE_JUDGE
	freopen ("in.txt", "r", stdin);
	freopen ("out.txt", "w", stdout);
#endif

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

	// for (int i = 0; i < 101; i++)
	// {
	// 	for (int j = 0; j < 100006; j++)
	// 	{
	// 		dp[i][j] = -1;
	// 	}
	// }

	memset(dp, -1, sizeof(dp));
	ll ans = knapsack(wt, w, v, n);
	cout << ans;
}


Compiler output:
a.cc:19:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   19 | ll dp[101][1e5 + 4];
      |            ~~~~^~~
a.cc:19:16: error: could not convert '(1.0e+5 + (double)4)' from 'double' to 'long unsigned int'
   19 | ll dp[101][1e5 + 4];
      |            ~~~~^~~
      |                |
      |                double
a.cc:19:16: error: size of array 'dp' has non-integral type 'double'
a.cc: In function 'long long int knapsack(int, int*, int*, int)':
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
Language: Java

import java.util.*;
import java.io.*;
public class Public {
	
	static int []w,v;
	static int n,s;
	static int [][]dp;
	public static int dp(int index,int remw) {
		
		if(remw<0) 
			return -(int)1e9;
		
		if(index==n) 
			return 0;
		
		
		
		if(dp[index][remw]!=-1) 
			return dp[index][remw];
		
		int take=v[index]+dp(index+1,remw-w[index]);
		int  leave=dp(index+1,remw);
		return dp[index][remw]=Math.max(take,leave);
		
	}
	public static void main (String []args) throws IOException {
		
		Scanner sc=new Scanner (System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		s=sc.nextInt();
		w=sc.nextIntArr(n);
		v=sc.nextIntArr(n);
		dp=new int [n+1][s+1];
		for(int[]x:dp) {
			Arrays.fill(x,-1);
		}
		for (int i = n-1;i>0;i-=1000 ) {
			for(int j=0;j<s+1;j+=1000) {
				dp(i,j);
			}
		}
		pw.println(dp(0,s));
		pw.close();
		

	}
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}
	}
		
	}

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

import java.util.*;
import java.io.*;
public class public {
	
	static int []w,v;
	static int n,s;
	static int [][]dp;
	public static int dp(int index,int remw) {
		
		if(remw<0) 
			return -(int)1e9;
		
		if(index==n) 
			return 0;
		
		
		
		if(dp[index][remw]!=-1) 
			return dp[index][remw];
		
		int take=v[index]+dp(index+1,remw-w[index]);
		int  leave=dp(index+1,remw);
		return dp[index][remw]=Math.max(take,leave);
		
	}
	public static void main (String []args) throws IOException {
		
		Scanner sc=new Scanner (System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		s=sc.nextInt();
		w=sc.nextIntArr(n);
		v=sc.nextIntArr(n);
		dp=new int [n+1][s+1];
		for(int[]x:dp) {
			Arrays.fill(x,-1);
		}
		for (int i = n-1;i>0;i-=1000 ) {
			for(int j=0;j<s+1;j+=1000) {
				dp(i,j);
			}
		}
		pw.println(dp(0,s));
		pw.close();
		

	}
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}
	}
		
	}
	

Compiler output:
Main.java:3: error: <identifier> expected
public class public {
            ^
Main.java:3: error: class, interface, enum, or record expected
public class public {
                    ^
Main.java:6: error: class, interface, enum, or record expected
	static int n,s;
	       ^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
	static int [][]dp;
	       ^
  (use --enable-preview to enable unnamed classes)
Main.java:78: error: class, interface, enum, or record expected
	}
	^
5 errors
Language: Java

import java.util.*;
import java.io.*;
public class Public {
	
	static int []w,v;
	static int n,s;
	static int [][]dp;
	public static int dp(int index,int remw) {
		
		if(remw<0) 
			return -(int)1e9;
		
		if(index==n) 
			return 0;
		
		
		
		if(dp[index][remw]!=-1) 
			return dp[index][remw];
		
		int take=v[index]+dp(index+1,remw-w[index]);
		int  leave=dp(index+1,remw);
		return dp[index][remw]=Math.max(take,leave);
		
	}
	public static void main (String []args) throws IOException {
		
		Scanner sc=new Scanner (System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		s=sc.nextInt();
		w=sc.nextIntArr(n);
		v=sc.nextIntArr(n);
		dp=new int [n+1][s+1];
		for(int[]x:dp) {
			Arrays.fill(x,-1);
		}
		for (int i = n-1;i>0;i-=1000 ) {
			for(int j=0;j<s+1;j+=1000) {
				dp(i,j);
			}
		}
		pw.println(dp(0,s));
		pw.close();
		
		
		
	}

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

#include<iostream>
using namespace std;

long long dp[110][100010];

int main()
{
	int N,W;
	int v[110] ,w[110];
	cin>>N>>W;
	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++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>0)
			{
				dp[i][j]=max(dp[i-1][j-w[i]],dp[i-1][j-w[i]]+v[i]);
			}
		}
		cout<<dp[i][j]<<endl;
	}
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:29: error: 'j' was not declared in this scope
   25 |                 cout<<dp[i][j]<<endl;
      |                             ^
Language: C

#include<iostream>
using namespace std;

long long dp[110][100010];

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


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

#include<iostream>
using namespace std;
long long dp[110][100010];
int main()
{
	int N,W;
	int v[100];
	long long w[100010];
	cin>>N>>W;
	for(int i=0;i<N;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int j=0;j<N;j++)
	{
		for(int i=0;i<W;i++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>0)
			{
				dp[i][j]=max(dp[i-1][j-w[i]],dp[i-1][j-w[i]]+v[i]);
				cout<<dp[i][j]<<endl;
			}
		}
	}
	
}


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

#include<bits/stdc++.h>
using namespace std;
long long dp[110][100010];
int main()
{
	int N,W;
	int v[100];
	long long w[100010];
	cin>>N>>W;
	for(int i=0;i<N;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int j=0;j<N;j++)
	{
		for(int i=0;i<W;i++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>0)
			{
				dp[i][j]=max(dp[i-1][j-w[i]],dp[i-1][j-w[i]]+v[i]);
				cout<<dp[i][j]<<endl;
			}
		}
	}
	
}


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

import java.util.*;
public class Main
{

	public static void main(String [] args)
	{
	
		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+1][W+1];
		
		for(int i=0;i<N;i++) dp[i][0] =0;
		for(int i=0;i<W;i++) dp[0][i] =0;
		
		for(int i=1;i<=N;i++)
		{
			for(int j=0;j<=W;j++)
			{
				 if(w[i]>j) dp[i][j]=dp[i-1][j];
				dp[i][j]= Math.max(v[i]+dp[i-1][j-w[i]], dp[i-1][j])
			}	
		}	
		
		return dp[N][W];	
	}

}

Compiler output:
Main.java:32: error: ';' expected
				dp[i][j]= Math.max(v[i]+dp[i-1][j-w[i]], dp[i-1][j])
				                                                    ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
//TOP BOTTOM 

public class knapsack {
	static int[] v, w;
	static int n, s; // Length el elements w hgm l shanta ele m3ak
	static long dp[][];

	public static long dp(int idx, int rem) {
		if (rem < 0) {
			return -(int) 1e9; // infinty value
		}
		if (idx == n) {
			return 0;
		}
		if (dp[idx][rem] != -1) {
			return dp[idx][rem];
		}

		long take = v[idx] + dp(idx + 1, rem - w[idx]);
		long leave = dp(idx + 1, rem);
		return dp[idx][rem] = Math.max(take, leave); // Da keda mn gher dp da tkrar tbe3e gddn !

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		n = sc.nextInt();
		s = sc.nextInt();

		w = new int[n];
		v = new int[n];

		for (int i = 0; i < w.length; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();

		}

		dp = new long[n][s + 1]; // tagnab l outof range
		for (long[] x : dp) {
			Arrays.fill(x, -1);
		}
		pw.println(dp(0, s));
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


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

import java.util.Scanner;
public class atcoder{
	
	
	private static Scanner sc=new Scanner(System.in);
	private static long dp[][];
	
	public static long maxProfit(int weivalue[][],int i,int capacity){
		
		if(capacity<=0)
			return 0;
		if(i>=weivalue.length)
			return 0;
		
		if(dp[i][capacity]!=Integer.MIN_VALUE)
			return dp[i][capacity];
		
		if(capacity>=weivalue[i][0])		
			dp[i][capacity]=Math.max(maxProfit(weivalue,i+1,capacity),
									weivalue[i][1]+maxProfit(weivalue,i+1,capacity-weivalue[i][0]));
		else
			dp[i][capacity]=maxProfit(weivalue,i+1,capacity);
		
		return dp[i][capacity];
		
	}
	
	public static void main(String []args){
		
		int n=sc.nextInt();
		int w=sc.nextInt();
		int weivalue[][]=new int[n][w];
		dp=new long[n+1][w+1];
		for(int i=0;i<n;i++){
			weivalue[i][0]=sc.nextInt();
			weivalue[i][1]=sc.nextInt();
		}
		for(int i=0;i<=n;i++)
			for(int j=0;j<=w;j++)
				dp[i][j]=Integer.MIN_VALUE;
			
		
		System.out.println(maxProfit(weivalue,0,w));
		
	}
}

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

#include <iostream>
using namespace std;
struct Item{
    long long val;
    int wgt;
};
long long dp[100][100002];
Item *obj;

long long knapsck(int n, int w){
    if(n==0 || w < 0)
        return 0ll;
    if(dp[n][w]!=-1)
        return dp[n][w];
    long long a = -1;
    if(w-obj[n-1].wgt >= 0)
        a = knapsck(n-1, w-obj[n-1].wgt) + obj[n-1].val;
    long long b = knapsck(n-1, w);
    return dp[n][w] = max(a, b); 
}

int main() {
    int n,w;
    cin>>n>>w;
    memset(dp, -1, sizeof(dp));
    obj = new Item[n];
    for (int i=0;i<n; i++)
        cin >> obj[i].wgt >> obj[i].val;
    
    cout<<knapsck(n, w);
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'memset' was not declared in this scope
   25 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
struct Item{
    long long val;
    int wgt;
};
long long dp[100][100002];
Item *obj;

long long knapsck(int n, int w){
    if(n==0 || w < 0)
        return 0ll;
    if(dp[n][w]!=-1)
        return dp[n][w];
    long long a = -1e18;
    if(w-obj[n-1].wgt >= 0)
        a = knapsck(n-1, w-obj[n-1].wgt) + obj[n-1].val;
    long long b = knapsck(n-1, w);
    return dp[n][w] = max(a, b); 
}

int main() {
    int n,w;
    cin>>n>>w;
    memset(dp, -1, sizeof(dp));
    obj = new Item[n];
    for (int i=0;i<n; i++)
        cin >> obj[i].wgt >> obj[i].val;
    
    cout<<knapsck(n, w);
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'memset' was not declared in this scope
   25 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: cannot convert 'long long int*' to 'int*'
   31 |   cout<<fun(w,ww,vv,n);
      |               ^~
      |               |
      |               long long int*
a.cc:3:26: note:   initializing argument 2 of 'long long int fun(int, int*, int*, int)'
    3 | long long fun(int W, int wt[], int val[], int n)
      |                      ~~~~^~~~
Language: C++

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: cannot convert 'long long int*' to 'int*'
   31 |   cout<<fun(w,ww,vv,n);
      |               ^~
      |               |
      |               long long int*
a.cc:3:26: note:   initializing argument 2 of 'long long int fun(int, int*, int*, int)'
    3 | long long fun(int W, int wt[], int val[], int n)
      |                      ~~~~^~~~
a.cc:32:12: error: expected '}' at end of input
   32 |   return 0;
      |            ^
a.cc:25:1: note: to match this '{'
   25 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[100005];
  int wt[100];
  int v[100];
 int n,w;
int solve(int j,int w){
//base case
  if(j==n||w==0)
    return 0;
  
  if(dp[j]!=-1){
    return dp[j]; 
  }
  int o1=v[j]+solve(j+1,w-wt[j]);
  int o2=solve(j+1,1,w-wt[j]);
 
  int ans=max(o1,o2);
  
    return dp[j]=ans;
    
 }
  
int main(){
   memset(dp, -1, sizeof(dp)); 
   memset(wt, -1, sizeof(wt)); 
   memset(v, -1, sizeof(v)); 
 
  cin>>n>>w;

  for(int i=0;i<n;i++)
    cin>>wt[i]>>v[i];
 
  cout<<solve(0,w);
 
  return 0;
  
}

Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:16:15: error: too many arguments to function 'int solve(int, int)'
   16 |   int o2=solve(j+1,1,w-wt[j]);
      |          ~~~~~^~~~~~~~~~~~~~~
a.cc:7:5: note: declared here
    7 | int solve(int j,int w){
      |     ^~~~~
Language: Java


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

public class HelloWorld {

    static int n,k ;
    static int [] w,v ;
    static long dp[][] ;

    static long dp (int idx , int k ){
        if (k<0){
            return -(int) 1e9 ;
        }
        if(idx == n)
            return 0 ;
        else{
            if (dp[idx][k]!=-1){
                return dp[idx][k] ;
            }
            long take = v[idx] + dp(idx+1,k-w[idx]) ;
            long leave = dp(idx+1 , k) ;
            return dp[idx][k] = Math.max(take,leave) ;
        }
    }

    public  static void main (String args [] ) throws IOException ,InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        n = sc.nextInt() ;
        k = sc.nextInt() ;
        w = new int[n] ;
        v = new int[n] ;
        dp = new long [n][k+1] ;
        for (int i =0 ; i < n ;i ++  ) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            Arrays.fill(dp[i],-1);
        }

        pw.println(dp(0,k));

        pw.close();
    }
     static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
}


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

#include<iostream>
using namespace std;
#define ll long long int 
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];
  }
  ll dp[n+1][w+1];
  for(int i=0;i<=n;i++){
    dp[i][0]=0;
  }
  for(int i=1;i<=w;i++){
    dp[0][i]=0;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=w;j++){
      if (j>=wt[i-1]){
        dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
      }
      else{
      dp[i][j]=dp[i-1][j];}
    }
  }
}
cout<<dp[n][w]<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: expected primary-expression before '.' token
    6 |   cin>>n>.w;
      |          ^
a.cc: At global scope:
a.cc:28:1: error: 'cout' does not name a type
   28 | cout<<dp[n][w]<<endl;
      | ^~~~
a.cc:29:1: error: expected unqualified-id before 'return'
   29 | return 0;
      | ^~~~~~
a.cc:30:1: error: expected declaration before '}' token
   30 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
#define ll long long
ll ks(ll n,ll c,ll w[],ll p[],ll dp[])
{
    if(n==0)
    {
        if(c>=w[n])
            return p[n];
        return 0;
    }
    ll ans1=INT_MIN;
    if(c>=w[n])
        ans1 = ks(n-1,c-w[n],w,p,dp)+p[n];
    return max(ans1,ks(n-1,c,w,p,dp));
}
int main()
{
    ll n,c;
    cin>>n>>c;
    ll w[n+1],p[n+1];
    for(ll i=0;i<n;i++)
        cin>>w[i]>>p[i];
    ll dp[n+1]={0};
    cout<<ks(n-1,c,w,p,dp);
}


Compiler output:
a.cc: In function 'long long int ks(long long int, long long int, long long int*, long long int*, long long int*)':
a.cc:12:13: error: 'INT_MIN' was not declared in this scope
   12 |     ll ans1=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;
Language: Java

import java.util.*;
import java.io.*;
public class MyClass {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      
      int n=sc.nextInt();
      int W=sc.nextInt();
      long wei[] = new long[n+1];
      long val[] = new long[n+1];
      for(int i=1;i<=n;i++)
      {
          wei[i]=sc.nextLong();
          val[i]=sc.nextLong();
      }
      
      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(wei[i]<=j)
                  {
                      dp[i][j]=Math.max(dp[i-1][j],val[i]+dp[i-1][j-(int)wei[i]]);
                  }
                  else
                  {
                      dp[i][j]=dp[i-1][j];
                  }
              }
              //w.print(dp[i][j]+" ");
          }
          //w.println();
      }
      w.println(dp[n][W]);
      w.close();
    }
}

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

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#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 weights[100+9];
long long benefit[100+9];
int n , kpWeight;
long long dp[100 + 9][10000 + 9];

long long  knapSack(int index , int reminderWeight)
{
	if (index == n)
		return 0;

	if (dp[index][reminderWeight] != -1)
	{
		return dp[index][reminderWeight];
	}

	long long leave = knapSack(index + 1, reminderWeight);

	long long take = 0;
	if (reminderWeight >= weights[index])
	{
		take = benefit[index] + knapSack(index + 1, reminderWeight - weights[index]);
	}
	return dp[index][reminderWeight] = max(leave, take);
}

int main()
{
	cin >> n >> kpWeight;
	for (int i1 = 0; i1 < 100+9; i1++)
	{
		for (int i2 = 0; i2 < 100000+9; i2++)
		{
			dp[i1][i2] = -1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		int a, 
		long long b;
		cin >> a >> b;
		weights[i] = a;
		benefit[i] = b;
	}
	cout << knapSack(0, kpWeight);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:88:17: error: expected unqualified-id before 'long'
   88 |                 long long b;
      |                 ^~~~
a.cc:89:29: error: 'b' was not declared in this scope
   89 |                 cin >> a >> b;
      |                             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int w[100], v[100], dp[100][100001];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,W; cin >> n >> W;
        FOR(i,0,n){
            cin >> w[i] >> v[i] ;
        }
        dp[0][0] = 0;
        d[0][w[0]] = v[0];
        FOR(i,1,n){
            dp[i][0] = 0;
            FOR(j,1,w+1){
                dp[i][j] = dp[i-1][j];
                if(j >= W-w[i])
                    dp[i][j] = max(dp[i][j], dp[i-1][j - w[i]] + v[i]);
            }
        }
        int ans = -1e18;
        FOR(i,0,W+1)
            ans = max(ans,dp[n-1][i]);
        cout << ans;
    }   
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:26:9: error: 'd' was not declared in this scope
   26 |         d[0][w[0]] = v[0];
      |         ^
a.cc:9:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 | #define FOR(i,a,n) for(int i=a;i<n;i++)
      |                                 ^
a.cc:29:13: note: in expansion of macro 'FOR'
   29 |             FOR(j,1,w+1){
      |             ^~~
Language: Java

import java.util.*;
public class Dp {
	static long [][]memo;
	
	static int [] w,v;
	static int n;
	public static long dp(int ne,int we) {
		if(ne==n)
			return 0;
		if(memo[ne][we]!=-1)
			return memo[ne][we];
		long t=0,l=-1;
		if(we>=w[ne])
		t=v[ne]+dp(ne+1,we-w[ne]);
		l=dp(ne+1,we);
		return memo[ne][we]=Math.max(t, l);
		 
	}
	public static void main (String[]args) {
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int wmax=sc.nextInt();
		w=new int[n];
		v=new int[n];
		memo=new long[n][wmax+1];
		for(long[]x:memo) {
			Arrays.fill(x,-1);
		}
		for(int i=0;i<n;i++) {
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		for(int i=n-1;i>0;i-=10)
			dp(i,wmax);
		System.out.print(dp(0,wmax));
				
		
		
		sc.close();
	}

		
	}




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

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

public class fib {
	 static int[] w, v;
	static int n, s;
	static int [][]mydpArr ;
	public static int dp(int indx, int remw) {
		if (remw<0)
			return -(int) 1e9;
	
	if (indx == n)
		return 0;
	if(mydpArr[indx][remw]!=-1)
		return mydpArr[indx][remw];
	int take = v[indx] + dp(indx+1,remw-w[indx]);
	int leave = dp(indx+1,remw);
	return mydpArr[indx][remw] = Math.max(take, leave);	
	}
	public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = sc.nextInt();
        s = sc.nextInt();
        w =new int[n];
        v =new int[n];
        mydpArr =new int[n+1][s+1];
        for(int i=0;i<n;i++) {
        	w[i]=sc.nextInt();
        	v[i]=sc.nextInt();
        }
        for(int[] x :mydpArr) {
        	Arrays.fill(x,-1);
        }
        pw.print(dp(0,s));
        pw.close();
        }
	  static class Scanner {
	         BufferedReader br;
	         StringTokenizer st;
	 
	         public Scanner(InputStream s) {
	             br = new BufferedReader(new InputStreamReader(s));
	         }
	 
	         public String next() throws IOException {
	             while (st == null || !st.hasMoreTokens())
	                 st = new StringTokenizer(br.readLine());
	             return st.nextToken();
	         }
	 
	         public int nextInt() throws IOException {
	             return Integer.parseInt(next());
	         }
	 
	         public long nextLong() throws IOException {
	             return Long.parseLong(next());
	         }
	 
	         public double nextDouble() throws IOException {
	             return Double.parseDouble(next());
	         }
	 
	         public int[] nextIntArr(int n) throws IOException {
	             int[] arr = new int[n];
	             for (int i = 0; i < n; i++) {
	                 arr[i] = Integer.parseInt(next());
	             }
	             return arr;
	         }
	 
	     }
}

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

import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N + 1];
        long[] v = new long[N + 1];
        for (int i = 1; i <= N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextLong();
        }
        long[][] dp = new long[N + 1][W + 1];
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= W; j++) {
                if (j < w[i]) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
                }
            }
        }
        System.out.println(dp[N][W]);
    }

}


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

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

public class Train {
	static int w[];
	static int v[];
	static int n,s;
	static long dp[][];
	public static long dp(int idx,int remw) {
		if(remw<0)
			return -(int)1e9;
		if(idx==n)
			return 0;
		if(dp[idx][remw]!=-1)
		{
			return dp[idx][remw];
		}
		long take = v[idx]+dp(idx+1,remw-w[idx]);
		long leave = dp(idx+1,remw);
		return dp[idx][remw]=Math.max(take, leave);
	}
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n =sc.nextInt();
		w = new int[n];
		v = new int[n];
		s = sc.nextInt();
		dp = new long[n+1][s+1];
		for(int j=0;j<n+1;j++)
		{
			Arrays.fill(dp[j],-1);
		}
		for(int i=0;i<n;i++)
		{
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		out.println(dp(0,s));
		out.flush();
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

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

package Knapsack;

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

protected 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:10: error: modifier protected not allowed here
protected class Knapsack {
          ^
1 error
Language: Java

package Knapsack;

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:10: error: class Knapsack is public, should be declared in a file named Knapsack.java
public class Knapsack {
       ^
1 error