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

import java.util.Scanner;
import java.math.BigInteger;
import java.util.Arrays;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.lang.Math;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.math.*;

class lcs
{
	String ai,bi;
	void input()
	{
		Scanner inp = new Scanner(System.in);
		this.ai=inp.nextLine();
		this.bi=inp.nextLine();
	}
	int lcs()
	{
		char[] a = this.ai.toCharArray();
		char[] b = this.bi.toCharArray();
		int[][] dp=new int[this.ai.length()+1][this.bi.length()+1];
		for(int i=0;i<=this.ai.length();i++)
		{
			for(int j=0;j<=this.bi.length();j++)
			{
				if(j==0||i==0)
					dp[i][j]=0;
				else if(a[i-1]==b[j-1])
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
			}
		}
		return dp[this.ai.length()][this.bi.length()];
	}	
}

class tree
{
	int n,e;
	Vector[] v = new Vector[100009];
	int[] visited =  new int[100009];
	void init()
	{
		for(int i=0;i<100009;i++)
		{
			v[i] = new Vector();
			visited[i]=0;
		}
	}
	void inputn()
	{
		Scanner inp = new Scanner(System.in);
		this.n = inp.nextInt();
		this.e = inp.nextInt();
	}
	void inputt()
	{
		Scanner inp = new Scanner(System.in);
		int a,b;
		for(int i=0;i<this.e;i++)
		{
			a=inp.nextInt();
			b=inp.nextInt();
			v[a].add(b);
			v[b].add(a);
		}
	}
	void dfs(int k)
	{
		System.out.println(k);
		visited[k]=1;
		for(int i=0;i<v[k].size();i++)
		{
			if(visited[(int)v[k].get(i)]==0)
			{
				dfs((int)v[k].get(i));
			}
		}
	}
	void solve()
	{
		init();
		inputn();
		inputt();
		dfs(1);
	}
}
public class test
{
	public static void main(String[] args) 
	{
		Scanner inp = new Scanner(System.in);
		int n,w;
		n=inp.nextInt();
		w=inp.nextInt();
		int[] wgh = new int[n];
		int[] val = new int[n];
		int[][] dp = new int[100009][101];
		for(int i=0;i<n;i++)
		{
			wgh[i]=inp.nextInt();
			val[i]=inp.nextInt();
		}
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<100009;j++)
			{
				dp[j][i]=-1;
			}
		}
		dp[val[0]][1]=wgh[0];
		for(int i=2;i<=n;i++)
		{
			for(int j=0;j<100009;j++)
			{
				if(j>=val[i-1]&&dp[j-val[i-1]][i-1]!=-1&&dp[j][i-1]!=-1)
				{
					dp[j][i]=Math.min(dp[j-val[i-1]][i-1]+wgh[i-1],dp[j][i-1]);
				}
				else if(j>=val[i-1]&&dp[j-val[i-1]][i-1]!=-1)
				{
					dp[j][i]=dp[j-val[i-1]][i-1]+wgh[i-1];
				}
				else if(dp[j][i-1]!=-1)
				{
					dp[j][i]=dp[j][i-1];
				}
				else if(j==val[i-1])
				{
					dp[j][i]=wgh[i-1];
				}
			}
		}
		int ans=-1;
		for(int i=100008;i>=0;i--)
		{
			if(dp[i][n]!=-1&&dp[i][n]<=w)
			{
				ans=i;
				break;
			}
		}
		System.out.println(ans);
	}
}

Compiler output:
Main.java:95: error: class test is public, should be declared in a file named test.java
public class test
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include <bits/stdc++.h>

using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;
int we[MAXN] , val[MAXN];
ll mem[105][MAXN];
ll n,wmax;
ll ans = 0;
ll solve(int i, ll v)
{
if(v < 0) return 1e18;
if(v == 0) return 0;
if(i == n) return 1e18;
ll &ret = mem[i][v];
ret =  min(solve(i + 1 , v) , solve(i + 1 , v - val[i]) + we[i]);

return ret;

    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr)
   cin >> n >> wmax;
   for(int i = 0 ; i < n ; i++) cin >> we[i] >> val[i];
  memset(mem,-1,sizeof(mem));
   
  for(int i = 1 ; i <= 1e5 ; ++i)
  {
      if(solve(0,(ll)i) <= wmax) ans = i;
  }
  cout << ans;
   
   
  
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:21: error: expected ';' before 'cin'
   25 |     cin.tie(nullptr)
      |                     ^
      |                     ;
   26 |    cin >> n >> wmax;
      |    ~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;
int we[MAXN] , val[MAXN];
ll mem[105][MAXN];
ll n,wmax;
ll ans = 0;
ll solve(int i, ll v)
{
if(v < 0) return 1e18;
if(v == 0) return 0;
if(i == n) return 1e18;
ll &ret = mem[i][v];
ret =  min(solve(i + 1 , v) , solve(i + 1 , v - val[i]) + we[i]);

return ret;

    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nulltptr)
   cin >> n >> wmax;
   for(int i = 0 ; i < n ; i++) cin >> we[i] >> val[i];
  memset(mem,-1,sizeof(mem));
   
  for(int i = 1 ; i <= 1e5 ; ++i)
  {
      if(solve(0,(ll)i) <= wmax) ans = i;
  }
  cout << ans;
   
   
  
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: 'nulltptr' was not declared in this scope; did you mean 'nullptr_t'?
   25 |     cin.tie(nulltptr)
      |             ^~~~~~~~
      |             nullptr_t
Language: C++

#include <bits/stdc++.h>

using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;
int we[MAXN] , val[MAXN];
ll mem[105][MAXN];
ll n,wmax;
ll ans = 0;
ll solve(int i, ll v)
{
if(v < 0) return 1e18;
if(v == 0) return 0;
if(i == n) return 1e18;
ll &ret = mem[i][v];
ret =  min(solve(i + 1 , v) , solve(i + 1 , v - val[i]) + we[i]);

return ret;

    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nulltpr)
   cin >> n >> wmax;
   for(int i = 0 ; i < n ; i++) cin >> we[i] >> val[i];
  memset(mem,-1,sizeof(mem));
   
  for(int i = 1 ; i <= 1e5 ; ++i)
  {
      if(solve(0,(ll)i) <= wmax) ans = i;
  }
  cout << ans;
   
   
  
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: 'nulltpr' was not declared in this scope; did you mean 'nullptr_t'?
   25 |     cin.tie(nulltpr)
      |             ^~~~~~~
      |             nullptr_t
Language: Java

import java.util.*;
public class Meme {
	static int val[];
	static int weight[];
	static int dp[][];
	static int l = 0;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		val = new int[n];
		weight = new int[n];
		dp = new int[1000][n];
		for(int i = 0;i<n;i++){
			weight[i] = sc.nextInt();
			val[i] = sc.nextInt();
		}
		for(int i = 0;i<1000;i++){
			for(int j = 0;j<n;j++){
				dp[i][j]=-1;
			}
		}
		System.out.println(rec(0, 0, w));
	}
	public static int rec(int i, int v, int w){
		if(w<0)
			return 0;
		if(i>=val.length)
			return v;
		if(dp[v][i]!=-1){
			return dp[v][i];
		}
		return dp[v][i] = (int) Math.max(rec(i+1, v+val[i], w-weight[i]), rec(i+1, v, w));
	}
}


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

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[][] dp = new int[2][W + 1];
    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();
    }
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= S; j++) {
      	dp[i % 2][j] = dp[(i - 1) % 2][j];
        if (j >= w[i - 1]) {
          dp[i % 2][j] = Math.max(dp[i % 2][j],dp[(i - 1) % 2][j - w[i - 1]] + v[i - 1]); 
        }
      }
    }
    System.out.println(dp[N % 2][W];
  }
}

Compiler output:
Main.java:22: error: ')' or ',' expected
    System.out.println(dp[N % 2][W];
                                   ^
1 error
Language: C++

#include <bits/stdc++.h>
#define MAX 1000000005
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

ull dp[105][MAX];
int main() {
  ull N,W;
  scanf("%llu%llu",&N,&W);
  vector<ull> weight(N);
  vector<ull> value(N);
  for(int i=0;i<N;i++) {
    scanf("%llu",&weight[i]);
    scanf("%llu",&value[i]);
    dp[i][0]=0;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:17:4: error: expected '}' at end of input
   17 |   }
      |    ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<vector>
#include<set>
#include<cmath>

int main(){
	int n;
	long long w;
	std::vector<long long> wList;
	std::vector<long long> vList;
	std::vector<long long> dpList;
	std::vector<std::set<long long>> tgList;

	std::cin>>n>>w;
	wList.resize(n);
	vList.resize(n);
	tgList.resize(n+1);
	dpList.resize(100001, 0);

	tgList[0].insert(0);

	for(int i=0; i<n; i++)
		std::cin>>wList[i]>>vList[i];

	for(int i=0; i<n; i++){
		for(auto iter= tgList[i].begin(); iter!= tgList[i].end(); ++iter){
			long long curV= *iter;
			long long nextV= *iter+vList[i];
			long long nextW= dpList[curV]+ wList[i];

			tgList[i+1].insert(curV); 
			if(nextW <= w){
				if(dpList[nextV] == 0)
					dpList[nextV]= nextW;
				else
					dpList[nextV]= std::min(dpList[nextV],nextW);

				tgList[i+1].insert(nextV); 				
			}
		}
	}

	int ans=0;
	for(auto iter= tgList[n].begin(); iter!= tgList[n].end(); ++iter){
		ans= std::max(ans, *iter);
	}

	std::cout<<ans<<std::endl;

	return 0;
	
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:30: error: no matching function for call to 'max(int&, const long long int&)'
   45 |                 ans= std::max(ans, *iter);
      |                      ~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:45:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |                 ans= std::max(ans, *iter);
      |                      ~~~~~~~~^~~~~~~~~~~~
/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
Language: C++

#include <bits/stdc++.h>

using namespace std;

long long int dp[100005][105];

pair<int,int>jinis[105];

void init(){
 memset(dp,-1,sizeof(dp));
}

long long solve(int vleft, int cur, int n){
 if(cur==n){
   if(vleft==0)return 0;
   return (long long)2000000000;
 }
 if(dp[vleft][cur]!=-1)return dp[vleft][cur];
 long long ret1 = 0, ret2 = 0;
  
 ret1 = (long long)jinis[cur].first + solve(max(0,vleft-jinis[cur].second),cur+1,n);
 
  ret2 = solve(vleft, cur+1, n);
  return dp[wleft][cur] = min(ret1,ret2);
}

int main(){
  int n,w;
  cin>>n>>w;
  int hi = 0;
  for(int i = 0; i<n; ++i){
   cin>>jinis[i].first>>jinis[i].second;
    hi = hi+jinis[i].second;
  }
  
  int lo = 0;
  while(lo+1<hi){
     int mid = (lo+hi)/2;
    init();
     if(solve(mid,0,n)<=w)lo = mid;
    else hi = mid;
  }
  long long lw = solve(hi,0,n);
  if(lw<=w){
   cout<<hi<<"\n";
  }
  else{
  		cout<<lo<<"\n";
  }
  //cout<<solve(w,0,n)<<"\n";
  return 0;
}

Compiler output:
a.cc: In function 'long long int solve(int, int, int)':
a.cc:24:13: error: 'wleft' was not declared in this scope; did you mean 'vleft'?
   24 |   return dp[wleft][cur] = min(ret1,ret2);
      |             ^~~~~
      |             vleft
Language: C++

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

int main(){
    int x;
    long long  n,w;
    scanf("%lld %lld",&n,&w);
    x=n*1000+1;
    long long dp[101][x];
    for(int i=0;i<101;i++) for(int j=0;j<x;j++) dp[i][j]=0;
    long long ans=0;
    for (int i=0;i<n;i++) {
        long long  a,b;
        scanf("%lld %lld",&a,&b);
        for (int j=0;j<x;j++) {
            if (dp[i][j]==0 && j>=b) {
              dp[i][j]=a;
              if (dp[i+1][j]==0) dp[i+1][j]=a;
            } else if (j>=b){
              dp[i][j+b]=min(dp[i][j+b],dp[i][j]+a);
              dp[i+1][j+b]=dp[i][j+b];
        }
    }
    for (int i=x-1;i>0;i--) if (dp[n][i]!=0 && dp[n][i]<=w) {
        ans=i;
        break;
    }
    printf("%lld\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)



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

    int n,x,w;
    ll u,ans=0;
    cin>>n>>x;
    
    vector<ll> s(114514,1e16);
    s[0]=0;
    
    rep(i,n){
        cin>>w>>u;
        
        for(int j=100000;j=>0;j--)
        if(s[j]<1e12){
            if(s[j+u]>1e12)s[j+u]*=0;
            s[j+u]=max(s[j+u],s[j]+w);
        }
    }
    
    for(auto i:s)
        if(i<1e13)ans=max(ans,i);
    cout<<ans<<endl;
        
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:28: error: expected primary-expression before '>' token
   24 |         for(int j=100000;j=>0;j--)
      |                            ^
Language: C++

/* A Naive recursive implementation of 0-1 Knapsack problem */
#include<stdio.h> 
using namespace std;
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 

// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
// Base Case 
if (n == 0 || W == 0) 
	return 0; 

// If weight of the nth item is more than Knapsack capacity W, then 
// this item cannot be included in the optimal solution 
if (wt[n-1] > W) 
	return knapSack(W, wt, val, n-1); 

// Return the maximum of two cases: 
// (1) nth item included 
// (2) not included 
else return max( val[n-1] + knapSack(W-wt[n-1], wt, val, n-1), 
					knapSack(W, wt, val, n-1) 
				); 
} 

// Driver program to test above function 
int main() 
{ 
	int n,W;
  cin>>n>>W;
  int val[n],wt[n];
  for(int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
	printf("%d", knapSack(W, wt, val, n)); 
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:31:3: error: 'cin' was not declared in this scope
   31 |   cin>>n>>W;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<stdio.h>
  +++ |+#include <iostream>
    3 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[102][100005];
int32_t main()
{
	int n,w;
	cin >> n >> w;
	vector<pair<int,int> > arr(n+1);
	memset(dp,LLONG_MAX,sizeof dp);
	for(int i=1;i<=n;i++)
	{
		cin >> arr[i].first >> arr[i].second;
	}
	for(int i = 1; i<= n ; i++)
	{
		dp[i][arr[i].second] = arr[i].first;
		for(int j = 1; j <= 100003 ;j++)
		{
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			if(j >= arr[i].second)
				dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+arr[i].first);
		}
	}
	int ans = 0;
	for(int i=1;i<=100003;i++)
	{
		if(dp[n][i] <= w)
		ans = max(ans,i);
	}
	cout << ans;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:10:19: warning: overflow in conversion from 'long long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow]
   10 |         memset(dp,LLONG_MAX,sizeof dp);
      |                   ^~~~~~~~~
a.cc:22:67: error: 'v' was not declared in this scope
   22 |                                 dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+arr[i].first);
      |                                                                   ^
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

short dp [105] [1000000005], w [105], val[105]; 

int f (short pos,short x) {
	if (pos == -1) return 0;
	//cout << pos << " " << x << " " << dp [pos] [x] << endl;
	if (dp [pos] [x]) return dp [pos] [x];
	if (x - w [pos] < 0) {
		dp [pos] [x] = f  (pos - 1, x);
		return dp [pos] [x];
	}
	dp [pos] [x] = max (f (pos - 1, x), f (pos - 1,x - w [pos]) + val [pos]);
	return dp [pos] [x];
}

int main  () {
	short W,n,i;
	cin >> n >> W;
	for  (i = 0; i < n; i++) {
		cin >> w [i] >> val [i];
	}
	short a = f (n-1,W);
	cout << a;
	return 0;
}



Compiler output:
/tmp/ccLvWirM.o: in function `f(short, short)':
a.cc:(.text+0x8d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccLvWirM.o
a.cc:(.text+0x117): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccLvWirM.o
a.cc:(.text+0x143): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccLvWirM.o
/tmp/ccLvWirM.o: in function `main':
a.cc:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccLvWirM.o
a.cc:(.text+0x23d): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccLvWirM.o
collect2: error: ld returned 1 exit status
Language: C++

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

#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;

int n, w;
int tb[105][1000000005];
vi peso, val;

int dp(int i, int p) {
    if(i == n or p == w) return 0;
    if(tb[i][p] != -1) return tb[i][p];

    int ans = dp(i+1, p);
    if(p + peso[i] <= w) ans = max(ans, dp(i+1, p + peso[i]) + val[i]);

    tb[i][p] = ans;
    return ans;
}

int main() {
    cin >> n >> w;

    peso.resize(n+5);
    val.resize(n+5);
    for(int i = 0; i < n; i++)
    {
        scanf("%d %d", &peso[i], &val[i]);
    }
    memset(tb, -1, sizeof tb);
    printf("%d\n", dp(0, 0));



    return 0;
}

Compiler output:
/tmp/ccnUayui.o: in function `dp(int, int)':
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `peso' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0xd4): relocation truncated to fit: R_X86_64_PC32 against symbol `peso' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccnUayui.o
/tmp/ccnUayui.o: in function `main':
a.cc:(.text+0x1aa): relocation truncated to fit: R_X86_64_PC32 against symbol `peso' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x1c7): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x1e7): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x201): relocation truncated to fit: R_X86_64_PC32 against symbol `peso' defined in .bss section in /tmp/ccnUayui.o
/tmp/ccnUayui.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x28e): relocation truncated to fit: R_X86_64_PC32 against symbol `peso' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x2a7): relocation truncated to fit: R_X86_64_PC32 against symbol `peso' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x2c0): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccnUayui.o
a.cc:(.text+0x2d9): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int MOD = 1000'000'007;
const double EPS = 0.000'000'001;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 105, W = MOD;
int n, w;
int dp[2][W];
pii x[N];

int main()
{
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);
	cout.precision(10);
	
	cin >> n >> w;

	for(int i = 1; i <= n; i++)
		cin >> x[i].second >> x[i].first;

	for(int i = 0; i <= n; i++)
	{
		bool b = i % 2;
		for(int j = 0; j <= w; j++)
		{
			if(i == 0 || j == 0) dp[b][j] = 0;
			else
			{
				dp[b][j] = dp[!b][j];
				if(j - x[i].second >= 0) dp[b][j] = max(dp[b][j], x[i].first + dp[!b][j - x[i].second]);
			}
		}
	}

	cout << dp[n % 2][w] << endl;
	
	//cerr << "Tempo de execucao: " << (double)clock() / CLOCKS_PER_SEC << endl;
	return 0;
}

Compiler output:
/tmp/ccCvG4v6.o: in function `main':
a.cc:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccCvG4v6.o
a.cc:(.text+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccCvG4v6.o
a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccCvG4v6.o
a.cc:(.text+0x1e9): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccCvG4v6.o
a.cc:(.text+0x20a): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccCvG4v6.o
collect2: error: ld returned 1 exit status
Language: Java

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

public class HighWeightKnapsack {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int w = nextInt();
		int[] weight = new int[n];
		int[] val = new int[n];
		int max = 0;
		for(int i = 0; i < n; i++) {
			weight[i] = nextInt();
			val[i] = nextInt();
			max += val[i];
		}
		long[] dp = new long[max + 1];
		Arrays.fill(dp, Long.MAX_VALUE);
		dp[0] = 0;
		for(int i = 0; i < n; i++) {
			for(int k = max; k >= val[i]; k--) {
				if(dp[k - val[i]] == Long.MAX_VALUE || dp[k - val[i]] + weight[i] > w)
					continue;
				dp[k] = Math.min(dp[k], dp[k - val[i]] + weight[i]);
			}
		}
		for(int i = max; i >=0; i--) {
			if(dp[i] < Long.MAX_VALUE) {
				System.out.println(i);
				return;
			}
		}
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

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


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

#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;

int main(){
	int N, W;
	long long int sum = 0;
	int ans = 0;
	cin>>N>>W;
    int value[N+1];
    int weight[N+1];
    for(int i=1;i<=N;i++){
    	cin>>weight[i];
    	cin>>value[i];
    	sum+=value[i];
    }
    long long int dp[100001][N+1];
    dp[0][0] = 0;
    for(int i=1;i<=sum;i++)
    	for(int j=0;j<=N;j++)
    		dp[i][j]=W+1;

    for(int i=1;i<=sum;i++){
    	for(int j=1;j<=N;j++){
    		dp[i][j] = dp[i-1][j];
    		if(value[j]>=i){
    			dp[i][j] = min(dp[i][j], dp[i-value[j]][j-1]+weight[j] )
    		}
    		if(dp[i][j]<=W)
    			ans = max(ans,i);
    	}
    }	
    return ans;	
}









Compiler output:
a.cc: In function 'int main()':
a.cc:35:81: error: expected ';' before '}' token
   35 |                         dp[i][j] = min(dp[i][j], dp[i-value[j]][j-1]+weight[j] )
      |                                                                                 ^
      |                                                                                 ;
   36 |                 }
      |                 ~
Language: C++

#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;

int main(){
	int N,int W;
	long long int sum = 0;
	int ans = 0;
	cin>>N>>W;
    int value[N+1];
    int weight[N+1];
    for(int i=1;i<=N;i++){
    	cin>>weight[i];
    	cin>>value[i];
    	sum+=value[i];
    }
    long long int dp[100001][N+1];
    dp[0][0] = 0;
    for(int i=1;i<=sum;i++)
    	for(int j=0;j<=N;j++)
    		dp[i][j]=W+1;

    for(int i=1;i<=sum;i++){
    	for(int j=1;j<=N;j++){
    		dp[i][j] = dp[i-1][j];
    		if(value[j]>=i){
    			dp[i][j] = min(dp[i][j], dp[i-value[j]][j-1]+weight[j] )
    		}
    		if(dp[i][j]<=W)
    			ans = max(ans,i);
    	}
    }	
    return ans;	
}









Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: expected unqualified-id before 'int'
   14 |         int N,int W;
      |               ^~~
a.cc:17:17: error: 'W' was not declared in this scope
   17 |         cin>>N>>W;
      |                 ^
a.cc:35:81: error: expected ';' before '}' token
   35 |                         dp[i][j] = min(dp[i][j], dp[i-value[j]][j-1]+weight[j] )
      |                                                                                 ^
      |                                                                                 ;
   36 |                 }
      |                 ~
Language: C++

/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,t,dp[500010][1010],all=0,ans;//dp[val][used items' numbers]=real_val>=val,min_weight
pii vw[1010];

int main()
{
	rep(i,100005) rep(j,105) dp[i][j]=1e18;
	cin>>n>>t;
	repn(i,n) cin>>vw[i].se>>vw[i].fi,all+=vw[i].fi;
	sort(vw,vw+n);
	dp[0][0]=0;
	rep(i,all+1)
	{
		repn(j,n)
		{
			dp[i][j]=min(dp[i][j],dp[i][j-1]);
			dp[i+vw[j].fi][j]=dp[i][j-1]+vw[j].se;
		}
	}
	rep(i,all+1) if(dp[i][n]<=t) ans=i;
	cout<<ans<<endl;
	rt0;
}

Compiler output:
/tmp/ccq0D7ka.o: in function `main':
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0xd8): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `all' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x10e): relocation truncated to fit: R_X86_64_PC32 against symbol `all' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x14a): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x23b): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x259): relocation truncated to fit: R_X86_64_PC32 against symbol `vw' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x2b1): relocation truncated to fit: R_X86_64_PC32 against symbol `all' defined in .bss section in /tmp/ccq0D7ka.o
a.cc:(.text+0x305): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

long long n, w, i, k, dp[2][1000000009] = { };
vector<pair<long long, long long>> items;
//w - v
int main() {
	cin >> n >> w;
	memset(dp, 0, sizeof(dp));
	items.resize(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> items[i].first >> items[i].second;

	for(long long it = 1; it <= n; it++) {
		i = it&1;
		for(long long j = 1; j <= w; j++) {
			if(items[it].first > j) {
				dp[i][j] = dp[i^1][j];
				continue;
			}
			dp[i][j] = max(dp[i^1][j], dp[i^1][j - items[it].first] + items[it].second);

		}
	}

	cout << *max_element(begin(dp[n&1]), end(dp[n&1]));

	return 0;
}


Compiler output:
/tmp/ccObmgB1.o: in function `main':
a.cc:(.text+0x69): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
a.cc:(.text+0x89): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
a.cc:(.text+0x118): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
a.cc:(.text+0x1a3): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
a.cc:(.text+0x1e0): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
/tmp/ccObmgB1.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x321): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
a.cc:(.text+0x33a): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccObmgB1.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>

using namespace std ;
long long int n;
long long int N,W;
long long int v[108],w[108];

long long int dp[108][10800];

long long int mx(long long int a,long long int b){
	if(a > b){
		return a;
	}else{
		return b;
	}
}
long long int main(){
	cin >> N >> W;
	for(long long int i = 0;i < n;i++){
		cin >> w[i] >> v[i];
	}
	
	for(long long int i = 0;i < N;i++){
		for(long long int j = 0;j < W;j++){
			if(i == 0){
				if(j >= w[0]){
					dp[i][j] = v[0];
				}else{
					dp[i][j] = 0;
				}
			}else if(j - w[i] < 0){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = mx(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
			}
		}
	}
	cout << dp[N-1][W] << endl;
		
}

Compiler output:
a.cc:17:11: error: '::main' must return 'int'
   17 | long long int main(){
      |           ^~~
Language: C++

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

const ll w_max = 100005;
const ll n_max = 105;

ll dp[w_max][n_max];

int main(){
  ll N,W;
  cin >> N >> W;
  
  
  vector<ll> v(N+1);
  vector<ll> w(N+1);
  
  for(ll i=1; i<=N; i++) cin >> w[i] >> v[i];
  
  ll sumw = 0;
  ll sumv = 0;
  for(ll i=1; i<n; i++){
    sumw += w[i];
    sumv += v[i];
  }
  
  if(W >= sumw){
    cout << sumv << endl;
    return 0;
  }
  
  for(ll i=0; i<=W; i++) dp[i][0] = 0;
  for(ll i=0; i<=N; i++) dp[0][i] = 0;
    
  for(ll i=1; i<=W; i++){
    for(ll j=1; j<=N; j++){
      if(i >= w[j]){
        dp[i][j] = max(dp[i-w[j]][j-1] + v[j], dp[i][j-1]);
      }else
        dp[i][j] = dp[i][j-1];
    }
  }
  
    cout << dp[W][N] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'n' was not declared in this scope
   22 |   for(ll i=1; i<n; i++){
      |                 ^
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;

int w[maxn], v[maxn];
long long dp[maxn];

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

    memset(dp, INF, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = V; j >= v[i]; --j) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    for (int i = V; i >= 0; --i) {
        if (dp[i] <= W) {
            printf("%d\n", i);
            return 0;
        }
    }
}

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

#include <iostream>
using namespace std;

int main()
{
    int n, w;
    cin >> n >> w;
    int a[n] = {};
    long long v[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i] >> v[i];
    }
    long long dp[w+1] = {};

    for(int i=0; i<n; i++){
        for(int j=0; j<=w; j++){
            if(j>=a[i]){
                dp[j] = max(dp[j], dp[j-a[i]]+v[i]);
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


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

/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/
#include<bits/stdc++.h>
using namespace std;
long long int dp[2][2000000001];
long long int wt[505],val[501];
int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0);
    int k,n,i,j;
    cin>>n>>k;
    for(i=1;i<=n;i++)
        cin>>wt[i]>>val[i]; 
    dp[0][0]=0;
    dp[1][0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(j>=wt[i])
                dp[(i&1)][j]=max(dp[!(i&1)][j],(dp[!(i&1)][j-wt[i]]+val[i]));
            else
                dp[(i&1)][j]=dp[!(i&1)][j];
        }
    }
    cout<<(dp[(n&1)][k]);
    return 0;
}



Compiler output:
/tmp/ccCf8jjd.o: in function `main':
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `wt' defined in .bss section in /tmp/ccCf8jjd.o
a.cc:(.text+0x93): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccCf8jjd.o
a.cc:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `wt' defined in .bss section in /tmp/ccCf8jjd.o
a.cc:(.text+0x134): relocation truncated to fit: R_X86_64_PC32 against symbol `wt' defined in .bss section in /tmp/ccCf8jjd.o
a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccCf8jjd.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<string>

using namespace std;

	long long dp[200090];

int main(){

	memset(dp,63,sizeof dp);
	long long deff = dp[0];

	int n; cin >> n;
	long long w; cin >> w;
	
	for(int i = 0; i < n; i++){
		int val;
		long long wei; cin >> wei >> val;
		for(int i = 100090; i >= 0; i--){
			if(dp[i] == deff) continue;
			else dp[i + val] = min(dp[i] + wei , dp[i + val]);
		//	cout << i + val << " " << dp[i + val] << endl; system("pause");
		}
		dp[val] = min(wei,dp[val]);
	}
	
	int
	for(int i = 0; i < 100090; i++){
		if(dp[i] <= w) sol = max(i ,sol);
	} cout << sol;
	



	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: expected unqualified-id before 'for'
   34 |         for(int i = 0; i < 100090; i++){
      |         ^~~
a.cc:34:24: error: 'i' was not declared in this scope
   34 |         for(int i = 0; i < 100090; i++){
      |                        ^
a.cc:36:19: error: 'sol' was not declared in this scope
   36 |         } cout << sol;
      |                   ^~~
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,w[103],v[103],W,dp[103][100003];
int main(){
	memset (dp,-1,sizeof(dp));
	cin>>N>>W;
	ll NUM=0;
	for (ll i=1;i<=N;i++){
		cin>>w[i]>>v[i];
		num+=v[i];
	}
	dp[0][0]=0;
	for (ll i=1;i<=N;i++)
		for (ll j=0;j<=num;j++){
			if (dp[i-1][j]!=-1){
				if (dp[i][j]==-1) dp[i][j]=dp[i-1][j];
				else dp[i][j]=min(dp[i][j],dp[i-1][j]);
				dp[i][j+v[i]]=dp[i-1][j]+w[i];
			}
		}
	ll ans=0;
	for (ll i=0;i<=num;i++)
		if (dp[N][i]<=W && dp[N-1][i]!=-1) ans=i;
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:17: error: 'num' was not declared in this scope; did you mean 'enum'?
   37 |                 num+=v[i];
      |                 ^~~
      |                 enum
a.cc:41:32: error: 'num' was not declared in this scope; did you mean 'enum'?
   41 |                 for (ll j=0;j<=num;j++){
      |                                ^~~
      |                                enum
a.cc:49:24: error: 'num' was not declared in this scope; did you mean 'enum'?
   49 |         for (ll i=0;i<=num;i++)
      |                        ^~~
      |                        enum
Language: C++

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll wt[101],pft[101];
ll n;
ll dp[110][1000000001];

map<ll,ll
ll solve(ll st_index,ll wt_left){
    
    if(st_index == n ) return 0;
    
    if(dp[st_index][wt_left]!=-1) return dp[st_index][wt_left];
    
    ll ans = solve(st_index+1,wt_left);
    
    if(wt[st_index]<=wt_left){
        ans = max(ans,pft[st_index]+solve(st_index+1,wt_left-wt[st_index]));
    }
    
    return dp[st_index][wt_left] = ans;
    
}


int main() {
	
	ll w;
	cin>>n>>w;
	memset(wt,0,sizeof wt);
	memset(pft,0,sizeof pft);
	memset(dp,-1,sizeof dp);
	
	for(ll i=0;i<n;i++){
	    cin>>wt[i]>>pft[i];
	}
	
	ll ans = solve(0,w);
	cout << ans;
	
	return 0;
}

Compiler output:
a.cc:4:12: error: 'long long long' is too long for GCC
    4 | #define ll long long
      |            ^~~~
a.cc:10:1: note: in expansion of macro 'll'
   10 | ll solve(ll st_index,ll wt_left){
      | ^~
a.cc:4:17: error: 'long long long' is too long for GCC
    4 | #define ll long long
      |                 ^~~~
a.cc:10:1: note: in expansion of macro 'll'
   10 | ll solve(ll st_index,ll wt_left){
      | ^~
a.cc:10:32: error: template argument 2 is invalid
   10 | ll solve(ll st_index,ll wt_left){
      |                                ^
a.cc:10:32: error: template argument 4 is invalid
a.cc:10:33: error: expected unqualified-id before '{' token
   10 | ll solve(ll st_index,ll wt_left){
      |                                 ^
a.cc: In function 'int main()':
a.cc:39:18: error: 'solve' was not declared in this scope
   39 |         ll ans = solve(0,w);
      |                  ^~~~~
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
  
// val[] is for storing maximum profit for each weight 
// wt[] is for storing weights 
// n number of item 
// W maximum capacity of bag 
// dp[W+1] to store final result 
int KnapSack(int val[], int wt[], int n, long W) 
{ 
    // array to store final result 
    //dp[i] stores the profit with KnapSack capacity "i" 
    int dp[W+1]; 
      
    //initially profit with 0 to W KnapSack capacity is 0 
    memset(dp, 0, sizeof(dp)); 
  
    // iterate through all items 
    for(int i=0; i < n; i++)  
        //traverse dp array from right to left 
        for(int j=W; j>=wt[i]; j--) 
            dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
    /*above line finds out maximum of  dp[j](excluding ith element value) 
      and val[i] + dp[j-wt[i]] (including ith element value and the 
      profit with "KnapSack capacity - ith element weight") */    
    return dp[W]; 
} 
  
// Driver program to test the cases 
int main() 
{ 
  	int n;
  cin>>n;
  long long w;
  cin>>w;
    int val[110],wt[110];
  	for(int i=0;i<n;++i)	cin>>wt[i]>>val[i];
    cout << KnapSack(val, wt, n, W) << endl; 
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:38:34: error: 'W' was not declared in this scope
   38 |     cout << KnapSack(val, wt, n, W) << endl;
      |                                  ^
Language: C++

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

int dp[5001];
signed main() {
	int n, w; cin >> n >> w;
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		for (int j = 5000; j >= y; j--) {
			dp[j] = min(dp[j], dp[j - y] + x);
		}
	}
	for (int i = 5000; i >= 0; i--) {
		if (dp[i] <= w) { cout << i << endl; return 0; }
	}
}

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

#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

const int maxv = 100002;

int n, m, w, v, f[maxv];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	memset(f, -1, sizeof(f));
	f[0] = 0;

	cin >> n >> m;
	int sumv = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> w >> v;
		sumv += v;

		for (int j = sumv; j >= v; --j)
			if (f[j-v] != -1)
				if (f[j] == -1 || f[j] > f[j-v] + w)
					f[j] = f[j-v] + w;
	}
	
	int ans = 0;
	for (int i = sumv; i > 0; --i)
		if (f[i] != -1 && f[i] <= m) {
			ans = i;
			break;
		}

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'memset' was not declared in this scope
   24 |         memset(f, -1, sizeof(f));
      |         ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include <utility>
  +++ |+#include <cstring>
   12 |
Language: C++

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

#define fast ios::sync_with_stdio(0); cin.tie(NULL); 
#define fi first
#define se second
#define mp make_pair
#define pi 3.14159265359
#define MOD 1000000007
#define inf 1e18
#define setbits(x) __builtin_popcountll(x)
typedef long long ll;
#define mp make_pair
#define ALL(v) v.begin(), v.end() 
#define F(i,s,n) for(i=s;i<n;++i)
#define pb push_back
#define eb emplace_back
#define tin freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pll pair<ll,ll>
ll max(ll a,ll b)
{
    return a*(a>=b)+b*(b>a);
}
string smax(string a,string b)
{
    if(a.size()>b.size())return a;
    return b;
}
/*----------------------------------------------------------*/
string a,b;

void solve()
{
    cin>>a>>b;
    ll n=a.size(),m=b.size();
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<n+1;++i)
    {
        for(ll j=1;j<m+1;++j)
        {
            if(a[i-1]==b[j-1])dp[i][j]=1+dp[i-1][j-1];
            dp[i][j]=max(dp[i][j],dp[i][j-1]);
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            //cout<<dp[i][j]<<" ";
        }//cout<<endl;
    }
    ll i=n,j=m;
    string s=" ";
    while(i!=0&&j!=0)
    {
        if(dp[i][j]==dp[i][j-1])--j
        else if(dp[i][j]==dp[i-1][j])--i;
        else {--i;--j;s=a[i]+s;}
    }cout<<s;
}

int main()
{
    //tin
    fast
    ll tc=1;//cin>>tc;
   for(ll i=1;i<=tc;++i)
   {
    //cout<<"Case #"<<i<<": ";
    solve();
    if(i!=tc)cout<<"\n";
   }
return 0;
}
//End-Cases 
//Precomputation
//Segmentation Fault
//Complexity
//Break it up
//Sub Problems


Compiler output:
a.cc: In function 'void solve()':
a.cc:52:36: error: expected ';' before 'else'
   52 |         if(dp[i][j]==dp[i][j-1])--j
      |                                    ^
      |                                    ;
   53 |         else if(dp[i][j]==dp[i-1][j])--i;
      |         ~~~~
Language: C++

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

const int N = 3005;
string s , t;
int f[N][N];

void trace(int i , int j)
{
    if(i == 0 || j == 0)return;
    if(f[i][j] == f[i-1][j-1] + 1 && f[i-1][j] + 1= f[i][j] && f[i][j-1] + 1 == f[i][j])
    {
        trace(i-1 , j-1);
        cout << s[i-1];
    }
    else
    {
        if(f[i][j] == f[i-1][j])trace(i-1 , j);
        else trace(i , j-1);
    }
}

int main()
{
    cin >> s >> t;
    f[0][0] = 0;
    f[0][1] = 0;
    f[1][0] = 0;
    for(int i = 1; i <= s.size(); ++i)
    {
        for(int j = 1; j <= t.size(); ++j)
        {
            if(s[i-1] == t[j-1])f[i][j] = f[i-1][j-1] + 1;
            else f[i][j] = max(f[i-1][j] , f[i][j-1]);
        }
    }
    //cout << f[s.size()][t.size()];
    trace(s.size() , t.size());
    return 0;
}


Compiler output:
a.cc: In function 'void trace(int, int)':
a.cc:11:35: error: lvalue required as left operand of assignment
   11 |     if(f[i][j] == f[i-1][j-1] + 1 && f[i-1][j] + 1= f[i][j] && f[i][j-1] + 1 == f[i][j])
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e9
// Parent pointer's concept with 2d suffix dp
//dp[i][j] - till i-1th char and j-1th char - max lcs found
//p[i][j] - parent of dp[i][j] - so basically from which cell of dp I came to i,j
//going from i,j to i+1,j nd stuff not oworking out for me--> back to basics
string solnF(string& a,string& b){
	int n1 = a.length(),n2 = b.length();
	// cout<<endl<<a<<endl<<b<<endl;
	vector<vector<int> > dp(n1+1,vector<int>(n2+1,0));
	vector<vector< pair<int,int> > > p(n1+1,vector< pair<int,int> >(n2+1));
	// dp[0][0]
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			if(a[i-1]==b[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
				p[i][j] = make_pair(i-1,j-1);
			}	
			else if(dp[i][j-1]>dp[i-1][j]){
				dp[i][j] = dp[i][j-1];
				p[i][j] = make_pair(i,j-1);
			}
			else{
				dp[i][j] = dp[i-1][j];
				p[i][j] = make_pair(i-1,j);
			}
			// cout<<i<<" "<<j<<" "<<dp[i][j]<<" - "<<p[i][j].first<<" "<<p[i][j].second<<endl;
		}
	}
	//dp[n1][n2] is length of lcs
	string str;
	pair<int,int> cur = make_pair(n1,n2);
	pair<int,int> prev = p[n1][n2];
	// int count = 50;
	while(cur.first&&cur.second){
		// cout<<"KK";
		// cout<<cur.first<<" "<<cur.second<<endl;
		// cout<<prev.first<<" "<<prev.second<<endl;
		if(cur == make_pair(prev.first+1,prev.second+1)){
			str.push_back(a[prev.first]);
		}
		cur = prev;
		prev = p[prev.first][prev.second];
		// count--;
	}
	reverse(str.begin(),str.end());
	return str;
}

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