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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: conversion from 'long long int*' to 'long unsigned int' in a converted constant expression
    9 |          ll dp[n+1][w+1];
      |                     ~^~
a.cc:9:22: error: could not convert '(((long long int*)(& w)) + 8)' from 'long long int*' to 'long unsigned int'
    9 |          ll dp[n+1][w+1];
      |                     ~^~
      |                      |
      |                      long long int*
a.cc:9:22: error: size of array 'dp' has non-integral type 'long long int*'
a.cc:22:21: error: invalid types 'long long int [1][long long int [(n + 1)]]' for array subscript
   22 |          cout<<dp[n][w];
      |                     ^
Language: C++

N, W = map(int, input().split())
wt, val = [], []
for i in range(N):
	w,v = map(int, input().split())
	wt.append(v)
	val.append(w)

K = [[0 for x in range(W+1)] for y in range(N+1)]

for i in range(N+1):
	for w in range(W+1):
		if i == 0 or w == 0:
			K[i][w] = 0
		elif wt[i-1] <= w:
#			print("ayo")
			K[i][w] = max(val[i-1]+K[i-1][w-wt[i-1]], K[i-1][w])
		else:
			K[i][w] = K[i-1][w]
print(K[N][W])

Compiler output:
a.cc:15:25: error: invalid preprocessing directive #print
   15 | #                       print("ayo")
      |                         ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N, W = map(int, input().split())
      | ^
Language: C++

#if LOCAL_ENVIRONMENT == 1
#include "debug.hpp"
#endif
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
 
int main()
{
#if LOCAL_ENVIRONMENT == 1
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  ll N = input();
  ll W = input();
 
  vector<ll> weight;
  vector<ll> value;
  
  for(ll i=0;i<N;i++){
    ll w = input();
    ll v = input();
    weight.push_back(w);
    value.push_back(v);
  }
 
  vector<vector<ll>> dp(N+1, vector<ll>(W+1));
 
  for(int w=0;w<=W;w++){
    dp[0][w] = 0;
  }
 
  for(int i=0;i<N;i++){
    for(int w=0;w<=W;w++){
      if(weight[i] <= w){
        dp[i+1][w] = max(dp[i][w], dp[i][w-weight[i]] + value[i]);
      }
      else{
        dp[i+1][w] = dp[i][w];
      }
    }
  }

  debugDPTable(dp);
 
  output(dp[N][W]);
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:3: error: 'debugDPTable' was not declared in this scope
   54 |   debugDPTable(dp);
      |   ^~~~~~~~~~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:27:21: error: 'j' was not declared in this scope
   27 |             dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
      |                     ^
a.cc: At global scope:
a.cc:30:5: error: 'cout' does not name a type
   30 |     cout << dp[n][w] << endl;
      |     ^~~~
a.cc:31:5: error: expected unqualified-id before 'return'
   31 |     return 0;
      |     ^~~~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int weight[110];
int value[110];
int dp[110][110000];

int main()
{
  int n, w;
  cin >> n >> w;
  rep(i, n)
  {
    cin >> weight[i] >> value[i];
  }

  rep(i, n)
  {
    rep(j, w)
    {
      if (weight[i] <= w && w - weight[i] >= 0)
        dp[i][j] = max(dp[i - 1][j], dp[j - weight[i]] + value[i]);
    }
  }
  int ans = 0;
  rep(i, n)
  {
    rep(j, w)
        ans = max(ans, dp[i][j]);
  }
  cout << ans;
  return 0;
}

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

#include<iostream>
using namespace std;
const int N=1e5+5,M=1e9+5;
long long n,w;
long long v[M],wi[N];
long long dp[105][N];
int main()
{
	cin>>n>>w;
	for(int i=0;i<w;i++)
	{
		cin>>v[i]>>wi[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(i==0 && j>=wi[i])
			{
				dp[i][j]=v[i];
			}
			else if(j>=wi[i])
			{
				dp[i][j]=max(dp[i][j-1],dp[i-1][j-wi[i]]+v[i]);
			}
			else
			{
				dp[i][j]=dp[i][j-1];
			}
		}
	}
	cout<<dp[n][w];
}

Compiler output:
/tmp/ccePezmP.o: in function `main':
a.cc:(.text+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `wi' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `wi' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x11d): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `wi' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `wi' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x190): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x1da): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x26a): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccePezmP.o
a.cc:(.text+0x2c9): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

/*const int maxn=1e6;
int dp[maxn];
int h[maxn];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=1;i<n;i++)
    {
        dp[i]=1e9;
        for(int j=1;j<=min(i,k);j++)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout<<dp[n-1];

    return 0;
}*/
/*const int maxn=1e5;
int a[maxn][3];
int dp[maxn][3];
int main()
{
    int n;
    cin>>n;
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i-1][j];
        }
        dp[i][0]=a[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i-1][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}*/

const int maxn=110;
long long a[maxn][2];
const int maxx=1e5+10;
long long dp[maxn][maxx];

int main()
{
    long long n,w;
    cin>>n>>w;
    for(long long i=1;i<=n;i++)
    {
        for(long long j=0;j<2;j++)
        {
            cin>>a[i-1][j];
        }
        for(int j=0;j<1e5+10;j++)
        {
            if(j-a[i-1][0]>=0)
                dp[i][j]=max(dp[i-1][j],(a[i-1][1]+dp[i-1][j-a[i-1][0]]));
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return 0;
}

int main()
{

    return 0;
}











Compiler output:
a.cc:76:5: error: redefinition of 'int main()'
   76 | int main()
      |     ^~~~
a.cc:54:5: note: 'int main()' previously defined here
   54 | int main()
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,w;
  cin>>n>>w;
  vll w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  vvll dp(101,vll(100010));
  for(int i=0;i<n;i++){
    for(int j=0;j<100010;j++){
      if(w[i]>=j){
        dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }
      else dp[i+1][j]=dp[i][j];
    }
  }
  COUT(dp[n][w]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:7: error: conflicting declaration 'vll w'
   43 |   vll w(n),v(n);
      |       ^
a.cc:41:8: note: previous declaration as 'long long int w'
   41 |   ll n,w;
      |        ^
a.cc:44:18: error: invalid types 'long long int[long long int]' for array subscript
   44 |   rep(i,n) cin>>w[i]>>v[i];
      |                  ^
a.cc:48:11: error: invalid types 'long long int[int]' for array subscript
   48 |       if(w[i]>=j){
      |           ^
a.cc:49:33: error: invalid types 'long long int[int]' for array subscript
   49 |         dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      |                                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long dp[1001][1000001],a[10001],b[10001],i,j,n,w;
long long cal(long long i, long long j)
{
    if (i>n)  return 0;
    if (dp[i][j]!=-1) return dp[i][j];
    else dp[i][j]=0;
    if (j+a[i]<=w) dp[i][j]=max(cal(i+1,j),cal(i+1,j+a[i])+b[i]);
    else dp[i][j]=cal(i+1,j);
    return dp[i][j];
}
int main()
{
    cin>>n>>w;
    for (i=1;i<=n;i++) cin>>a[i]>>b[i];
    for (i=1;i<=n;i++)
        for (j=0;j<=1000000;j++)
        dp[i][j]=-1;
    cout<<cal(1,0);
}


Compiler output:
/tmp/ccnZUgzQ.o: in function `cal(long long, long long)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0xb4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0xc6): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0xe2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0x113): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccnZUgzQ.o
/tmp/ccnZUgzQ.o: in function `main':
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0x200): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0x212): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccnZUgzQ.o
a.cc:(.text+0x24d): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
  int N, W; cin >> N >> W;
  int w[N],v[N]; REP(i,N) cin >> w[i] >> v[i];

  int dp[N+1][W+1];
  REP(i,N+1) REP(j,W+1) dp[i][j] = 0;

  REP(i,N) {
    REP(j,W+1) {
      dp[i+1][j] = dp[i][j];
      if (j-w[i] >= 0) 
        dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
      }
    }
  }
  cout << dp[N][W] << endl;
}

Compiler output:
a.cc:21:3: error: 'cout' does not name a type
   21 |   cout << dp[N][W] << endl;
      |   ^~~~
a.cc:22:1: error: expected declaration before '}' token
   22 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define rrep(n,i) for(int i = n-1; i>=0; --i)
#define PI 3.14159265
#define INF 1e9
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
	int n,w; cin >>n >> w;
	vector<int> h(n),we(n); 
	rep(i,n){
		cin >> h[i] >> we[i];
	}	

	vector<vector<ll>> dp(n+1,vector<ll> (w+1));

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



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

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:80: error: invalid types 'int[int]' for array subscript
   28 |                                 dp[i+1][j] = max(dp[i+1][j],dp[i+1][j-h[i]] + w[i]);
      |                                                                                ^
Language: C

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	ll n, W;
	ll weight[110], value[110];
	cin >> n >> W;
	rep(i, n)scanf("%d%d", &weight[i], &value[i]);
	ll dp[110][100010];
	rep(w, W + 1)dp[0][w] = 0;
	rep(i, n) {
		rep(w, W + 1) {
			if (w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i + 1][w]);
			else dp[i + 1][w] = dp[i][w];
		}
	}
	cout << dp[n][W];
}



Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: Java

class Main {
    // dp
    public static long knapsack1(int[] w, long[] v, int C) {
        int n = w.length;
        long[][] dp = new long[n][C+1];
 
        for (int c = 1; c <= C; c++) {
            dp[0][c] = (c >= w[0]) ? v[0] : 0;
        }
 
        for (int i = 1; i < n; i++) {
            for (int c = 1; c <= C; c++) {
                dp[i][c] = dp[i-1][c];
                if (c >= w[i]) {
                    dp[i][c] = Math.max(dp[i][c], v[i] + dp[i-1][c-w[i]]);
                }
            }
        }
 
        return dp[n-1][C];
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int C = in.nextInt();
 
        int[] w = new int[N];
        long[] v = new long[N];
        for (int i = 0; i < N; i++) {
            w[i] = in.nextInt();
            v[i]  = in.nextLong();
        }
        in.close();
 
        // call function hear
        long ret = knapsack1(w, v, C);
        System.out.println(ret);
    }
}

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

3 8
3 30
4 50
5 60
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
6 15
6 5
5 6
6 4
6 6
3 5
7 2


Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 3 8
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e5 + 50;
const int INF = 1e9;

int w[MAXN], val[MAXN];
int dp[150][MAXN];
int cap, n;

int solve(int id, int restou)
{
	if(id == n or restou < 0) return 0;
	if(dp[id][restou] != -1) return dp[id][restou];
	
	int ans = solve(id+1, restou);
	if(restou - w[id] >= 0)
	{
		int esc = solve(id+1, restou - w[id]);
		return dp[id][restou] = max(n_esc, esc+val[id]);
	}
	
	return dp[id][restou] = n_esc;
}



int32_t main()
{
	cin >> n >> cap;
	for(int i = 0; i < n; i++)
		cin >> w[i] >> val[i];
	memset(dp, -1, sizeof dp);
	cout << solve(0, cap) << '\n';
}

Compiler output:
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:20:45: error: 'n_esc' was not declared in this scope; did you mean 'esc'?
   20 |                 return dp[id][restou] = max(n_esc, esc+val[id]);
      |                                             ^~~~~
      |                                             esc
a.cc:23:33: error: 'n_esc' was not declared in this scope
   23 |         return dp[id][restou] = n_esc;
      |                                 ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
int w[105],v[105];
bool visited[105];
int dp[100005];
int32_t func(int s,int n)
{
    if(s<=0)
        return 0;
    if(dp[s]!=0)
        return dp[s];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(!visited[i]&&s>=w[i])
        {
            visited[i]=true;
            int ansi=v[i];
            ansi+=func(s-w[i],n);
            ans=max(ansi,ans);
            visited[i]=false;
        }
    }
    dp[s]=ans;
    return ans;
}

int main() {
	int n,s;
	cin>>n>>s;
	for (int i = 0; i < n ; i++) {
	    cin>>w[i]>>v[i];
	}
	cout<<func(s,n);
	
	return 0;
}

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

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 1e6 + 9;

int n, w, mx;
int a[N], b[i], ans[N];

bool dp[N];

main(){
  cin>> n>> w;
  for(int i = 1; i <= n; i++){
  	cin>> a[i]>> b[i];
  }
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
  	  for(int j = w; j >= 0; j--){
      	if(dp[j] == 1){
        	dp[j + a[i]] = 1;
          	ans[j + a[i]] = max(ans[j + a[i]], ans[j] + b[i]);
          	mx = ans[j + a[i]];
        }
      }
  }
  cout<< mx;
}

Compiler output:
a.cc:10:13: error: 'i' was not declared in this scope
   10 | int a[N], b[i], ans[N];
      |             ^
a.cc:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:22: error: 'b' was not declared in this scope
   17 |         cin>> a[i]>> b[i];
      |                      ^
a.cc:24:61: error: 'b' was not declared in this scope
   24 |                 ans[j + a[i]] = max(ans[j + a[i]], ans[j] + b[i]);
      |                                                             ^
Language: C++

#include <iostream>
using namespace std;
long long int max_val(int wt[],int val[],int n,int w)
{
	long long int i,j;
	long long int dp[n+1][w+1];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
		    if(i==0 || j==0)
		    dp[i][j]=0;
		    else if(wt[i-1]<=j)
		    dp[i][j]=max(dp[i-1][j-wt[i-1]]+val[i-1],dp[i-1][j]);
		    else
		    dp[i][j]=dp[i-1][j];
		}
	}
	return dp[n][w];
}
int main() {
    long long int n,w,i;
    cin>>n>>w;
    long long int val[n],wt[n];
    for(i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    cout<<max_val(wt,val,n,w);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:19: error: cannot convert 'long long int*' to 'int*'
   27 |     cout<<max_val(wt,val,n,w);
      |                   ^~
      |                   |
      |                   long long int*
a.cc:3:27: note:   initializing argument 1 of 'long long int max_val(int*, int*, int, int)'
    3 | long long int max_val(int wt[],int val[],int n,int w)
      |                       ~~~~^~~~
Language: C++

N, W = map(int, input().split())
weights, values = [0]*N, [0]*N
for i in range(N):
    weights[i], values[i] = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N)]
for j in range(W+1):
    dp[0][j] = values[0]
for i in range(1,N):
    for j in range(W+1):
        if j - weights[i] >=0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i]] + values[i])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[-1][-1])

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

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

Compiler output:
a.cc: In function 'long long int knap(long long int*, long long int*, int, long long int, long long int)':
a.cc:6:12: error: 'j' was not declared in this scope
    6 |   if(dp[i][j]!=-1)
      |            ^
a.cc:9:18: error: 'j' was not declared in this scope
    9 |     return dp[i][j]=0;
      |                  ^
a.cc:11:30: error: 'j' was not declared in this scope
   11 |                 return dp[i][j]=knap(w,v,i+1,n,W);
      |                              ^
a.cc:12:16: error: 'j' was not declared in this scope
   12 |   return dp[i][j]=max(v[i]+knap(w,v,i+1,n,W-w[i]),knap(w,v,i+1,n,W));
      |                ^
Language: C++

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

Compiler output:
a.cc: In function 'long long int knap(long long int*, long long int*, int, long long int, long long int)':
a.cc:6:12: error: 'j' was not declared in this scope
    6 |   if(dp[i][j]!=-1)
      |            ^
a.cc:9:18: error: 'j' was not declared in this scope
    9 |     return dp[i][j]=0;
      |                  ^
a.cc:11:30: error: 'j' was not declared in this scope
   11 |                 return dp[i][j]=knap(w,v,i+1,n,W);
      |                              ^
a.cc:12:16: error: 'j' was not declared in this scope
   12 |   return dp[i][j]=max(v[i]+knap(w,v,i+1,n,W-w[i]),knap(w,v,i+1,n,W));
      |                ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

const int maxn = 100+5;
const int inf = 0x3f3f3f3f;
const int maxm=1000+5;

long long a[maxn],t[maxn],f[maxm];

int main(){
	int n,m;
	cin>>n>>m;
    for(int i=1;i<=n;i++){
    	cin>>t[i]>>a[i];
    }
    for(int j=1;j<=m;j++){
    	f[j]=-inf;
    }
    f[0]=0;
    for(int i=1;i<=n;i++){
    	for(int j=m;j>=0;j--){
    		if(j>=t[i]){
    			f[j]=max(f[j],f[j-t[i]]+a[i]);
    		}	
    		}
    }
    int ret=-1;
    for(int j=0;j<=m;j++){
    	ret=max(ret,f[j]);
    }
cout<<ret <<endl;
return 0;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:16: error: no matching function for call to 'max(int&, long long int&)'
   31 |         ret=max(ret,f[j]);
      |             ~~~^~~~~~~~~~
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:31:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |         ret=max(ret,f[j]);
      |             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:31:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |         ret=max(ret,f[j]);
      |             ~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define INF 1e8
using namespace std;

int main() {
    
    int64_t N,W;
    cin >> N >> W;
    vector<int64_t,int64_t> A(N);
    for(int i=0; i<N i++){cin >> A[i];}
    vector<vector<int>> dp(N+1,vector<int>(W+1))
    for(int i=0;i<N;i++){
      for(int j=0; j<W;j++){
        if(A[i].second>j)dp[i+1][j]=0;
        else{dp[i+1][j]=max(dp[i][j],dp[i][j-A[i].second]);}}
    cout <<dp[N][W]<< endl;

}


Compiler output:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<long int, long int>':
/usr/include/c++/14/bits/stl_vector.h:428:11:   required from 'class std::vector<long int, long int>'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc:9:32:   required from here
    9 |     vector<int64_t,int64_t> A(N);
      |                                ^
/usr/include/c++/14/bits/stl_vector.h:87:28: error: 'long int' is not a class, struct, or union type
   87 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:89:9: error: 'long int' is not a class, struct, or union type
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<long int, long int>':
a.cc:9:32:   required from here
    9 |     vector<int64_t,int64_t> A(N);
      |                                ^
/usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<long int, long int>::_Base'
  518 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<long int, long int>::_Base'
  519 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<long int, long int>::_Base'
  521 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:10:21: error: expected ';' before 'i'
   10 |     for(int i=0; i<N i++){cin >> A[i];}
      |                     ^~
      |                     ;
a.cc:10:35: error: no match for 'operator[]' (operand types are 'std::vector<long int, long int>' and 'int')
   10 |     for(int i=0; i<N i++){cin >> A[i];}
      |                                   ^
a.cc:12:5: error: expected ',' or ';' before 'for'
   12 |     for(int i=0;i<N;i++){
      |     ^~~
a.cc:12:17: error: 'i' was not declared in this scope
   12 |     for(int i=0;i<N;i++){
      |                 ^
a.cc:18:2: error: expected '}' at end of input
   18 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define INF 1e8
using namespace std;

int main() {
    
    long long N,W;
    cin >> N >> W;
    
    vector<long long,long long> A(N);
    for(int i=0; i<N i++){cin >> A[i];}
    vector<vector<int>> dp(N+1,vector<int>(W+1))
    for(int i=0;i<N;i++){
      for(int j=0; j<W;j++){
        if(A[i].second>j)dp[i+1][j]=0;
        else{dp[i+1][j]=max(dp[i][j],dp[i][j-A[i].second]);}}
    cout <<dp[N][W]<< endl;

}


Compiler output:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<long long int, long long int>':
/usr/include/c++/14/bits/stl_vector.h:428:11:   required from 'class std::vector<long long int, long long int>'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc:10:36:   required from here
   10 |     vector<long long,long long> A(N);
      |                                    ^
/usr/include/c++/14/bits/stl_vector.h:87:28: error: 'long long int' is not a class, struct, or union type
   87 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:89:9: error: 'long long int' is not a class, struct, or union type
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<long long int, long long int>':
a.cc:10:36:   required from here
   10 |     vector<long long,long long> A(N);
      |                                    ^
/usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
  518 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
  519 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<long long int, long long int>::_Base'
  521 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:11:21: error: expected ';' before 'i'
   11 |     for(int i=0; i<N i++){cin >> A[i];}
      |                     ^~
      |                     ;
a.cc:11:35: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'int')
   11 |     for(int i=0; i<N i++){cin >> A[i];}
      |                                   ^
a.cc:13:5: error: expected ',' or ';' before 'for'
   13 |     for(int i=0;i<N;i++){
      |     ^~~
a.cc:13:17: error: 'i' was not declared in this scope
   13 |     for(int i=0;i<N;i++){
      |                 ^
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define INF 1e8
using namespace std;

int main() {
    
    long long N,W;
    cin >> N >> W;
    pair<long long,long long> P;
    vector<P> A(N);
    for(int i=0; i<N i++){cin >> A[i];}
    vector<vector<int>> dp(N+1,vector<int>(W+1))
    for(int i=0;i<N;i++){
      for(int j=0; j<W;j++){
        if(A[i].second>j)dp[i+1][j]=0;
        else{dp[i+1][j]=max(dp[i][j],dp[i][j-A[i].second]);}}
    cout <<dp[N][W]<< endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   10 |     vector<P> A(N);
      |             ^
a.cc:10:13: note:   expected a type, got 'P'
a.cc:10:13: error: template argument 2 is invalid
a.cc:11:21: error: expected ';' before 'i'
   11 |     for(int i=0; i<N i++){cin >> A[i];}
      |                     ^~
      |                     ;
a.cc:11:35: error: invalid types 'int[int]' for array subscript
   11 |     for(int i=0; i<N i++){cin >> A[i];}
      |                                   ^
a.cc:13:5: error: expected ',' or ';' before 'for'
   13 |     for(int i=0;i<N;i++){
      |     ^~~
a.cc:13:17: error: 'i' was not declared in this scope
   13 |     for(int i=0;i<N;i++){
      |                 ^
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define INF 1e8
using namespace std;

int main() {
    
    long long N,W;
    cin >> N >> W;
    pair<long long,long long> P
    vector<P> A(N)
    for(int i=0; i<N i++){cin >> A[i];}
    vector<vector<int>> dp(N+1,vector<int>(W+1))
    for(int i=0;i<N;i++){
      for(int j=0; j<W;j++){
        if(A[i].second>j)dp[i+1][j]=0;
        else{dp[i+1][j]=max(dp[i][j],dp[i][j-A[i].second]);}}
    cout <<dp[N][W]<< endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: expected initializer before 'vector'
   10 |     vector<P> A(N)
      |     ^~~~~~
a.cc:11:18: error: 'i' was not declared in this scope
   11 |     for(int i=0; i<N i++){cin >> A[i];}
      |                  ^
a.cc:13:5: error: expected ',' or ';' before 'for'
   13 |     for(int i=0;i<N;i++){
      |     ^~~
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define io ios_base::sync_with_stdio(false); cin.tie(0);

#define fs first
#define sc second
#define pb push_back

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef long double ld;

const ll LINF = 1e18;
const int INF = 1e9;
const ld EPS = 1e-9;
const int MOD = 1e9+7;

/// Scanf para ler char array separado por espacos -> scanf(" %[^\n]", texto);
 
////////////////////////// Solution starts below. //////////////////////////////

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

int main(){

	int n, W;
	scanf("%d %d", &n, &W);
	vll dp(W+1);
	for(int i =  0; i < n; i++){
		ll value, weight;
		scanf("%lld %lld", &value, &weight);
		for(int weight_now = W - weight; weight_now >= 0; weight_now--){
			change(dp[weight_now + weight], dp[weight_now] + value);
		}
	}
	ll ans = 0;
	for(int i = 0; i <= w; i++){
		change(ans, dp[i]);
	}
	printf("%lld\n", ans);


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   48 |                         change(dp[weight_now + weight], dp[weight_now] + value);
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:35:18: note:   initializing argument 1 of 'void change(int&, int)'
   35 | void change(int& a, int b){
      |             ~~~~~^
a.cc:52:29: error: 'w' was not declared in this scope
   52 |         for(int i = 0; i <= w; i++){
      |                             ^
a.cc:53:24: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   53 |                 change(ans, dp[i]);
      |                        ^~~
a.cc:35:18: note:   initializing argument 1 of 'void change(int&, int)'
   35 | void change(int& a, int b){
      |             ~~~~~^
Language: C++

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

struct item {
  int weight;
  int value;
};

int main() {
  int n, W;
  cin >> n >> W;
  
  int items[item], dp[n+1][W+1];
  memset(dp, 0, sizeof(dp));
  for(int i = 0; i < n; i++) cin >> items[i].weight >> items[i].value;
  
  for(int i = 1; i <= n; i++) {
    int weight = items[i].weight;
    int value  = items[i].value;
    for(int j = 1; j <= W; j++) {
      int maxValue = j <= weight ? max(dp[i-1][j], dp[i-1][j-weight] + value) : 0;
      dp[i][j] = max(dp[i][j], maxValue);
    }
  }
  
  cout << dp[n][W];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: expected primary-expression before ']' token
   13 |   int items[item], dp[n+1][W+1];
      |                 ^
a.cc:15:37: error: 'items' was not declared in this scope; did you mean 'item'?
   15 |   for(int i = 0; i < n; i++) cin >> items[i].weight >> items[i].value;
      |                                     ^~~~~
      |                                     item
a.cc:18:18: error: 'items' was not declared in this scope; did you mean 'item'?
   18 |     int weight = items[i].weight;
      |                  ^~~~~
      |                  item
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, w;
	cin>>n>>w;
	vector<int> val, wt;
	for(int i =0;i<n;i++){
		int kg ,p;
		cin>>kg>>p;
		wt.push_back(kg);
		val.push_back(p);
	}
	int dp[n+1][w + 1];
	memset(dp,0,sizeof(dp));
	for(int i =0;i<=n;i++)
	{
		for(int w =0; w <= W; w++)
		{
			if(i == 0 || w == 0)
				dp[i][w] = 0;
			else if(wt[i-1] <= w)
				dp[i][w] = max(dp[i-1][w], dp[i-1][w - wt[i-1]] + val[i-1]);
			else
				dp[i][w] = dp[i-1][w];
		}
	}
	cout<<dp[n][W]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:36: error: 'W' was not declared in this scope
   18 |                 for(int w =0; w <= W; w++)
      |                                    ^
a.cc:28:21: error: 'W' was not declared in this scope
   28 |         cout<<dp[n][W]<<endl;
      |                     ^
Language: C++

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

#define MAXN 123
#define INF 0x3f3f3f3f

long long int n, w, weight[MAXN], value[MAXN], memo[MAXN][MAXN];

long long int knap(int i, int carry){
    if(carry>w) return -INF;
    if(i==n) return 0;
    if(memo[i][carry]!=-1) return memo[i][carry];

    return memo[i][carry] = max(knap(i+1, carry), knap(i+1, carry+weight[i])+value[i]);
}

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

    for(int i=0;i<n;i++){
        cin >> weight[i] >> value[i];
    }

    memset(memo, -1, sizeof memo);

    cout << knap(0, 0) << endl;
}


Compiler output:
a.cc:17:5: error: 'cin' does not name a type
   17 |     cin >> n >> w;
      |     ^~~
Language: C++

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

int main(){
  int n,w;
  int dp[w];
  cin>>n>>w;
  int wi,vi;
  for(int i = 0; i < n; i++){
	cin >>  wi >> vi;
	for(int w_cur = W-wi; w_cur >= 0; w_cur--)
		dp[w_cur + wi] = max(dp[w_cur + wi], dp[w_cur] + vi);
  }
  int ans = 0;
  for(int i:dp)
    if(i>ans){ans = i;}
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: 'W' was not declared in this scope
   15 |         for(int w_cur = W-wi; w_cur >= 0; w_cur--)
      |                         ^
Language: C++

#include <iostream>
using namespace std;

int knapsack(int W, int wt[],int v[],int n)
{
	if(n==0 || W==0)
	return 0;
	else if(wt[n-1]>W)
	return knapsack(W,wt,v,n-1);
	else return max(v[n-1]+knapsack(W-wt[n-1],wt,v,n-1),knapsack(W,wt,v,n-1));
}

int main() {
	int n,W;
	cin>>n>>W;
	long long int wt[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>v[i];
	}
	cout<<knapsack(W,wt,v,n);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: cannot convert 'long long int*' to 'int*'
   21 |         cout<<knapsack(W,wt,v,n);
      |                          ^~
      |                          |
      |                          long long int*
a.cc:4:25: note:   initializing argument 2 of 'int knapsack(int, int*, int*, int)'
    4 | int knapsack(int W, int wt[],int v[],int n)
      |                     ~~~~^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i,j,k,W,w,v;
	
	cin>>n>>W;
	int dp[W+1]={0};
	for(i=0;i<n;i++)
	{
		cin>>w>>v;
		for(j=W-w;j>=0;j--)
		{
			dp[j+w]=max(dp[j+w],dp[j]+v);
		//	cout<<j+w<<" "<<dp[j+w]<<endl;
		}
	}
	k=0;
	for(i=0;i<W+1;i++)
	{
		k=max(k,dp[i]);
	}
	cout<<k;
	return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
int n;
int dp[10000][10000]={-1};
int knap(int index,int w,int wt[],int val[])
{ int ans=0;
    if(w==0)
    {
        return 0;
        
    }
     if(index>=n)
   {
       return 0;
       
   }
     if(w<0)
    {
        return -val[index];
    }
    if(dp[index][w]>=0)
    {
        return dp[index][w];
    }
   
    else
    {
        ans=max(val[index]+knap(index+1,w-wt[index],wt,val) ,knap(index+1,w,wt,val));
        return dp[index][w]=ans;
    }
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,w;
    cin>>n>>w;
    int wt[n];
    int val[n];
   // int dp[n][n]={-1};
   int index=0;
    cout<<knap( index, w,wt,val);
}

Compiler output:
g++: internal compiler error: File size limit exceeded signal terminated program as
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,W;
  cin>>n>>W;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<W;j++)
    {
      cin>>a[i][j];
    }
  }
int K[n+1][W+1]; 
for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   }
  cout<<K[n][W]<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'a' was not declared in this scope
   11 |       cin>>a[i][j];
      |            ^
a.cc:15:6: error: 'i' was not declared in this scope
   15 | for (i = 0; i <= n; i++)
      |      ^
a.cc:17:13: error: 'w' was not declared in this scope
   17 |        for (w = 0; w <= W; w++)
      |             ^
a.cc:21:21: error: 'wt' was not declared in this scope
   21 |            else if (wt[i-1] <= w)
      |                     ^~
a.cc:22:32: error: 'val' was not declared in this scope
   22 |                  K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
      |                                ^~~