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

#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int N, W;
	cin >> N >> W;
	vector<int[2]> objects(N);

	int val_sum = 0;
	for(int i = 0; i < N; ++i) {
		cin >> objects[i][0] >> objects[i][1];
		val_sum += objects[i][1];
	}

	ull dp[N + 1][val_sum + 1];
	// dp[i][j] = minimum weight taking objects 1..i with total value j
	for(int i = 0; i <= val_sum; ++i) {
		dp[0][i] = W + 1;
	}
	for(int i = 0; i <= N; ++i) {
		dp[i][0] = 0;
	}

	for(int i = 1; i <= N; ++i) {
		for(int j = 1; j <= val_sum; ++j) {
			int v = objects[i - 1][1];
			int w = objects[i - 1][0];
			dp[i][j] = dp[i - 1][j];
			if(dp[i - 1][j - v] <= W) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w);
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= val_sum; ++i) {
		if(dp[N][i] <= W) {
			ans = i;
		}
	}
	cout << ans << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Compiler output:
a.cc:10:10: fatal error: prettyprint/prettyprint.hpp: No such file or directory
   10 | #include <prettyprint/prettyprint.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pb  push_back
#define F  first
#define S  second
#define mak make_pair
const int N=1e5+3,mod=1e8;
map<int,int>mp;
pair<ll,ll>p[N];
ll n,k,index=1;
ll oo=-1e9;
ll mem[103][N];

ll dp(int i,int crtw)
{
    if(!mp[crtw])
    {
        mp[crtw]=index;
        index++;
    }
    if (i==n)
    {
        if (crtw+p[i].F<=k)return p[i].S;
        return 0;
    }
    ll &ret=mem[i][mp[crtw]];
    if (ret!=-1)return ret;
    ll x1=0,x2=0;
    if (p[i].F+crtw<=k)
        x1=p[i].S+dp(i+1,crtw+p[i].F);
    x2=dp(i+1,crtw);
    return ret=max(x1,x2);
}

 int main ()
{
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 memset(mem,-1,sizeof mem);
 cin>>n>>k;
 for (int i=1;i<=n;i++)
    cin>>p[i].F>>p[i].S;
 cout<<dp(1,0);
}


Compiler output:
a.cc:11:8: error: 'long long int index' redeclared as different kind of entity
   11 | ll n,k,index=1;
      |        ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'long long int dp(int, int)':
a.cc:19:18: error: cannot resolve overloaded function 'index' based on conversion to type 'std::map<int, int>::mapped_type' {aka 'int'}
   19 |         mp[crtw]=index;
      |                  ^~~~~
a.cc:20:14: error: no post-increment operator for type
   20 |         index++;
      |              ^~
Language: C++

#include<iostream>
#include<algorithm>
#include<limits.h>
using namespace std;

long long int dp[101][1000000001L]={{}};
int N,W;
int w[101];
int v[101];

long long int maxValue(int i, int limit){
    if(i<0 || limit<=0)return 0;
    if(dp[i][limit]!=0)return dp[i][limit];
    if(limit-w[i] < 0)return maxValue(i-1,limit);
    long long int  ret = max(maxValue(i-1,limit), maxValue( i-1, limit-w[i] ) + v[i]);
    dp[i][limit] = ret;
    return ret;
}



int main(){
    cin >> N >> W;
    for(int i = 0; i<N; i++){
        cin>>w[i]>>v[i];
    }
    cout<<maxValue(N-1,W)<<endl;

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

Compiler output:
/tmp/cc1pRnDt.o: in function `maxValue(int, int)':
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1pRnDt.o
/tmp/cc1pRnDt.o: in function `main':
a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0x1df): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0x1f7): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0x202): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc1pRnDt.o
a.cc:(.text+0x208): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc1pRnDt.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<limits.h>
using namespace std;

long long int dp[101][1000000001]={{}};
int N,W;
int w[101];
int v[101];

long long int maxValue(int i, int limit){
    if(i<0 || limit<=0)return 0;
    if(dp[i][limit]!=0)return dp[i][limit];
    if(limit-w[i] < 0)return maxValue(i-1,limit);
    long long int  ret = max(maxValue(i-1,limit), maxValue( i-1, limit-w[i] ) + v[i]);
    dp[i][limit] = ret;
    return ret;
}



int main(){
    cin >> N >> W;
    for(int i = 0; i<N; i++){
        cin>>w[i]>>v[i];
    }
    cout<<maxValue(N-1,W)<<endl;

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

Compiler output:
/tmp/ccvUKl1R.o: in function `maxValue(int, int)':
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccvUKl1R.o
/tmp/ccvUKl1R.o: in function `main':
a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0x1df): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0x1f7): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0x202): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccvUKl1R.o
a.cc:(.text+0x208): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccvUKl1R.o
collect2: error: ld returned 1 exit status
Language: C++

    #include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    int backtrack(int,int);
    int M = 1000000007;
    int dp[101][1000000005];
    int n,w;
    std::vector< pair<int,int> > v;
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n>>w;
        fr(i,n)
        {
            int a,b;
            cin>>a>>b;
            v.pb(mp(a,b));
        }
        cout<<backtrack(0,w)<<endl;
        return 0; 
    }

    int backtrack(int j,int we)
    {
        if(we<=0)
            return 0;
        else
            if(j>n-1)
                return 0;
            if(dp[j][we]!=0)
                return dp[j][we];
            else
            if(v[j].f > we)
                return dp[j][we]=backtrack(j+1,we);
            else
                return dp[j][we]=max(backtrack(j+1,we),v[j].s + backtrack(j+1,we-v[j].f));
    }

Compiler output:
/tmp/ccN3Sjfp.o: in function `main':
a.cc:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0x45): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0xa6): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0xc3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccN3Sjfp.o
/tmp/ccN3Sjfp.o: in function `backtrack(int, int)':
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0x193): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0x21c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0x236): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccN3Sjfp.o
/tmp/ccN3Sjfp.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2e3): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccN3Sjfp.o
a.cc:(.text+0x2fc): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

    #include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    ll backtrack(int,int);
    int M = 1000000007;
    int dp[101][1000000005];
    int n,w;
    std::vector< pair<int,int> > v;
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n>>w;
        fr(i,n)
        {
            int a,b;
            cin>>a>>b;
            v.pb(mp(a,b));
        }
        cout<<backtrack(0,w)<<endl;
        return 0; 
    }

    ll backtrack(int j,int we)
    {
        if(we<=0)
            return 0;
        else
            if(j>n-1)
                return 0;
            if(dp[j][we]!=0)
                return dp[j][we];
            else
            if(v[j].f > we)
                return dp[j][we]=backtrack(j+1,we);
            else
                return dp[j][we]=max(backtrack(j+1,we),v[j].s + backtrack(j+1,we-v[j].f));
    }

Compiler output:
/tmp/ccFUlheU.o: in function `main':
a.cc:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0x45): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0xa6): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0xc3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccFUlheU.o
/tmp/ccFUlheU.o: in function `backtrack(int, int)':
a.cc:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0x222): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0x23f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccFUlheU.o
/tmp/ccFUlheU.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2f3): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccFUlheU.o
a.cc:(.text+0x30c): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

long long dp[100][100000];
int main() {
  int n, w;
  scanf("%d%d", &n, &w);
  if( w > 100000 ) {
    long long s = 0;
    for( int i=0, w, v; i<n; ++i )
      scanf("%d%d", &w, &v), s += v;
    printf("%lld\n", sum);
    return 0;
  }
  for( int i=1, wi, vi; i<=n; ++i )
  {
    scanf("%d%d", &wi, &vi);
    for( int j=1; j<=w; ++j )
      if( wi <= j )
        dp[i][j] = max( dp[i-1][j], dp[i-1][j-wi] + vi );
      else
        dp[i][j] = dp[i-1][j];
  }
  printf("%lld\n", dp[n][w] );
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: 'sum' was not declared in this scope
   13 |     printf("%lld\n", sum);
      |                      ^~~
Language: C++

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

long long N,maxW;
long long dp[102][100002];
struct asdfklj{
    long long val,w;
}arr[102];

long long knapsack(long long i, long long current){
    if(current<0)return long long_MAX;
    if(i==N){
        if(current==0)return 0;
        return long long_MAX;
    }
    long long &ret=dp[i][current];
    return ret = min(arr[i].w+knapsack(i+1,current-arr[i].val), knapsack(i+1,current));
}

long long main(){
    cin>>n>>w;
    memset(dp,-1,sizeof(dp));
    for(long long i=0; i<N; i++)cin>>arr[i].w>>arr[i].val;
    for(long long i=100000;;i--)
        if(knapsack(0,i)<=maxW)
            prlong longf("%d",i),exit(0);
}


Compiler output:
a.cc: In function 'long long int knapsack(long long int, long long int)':
a.cc:11:25: error: expected primary-expression before 'long'
   11 |     if(current<0)return long long_MAX;
      |                         ^~~~
a.cc:11:24: error: expected ';' before 'long'
   11 |     if(current<0)return long long_MAX;
      |                        ^~~~~
      |                        ;
a.cc:14:16: error: expected primary-expression before 'long'
   14 |         return long long_MAX;
      |                ^~~~
a.cc:14:15: error: expected ';' before 'long'
   14 |         return long long_MAX;
      |               ^~~~~
      |               ;
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:21:10: error: 'n' was not declared in this scope
   21 |     cin>>n>>w;
      |          ^
a.cc:21:13: error: 'w' was not declared in this scope
   21 |     cin>>n>>w;
      |             ^
a.cc:26:13: error: 'prlong' was not declared in this scope; did you mean 'ulong'?
   26 |             prlong longf("%d",i),exit(0);
      |             ^~~~~~
      |             ulong
Language: C++

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

map<long long, map<long long,long long> >dp;
int N,maxW;
struct asdfklj{
    long long
}arr[102];

long long knapsack(int i=0, long long current=0){
    if(i==N || current>=maxW)return 0;
    if(dp[i][current])return dp[i][current];
    if(current+arr[i].w<=maxW)return dp[i][current] = max(knapsack(i+1,current+arr[i].w)+arr[i].val, knapsack(i+1,current));
    return dp[i][current] = knapsack(i+1,current);
}

int main(){
    scanf("%d%d",&N,&maxW);
    for(int i=0; i<N; i++)scanf("%I64d%I64d",&arr[i].w,&arr[i].val);
    printf("%d",knapsack());
return 0;
}


Compiler output:
a.cc:8:1: error: expected unqualified-id before '}' token
    8 | }arr[102];
      | ^
a.cc: In function 'long long int knapsack(int, long long int)':
a.cc:13:23: error: 'struct asdfklj' has no member named 'w'
   13 |     if(current+arr[i].w<=maxW)return dp[i][current] = max(knapsack(i+1,current+arr[i].w)+arr[i].val, knapsack(i+1,current));
      |                       ^
a.cc:13:87: error: 'struct asdfklj' has no member named 'w'
   13 |     if(current+arr[i].w<=maxW)return dp[i][current] = max(knapsack(i+1,current+arr[i].w)+arr[i].val, knapsack(i+1,current));
      |                                                                                       ^
a.cc:13:97: error: 'struct asdfklj' has no member named 'val'
   13 |     if(current+arr[i].w<=maxW)return dp[i][current] = max(knapsack(i+1,current+arr[i].w)+arr[i].val, knapsack(i+1,current));
      |                                                                                                 ^~~
a.cc: In function 'int main()':
a.cc:19:54: error: 'struct asdfklj' has no member named 'w'
   19 |     for(int i=0; i<N; i++)scanf("%I64d%I64d",&arr[i].w,&arr[i].val);
      |                                                      ^
a.cc:19:64: error: 'struct asdfklj' has no member named 'val'
   19 |     for(int i=0; i<N; i++)scanf("%I64d%I64d",&arr[i].w,&arr[i].val);
      |                                                                ^~~
Language: C++

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

map<int, map<int,int> >dp;
int N,maxW;
struct asdfklj{
    int val,w;
}arr[102];

int knapsack(int i=0, int current=0){
    if(i==N || current>=maxW)return 0;
    if(dp[i][current])return ret;
    if(current+arr[i].w<=maxW)return dp[i][current] = max(knapsack(i+1,current+arr[i].w)+arr[i].val, knapsack(i+1,current));
    return dp[i][current] = knapsack(i+1,current);
}

int main(){
    scanf("%d%d",&N,&maxW);
    for(int i=0; i<N; i++)scanf("%d%d",&arr[i].w,&arr[i].val);
    printf("%d",knapsack());
return 0;
}


Compiler output:
a.cc: In function 'int knapsack(int, int)':
a.cc:12:30: error: 'ret' was not declared in this scope
   12 |     if(dp[i][current])return ret;
      |                              ^~~
Language: C++

#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll val[103] , w[103] , n , mw ;
map<pair<ll,ll>,ll>dp ;
ll knapsack(ll i , ll v)
{
    if(i > n) return 0 ;
    if(dp[{i,v}] != -1) return dp[{i,v}] ;
    ll a = 0 , b = 0 ;
    if(v + w[i] <= mw)a = val[i] + knapsack(i+1,v + w[i]) ;
    b = knapsack(i+1,v) ;
    return dp[{i,v}] = max(a,b) ;
}
int main()
{
    memset(dp,-1,sizeof(dp)) ;
    cin>>n>>mw ;
    for(ll i = 1 ; i <= n ; i++) cin>>w[i]>>val[i] ;
    ll k = knapsack(1,0) ;
    cout<<k<<endl ;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:12: error: cannot convert 'std::map<std::pair<long long unsigned int, long long unsigned int>, long long unsigned int>' to 'void*'
   17 |     memset(dp,-1,sizeof(dp)) ;
      |            ^~
      |            |
      |            std::map<std::pair<long long unsigned int, long long unsigned int>, long long unsigned int>
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fore(i, init, n) for(long long i = init; i <= n; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;

const int MAXN = 105;
const int MAXV = 1e3+5;
ll N, W, w[MAXN], v[MAXN], dp[MAXN][MAXV], sum, r;

// void debug() {
//     cout << "   ";
//     fore(j, 1, sum) cout << j << "." << (j<=9? " " : "");
//     cout << endl;
//     fore(i, 1, N) {
//         cout << i << ": ";
//         fore(j, 1, sum) {
//             if (dp[i][j] > 100) cout << "-  ";
//             else if (dp[i][j] >= 10) cout << dp[i][j] << " ";
//             else cout << dp[i][j] << "  ";
//         }
//         cout << endl;
//     }
// }

int main() {
    FIN;
    cin >> N >> W;
    
    fore(i,1,N) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    fore(j,1,sum) dp[i][j] = 1e15;
    
    fore(i,1,N) {
        fore(j,1,sum) {
            dp[i][j] = dp[i-1][j];
            if (j >= v[i]) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
        }
    }

    // debug();

    for(ll j = 0LL; j <= sum; j++)
        if (dp[N][j] <= W)
            r = max(r, j);
        
    cout << r << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:22: error: 'i' was not declared in this scope
   38 |     fore(j,1,sum) dp[i][j] = 1e15;
      |                      ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>

using namespace std;

const int MAXN = 1e2 + 5;
const int MAXW = 1e5;
const int INF = 1e9;

struct item
{
    long long v;
    int w;

    item(){};
    item(long long _v, int _w)
    {
        v = _v;
        w = _w;
    }

    bool operator<(item other) const
    {
        return w < other.w;
    }
};

int n, we;
item a[MAXN];
int T[MAXN][MAXW];
map <int, int> T2;

long long rec(int index, int rem)
{
    if(rem < 0) return -INF;
    if(index == n) return 0;
    if(T[index][T2[rem]])
    {
        return T[index][T2[rem]];
    }

    long long ans = rec(index + 1, rem - a[index].w) + a[index].v;
    ans = max(ans, rec(index + 1, rem));

    return T[index][T2[rem]] = ans;
}

void read_input()
{
    scanf("%d %d", &n, &we);

    for(int i = 0; i < n; i++)
    {
        scanf("%d %lld", &a[i].w, &a[i].v);
    }
    sort(a, a + n);
}

void solve()
{
    long long ans = rec(0, we);

    printf("%lld\n", ans);
}

set <int> s;
vector<int> sums;

void pre()
{
    sums.push_back(we);
    int cnt = 0;
    T2[we] = cnt++;

    for(int i = 0; i < n; i++)
    {
        int z = sums.size();
        for(int j = 0; j < z; j++)
        {
            int temp = sums[j] - a[i].w;
            if(temp > 0)
            if(!s.count(temp))
            {
                s.insert(temp);
                sums.push_back(temp);
                T2[temp] = cnt++;
            }
        }
    }
}

int main()
{
    read_input();
    pre();
    solve();

    return 0;
}


Compiler output:
a.cc:70:1: error: 'vector' does not name a type
   70 | vector<int> sums;
      | ^~~~~~
a.cc: In function 'void pre()':
a.cc:74:5: error: 'sums' was not declared in this scope
   74 |     sums.push_back(we);
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
#define INF 0x7fffffff
int main(){
    ll n,w;
    cin>>n>>w;
    ll A[n+1][2];
    for(ll i = 1; i <= n; i++){
        cin>>A[i][0]>>A[i][1];
    }
    ll dp[100004];
    memset(dp,INT,sizeof dp);
    dp[0] = 0;
    for(ll i = 1; i <= n; i++){
        for(ll j = 100003; j >= 0; j--){
            if(j >= A[i][1]){
                dp[j] = min(A[i][0] + dp[j - A[i][1]],dp[j]);
                //cout<<j<<" "<<dp[j]<<"\n";
            }else break;
        }
    }
    for(ll i = 100003; i >= 0; i--){
        //cout<<dp[i]<<"   d\n";
        if(dp[i] <= w){
            cout<<i;
            return 0;
        }
    }
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'INT' was not declared in this scope; did you mean 'INF'?
   14 |     memset(dp,INT,sizeof dp);
      |               ^~~
      |               INF
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9023372036854775807ll;
int n,m,w[105],v[105],dp[N][105],ans;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	memset(dp,llinf,sizeof(dp));
	dp[1][0]=0,dp[1][v[i]]=w[i];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=100000;j++)
			dp[i][j]=dp[i-1][j];
		for(int j=v[i];j<=100000;j++)
			dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
	}
	for(int i=0;i<=100000;i++)
  		if(dp[n][i]<=m)
        	ans=i;
  	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:19: warning: overflow in conversion from 'long long int' to 'int' changes value from '9023372036854775807' to '1156317183' [-Woverflow]
   21 |         memset(dp,llinf,sizeof(dp));
      |                   ^~~~~
a.cc:22:28: error: 'i' was not declared in this scope
   22 |         dp[1][0]=0,dp[1][v[i]]=w[i];
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long f[101][100001];
int w[101];
int v[101];
int N,W;
int main()
{
	int i,j,max_v=100000,ans=0;
	scanf("%d %d",&N,&W);
	for(i=1;i<=N;i++)
	{
		scanf("%d %d",&w[i],&v[i]);	
	}
	memset(f,0x7f,sizeof(f));
	for(j=0;j<=max_v;j++)
		f[0][j]=0; */
	for(i=1;i<=N;i++)
	{
		for(j=v[i];j<=max_v;j++)
		{
			f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);	
		}	
	}
	for(j=1;j<=max_v;j++)
	{
		if(f[N][j]<=W)
			ans=max(ans,j);	
	}
	printf("%d",ans);
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:17:29: error: expected primary-expression before '/' token
   17 |                 f[0][j]=0; */
      |                             ^
a.cc:18:9: error: expected primary-expression before 'for'
   18 |         for(i=1;i<=N;i++)
      |         ^~~
a.cc:18:25: error: expected ';' before ')' token
   18 |         for(i=1;i<=N;i++)
      |                         ^
      |                         ;
Language: C++

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

int dp[n+1][w+1];

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,w;
	cin>>n>>w;
	pair<int,int> arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr+1,arr+n+1);
	for(int j=0;j<=w;j++)
	{
		if(j<arr[1].first)
			dp[1][j]=0;
		else
		{
			dp[1][j]=arr[1].second;
		}
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(j<arr[i].first)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],arr[i].second+dp[i-1][j-arr[i].first]);
			}
		}
	}
	cout<< *max_element(dp[n],dp[n]+w+1)<<endl;
	
return 0;
}

Compiler output:
a.cc:5:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 | int dp[n+1][w+1];
      |        ^
      |        yn
a.cc:5:13: error: 'w' was not declared in this scope
    5 | int dp[n+1][w+1];
      |             ^
a.cc: In function 'int main()':
a.cc:22:25: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |                         dp[1][j]=0;
      |                         ^~
      |                         dup
a.cc:25:25: error: 'dp' was not declared in this scope; did you mean 'dup'?
   25 |                         dp[1][j]=arr[1].second;
      |                         ^~
      |                         dup
a.cc:34:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   34 |                                 dp[i][j]=dp[i-1][j];
      |                                 ^~
      |                                 dup
a.cc:38:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   38 |                                 dp[i][j]=max(dp[i-1][j],arr[i].second+dp[i-1][j-arr[i].first]);
      |                                 ^~
      |                                 dup
a.cc:42:29: error: 'dp' was not declared in this scope; did you mean 'dup'?
   42 |         cout<< *max_element(dp[n],dp[n]+w+1)<<endl;
      |                             ^~
      |                             dup
Language: C++

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
typedef unsigned long ul;
const ul INF=1LL<<60;
const ul MAX_N=111;
const ul MAX_V=10000000000000;
ul N,W,w[MAX_N],v[MAX_N],dp[MAX_N][MAX_V],i,j,ans;
inline void solve(){
  IN2(N,W);
  REP(i,N){
    IN2(w[i],v[i]);
  }
  REP(i,MAX_N)REP(j,MAX_V)dp[i][j]=INF;
  dp[0][0]=0;
  REP(i,N){
    REP(j,MAX_V){
      if(j+v[i]<=MAX_V)dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      // if(j-v[i]>=0)dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    }
  }
  DW(j,MAX_V-1,0){
    if(dp[N][j]<=W){
      OUT(j);
      return;
    }
  }
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Compiler output:
/tmp/ccMhyVi0.o: in function `solve()':
a.cc:(.text._Z5solvev[_Z5solvev]+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0x46): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0xbd): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0xcd): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0xe1): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/ccMhyVi0.o
a.cc:(.text._Z5solvev[_Z5solvev]+0x116): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define MAXI ((ll)1e16)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;  
     
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
ll n,w,res;
ll weight[101];
ll val[101];
ll dp[101][1001];
ll solve(ll i, ll value){
	if(i==-1 && (value<0 || value>0)return MAXI;
	if(i==-1)return 0;
	if(dp[i][value]!=-1)return dp[i][value];
	dp[i][value] = min(weight[i]+solve(i-1,value-val[i]),solve(i-1,value));
	return dp[i][value];
}
int main(){FIN;
	cin >> n >> w;
	fore(i,0,n){
		cin >> weight[i] >> val[i];
	}
	memset(dp,-1,sizeof(dp));
	for(int i = 1000 ; i>-1 ; i--){
		if(solve(n-1,i)<=w){
			cout << i << endl;
			return 0;
		}
	}
	
}

Compiler output:
a.cc: In function 'll solve(ll, ll)':
a.cc:28:41: error: expected ';' before 'return'
   28 |         if(i==-1 && (value<0 || value>0)return MAXI;
      |                                         ^~~~~~
      |                                         ;
a.cc:29:9: error: expected primary-expression before 'if'
   29 |         if(i==-1)return 0;
      |         ^~
a.cc:28:53: error: expected ')' before 'if'
   28 |         if(i==-1 && (value<0 || value>0)return MAXI;
      |           ~                                         ^
      |                                                     )
   29 |         if(i==-1)return 0;
      |         ~~
Language: C++

#include <iostream>
#include <cstdlib>
#include <limits>
using namespace std;
int imax = std::numeric_limits<int>::max();
long long dp[101][1000000002],i,j,n,k,w,vi[101],wi[101];
int main()
{
    
   // cout<<"P:";
    cin>>n>>w;
    for(i=1;i<=n;i++)
        cin>>wi[i]>>vi[i];
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-wi[i]>=0)
                dp[i][j]=max(dp[i][j],dp[i-1][j-wi[i]]+vi[i]);
            
        }
    }
    /*
    for(i=1;i<=n;i++)
        {
            for(j=1;j<=w;j++)
                cout<<dp[i][j]<<" ";
            cout<<"\n";
        }
     */
    cout<<dp[n][w];
    return 0;
}

Compiler output:
/tmp/cc9mR2PB.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x46): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `wi' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x83): relocation truncated to fit: R_X86_64_PC32 against symbol `vi' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9mR2PB.o
a.cc:(.text+0xb1): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

#define ll long long
ll n,W,w[1000000],v[1000000];
ll knapsack(){
	ll dp[n+1][W+1];
	for(ll i=0;i<=n;i++){
		for(auto it=wgt.begin();it!=wgt.end();++it){
			if(i==0 || wt==0)
				dp[i][wt]=0;
			else if(w[i-1]<=wt)
				dp[i][wt]=max(v[i-1]+dp[i-1][wt-w[i-1]], dp[i-1][wt]);
			else
				dp[i][wt]=dp[i-1][wt];
		}
	}
	return dp[n][W];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>W;
	for(ll i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<knapsack();
	return 0;
}

Compiler output:
a.cc: In function 'long long int knapsack()':
a.cc:9:29: error: 'wgt' was not declared in this scope
    9 |                 for(auto it=wgt.begin();it!=wgt.end();++it){
      |                             ^~~
a.cc:10:36: error: 'wt' was not declared in this scope; did you mean 'w'?
   10 |                         if(i==0 || wt==0)
      |                                    ^~
      |                                    w
Language: C++

#include <iostream>
using namespace std;
int n;
int max_weight;
int w[101];
long long int v[101];
long long int dp[101][1000000001];
long long int ans = 0;
int main()
{
    cin >> n >> max_weight;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }

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

Compiler output:
/tmp/ccXxleQa.o: in function `main':
a.cc:(.text+0x2aa): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXxleQa.o
a.cc:(.text+0x2e1): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXxleQa.o
a.cc:(.text+0x2f7): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXxleQa.o
collect2: error: ld returned 1 exit status
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	ll n,W;
	cin >> n >> W;
	ll w[n],v[n];
	for (int i = 0;i < n;i++) {
		cin >> w[i] >> v[i];
	}
	ll dp[100050];
	for (int i = 0;i < 100050;i++) {dp[i] = 1145141919810;}
	dp[0] = 0;dp[v[0]]=w;
	for (int i = 0;i < n;i++) {
		for (int j = 100000;j >= v[i];j--) {
			dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	ll ans = 0;
	for (int i = 0;i < 100001;i++) {
		if (dp[i] <= W) ans = i;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:28: error: invalid conversion from 'll*' {aka 'long long int*'} to 'll' {aka 'long long int'} [-fpermissive]
   21 |         dp[0] = 0;dp[v[0]]=w;
      |                            ^
      |                            |
      |                            ll* {aka long long int*}
Language: C++

#include <iostream>
using namespace std;
int n;
long long int max_weight;
long long int w[101];
int v[101];
long long int dp[101][101001];

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

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

    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 101001; j++)
        {
            dp[i][j] = #include <iostream>
using namespace std;
int n;
long long int max_weight;
long long int w[101];
int v[101];
long long int dp[101][101001];

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

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

    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 101001; j++)
        {
            dp[i][j] = 1000000001;
        }
    }

    dp[0][0] = 0;
    dp[0][v[0]] = w[0];


    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            if (dp[i][j] == 1000000001)
                continue;
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    for (int i = 101000; i >= 0; i--)
    {
        if (dp[n][i] <= max_weight)
        {
            cout << i << endl;
            break;
        }
    }
    //cout << ans << endl;
};
        }
    }

    dp[0][0] = 0;
    dp[0][v[0]] = w[0];


    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            if (dp[i][j] == max_weight)
                continue;
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    for (int i = 101000; i >= 0; i--)
    {
        if (dp[n][i] <= max_weight)
        {
            cout << i << endl;
            break;
        }
    }
    //cout << ans << endl;
}

Compiler output:
a.cc:22:24: error: stray '#' in program
   22 |             dp[i][j] = #include <iostream>
      |                        ^
a.cc: In function 'int main()':
a.cc:22:25: error: 'include' was not declared in this scope
   22 |             dp[i][j] = #include <iostream>
      |                         ^~~~~~~
a.cc:22:42: error: expected primary-expression before '>' token
   22 |             dp[i][j] = #include <iostream>
      |                                          ^
a.cc:23:1: error: expected primary-expression before 'using'
   23 | using namespace std;
      | ^~~~~
a.cc:30:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   30 | int main()
      |         ^~
a.cc:30:9: note: remove parentheses to default-initialize a variable
   30 | int main()
      |         ^~
      |         --
a.cc:30:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:31:1: error: a function-definition is not allowed here before '{' token
   31 | {
      | ^
Language: C++

#include <iostream>
using namespace std;
int n;
long long int max_weight;
long long int w[101];
int v[101];
long long int dp[101][100001];

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

    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            dp[i][j] = 1000000001;
        }
    }
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    for (int i = 100000; i > 0; i--)
    {
        if (dp[n][i] <= max_weight)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |             ans = i;
      |             ^~~
      |             abs
a.cc:43:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	int n,W;
	cin >> n >> W;
	ll w[n],v[n];
	map<ll,ll> dp[n];
	for (int i = 0;i < n;i++) {
		cin >> w[i] >> v[i];
	}
	dp[0][0] = 0; dp[0][w[0]] = v[0];
	for (int i = 0;i < n-1;i++) {
		for (auto j = dp[i].begin();j != dp[i].end();j++) {
			dp[i+1][j->first] = max(dp[i+1][j->first],dp[i][j->first]);
			if (j->first+w[i+1] <= W) {
				dp[i+1][j->first+w[i+1]] = max(dp[i+1][j->first+w[i+1]],dp[i][j->first]+v[i->first+1]);
			}
		}
	}
	ll ans = 0;
	for (auto itr = dp[n-1].begin();itr != dp[n-1].end();itr++) {
		ans = max(ans,itr -> second);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:108: error: base operand of '->' is not a pointer
   25 |                                 dp[i+1][j->first+w[i+1]] = max(dp[i+1][j->first+w[i+1]],dp[i][j->first]+v[i->first+1]);
      |                                                                                                            ^~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
using namespace std;

template<typename T>
void mymin(T& a, T b)
{
    if(a > b) a = b;
}

int main()
{
    int N, W; cin >> N >> W;
    vector<int> w(N, 0); vector<int> v(N, 0);
    for(int i = 0; i < N; i++) cin >> w.at(i) >> v.at(i);
    int Vmax = accumulate(v.begin(), v.end(), 0);
    vector< vector<long long> >dp(N+1, vector<long long>(Vmax+1, LLONG_MAX));
    dp.at(0).at(0) = 0;
    for(int i = 0; i < N; i++)
    {
        for(int sum_v= 0; sum_v <= Vmax; sum_v++)
        {
            dp.at(i+1).at(sum_v) = dp.at(i).at(sum_v);
            if(sum_v - v.at(i) >= 0)
            {
                mymin(dp.at(i+1).at(sum_v), dp.at(i).at(sum_v - v.at(i)) + w.at(i));
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i <= Vmax; i++)
    {
        if(dp.at(N).at(i) <= W)
        {
            ans = i;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: 'accumulate' was not declared in this scope
   18 |     int Vmax = accumulate(v.begin(), v.end(), 0);
      |                ^~~~~~~~~~
Language: Java

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

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

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

Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.