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

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

class Item{
   long val, weight;
   public Item(long weight, long val){
      this.weight = weight;
      this.val = val;
   }
   
}
public class Main {
   public static void main(String[]abc) {
      Main ans = new Main();
      long solution = ans.solve();
      System.out.println(solution);
   }
   private long solve() {
      Scanner sc = new Scanner(System.in);
      long N = sc.nextLong();
      int maxWeight = sc.nextLong();
      // max value of an item is 10000
      long maxValue = N*1000;
      Item [] array = new Item[N];
      for(int i=0;i<N;i++){
         array[i] = new Item(sc.nextLong(),sc.nextLong());
      }
      long [][] dp = new long[N+1][maxValue+1];
      long INF = (long) 1e9+1;
	  for(int val=1;val<=maxValue;val++){
         dp[1][val] = INF;
      }
      dp[1][array[0].val]= array[0].weight;
      dp[1][0] = 0;
      for(int val=2;val<=maxValue;val++){
         for(int i=1;i<=N;i++){
            dp[i][val] = dp[i-1][val];
            if (array[i].val>val) continue;
            dp[i][val] = Math.min(dp[i][val], dp[i-1][val-array[i].val]);
         }
      }
      long bestVal=0;
      for(int val=1;val<=maxValue;val++){
         if (dp[N][val]>maxWeight) continue;
         bestVal = Math.max(bestVal, dp[N][val]);
      }
      return bestVal;
	       
   }
}


Compiler output:
Main.java:21: error: incompatible types: possible lossy conversion from long to int
      int maxWeight = sc.nextLong();
                                 ^
Main.java:24: error: incompatible types: possible lossy conversion from long to int
      Item [] array = new Item[N];
                               ^
Main.java:28: error: incompatible types: possible lossy conversion from long to int
      long [][] dp = new long[N+1][maxValue+1];
                               ^
Main.java:28: error: incompatible types: possible lossy conversion from long to int
      long [][] dp = new long[N+1][maxValue+1];
                                           ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
      dp[1][array[0].val]= array[0].weight;
                    ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
            dp[i][val] = Math.min(dp[i][val], dp[i-1][val-array[i].val]);
                                                         ^
Main.java:44: error: incompatible types: possible lossy conversion from long to int
         if (dp[N][val]>maxWeight) continue;
                ^
Main.java:45: error: incompatible types: possible lossy conversion from long to int
         bestVal = Math.max(bestVal, dp[N][val]);
                                        ^
8 errors
Language: Java

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

class Item{
   long val, weight;
   public Item(long weight, long val){
      this.weight = weight;
      this.val = val;
   }
   
}
public class Main {
   public static void main(String[]abc) {
      Main ans = new Main();
      long solution = ans.solve();
      System.out.println(solution);
   }
   private long solve() {
      Scanner sc = new Scanner(System.in);
      long N = sc.nextLong();
      long maxWeight = sc.nextLong();
      // max value of an item is 10000
      long maxValue = N*1000;
      Item [] array = new Item[N];
      for(int i=0;i<N;i++){
         array[i] = new Item(sc.nextLong(),sc.nextLong());
      }
      long [][] dp = new long[N+1][maxValue+1];
      long INF = (long) 1e9+1;
	  for(int val=1;val<=maxValue;val++){
         dp[1][val] = INF;
      }
      dp[1][array[0].val]= array[0].weight;
      dp[1][0] = 0;
      for(int val=2;val<=maxValue;val++){
         for(int i=1;i<=N;i++){
            dp[i][val] = dp[i-1][val];
            if (array[i].val>val) continue;
            dp[i][val] = Math.min(dp[i][val], dp[i-1][val-array[i].val]);
         }
      }
      long bestVal=0;
      for(int val=1;val<=maxValue;val++){
         if (dp[N][val]>maxWeight) continue;
         bestVal = Math.max(bestVal, dp[N][val]);
      }
      return bestVal;
	       
   }
}


Compiler output:
Main.java:24: error: incompatible types: possible lossy conversion from long to int
      Item [] array = new Item[N];
                               ^
Main.java:28: error: incompatible types: possible lossy conversion from long to int
      long [][] dp = new long[N+1][maxValue+1];
                               ^
Main.java:28: error: incompatible types: possible lossy conversion from long to int
      long [][] dp = new long[N+1][maxValue+1];
                                           ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
      dp[1][array[0].val]= array[0].weight;
                    ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
            dp[i][val] = Math.min(dp[i][val], dp[i-1][val-array[i].val]);
                                                         ^
Main.java:44: error: incompatible types: possible lossy conversion from long to int
         if (dp[N][val]>maxWeight) continue;
                ^
Main.java:45: error: incompatible types: possible lossy conversion from long to int
         bestVal = Math.max(bestVal, dp[N][val]);
                                        ^
7 errors
Language: Java

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

class Item{
   long val, weight;
   public Item(long weight, long val){
      this.weight = weight;
      this.val = val;
   }
   
}
public class Main {
   public static void main(String[]abc) {
      Main ans = new Main();
      long solution = ans.solve();
      System.out.println(solution);
   }
   private long solve() {
      Scanner sc = new Scanner(System.in);
      long N = sc.nextLong();
      long maxWeight = sc.nextLong();
      // max value of an item is 10000
      long maxValue = N*1000;
      Item [] array = new Item[N];
      for(int i=0;i<N;i++){
         array[i] = new Item(sc.nextLong(),sc.nextLong());
      }
      long [][] dp = new long[N+1][maxValue+1]
      long INF = (long) 1e9+1;
	  for(int val=1;val<=maxValue;val++){
         dp[1][val] = INF;
      }
      dp[1][array[0].val]= array[0].weight;
      dp[1][0] = 0;
      for(int val=2;val<=maxValue;val++){
         for(int i=1;i<=N;i++){
            dp[i][val] = dp[i-1][val];
            if (array[i].val>val) continue;
            dp[i][val] = Math.min(dp[i][val], dp[i-1][val-array[i].val]);
         }
      }
      long bestVal=0;
      for(int val=1;val<=maxValue;val++){
         if (dp[N][val]>maxWeight) continue;
         bestVal = Math.max(bestVal, dp[N][val]);
      }
      return bestVal;
	       
   }
}

Compiler output:
Main.java:28: error: ';' expected
      long [][] dp = new long[N+1][maxValue+1]
                                              ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100000
int n,k;
int w[105],v[105];
ll dp[N+5];
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {cin>>w[i]>>v[i];}
    for(int i=1;i<=N;i++) {dp[i]=int(2e9);}
    for(int i=1;i<=n;i++) {
       for(int j=N;j>=v[i];j--)
       	{dp[j]=min(dp[j],dp[j-v[i]]+w[i]);}
    }
    int ans=0;
    for(int i=0;i<=N;i++) {
       if(dp[i]<=k) {ans=max(ans,i);}
    }
    cout<<ans<<endl;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100000
int n,k;
int w[105],v[105];
ll dp[N+5],s=0;
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {cin>>w[i]>>v[i]; s+=v[i];}
    for(int i=1;i<=s;i++) {dp[i]=int(2e9);}
    for(int i=1;i<=n;i++) {
       for(int j=s;j>=v[i];j--)
       	{dp[j]=min(dp[j],dp[j-v[i]]+w[i]);}
    }
    int ans=0;
    for(int i=s;i>=0;i--) {
       if(dp[i]<=k) {cout<<ans<<endl; return 0;}
    }
  cout<<ans<<endl;
return 0;
}


Compiler output:
a.cc:26:5: error: redefinition of 'int n'
   26 | int n,k;
      |     ^
a.cc:5:5: note: 'int n' previously declared here
    5 | int n,k;
      |     ^
a.cc:26:7: error: redefinition of 'int k'
   26 | int n,k;
      |       ^
a.cc:5:7: note: 'int k' previously declared here
    5 | int n,k;
      |       ^
a.cc:27:5: error: redefinition of 'int w [105]'
   27 | int w[105],v[105];
      |     ^
a.cc:6:5: note: 'int w [105]' previously declared here
    6 | int w[105],v[105];
      |     ^
a.cc:27:12: error: redefinition of 'int v [105]'
   27 | int w[105],v[105];
      |            ^
a.cc:6:12: note: 'int v [105]' previously declared here
    6 | int w[105],v[105];
      |            ^
a.cc:28:4: error: redefinition of 'long long int dp [100005]'
   28 | ll dp[N+5],s=0;
      |    ^~
a.cc:7:4: note: 'long long int dp [100005]' previously declared here
    7 | ll dp[N+5];
      |    ^~
a.cc:29:5: error: redefinition of 'int main()'
   29 | int main() {
      |     ^~~~
a.cc:8:5: note: 'int main()' previously defined here
    8 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100000
int n,k;
int w[105],v[105];
ll dp[N+5];
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {cin>>w[i]>>v[i];}
    for(int i=1;i<=N;i++) {dp[i]=int(2e9);}
    for(int i=1;i<=n;i++) {
       for(int j=N;j>=v[i];j--)
       	{p[j]=min(dp[j],dp[j-v[i]]+w[i]);}
    }
    int ans=0;
    for(int i=0;i<=N;i++) {
       if(dp[i]<=k) {ans=max(ans,i);}
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'p' was not declared in this scope
   14 |         {p[j]=min(dp[j],dp[j-v[i]]+w[i]);}
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int n,k,N=1e5;
int w[105],v[105];
ll dp[N+5];
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {cin>>w[i]>>v[i];}
    for(int i=1;i<=1e5+5;i++) {dp[i]=int(2e9);}
    for(int i=1;i<=n;i++) {
       for(int j=N;j>=v[i];j--)
       	{p[j]=min(dp[j],dp[j-v[i]]+w[i]);}
    }
    int ans=0;
    for(int j=0;j<=N;j++) {
       if(dp[j]<=k) {ans=max(ans,j);}
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc:6:8: error: size of array 'dp' is not an integral constant-expression
    6 | ll dp[N+5];
      |       ~^~
a.cc: In function 'int main()':
a.cc:13:10: error: 'p' was not declared in this scope
   13 |         {p[j]=min(dp[j],dp[j-v[i]]+w[i]);}
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100005],a[105],b[105];
int main() {
	int n,k;
	cin>>n>>k;
	ll a[n],b[n],s=0,ans=0;
	for(int i=1;i<=n;i++) {cin>>a[i]>>b[i]; s+=b[i];}
	memset(dp,2e9,sizeof(dp));
  	for(int i=1;i<=n;i++) {
    	for(int j=s;j>=b[i];j--) {
        	dp[j]=min(dp[j],dp[j-b[i]]+a[i]);
        }
    }
  	for(int i=0;i<=s;i++) {
    	if(dp[i]<=k) {ans=max(ans,i);}
    }
	cout<<ans<<endl;
return 0;
}


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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |         dp[0][b[0]]=a[0];
      |         ^~
      |         dup
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	int n,k;
	cin>>n>>k;
	ll a[n],b[n],s=0;
	for(int i=0;i<n;i++) {cin>>a[i]>>b[i];}
	s=accumulate(b,b+n,0);
	ll dp[n][s+1];
	for(int i=0;i<n;i++) {
      	memset(dp[i],1e18,sizeof(dp[i]));
        dp[i][0]=0;
    }
	dp[0][b[0]]=a[0];
	for(int i=1;i<n;i++) {
		for(int j=0;j<=s;j++) {
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(j-b[i]>=0) {
              dp[i][j]=min(dp[i][j],a[i]+dp[i-1][j-b[i]]);
            } 
		}
	}
	ll ans=0;
	for(ll i=s;i>=0;i--) {
		if(dp[n-1][i]<=W) {
			ans=max(ans,i);
		}
	}
	cout<<ans<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   12 |         memset(dp[i],1e18,sizeof(dp[i]));
      |                      ^~~~
a.cc:26:32: error: 'W' was not declared in this scope
   26 |                 if(dp[n-1][i]<=W) {
      |                                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll n,k;
	cin>>n>>k;
  	ll a[n],b[n],s=0;
  	for(ll i=0;i<n;i++) {
    	cin>>a[i]>>b[i]; s+=b[i];
    }
  	ll dp[n][s+1];
  	for(ll i=0;i<n;i++) {
      for(ll j=0;j<=s;j++) {
      	  if(i==0 || j==b[i]) {dp[i][j]=a[i];}
          else {dp[i][j]=-1;}
      }
    }
    dp[0][0]=0;
  	for(ll i=1;i<n;i++) {
      for(ll j=0;j<=s;j++) {
      	if(dp[i-1][j]!=-1) {
        	if(dp[i][j]==-1) {dp[i][j]=dp[i-1][j];}
            else {dp[i][j]=min(dp[i][j],dp[i-1][j]);}
            if(dp[i][j+b[i]]==-1) {dp[i][j+b[i]]=dp[i-1][j]+a[i];}
            else {dp[i][j+b[i]]=min(dp[i][j+b[i]],dp[i-1][j]+a[i]);}
        }
      }
    }
  	ll ans=INT_MIN;
  	for(ll i=0;i<=s;i++) {
    	if(dp[n-1][i]<=w && dp[n-1][i]!=-1) {
        	ans=max(ans,i);
        }
    }
  	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:24: error: 'w' was not declared in this scope
   31 |         if(dp[n-1][i]<=w && dp[n-1][i]!=-1) {
      |                        ^
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
  if(x<=0) {return 0;}
  if(i==n) {return INT_MAX;}
  if(dp[x][i]!=-1) {return dp[x][i];}
  return dp[x][i]=min(a[i]+fn(a,b,i+1,n,x-b[i]),fn(a,b,i+1,n,x));
}
int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n],b[n],s=0;
  for(ll i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  	s+=b[i];
  }
  ll dp[s+1][n+1];
  for(int i=0;i<=s;i++) {memset(dp[i],-1,sizeof(dp[i]));}
  for(ll i=s;i>=0;i--) {
    ll x=fn(a,b,0,n,i,dp);
    if(x<=k) {cout<<i<<endl; break;}
  }
return 0;
}


Compiler output:
a.cc: In function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)':
a.cc:8:30: error: too few arguments to function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    8 |   return dp[x][i]=min(a[i]+fn(a,b,i+1,n,x-b[i]),fn(a,b,i+1,n,x));
      |                            ~~^~~~~~~~~~~~~~~~~~
a.cc:4:4: note: declared here
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |    ^~
a.cc:8:51: error: too few arguments to function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    8 |   return dp[x][i]=min(a[i]+fn(a,b,i+1,n,x-b[i]),fn(a,b,i+1,n,x));
      |                                                 ~~^~~~~~~~~~~~~
a.cc:4:4: note: declared here
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |    ^~
a.cc: In function 'int main()':
a.cc:21:23: error: cannot convert 'long long int (*)[(n + 1)]' to 'long long int**'
   21 |     ll x=fn(a,b,0,n,i,dp);
      |                       ^~
      |                       |
      |                       long long int (*)[(n + 1)]
a.cc:4:41: note:   initializing argument 6 of 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |                                         ^
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
  if(x<=0) {return 0;}
  if(i==n) {return INT_MAX;}
  if(dp[x][i]!=-1) {return dp[x][i];}
  dp[x][i]=min(b[i]+fn(a,b,i+1,n,x-a[i]),fn(a,b,i+1,n,x));
  return dp[x][i];
}
int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n],b[n],s=0;
  for(ll i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  	s+=b[i];
  }
  for(ll i=s;i>=0;i--) {
  	vector<vector<ll>>(s+1,vector<ll>(n+1,-1));
    ll x=fn(a,b,0,n,i,dp);
    if(x<=k) {cout<<i<<endl; break;}
  }
return 0;
}


Compiler output:
a.cc: In function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)':
a.cc:8:23: error: too few arguments to function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    8 |   dp[x][i]=min(b[i]+fn(a,b,i+1,n,x-a[i]),fn(a,b,i+1,n,x));
      |                     ~~^~~~~~~~~~~~~~~~~~
a.cc:4:4: note: declared here
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |    ^~
a.cc:8:44: error: too few arguments to function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    8 |   dp[x][i]=min(b[i]+fn(a,b,i+1,n,x-a[i]),fn(a,b,i+1,n,x));
      |                                          ~~^~~~~~~~~~~~~
a.cc:4:4: note: declared here
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |    ^~
a.cc: In function 'int main()':
a.cc:21:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |     ll x=fn(a,b,0,n,i,dp);
      |                       ^~
      |                       dup
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
  if(x<=0) {return 0;}
  if(i==n) {return INT_MAX;}
  if(dp[x][i]!=-1) {return dp[x][i];}
  dp[x][i]=min(b[i]+fn(a,b,i+1,n,x-a[i]),fn(a,b,i+1,n,x);
  return dp[x][i];
}
int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n],b[n],s=0;
  for(ll i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  	s+=b[i];
  }
  for(ll i=s;i>=0;i--) {
  	vector<vector<ll>>(s+1,vector<ll>(n+1,-1));
    ll x=fn(a,b,0,n,i,dp);
    if(x<=k) {cout<<i<<endl; break;}
  }
  
  
  
return 0;
}


Compiler output:
a.cc: In function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)':
a.cc:8:23: error: too few arguments to function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    8 |   dp[x][i]=min(b[i]+fn(a,b,i+1,n,x-a[i]),fn(a,b,i+1,n,x);
      |                     ~~^~~~~~~~~~~~~~~~~~
a.cc:4:4: note: declared here
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |    ^~
a.cc:8:44: error: too few arguments to function 'long long int fn(long long int*, long long int*, long long int, long long int, long long int, long long int**)'
    8 |   dp[x][i]=min(b[i]+fn(a,b,i+1,n,x-a[i]),fn(a,b,i+1,n,x);
      |                                          ~~^~~~~~~~~~~~~
a.cc:4:4: note: declared here
    4 | ll fn(ll a[],ll b[],ll i,ll n,ll x,ll** dp) {
      |    ^~
a.cc: In function 'int main()':
a.cc:21:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |     ll x=fn(a,b,0,n,i,dp);
      |                       ^~
      |                       dup
Language: C++

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

int main() {
    long long n,w;    cin>>n>>w;
    long long dp[100005];
    memset(dp, -1, sizeof(dp));
    int mx_till_now=0;
    dp[0]=0;
    for(int i=0;i<n;i++){
        long long wi,vi;cin>>wi>>vi;
        for(long long j=mx_till_now;j>=0;j--)if( dp[j]!=-1 && (dp[j] + wi)<=w ){
                dp[j+vi] = max ( dp[j+vi] , dp[j] + wi );
                mx_till_now=max(mx_till_now,j+vi);
        }
    }   
    cout<<mx_till_now;
    
    return 0;
}

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

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

class Item {
   int weight, val;
   public Item(int weight, int val) {
      this.weight = weight;
      this.val = val;
   }
}
public class Main {
  
  
  public static void main(String []abc) {
     Main sol = new Main();
	 long answer=sol.solve();
     System.out.println(answer);
  }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     int maxWeight = sc.nextInt();
     int maxValue = 1000*N;
     long [][] dp = new long[N+1][maxValue+1];
     long INF = (long) 1e9+1;
     for(int i=0;i<=maxValue;i++){
        dp[1][i] = INF;
     }
     Item []array = new Item[N+1];
     for(int i=1;i<=N;i++){
        array[i] = new Item(sc.nextInt(), sc.nextInt());
     }
     dp[1][array[1].val] = array[1].weight;
     dp[1][0] = 0;
     for(int i=2;i<=N;i++){
        for(int val=0;val<=maxValue;val++){
           dp[i][val] = dp[i-1][val];
           if (array[i].val > val) continue;
           dp[i][val] = Math.min( dp[i-1][val],
                                  dp[i-1][val-array[i].val]);
        }       
     }
     int bestVal=0;
     for(int i=0;i<=maxValue;i++){
        if (dp[N][i]<=maxWeight) bestVal = Math.max(bestVal, dp[N][i]);
     }
     return bestVal;
  }
}

Compiler output:
Main.java:46: error: incompatible types: possible lossy conversion from long to int
        if (dp[N][i]<=maxWeight) bestVal = Math.max(bestVal, dp[N][i]);
                                                   ^
1 error
Language: Java

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

class Item {
  int val;
  int weight;
  public Item(int weight, int value) {
    this.val = value;
    this. weight = weight;
  }
}
public class Main {
 
  public static void main(String[]abc) {
     Main answer = new Main();
     long solution = answer.solve();
     System.out.println(solution);
  }
  
  private long solve() {
	Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    int maxWeight = sc.nextInt();
    // max value of an item = 1000
    // total max value = N items * 1000
    int maxValue = 1000*N;
    long [][] dp = new int[N+1][maxValue];
    long INF = (long) 1e9+1;
    for(int i=0;i<maxValue;i++){
       dp[1][i]= INF;
    }
    Item[] array = new Item[N+1];
    for(int i=1;i<=N;i++){
      array[i]= new Item(sc.nextInt(), sc.nextInt());
    }
    dp[1][array[1].val] = array[1].weight;
    dp[1][0]=0;
    for(int i=2;i<=N;i++){
      for(int j=0;j<=maxValue;i++){
        dp[i][j] = dp[i-1][j];
        if (array[i].val>j) continue;
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-array[i].val] + array[i].weight);
      }
    }
    long bestValue =0;
    for(int i=0;i<=maxValue;i++) {
       if (dp[N][i]<maxWeight) bestValue = Math.max(bestValue, dp[N][i]);
    }
    return bestValue;
     
  }
  
}


Compiler output:
Main.java:27: error: incompatible types: int[][] cannot be converted to long[][]
    long [][] dp = new int[N+1][maxValue];
                   ^
1 error
Language: Java

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

class Item {
  int val;
  int weight;
  public Item(int weight, int value) {
    this.val = value;
    this. weight = weight;
  }
}
public class Main {
 
  public static void main(String[]abc) {
     Main answer = new Main();
     long solution = answer.solve();
     System.out.println(solution);
  }
  
  private void solve() {
	Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    int maxWeight = sc.nextInt();
    // max value of an item = 1000
    // total max value = N items * 1000
    int maxValue = 1000*N;
    int [][] dp = new int[N+1][maxValue];
    long INF = (long) 1e9+1;
    for(int i=0;i<maxValue;i++){
       dp[1][i]= INF;
    }
    Item[] array = new Item[N+1];
    for(int i=1;i<=N;i++){
      array[i]= new Item(sc.nextInt(), sc.nextInt());
    }
    dp[1][array[1].val] = array[1].weight;
    dp[1][0]=0;
    for(int i=2;i<=N;i++){
      for(int j=0;j<=maxValue;i++){
        dp[i][j] = dp[i-1][j];
        if (array[i].value>j) continue;
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-array[i].value] + array[i].weight);
      }
    }
    long bestValue =0;
    for(int i=0;i<=maxValue;i++) {
       if (dp[N][i]<maxWeight) bestValue = Math.max(bestValue, dp[N][i]);
    }
    return bestValue;
    
                             
    
  }
  
}


Compiler output:
Main.java:16: error: incompatible types: void cannot be converted to long
     long solution = answer.solve();
                                 ^
Main.java:30: error: incompatible types: possible lossy conversion from long to int
       dp[1][i]= INF;
                 ^
Main.java:41: error: cannot find symbol
        if (array[i].value>j) continue;
                    ^
  symbol:   variable value
  location: class Item
Main.java:42: error: cannot find symbol
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-array[i].value] + array[i].weight);
                                                           ^
  symbol:   variable value
  location: class Item
Main.java:49: error: incompatible types: unexpected return value
    return bestValue;
           ^
5 errors
Language: C++

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

long long int knapsack(int s, int wt[], long long int val[], int n){
	int W=0;
  	for(int i=0; i<n; i++){
      sum+=val[i];
    }
  	long long int k[n+1][W+1];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=W; j++){
			if(i==0 ||j==0){
				k[i][j]=0;
			}
			else if(j>=wt[i-1]){
				k[i][j]= max(val[i-1]+k[i-1][j-wt[i-1]],k[i-1][j]);
			}
			else{
				k[i][j]=k[i-1][j];
			}
		}
	}
	return k[n][W];
}

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

Compiler output:
a.cc: In function 'long long int knapsack(int, int*, long long int*, int)':
a.cc:7:7: error: 'sum' was not declared in this scope
    7 |       sum+=val[i];
      |       ^~~
Language: C++

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


void solve()
{
   int n;int W;cin>>n>>W;
   vector<int>dp(n+1,1e12);
   dp[0]=0;
   
   for(int j=0;j<n;j++)
   {
    int w,v;
    cin>>w>>v;
    for(int i=N-v;i>=0;i--)
        dp[i+v]=min(dp[i+v],dp[i]+w);
   }
		int ans=0;
		for(int i=0;i<n+1;i++)
		{
		if(dp[i]<=W) 
		ans=i;
		}
		cout<<ans;
	
   
}
int32_t main()
{
    rapido;
    int t;t=1;
    while(t--)
    solve();
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:17:15: error: 'N' was not declared in this scope
   17 |     for(int i=N-v;i>=0;i--)
      |               ^
Language: C++

#include<bits/stdc++.h>

2.#define qtr ios::sync_with_stdio(0); cin.tie(0);

3.#define int long long

4.using namespace std;

5. 

6.int32_t main(){ qtr

7.	int n, m;

8.	cin >> n >> m;

9.	vector<int> weight(n);

10.	vector<int> value(n);

11.	for(int i = 0; i < n; i++){

12.		cin >> weight[i] >> value[i];

13.	}

14.	vector<vector<int>> dp(2, vector<int>(m+1));

15.	for(int i = 0; i < n; i++){

16.		for(int j = 0; j <= m; j++){

17.			if(j < weight[i]) dp[i%2][j] = dp[(i+1)%2][j];

18.			else dp[i%2][j] = max(dp[(i+1)%2][j], dp[(i+1)%2][j-weight[i]] + value[i]);

19.		}

20.	}

21.	cout << max(dp[0][m], dp[1][m]) << endl;

22.}



Compiler output:
a.cc:3:3: error: stray '#' in program
    3 | 2.#define qtr ios::sync_with_stdio(0); cin.tie(0);
      |   ^
a.cc:5:3: error: stray '#' in program
    5 | 3.#define int long long
      |   ^
a.cc:3:1: error: expected unqualified-id before numeric constant
    3 | 2.#define qtr ios::sync_with_stdio(0); cin.tie(0);
      | ^~
a.cc:3:40: error: 'cin' does not name a type
    3 | 2.#define qtr ios::sync_with_stdio(0); cin.tie(0);
      |                                        ^~~
a.cc:5:1: error: expected unqualified-id before numeric constant
    5 | 3.#define int long long
      | ^~
a.cc:9:1: error: expected unqualified-id before numeric constant
    9 | 5.
      | ^~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll c[100000005];
ll ans,n,w;
ll a[100000005],
ll b[100000005];
int main()
{
	ll i,j,k,x,y,t;
	cin>>n>>w;
	for(i=1;i<=n;i++)
	cin>>a[i]>>b[i];
	for(i=1;i<=n;i++)
		for(j=w;j>=a[i];j--)
		c[j]=max(c[j],c[j-a[i]]+b[i]);
	
	cout<<c[w];
	return 0;
}


Compiler output:
a.cc:10:4: error: expected initializer before 'b'
   10 | ll b[100000005];
      |    ^
a.cc: In function 'int main()':
a.cc:16:20: error: 'b' was not declared in this scope
   16 |         cin>>a[i]>>b[i];
      |                    ^
a.cc:19:41: error: 'b' was not declared in this scope
   19 |                 c[j]=max(c[j],c[j-a[i]]+b[i]);
      |                                         ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;
int n, c;

int main() {
    scanf("%d %d", &n, &c);
    vector<int> w(n);
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &w[i], &v[i]);
    }

    // dp[i][j] := maximum total value of a subset of the first i items, with total size at most j
    vector<long long> dp(n + 1);
    for (int j = 0; j <= n; ++j) {
        dp[j] = 0;
    }

    for (int i = 1; i <= n; ++i) {
        vector<long long> cur(n + 1);
        for (int j = 0; j <= c; ++j) {
            if (j < w[i - 1]) cur[j] = dp[j];
            else cur[j] = max(dp[j], dp[j - w[i -1]] + v[i - 1]);
        }
        dp = cur;
    }
    printf("%lld\n", dp[n][c]);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:27: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[int]' for array subscript
   29 |     printf("%lld\n", dp[n][c]);
      |                           ^
Language: C++

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


typedef struct{
    long long peso, valor;
}item;

vector<item> itens;
long long dp[101][100001];
long long n,w;


long long solve(long long pos, long long totvalue, long long totpeso){
    if(dp[pos][totvalue]) return dp[pos][totvalue];
    if(totpeso > w) return -1000000000000000000;
    if(pos >= n) return 0;
    return dp[pos][totvalue] = max(solve(pos+1, totvalue, totpeso), itens[pos].valor + solve(pos+1, totvalue + itens[pos].valor, totpeso + itens[pos].peso));
}

int main() {
    cin >> n >> w;
    for(long long i = 0 ; i < n; i++){
        item it; cin >> it.peso >> it.valor;
        itens.push_back(it);
    }
    cout << min(0, solve(0,0,0)) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:16: error: no matching function for call to 'min(int, long long int)'
   27 |     cout << min(0, solve(0,0,0)) << 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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:27:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |     cout << min(0, solve(0,0,0)) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:27:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |     cout << min(0, solve(0,0,0)) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

int knapsack(vector<int> wt, vector<int> val, i, w){
	if (i<0)	return 0;
	if (w < wt[i]) 	return knapsack(wt, val, i-1, w);

	return max(knapsack(wt, val, i-1, w), val[i] + knapsack(wt, val, i-1, w-wt[i]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, w;
    cin >> n >> w;
    vector<int> wt(n), val(n);
    for (int i = 0; i < n; ++i)
        cin >> wt[i] >> val[i];

    int sol = knapsack(wt, val, n-1, w);

    cout << sol << endl;

    return 0;
}

Compiler output:
a.cc:9:47: error: 'i' has not been declared
    9 | int knapsack(vector<int> wt, vector<int> val, i, w){
      |                                               ^
a.cc:9:50: error: 'w' has not been declared
    9 | int knapsack(vector<int> wt, vector<int> val, i, w){
      |                                                  ^
a.cc: In function 'int knapsack(std::vector<int>, std::vector<int>, int, int)':
a.cc:10:13: error: 'i' was not declared in this scope
   10 |         if (i<0)        return 0;
      |             ^
a.cc:11:13: error: 'w' was not declared in this scope; did you mean 'wt'?
   11 |         if (w < wt[i])  return knapsack(wt, val, i-1, w);
      |             ^
      |             wt
a.cc:11:20: error: 'i' was not declared in this scope
   11 |         if (w < wt[i])  return knapsack(wt, val, i-1, w);
      |                    ^
a.cc:13:38: error: 'i' was not declared in this scope
   13 |         return max(knapsack(wt, val, i-1, w), val[i] + knapsack(wt, val, i-1, w-wt[i]));
      |                                      ^
a.cc:13:43: error: 'w' was not declared in this scope; did you mean 'wt'?
   13 |         return max(knapsack(wt, val, i-1, w), val[i] + knapsack(wt, val, i-1, w-wt[i]));
      |                                           ^
      |                                           wt
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include"prettyprint.hpp"
typedef long long ll;
typedef double db;

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

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    ll n, mxw;
    cin >> n >> mxw;
    ll w[n], v[n];
    ll sum = 0;
    for (ll i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    // debug(arr(w, n));
    // debug(arr(v, n));
    ll dp[sum + 1] = {0};
    dp[v[0]] = w[0];
    // debug(arr(dp, sum + 1));
    for (ll i = 1; i < n; ++i) {
        // debug(i);
        for (ll j = sum; j >= 1; --j) {
            if (dp[j]) {
                // debug(j);
                ll sum_v = j + v[i];
                ll sum_w = dp[j] + w[i];
                // debug(sum_v, sum_w);
                if (sum_w <= mxw) {
                    if (dp[sum_v] != 0) dp[sum_v] = min(sum_w, dp[sum_v]);
                    else dp[sum_v] = sum_w;
                }
            }
        }
        if (w[i] <= mxw) dp[v[i]] = w[i];
        // debug(arr(dp, sum + 1));
    }
    ll ans = 0;
    for (ll i = sum; i >= 1; --i) {
        if (dp[i]) {
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Compiler output:
a.cc:3:9: fatal error: prettyprint.hpp: No such file or directory
    3 | #include"prettyprint.hpp"
      |         ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int weight = sc.nextInt();
		int[] w = new int[n];
		int[] v = new int[n];
		for(int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		long[][] dp = new long[n+1][100001];
		for(int i = 0; i < n + 1; i++) {
			for(int j = 0; j < 100001; j++) {
				dp[i][j] = 92233720368l;
			}
		}
		/*for(int i = 0; i < 100001; i++) {
			dp[0][i] = 0;
		}*/
		dp[0][0] = 0;
		//---------初期設定終了-----------
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 100001; j++) {
				dp[i+1][j] = Math.min(dp[i+1][j], dp[i][j]);
				if(j + v[i] <= 100000)dp[i+1][j+v[i]] = Math.min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
			}
		}
		long ans = 0;
		for(int i = 0; i < 100001; i++) {
			if(dp[n][i] <= weight)ans = i;
		}
		System.out.println(ans);
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

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

int dp[102][100005];

int main()
{

	// 	#ifndef ONLINE_JUDGE
	// 		freopen("input", "r", stdin);
	// 		freopen("output","w",stdout);
	// #endif


	int n,W;	cin>>n>>W;
	int v[n+1], w[n+1];

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


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

	// for(int i=1;i<=n;++i)
	// 	for(int j=1;j<=W;++j)
	// 		cout<<dp[i][j]<<" \n"[j==W];

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

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namepsace std;
int maxValue(int n,int W,int w[],int val[])
{
  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(j>=w[i-1])
        dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-w[i-1]]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  return dp[n][W];
}
int main(){
  int n,W;
  cin>>n>>W;
  int w[n+1],val[n+1]; 
  for(int i=0;i<n;i++)
   cin>>w[i]>>val[i];
  int ans = maxValue(n,W,w,val);
  cout<<ans;
}


Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namepsace'
    2 | using namepsace std;
      |       ^~~~~~~~~
a.cc: In function 'int maxValue(int, int, int*, int*)':
a.cc:13:18: error: 'max' was not declared in this scope; did you mean 'std::max'?
   13 |         dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-w[i-1]]);
      |                  ^~~
      |                  std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:22:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |   cin>>n>>W;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:27:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |   cout<<ans;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<iostream>
using namepsace std;
int maxValue(int n,int W,int w[],int val[]){
  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(j>=w[i-1])
        dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-w[i-1]]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  return dp[n][W];
}
int main(){
  int n,W;
  cin>>n>>W;
  int w[n+1],val[n+1]; 
  for(int i=0;i<n;i++)
   cin>>w[i]>>val[i];
  int ans = maxValue(n,W,w,val);
  cout<<ans;
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namepsace'
    2 | using namepsace std;
      |       ^~~~~~~~~
a.cc: In function 'int maxValue(int, int, int*, int*)':
a.cc:12:18: error: 'max' was not declared in this scope; did you mean 'std::max'?
   12 |         dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-w[i-1]]);
      |                  ^~~
      |                  std::max
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:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:21:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   21 |   cin>>n>>W;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |   cout<<ans;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int dp[101][100001];
int max(int a,int b){
	if(a>b)
	return a;
	else return b;
}
int knapsack(int w[],int v[],int n,int c,int max){
	if(c<=0 || max==0)
      return 0;
		else{
	 dp[n-1][max] = max(knapsack(w,v,n-1,c,max),v[n-1]+knapsack(w,v,n-1,c-w[n-1],max-v[n-1]));
	 return dp[n-1][max];
		}
		
}

int main(){
	int n,c;
	cin >> n >> c;
	 int v[n],w[n];
  int max = 0;
	for(int i=0;i<n;i++){ cin >> w[i];
	 cin >> v[i];
      max+=v[i];                   
                        }
	for(int i=0;i<n;i++){
		  for(int j=0;j<=max;j++){
			  dp[i][j]=-1;
		  }
	  }
	  knapsack(w,v,n,c,max);
	 cout << dp[n-1][max] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int knapsack(int*, int*, int, int, int)':
a.cc:14:28: error: 'max' cannot be used as a function
   14 |          dp[n-1][max] = max(knapsack(w,v,n-1,c,max),v[n-1]+knapsack(w,v,n-1,c-w[n-1],max-v[n-1]));
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;
int dp[101][1001];
int max(int a,int b){
  return (a>b)?a:b;
}
int knapsack(int v[],int w[],int n,int c){
  if(dp[n-1][c]!=0)
    return dp[n-1][c];
  if(n==0 || c==0)
    return 0;
  else if(w[n-1]>c){
    dp[n-1][c] = knapsack(v,w,n-1,c);
    return dp[n-1][c];
  }
  dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
  return dp[n-1][c];
}
int main(){
  ios::sync_with_sydio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  int n,c;
  cin >> n >> c;
  int w[n],v[n];
  for(int i=0;i<n;i++){
  	cin >> w[i];
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
  for(int j=0;j<=c;j++){
    dp[i][j]=0;
  }
     }
  knapsack(v,w,n,c);
  cout << dp[n-1][c] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: 'sync_with_sydio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   20 |   ios::sync_with_sydio(false);
      |        ^~~~~~~~~~~~~~~