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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mx = (int) 1e3 * 100;
const int inf = (int) 1e9 + 778;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	vector<long long> dp(mx + 1, inf);
	dp[0] = 0;
	for (int t = 0; t < n; t++) {
		int x, y;
		cin >> x >> y;
		// weight, value
		for (int i = mx - y; i >= 0; i--) {
			// look at dp[i] for result
			// working on dp[i + this.value
			dp[i + y] = min(dp[i + y], dp[i] + x);
		}
	}
	long long ans = 0;
	for (long lon i = 0; i < mx; i++) {
		if (dp[i] <= w) {
			ans = max(ans, i);
		}
	}
	cout << ans << '\n';
	return 0;
}

/*
- minimize the weight but maximize the value
dp[value] = total weight required to aquire
that value
- make sure dp[value] <= weight given.
dp[0] = 0
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:28:22: error: expected ';' before 'i'
   28 |         for (long lon i = 0; i < mx; i++) {
      |                      ^~
      |                      ;
a.cc:28:23: error: 'i' was not declared in this scope
   28 |         for (long lon i = 0; i < mx; i++) {
      |                       ^
a.cc:28:36: error: expected ')' before ';' token
   28 |         for (long lon i = 0; i < mx; i++) {
      |             ~                      ^
      |                                    )
a.cc:28:38: error: 'i' was not declared in this scope
   28 |         for (long lon i = 0; i < mx; i++) {
      |                                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, W;
  cin >> N >> W;
  
  vector<vector<long long>> dp(N + 1, vector<long long>(100000 + 1, 1000000000 + 1));
  
  dp.at(0).at(0) = 0;
  
  int w, v;
  for (int i = 1; i <= N; i++) {
    cin >> w >> v;
    for (int j = 0; j <= 100000; j++) {
      if (j >= w) {
        dp.at(i).at(j) = min(dp.at(i - 1).at(j), dp.at(i - 1).at(max(int(j - v), 0)) + w);
      }
      else {
        dp.at(i).at(j) = dp.at(i - 1).at(j)
      }
    }
  }
  
  long long ans = 100000;
  
  while (dp.at(N - 1).at(ans) > W) {
    ans--;
  }
  
  cout << ans << endl;
  for (int i = -10; i <= 10; i++) {
    cout << dp.at(N - 1).at(ans + i) << ' ';
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:44: error: expected ';' before '}' token
   20 |         dp.at(i).at(j) = dp.at(i - 1).at(j)
      |                                            ^
      |                                            ;
   21 |       }
      |       ~
Language: C++

#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

int solution(){
    ll n,W; cin>>n>>W;
    vector<ll> w(n), v(n);
    for(ll i = 0;i < n;i++) cin>>w[i]>>v[i];
    
    vector<ll> dp(W+1, 0);
    for(ll i = 0;i < n;i++){
        for(ll j = W; j >= w[i];j--){
                dp[j] = max( v[i]+dp[j-w[i]], dp[j]);
        }
    }
    // for(ll j = 0;j <= W;j++)
    //     cout<<dp[j]<<" ";
    // cout<<"\n";
    cout<<dp[W]<<"\n";
    return 0; 
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

int solution(){
    ll n,W; cin>>n>>W;
    vector<ll> w(n), v(n);
    for(ll i = 0;i < n;i++) cin>>w[i]>>v[i];
    
    vector<ll> dp(W+1, 0);
    for(ll i = 0;i < n;i++){
        for(ll j = W; j >= w[i];j--){
                dp[j] = max( v[i]+dp[j-w[i]], dp[j]);
        }
    }
    // for(ll j = 0;j <= W;j++)
    //     cout<<dp[j]<<" ";
    // cout<<"\n";
    cout<<dp[W]<<"\n";
    return 0; 
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

int solution(){
    ll n,W; cin>>n>>W;
    vector<ll> w(n), v(n);
    for(ll i = 0;i < n;i++) cin>>w[i]>>v[i];
    
    vector<ll> dp(W+1, 0);
    for(ll i = 0;i < n;i++){
        for(ll j = W; j >= w[i];j--){
                dp[j] = max( v[i]+dp[j-w[i]], dp[j]);
        }
    }
    // for(ll j = 0;j <= W;j++)
    //     cout<<dp[j]<<" ";
    // cout<<"\n";
    cout<<dp[W]<<"\n";
    return 0; 
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Compiler output:
a.cc:30:2: error: stray '#' in program
   30 | }#include <bits/stdc++.h>
      |  ^
a.cc:59:2: error: stray '#' in program
   59 | }#include <bits/stdc++.h>
      |  ^
a.cc:30:3: error: 'include' does not name a type
   30 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:35:5: error: redefinition of 'int solution()'
   35 | int solution(){
      |     ^~~~~~~~
a.cc:6:5: note: 'int solution()' previously defined here
    6 | int solution(){
      |     ^~~~~~~~
a.cc:53:5: error: redefinition of 'int main()'
   53 | int main(){
      |     ^~~~
a.cc:24:5: note: 'int main()' previously defined here
   24 | int main(){
      |     ^~~~
a.cc:59:3: error: 'include' does not name a type
   59 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:64:5: error: redefinition of 'int solution()'
   64 | int solution(){
      |     ^~~~~~~~
a.cc:6:5: note: 'int solution()' previously defined here
    6 | int solution(){
      |     ^~~~~~~~
a.cc:82:5: error: redefinition of 'int main()'
   82 | int main(){
      |     ^~~~
a.cc:24:5: note: 'int main()' previously defined here
   24 | int main(){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int nxx=1e9+5;
vector<pair<long long,long long>> v(101);
long long dp[101][nxx];
int n,k;

long long ans(int i,int k){
    if(i==n||k==0){
        return 0;
    }
	if(v[i].first>k) return ans(i+1,k);
	if(dp[i][k]!=-1) return dp[i][k];
	else{
	    long long value=max(ans(i+1,k),ans(i+1,k-v[i].first)+v[i].second);
	    return dp[i][k]=value;
	}
}

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

    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
	memset(dp,-1,sizeof(dp));
    cout<<ans(0,k);
    
}

Compiler output:
/tmp/cc55NDfm.o: in function `ans(int, int)':
a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc55NDfm.o
/tmp/cc55NDfm.o: in function `main':
a.cc:(.text+0x1b4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc55NDfm.o
a.cc:(.text+0x1d0): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc55NDfm.o
a.cc:(.text+0x240): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc55NDfm.o
a.cc:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc55NDfm.o
collect2: error: ld returned 1 exit status
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define int long long
signed main(){
  
  int n,c;
  cin >> n >> c;
  
  int wt[n];
  int val[n];
  for(int i=0;i<n;i++){
    cin >> wt[i] >> val[i] ;
  }
  
  int sz=100001;
  int dp[sz] ;
  int ans=INT_MAX;
  for(int i=0;i<n;i++){
    
    for(int j=sz-1;j>=0;j--){
      if(i==0)
        dp[j]=c+1;
      
      if(j==0)
        dp[j]=0;
      
      if(wt[i-1]<=c)
        dp[j]=min(dp[j],wt[i-1]+dp[j-wt[i-1]]);
      
    }
 
  }
  int ans;
  for(int j=0;j<=100000;j++){
    if(dp[j]<=c)
      ans=j;
  }
  
  
  cout<<ans;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:7: error: redeclaration of 'long long int ans'
   33 |   int ans;
      |       ^~~
a.cc:17:7: note: 'long long int ans' previously declared here
   17 |   int ans=INT_MAX;
      |       ^~~
Language: C++

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

int main() {
	// your code goes here
	int n, w;
	cin >> n >> w;
	long long int a[n], v[n], tot = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> v[i];
		tot += v[i];
	}
	
	const int inf = 2e5 + 9;
	vector<int> dp(tot + 1, inf);
	for (int i = 0; i < n; ++i) {
		for (int j = tot - v[i]; j >= 0; --j) {
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + a[i]); 
		}
	}
	for (int i = tot; i >= 0; --i) {
		if (dp[i] <= w) {
			cout << i;
			return 0;
		}
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:43: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int)'
   18 |                         dp[j + v[i]] = min(dp[j + v[i]], dp[j] + a[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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:18:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |                         dp[j + v[i]] = min(dp[j + v[i]], dp[j] + a[i]);
      |                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:18:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |                         dp[j + v[i]] = min(dp[j + v[i]], dp[j] + a[i]);
      |                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long int dp[101][100001];
int main() 
{
long long int n,w;
   cin>>n>>w;
   long long int wt[n],val[n],i,j;
   for(i=0;i<n;i++)
   {
   	cin>>wt[i]>>val[i];
   }
   for(i=0;i<101;i++)
        {
            for(j=0;j<100001;j++)
            dp[i][j]=LLONG_MAX=1000000000;
        }
        for(i=0;i<=n;i++)
        dp[i][0]=0ll;
        for(i=1;i<=n;i++)
        {
        	for(j=0;j<100001;j++)
        	{
        		if(j>=val[i-1])
                {
                    dp[i][j]=min(dp[i][j],wt[i-1]+dp[i-1][j-val[i-1]]);
                }
                dp[i][j]=min(dp[i][j],dp[i-1][j]);
               
        	}
        }
        ll ans;
        for(i=100000;i>=0;i--)
        {
            if(dp[n][i]<=w)
            {ans=i; break;}
        }
        cout<<ans<<"\n";
 
   
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: error: lvalue required as left operand of assignment
   16 |             dp[i][j]=LLONG_MAX=1000000000;
      |                      ^~~~~~~~~
a.cc:32:9: error: 'll' was not declared in this scope
   32 |         ll ans;
      |         ^~
a.cc:36:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |             {ans=i; break;}
      |              ^~~
      |              abs
a.cc:38:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |         cout<<ans<<"\n";
      |               ^~~
      |               abs
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
using namespace std;

const int mxN = 1e3+1;
ll w[101]; int val[101];
ll dp[mxN][101];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n; ll c; cin >> n >> c;
	int vv = 0;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> val[i];
	    vv += val[i];
    }
    memset(dp, 0, sizeof(dp));
    
    for(int i = 0; i <= n; i++)
        dp[0][i] = 0;
    for(int i = 1; i <= vv; i++)
		dp[i][0] = 1e18;

    ll ans = 0;
    for(int i = 1; i <= vv; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j] = dp[i][j-1];
            if(i >= val[j]) {
                dp[i][j] = min(dp[i][j], w[j]+dp[i-val[j]][j-1]);
            }
            if(dp[i][j] <= c)
                ans = i;
        }
    }
    cout << ans << '\n';
}
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
using namespace std;

const int mxN = 1e3+1;
ll w[101]; int val[101];
ll dp[mxN][101];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n; ll c; cin >> n >> c;
	int vv = 0;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> val[i];
	    vv += val[i];
    }
    memset(dp, 0, sizeof(dp));
    
    for(int i = 0; i <= n; i++)
        dp[0][i] = 0;
    for(int i = 1; i <= vv; i++)
		dp[i][0] = 1e18;

    ll ans = 0;
    for(int i = 1; i <= vv; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j] = dp[i][j-1];
            if(i >= val[j]) {
                dp[i][j] = min(dp[i][j], w[j]+dp[i-val[j]][j-1]);
            }
            if(dp[i][j] <= c)
                ans = i;
        }
    }
    cout << ans << '\n';
}


Compiler output:
a.cc:44:11: error: redefinition of 'const int mxN'
   44 | const int mxN = 1e3+1;
      |           ^~~
a.cc:6:11: note: 'const int mxN' previously defined here
    6 | const int mxN = 1e3+1;
      |           ^~~
a.cc:45:4: error: redefinition of 'long long int w [101]'
   45 | ll w[101]; int val[101];
      |    ^
a.cc:7:4: note: 'long long int w [101]' previously declared here
    7 | ll w[101]; int val[101];
      |    ^
a.cc:45:16: error: redefinition of 'int val [101]'
   45 | ll w[101]; int val[101];
      |                ^~~
a.cc:7:16: note: 'int val [101]' previously declared here
    7 | ll w[101]; int val[101];
      |                ^~~
a.cc:46:4: error: redefinition of 'long long int dp [1001][101]'
   46 | ll dp[mxN][101];
      |    ^~
a.cc:8:4: note: 'long long int dp [1001][101]' previously declared here
    8 | ll dp[mxN][101];
      |    ^~
a.cc:48:5: error: redefinition of 'int main()'
   48 | int main(){
      |     ^~~~
a.cc:10:5: note: 'int main()' previously defined here
   10 | int main(){
      |     ^~~~
Language: C++

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N 1000001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
    int w;
    cin>>n>>w;

    int wt[n],val[n];

    for(i=0;i<n;i++)
        cin>>wt[i]>>val[i];


    unordered_map<int,int>dp,vis;

    dp[0]=0;

    for(i=0;i<n;i++)
    {
        for(auto itr=dp.rbegin();itr!=dp.rend();itr++)
        {
            int key=itr->first,va=itr->second;

            if(key+wt[i]<=w)dp[key+wt[i]]=max(dp[key]+val[i],dp[key+wt[i]]);

        }

    }
    int ans=0;

    for(i=0;i<=w;i++)
        ans=max(ans,dp[i]);

    cout<<ans;

}

}


Compiler output:
a.cc:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:55:25: error: 'class std::unordered_map<long long int, long long int>' has no member named 'rbegin'; did you mean 'begin'?
   55 |         for(auto itr=dp.rbegin();itr!=dp.rend();itr++)
      |                         ^~~~~~
      |                         begin
a.cc:55:42: error: 'class std::unordered_map<long long int, long long int>' has no member named 'rend'; did you mean 'end'?
   55 |         for(auto itr=dp.rbegin();itr!=dp.rend();itr++)
      |                                          ^~~~
      |                                          end
Language: C++

 
int dp[100001];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int n, W;
	cin >> n >> W;
	int w[n], v[n];
	for(int i=0; i<n; ++i)
		cin >> w[i] >> v[i];
	memset(dp, 0x3f, sizeof(dp));
	dp[0]=0;
	for(int i=0; i<n; ++i) {
		for(int j=1001-v[i]; j>=0; --j)
			dp[j+v[i]]=min(dp[j]+w[i], dp[j+v[i]]);
	}
	for(int i=1001; i>=0; --i) {
		if(dp[i]<=W) {
			cout << i;
			break;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: 'ios' has not been declared
    5 |         ios::sync_with_stdio(0);
      |         ^~~
a.cc:6:9: error: 'cin' was not declared in this scope
    6 |         cin.tie(0);
      |         ^~~
a.cc:13:9: error: 'memset' was not declared in this scope
   13 |         memset(dp, 0x3f, sizeof(dp));
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | 
a.cc:17:36: error: 'min' was not declared in this scope; did you mean 'main'?
   17 |                         dp[j+v[i]]=min(dp[j]+w[i], dp[j+v[i]]);
      |                                    ^~~
      |                                    main
a.cc:21:25: error: 'cout' was not declared in this scope
   21 |                         cout << i;
      |                         ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:23:15: error: 'i' was not declared in this scope
   23 |         cout<<i;
      |               ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:33: error: expected primary-expression before ')' token
    9 |         for(int i=0;i<=100000;++) dp[i]=1e18;
      |                                 ^
a.cc:15:46: error: 'v' was not declared in this scope
   15 |                         dp[j]=min(dp[j],dp[j-v]+a);
      |                                              ^
a.cc:21:23: error: 'j' was not declared in this scope
   21 |                 if(dp[j]<=w) ans=i;
      |                       ^
a.cc:23:15: error: 'i' was not declared in this scope
   23 |         cout<<i;
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
   	int n;
   	cin >> n >> w;
   	int dp[100005];
   	memset(dp, 0x3f, sizeof(dp));
   	dp[0] = 0;
   	f(n) {
   		int x, y;
   		cin >> x >> y;
   		for (int j = 100000 ; j >= y ; i++) {
   			dp[j] = min(dp[j] , dp[j - y] + x);
   		}
   	}
   	for (int i = 100000 ; i >= 0 ; i--) {
   		if (dp[i] <= w) {
   			cout << i << '\n';
   			return;
   		}
   	}
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Compiler output:
a.cc: In function 'void go()':
a.cc:16:21: error: 'w' was not declared in this scope
   16 |         cin >> n >> w;
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long W;
   long int a[1001][50001];
long int dp(int v,int i,int val[],long w[])
{   long ans;
   if(v>=0)
   if(a[i][v]!=-1)
   return a[i][v];
   if(v<=0)
   ans=0;
   else if(i==0 && val[i]<v)
   ans= INT_MAX;
   else if(i==0 && val[i]>=v)
   ans=w[0];
   else 
   ans =min(dp(v,i-1,val,w),dp(v-val[i],i-1,val,w)+w[i]);
   if(v>=0)
   a[i][v]=ans;
   return ans;
}
int main(){
   int n;
   cin>>n>>W;
   long int w[n];int val[n];
   int sum=0;
   for(int i=0;i<n;i++)
   {
       cin>>val[i];
       sum+=val[i];
   }
   for(int i=0;i<n;i++)
   cin>>w[i];
   for(int i=0;i<1001;i++)
   for(int j=0;j<50001;j++)
   a[i][j]=-1;
   int max=-1;
   for(int i=0;i<50001;i++)
   {
  
       if(dp(i,n-1,val,w)<=W)
       max=i;
       
   }
   cout<<max;

Compiler output:
a.cc: In function 'int main()':
a.cc:45:14: error: expected '}' at end of input
   45 |    cout<<max;
      |              ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 
  
#define V_SUM_MAX 1000 
#define N_MAX 100 
#define W_MAX 10000000 
  
// To store the states of DP 
int dp[V_SUM_MAX + 1][N_MAX]; 
bool v[V_SUM_MAX + 1][N_MAX]; 
  
// Function to solve the recurrence relation 
int solveDp(int r, int i, int* w, int* val, int n) 
{ 
    // Base cases 
    if (r <= 0) 
        return 0; 
    if (i == n) 
        return W_MAX; 
    if (v[r][i]) 
        return dp[r][i]; 
  
    // Marking state as solved 
    v[r][i] = 1; 
  
    // Recurrence relation 
    dp[r][i] 
        = min(solveDp(r, i + 1, w, val, n), 
              w[i] + solveDp(r - val[i], 
                             i + 1, w, val, n)); 
    return dp[r][i]; 
} 
  
// Function to return the maximum weight 
int maxWeight(int* w, int* val, int n, int c) 
{ 
  
    // Iterating through all possible values 
    // to find the the largest value that can 
    // be represented by the given weights 
    for (int i = V_SUM_MAX; i >= 0; i--) { 
        if (solveDp(i, 0, w, val, n) <= c) { 
            return i; 
        } 
    } 
    return 0; 
} 
  
// Driver code 
int main() 
{ 
    int n,W;
  	cin >> n >> W;
  	int v[n],w[n];
  	for(int i=0;i<n;i++){
      cin >> w[i] >> val[i];
    }
  
    cout << maxWeight(w, val, n, W); 
  
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:57:22: error: 'val' was not declared in this scope
   57 |       cin >> w[i] >> val[i];
      |                      ^~~
a.cc:60:26: error: 'val' was not declared in this scope
   60 |     cout << maxWeight(w, val, n, W);
      |                          ^~~
Language: C++

// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 
  
#define V_SUM_MAX 1000 
#define N_MAX 100 
#define W_MAX 10000000 
  
// To store the states of DP 
int dp[V_SUM_MAX + 1][N_MAX]; 
bool v[V_SUM_MAX + 1][N_MAX]; 
  
// Function to solve the recurrence relation 
int solveDp(int r, int i, int* w, int* val, int n) 
{ 
    // Base cases 
    if (r <= 0) 
        return 0; 
    if (i == n) 
        return W_MAX; 
    if (v[r][i]) 
        return dp[r][i]; 
  
    // Marking state as solved 
    v[r][i] = 1; 
  
    // Recurrence relation 
    dp[r][i] 
        = min(solveDp(r, i + 1, w, val, n), 
              w[i] + solveDp(r - val[i], 
                             i + 1, w, val, n)); 
    return dp[r][i]; 
} 
  
// Function to return the maximum weight 
int maxWeight(int* w, int* val, int n, int c) 
{ 
  
    // Iterating through all possible values 
    // to find the the largest value that can 
    // be represented by the given weights 
    for (int i = V_SUM_MAX; i >= 0; i--) { 
        if (solveDp(i, 0, w, val, n) <= c) { 
            return i; 
        } 
    } 
    return 0; 
} 
  
// Driver code 
int main() 
{ 
    int n,W;
  	cin >> n >> W;
  	int v[n],w[n];
  	for(int i=0;i<n;i++){
      cin >> w[i] >> v[i];
    }
  
    cout << maxWeight(w, val, n, W); 
  
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:60:26: error: 'val' was not declared in this scope
   60 |     cout << maxWeight(w, val, n, W);
      |                          ^~~
Language: C++

// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 
  
#define V_SUM_MAX 1000 
#define N_MAX 100 
#define W_MAX 10000000 
  
// To store the states of DP 
int dp[V_SUM_MAX + 1][N_MAX]; 
bool v[V_SUM_MAX + 1][N_MAX]; 
  
// Function to solve the recurrence relation 
int solveDp(int r, int i, int* w, int* val, int n) 
{ 
    // Base cases 
    if (r <= 0) 
        return 0; 
    if (i == n) 
        return W_MAX; 
    if (v[r][i]) 
        return dp[r][i]; 
  
    // Marking state as solved 
    v[r][i] = 1; 
  
    // Recurrence relation 
    dp[r][i] 
        = min(solveDp(r, i + 1, w, val, n), 
              w[i] + solveDp(r - val[i], 
                             i + 1, w, val, n)); 
    return dp[r][i]; 
} 
  
// Function to return the maximum weight 
int maxWeight(int* w, int* val, int n, int c) 
{ 
  
    // Iterating through all possible values 
    // to find the the largest value that can 
    // be represented by the given weights 
    for (int i = V_SUM_MAX; i >= 0; i--) { 
        if (solveDp(i, 0, w, val, n) <= c) { 
            return i; 
        } 
    } 
    return 0; 
} 
  
// Driver code 
int main() 
{ 
    int n,W;
  	cin >> n >> W;
  	ll v[n],w[n];
  	for(int i=0;i<n;i++){
      cin >> w[i] >> v[i];
    }
  
    cout << maxWeight(w, val, n, W); 
  
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:55:9: error: 'll' was not declared in this scope
   55 |         ll v[n],w[n];
      |         ^~
a.cc:57:14: error: 'w' was not declared in this scope
   57 |       cin >> w[i] >> v[i];
      |              ^
a.cc:60:23: error: 'w' was not declared in this scope
   60 |     cout << maxWeight(w, val, n, W);
      |                       ^
a.cc:60:26: error: 'val' was not declared in this scope
   60 |     cout << maxWeight(w, val, n, W);
      |                          ^~~
Language: C++

#include <iostream>
#include <cstring>
using namespace std;

long long int dp[101]*[101];

long long int max(long long int a,long long int b){
  if(a>b) return a;
  else return b;
}

int main(){
  int n,W,wt[101],val[101],i;
  cin>>n>>W;
  for(i=0;i<n;i++){
    cin>>wt[i]>>val[i];
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=W;j++){
      if(i==0||j==0) dp[i][j]=0;
      else{
        if(wt[i-1]<=j) dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
        else dp[i][j]=dp[i-1][j];
      }
    }
  }
  return 0;
}

Compiler output:
a.cc:5:22: error: expected initializer before '*' token
    5 | long long int dp[101]*[101];
      |                      ^
a.cc: In function 'int main()':
a.cc:19:9: error: 'j' was not declared in this scope
   19 |     for(j=0;j<=W;j++){
      |         ^
a.cc:20:22: error: 'dp' was not declared in this scope
   20 |       if(i==0||j==0) dp[i][j]=0;
      |                      ^~
a.cc:22:24: error: 'dp' was not declared in this scope
   22 |         if(wt[i-1]<=j) dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
      |                        ^~
a.cc:23:14: error: 'dp' was not declared in this scope
   23 |         else dp[i][j]=dp[i-1][j];
      |              ^~
Language: Java

import java.util.*;
public class knapsack1bottomup {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long w=sc.nextLong();
		long value[]=new long[n];
		long weight[]=new long[n];
		for(int i=0;i<n;i++){
			weight[i]=sc.nextLong();
			value[i]=sc.nextLong();
		}
		long dp[][]=new long[n+1][(int)w+1];
		for(int i=0;i<=n;i++){
			for(int j=0;j<=w;j++){
				if(i==0||j==0){
					dp[i][j]=0;
					continue;
				}
				long inc=0,exe=0;
				if(weight[i-1]<=j){
					dp[i][j]=Math.max(value[i-1]+dp[i-1][(int)(j-weight[i-1])],dp[i-1][j]);
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		System.out.println(dp[n][(int)w]);
	}
}


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

import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long w=sc.nextLong();
		long value[]=new long[n];
		long weight[]=new long[n];
		for(int i=0;i<n;i++){
			weight[i]=sc.nextLong();
			value[i]=sc.nextLong();
		}
		long dp[][]=new long[n+1][(int)w+1];
		for(int i=0;i<=n;i++){
			for(int j=0;j<=w;j++){
				if(i==0||j==0){
					dp[i][j]=0;
					continue;
				}
				long inc=0,exe=0;
				if(weight[i-1]<=j){
					dp[i][j]=Math.max(value[i-1]+dp[i-1][(int)(j-weight[i-1])],dp[i-1][j]);
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		System.out.println(dp[n][w]);
	}
}


Compiler output:
Main.java:29: error: incompatible types: possible lossy conversion from long to int
		System.out.println(dp[n][w]);
		                         ^
1 error
Language: Java

import java.util.*;
public class knapsack1bottomup {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int w=sc.nextInt();
		long value[]=new long[n];
		long weight[]=new long[n];
		for(int i=0;i<n;i++){
			weight[i]=sc.nextLong();
			value[i]=sc.nextLong();
		}
		long dp[][]=new long[n+1][w+1];
		for(int i=0;i<=n;i++){
			for(int j=0;j<=w;j++){
				if(i==0||j==0){
					dp[i][j]=0;
					continue;
				}
				long inc=0,exe=0;
				if(weight[i-1]<=j){
					dp[i][j]=Math.max(value[i-1]+dp[i-1][(int)(j-weight[i-1])],dp[i-1][j]);
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
        long ans=0;
        for(int i=0;i<=n;i++){
          for(int j=0;j<=w;j++){
            ans=Math.max(ans,dp[i][j]);
		System.out.println(ans);
	}
}


Compiler output:
Main.java:35: error: reached end of file while parsing
}
 ^
1 error
Language: C++

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

long long dp[101][100001];

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

    for(long long i=0;i<=N;++i){
        for(long long j=0;j<=V;++j){
            dp[i][j]=10000000001;
        }
    }

//    for(long long j=1;j<=V;++j){
//      if(v[1]>=j){
//        dp[1][j]=w[1];
//      }
//    }
    dp[1][v[1]] = w[1];
    
    for(long long i=2;i<=N;++i){
        for(long long j=1;j<=V;++j){
//         dp[i][j] = min(dp[i][j], dp[i-1][j]);
//         if(j+v[i]<=V){
//          dp[i][j+v[i]] = min(dp[i][j])
//         }
         
         
           if(j-v[i]<1) dp[i][j]=min(dp[i-1][j],v[i]);
           else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);

    }


    long long ans=0;
    for(int j=1;j<=V;++j){
      if(dp[N][j]<=W) ans=j;
    }
    cout<<ans<<endl;
}


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

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define mod 1000000007

struct item{
    int wt;
    int val;
};

void solve(){

    int n, w; cin >> n >> w;
    w = min(w, 1e5+5);
    item arr[n];
    for(int i = 0; i < n; ++i){
        cin >> arr[i].wt >> arr[i].val;
    }
    vector<ll> dp (w+1, -1);
    dp[0] = 0;

    for(int i = 0; i < n; ++i){
        for(int j = w; j-arr[i].wt >= 0; --j){
            if(dp[j-arr[i].wt] != -1)
                dp[j] = max(dp[j], (ll)dp[j-arr[i].wt] + arr[i].val);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:17:12: error: no matching function for call to 'min(int&, double)'
   17 |     w = min(w, 1e5+5);
      |         ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:17:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   17 |     w = min(w, 1e5+5);
      |         ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:17:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |     w = min(w, 1e5+5);
      |         ~~~^~~~~~~~~~
Language: C++

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


Compiler output:
/tmp/ccjJYUv5.o: in function `main':
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccjJYUv5.o
a.cc:(.text+0x251): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccjJYUv5.o
a.cc:(.text+0x29f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccjJYUv5.o
a.cc:(.text+0x342): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccjJYUv5.o
a.cc:(.text+0x350): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccjJYUv5.o
collect2: error: ld returned 1 exit status
Language: C++

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

Compiler output:
/tmp/cc1tOTnS.o: in function `main':
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1tOTnS.o
a.cc:(.text+0x251): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1tOTnS.o
a.cc:(.text+0x29f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1tOTnS.o
a.cc:(.text+0x342): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1tOTnS.o
a.cc:(.text+0x350): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1tOTnS.o
collect2: error: ld returned 1 exit status
Language: Java

// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

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

public class knapsack2 {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();
        int w = nextInt();

        Item[] items = new Item[n+1];

        int totalValues = 0;

        for (int i = 1; i <= n; i++) {
            items[i] = new Item(nextInt(), nextInt());
            totalValues += items[i].value;
        }

        int[][] dp = new int[n+1][totalValues + 1];

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= totalValues; j++) {
                dp[i][j] = Integer.MAX_VALUE;
            }
        }

        dp[0][0] = 0;

        for (int i = 1; i <= n; i++) {
            Item item = items[i];
            dp[i][item.value] = Math.min(dp[i][item.value] = item.weight, dp[i][item.value]);
            for (int j = 0; j <= totalValues; j++) {
                if (dp[i-1][j] != Integer.MAX_VALUE) dp[i][j] = dp[i-1][j];
                if (j - item.value >= 0 && dp[i-1][j-item.value] != Integer.MAX_VALUE) {
                    dp[i][j] = Math.min(dp[i][j], dp[i-1][j-item.value] + item.weight);
                }
            }
        }

        int result = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= totalValues; j++) {
                if (dp[i][j] <= w) result = Math.max(result, j);
            }
        }

        out.println(result);

        out.close();
    }

    static class Item {
        int weight, value;

        Item(int weight, int value) {
            this.weight = weight;
            this.value = value;
        }
    }
}




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

using namespace std;

int main() {
   int  n,w,gmax=0;
   cin>>n>>w;
   vector<int> weights(n,0),values(n,0);

   for(int i=0;i<n;i++)
    cin>>weights[i]>>values[i];

   vector<long long int> dp(100001);

   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<100001;j++)
       {

           if(j==0)
           {
               dp[j]=0;
               continue;
           }

           if(i==0)
           {
               dp[j]=w+1;
               continue;
           }

           if(values[i-1]<=j)
           {
               dp[j]=min(weights[i-1]+dp[j-values[i-1]],dp[j]);
           }
       }
   }
    
    for(int j=0;j<100001;j++)
       {
           if(dp[j]<=w)
            gmax=max(gmax,j);
       }

   cout<<gmax;

   return 0;
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
using namespace std;
^
Main.java:5: error: not a statement
   cin>>n>>w;
         ^
Main.java:6: error: not a statement
   vector<int> weights(n,0),values(n,0);
                       ^
Main.java:9: error: not a statement
    cin>>weights[i]>>values[i];
                   ^
Main.java:11: error: not a statement
   vector<long long int> dp(100001);
         ^
Main.java:11: error: not a statement
   vector<long long int> dp(100001);
               ^
Main.java:11: error: not a statement
   vector<long long int> dp(100001);
                    ^
Main.java:43: error: not a statement
   cout<<gmax;
       ^
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
int main() {
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: ';' expected
   vector<int> weights(n,0),values(n,0);
                      ^
Main.java:6: error: ';' expected
   vector<int> weights(n,0),values(n,0);
                        ^
Main.java:11: error: ';' expected
   vector<long long int> dp(100001);
                   ^
Main.java:11: error: ';' expected
   vector<long long int> dp(100001);
                       ^
13 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
int knapsack(vector<int> &v, vector<int> &w, int V, int i) {
	if (V == 0 || i == -1) {
		return 0;
	}
	else if (v[i] <= V) {
		return max(knapsack(&v, &w, V - v[i], i - 1),
			           knapsack(&v, &w, V, i - 1));
	}
	else if (v[i] > V) {
		return knapsack(&v, &w, V, i - 1);
	}
}
int main() {
	int n, W;
	cin >> n >> W;
	vector<int> v(n), w(n);
	for (int i{}; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	vector<int> dp(n);
	cout << knapsack(&v, &w, &dp, n - 1);
}

Compiler output:
a.cc: In function 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)':
a.cc:8:37: error: invalid initialization of non-const reference of type 'std::vector<int>&' from an rvalue of type 'std::vector<int>*'
    8 |                 return max(knapsack(&v, &w, V - v[i], i - 1),
      |                                     ^~
a.cc:3:27: note: in passing argument 1 of 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)'
    3 | int knapsack(vector<int> &v, vector<int> &w, int V, int i) {
      |              ~~~~~~~~~~~~~^
a.cc:9:45: error: invalid initialization of non-const reference of type 'std::vector<int>&' from an rvalue of type 'std::vector<int>*'
    9 |                                    knapsack(&v, &w, V, i - 1));
      |                                             ^~
a.cc:3:27: note: in passing argument 1 of 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)'
    3 | int knapsack(vector<int> &v, vector<int> &w, int V, int i) {
      |              ~~~~~~~~~~~~~^
a.cc:12:33: error: invalid initialization of non-const reference of type 'std::vector<int>&' from an rvalue of type 'std::vector<int>*'
   12 |                 return knapsack(&v, &w, V, i - 1);
      |                                 ^~
a.cc:3:27: note: in passing argument 1 of 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)'
    3 | int knapsack(vector<int> &v, vector<int> &w, int V, int i) {
      |              ~~~~~~~~~~~~~^
a.cc: In function 'int main()':
a.cc:23:26: error: invalid initialization of non-const reference of type 'std::vector<int>&' from an rvalue of type 'std::vector<int>*'
   23 |         cout << knapsack(&v, &w, &dp, n - 1);
      |                          ^~
a.cc:3:27: note: in passing argument 1 of 'int knapsack(std::vector<int>&, std::vector<int>&, int, int)'
    3 | int knapsack(vector<int> &v, vector<int> &w, int V, int i) {
      |              ~~~~~~~~~~~~~^
Language: C++

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

int main(){
  long long n,wt,sum=0;
  cin>>n>>wt;
  vector<long long> v(n+1),w(n+1);
  vector<long long> dp(wt+1,INT_MAX);
  dp[0]=0;
  for(long long i=1;i<=n;i++){
      cin>>w[i]>>v[i];
      sum+=v[i];
  }
  for(long long i=1;i<=n;i++){
      for(long long j=sum;j>=v[i];j--){
          dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
      }
  }
  int ans=0;
  for(int i=sum;i>=1;i--)
        if(minn[i]<=W)
        {
            ans=i;
            break;
        }
  cout<<ans;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'minn' was not declared in this scope
   22 |         if(minn[i]<=W)
      |            ^~~~
a.cc:22:21: error: 'W' was not declared in this scope
   22 |         if(minn[i]<=W)
      |                     ^
Language: C++

#include "../template.cc"
const int inf = 1e9;
vi w, p;
int N;
int knapsack(const vi& w, const vi& p, int B) {
  ll maxP = accumulate(ALL(p), 0);

  vvi dp(maxP + 1, vi(SZ(w), inf));
  fill(ALL(dp[0]), 0);
  dp[p[0]][0] = w[0];

  FOR(t, 1, maxP + 1) {
    FOR(i, 1, SZ(w)) {
      dp[t][i] = dp[t][i - 1];
      if(t - p[i] >= 0)
        ckmin(dp[t][i], dp[t - p[i]][i - 1] + w[i]);
    }
  }

  int res = 0;
  F0R(i, maxP + 1)
    if(dp[i][SZ(w) - 1] <= B)
      ckmax(res, i);
  return res;
}

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

  int B;
  cin >> N >> B;

  vi w(N), p(N);
  F0R(i, N)
    cin >> w[i] >> p[i];

  cout << knapsack(w, p, B) << endl;
}


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

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

int main(){
  long long n,wt;
  cin>>n>>wt;
  vector<long long> v(n+1),w(n+1);
  vector<long long> dp(wt+1,0);
  for(long long i=1;i<=n;i++){
      cin>>w[i]>>v[i];
  }
  for(lng long i=0;i<=n;i++){
      for(long long j=wt;j>=0;j--){
          if(w[i]<=j) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
      }
  }
  cout<<dp[wt];

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: 'lng' was not declared in this scope; did you mean 'long'?
   13 |   for(lng long i=0;i<=n;i++){
      |       ^~~
      |       long
a.cc:13:20: error: 'i' was not declared in this scope
   13 |   for(lng long i=0;i<=n;i++){
      |                    ^