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


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

public class Knapsack1 {

	static int N, INF = (int) 1e9;
	static Long[][] memo;
	static int[] values;
	static int[] weights;

	
	static Long solve(int idx, int remA) {
		if (remA < 0) 
			return (long) (-1 * INF);
		if (idx == N)
			return 0L;
		if (memo[idx][remA] != -1)
			return memo[idx][remA];
	

	Long	max = Math.max(solve(idx + 1, remA), values[idx] + solve(idx + 1, remA - weights[idx]));

		return memo[idx][remA] = max;
	}

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s);
		int n = Integer.parseInt(st.nextToken());
		int w = Integer.parseInt(st.nextToken());
		
		memo=new Long [n][w+1];
		N=n;
		for (int i = 0; i < N; i++)
			Arrays.fill(memo[i], -1L);
		values = new int[n];
		weights = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			weights[i] = Integer.parseInt(st.nextToken());
			values[i] = Integer.parseInt(st.nextToken());
		}
		System.out.println(solve(0, w));
	}
}


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

#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, w;
vector<ll>v, v2;
unordered_map<string, ll>mp;
ll knapsak(ll x, ll pr)
{
	if (x == n)
		return 0;
	string ss = to_string(x) + "S" + to_string(pr);
	if (mp[ss]>0) {
		return mp[ss];
	}
	ll ret = knapsak(x + 1, pr);
	if (w >= pr + v[x])
		ret = max(knapsak(x + 1, pr + v[x]) + v2[x], ret);
	ss = to_string(x) + "S" + to_string(pr);
	mp[ss] = ret;
	return ret;
}
int main()
{
	//run();
	M_Sayed;
	memset(vis, -1, sizeof vis);
	cin >> n >> w;
	v.resize(n);
	v2.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> v2[i];
	}
	RT(knapsak(0, 0));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:16: error: 'vis' was not declared in this scope
   56 |         memset(vis, -1, sizeof vis);
      |                ^~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, w;
vector<ll>v, v2;
unordered_map<string, ll>mp;
ll knapsak(ll x, ll pr)
{
	if (x == n)
		return 0;
	string ss = to_string(x) + "S" + to_string(pr);
	if (mp[ss]>0) {
		return mp[ss];
	}
	ll ret = knapsak(x + 1, pr);
	if (w >= pr + v[x])
		ret = max(knapsak(x + 1, pr + v[x]) + v2[x], ret);
	ss = to_string(x) + "S" + to_string(pr);
	mp[ss] = ret;
	return ret;
}
int main()
{
	//run();
	M_Sayed;
	memset(vis, -1, sizeof vis);
	cin >> n >> w;
	v.resize(n);
	v2.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> v2[i];
	}
	RT(knapsak(0, 0));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:16: error: 'vis' was not declared in this scope
   63 |         memset(vis, -1, sizeof vis);
      |                ^~~
Language: C++

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

#define lli long long int
#define pb push_back
#define f first
#define sec second

main()
{
    lli i,n,t,j,k,a,b,c,w,val;
    vector<pair<lli,lli>> v;

    lli cap;

    cin>>n>>cap;

    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        v.pb({b,a});
    }

    /*
    v.pb({89, 123});
    v.pb({90, 154});
    v.pb({95, 258});
    v.pb({100, 354});
    v.pb({90, 365});
    v.pb({79, 150});
    v.pb({50, 95});
    v.pb({10, 195});
    */

    lli dp[n+1][cap+a1];

    for(i=0;i<=n;i++)
    {
        dp[i][0] = 0;
    }

    for(i=0;i<=cap;i++)
    {
        dp[0][i] = 0;
    }

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=cap;j++)
        {
            val = v[i-1].f;
            w = v[i-1].sec;
            if(j<w)
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(val+dp[i-1][j-w], dp[i-1][j]);
            }
        }
    }

    cout<<dp[n][cap];
}


Compiler output:
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:35:21: error: 'a1' was not declared in this scope; did you mean 'a'?
   35 |     lli dp[n+1][cap+a1];
      |                     ^~
      |                     a
a.cc:39:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   39 |         dp[i][0] = 0;
      |         ^~
      |         dup
a.cc:44:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   44 |         dp[0][i] = 0;
      |         ^~
      |         dup
a.cc:55:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   55 |                 dp[i][j] = dp[i-1][j];
      |                 ^~
      |                 dup
a.cc:59:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   59 |                 dp[i][j] = max(val+dp[i-1][j-w], dp[i-1][j]);
      |                 ^~
      |                 dup
a.cc:64:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   64 |     cout<<dp[n][cap];
      |           ^~
      |           dup
Language: C++

//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=1e2 + 1,M=1e5 + 1;
ll arr[N];
ll pre[N];
ll dp[N][N];
ll OO=1e12; 
 
ll n,m,k,cnt,SU,idx,len,MN,MX;
ll l,r,mid;
ll a,b,c,d,s;
vector<ll> vec;
 
ll Solve(int idx,int rem){
	
	if(idx == n)
		return (rem < 0) ? -OO : 0;
	if(rem < 0)
		return -OO;
		
		
	ll &ret=dp[idx][rem];
	
	if(~ret)
		return ret;
	
	
	return ret = max(Solve(idx+1,rem) , pre[idx] + Solve(idx+1,rem-arr[idx]));

}

 
 
 
int main(){

.	memset(dp,-1,sizeof dp);
	
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i)
		scanf("%d%d",arr+i,pre+i);
	
	
	
	printf("%lld\n",Solve(0,m));

	
		
}
 
 


Compiler output:
a.cc: In function 'int main()':
a.cc:67:1: error: expected primary-expression before '.' token
   67 | .       memset(dp,-1,sizeof dp);
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

typedef long long int ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;

bool compare(const pair<ll,ll>& x, const pair<ll,ll>& y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

ll gcd(ll a,ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}

int n,w;
int W[101];
int P[101];

bool visit[101][100005];
ll dp[101][100005];

ll solve(int pos,int wt) {
    if(wt > w) {
        return -1e9;
    }
    if(pos >=n ) {
        return 0;
    }
    if(visit[pos][wt]) {
        return dp[pos][wt];
    }
    ll ans = 0;
    ans = solve(pos+1,wt);
    ans = max(ans,P[pos] + solve(pos+1,wt+W[pos]));
    visit[pos][wt] = true;
    dp[pos][wt] = ans;
    return ans;
}

int main() {
    cin >> n >> w;s
    for(int i=0;i<n;i++) {
        cin >> W[i] >> P[i];
    }
    cout << solve(0,0) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:19: error: 's' was not declared in this scope
   70 |     cin >> n >> w;s
      |                   ^
a.cc:71:17: error: 'i' was not declared in this scope
   71 |     for(int i=0;i<n;i++) {
      |                 ^
Language: C++

#include<bits/stdc++.h> 
using namespace std;
#define ll long long 
// A utility function that returns maximum of two integers 
ll int max(ll int a, ll int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
ll int knapSack(ll int W,ll int wt[], ll int val[], ll int n) 
{ 
   ll int i, w; 
   ll 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() 
{ 
    ll int W, n;
    cin>>n>>W;
    ll int wt[W], val[n];
    for(int i=0;i<n;i++){
        cin>>wt[i];
    }
    for(int i=0;i<n;i++){
        cin>>val[i];
    }
    //
    cout<<knapsack(W, wt, val, n)<<endl;
    return 0;
} 


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

#include<bits/stdc++.h>

using namespace std;
int dp[101][100010];
int w[101],v[101];
int main(){
  int n,W;cin>>n>>W;
for(int i = 1;i<=n;i++){
  cin>>w[i]>>v[i];
    for(int j = 0;j<=W;j++){
        //容量不够
        if(j < w[i]){
            dp[i][j] = dp[i-1][j];
        //容量足够
        }else{
            dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
        }
    }
  cout<<dp[n][w];
}}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:14: error: invalid types 'int [100010][int [101]]' for array subscript
   19 |   cout<<dp[n][w];
      |              ^
Language: C++

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

ll maxi(ll a,ll b)
{
    return a>b?a:b;
}

ll knapsack_bool(vector<int>& wt,vector<ll>& profit,int capacity)
{
    int n=wt.size();
    int m[n+1][capacity+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=capacity;j++)
        {
            if(i==0 || j==0)
                m[i][j]=0;

            else if(wt[i-1]<=j)
                m[i][j]=maxi(profit[i]+m[i-1][j-wt[i-1]],m[i-1][j]);

            else
                m[i][j]=m[i-1][j];
        }
    }
    return m[n][capacity];
}

int main()
{
    int capacity,n;
    cin>>n>>capacity;
    vector<pair<int,ll> > V(n,make_pair(0,0);
    for(int i=0;i<n;i++)
                            cin>>V[i].first>>V[i].second;
                            sort(V.begin(),V.end());
                            
    vector<int> weights(n,0);
    vector<ll> profit(n,0);
   
    for(int i=0;i<n;i++)
    {
        weights[i]=V[i].first;
        profit[i]=V[i].second;
    }
    ll max_profit=knapsack_bool(weights,profit,capacity);

    cout<<max_profit<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:45: error: expected ')' before ';' token
   35 |     vector<pair<int,ll> > V(n,make_pair(0,0);
      |                            ~                ^
      |                                             )
Language: C++

#include <bits/stdc++.h> 
using namespace std;   
using ll = long long;
//const int INF = 1e9 + 5;

void max_self(int& a, int b) {
	a = max(a, b);
}

int main() 
{ 
	int n, w; cin >> n >> w;
	vector<ll > dp(w + 1);
	for(int item = 0; item < n; item++) {
		int weight, value;
		cin >> weight >> value;
		for(int weight_already = w - weight; weight_already >= 0; weight_already--) {
			max_self(dp[weight_already + weight], dp[weight_already] + value);
		}
	}
	int answer = 0;
	for(int i=0; i <= w; i++) {
		max_self(answer, dp[i]);
	}
	cout << answer;
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:18:33: 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'}
   18 |                         max_self(dp[weight_already + weight], dp[weight_already] + value);
      |                         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:6:20: note:   initializing argument 1 of 'void max_self(int&, int)'
    6 | void max_self(int& a, int b) {
      |               ~~~~~^
Language: C++

using namespace std;
 
/*
 
    top down.
 
*/
 
 
const int MAXN = 100 + 5 , MAXW = 1e5 + 5;
 
 
int n , W;
long long w[MAXN] , v[MAXN];
long long mem[MAXN][MAXW];
 
long long dp(int i , int totalWeight){
 
    if(i == n) return 0;
 
    if(mem[i][totalWeight] != -1) return mem[i][totalWeight];
 
    long long path1 = dp(i + 1 , totalWeight);
    long long path2 = 0;
 
    if(totalWeight + w[i] <= W){
            path2 = v[i] + dp(i + 1 , totalWeight + w[i]);
    }
 
    mem[i][totalWeight] = max(path1 , path2);
    return mem[i][totalWeight];
 
}
 
main(){
 
    scanf("%d %d" , &n , &W);
 
    for(int i = 0 ; i < n ; i ++){
            scanf("%lld %lld" , &w[i] , &v[i]);
    }
 
    memset(mem , -1 , sizeof mem);
 
    printf("%lld\n" , dp(0 , 0));
 
    return 0;
}

Compiler output:
a.cc: In function 'long long int dp(int, int)':
a.cc:30:27: error: 'max' was not declared in this scope
   30 |     mem[i][totalWeight] = max(path1 , path2);
      |                           ^~~
a.cc: At global scope:
a.cc:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:37:5: error: 'scanf' was not declared in this scope
   37 |     scanf("%d %d" , &n , &W);
      |     ^~~~~
a.cc:43:5: error: 'memset' was not declared in this scope
   43 |     memset(mem , -1 , sizeof mem);
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | using namespace std;
a.cc:45:5: error: 'printf' was not declared in this scope
   45 |     printf("%lld\n" , dp(0 , 0));
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;
Language: Java

import java.util.*;


public class Main{
  
    public static void main(String[] args) {

        Scanner s = new Scanner(new BufferedInputStream(System.in));
        int N = s.nextInt();
        int W = s.nextInt();
        int[] wg = new int[N];
        int[] v = new int[N];
        int[][] dp = new int[N][W+1];

        for (int i = 0;i < N;i++) {
            wg[i] = s.nextInt();
            v[i] = s.nextInt();
        }

        for (int i = 0;i < N;i++) {
            for (int j = 1;j <= W;j++) {
                if (i > 0 && j - wg[i] > 0)
                dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-wg[i]]+v[i]);
                else if (i == 0) {
                    if (j - wg[i] >= 0) {
                        dp[i][j] = v[i];
                    }
                } else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }

        System.out.println(dp[N-1][W]);
    }
 	 
  
  
  
}


Compiler output:
Main.java:8: error: cannot find symbol
        Scanner s = new Scanner(new BufferedInputStream(System.in));
                                    ^
  symbol:   class BufferedInputStream
  location: class Main
1 error
Language: Java

import java.util.*;


public class Main{
  
    public static void main(String[] args) {

        Scanner s = new Scanner(new BufferedInputStream(System.in));
        int N = s.nextInt();
        int W = s.nextInt();
        int[] wg = new int[N];
        int[] v = new int[N];
        int[][] dp = new int[N][W+1];

        for (int i = 0;i < N;i++) {
            wg[i] = s.nextInt();
            v[i] = s.nextInt();
        }

        for (int i = 0;i < N;i++) {
            for (int j = 1;j <= W;j++) {
                if (i > 0 && j - wg[i] >= 0)
                dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-wg[i]]+v[i]);
                else if (i == 0) {
                    if (j - wg[i] >= 0) {
                        dp[i][j] = v[i];
                    }
                } else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }

        System.out.println(dp[N-1][W]);
    }
 	 
  
  
  
}

Compiler output:
Main.java:8: error: cannot find symbol
        Scanner s = new Scanner(new BufferedInputStream(System.in));
                                    ^
  symbol:   class BufferedInputStream
  location: class Main
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int n,w,a[1002],v[1002],c[1002],m,val;
	cin>>n>>w;
	for (int i=0;i<n;i++) cin>>a[i]>>v[i];
	int dp[w+7];
	memset(dp,0,sizeof(dp));
	for (int i=0;i<n;i++)
	{
		cin>>m>>val;
		for (int j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
	}
	cout<<dp[k]<<"\n";
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:28: error: 'k' was not declared in this scope
   14 |                 for (int j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                            ^
a.cc:14:68: error: expected ';' before '}' token
   14 |                 for (int j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                                                                    ^
      |                                                                    ;
   15 |         }
      |         ~                                                           
a.cc:16:18: error: 'k' was not declared in this scope
   16 |         cout<<dp[k]<<"\n";
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int n,w,a[1002],v[1002],c[1002]m,val;
	cin>>n>>w;
	for (int i=0;i<n;i++) cin>>a[i]>>v[i];
	int dp[w+7];
	memset(dp,0,sizeof(dp));
	for (int i=0;i<n;i++)
	{
		cin>>m>>val;
		for (int j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
	}
	cout<<dp[k]<<"\n";
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:40: error: expected initializer before 'm'
    6 |         int n,w,a[1002],v[1002],c[1002]m,val;
      |                                        ^
a.cc:13:22: error: 'm' was not declared in this scope
   13 |                 cin>>m>>val;
      |                      ^
a.cc:13:25: error: 'val' was not declared in this scope
   13 |                 cin>>m>>val;
      |                         ^~~
a.cc:14:28: error: 'k' was not declared in this scope
   14 |                 for (int j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                            ^
a.cc:16:18: error: 'k' was not declared in this scope
   16 |         cout<<dp[k]<<"\n";
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int n,w,a[1002],v[1002],c[1002],m,val;
	cin>>n>>w;
	for (int i=0;i<n;i++) cin>>a[i]>>v[i];
	int dp[w+7];
	memset(dp,0,sizeof(dp));
	for (int i=0;i<n;i++)
	{
		cin>>m>>val;
		for (j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
	}
	cout<<dp[k]<<"\n";
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: 'j' was not declared in this scope
   14 |                 for (j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                      ^
a.cc:14:24: error: 'k' was not declared in this scope
   14 |                 for (j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                        ^
a.cc:16:18: error: 'k' was not declared in this scope
   16 |         cout<<dp[k]<<"\n";
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int n,w,a[1002],v[1002],c[1002]m,val;
	cin>>n>>w;
	for (int i=0;i<n;i++) cin>>a[i]>>v[i];
	int dp[w+7];
	memset(dp,0,sizeof(dp));
	for (int i=0;i<n;i++)
	{
		cin>>m>>val;
		for (j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
	}
	cout<<dp[k]<<"\n";
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:40: error: expected initializer before 'm'
    6 |         int n,w,a[1002],v[1002],c[1002]m,val;
      |                                        ^
a.cc:13:22: error: 'm' was not declared in this scope
   13 |                 cin>>m>>val;
      |                      ^
a.cc:13:25: error: 'val' was not declared in this scope
   13 |                 cin>>m>>val;
      |                         ^~~
a.cc:14:22: error: 'j' was not declared in this scope
   14 |                 for (j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                      ^
a.cc:14:24: error: 'k' was not declared in this scope
   14 |                 for (j=k;j>=m;j--) dp[j]=max(dp[j],val+dp[j-m])
      |                        ^
a.cc:16:18: error: 'k' was not declared in this scope
   16 |         cout<<dp[k]<<"\n";
      |                  ^
Language: Java

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int W = stdIn.nextInt();
        int w[] = new int[N];
        int v[] = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = stdIn.nextInt();
            v[i] = stdIn.nextInt();
        }
        stdIn.close();
        Knapsack knapsak = new Knapsack();
        long max = knapsak.solve(w, v, W);
        System.out.println(max);
    }
}

class Knapsack {
    public long solve(int[] W, int[] P, int maxWeight) {
        long prev[] = new long[maxWeight + 1];
        long cur[] = new long[maxWeight + 1];

        for (int i = 0; i < W.length; i++) {
            for (int j = 0; j < cur.length; j++) {
                if (W[i] > j) {
                    cur[j] = Math.max(0, prev[j]);
                } else {
                    cur[j] = Math.max(prev[j], prev[j - W[i]] + P[i]);
                }
            }
            System
            for (int k = 0; k < cur.length; k++) {
                prev[k] = cur[k];
            }
        }

        return cur[cur.length - 1];
    }
}


Compiler output:
Main.java:34: error: not a statement
            System
            ^
Main.java:34: error: ';' expected
            System
                  ^
2 errors
Language: Java

import javax.swing.*;
import java.io.*;
import java.util.*;

public class FightAgainstTraffic {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int maxWeight = sc.nextInt();
        long[] weights = new long[count];
        int[] values = new int[count];
        for (int i = 0; i < count; i++) {
            weights[i] = sc.nextLong();
            values[i] = sc.nextInt();
        }
        int maxValue = 100001;
        long[][] res = new long[count][maxValue];
        boolean[][] b = new boolean[count][maxValue];
        for (int i = 0; i < count; i++) {
            for(int j= 0; j < maxValue; j++) {
                res[i][j] = Integer.MAX_VALUE;
            }
        }
        for (int i = 0; i < maxValue; i++) {
            b[0][i] = true;
        }
        res[0][values[0]] = weights[0];
        res[0][0] = 0;
        long result = calculate(res, weights, values, count - 1, maxValue - 1,b);
        int min = 0;
        for (int i = 0 ; i < count; i++) {
            for (int j = 0 ; j < maxValue; j++) {
                if (calculate(res, weights, values,  i, j,b) <= maxWeight) {
                    min = Math.max(j, min);
                }

            }
            System.out.println(Arrays.toString(res[i]));
        }
        System.out.println(min);
    }

    public static long calculate(long[][] res, long[] weights, int[] values, int index, int value, boolean[][] b) {
        if (index == 0) {
            return res[index][value];
        }
        if (b[index][value]) {
            return res[index][value];
        }
        int curValue = values[index];
        long mesame = Integer.MAX_VALUE;
//        if (value > 0) {
//            mesame = calculate(res, weights, values, index, value - 1, b);
//        }
        long without = calculate(res, weights, values, index - 1, value, b);
        long with = Integer.MAX_VALUE;
        if (value >= curValue) {
            with = calculate(res,weights, values, index -1, value - curValue, b) + weights[index];
        }
        res[index][value] = Math.min(Math.min(without, with), mesame);
        b[index][value] = true;
        return res[index][value];
    }
}

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

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return 1};return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return 1};return 0;}
const long long INF = 1LL << 60;

int main(){
  int N, W; cin >> N >> W;
  long long weight[110], value[110];
  long long dp[110][100100] = {0};
  for(int i = 1; i <= N; i++){
    cin >> weight[i] >> value[i];
  }
  
  for(int i = 1; i <= N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(sum_w - weight[i] > 0){
        chmax(dp[i][sum_w], dp[i - 1][sum_w - weight[i - 1]] + value[i]);
      }
      chmax(dp[i][sum_w], dp[i - 1][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
}
  



Compiler output:
a.cc: In function 'bool chmax(T&, T)':
a.cc:3:73: error: expected ';' before '}' token
    3 | template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return 1};return 0;}
      |                                                                         ^
      |                                                                         ;
a.cc: In function 'bool chmin(T&, T)':
a.cc:4:73: error: expected ';' before '}' token
    4 | template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return 1};return 0;}
      |                                                                         ^
      |                                                                         ;
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
ll dp[1100100][1050];
ll w[1050];
ll v[1050];

ll knapsack(ll i,ll W){
    if(dp[i][W] != -1){
        return dp[i][W];
    }
    if(W-w[i] < 0){
        dp[i][W] = knapsack(i-1,W);
    }else{
        dp[i][W] = max(knapsack(i-1,W),knapsack(i-1,W-w[i])+v[i]);
    }
    return dp[i][W];
}

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

    ll n,weight;
    cin >> n >> weight;
    for(ll i = 1; i < n+1;i++) {
        cin >> w[i] >> v[i];
    }

    for(ll i = 0; i < n+1;i++){
        for(ll l = 0; l < weight+1;l++){
            dp[i][l] = -1;
        }
    }
    for(ll i = 0; i < weight+1;i++){
        dp[0][i] = 0;
    }


    for(ll i = 1; i < n+1;i++){
        for(ll l = 1; l < weight+1;l++){
            knapsack(i,l);
        }
    }
    cout << dp[n][weight] << endl;

    return 0;
}

Compiler output:
/tmp/ccUc5Zg4.o: in function `knapsack(long long, long long)':
a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccUc5Zg4.o
a.cc:(.text+0xd8): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccUc5Zg4.o
a.cc:(.text+0x109): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccUc5Zg4.o
/tmp/ccUc5Zg4.o: in function `main':
a.cc:(.text+0x1fc): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccUc5Zg4.o
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccUc5Zg4.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
ll dp[11001000][105];
ll w[105];
ll v[105];

ll knapsack(ll i,ll W){
    if(dp[i][W] != -1){
        return dp[i][W];
    }
    if(W-w[i] < 0){
        dp[i][W] = knapsack(i-1,W);
    }else{
        dp[i][W] = max(knapsack(i-1,W),knapsack(i-1,W-w[i])+v[i]);
    }
    return dp[i][W];
}



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

    ll n,weight;
    cin >> n >> weight;
    REPP(i,1,n+1) cin >> w[i] >> v[i];

    REP(i,n+1) REP(l,weight+1) dp[i][l] = -1;
    REP(i,weight+1) dp[0][i] = 0;


    for(int i = 1; i < n+1;i++){
        for(int l = 1; l < weight+1;l++){
            knapsack(i,l);
        }
    }
    cout << dp[n][weight] << endl;

    return 0;
}

Compiler output:
/tmp/ccImSklJ.o: in function `knapsack(long long, long long)':
a.cc:(.text+0x94): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccImSklJ.o
a.cc:(.text+0x10b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccImSklJ.o
a.cc:(.text+0x13c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccImSklJ.o
/tmp/ccImSklJ.o: in function `main':
a.cc:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccImSklJ.o
a.cc:(.text+0x27b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccImSklJ.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int W = stdIn.nextInt();
        int w[] = new int[N];
        int v[] = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = stdIn.nextInt();
            v[i] = stdIn.nextInt();
        }
        Knapsak knapsak = new Knapsack();
        int max = knapsak.solve(w, v, W);
        System.out.println(max);
    }
}

class Knapsack {
    public int solve(int[] W, int[] P, int maxWeight) {
        int prev[] = new int[W.length + 2];
        int cur[] = new int[W.length + 2];

        for (int i = 0; i < W.length; i++) {
            for (int j = 0; j < cur.length; j++) {
                if (W[i] > j) {
                    cur[j] = Math.max(0, prev[j]);
                } else {
                    cur[j] = Math.max(prev[j], prev[j - W[i]] + P[i]);
                }
            }
            System.out.println(Arrays.toString(cur));
            for (int k = 0; k < cur.length; k++) {
                prev[k] = cur[k];
            }
        }

        return cur[cur.length - 1];
    }
}

Compiler output:
Main.java:14: error: cannot find symbol
        Knapsak knapsak = new Knapsack();
        ^
  symbol:   class Knapsak
  location: class Main
1 error
Language: C++

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

int main(){
  int n,w;
  cin>>n>>w;
  vector<ll>weight(n);
  vector<ll>value(n);
  for(int i=0;i<n;i++){
    cin>>weight[i]>>value[i];
  }
  vector<ll>dp(w+1);
  for(int i=0;i<n;i++){
   	for(int j=0;j<=w-weight[i];j++){
    	dp[weight[i]+j]=max(dp[weight[i]+j],d[j]+value[i]); 
    }
  }
  ll maxa=0;
  for(int i=0;i<w+1;i++){
    maxa=max(dp[i],maxa);
  }
  cout<<maxa<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:45: error: 'd' was not declared in this scope
   16 |         dp[weight[i]+j]=max(dp[weight[i]+j],d[j]+value[i]);
      |                                             ^
Language: C++

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

int main(){
  int n,w;
  cin>>n>>w;
  vector<int>weight(n);
  vector<ll>value(n);
  for(int i=0;i<n;i++){
    cin>>weight[i]>>value[i];
  }
  vector<ll>dp(n);
  dp[0]=value[0];
  for(int i=1;i<n;i++){
    int j=i-1;
    while(j--){
      if(weight[i]+weight[j]<=w){
        dp[i]=max(dp[i],dp[j]+value);
      }
    }
  }
  ll maxa=0;
  for(int i=0;i<n;i++){
    maxa=max(dp[i],maxa);
  }
  cout<<maxa<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'll' was not declared in this scope
    8 |   vector<ll>value(n);
      |          ^~
a.cc:8:12: error: template argument 1 is invalid
    8 |   vector<ll>value(n);
      |            ^
a.cc:8:12: error: template argument 2 is invalid
a.cc:10:26: error: invalid types 'int[int]' for array subscript
   10 |     cin>>weight[i]>>value[i];
      |                          ^
a.cc:12:12: error: template argument 2 is invalid
   12 |   vector<ll>dp(n);
      |            ^
a.cc:13:5: error: invalid types 'int[int]' for array subscript
   13 |   dp[0]=value[0];
      |     ^
a.cc:13:14: error: invalid types 'int[int]' for array subscript
   13 |   dp[0]=value[0];
      |              ^
a.cc:18:11: error: invalid types 'int[int]' for array subscript
   18 |         dp[i]=max(dp[i],dp[j]+value);
      |           ^
a.cc:18:21: error: invalid types 'int[int]' for array subscript
   18 |         dp[i]=max(dp[i],dp[j]+value);
      |                     ^
a.cc:18:27: error: invalid types 'int[int]' for array subscript
   18 |         dp[i]=max(dp[i],dp[j]+value);
      |                           ^
a.cc:22:5: error: expected ';' before 'maxa'
   22 |   ll maxa=0;
      |     ^~~~~
      |     ;
a.cc:24:5: error: 'maxa' was not declared in this scope
   24 |     maxa=max(dp[i],maxa);
      |     ^~~~
a.cc:24:16: error: invalid types 'int[int]' for array subscript
   24 |     maxa=max(dp[i],maxa);
      |                ^
a.cc:26:9: error: 'maxa' was not declared in this scope
   26 |   cout<<maxa<<endl;
      |         ^~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int n,w;
int W[1000],V[1000];
ll dp[110][100010];
int solve(){
  cin>>n>>w;
  rep(i,n){
    cin>>W[i]>>V[i];
  }
  rep(i,n){
    rep(j,w+1){
      if(j+W[i]<=w)dp[i+1][j+W[i]]=max(dp[i+1][j+W[i]],dp[i][j]+V[i];
      else dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:48:69: error: expected ')' before ';' token
   48 |       if(j+W[i]<=w)dp[i+1][j+W[i]]=max(dp[i+1][j+W[i]],dp[i][j]+V[i];
      |                                       ~                             ^
      |                                                                     )
Language: Java

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

public class KnapsackAt {
    public static long maxK(int[] weights, int[] values, int W){
        long[] dp = new long[W+1];
        for (int i = 0; i < weights.length; i++) {
            for (int weight = W - weights[i]; weight >= 0; weight--) {
                dp[weight+ weights[i]] = Math.max(dp[weight + weights[i]], dp[weight] + values[i]);
            }
        }
        return max(dp);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine());
        int N = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());
        int[] weights = new int[N];
        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            st = new StringTokenizer(reader.readLine());
            weights[i] = Integer.parseInt(st.nextToken());
            values[i] = Integer.parseInt(st.nextToken());
        }
        System.out.println(maxK(weights, values, W));
    }

    private static long max(long[] a){
        long max = 0;
        for (int i = 0; i < a.length; i++) {
            if (a[i] > max){
                max = a[i];
            }
        }
        return max;
    }
}


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

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
typedef pair<int, int> P;

int dp[101][100001] = {};

int main(){
    int n, w, w_i, v, i, j;
    cin >> n >> w;
    for(i=1; i<=n; i++){
        cin >> w_i >> v;
        for(j=0; j<=w; j++){
            if(j>=w_i){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w_i] + v):
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][w] << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:63: error: expected ';' before ':' token
   17 |                 dp[i][j] = max(dp[i-1][j], dp[i-1][j-w_i] + v):
      |                                                               ^
      |                                                               ;
Language: C++

/*一次元DP*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
  IOS;
  ll n,w;
  cin>>n>>w;
  vector<ll> value(n),weight(n);
  rep(i,n) cin>>weight[i]>>value[i];
  ll dp[w+1];
  rep(i,w+1) dp[i]=0;
  rep(i,n) for(ll j=w;j>=0;j--) if(j-weight[i]>=0)　dp[j]=max(dp[j],dp[j-weight[i]]+value[i]);
  cout<<dp[w]<<endl;
}


Compiler output:
a.cc:15:51: error: extended character 　 is not valid in an identifier
   15 |   rep(i,n) for(ll j=w;j>=0;j--) if(j-weight[i]>=0)　dp[j]=max(dp[j],dp[j-weight[i]]+value[i]);
      |                                                   ^
a.cc: In function 'int main()':
a.cc:15:51: error: '\U00003000dp' was not declared in this scope
   15 |   rep(i,n) for(ll j=w;j>=0;j--) if(j-weight[i]>=0)　dp[j]=max(dp[j],dp[j-weight[i]]+value[i]);
      |                                                   ^~~~
Language: C++

/*一次元DP*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
  IOS;
  ll n,w;
  cin>>n>>w;
  vector<ll> value(n),weight(n);
  rep(i,n) cin>>weight[i]>>value[i];
  ll dp[w+1];
  rep(i,w+1) dp[i]=0;
  rep(i,n) for(ll j=w;j>=0;j--) if(j-weight[i]>=0) chmax(dp[j],dp[j-weight[i]]+value[i]);
  cout<<dp[w]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:52: error: 'chmax' was not declared in this scope
   15 |   rep(i,n) for(ll j=w;j>=0;j--) if(j-weight[i]>=0) chmax(dp[j],dp[j-weight[i]]+value[i]);
      |                                                    ^~~~~
Language: C++

/*一次元DP*/
#include<bits/stdc++.h>using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
  IOS;
  ll n,w;
  cin>>n>>w;
  vector<ll> value(n),weight(n);
  rep(i,n) cin>>weight[i]>>value[i];
  ll dp[w+1];
  rep(i,w+1) dp[i]=0;
  rep(i,n) for(ll j=w;j>=0;j--) if(j-weight[i]>=0) chmax(dp[j],dp[j-weight[i]]+value[i]);
  cout<<dp[w]<<endl;
}

Compiler output:
a.cc:2:30: warning: extra tokens at end of #include directive
    2 | #include<bits/stdc++.h>using namespace std;
      |                              ^~~~~~~~~
a.cc:2:9: fatal error: bits/stdc++.h>usin: No such file or directory
    2 | #include<bits/stdc++.h>using namespace std;
      |         ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;

public class D_Knapsack1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int maxW = scanner.nextInt();

        int[] w = new int[n];
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }

        long[][] dp = new long[n + 1][maxW + 1];
        for (int i = 0; i < n + 1; i++) {
            for (int j = 0; j < maxW + 1; j++) {
                dp[i][j] = 0;
            }
        }

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

        System.out.println(dp[n][maxW]);
    }
}

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

include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll dp[109][100009];
int wt[109];
ll v[109];
ll knapSack(int n,int w){
 
    if(n<0) return 0;
    else if(wt[n]>w) knapSack(n-1,w);
    else if(dp[n][w]!= -1) return dp[n][w];
    else{
 
        dp[n][w] = max(v[n]+knapSack(n-1,w-wt[n]),knapSack(n-1,w));
        return dp[n][w];
    }
 
}
 
 
int main(){
    //freopen("input","r",stdin);
    memset(dp,-1,sizeof(dp));
    int n,w;
    cin >> n >> w;
    for(int i=0;i<n;i++) cin >> wt[i] >> v[i];
    cout << knapSack(n-1,w) << endl;
 
 
 
return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'll knapSack(int, int)':
a.cc:15:20: error: 'max' was not declared in this scope
   15 |         dp[n][w] = max(v[n]+knapSack(n-1,w-wt[n]),knapSack(n-1,w));
      |                    ^~~
a.cc: In function 'int main()':
a.cc:24:5: error: 'memset' was not declared in this scope
   24 |     memset(dp,-1,sizeof(dp));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | include<bits/stdc++.h>
a.cc:26:5: error: 'cin' was not declared in this scope
   26 |     cin >> n >> w;
      |     ^~~
a.cc:28:5: error: 'cout' was not declared in this scope
   28 |     cout << knapSack(n-1,w) << endl;
      |     ^~~~
a.cc:28:32: error: 'endl' was not declared in this scope
   28 |     cout << knapSack(n-1,w) << endl;
      |                                ^~~~
a.cc: In function 'll knapSack(int, int)':
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C++

clude<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll dp[109][100009];
int wt[109];
ll v[109];
ll knapSack(int n,int w){
 
    if(n<0) return 0;
    else if(wt[n]>w) knapSack(n-1,w);
    else if(dp[n][w]!= -1) return dp[n][w];
    else{
 
        dp[n][w] = max(v[n]+knapSack(n-1,w-wt[n]),knapSack(n-1,w));
        return dp[n][w];
    }
 
}
 
 
int main(){
    //freopen("input","r",stdin);
    memset(dp,-1,sizeof(dp));
    int n,w;
    cin >> n >> w;
    for(int i=0;i<n;i++) cin >> wt[i] >> v[i];
    cout << knapSack(n-1,w) << endl;
 
 
 
return 0;
}

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude<bits/stdc++.h>
      | ^~~~~
a.cc: In function 'll knapSack(int, int)':
a.cc:15:20: error: 'max' was not declared in this scope
   15 |         dp[n][w] = max(v[n]+knapSack(n-1,w-wt[n]),knapSack(n-1,w));
      |                    ^~~
a.cc: In function 'int main()':
a.cc:24:5: error: 'memset' was not declared in this scope
   24 |     memset(dp,-1,sizeof(dp));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | clude<bits/stdc++.h>
a.cc:26:5: error: 'cin' was not declared in this scope
   26 |     cin >> n >> w;
      |     ^~~
a.cc:28:5: error: 'cout' was not declared in this scope
   28 |     cout << knapSack(n-1,w) << endl;
      |     ^~~~
a.cc:28:32: error: 'endl' was not declared in this scope
   28 |     cout << knapSack(n-1,w) << endl;
      |                                ^~~~
a.cc: In function 'll knapSack(int, int)':
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^