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

int N,W;
  cin>>N>>W;
  int weight[N];
  int value[N];
  for(int i=0;i<N;i++){
  cin>>weight[i]>>value[i];
  }
  long long ans=0;
  long long dp[W+1]={0};
  for(int i=1;i<=W;i++){
    long long maxval=0;
  for(int j=0;j<N;j++){
  if(i>=weight[j]&&maxval<((long long)dp[i-weight[j]]+(long long)value[j]))
    maxval=((long long)dp[i-weight[j]]+(long long)value[j]);
  }
    
      dp[i]=maxval;
  }
  cout<<dp[W];
  return 0;


Compiler output:
a.cc:2:3: error: 'cin' does not name a type
    2 |   cin>>N>>W;
      |   ^~~
a.cc:3:14: error: size of array 'weight' is not an integral constant-expression
    3 |   int weight[N];
      |              ^
a.cc:4:13: error: size of array 'value' is not an integral constant-expression
    4 |   int value[N];
      |             ^
a.cc:5:3: error: expected unqualified-id before 'for'
    5 |   for(int i=0;i<N;i++){
      |   ^~~
a.cc:5:15: error: 'i' does not name a type
    5 |   for(int i=0;i<N;i++){
      |               ^
a.cc:5:19: error: 'i' does not name a type
    5 |   for(int i=0;i<N;i++){
      |                   ^
a.cc:9:17: error: size of array 'dp' is not an integral constant-expression
    9 |   long long dp[W+1]={0};
      |                ~^~
a.cc:10:3: error: expected unqualified-id before 'for'
   10 |   for(int i=1;i<=W;i++){
      |   ^~~
a.cc:10:15: error: 'i' does not name a type
   10 |   for(int i=1;i<=W;i++){
      |               ^
a.cc:10:20: error: 'i' does not name a type
   10 |   for(int i=1;i<=W;i++){
      |                    ^
a.cc:19:3: error: 'cout' does not name a type
   19 |   cout<<dp[W];
      |   ^~~~
a.cc:20:3: error: expected unqualified-id before 'return'
   20 |   return 0;
      |   ^~~~~~
Language: C++

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

Compiler output:
a.cc:3:19: error: declaration does not declare anything [-fpermissive]
    3 | typedef long long int;
      |                   ^~~
Language: C++

#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
const int MX = 1e5+5;
int dp[MX][105];
vector <int> v,w;
int n,W;

int solve(int weight,int ind){
    if(weight > W) return -1e17;
    if(ind == n+1) return 0;
    if(dp[weight][ind] != -1) return dp[weight][ind];
    long long ans = -1e17;
    for(int i=1 ; i<=n ; i++){
        ans = max(ans, solve(weight + w[ind],ind + 1) + v[ind]);
        ans = max(ans, solve(weight ,ind + 1));
    }a
    return dp[weight][ind] = ans;
}

int32_t main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>W;
    v.resize(n+1);
    w.resize(n+1);
    for(int i=1 ; i<=n ; i++) cin>>w[i]>>v[i];
    cout<<solve(0,1);
    return 0;
}


Compiler output:
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:18:6: error: 'a' was not declared in this scope
   18 |     }a
      |      ^
a.cc:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
Language: C++

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

ll solve(int W[], ll V[]){
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			//cout<<"1"<<endl;
			if(i==0 || j==0)
			{
				dp[i][j] = 0;
				continue;
			}
			if(W[i-1]<=j)
			{
				dp[i][j] = max(V[i-1]+dp[i-1][j-W[i-1]],dp[i-1][j]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	return dp[n][w];
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:36:5: error: expected initializer before 'int'
   36 |     int W[n];
      |     ^~~
a.cc:39:22: error: 'W' was not declared in this scope
   39 |                 cin>>W[i]>>V[i];
      |                      ^
a.cc:39:28: error: 'V' was not declared in this scope
   39 |                 cin>>W[i]>>V[i];
      |                            ^
a.cc:42:21: error: 'W' was not declared in this scope
   42 |         cout<<solve(W,V)<<endl;
      |                     ^
a.cc:42:23: error: 'V' was not declared in this scope
   42 |         cout<<solve(W,V)<<endl;
      |                       ^
Language: C++

#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)
#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll oo=1e15;
int n,cap,w[100005],v[100005];
int main()
{
    scanf("%d %d",&n,&cap);
    f(i,0,n)
        scanf("%d %d",&w[i],&v[i]);
    int knapsack[n+1][cap+1];
    f(i,0,n+1){
       for (j,0,cap+1){
           if (i==0 || j==0)
               knapsack[i][j] = 0;
           else if (w[i-1]<=j)
                 knapsack[i][j] = max(v[i-1] + knapsack[i-1][j-w[i-1]],  knapsack[i-1][j]);
           else
                 knapsack[i][j] = knapsack[i-1][j];
       }

   }
    cout<<knapsack[n][cap]<<'\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: 'j' was not declared in this scope
   15 |        for (j,0,cap+1){
      |             ^
a.cc:24:4: error: expected primary-expression before '}' token
   24 |    }
      |    ^
a.cc:22:9: error: expected ';' before '}' token
   22 |        }
      |         ^
      |         ;
   23 | 
   24 |    }
      |    ~     
a.cc:24:4: error: expected primary-expression before '}' token
   24 |    }
      |    ^
a.cc:22:9: error: expected ')' before '}' token
   22 |        }
      |         ^
      |         )
   23 | 
   24 |    }
      |    ~     
a.cc:15:12: note: to match this '('
   15 |        for (j,0,cap+1){
      |            ^
a.cc:24:4: error: expected primary-expression before '}' token
   24 |    }
      |    ^
Language: Java


import java.util.*;

public class Solution {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 0;
    public static int[] weight = new int[10001];
    public static int[] benifit = new int[10001];
    public static int[][] dp = new int[10001][10001];

    public static int solve(int idx, int rem) {
        if (idx == n) {
            return 0;
        } else {
            if (dp[idx][rem] == -1) {
                int c1 = solve(idx + 1, rem);
                int c2 = 0;
                if (weight[idx] <= rem) {
                    c2 = solve(idx + 1, rem - weight[idx]) + benifit[idx];
                }
                return dp[idx][rem] = Math.max(c2, c1);
            } else {
                return dp[idx][rem];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10001; i++) {
            for (int j = 0; j < 10001; j++) {
                dp[i][j] = -1;
            }
        }
        n = in.nextInt();
        k = in.nextInt();
        for (int i = 0; i < n; i++) {
            weight[i] = in.nextInt();
            benifit[i] = in.nextInt();
        }
        System.out.println(solve(0, k));
    }

}


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


import java.util.*;
import javafx.util.*;

public class Expert {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 0;
    public static int[] weight = new int[10001];
    public static int[] benifit = new int[10001];
    public static int[][] dp = new int[10001][10001];

    public static int solve(int idx, int rem) {
        if (idx == n) {
            return 0;
        } else {
            if (dp[idx][rem] == -1) {
                int c1 = solve(idx + 1, rem);
                int c2 = 0;
                if (weight[idx] <= rem) {
                    c2 = solve(idx + 1, rem - weight[idx]) + benifit[idx];
                }
                return dp[idx][rem] = Math.max(c2, c1);
            } else {
                return dp[idx][rem];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10001; i++) {
            for (int j = 0; j < 10001; j++) {
                dp[i][j] = -1;
            }
        }
        n = in.nextInt();
        k = in.nextInt();
        for (int i = 0; i < n; i++) {
            weight[i] = in.nextInt();
            benifit[i] = in.nextInt();
        }
        System.out.println(solve(0, k));
    }

}


Compiler output:
Main.java:5: error: class Expert is public, should be declared in a file named Expert.java
public class Expert {
       ^
Main.java:3: error: package javafx.util does not exist
import javafx.util.*;
^
2 errors
Language: C++

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

#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define rrep(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
/* Long Long Int */
#define int long long int

int n, wt;
int dp[150][N];
int w[150], v[150];

int calc(int curr, int currwt){
    if(currwt > wt) return -M;
    if(curr == n) return 0;
    

    int &ans  = dp[curr][currwt];

    if(ans) return ans;

    ans = v[curr]+ calc(curr+1, currwt+w[curr]);
    ans = max(ans, calc(curr+1, currwt+0));

    return ans;
}
 

void solve(){
   cin>>n>>wt;
   // memset(dp, -1, sizeof(dp));
   for (int i = 0; i < n; ++i)
   {
       cin>>w[i]>>v[i];
   }

   cout<<calc(0, 0);


}

signed main()
{
    FAST
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;

return 0;
}

Compiler output:
a.cc:58:13: error: 'N' was not declared in this scope
   58 | int dp[150][N];
      |             ^
a.cc: In function 'long long int calc(long long int, long long int)':
a.cc:66:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   66 |     int &ans  = dp[curr][currwt];
      |                 ^~
      |                 dup
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,W;
  cin>>N>>W;
  int v[N],w[N];
  unordered_map<int,int> mp;
  for(int i=0;i<N;i++){
    cin>>w[i]>>v[i];
    mp[w[i]]=v[i];
  }
  int T[N+1][W+1];
  for(int j=0;j<=N;j++){
    T[0][j]=0;
  }
  for(int i=1;i<=W;i++)
    T[i][0]=0;
  sort(w,w+n);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=W;j++){
    if(if(j<w[i-1])
       T[i][j]=T[i-1][j];
       else 
       T[i][j]=max(T[i-1][j],mp[w[i-1]]+T[i-1][j-w[i-1]]);
    }
  }
       cout<<T[N][W];
       return 0;
       }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: 'n' was not declared in this scope
   18 |   sort(w,w+n);
      |            ^
a.cc:21:8: error: expected primary-expression before 'if'
   21 |     if(if(j<w[i-1])
      |        ^~
a.cc:23:8: error: expected primary-expression before 'else'
   23 |        else
      |        ^~~~
a.cc:22:26: error: expected ')' before 'else'
   22 |        T[i][j]=T[i-1][j];
      |                          ^
      |                          )
   23 |        else
      |        ~~~~               
a.cc:21:7: note: to match this '('
   21 |     if(if(j<w[i-1])
      |       ^
Language: C++

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

template<typename T> 
bool chmin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T>
bool chmax(T& a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int inf = 1ll<<30;

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
typedef long long ll;
using namespace std;

int main()
{

	int N, W;
	cin >> N;
	cin >> W;
	vector<vector<ll>> A(N, vector<ll>(2));
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			cin >> A[i][j];
		}
	}

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

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

	/*for (int i = 0; i < N + 1; ++i)
	{
		for (int j = 0; j < W + 1; ++j)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << dp[N][W] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:50:34: error: expected '}' at end of input
   50 |         cout << dp[N][W] << endl;
      |                                  ^
a.cc:11:1: note: to match this '{'
   11 | {
      | ^
Language: Java

import java.util.*;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int W = sc.nextInt();

        int[] wt = new int[N];
        int[] val = new int[N];

        for (int i = 0; i < N; i++) {
            wt[i] = sc.nextInt();
            val[i] = sc.nextInt();
        }

        System.out.println(knapsack(W,N,wt,val));
    }

    static long knapsack(int W, int N, int[] wt, int[] val) {

        long[][] dp = new int[N+1][W+1];

        for (int i = 0; i <= N; i++) {
            for (int w = 0; w <= W; w++) {
                if (i == 0 || w == 0) 
                    dp[i][w] = 0;
                else if (wt[i-1] <= w) {
                    long a = val[i-1] + dp[i-1][w-wt[i-1]];
                    long b = dp[i-1][w];
                    dp[i][w] = Math.max(a,b);
                } else
                    dp[i][w] = dp[i-1][w];
            }
        }

        return dp[N][W];
    }
}







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

import java.util.*;

/**
 * @Author :花のQ
 * @create 2020/4/19 10:32
 **/
public class SecondClass {
    static Scanner scanner = new Scanner(System.in);
    static int[][] wAv;

    public static void main(String[] args) {
        int number = scanner.nextInt();
        int capacity = scanner.nextInt();
        wAv = new int[number][2];
        for (int i = 0; i < wAv.length; i++) {
            wAv[i][0] = scanner.nextInt();
            wAv[i][1] = scanner.nextInt();
        }
        System.out.println(Dp(number - 1, capacity));
    }

    public static int Dp(int n, int c) {
        if (n < 0)
            return 0;
        else if (wAv[n][0] > c)
            return Dp(n - 1, c);
        else
            return Math.max(Dp(n - 1, c - wAv[n][0]) + wAv[n][1], Dp(n - 1, c));
    }
}

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

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define LONGMAX 1e18
#define MOD 1000000007
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(int i=a;i<n;i++)

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

	int n;
	cin>>n;

	int w;
	cin>>w;

	// using dp on value 
	int n1[n];
	int w1[n];
	
	for( int i=0;i<n;i++)
		cin>>n1[i]>>w1[i];

	int dp[n+1][w+1];
	// int val;
	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(w1[i-1]<=j)
				dp[i][j]=max(val[i-1] + dp[i-1][j-w1[i-1]],dp[i-1][j]);
			else
				dp[i][w]=dp[i-1][w];

		}
	}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:40:46: error: 'val' was not declared in this scope
   40 |                                 dp[i][j]=max(val[i-1] + dp[i-1][j-w1[i-1]],dp[i-1][j]);
      |                                              ^~~
Language: C++

#include "pch.h"
#include <bits/stdc++.h>

using namespace std;

int main() {

	long long n,W;

	cin >> n >> W;

	vector<long long> w(n + 1),v(n+1);

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

	vector<vector<long long>> dp(n+2,vector<long long>(W+2));

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

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

Compiler output:
a.cc:1:10: fatal error: pch.h: No such file or directory
    1 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

N,W = map(int,input().split())
dp = [[0 for i in range(W+1)] for j in range (N+1)]

for i in range(N):
    w,v = map(int,input().split())
    for sw in range(W+1):
        if sw < w:
            dp[i+1][sw] = dp[i][sw]
        else:
            dp[i+1][sw] = max((dp[i][sw]),(dp[i][sw-w]+v))
print(dp[-1][-1])


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N,W = map(int,input().split())
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: conversion from 'int*' to 'long unsigned int' in a converted constant expression
   11 |   long long dp[n+1][w+1];
      |                     ~^~
a.cc:11:22: error: could not convert '(((int*)(& w)) + 4)' from 'int*' to 'long unsigned int'
   11 |   long long dp[n+1][w+1];
      |                     ~^~
      |                      |
      |                      int*
a.cc:11:22: error: size of array 'dp' has non-integral type 'int*'
a.cc:14:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |         for(j=0;j<=w;j++)
      |                 ~^~~
a.cc:19:55: error: expected ')' before ';' token
   19 |         dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i-1]];
      |                     ~                                 ^
      |                                                       )
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: conflicting declaration 'int w [n]'
    7 |   int v[n],w[n];
      |            ^
a.cc:5:9: note: previous declaration as 'int w'
    5 |   int n,w;
      |         ^
a.cc:10:11: error: invalid types 'int[int]' for array subscript
   10 |     cin>>w[i]>>v[i];
      |           ^
a.cc:18:11: error: invalid types 'int[int]' for array subscript
   18 |       if(w[i-1]<=j)
      |           ^
a.cc:19:49: error: invalid types 'int[int]' for array subscript
   19 |         dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i-1]];
      |                                                 ^
Language: C++

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

long long max(long long a,long long b)
{
return a>b?a:b;
}

int main()
{
  int n,W;
  cin>>n>>W;
  int w[n+1];
  long long v[n+1];
  int i,j;
  for(i=1;i<=n;i++)    
      cin>>w[i]>>v[i];
  long long dp[n+1][w+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=w;j++)
      dp[i][j]=0;
  for(i=1;i<=n;i++)
      for(j=1;j<=w;j++)
      {
        if (wv[i-1]<= W)
                 dp[i][j] = max(v[i-1]+ dp[i-1][j-w[i-1]],dp[i-1][j]);
           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:18:22: error: conversion from 'int*' to 'long unsigned int' in a converted constant expression
   18 |   long long dp[n+1][w+1];
      |                     ~^~
a.cc:18:22: error: could not convert '(((int*)(& w)) + 4)' from 'int*' to 'long unsigned int'
   18 |   long long dp[n+1][w+1];
      |                     ~^~
      |                      |
      |                      int*
a.cc:18:22: error: size of array 'dp' has non-integral type 'int*'
a.cc:20:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   20 |     for(j=0;j<=w;j++)
      |             ~^~~
a.cc:23:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |       for(j=1;j<=w;j++)
      |               ~^~~
a.cc:25:13: error: 'wv' was not declared in this scope; did you mean 'v'?
   25 |         if (wv[i-1]<= W)
      |             ^~
      |             v
a.cc:30:14: error: invalid types 'long long int [1][int [(n + 1)]]' for array subscript
   30 |   cout<<dp[n][w]<<"\n";
      |              ^
Language: C++

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

long long max(long long a,long long b)
{
return a>b?a:b;
}

int main()
{
  int n,w;
  cin>>n>>w;
  int w[n+1];
  long long v[n+1];
  int i,j;
  for(i=1;i<=n;i++)    
      cin>>w[i]>>v[i];
  long long dp[n+1][w+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=w;j++)
      dp[i][j]=0;
  for(i=1;i<=n;i++)
      for(j=1;j<=w;j++)
      {
        if (wv[i-1]<= w)
                 dp[i][j] = max(v[i-1]+ dp[i-1][j-w[i-1]],dp[i-1][j]);
           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:13:7: error: conflicting declaration 'int w [(n + 1)]'
   13 |   int w[n+1];
      |       ^
a.cc:11:9: note: previous declaration as 'int w'
   11 |   int n,w;
      |         ^
a.cc:17:13: error: invalid types 'int[int]' for array subscript
   17 |       cin>>w[i]>>v[i];
      |             ^
a.cc:25:13: error: 'wv' was not declared in this scope; did you mean 'v'?
   25 |         if (wv[i-1]<= w)
      |             ^~
      |             v
a.cc:26:52: error: invalid types 'int[int]' for array subscript
   26 |                  dp[i][j] = max(v[i-1]+ dp[i-1][j-w[i-1]],dp[i-1][j]);
      |                                                    ^
Language: C++

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



int main()
{
  int n,w;
  cin>>n>>w;
  long long wv[n][2];
  int i,j;
  for(i=0;i<n;i++)
    for(j=0;j<2;j++)
      cin>>wv[i][j];
  int dp[n+1][w+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=w;j++)
      dp[i][j]=0; 
  for(i=1;i<=n;i++)
      for(j=1;j<=w;j++)
      {
        if (wv[i-1][j] <= w) 
                 dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]); 
           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:23:32: error: no matching function for call to 'max(long long int, int&)'
   23 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:23:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:23:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main()
{
  int n,w;
  cin>>n>>w;
  long long wv[n][2];
  int i,j;
  for(i=0;i<n;i++)
    for(j=0;j<2;j++)
      cin>>wv[i][j];
  int dp[n+1][w+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=w;j++)
      dp[i][j]=0; 
  for(i=1;i<=n;i++)
      for(j=1;j<=w;j++)
      {
        if (wv[i-1][j] <= w) 
                 dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]); 
           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:21:32: error: no matching function for call to 'max(long long int, int&)'
   21 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:21:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:21:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll sol[101][100001]={0};
int main()
{
  ll n,c;
  cin>>n>>c;
  ll w[n],p[n];
  ll i;
  for(i=0;i<n;i++)
  {
    cin>>w[i];
    cin>>p[i];
  }
  for(i=0;i<100001;i++)
  {
    if(i>=w[0])
      sol[0][i]=p[0];
    else
      sol[0][i]=0;
  }
  ll j;
  for(i=1;i<n;i++)
  {
    for(j=0;j<100001;j++)
    {
      if(j<w[i])
        sol[i][j]=sol[i-1][j];
      else if(j>=w[i]))
        sol[i][j]=max(sol[i-1][j],sol[i-1][j-w[i]]+p[i]);
    }
  }
  cout<<sol[n-1][c]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:23: error: expected primary-expression before ')' token
   30 |       else if(j>=w[i]))
      |                       ^
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 W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

        long[][] dp = new long[N+1][W+1];
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

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

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

    }

}


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;

int main()
{
  int n,w;
  cin>>n>>w;
  long long wv[n][2];
  int i,j;
  for(i=0;i<n;i++)
    for(j=0;j<2;j++)
      cin>>wv[i][j];
  int dp[n+1][w+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=w;j++)
      dp[i][j]=0; 
  for(i=1;i<n;i++)
      for(j=1;j<w;j++)
      {
        if (wv[i-1][0] <= w) 
                 dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]); 
           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:21:32: error: no matching function for call to 'max(long long int, int&)'
   21 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:21:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:21:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |                  dp[i][j] = max(wv[i-1][1] + dp[i-1][j-wv[i-1][0]],  dp[i-1][j]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    goods = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for w in range(W+1):
            if w >= goods[i][0]:
                dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    main()

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

 	#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include <inttypes.h>
#include<iostream>
using ll = long long;
using namespace std;

int main()
{
   int w,n;
   scanf("%d %d", &n, &w);

   int a[n];
   int dp[n+1];
   int v,weight;
   for(int item = 0; item<n;item++){
        scanf("%d %d", &weight,&v);
		
        for(int i= w-weight;i>=0;i--){
            dp[i+weight] = max(dp[i+weight], dp[i] + value);
        }
   }
   int res = 0;
   for(int i= 0;i<n+1;i++){
       res = max(res, dp[i]);         
   }
  	
	cout<< res;
   return 0;
}


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

 	#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include <inttypes.h>
#include<iostream>
using ll = long long;
using namespace std;

int main()
{
   int w,n;
   scanf("%d %d", &n, &w);

   int a[n];
   int dp[n+1];
   int v,weight;
   for(int item = 0; item< n;i++){
        scanf("%d %d", &weight,&v);
		
        for(int i= w-weight;i>=0;i--){
            dp[i+weight] = max(dp[i+weight], dp[i] + value);
        }
   }
   int res = 0;
   for(int i= 0;i<n+1;i++){
       res = max(res, dp[i]);         
   }
  	
	cout<< res;
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:30: error: 'i' was not declared in this scope
   18 |    for(int item = 0; item< n;i++){
      |                              ^
a.cc:22:54: error: 'value' was not declared in this scope
   22 |             dp[i+weight] = max(dp[i+weight], dp[i] + value);
      |                                                      ^~~~~
Language: Java

import java.util.Scanner;

public class taro {
	public static void main(String args[]) {
		Scanner kb = new Scanner(System.in);
		
		int n = kb.nextInt(), maxw = kb.nextInt();
		
		int[] w = new int[n];
		int[] v = new int[n];
		
		for(int i = 0 ; i < n; i++) {
			w[i] = kb.nextInt();
			v[i] = kb.nextInt();
		}
		System.out.println(dp(maxw, w, v));
	}
	static int dp(int maxw, int[] w, int[] v) {
		int[][] cache = new int[2][maxw+1];
		int pre = 0, cur = 1;
		
		for(int i = 1; i <= w.length; i++) {
			for(int x = 0; x <= maxw; x++) {
				if(w[i-1] > x) {
					cache[cur][x] = cache[pre][x];
				}else {
					cache[cur][x] = Math.max(cache[pre][x], cache[pre][x-w[i-1]]+v[i-1]);
				}
			}
			int temp = cur;
			cur = pre;
			pre = temp;
		}
		return cache[pre][maxw];
	}
}


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

import java.util.Scanner;

public class taro {
	public static void main(String args[]) {
		Scanner kb = new Scanner(System.in);
		
		int n = kb.nextInt(), maxw = kb.nextInt();
		
		int[] w = new int[n];
		int[] v = new int[n];
		
		for(int i = 0 ; i < n; i++) {
			w[i] = kb.nextInt();
			v[i] = kb.nextInt();
		}
		System.out.println(dp(maxw, w, v));
	}
	static int dp(int maxw, int[] w, int[] v) {
		int[][] cache = new int[2][maxw+1];
		int pre = 0, cur = 1;
		
		for(int i = 1; i <= w.length; i++) {
			for(int x = 0; x <= maxw; x++) {
				if(w[i-1] > cache[pre][x]) {
					cache[cur][x] = cache[pre][x];
				}else {
					cache[cur][x] = Math.max(cache[pre][x], cache[pre][x-w[i]]+v[i-1]);
				}
			}
			int temp = cur;
			cur = pre;
			pre = temp;
		}
		return cache[w.length][maxw];
	}
}


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

#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}


ll dp[100010][100010],value[100010],w[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin>>n>>m;
    
    rep(i,n) cin>>w[i]>>value[i];
    rep(i,m) dp[0][i]=0;
    
    rep(i,n){
        for(ll j=0;j<=m;j++){
            if(j>=w[i]) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+value[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}


Compiler output:
/tmp/ccksiOpP.o: in function `main':
a.cc:(.text+0x2a2): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccksiOpP.o
a.cc:(.text+0x2cd): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccksiOpP.o
a.cc:(.text+0x34b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccksiOpP.o
a.cc:(.text+0x36c): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccksiOpP.o
a.cc:(.text+0x3ab): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccksiOpP.o
collect2: error: ld returned 1 exit status
Language: C++

#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

const ll MAX = 1000000;
const ll MOD = 1000000007;



ll dp[100010][100010],value[100010],w[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin>>n>>m;
    
    rep(i,n) cin>>w[i]>>value[i];
    rep(i,m) dp[0][i]=0;
    
    rep(i,n){
        for(ll j=0;j<=m;j++){
            if(j>=w[i]) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+value[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}


Compiler output:
/tmp/ccytAQ2Y.o: in function `main':
a.cc:(.text+0x2a2): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytAQ2Y.o
a.cc:(.text+0x2cd): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccytAQ2Y.o
a.cc:(.text+0x34b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytAQ2Y.o
a.cc:(.text+0x36c): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytAQ2Y.o
a.cc:(.text+0x3ab): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccytAQ2Y.o
collect2: error: ld returned 1 exit status
Language: C++

#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dp[100010][100010],v[100010],w[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin>>n>>m;
    
    rep(i,n) cin>>w[i]>>v[i];
    rep(i,m) dp[0][i]=0;
    
    rep(i,n){
        for(ll j=0;j<=m;j++){
            if(j>=w[i]) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}


Compiler output:
/tmp/ccEzhyCa.o: in function `main':
a.cc:(.text+0x55f): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccEzhyCa.o
a.cc:(.text+0x58a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccEzhyCa.o
a.cc:(.text+0x608): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccEzhyCa.o
a.cc:(.text+0x629): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccEzhyCa.o
a.cc:(.text+0x668): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccEzhyCa.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")

int knapsack(vector<int>& wt, vector<int>& val, int n, int Weight){
    vector<vector<long long>> dp(n+1,vector<long long>(Weight+1));
    for(int v=0; v<=n; v++){
        for(int w=0; w<=Weight; w++){
            if(v==0 || w==0)
                dp[v][w] = 0;
            else if (wt[i-1]<=w)
                dp[v][w] = max(val[v-1] + dp[v-1][w-wt[v-1]], dp[v-1][w]);
            else
                dp[v][w] = dp[v-1][w];
        }
    }
    return dp[n][Weight];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin>>n>>w;
    vector<int> wt(n), val(n);
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    cout<<knapsack(wt, val, n, w)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)':
a.cc:11:25: error: 'i' was not declared in this scope
   11 |             else if (wt[i-1]<=w)
      |                         ^