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

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



int main()
{
	int n,W;
	cin >> n >> W;
	int w[n], v[n];

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

	int res = 0;
	for (int b = 0; b < (1<<n); b++) {
		long long sw=0,sv=0;
		for (int i = 0; i < n; i++) {
			if (b&(1<<i)){
				sw += w[i];
				sv += v[i];
			}
		}
		if(sw<=W)
			res = max(res,sv);
	}

	cout << res << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:34: error: no matching function for call to 'max(int&, long long int&)'
   27 |                         res = max(res,sv);
      |                               ~~~^~~~~~~~
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:27:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |                         res = max(res,sv);
      |                               ~~~^~~~~~~~
/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:27:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |                         res = max(res,sv);
      |                               ~~~^~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:24: error: lvalue required as increment operand
   19 |     for(int j=0;j<w+1lj++)
      |                        ^~
a.cc:19:26: error: expected ';' before ')' token
   19 |     for(int j=0;j<w+1lj++)
      |                          ^
      |                          ;
a.cc:21:36: error: 'a' was not declared in this scope
   21 |       dp[i][j]=max(dp[i][j-1],dp[i-a[j]][j-1]+v[i]);
      |                                    ^
Language: C++


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

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


Compiler output:
a.cc: In function 'int main()':
a.cc:97:25: error: expected ';' before 'if'
   97 |    dp[i][j] = dp[i-1][j]
      |                         ^
      |                         ;
   98 |    if(j >= w[i]) dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i][j]);
      |    ~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e3) + 5;
const long long int M = ((long long int)1e5) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli n;
lli W;
lli weight[N];
lli value[N];

lli dp[N][M];

lli f(lli i, lli curw)
{
	if (dp[i][curw] != -1)
		return dp[i][curw];
	if (i > n)
	{
		if (curw > W)
				return -llinf;
		return 0;
	}
	lli t1 = f(i + 1,curw + weight[i]) + value[i];
	lli t2 = f(i + 1,curw);
	return dp[i][curw] = max(t1,t2);
}

int main ()
{
	fast;
	//freop;
	cin >> n >> W;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++)
	{
		lli a,b;
		cin >> a >> b;
		weight[i] = a;
		value[i] = b;
	}
	cout << max(f(1,0),0) << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:20: error: no matching function for call to 'max(lli, int)'
   52 |         cout << max(f(1,0),0) << "\n";
      |                 ~~~^~~~~~~~~~
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:52:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   52 |         cout << max(f(1,0),0) << "\n";
      |                 ~~~^~~~~~~~~~
/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:52:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |         cout << max(f(1,0),0) << "\n";
      |                 ~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll w[100000];
ll v[100000];
ll c[100001][100001];
ll n,m;
ll backpack(int x,int y){
	if(x==0) return 0;
	if(c[x][y]) return c[x][y];
	if(w[x-1]<=y) c[x][y]=max(backpack(x-1,y-w[x-1])+v[x-1],backpack(x-1,y));
	else c[x][y]=backpack(x-1,y);
	return c[x][y];
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<backpack(n,m)<<endl;
}

Compiler output:
/tmp/cci5PVH6.o: in function `main':
a.cc:(.text+0x1db): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cci5PVH6.o
a.cc:(.text+0x1f7): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cci5PVH6.o
a.cc:(.text+0x26a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cci5PVH6.o
a.cc:(.text+0x276): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cci5PVH6.o
a.cc:(.text+0x27f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cci5PVH6.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll w[100000];
ll v[100000];
ll c[100001][100001];
ll n,m;
ll backpack(int x,int y){
	if(x==0) return 0;
	if(c[x][y]) return c[x][y];
	if(w[x-1]<=y) c[x][y]=max(backpack(x-1,y-w[x-1])+v[x-1],backpack(x-1,y));
	else c[x][y]=backpack(x-1,y);
	return c[x][y];
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<backpack(n,m)<<endl;
}


Compiler output:
/tmp/ccAI6Ab9.o: in function `main':
a.cc:(.text+0x1db): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccAI6Ab9.o
a.cc:(.text+0x1f7): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccAI6Ab9.o
a.cc:(.text+0x26a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccAI6Ab9.o
a.cc:(.text+0x276): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccAI6Ab9.o
a.cc:(.text+0x27f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccAI6Ab9.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //?index
#define all(x) (x).begin(),(x).end()
#define put(x) cout << x << endl;
const int INF = 1000000007;  //MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD
ll dp[110][100010] = {0};
int main(){
    long long n,w;
    cin >> n >> w;
    vector<ll>W(110),V(110);
    rep0(ii,n)cin >> W[ii] >> V[ii];
    rep0(i,n){
        rep0(j,w + 1){
            if(j - W[i] >= 0)chmax(dp[i + 1][j],dp[i][j - W[i]] + V[i]);
            else chmax(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
    return 0;
} 

Compiler output:
a.cc: In function 'bool chmin(T&, T)':
a.cc:12:20: error: a function-definition is not allowed here before '{' token
   12 | ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD
      |                    ^
a.cc:14:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   14 | int main(){
      |         ^~
a.cc:14:9: note: remove parentheses to default-initialize a variable
   14 | int main(){
      |         ^~
      |         --
a.cc:14:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:14:11: error: a function-definition is not allowed here before '{' token
   14 | int main(){
      |           ^
a.cc:27:2: error: expected '}' at end of input
   27 | }
      |  ^
a.cc:11:48: note: to match this '{'
   11 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }
      |                                                ^
Language: C

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

int dp [105][10010];
 
int main() {

    int n,W;
    int v[105];
    int w[105];

    cin>>n>>W;
    rep(i,n)    cin>>w[i]>>v[i];

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

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

 return 0;
}

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

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

int dp [105][10010];
 
int main() {

    int n,w;
    int v[105];
    int w[105];

    cin>>n>>w;
    rep(i,n)    cin>>w[i]>>v[i];

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

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

 return 0;
}

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

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

int dp [105][105];
 
int main() {

    int n,w;
    int v[105];
    int w[105];

    cin>>n>>w;
    rep(i,n)    cin>>w[i]>>v[i];

    rep(i,n) {
        rep(sum_w,w) {
            if(sum_w>=w[i]) dp[i+1][sum_w]=max(dp[i][sum_w-w[i]]+v[i],dp[i][w]);
            else dp[i+1][sum_w]=dp[i][sum_w];
        }
    }

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

 return 0;
}

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

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

ll N, weight_limit;

int weight[107];
int cost[107];

ll dp[107][10000007]; ///for dp
bool vis[107][107]; ///for dp

ll dfs(int pos, ll koto_weight)
{
    if (pos >= N) return 0;
    if (vis[pos][koto_weight]) return dp[pos][koto_weight]; ///for dp
    vis[pos][koto_weight] = 1; ///for dp

    ll p = 0, q = 0;
    if (koto_weight + (ll)weight[pos] <= weight_limit) p = dfs(pos+1, koto_weight+(ll)weight[pos]) + (ll)cost[pos];
    q = dfs(pos+1, koto_weight);

    return dp[pos][koto_weight] = max(p, q); ///for dp
}

int main()
{
    cin >> N >> weight_limit;
    for (int i = 0; i < N; i++) cin >> weight[i] >> cost[i];

    ll ans = dfs(0, 0);
    cout << ans << "\n";
}


Compiler output:
/tmp/cceIjWBJ.o: in function `dfs(int, long long)':
a.cc:(.text+0x3e): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cceIjWBJ.o
a.cc:(.text+0x8a): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cceIjWBJ.o
collect2: error: ld returned 1 exit status
Language: Java

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

public class Knapsack {

    static int N, W;
    static int[] w;
    static int[] v;
    static Long[][] memo;

    static long dp(int idx, int rem) {
        if(idx == N) return 0;
        if(memo[idx][rem] != null) return memo[idx][rem];
        long ans = 0;
        if(rem - w[idx] >= 0)
            ans = v[idx] + dp(idx + 1, rem - w[idx]);
        ans = Math.max(ans, dp(idx + 1, rem));
        return ans;
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        w = new int[N];
        v = new int[N];
        memo = new Long[N][W + 1];
        for(int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        System.out.println(dp(0, W));
    }
}


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

package com.demo;

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

public class Knapsack {

    static int N, W;
    static int[] w;
    static int[] v;
    static Long[][] memo;

    static long dp(int idx, int rem) {
        if(idx == N) return 0;
        if(memo[idx][rem] != null) return memo[idx][rem];
        long ans = 0;
        if(rem - w[idx] >= 0)
            ans = v[idx] + dp(idx + 1, rem - w[idx]);
        ans = Math.max(ans, dp(idx + 1, rem));
        return ans;
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        w = new int[N];
        v = new int[N];
        memo = new Long[N][W + 1];
        for(int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        System.out.println(dp(0, W));
    }
}


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

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
ll dp[200][100500]={};
ll min(ll a,ll b){
  if(a<b)return a;
  else return b;
}
ll inf=100000000000;
void main(){
  int n;
  ll sup;
  cin>>n>>sup;
  vector<ll> v(n+5);
  vector<ll> w(n+5);
  for(int i=1;i<=n;i++){
    cin>>w[i]>>v[i];
  }
  dp[0][0]=0;
  for(ll i=1;i<100500;i++){
    dp[0][i]=inf;
  }
  for(ll i=1;i<=n;i++){
    //    dp[i][v[i]]=min(dp[i-1][v[i]],w[i]);
    for(ll j=1;j<10001;j++){
      if(j>=v[i]){
	dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
      }
      else dp[i][j]=dp[i-1][j];
    }
  }
  ll ans=0;
  for(ll i=100000;i>0;i--){
    if(dp[n][i]<=sup){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc:13:1: error: '::main' must return 'int'
   13 | void main(){
      | ^~~~
Language: C++

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

#define ll long long int
const int N = 102,W = 1e10+2;
int n,w;
ll weight[W],value[N], dp[N][W];

ll solve(ll i,ll j){
    if(j < 0)
        return -W;
    else if(i < 0)
        return 0;
    else if(dp[i][j] != -1)
        return dp[i][j];
    dp[i][j] = max(value[i] + solve(i-1,j-weight[i]),solve(i-1,j));
    return dp[i][j];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> w;
    for(int i=0;i<n;i++){
        int j,k;
        cin >> j >> k;
        weight[i] = j;
        value[i] = k;
    }
    memset(dp,-1,sizeof(dp));
    cout << solve(n-1,w) << '\n';

    return 0;
}

Compiler output:
a.cc:5:27: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000002e+10' to '2147483647' [-Woverflow]
    5 | const int N = 102,W = 1e10+2;
      |                       ~~~~^~
a.cc:7:11: error: size of array 'weight' exceeds maximum object size '9223372036854775807'
    7 | ll weight[W],value[N], dp[N][W];
      |           ^
a.cc:7:30: error: size of array 'dp' exceeds maximum object size '9223372036854775807'
    7 | ll weight[W],value[N], dp[N][W];
      |                              ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:74: error: expected ')' before ';' token
   19 |       dp.at(i +1).at(j)=max(dp.at(i).at(j-w.at(i))+v.at(i),dp.at(i).at(j);
      |                            ~                                             ^
      |                                                                          )
Language: C++

// A Dynamic Programming based solution for 0-1 Knapsack problem 
#include<stdio.h> 

// 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) 
{ 
int i, w; 
int K[n+1][W+1]; 

// Build table K[][] in bottom up manner 
for (i = 0; i <= n; i++) 
{ 
	for (w = 0; w <= W; w++) 
	{ 
		if (i==0 || w==0) 
			K[i][w] = 0; 
		else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
		else
				K[i][w] = K[i-1][w]; 
	} 
} 

return K[n][W]; 
} 

int main() 
{ 
	long long int val[101]; 
	long long int wt[101]; 
	int n,W;
  	cin>>n>>W;
  	int c=n;
  int i=0,j=0;
  	while(c--){
    cin>>wt[i++]>>val[j++];
    }
	
	printf("%d", knapSack(W, wt, val, n)); 
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'cin' was not declared in this scope
   35 |         cin>>n>>W;
      |         ^~~
a.cc:42:34: error: cannot convert 'long long int*' to 'int*'
   42 |         printf("%d", knapSack(W, wt, val, n));
      |                                  ^~
      |                                  |
      |                                  long long int*
a.cc:8:25: note:   initializing argument 2 of 'int knapSack(int, int*, int*, int)'
    8 | int knapSack(int W, int wt[], int val[], int n)
      |                     ~~~~^~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end() 
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout  
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ull MOD = 1e9 + 7;
const int N = (int)(5e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}
void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, k;
ll dp[N][101], w[101], v[101];

ll rec(int cur,int idx)
{
	if (cur < 0)return -1e9;
	if (idx == n) return (cur >= 0 ? 0 : -1e9);
	ll& dp = ::dp[cur][idx];
	if (~dp)return dp;

	dp = rec(cur - w[idx], idx + 1) + v[idx];
	dp = max(dp, rec(cur, idx + 1));
	return dp;
}

int main()
{
	inp();
	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", w + i, v + i);
	}

	memset(dp, -1, sizeof(dp));

	printf("%lld", rec(k, 0));
}

Compiler output:
a.cc: In function 'void inp()':
a.cc:56:9: error: 'freopen_s' was not declared in this scope; did you mean 'freopen64'?
   56 |         freopen_s(&stream, "inp.txt", "r", stdin);
      |         ^~~~~~~~~
      |         freopen64
a.cc: In function 'void out()':
a.cc:63:9: error: 'freopen_s' was not declared in this scope; did you mean 'freopen64'?
   63 |         freopen_s(&stream, "out.txt", "w", stdout);
      |         ^~~~~~~~~
      |         freopen64
a.cc: In function 'int main()':
a.cc:43:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   43 | #define scanf scanf_s
      |               ^~~~~~~
a.cc:103:17: note: in expansion of macro 'scanf'
  103 |                 scanf("%d%d", w + i, v + i);
      |                 ^~~~~
Language: C++

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define sec second
#define fori(i, a, b) for(int i = int(a); i < int(b); i++)
#define cc(x)	cout << #x << " = " << x << endl
#define ok		cout << "ok" << endl

typedef pair<int,int> ii;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const int N = 1e5 + 10;
int n, w; 
int dp[N][N];
int size[N], value[N];

int pog(int at, int cap){
	if(at >= n) return 0;
	if(cap < 0) return -INF;

	int &r = dp[at][cap];
	if(r != -1) return r;

	return r = max(pog(at+1, cap), pog(at+1, cap-size[at]) + value[at]);
}

int main(){
	ios_base::sync_with_stdio(false);
	
        memset(dp, -1, sizeof dp);
	cin >>n >>w;

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

	cout <<pog(0, w) <<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int pog(int, int)':
a.cc:30:54: error: reference to 'size' is ambiguous
   30 |         return r = max(pog(at+1, cap), pog(at+1, cap-size[at]) + value[at]);
      |                                                      ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:5: note:                 'int size [100010]'
   21 | int size[N], value[N];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:40:23: error: reference to 'size' is ambiguous
   40 |                 cin >>size[i] >>value[i];
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:5: note:                 'int size [100010]'
   21 | int size[N], value[N];
      |     ^~~~
Language: C++

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define sec second
#define fori(i, a, b) for(int i = int(a); i < int(b); i++)
#define cc(x)	cout << #x << " = " << x << endl
#define ok		cout << "ok" << endl

typedef pair<int,int> ii;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const int N = 1e5 + 10;
int n, w; 
int dp[N][N];
int size[N], value[N];

int pog(int at, int cap){
	if(at >= n) return 0;
	if(cap < 0) return -INF;

	int &r = dp[at][cap];
	if(r != -1) return r;

	return r = max(pog(at+1, cap), pog(at+1, cap-size[at]) + value[at]);
}

int main(){
	ios_base::sync_with_stdio(false);
	
  memset(dp, -1, sizeof dp);
	cin >>n >>w;

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

	cout <<pog(0, w) <<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int pog(int, int)':
a.cc:30:54: error: reference to 'size' is ambiguous
   30 |         return r = max(pog(at+1, cap), pog(at+1, cap-size[at]) + value[at]);
      |                                                      ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:5: note:                 'int size [100010]'
   21 | int size[N], value[N];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:40:23: error: reference to 'size' is ambiguous
   40 |                 cin >>size[i] >>value[i];
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:5: note:                 'int size [100010]'
   21 | int size[N], value[N];
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define endl "\n"
using namespace std;
int arr[105][100005];
int main()
{
 ll s[1000][2]={0};
  ll n,w;cin>>n>>w;
    for(ll i=0;i<n;i++)
    {
        cin>>s[i][0]>>s[i][1];
    }
      
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
            {
                arr[i][j]=0;
            }
            else{
            if(s[i-1][0]<=j)
            {
                arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
            }
            else

            {
                arr[i][j]=arr[i-1][j];
            }
            }
        }
    }
    cout<<arr[n][w]<<endl;;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:30: error: no matching function for call to 'max(int&, long long int)'
   28 |                 arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:28:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   28 |                 arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:28:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |                 arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
void f(vector<int>&w, vector<int>&p, int weight){
	    int n = w.size();
		  int dp[n][weight+1];
		    memset(dp, 0, sizeof(dp));
		    for(int i=0; i<n; i++ ){
			        dp[i][0] = 0;
				  
		    }
		    for(int j=1; j<weight+1; j++){
			    if(w[0] >= j){
				          dp[0][j] = p[0];
					      
			    }
			      
		    }
		    for(int i=1; i<n; i++){
			    for(int j=1; j<weight+1; j++){
				    if(j-w[i] >= 0){
					            dp[i][j] = max(p[i] + dp[i-1][j-w[i]], dp[i-1][j]);
						          
				    }else {
					            dp[i][j] = dp[i-1][j];
						          
				    }
				        
			    }
			      
		    }
		      cout << dp[n-1][weight] << endl;
		      
}
int main(){
	int n;
	int weight;
	cin >> n;
	cin >> weight;
	vector<int>w;
	int weight_val;
	int profit_val;
	vector<int>p;
	for(int i=0; i<n ;i++){
			cin >> weight_val;
				w.push_back(weight);
					cin >> profit_val;
						p.push_back(profit);
						
	}
	f(w,p, weight);
	return 0;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:61: error: 'profit' was not declared in this scope; did you mean 'profil'?
   47 |                                                 p.push_back(profit);
      |                                                             ^~~~~~
      |                                                             profil
Language: C++

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

int N, W, w[110], v[110], dp[110][100010];
int main(){
  cin>>N >>W;
  
  for(int i=0;i<N;i++)cin>>w[i] >>v[i];
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i])continue;
      dp[i+1][j]=max(dp[i+1][j], dp[i][j-w[i]]+v[i]):
    }
  }
  
  cout<<dp[N][W]<<endl;
  return 0;
}

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

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

int N, W, w[110], v[110], dp[110][100010];
int main(){
  cin>>N >>W;
  
  for(int i=0;i<N;i++)cin>>w[i] >>v[i];
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i])continue;
      dp[i+!][j]=max(dp[i+1][j], dp[i][j-w[i]]+v[i]):
    }
  }
  
  cout<<dp[N][W]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: expected primary-expression before ']' token
   13 |       dp[i+!][j]=max(dp[i+1][j], dp[i][j-w[i]]+v[i]):
      |             ^
Language: C++

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  vector<unsigned long long int> dp(W+1,0);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  for (int i = 0; i < N; i++) { 
    for (int j = W-w[i]; j >= 0; j--) {
       dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
    }
  }
  unsigned long long int answer = 0;
  for (int i = 0; i <= W; i++) {
    answer = max(dp[i],answer);
  }
  cout << answer;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> N >> W;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> w(N), v(N);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> w(N), v(N);
      |          ^~~
a.cc:5:10: error: expected primary-expression before 'unsigned'
    5 |   vector<unsigned long long int> dp(W+1,0);
      |          ^~~~~~~~
a.cc:7:12: error: 'w' was not declared in this scope
    7 |     cin >> w[i] >> v[i];
      |            ^
a.cc:7:20: error: 'v' was not declared in this scope
    7 |     cin >> w[i] >> v[i];
      |                    ^
a.cc:10:20: error: 'w' was not declared in this scope
   10 |     for (int j = W-w[i]; j >= 0; j--) {
      |                    ^
a.cc:11:8: error: 'dp' was not declared in this scope
   11 |        dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
      |        ^~
a.cc:11:42: error: 'v' was not declared in this scope
   11 |        dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
      |                                          ^
a.cc:11:21: error: 'max' was not declared in this scope
   11 |        dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
      |                     ^~~
a.cc:16:18: error: 'dp' was not declared in this scope
   16 |     answer = max(dp[i],answer);
      |                  ^~
a.cc:16:14: error: 'max' was not declared in this scope
   16 |     answer = max(dp[i],answer);
      |              ^~~
a.cc:18:3: error: 'cout' was not declared in this scope
   18 |   cout << answer;
      |   ^~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,a[100005],f[100005];
int main(){
	scanf("%lld",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	f[n-1]=0;
	f[n-2]=abs(a[n-2]-a[n-1]);
	for(int i=n-3;i>=0;i--){
		int add=1;
		while(add<n-i-2){
			f[i]=min(abs(a[temp]-a[temp+1])+f[temp+1],abs(a[temp]-a[temp+2])+f[temp+2]);
		}
	}
	printf("%lld",f[0]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:40: error: 'temp' was not declared in this scope; did you mean 'mktemp'?
   17 |                         f[i]=min(abs(a[temp]-a[temp+1])+f[temp+1],abs(a[temp]-a[temp+2])+f[temp+2]);
      |                                        ^~~~
      |                                        mktemp
Language: C++

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

const int n_max=100100;

int N,W;
int w[n_max],v[n_max];

ll dp[n_max][n_max];

int main() {

    cin>>N>>W;
    rep(i,N) {
        cin>>w[i]>>v[i];
      }

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

    cout<<dp[0][W]<<endl;

 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:19: error: invalid types 'int[int]' for array subscript
   23 |             if(j<W[i]) {
      |                   ^
a.cc:24:28: error: expected ',' before '+' token
   24 |                 dp[i][j]=[i+1][j];
      |                            ^
      |                            ,
a.cc:24:28: error: expected identifier before '+' token
a.cc: In lambda function:
a.cc:24:31: error: expected '{' before '[' token
   24 |                 dp[i][j]=[i+1][j];
      |                               ^
a.cc: In function 'int main()':
a.cc:24:31: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e5 + 5, M = 1e9 + 7;
ll dp[105][N], wt[105], v[105];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int n, w;
    cin >> n >> w;
    for (ll i = 0; i < n; i++)
        cin >> wt[i] >> v[i];
    for (ll i = wt[0]; i <= w; i++)
        dp[0][i] = v[0];
    for (ll i = 1; i < n; i++)
        for (ll j = 0; j <= w; j++)
            dp[i][j] = max(dp[i - 1][j], ((j < wt[i]) ? 0ll : (dp[i - 1][j - wt[i]] + v[i])));
    cout << dp[n - 1][w];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: no matching function for call to 'max(int64_t&, long long int)'
   17 |             dp[i][j] = max(dp[i - 1][j], ((j < wt[i]) ? 0ll : (dp[i - 1][j - wt[i]] + v[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:17:27: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   17 |             dp[i][j] = max(dp[i - 1][j], ((j < wt[i]) ? 0ll : (dp[i - 1][j - wt[i]] + v[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:17:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   17 |             dp[i][j] = max(dp[i - 1][j], ((j < wt[i]) ? 0ll : (dp[i - 1][j - wt[i]] + v[i])));
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

N, W = (int(n) for n in input().split())
w, v = [], []
for _ in range(N):
    w_, v_ = (int(n) for n in input().split())
    w.append(w_)
    v.append(v_)

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

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

print(dp[N][W])

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:26: error: expected ')' before ';' token
   15 |     {ans=max(ans,dp[i][j];
      |             ~            ^
      |                          )
Language: C++

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

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

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

	for(int i=0 ; i<n ; i++)
	{
		dp[i][0] = 0;
	}
	for(int i=0 ; i<W+1 ; i++)
	{
		if(i<w[0])
			dp[0][i] = 0;
		else
			dp[0][i] = v[0];
	}

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

		}
	}
	int ans=0;
	for(int i=0 ; i<W+1 ; i++)
	{
		ans = max(ans , dp[n-1][i])
	}
	// for(int i =0 ; i<n ; i++)
	// {
	// 	for(int j = 0 ; j<W+1 ; j++)
	// 		cout<<dp[i][j]<<" ";

	// 	cout<<"\n";
	// }
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:44: error: expected ';' before '}' token
   47 |                 ans = max(ans , dp[n-1][i])
      |                                            ^
      |                                            ;
   48 |         }
      |         ~
Language: C++

#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin>>N>>W;
    //dp[i]:重さiで達成できる最大の価値
    int dp[d5];
    for(int i=0;i<d5;i++)dp[i]=-1;
    dp[0]=0;
    for(int i=0;i<n;i++){
        int w,v;
        cin>>w>>v;
        for(int i=W;i>=0;i--){
            if(dp[i]==-1)continue;
            else{
                dp[i+w]=max(dp[i+w],dp[i]+v);
            }
        }
    }
    int res=0;
    for(int i=0;i<=W;i++)res=max(res,dp[i]);
    cout<<res<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:19: error: 'n' was not declared in this scope
   35 |     for(int i=0;i<n;i++){
      |                   ^
Language: Java

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


public class Hey {

	public static void main(String[] args) throws IOException {
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int  n =Integer.parseInt(ana.nextToken()) ; 
		int siz = Integer.parseInt(ana.nextToken())  ;
		long v[]= new long[n] ; int w []=new int[n] ; 
		for(int i=0 ; i<n ;i++)
		{
			ana = new StringTokenizer(jk.readLine()) ;
			w[i] = Integer.parseInt(ana.nextToken()) ; 
			v[i]= Long.parseLong(ana.nextToken())  ;
		}
		long dp[][]= new long[n][siz+1]  ;
		for(int i=0 ;i<n ;i++)
		{
			for(int j=0 ; j<siz+1 ;j++) dp[i][j]=-1 ; 
		}
		
		dp[0][0]=0 ; dp[0][w[0]]= v[0] ; 
		for(int i=1 ; i<n ;i++)
		{
			for(int we=0 ;we<=siz ;we++ )
			{
				long y = dp[i-1][we] ; 
				if(y!=-1)
				{
					dp[i][we]= Long.max(dp[i][we], dp[i-1][we]) ;
					if(we+w[i]<=siz) dp[i][we+w[i]] = Long.max(dp[i][we+w[i]], dp[i-1][we]+v[i]) ; 
				}
			}
		}
		long res = 0 ;
		for(int j=0 ; j<=siz ;j++) res = Long.max(res, dp[n-1][j]) ;
		out.println(res);
		
		out.flush(); 
	}

}




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