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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[110][100100] = {1145141919810};
int main()
{
    ll n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
    }

    dp[0][0] = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < 100100;j++){
            if(j - value[i] >= 0)
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
            dp[i + 1][j] = dp[i][j];
        }
    }
    ll res = 0;
    for(ll j = 0; j < 100100){
        if(dp[n][j] <= w)
        res = j;
    }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:29: error: expected ';' before ')' token
   24 |     for(ll j = 0; j < 100100){
      |                             ^
      |                             ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1, inf = 2e9 + 7, mod = 1e9 + 7;
const ll INF = 2e18 + 7, MOD = 1e15 + 7;
 
int w[101], v[101], dp[N];
 
int main() {
    int n, W;
    cin>>n>>W;
    for(int i = 1; i <= n; i++) {
        cin>>w[i]>>v[i];
    }
    for(int i = 0; i <= 1e5; i++) dp[i] = inf;
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1e5; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    int ans = -1;
    for(int i = 1; i <= 1e5; i++) {
        if(dp[i] <= W) ans = i;
    }
    cout<<ans;
    return 0;
}


Compiler output:
a.cc:4:7: error: 'll' does not name a type
    4 | const ll INF = 2e18 + 7, MOD = 1e15 + 7;
      |       ^~
Language: C++

#include <sstream>
#include <fstream>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <cstdio>
 
 
#include <stdlib.h>
#include <iostream>
#include <chrono> //clock
#include <vector>
#include <string>
#include <iomanip>  //setprecision function
#include <cmath>	//math
#include <cstdio>
#include <vector>	//vector array
#include <algorithm>	//STL algorithm
#include <set> //STL library set
#include <sstream> // for stringstream
 
 
using namespace std;
using namespace std::chrono; 
 
 
 
int main() {
	stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
 
 
	int n,k;
	cin>>n>>k;
	int vec[n][2];
	for(int i=0;i<n;i++){
		cin>>vec[i][0];
		cin>>vec[i][1];
	}
	
	vector<vector<long long>> dp(n+1,vector<long long>(k+1,0));
 
	
	//int dp[n][k];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(j-vec[i-1][0]>-1){
				dp[i][j]=max(vec[i-1][1]+dp[i-1][j-vec[i-1][0]],dp[i][j-1]);
				dp[i][j]=max(dp[i][j],dp[i-1][j]);
			}else dp[i][j]=dp[i-1][j];
		}
	}
	
	cpout<<dp[n][k]<<endl;
	
	return 0;
}
 
 
 
 
 
 
 
 
 

Compiler output:
a.cc: In function 'int main()':
a.cc:78:9: error: 'cpout' was not declared in this scope
   78 |         cpout<<dp[n][k]<<endl;
      |         ^~~~~
Language: C++

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

const long long INF = 1LL << 60;
long long item_weight[110], item_value[110];
long long dp[110][100010];

int main() {
  int N, W; cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> item_weight[i] >> item_value[i];
  }
  for (int i = 0; i < 110; i++) for (int j = 0; j < 100010; j++) dp[i][j] = INF;

  dp[0][0] = 0;

  for (int i = 0; i <= N; i++) {
    for (int v = 0; v <= 100010; w++) {
      if (0 <= w - item_value[i+1]) {
        dp[i+1][v] = min(dp[i+1][v], dp[i][v - item_value[i+1]] + item_weight[i+1]);
      }
      dp[i+1][v] = max(dp[i+1][v], dp[i][v]);
    }
  }

  long long res = 0;
  for (long long v = 0; v < 100010; v++) {
    if (dp[N][v] <= W) res = v;
  }
  cout << res << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:34: error: 'w' was not declared in this scope
   18 |     for (int v = 0; v <= 100010; w++) {
      |                                  ^
Language: C++

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

int n,bag;
const int N = 1000000001;

ll dp[2][N];
int W[105], C[105];
int main() {
	cin >> n >> bag;
	for (int i = 1; i <= n; i++)cin >> W[i] >> C[i];

	int idx;
	for (int i = 1; i <= n; i++) {
		idx = i & 1;//1 0

		for (int j = 1; j <= bag; j++) {
										//i-1
			if (j < W[i])dp[idx][j] = dp[!idx][j];//leave
											//i-1				//i-1
			else dp[idx][j] = max(C[i] + dp[!idx][j - W[i]], dp[!idx][j]);//take
		}
	}
	ll ans = 0;
	for (int i = 0; i <= bag; i++)ans = max(ans, dp[n&1][i]);
	cout << ans;
}

Compiler output:
/tmp/ccZMqSNX.o: in function `main':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZMqSNX.o
a.cc:(.text+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccZMqSNX.o
a.cc:(.text+0xcd): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZMqSNX.o
a.cc:(.text+0x174): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccZMqSNX.o
a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZMqSNX.o
collect2: error: ld returned 1 exit status
Language: C++

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

int n,bag;
const int N = 1000000005;

ll dp[2][N];
int W[105], C[105];
int main() {
	cin >> n>>bag;
	for (int i = 1; i <= n; i++)cin >> W[i] >> C[i];
	int cur;
	for (int i = 1; i <= n; i++) {
		cur = (i&1);
		for (int j = 0; j <= bag; j++) {
			if (j < W[i])dp[cur][j] = dp[!cur][j];
			else dp[cur][j] = max(C[i] + dp[!cur][j - W[i]], dp[!cur][j]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= bag; i++)ans = max(ans, dp[1][i]);
	cout << ans;
	
}

Compiler output:
/tmp/ccvduUOX.o: in function `main':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccvduUOX.o
a.cc:(.text+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccvduUOX.o
a.cc:(.text+0xcd): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccvduUOX.o
a.cc:(.text+0x174): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccvduUOX.o
a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccvduUOX.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll store[110][1000000000+1];
ll n,Wei;
ll v[1001],w[1000000000+1];
ll dp(ll i,ll cap)
{
    if(i==n+1) return 0;
    if(store[i][cap]!=-1) return store[i][cap];
    ll profit1=0,profit2=0;
    if(cap+w[i]<=Wei)
    {
        profit1=v[i]+dp(i+1,cap+w[i]);
    }
    else
    {
        profit1=0;
    }
    profit2=dp(i+1,cap);
    return store[i][cap]=max(profit1,profit2);
}
int main()
{
    //freopen("take.in","r",stdin);
    cin>>n>>Wei;
    for(ll i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    memset(store,-1,sizeof store);
    ll ans=dp(1,0);
    cout<<ans<<endl;
}

Compiler output:
/tmp/cczNPXzT.o: in function `dp(long long, long long)':
a.cc:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `Wei' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0xca): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0xe1): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cczNPXzT.o
/tmp/cczNPXzT.o: in function `main':
a.cc:(.text+0x1a0): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0x1bc): relocation truncated to fit: R_X86_64_PC32 against symbol `Wei' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0x20f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cczNPXzT.o
a.cc:(.text+0x229): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cczNPXzT.o
collect2: error: ld returned 1 exit status
Language: Java



class Main{

    /**
     * https://atcoder.jp/contests/dp/tasks/dp_e
     * 
     * In this question, W <= 10>9 which is aa huge number to have as dp dimension
     * instead of maximizing value subject to max weight we minimize weight
     * subject to value.
     */
    private static int sum(int[] v){
        int sum = 0;
        for(int i = 0; i < v.length; i++){
            sum += v[i];
        }
        return sum;
    }

    // space optimized version, value is the dimension  
    private static int solverOneDimension(int[] w, int[] v, int n, int max){
        
        itn sumValues = sum(v);
        long[] dp = new long[sumValues + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);

        // iterate on items
        for(int i = 1; i <= n ;i++){

            int value = v[i - 1];
            int weight = w[i - 1];

            for(int value_already = sumValues - value; value_already >= 0; --value_already) {
                    dp[value_already + value] = Math.min(dp[value_already + value], dp[value_already] + weight);
            }
        }

        long answer = 0;
        
        for(int i = 0; i <= sumValues; i++) {
            if(dp[i] <= max) {
                answer = Math.max(answer, (long) i);
            }
        }
        return answer;
    }



    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // number of items
        int max = in.nextInt(); // max weight
        int[] w = new int[n];
        int[] v = new int[n];
        
        for(int i = 0; i < n; i++){
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(solverOneDimension(w, v, n, max));
        
    }
}

Compiler output:
Main.java:23: error: cannot find symbol
        itn sumValues = sum(v);
        ^
  symbol:   class itn
  location: class Main
Main.java:25: error: cannot find symbol
        Arrays.fill(dp, Integer.MAX_VALUE);
        ^
  symbol:   variable Arrays
  location: class Main
Main.java:45: error: incompatible types: possible lossy conversion from long to int
        return answer;
               ^
Main.java:51: error: cannot find symbol
        Scanner in = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:51: error: cannot find symbol
        Scanner in = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
5 errors
Language: Java

import java.util.*;

class Main{


    private static int solver(int[] w, int[] v, int n, int max){
        
        int[][] dp = new int[n + 1][max + 1];
        for(long[] row: dp) Arrays.fill(row, 0);


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

                if(w[i-1] <= j) { 
                    int emptyCapacity = j - w[i-1]; 
                    dp[i][j] = Math.max(dp[i-1][j], v[i-1] + dp[i-1][emptyCapacity]);
                     
                } else { 
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        return dp[n][max];
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // number of items
        int max = in.nextInt(); // max weight
        int[] w = new int[n];
        int[] v = new int[n];
        
        for(int i = 0; i < n; i++){
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(solver(w, v, n, max));
    }
}


Compiler output:
Main.java:9: error: incompatible types: int[] cannot be converted to long[]
        for(long[] row: dp) Arrays.fill(row, 0);
                        ^
1 error
Language: Java

import java.util.*;

class Main{


    private static long solver(long[] w, long[] v, int n, int max){
        
        long[][] dp = new long[n + 1][max + 1];
        for(long[] row: dp) Arrays.fill(row, 0);


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

                if(w[i-1] <= j) { 
                    int emptyCapacity = j - w[i-1]; 
                    dp[i][j] = Math.max(dp[i-1][j], v[i-1] + dp[i-1][emptyCapacity]);
                     
                } else { 
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        return dp[n][max];
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // number of items
        int max = in.nextInt(); // max weight
        int[] w = new int[n];
        int[] v = new int[n];
        
        for(int i = 0; i < n; i++){
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(solver(w, v, n, max));
    }
}

Compiler output:
Main.java:16: error: incompatible types: possible lossy conversion from long to int
                    int emptyCapacity = j - w[i-1]; 
                                          ^
Main.java:40: error: incompatible types: int[] cannot be converted to long[]
        System.out.println(solver(w, v, n, max));
                                  ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

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

int n,W;
long long int dp[101][1000000001];
long long int w[100],v[100];


int main(){
	cin>>n>>W;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		for(int j=W;j>=0;j--){
			if(j>=w[i-1]){
				dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1], dp[i-1][j]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][W]<<endl;
}

Compiler output:
/tmp/ccCXZua2.o: in function `main':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccCXZua2.o
a.cc:(.text+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccCXZua2.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccCXZua2.o
a.cc:(.text+0x14b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccCXZua2.o
a.cc:(.text+0x189): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccCXZua2.o
collect2: error: ld returned 1 exit status
Language: C++

# Python3 implementation of the approach 
V_SUM_MAX = 1000
N_MAX = 100
W_MAX = 10000000000
  
# To store the states of DP 
dp = [[ 0 for i in range(N_MAX)] 
          for i in range(V_SUM_MAX + 1)] 
v = [[ 0 for i in range(N_MAX)] 
         for i in range(V_SUM_MAX + 1)] 
  
# Function to solve the recurrence relation 
def solveDp(r, i, w, val, n): 
      
    # Base cases 
    if (r <= 0): 
        return 0
    if (i == n): 
        return W_MAX 
    if (v[r][i]): 
        return dp[r][i] 
  
    # Marking state as solved 
    v[r][i] = 1
  
    # Recurrence relation 
    dp[r][i] = min(solveDp(r, i + 1, w, val, n),  
            w[i] + solveDp(r - val[i], i + 1, 
                            w, val, n)) 
    return dp[r][i] 
  
# Function to return the maximum weight 
def maxWeight( w, val, n, c): 
  
    # Iterating through all possible values 
    # to find the the largest value that can 
    # be represented by the given weights 
    for i in range(V_SUM_MAX, -1, -1): 
        if (solveDp(i, 0, w, val, n) <= c): 
            return i 
  
    return 0
  
n,C = map(int, input().split())
w = [] 
val = [] 
for i in range(n):
    wei,vv = map(int, input().split())
    w.append(wei)
    val.append(vv)    

print(maxWeight(w, val, n, C)) 



Compiler output:
a.cc:1:3: error: invalid preprocessing directive #Python3
    1 | # Python3 implementation of the approach
      |   ^~~~~~~
a.cc:6:3: error: invalid preprocessing directive #To
    6 | # To store the states of DP
      |   ^~
a.cc:12:3: error: invalid preprocessing directive #Function
   12 | # Function to solve the recurrence relation
      |   ^~~~~~~~
a.cc:15:7: error: invalid preprocessing directive #Base
   15 |     # Base cases
      |       ^~~~
a.cc:23:7: error: invalid preprocessing directive #Marking; did you mean #warning?
   23 |     # Marking state as solved
      |       ^~~~~~~
      |       warning
a.cc:26:7: error: invalid preprocessing directive #Recurrence
   26 |     # Recurrence relation
      |       ^~~~~~~~~~
a.cc:32:3: error: invalid preprocessing directive #Function
   32 | # Function to return the maximum weight
      |   ^~~~~~~~
a.cc:35:7: error: invalid preprocessing directive #Iterating
   35 |     # Iterating through all possible values
      |       ^~~~~~~~~
a.cc:36:7: error: invalid preprocessing directive #to
   36 |     # to find the the largest value that can
      |       ^~
a.cc:37:7: error: invalid preprocessing directive #be
   37 |     # be represented by the given weights
      |       ^~
a.cc:2:1: error: 'V_SUM_MAX' does not name a type
    2 | V_SUM_MAX = 1000
      | ^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long knapsack(long long n,long long *w,long long *v,long long W){
    long long dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(long long i=1;i<=n;i++){
        for(long long j=1;j<=W;j++){
            if(j-w[i-1]>=0){
                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];
            }
        }
    }
    // for(long long i=0;i<=n;i++){
    //     for(long long j=0;j<=W;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    return dp[n][W];
}
int main(){
    long long n,W;
    cin>>n>>W;
    long long w[n];
    long long v[n];
    for(long long i=0;i<n;i++){
      cin>>w[i];
      cin>>v[i];
    }
    // for(long long i=0;i<n;i++){
    //     cout<<w[i]<<" ";
    // }
    cout<<knapsack(n,w,v,W);


    return 0;
}


Compiler output:
a.cc: In function 'long long int knapsack(long long int, long long int*, long long int*, long long int)':
a.cc:4:24: error: conversion from 'long long int*' to 'long unsigned int' in a converted constant expression
    4 |     long long dp[n+1][w+1];
      |                       ~^~
a.cc:4:24: error: could not convert '(w + 8)' from 'long long int*' to 'long unsigned int'
    4 |     long long dp[n+1][w+1];
      |                       ~^~
      |                        |
      |                        long long int*
a.cc:4:24: error: size of array 'dp' has non-integral type 'long long int*'
Language: C++

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


    return 0;
}

Compiler output:
a.cc: In function 'long long int knapsack(long long int, long long int*, long long int*, long long int)':
a.cc:4:24: error: conversion from 'long long int*' to 'long unsigned int' in a converted constant expression
    4 |     long long dp[n+1][w+1];
      |                       ~^~
a.cc:4:24: error: could not convert '(w + 8)' from 'long long int*' to 'long unsigned int'
    4 |     long long dp[n+1][w+1];
      |                       ~^~
      |                        |
      |                        long long int*
a.cc:4:24: error: size of array 'dp' has non-integral type 'long long int*'
Language: C++

/*
				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "
*/


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define f for
#define ll long long
#define ull unsigned long long
#define endl "\n"
using namespace std;
#define BI  acos(-1)
#define all(a) a.begin(), a.end()
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
void madesetprobblem()
{
	//$ $
	//less than or equal => $ 1 \leq 100 $
	//  $(1 \le A,B \le 10^5 )$
	// a[i] => $a_i$
	// a[i][j] => $a_{i,j}$
	// double qoutes ''yext''
	/*
		image
		\begine{center}
		\includegraphics{image.jpg}
		\end{center}
	*/
	/*
		list
		\begin{itemize}
			\item first one
			\item second one
		\end{itemize}
	*/
}

int n, k;
ll a[105][2];
map<pair<int, ll>, ll>mp;
ll ans(int c = 0, ll w = 0)
{
	if (c == n)
		return 0;
	if (map.find({ c,w }) != map.end())return map[{c, w}];
	ll p1 = LLONG_MIN, p2 = LLONG_MIN;
	if (w + a[c][0] <= k)
	{
		p1 = a[c][1] + ans(c + 1, w + a[c][0]);
		p2 = ans(c + 1, w);
	}
	else
		p2 = ans(c + 1, w);
	return mp[{c, w}] = max(p1, p2);

}
int main()
{
	// توكلت علي الله 
//Open();
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> k;
	f(int i = 0; i < n; i++)
	{
		cin >> a[i][0] >> a[i][1];
	}
	cout << ans();
}

Compiler output:
a.cc: In function 'long long int ans(int, long long int)':
a.cc:56:16: error: expected unqualified-id before '.' token
   56 |         if (map.find({ c,w }) != map.end())return map[{c, w}];
      |                ^
a.cc:56:54: error: missing template arguments before '[' token
   56 |         if (map.find({ c,w }) != map.end())return map[{c, w}];
      |                                                      ^
Language: C

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

const long long INF = 1LL << 62;

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

    long long dp[100001];  // dp[j] = 価値がちょうど j となるように選んだときの重さの最小値(配列再利用をするので i 番目という情報は入っていない)
    for (int j = 0; j < 100001; ++j) dp[j] = INF;
    dp[0] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < 100001; ++j) {
            if (j - v[i - 1] >= 0) dp[j] = min(dp[j], dp[j - v[i - 1]] + w[i - 1]);  // i 番目の商品を入れるか入れないか
        }
    }

    long long ans;
    for (int j = 0; j < 100001; ++j) {
        if (dp[j] <= W) ans = j;
    }

    cout << ans << endl;
}


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: 'W' was not declared in this scope
   14 |   long long dp[W+1];
      |                ^
a.cc:15:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |   memset(dp, 0, sizeof(dp));
      |          ^~
      |          dup
Language: Java

import java.util.*;

public class Knapsack2 {
    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];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            sum += v[i];
        }

        long[] dp = new long[sum + 1];
        long INF = (long)1e18;
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for (int i = 0; i < N; i++) {
            for (int j = sum; j >= v[i]; j--) {
                dp[j] = Math.min(dp[j], dp[j - v[i]] + w[i]);
            }
        }
        long res = 0;
        for (int j = 0; j <= sum; j++) {
            if (dp[j] <= W) {
                res = Math.max(res, j);
            }
        }
        System.out.println(res);
    }
}

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

#include <iostream>
#include <vector>

using namespace std;

typedef long long LL;
const int N = 101;
const int V = 100001;

LL dp[N][V], w[N], v[N];

int main() {
    // freopen("a.txt", "r", stdin);
    int n, wl;
    cin >> n >> wl;
    for(int i = 1; i <= n; ++i) cin >> w[i] >> v[i];

    memset(dp, 0x7f, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= V; ++j) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if(j >= v[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
        }
    }
    int res = 0;
    for(int i = V - 1; i >= 0; --i) {
        if(dp[n][i] <= wl) {
            res = i; break;
        }
    }
    cout << res << endl;
    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 101;
const int maxv = 1e3 + 1;

ll dp[maxn][maxv];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    ll n, w, v, ans = 0;
    memset(dp, -1, sizeof(dp));
    scanf("%lld%lld", &n, &dp[0][0]);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld%lld", &w, &v);
        for (int j = 0; j != maxv; ++j)
            if (j < v)
                dp[i][j] = dp[i - 1][j];
            else {
                dp[i][j] = max({ dp[i - 1][j], dp[i - 1][j - v] - w, -1 });
                if (dp[i][j] != -1 && j > ans)
                    ans = j;
            }
    }
    for (int i = maxv - 1; i != -1; --i)
        if (dp[n][i] != -1)
            printf("%d\n", i), exit(0);
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

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

        int[][] dp = new int[N][W + 1];
        dp[0][0] = 0;
//        System.out.print(dp[0][0] + "  ,");
        for (int i = 1; i < N; i++) dp[i][0] = 0;
        for (int j = 1; j < W + 1; j++) {
            dp[0][j] = w[0] <= j ? v[0] : 0;
//            System.out.print(dp[0][j] + "  ,");
        }
//        System.out.println();

        for (int i = 1; i < N; i++) {
            for (int j = 1; j < W + 1; j++) {
                int c1 = 0;
                if (w[i] <= j) {
                    c1 = dp[i - 1][W - w[i]] + v[i];
                }
                int c2 = dp[i - 1][W];
                dp[i][j] = Math.max(c1, c2);
//                System.out.print(dp[i][j] + "  ,");
            }
//            System.out.println();
        }
        System.out.println(dp[N - 1][W]);
//        return dp[N - 1][W];
    }
}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{  int n;
 long int m;
    int n,m;
    cin>>n>>m;
    long int w[n+1],v[n+1],i,j;
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    long int t[n+1][m+1];
    for(i=0;i<=m;i++)
    {
        t[0][i]=0;
    }
    for(i=1;i<=n;i++)
    {
        t[i][0]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(w[i]<=j)
            {
                t[i][j]=max(t[i-1][j],v[i]+t[i-1][j-w[i]]);
            }
            else{
                t[i][j]=t[i-1][j];
            }
        }
    }
    cout<<t[n][m]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: redeclaration of 'int n'
    8 |     int n,m;
      |         ^
a.cc:6:8: note: 'int n' previously declared here
    6 | {  int n;
      |        ^
a.cc:8:11: error: conflicting declaration 'int m'
    8 |     int n,m;
      |           ^
a.cc:7:11: note: previous declaration as 'long int m'
    7 |  long int m;
      |           ^
Language: C++

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

const int MAXW = 1e9 + 10;

long long knapsack[MAXW];
int N,W;

int main(){

	cin >> N >> W;

	for(int item = 1;item<=N;item++){
		int w,v;
		cin >> w >> v;
		for(int i = W;i>=w;i--) knapsack[i] = max(knapsack[i-w] + v,knapsack[i]);
	}

	long long best = 0;
	for(int i = 0;i<=W;i++) best = max(best,knapsack[i]);
	cout << best << endl;

	return 0;

}

Compiler output:
/tmp/ccpiOi15.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccpiOi15.o
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccpiOi15.o
a.cc:(.text+0x6c): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccpiOi15.o
a.cc:(.text+0xf3): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccpiOi15.o
a.cc:(.text+0x144): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccpiOi15.o
collect2: error: ld returned 1 exit status
Language: C++

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

#define ll long long

ll n, k, cache[2][int(2e9)];
vector < pair <ll, ll> > a;

ll dp(ll i, ll c)
{
	if (i >= n)	return 0;
	if (cache[i%2][c] != -1)	return cache[i%2][c];

	ll ret = -2e9;
	if (c + a[i].first > k){
		ret = max(ret, dp(i + 1, c));
	}
	else{
		ret = max({ret, dp(i + 1, c), a[i].second + dp(i + 1, c + a[i].first)});
	}
	return cache[i%2][c] = ret;
}
int main()
{	
	memset(cache, -1, sizeof cache);
	cin >> n >> k;	a.resize(n);
	for (ll i = 0; i < n; i ++){
		ll x, y;	cin >> x >> y;
		a[i] = {x, y};
	}
	cout << dp(0, 0) << "\n";
}

Compiler output:
/tmp/ccUhu3rN.o: in function `dp(long long, long long)':
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
a.cc:(.text+0x14f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
a.cc:(.text+0x169): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
/tmp/ccUhu3rN.o: in function `main':
a.cc:(.text+0x288): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
a.cc:(.text+0x2e7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
/tmp/ccUhu3rN.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x35b): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
a.cc:(.text+0x374): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccUhu3rN.o
collect2: error: ld returned 1 exit status
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: conflicting declaration 'long long int w [(n + 1)]'
    8 |   ll int  w[n+1],v[n+1],sum=0;
      |           ^
a.cc:6:12: note: previous declaration as 'long long int w'
    6 |   ll int n,w;
      |            ^
a.cc:11:11: error: invalid types 'long long int[int]' for array subscript
   11 |     cin>>w[i]>>v[i];
      |           ^
a.cc:19:35: error: invalid types 'long long int[int]' for array subscript
   19 |        dp[j+v[i]]=max(dp[j+v[i]],w[i]+dp[j]);
      |                                   ^
Language: C++

#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;
ll MOD = 1000000007;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<typename T> void view2d(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

int main(void) {

	ll N, W;
	cin >> N >> W;

	vector<pair<ll, ll>> item(N);
	ll V = 0;
	for (auto& x : item) {
		cin >> x.first >> x.second;
		V += x.second;
	}

	vector<vector<ll>> dp(N + 1, vector<ll>(V + 1, 1e13));
	for (auto& x : dp) {
		x[0] = 0;
	}

	REP(i, N) {
		ll w = item[i].first;
		ll v = item[i].second;
		FOR(j, 1, V + 1) {
			if (j - v >= 0) {
				chmin(dp[i + 1][j], dp[i][j - v] + w);
				//DEBUG(dp[i + 1][j]);
			}
			chmin(dp[i + 1][j], dp[i][j]);
		}
	}

	for (ll x = V; x >= 0; x--) {
		if (dp[N][x] <= W) {
			cout << x << endl;
			break;
		}
	}

	return 0;
}

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

import java.util.Scanner;

import static java.lang.Math.max;


public class MainApp{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] weight = new int[n + 1];
        int[] value = new int[n + 1];
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            weight[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
            sum = sum > value[i]?sum:value[i];
        }
        long[] dp = new long[sum + 1];
        for (int i = 0; i < dp.length; i++) {
            dp[i] = 1000000000;
        }
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = sum - value[i]; j >= 0; j--) {
                dp[j + value[i]] = max(dp[j + value[i]], dp[j] + weight[i]);
            }
        }
        int max = 0;
        for (int i = 0; i < dp.length; i++) {
            if(dp[i] <= w) {
                max = i;
            }
        }
        System.out.println(max);
    }



}

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

import org.springframework.util.MultiValueMap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

import static java.lang.Math.max;
import static java.lang.Math.min;


public class Main{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] weight = new int[n + 1];
        int[] value = new int[n + 1];
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            weight[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
            sum = sum > value[i]?sum:value[i];
        }
        long[] dp = new long[sum + 1];
        for (int i = 0; i < dp.length; i++) {
            dp[i] = 1000000000;
        }
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = dp.length - 1; j >= 0; j--) {
                if(j >= value[i]) {
                    dp[j] = min(dp[j - value[i]] + weight[i], dp[j]);
                }
            }
        }
        int max = 0;
        for (int i = 0; i < dp.length; i++) {
            if(dp[i] <= w) {
                max = i;
            }
        }
        System.out.println(max);
    }



}

Compiler output:
Main.java:1: error: package org.springframework.util does not exist
import org.springframework.util.MultiValueMap;
                               ^
1 error
Language: C++

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[110][10000010];
int w[110];
int v[110];
int main()
{
    int n;
    ll limit;
    cin >> n >> limit;
    ll sum_v = 0;

    rep(i,n)
    {
        cin >> w[i] >> v[i];
        sum_v += v[i];
    }

    rep(i,n+1)
    {
        rep(j,sum_v+1)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i, n)
    {
        rep(j, sum_v + 1)
        {
            chmin(dp[i+1][j], dp[i][j]);
            if (j-v[i]>=0)
            {
                chmin(dp[i+1][j], dp[i][j-v[i]]+w[i]);
            }
        }
    }
    
    ll ans = 0;
    rep(j,sum_v+1)
    {
        if (dp[n][j]<=limit)
        {
            ans = j;
        }
    }
    cout << ans << endl;
}

Compiler output:
/tmp/ccIqJe98.o: in function `main':
a.cc:(.text+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccIqJe98.o
a.cc:(.text+0x7d): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccIqJe98.o
a.cc:(.text+0x9f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccIqJe98.o
a.cc:(.text+0x1d1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccIqJe98.o
a.cc:(.text+0x1f5): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccIqJe98.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccIqJe98.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n, w;
  cin >> n >> w;
  int wt[n+1], v[n+1];
  for(int i = 1; i < n+1; i++) cin >> wt[i] >> v[i];
  int m = 0;
  for(int i = 1; i < n+1; i++) m+=v[i];
  int dp[n+1][m+1];
  memset(dp, -1, sizeof(dp));
  bool bl[m+1];
  memset(bl, 0, sizeof(bl));
  for(int i = 1; i < n+1;i++)
  {
    bl[v[i]] = 1;
    dp[i][v[i]] = wt[i];
    for(int j = 1; j < m+1; j++)
    {
      if(dp[i-1][j] == -1) continue;
      if(dp[i-1][j] + w[i] > w) continue;
      dp[i][j + v[i]] = dp[i-1][j] + w[i];
      bl[j + v[i]] = 1;
    }
  }
  int mx = 0;
  for(int i = 1; i < n; i++) if(bl[i]) mx = i;
  cout << mx << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: invalid types 'int[int]' for array subscript
   23 |       if(dp[i-1][j] + w[i] > w) continue;
      |                        ^
a.cc:24:39: error: invalid types 'int[int]' for array subscript
   24 |       dp[i][j + v[i]] = dp[i-1][j] + w[i];
      |                                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n, w;
  cin >> n >> w;
  int wt[n+1], v[n+1];
  for(int i = 1; i < n+1; i++) cin >> wt[i] >> v[i];
  int m = 0;
  for(int i = 1; i < n+1; i++) m+=v[i]
  int dp[n+1][m+1];
  memset(dp, -1, sizeof(dp));
  bool bl[m+1];
  memset(bl, 0, sizeof(bl));
  for(int i = 1; i < n+1;i++)
  {
    bl[v[i]] = 1;
    dp[i][v[i]] = wt[i];
    for(int j = 1; j < m+1; j++)
    {
      if(dp[i-1][j] == -1) continue;
      if(dp[i-1][j] + w[i] > w) continue;
      dp[i][j + v[i]] = dp[i-1][j] + w[i];
      bl[j + v[i]] = 1;
    }
  }
  int mx = 0;
  for(int i = 1; i < n; i++) if(bl[i]) mx = i;
  cout << mx << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:39: error: expected ';' before 'int'
   11 |   for(int i = 1; i < n+1; i++) m+=v[i]
      |                                       ^
      |                                       ;
   12 |   int dp[n+1][m+1];
      |   ~~~                                  
a.cc:13:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |   memset(dp, -1, sizeof(dp));
      |          ^~
      |          dup
a.cc:23:24: error: invalid types 'int[int]' for array subscript
   23 |       if(dp[i-1][j] + w[i] > w) continue;
      |                        ^
a.cc:24:39: error: invalid types 'int[int]' for array subscript
   24 |       dp[i][j + v[i]] = dp[i-1][j] + w[i];
      |                                       ^
Language: C++

#include <bits/stdc++.h>
//#define long long int ll 
using namespace std;
long long int KnapSack(long long int val[], long long int wt[], long long int n, long long int W) 
{ 
    // matrix to store final result 
    long long int mat[2][W+1]; 
    memset(mat, 0, sizeof(mat)); 
  
    // iterate through all items 
    long long int i = 0; 
    while (i < n) // one by one traverse each element 
    { 
        long long int j = 0; // traverse all weights j <= W 
  
        // if i is odd that mean till now we have odd 
        // number of elements so we store result in 1th 
        // indexed row 
        if (i%2!=0) 
        { 
            while (++j <= W) // check for each value 
            { 
                if (wt[i] <= j) // include element 
                    mat[1][j] = max(val[i] + mat[0][j-wt[i]], 
                                    mat[0][j] ); 
                else           // exclude element 
                    mat[1][j] = mat[0][j]; 
            } 
  
        } 
  
        // if i is even that mean till now we have even number 
        // of elements so we store result in 0th indexed row 
        else
        { 
            while(++j <= W) 
            { 
                if (wt[i] <= j) 
                    mat[0][j] = max(val[i] + mat[1][j-wt[i]], 
                                     mat[1][j]); 
                else
                    mat[0][j] = mat[1][j]; 
            } 
        } 
        i++; 
    } 
  
    // Return mat[0][W] if n is odd, else mat[1][W] 
    return (n%2 != 0)? mat[0][W] : mat[1][W]; 
}
int main()
{
    long long int n,W,i;
    cin>>n>>W;
    long long int wt[n+1],val[n+1];
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    cout<<KnapSack(W,wt,val,n)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:20: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   60 |     cout<<KnapSack(W,wt,val,n)<<endl;
      |                    ^
      |                    |
      |                    long long int
a.cc:4:38: note:   initializing argument 1 of 'long long int KnapSack(long long int*, long long int*, long long int, long long int)'
    4 | long long int KnapSack(long long int val[], long long int wt[], long long int n, long long int W)
      |                        ~~~~~~~~~~~~~~^~~~~
a.cc:60:25: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive]
   60 |     cout<<KnapSack(W,wt,val,n)<<endl;
      |                         ^~~
      |                         |
      |                         long long int*
a.cc:4:79: note:   initializing argument 3 of 'long long int KnapSack(long long int*, long long int*, long long int, long long int)'
    4 | long long int KnapSack(long long int val[], long long int wt[], long long int n, long long int W)
      |                                                                 ~~~~~~~~~~~~~~^