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

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

#define FILE_INPUT
#define DEBUG_MODE

static const int N_MAX = 100;
static const int W_MAX = 1000000000;
static const int N_SIZE = N_MAX + 1;
static const int W_SIZE = W_MAX + 1;

int n;
int ww;
int memo[N_SIZE][W_SIZE];
int w[N_MAX];
int v[N_MAX];

int Search(int num, long long int weight)
{
	if (num >= N_SIZE || weight >= W_SIZE) {
		return 0;
	}
	if (memo[num][weight] >= 0) {
		//cout << "Load : " << num << " : " << weight << " : " << memo[num][weight] << endl;
		return memo[num][weight];
	}
	int max = 0;
	if (num == n - 1) {
		if (weight + w[num] <= ww) {
			max = v[num];
		}
	}
	else {
		max = Search(num + 1, weight);
		if (weight + w[num] <= ww) {
			int value2 = v[num] + Search(num + 1, weight + w[num]);
			if (value2 > max) {
				max = value2;
			}
		}
	}
	memo[num][weight] = max;
	//cout << num << " : " << weight << " : " << max << endl;
	return max;
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	for (int i = 0; i < N_SIZE; ++i) {
		for (int j = 0; j < W_SIZE; ++j) {
			memo[i][j] = -1;
		}
	}

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

	int max_value = Search(0, 0);
	cout << max_value << endl;

	return 0;
}

Compiler output:
/tmp/ccZC4cW4.o: in function `Search(int, long long)':
a.cc:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZC4cW4.o
a.cc:(.text+0xd4): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZC4cW4.o
a.cc:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZC4cW4.o
a.cc:(.text+0x138): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZC4cW4.o
a.cc:(.text+0x14f): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZC4cW4.o
/tmp/ccZC4cW4.o: in function `main':
a.cc:(.text+0x29a): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZC4cW4.o
a.cc:(.text+0x2c6): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZC4cW4.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll dp[105][100005];

int main(){
	int n; ll wmax;
	cin >> n >> wmax;
	vector<ll> v(n);
	vector<ll> w(n);
	for( int i = 0; i < n; ++i ) cin >> w[i] >> v[i];
	ll vsm = accumulate( v.begin(), v.end(), 0ll );
	for( int i = 0; i <= n; ++i ){
		dp[i][0] = 0;
		for( int j = 1; j <= vsm; ++j ){
			dp[i][j] = -INF;
		}
	}
	
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j <= vsm; ++j ){
			dp[i+1][j] = dp[i][j];
			if( j >= v[i] && dp[i][j-v[i]] >= 0 && dp[i][j-v[i]] + w[i] <= wmax ){
				dp[i+1][j] = max(dp[i][j], p[i][j-v[i]] + w[i]);
			}
		}
	}
	ll ans = 0;
	for( ll j = vsm; j >= 0; --j ){
		if( dp[n][j] > 0 ){
			ans = j;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

// 13:36

Compiler output:
a.cc: In function 'int main()':
a.cc:28:60: error: 'p' was not declared in this scope
   28 |                                 dp[i+1][j] = max(dp[i][j], p[i][j-v[i]] + w[i]);
      |                                                            ^
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n,w;
    cin>>n>>w;
    vector<pair<long long, long long> > v;
// v.push_back(make_pair(-1,-1));
    for(int i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
        
    }
    vector<vector <long long  >> dp(n+1,vector<long long>(w+1,(long long)1e9);
    for(int i=1;i <=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
dp[i][j]=dp[i-1][j];
          if(j>=v[i].first) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i].first]+v[i].second); 
        }
    }
   long long ans=0;
     for(int j=0;j<=w;j++){ans=max(ans,dp[n][j]);}
     cout<<ans;
    
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:78: error: expected ')' before ';' token
   23 |     vector<vector <long long  >> dp(n+1,vector<long long>(w+1,(long long)1e9);
      |                                    ~                                         ^
      |                                                                              )
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n,w;
    cin>>n>>w;
    vector<pair<long long, long long> > v;
 v.push_back(make_pair(-1,-1));
    for(int i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
        
    }
    vector<vector <long long  >> dp(n+1,vector<long long>(w+1,(long long)1e9);
    for(int i=1;i <=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
dp[i][j]=dp[i-1][j];
          if(j>=v[i].first) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i].first]+v[i].second); 
        }
    }
   long long ans=0;
     for(int j=0;j<=w;j++){ans=max(ans,dp[n][j]);}
     cout<<ans;
    
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:78: error: expected ')' before ';' token
   23 |     vector<vector <long long  >> dp(n+1,vector<long long>(w+1,(long long)1e9);
      |                                    ~                                         ^
      |                                                                              )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char** argv) {
    int64_t n, w, ans{0};
    cin >> n >> w;

    std::vector<int64_t> dp(1e5+10, 1e12);
    dp[0] = 0;

    for (int64_t i = 1; i < n+1; ++i) {
        long long wi, vi;
        cin >> wi >> vi;
        for (int64_t j = dp.size(); j > 0; --j) {
            if (j-vi  >= 0) {
                dp[j] = min(dp[j], dp[j-vi] + wi);
            }
        }
    }
    for (int64_t j = 1; j < dp.size(); ++j) {
        if (dp[j] > w) continue;
        ans = j;
    }
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:20:28: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
   20 |                 dp[j] = min(dp[j], dp[j-vi] + wi);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~
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:20:28: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   20 |                 dp[j] = min(dp[j], dp[j-vi] + wi);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~
/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 a.cc:3:
/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:20:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   20 |                 dp[j] = min(dp[j], dp[j-vi] + wi);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

typedef long long ll;

int g[101],p[101],c;
ll dp[100001];

int main(){
    freopen("a.in", "r", stdin);

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>p[i]>>g[i];
    for(int i=1; i<=100000; i++)
        dp[i]=m+1;
    for(int i=1; i<=n; i++)
        for(int j=100000; j>=g[i]; j--){
            dp[j]=min(dp[j],dp[j-g[i]]+p[i]);
            dp[j]=min(dp[j],m+1);
        }

    for(int j = 100000; j >= 0; j--)
        if(dp[j] <= m){
            cout << j;
            return 0;
        }

    return 0;
}


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

#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;
void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}
//dp[ i ][ sum_v ] := i-1 番目までの品物から価値が sum_v 以上を達成するように選んだときの、重さの総和 sum_w の最小値
int N;
ll W,weight[MAX_N],value[MAX_N];
int main ()
{
    cin>>N>>W;
    REP(i,N) cin>>weight[i]>>value[i];
    REP(i,MAX_N){
        REP(j,MAX_V){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    REP(i,N){
        REP(sum_v,MAX_N){
            if(sum_v - value[i]>=0){
                chmin(dp[i+1][sum_v],dp[i][sum_v - value[i]] + weight[i]);
            }
            chmin(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }
    ll res = 0;
    REP(sum_v,MAX_V){
        if(dp[N][sum_v]<=W) res = sum_v;
    }

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

Compiler output:
a.cc:5:13: error: expected unqualified-id before numeric constant
    5 | #define INF 1000000000000000
      |             ^~~~~~~~~~~~~~~~
a.cc:14:17: note: in expansion of macro 'INF'
   14 | const long long INF = 1LL<<60;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:34:13: error: 'dp' was not declared in this scope; did you mean 'p'?
   34 |             dp[i][j] = INF;
      |             ^~
      |             p
a.cc:37:5: error: 'dp' was not declared in this scope; did you mean 'p'?
   37 |     dp[0][0] = 0;
      |     ^~
      |     p
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

const int N = 1e5+5;

ll n, val[101], w[101], wt, dp[101][N];

void solve()
{
       cin>>n>>wt;
       rep(i,1 n+1) cin>>w[i]>>v[i];
       rep(i,1,N) dp[0][i]=inf;
       // imp: dp[0][0] = 0
       rep(i,1,n+1)
       {
              rep(j,0,N)
              {
                     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]);
              }      
       }
       ll ans=0;
       rep(j,0,N) if(dp[n][j]<=wt) ans=j;
       cout<<ans;
}


int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Compiler output:
a.cc:28:19: error: macro "rep" requires 3 arguments, but only 2 given
   28 |        rep(i,1 n+1) cin>>w[i]>>v[i];
      |                   ^
a.cc:16:9: note: macro "rep" defined here
   16 | #define rep(i,a,b)  for(ll i=a;i<b;i++)
      |         ^~~
a.cc: In function 'void solve()':
a.cc:28:8: error: 'rep' was not declared in this scope
   28 |        rep(i,1 n+1) cin>>w[i]>>v[i];
      |        ^~~
a.cc:36:28: error: 'v' was not declared in this scope
   36 |                      if(j>=v[i]) dp[i][j]=min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
      |                            ^
Language: C++

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

unsigned long long dp[1000000001],g[1000000001],p[1000000001];

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>p[i]>>g[i];
}
for(int i=1;i<=n;i++){
for(int j=m;j>=p[i];j--){
dp[j]=max(dp[j],dp[j-p[i]]+g[i]);
}
}
cout<<dp[m];
}


Compiler output:
/tmp/ccP4dMBx.o: in function `main':
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccP4dMBx.o
a.cc:(.text+0x93): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccP4dMBx.o
a.cc:(.text+0xde): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccP4dMBx.o
a.cc:(.text+0x108): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccP4dMBx.o
a.cc:(.text+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccP4dMBx.o
collect2: error: ld returned 1 exit status
Language: C++

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

const int r = 101;
long long w[r], v[r], n, W;
map <pair<int ,long long>, int> dp;

int solve(int idx, long long weights) {
    if (idx == n)
        return 0;
    if (dp.find({idx, weights}) != dp.end())
        return dp[{idx, weights}];
    if (w[idx] + weights <= W)
        return dp[{idx, weights}] = max(v[idx] + solve(idx + 1, weights + w[idx]), solve(idx + 1, weights));
    else
        return dp[{idx, weights}] = solve(idx + 1, weights);
}
int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    cout << solve(0, 0) << '\n';
    return 0;
}


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

#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N, W;
ll dp[105][INF];

int main() 
{
    //optimization

    cin >> N >> W;
    vector<int> w(N), v(N);

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

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

    cout<<dp[N-1][W]<<endl;

    return 0;
}

Compiler output:
a.cc:10:12: error: size of array 'dp' exceeds maximum object size '9223372036854775807'
   10 | ll dp[105][INF];
      |            ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const ll MAXN = 50 + 5;
const ll MAXK = 1e5 + 10;

int main() {
    ll N, W;
    cin >> N >> W;
    vll W(N);
    vll V(N);
    for (int i = 0; i < N; ++i) {
        cin >> W[i] >> V[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(MAXK));
    fill(dp[0].begin(), dp[0].end(), INF);
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < MAXK; ++j) {
            if (j < V[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - V[i]] + W[i]);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < MAXK; ++i) {
        if (dp[N][i] <= W) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: conflicting declaration 'vll W'
   16 |     vll W(N);
      |         ^
a.cc:14:11: note: previous declaration as 'll W'
   14 |     ll N, W;
      |           ^
a.cc:19:17: error: invalid types 'll {aka long long int}[int]' for array subscript
   19 |         cin >> W[i] >> V[i];
      |                 ^
a.cc:29:65: error: invalid types 'll {aka long long int}[int]' for array subscript
   29 |                 dp[i + 1][j] = min(dp[i][j], dp[i][j - V[i]] + W[i]);
      |                                                                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e18;
void min_self(ll &a,ll b){
  a = min(a,b);
}
const int N = 110;
int n,W;
int main(){
  scanf("%d%d",&n,&W);
  vector<ll> weights(n);
  vector<ll> value(n);
  for(int i=0;i<n;++i){
    cin>>weights[i]>>value[i];
  }
  ll sum = 0;
  for(int x:values){
    sum += x;
  }
  vector<int> dp(sum+1,inf);
  dp[0] = 0;
  for(int i=0;i<n;++i){
    for(int va = sum - value[i];va>=0;--va){
      min_self(dp[va+value[i]],dp[va]+weight[i]);
    }
  }
  ll ans = inf;
  for(int i=0;i<=sum;++i){
	if(dp[i]<=W){
      ans = max(ans,(ll)i);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'values' was not declared in this scope; did you mean 'value'?
   18 |   for(int x:values){
      |             ^~~~~~
      |             value
a.cc:21:24: warning: overflow in conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   21 |   vector<int> dp(sum+1,inf);
      |                        ^~~
a.cc:25:39: error: 'weight' was not declared in this scope; did you mean 'weights'?
   25 |       min_self(dp[va+value[i]],dp[va]+weight[i]);
      |                                       ^~~~~~
      |                                       weights
Language: C++


#include <bits/stdc++.h>
using namespace std;
#define INF 1500000000
int main(){
	int n,w;
	cin >> n >> w;
	vector<pair<int,int> > v;
	int l=0;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		l+= y;
		v.push_back(make_pair(x,y));
	}
	//wt profit
	vector<ll> dp(l+1,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=l;j>=0;--j)
		{
			if(j-v[i].second >=0)
			dp[j]= min(dp[j],v[i].first+dp[j-v[i].second]);
		}
	}
	int ans=0;
	for(int i=0;i<=l;i++)
	{
		if(dp[i]<=w)
		ans= max(ans, i);
	}
	cout <<ans;
	return 0;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: 'll' was not declared in this scope; did you mean 'l'?
   18 |         vector<ll> dp(l+1,INF);
      |                ^~
      |                l
a.cc:18:18: error: template argument 1 is invalid
   18 |         vector<ll> dp(l+1,INF);
      |                  ^
a.cc:18:18: error: template argument 2 is invalid
a.cc:18:30: error: expression list treated as compound expression in initializer [-fpermissive]
   18 |         vector<ll> dp(l+1,INF);
      |                              ^
a.cc:19:11: error: invalid types 'int[int]' for array subscript
   19 |         dp[0]=0;
      |           ^
a.cc:25:27: error: invalid types 'int[int]' for array subscript
   25 |                         dp[j]= min(dp[j],v[i].first+dp[j-v[i].second]);
      |                           ^
a.cc:25:38: error: invalid types 'int[int]' for array subscript
   25 |                         dp[j]= min(dp[j],v[i].first+dp[j-v[i].second]);
      |                                      ^
a.cc:25:55: error: invalid types 'int[int]' for array subscript
   25 |                         dp[j]= min(dp[j],v[i].first+dp[j-v[i].second]);
      |                                                       ^
a.cc:31:22: error: invalid types 'int[int]' for array subscript
   31 |                 if(dp[i]<=w)
      |                      ^
Language: C++

/*****************************************************

Code by: Vichitr
Compiled On: 23rd March 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf pop_front
#define mp make_pair
#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ip pair<int, int>
#define N 100007
const ll MOD = 1e9+7;
const ll SZ = 107;
map<ip, int> dp;
int w[105], v[105], n, W;
int solve(int i, int we)
{
    if(i==0 or we==0)
        return dp[{i, we}]=0;
    if(dp[{i, we}] != 0)
        return dp[{i, we}];
    if(w[i-1]<=we)
        dp[{i, we}] = max(v[i-1]+solve(i-1, we-w[i-1]), solve(i-1, we));
    else
        dp[{i, we}] = solve(i-1, we);
    return dp[{i, we}];
}

signed main()
{
    fast;

   // int n, W;
    cin>>n>>W;
    
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    int dp[n+5];
    dp[0] = v[0];
    for(int i=1;i<n;i++)
    {
        dp[i] = dp[i-1];
        for(int j=0;j<i;j++)
        dp[i] = max(dp[i-1], )
    }
    int ans = solve(n, W);
    cout<<ans;
    return 0;
}


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

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

typedef long long ll;
const int MAX_N = 105;
const int MAX_V = 1005;

ll N,W;
vector<ll> w(MAX_N),v(MAX_N);
ll dp[MAX_N][MAX_N*MAX_V];

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

	rep(i,MAX_N)rep(j,MAX_N*MAX_V){
		dp[i][j] = INF;
	}
	dp[0][0] = 0;

	rep(i,N)rep(j,MAX_N*MAX_V){
		if(j+v[i]<=MAX_N*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]);
		}
	}
	
	ll ans = 0;
	rep(j,MAX_N*MAX_V){
		if(dp[N][j]<=W)ans = j;
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:28: error: 'INF' was not declared in this scope
   18 |                 dp[i][j] = INF;
      |                            ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long f[101][1000000001],w[100000001],v[100001];
int main()
{
	long long n,m,j,i;
	scanf("%lld %lld",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%lld %lld",&w[i],&v[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=w[i])
			{
				f[i][j]=max(f[i][j],f[i-1][j-w[i]]+v[i]);
			}
		}
	}
	printf("%lld",f[n][m]);
}

Compiler output:
/tmp/ccqO9cGB.o: in function `main':
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccqO9cGB.o
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccqO9cGB.o
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccqO9cGB.o
a.cc:(.text+0x123): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccqO9cGB.o
a.cc:(.text+0x15e): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccqO9cGB.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.Arrays;
import java.util.stream.IntStream;

public class AtCoder {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), w = scanner.nextInt();
        int[] wa = new int[n], va = new int[n];
        for (int i = 0; i < n; i++) {
            wa[i] = scanner.nextInt();
            va[i] = scanner.nextInt();
        }
        int sum = Arrays.stream(va).sum();
        long[] dp = new long[sum + 1];
        Arrays.fill(dp, 1, sum + 1, Long.MAX_VALUE);
        for (int i = 0; i < n; i++)
            for (int j = sum; j >= va[i]; j--)
                if (dp[j - va[i]] != Long.MAX_VALUE)
                    dp[j] = Math.min(dp[j], dp[j - va[i]] + wa[i]);
        IntStream.rangeClosed(0, sum)
                .filter(j -> dp[sum - j] <= w)
                .findFirst()
                .ifPresent(j -> System.out.println(sum - j));
    }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

    int n, w; // the number of temperatures to analyse
    int weight[101], value[101];
    long long dp[101][1000000010];
    long long ans=0;

int main() {
    


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

    //init
    for (int i = 0; i < w; ++i)
    {
      dp[0][i] = 0; 
    }

    for (int i = 0; i < n; ++i)
    {//till dp[n] 
    	for( int j = 0; j<=w; ++j)
    	{
	    	if (j >= weight[i])
	    	{
	    		dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i]); 
	    	} 
	    	else
	    	{
	    		dp[i+1][j] = dp[i][j];
	    	}
	    	//cout<<"i="<<i<<" j="<<j<<" "<< dp[i+1][j]<< endl;
		}
    }

    for (int i = 0; i <= w; ++i)
    {
    	if (ans<dp[n][i])
    	{
    		ans = dp[n][i];
    	}
    	//cout<<dp[n][i]<<endl; 
    }

	cout<<ans<<endl; 
    return 0;
}

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

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

typedef long long ll;

const int MAX_N = 105;
const int MAX_V = 1005;

//input
ll N,W;
vector<ll> w(MAX_N),v(MAX_N);

//dp
ll dp[MAX_N][MAX_N*MAX_V];

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

	//初期値
	rep(i,MAX_N)rep(j,MAX_N*MAX_V){
		dp[i][j] = INF;
	}
	dp[0][0] = 0;

	rep(i,N)rep(j,MAX_N*MAX_V){
		if(j+v[i]<=MAX_N*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]);
		}
		
	}


	ll ans = 0;
	rep(j,MAX_N*MAX_V){
		if(dp[N][j]<=W)ans = j;
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:28: error: 'INF' was not declared in this scope
   23 |                 dp[i][j] = INF;
      |                            ^~~
Language: Java


/*
USER: caoash3
LANG: JAVA
TASK: 
*/

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

public class knapsack1 {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			int N = br.nextInt();
			int W = br.nextInt();
			
			int[] w = new int[N];
			int[] v = new int[N];
			
			for(int i = 0; i < N; i++) {
				w[i] = br.nextInt();
				v[i] = br.nextInt();
			}
			
			long[][] dp = new long[N+1][1001];
			
			for(int i = 0; i <= N; i++) {
				for(int j = 0; j <= 1000; j++) {
					dp[i][j] = Integer.MAX_VALUE;
				}
			}
			
			dp[0][0] = 0;
			
			for(int i = 1; i <= N; i++) {
				for(int j = 0; j <= 1000; j++) {
					if(j-v[i-1] >= 0) {
						dp[i][j] = Math.min(dp[i-1][j], dp[i-1][j-v[i-1]]+w[i-1]);
					}
					else {
						dp[i][j] = dp[i-1][j];
					}
				}
			}
			
			int ans = 0;
			
			for(int i = 0; i <= 1000; i++) {
				if(dp[N][i] <= W) {
					ans = Math.max(ans, i);
				}
			}
			
			pw.println(ans);
			pw.close();
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



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

/*
USER: caoash3
LANG: JAVA
TASK: 
*/

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

public class knapsack1 {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			int N = br.nextInt();
			int W = br.nextInt();
			
			int[] w = new int[N];
			int[] v = new int[N];
			
			for(int i = 0; i < N; i++) {
				w[i] = br.nextInt();
				v[i] = br.nextInt();
			}
			
			long[][] dp = new long[N+1][W+1];
			
			for(int i = 0; i < W+1; i++) {
				dp[0][i] = -1 * Integer.MAX_VALUE;
			}
			
			dp[0][0] = 0;
			
			for(int i = 1; i <= N; i++) {
				for(int j = 0; j <= W; j++) {
					if(j - w[i-1] >= 0) {
						dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
					}
					else {
						dp[i][j] = dp[i-1][j];
					}
				}
			}
			
			long ans = 0;
			
			for(int i = 0; i <= W; i++) {
				ans = Math.max(ans, dp[N][i]);
			}
			
			pw.println(ans);
			
			
			
			pw.close();
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



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

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

long long w[102], v[102];

long long dp[102][100002];

long long sentinel = 1e9 + 1;
long long solve(long long i, long long j, long long W) {
    if(i==0 && j==0)
        return 0;
    if(i==0)
        return sentinel;
    if(dp[i][j]!=sentinel)
        return dp[i][j];
    int ans= solve(i-1, j, W);
    if(v[i]<=j) {
        int min_prev_w = solve(i-1, j - v[i], W);
        if(min_prev_w + w[i] <=W)
            ans =  min(ans, min_prev_w + w[i]);
    }
    return dp[i][j] = ans;
}
int main() {
	long long n, W;
	cin>>n>>W;
	int i, j;
	for(i=1;i<=n;i++)
	    cin>>w[i] >> v[i];
	for(i=1;i<=n;i++)
	    for(j=1;j<=1e5;j++)
	        dp[i][j] = sentinel;
	        
	int ans = 0;
	for(i=1;i<=1e5;i++)
	    if(solve(n, i, W) <= W)
	        ans = i;
	 cout<<ans<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(long long int, long long int, long long int)':
a.cc:20:23: error: no matching function for call to 'min(int&, long long int)'
   20 |             ans =  min(ans, min_prev_w + w[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:20:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   20 |             ans =  min(ans, min_prev_w + w[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:20:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |             ans =  min(ans, min_prev_w + w[i]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>                                                                                                                         

using namespace std;

int main()
{
        ios::sync_with_stdio(false);
        cin.tie(0);
        long long n, w; cin >> n >> w;
        long long a[n+1], v[n+1];
        for (int i=1; i<=n; i++)
                cin >> a[i] >> v[i];
        long long dp[10001];
        long long ans = 0;
        memset(dp,0,sizeof(dp));
        for (int i=1; i<=n; i++)
        {
                for (int j=1e5; j>=v[i]; j--)
                {
                        dp[j] = min(dp[j], dp[j-v[i]] + a[i]);
                        if (dp[j]<=w) ans = max(ans, j);
                }
        }
        cout << ans;
        return 0;
}


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

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

const int maxn = 110, maxv = 1010;
long long dp[maxv], w[maxn], v[maxn];
int n, W, totv = 0;

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld %lld", &w[i], &v[i]);
		totv += v[i];
	}
	
	for (int i = 1; i <= n; i++)
		for (int j = totv; j >= v[i]; j--)
		{
			dp[j] = max(dp[j], dp[j-v[i]] + w[i]);
		}
	
	for (int i = totv; i >= 0; i--)
		if (dp[i] <= W)
			printf("%lld\n", dp[i]), break;			

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:50: error: expected primary-expression before 'break'
   27 |                         printf("%lld\n", dp[i]), break;
      |                                                  ^~~~~
Language: C++

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

const int maxn = 110, maxv = 1010;
long long dp[maxv], w[maxn], v[maxn];
int n, W, totv = 0;

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d %d", &w[i], &v[i]);
		totv += v[i];
	}
	
	for (int i = 1; i <= n; i++)
		for (int j = totv; j >= v[i]; j--)
		{
			dp[j] = max(dp[j], dp[j-v[i]] + w[i]);
		}
	
	for (int i = totv; i >= 0; i--)
		if (dp[i] <= W)
			printf("%lld\n", dp[i]), break;			

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:50: error: expected primary-expression before 'break'
   27 |                         printf("%lld\n", dp[i]), break;
      |                                                  ^~~~~
Language: C++

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

const int maxn = 110, maxv = 1010;
long long dp[maxv], w[maxn], v[maxn];
int n, W, totv = 0;
/**
dp[i][j]±íÊ¾Ñ¡Ç°i¸öÎïÆ·£¬·ÖÅäj¿Õ¼äÊ±»ñµÃµÄ×î´ó¼ÛÖµ 
*/
int main() {
	freopen("demo.in", "r", stdin);
	freopen("demo.out", "w", stdout);
	
	scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d %d", &w[i], &v[i]);
		totv += v[i];
	}
	
	for (int i = 1; i <= n; i++)
		for (int j = totv; j >= v[i]; j--)
		{
			dp[j] = max(dp[j], dp[j-v[i]] + w[i]);
		}
	
	for (int i = totv; i >= 0; i--)
		if (dp[i] <= W)
			printf("%lld\n", dp[i]), break;			

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:50: error: expected primary-expression before 'break'
   29 |                         printf("%lld\n", dp[i]), break;
      |                                                  ^~~~~
Language: C++

#include <iostream>

using namespace std;

int n, k, S, valmax, W[105], P[105];
long long dp[100100], sol;

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> W[i] >> P[i], S+=P[i];

    dp[P[1]] = W[1];
    valmax = P[1];
    if(dp[P[1]] <= k) sol = P[1];

    for(int i=2; i<=n; i++)
    {   for(int j=valmax; j>=1; j--)
            if(dp[j])
            {   if(!dp[j + P[i]]) dp[j + P[i]] = dp[j] + W[i];
                else dp[j + P[i]] = min(dp[j + P[i]], dp[j] + W[i]);
                if(dp[j + P[i]] <= k) sol = max(sol, j+P[i]);
                valmax = max(valmax, j + P[i]);
            }
        if(!dp[P[i]]) dp[P[i]] = W[i];
        else if(W[i] < dp[P[i]]) dp[P[i]] = W[i];
    }
    cout << sol << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:48: error: no matching function for call to 'max(long long int&, int)'
   22 |                 if(dp[j + P[i]] <= k) sol = max(sol, j+P[i]);
      |                                             ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:22:48: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |                 if(dp[j + P[i]] <= k) sol = max(sol, j+P[i]);
      |                                             ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided