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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll k;
ll dp[105][100005];

ll foo(ll i, vector<pair<ll, ll> > &v, ll n, ll w)
{

    if (i >= n || w==0)
        return 0;

    if(dp[i][w]!=-1) return dp[i][w];
    
     ll mx=INT_MIN;

     if(w>=v[i].first){
       
        ll  l = v[i].second + foo(i+1,v,n,w-v[i].first);
        ll r = foo(i+1,v,n,w);
        return dp[i][w]=max(l,r);

     }
     else{

         return dp[i][w]=foo(i+1,v,n,w);

     }

}
ll main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    cin >> k;
    ll a[n];

    memset(dp, -1, sizeof(dp));
    vector<pair<ll, ll> > v(n);
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        v[i] = make_pair(x, y);
    }

    long long mx = INT_MIN;

    ll x;

        x = foo(0, v, n, k);

        mx = max(x, mx);
    
    cout << mx << "\n";
}

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

#include <iostream>

using namespace std;
const int MAXV = 1e5 + 10;
long long dp[MAXV];

int main()
{
    int n,W;
    scanf("%d %d",&n,&W);
    int weight[n+1], value[n+1];
    int V = 0;
    for(int i=1; i<=n; i++){
        scanf("%d %d",&weight[i], &value[i]);
        V+=value[i];
    }
    
    for(int i = 1;i<=V;i++) dp[i] = INT_MAX;
    
    dp[0] = 0;
    
    for(int i=1; i<=n; i++){
        int v = value[i], w = weight[i];
        for(int j=V; j>=v; j--){
            dp[j] = min(dp[j], dp[j-v]+w);
        }
    }
    for(int i=V; i>=0; i--){
        if(dp[i]<=W){
            cout << i;
            break;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:37: error: 'INT_MAX' was not declared in this scope
   18 |     for(int i = 1;i<=V;i++) dp[i] = INT_MAX;
      |                                     ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 |
Language: C++

#include <iostream>

using namespace std;
const int MAXV = 1e5 + 10;
ll dp[MAXV];

int main()
{
    int n,W;
    scanf("%d %d",&n,&W);
    int weight[n+1], value[n+1];
    int V = 0;
    for(int i=1; i<=n; i++){
        scanf("%d %d",&weight[i], &value[i]);
        V+=value[i];
    }
    
    for(int i = 1;i<=V;i++) dp[i] = INF;
    
    dp[0] = 0;
    
    for(int i=1; i<=n; i++){
        int v = value[i], w = weight[i];
        for(int j=V; j>=v; j--){
            dp[j] = min(dp[j], dp[j-v]+w);
        }
    }
    for(int i=V; i>=0; i--){
        if(dp[i]<=W){
            cout << i;
            break;
        }
    }
    return 0;
}

Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll dp[MAXV];
      | ^~
a.cc: In function 'int main()':
a.cc:18:29: error: 'dp' was not declared in this scope
   18 |     for(int i = 1;i<=V;i++) dp[i] = INF;
      |                             ^~
a.cc:18:37: error: 'INF' was not declared in this scope
   18 |     for(int i = 1;i<=V;i++) dp[i] = INF;
      |                                     ^~~
a.cc:20:5: error: 'dp' was not declared in this scope
   20 |     dp[0] = 0;
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  ll n,W;
  cin>>n>>W;
  vector<pair<ll,ll>> v(n+1);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  max_val=n*1000;
  vector<vector<ll>> dp(n+1,vector<ll> (max_val+1,mod));
  dp[1][0]=0;
  dp[1][v[i].second]=v[i].first;
  for (ll i=2;i<=n;i++)
  {
    for (ll j=0;j<=max_val;j++)
    {
      dp[i][j]=dp[i-1][j];
      if (v[i].second<=j)
        dp[i][j]=min(dp[i][j],dp[i-1][j-v[i].second]+v[i].first);
    }
  }
  ll ans=INT_MIN;
  for (ll i=0;i<=max_val;i++)
    if (dp[n][i]<=W)
      ans=max(ans,i);
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'max_val' was not declared in this scope
   14 |   max_val=n*1000;
      |   ^~~~~~~
a.cc:17:11: error: 'i' was not declared in this scope
   17 |   dp[1][v[i].second]=v[i].first;
      |           ^
Language: C++

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

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  ll n,W;
  cin>>n>>W;
  vector<pair<ll>> v(n+1);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for (ll i=1;i<=n;i++)
  {
    for (ll w=0;w<=W;w++)
    {
      if (w<v[i].first)
        dp[i][w]=dp[i-1][w];
      else 
        dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: wrong number of template arguments (1, should be 2)
   10 |   vector<pair<ll>> v(n+1);
      |               ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:10:17: error: template argument 1 is invalid
   10 |   vector<pair<ll>> v(n+1);
      |                 ^~
a.cc:10:17: error: template argument 2 is invalid
a.cc:12:11: error: invalid types 'int[ll {aka long long int}]' for array subscript
   12 |     cin>>v[i].first>>v[i].second;
      |           ^
a.cc:12:23: error: invalid types 'int[ll {aka long long int}]' for array subscript
   12 |     cin>>v[i].first>>v[i].second;
      |                       ^
a.cc:19:14: error: invalid types 'int[ll {aka long long int}]' for array subscript
   19 |       if (w<v[i].first)
      |              ^
a.cc:22:44: error: invalid types 'int[ll {aka long long int}]' for array subscript
   22 |         dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      |                                            ^
a.cc:22:56: error: invalid types 'int[ll {aka long long int}]' for array subscript
   22 |         dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      |                                                        ^
Language: C++

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

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  ll n,W;
  cin>>n>>W;
  vector<vector<ll>> v(n+1);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for (ll i=1;i<=n;i++)
  {
    for (ll w=0;w<=W;w++)
    {
      if (w<v[i].first)
        dp[i][w]=dp[i-1][w];
      else 
        dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'first'
   12 |     cin>>v[i].first>>v[i].second;
      |               ^~~~~
a.cc:12:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'second'
   12 |     cin>>v[i].first>>v[i].second;
      |                           ^~~~~~
a.cc:19:18: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'first'
   19 |       if (w<v[i].first)
      |                  ^~~~~
a.cc:22:48: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'first'
   22 |         dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      |                                                ^~~~~
a.cc:22:60: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'second'
   22 |         dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      |                                                            ^~~~~~
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll(i) = 0; i < (ll)(n); ++(i))
#define INF 10e12
#define MOD 1000000000 + 7
#define MX 51000
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))

using namespace std;

struct nap
{
    ll w;
    ll v;
};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    ll takadaka = 1000 * N + 1;
    vector<ll> w(N);
    vector<ll> v(N);
    for (ll i = 0; i < N; ++i)
        cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(takadaka + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < takadaka; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v - v[i] >= 0)
                dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - v[i]] + w[i]);

            // i 番目の品物を選ばない場合
            else
                dp[i + 1][sum_v] = dp[i][sum_v];
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < takadaka; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}
}


Compiler output:
a.cc:76:1: error: expected declaration before '}' token
   76 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define saski ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e8+5;
#define se 1e5+5;
typedef long long ll ;
typedef long double ld;
ll dp[1000][100000007],weight[107],value[107];
ll n;
ll fn(ll i , ll we)
{
    if (i==n)
    {
        return 0;
    }
    if(we==0)
    {
        return 0;
    }
    if(dp[i][we]!=-1)
    {
        return dp[i][we];
    }
    ll ans = fn(i+1,we);
    if(weight[i]<=we)
    {
    ans =max(ans,value[i]+fn(i+1,we-weight[i]));
    }
    return dp[i][we]=ans;
}
int main()
{ saski;
ll w;
cin>>n>>w;
memset(dp,-1,sizeof dp);

for(int i=0;i<n;i++)
cin>>weight[i]>>value[i];
cout<<fn(0,w);
    return 0;
}

Compiler output:
/tmp/ccj1yGxi.o: in function `fn(long long, long long)':
a.cc:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj1yGxi.o
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccj1yGxi.o
a.cc:(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccj1yGxi.o
a.cc:(.text+0xec): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccj1yGxi.o
/tmp/ccj1yGxi.o: in function `main':
a.cc:(.text+0x1c0): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj1yGxi.o
a.cc:(.text+0x222): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccj1yGxi.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccj1yGxi.o
a.cc:(.text+0x26d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj1yGxi.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define saski ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e8+5;
#define se 1e5+5;
typedef long long ll ;
typedef long double ld;
ll dp[1000][100000007],weight[107],value[107];
ll n;
ll fn(int i , ll we)
{
    if (i==n)
    {
        return 0;
    }
    if(we==0)
    {
        return 0;
    }
    if(dp[i][we]!=-1)
    {
        return dp[i][we];
    }
    ll ans = fn(i+1,we);
    if(weight[i]<=we)
    {
    ans =max(ans,value[i]+fn(i+1,we-weight[i]));
    }
    return dp[i][we]=ans;
}
int main()
{ saski;
ll w;
cin>>n>>w;
memset(dp,-1,sizeof dp);

for(int i=0;i<n;i++)
cin>>weight[i]>>value[i];
cout<<fn(0,w);
    return 0;
}

Compiler output:
/tmp/ccIWxdQd.o: in function `fn(int, long long)':
a.cc:(.text+0x19): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIWxdQd.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccIWxdQd.o
a.cc:(.text+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccIWxdQd.o
a.cc:(.text+0xf2): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccIWxdQd.o
/tmp/ccIWxdQd.o: in function `main':
a.cc:(.text+0x1c6): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIWxdQd.o
a.cc:(.text+0x228): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccIWxdQd.o
a.cc:(.text+0x254): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccIWxdQd.o
a.cc:(.text+0x273): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIWxdQd.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits\stdc++.h>
using namespace std;
#define saski ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e8+5;
#define se 1e5+5;
typedef long long ll ;
typedef long double ld;
ll dp[1000][100007],weight[100],value[1000];
ll n;
ll fn(int i , ll we)
{
    if (i==n)
    {
        return 0;
    }
    if(we==0)
    {
        return 0;
    }
    if(dp[i][we]!=-1)
    {
        return dp[i][we];
    }
    ll ans = fn(i+1,we);
    if(weight[i]<=we)
    {
    ans =max(ans,value[i]+fn(i+1,we-weight[i]));
    }
    return dp[i][we]=ans;
}
int main()
{ saski;
ll w;
cin>>n>>w;
memset(dp,-1,sizeof dp);

for(int i=0;i<n;i++)
cin>>weight[i]>>value[i];
cout<<fn(0,w);
    return 0;
}

Compiler output:
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
    1 | #include<bits\stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

using namespace std; 
#include<bits/stdc++.h>
long long int max(int a, int b) 
{ 
	return (a > b) ? a : b; 
} 

long long int knapSack(int W, int wt[], int val[], int n) 
{ 
	int i, w; 
	long long int K[n + 1][W + 1]; 

	for (i = 0; i <= n; i++) { 
		for (w = 0; w <= W; w++) { 
			if (i == 0 || w == 0) 
				K[i][w] = 0; 
			else if (wt[i - 1] <= w) 
				K[i][w] = max( 
					val[i - 1] + K[i - 1][w - wt[i - 1]], 
					K[i - 1][w]); 
			else
				K[i][w] = K[i - 1][w]; 
		} 
	} 

	return K[n][W]; 
} 

int main() 
{ 
    long long int n,w;
    cin>>n>>w;
    long long int val[n],wt[n];
    for(int i=0;i<n;i++)
      cin>>wt[i]>>val[i];
    
	cout<<(knapSack(w, wt, val, n)); 
	return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:37:28: error: cannot convert 'long long int*' to 'int*'
   37 |         cout<<(knapSack(w, wt, val, n));
      |                            ^~
      |                            |
      |                            long long int*
a.cc:8:35: note:   initializing argument 2 of 'long long int knapSack(int, int*, int*, int)'
    8 | long long int knapSack(int W, int wt[], int val[], int n)
      |                               ~~~~^~~~
Language: C++

#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF =  1e17;
int k, m, t;ll  sum = 0, ans = 0; string s;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
ll n,dp[110][100100],weight[110],value[10010];
int main(void) {
    cin >> n >> m;
    rep(i, n) cin >> weight[i] >> value[i];
    Fill(dp, INF);
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 10010) {
            if (j - value[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
            }
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    rep(i, 100100) {
        if (dp[n][i] <= m) ans = i;
    }cout <<ans <<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:44:24: error: expected '}' at end of input
   44 |     }cout <<ans <<endl;
      |                        ^
a.cc:29:16: note: to match this '{'
   29 | int main(void) {
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[105][10000000];
unsigned long long int knapsack(unsigned long long int *wt,long long *val,unsigned long long int w, int n)
{
for(int i=0;i<=n;i++)
{
for(int j=0;j<=w;j++)
{
if(i==0 || j==0)
{
dp[i][j]=0;
}
else
{
if(wt[i-1]>j)
{
dp[i][j]=dp[i-1][j];
}
else
{
dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
}
}
}
}
return dp[n][w];

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


Compiler output:
a.cc: In function 'long long unsigned int knapsack(long long unsigned int*, long long int*, long long unsigned int, int)':
a.cc:22:13: error: no matching function for call to 'max(long long int, int&)'
   22 | dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][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:22:13: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 | dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][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:22:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 | dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

// dp[i][v] = tuye i taye aval ye tedadi ro var darim ke majume arzeshashun beshe v, hade aghal vazneshun che ghadre !
// dp[0][v[0]] = w[0]
// dp[0][0] = 0
// else dp[0][i] = oo

#include <bits/stdc++.h>

using namespace std;

const int N = 110;
const int V = 1e3 + 10;

long long n, W, v[N], w[N], dp[N][N * V];

int mian() {
    ios::sync_with_stdio(0);

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

    memset(dp, 63, sizeof(dp));
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < N * V; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i] >= 0)
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j]);
        }
    }

    for (int i = N * V - 1; ~i; i--)
        if (dp[n - 1][i] <= W) {
            cout << i << endl;
            return 0;
        }


    return 0;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

using ll = long long;
#define MOD 10e9 + 7;

int main() {
    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);
    for(int i = 0; i < n; ++i) {
        for(int j = W - w[i]; j >= 0; --j) {
            dp[j + w[i]] = max( (dp[j + w[i]]) % MOD, (dp[j] + v[i]) % MOD);
        }
    }

    cout << dp[W] % MOD << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:48: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'double' to binary 'operator%'
   17 |             dp[j + w[i]] = max( (dp[j + w[i]]) % MOD, (dp[j] + v[i]) % MOD);
a.cc:17:53: error: expected primary-expression before ',' token
   17 |             dp[j + w[i]] = max( (dp[j + w[i]]) % MOD, (dp[j] + v[i]) % MOD);
      |                                                     ^
a.cc:17:70: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'double' to binary 'operator%'
   17 |             dp[j + w[i]] = max( (dp[j + w[i]]) % MOD, (dp[j] + v[i]) % MOD);
      |                                                       ~~~~~~~~~~~~~~ ^
      |                                                              |
      |                                                              __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}
a.cc:17:75: error: expected primary-expression before ')' token
   17 |             dp[j + w[i]] = max( (dp[j + w[i]]) % MOD, (dp[j] + v[i]) % MOD);
      |                                                                           ^
a.cc:21:19: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'double' to binary 'operator%'
   21 |     cout << dp[W] % MOD << endl;
a.cc:21:25: error: expected primary-expression before '<<' token
   21 |     cout << dp[W] % MOD << endl;
      |                         ^~
Language: C

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

namespace DPE
{
	ll N;
	ll W;

	void Run(void)
	{
		cin >> N >> W;
		N++;
		vector<ll> w(N);
		vector<ll> v(N);
		rep(i, 1, N)
			cin >> w[i] >> v[i];

		const ll v_max = 1000 * N + 1;
		vector<vector<ll>> dp(N, vector<ll>(v_max, W+1));
		dp[0][0] = 0;
		rep(i, 1, N)
		{
			rep(j, 0, v_max)
			{
				if (j == 0)
					dp[i][j] = 0;
				else
					dp[i][j] = (0 <= j - v[i]) ? min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j]) : dp[i - 1][j];
			}
		}

		repr(j, v_max - 1, -1)
		{
			if (dp.back()[j] <= W)
			{
				cout << j << endl;
				return;
			}
		}

	}
};

int main(void)
{
	DPE::Run();
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll dp[101][100001];


ll solve(ll n,ll val,ll wt[])
{
     if(val==0)return 0;
    // if(n<0)return INT_MAX;
     if(val<0)return INT_MAX;
     if(n==0)return INT_MAX;
     if(dp[n][val]!=-1)
     return dp[n][val];
     return dp[n][val]=min(solve(n-1,v-val[n],wt),solve(n-1,v-val[n],wt)+wt[n]);
     
}
int main()
{
     tez;
     ll n,w;
     cin>>n>>w;
     ll wt[n],val[n];
     for(ll i=0;i<101;i++)
     {
          for(ll j=0;j<100001;j++)
          {
               dp[i][j]={-1};
          }
     }
     for(ll i=0;i<n;i++)
     {
          cin>>wt[i]>>val[i];
     }
     ll v;
     for( v=100000;v>=0;v--)
     {
          ll ans=solve(0,v,wt);
          if(ans<=w)
          {
               break;
          }
     }
     cout<<v<<"\n";
     
}

Compiler output:
a.cc: In function 'long long int solve(long long int, long long int, long long int*)':
a.cc:16:38: error: 'v' was not declared in this scope
   16 |      return dp[n][val]=min(solve(n-1,v-val[n],wt),solve(n-1,v-val[n],wt)+wt[n]);
      |                                      ^
a.cc:16:43: error: invalid types 'long long int[long long int]' for array subscript
   16 |      return dp[n][val]=min(solve(n-1,v-val[n],wt),solve(n-1,v-val[n],wt)+wt[n]);
      |                                           ^
a.cc:16:66: error: invalid types 'long long int[long long int]' for array subscript
   16 |      return dp[n][val]=min(solve(n-1,v-val[n],wt),solve(n-1,v-val[n],wt)+wt[n]);
      |                                                                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,w;
ll wei[101],val[101];
ll dp[101][100001];
ll fun(ll ind, ll wt){
    if(ind ==n)
    return 0;
    if(wt>w ) return INT_MIN;
    
    
    if(dp[ind][wt] != -1) return dp[ind][wt];
    
   ll maxi=0;
    
    if(wt+wei[ind] < w){
       ll l= val[ind]+fun(ind+1 , wt+wei[ind]);
       ll r= fun(ind+1 , wt);
      return dp[ind][wt] = max(l,r);
    }
    else{
      return dp[ind][wt] = fun(ind+1 , wt);
    }
    return dp[ind][wt]
}
int main() {
cin>>n>>w;
for(ll i=0;i<n;i++)
cin>>wei[i]>>val[i];
memset(dp , -1 , sizeof dp);
cout<<fun(0,0);
	return 0;
}

Compiler output:
a.cc: In function 'll fun(ll, ll)':
a.cc:25:23: error: expected ';' before '}' token
   25 |     return dp[ind][wt]
      |                       ^
      |                       ;
   26 | }
      | ~
Language: C++

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

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define LL long long
#define ULL unsigned long long
#define LB lower_bound
#define MOD1 1000000007
#define MOD2 1000000009
#define int LL
int N, W;
vector<vector<int>> arr;

int solve()
{
    vector<vector<int>> dp(N+1, vector<int>(W+1, 0));

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

    return dp[N][W];
}

int main()
{
    static const int _ = []() {
        ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        return 0;
    }();
    cin >> N >> W;
    arr.resize(N);

    for (int i = 0; i < N; i++)
    {
        arr[i].resize(2);
        for (int j = 0; j < 2; j++)
            cin >> arr[i][j];
    }

    cout << solve();

    return 0;
}


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:31:25: error: could not convert 'w' from 'vector<long int>' to 'vector<int>'
   31 |         cout<<knapsack1(w,v,W);
      |                         ^
      |                         |
      |                         vector<long int>
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long t[101][10000001];

int  n=0,w=0;
long long int knapsack(int n,int w,long long int weight_array[],int value_array[]){
if(n==0||w==0)
    return 0;
if(t[n][w]!=-1)
    return t[n][w];
if(weight_array[n-1]>w)
    return t[n][w]=knapsack(n-1,w,weight_array,value_array);
else
    return t[n][w]=max(value_array[n-1]+knapsack(n-1,w-weight_array[n-1],weight_array,value_array),knapsack(n-1,w,weight_array,value_array));


}
int main() {
int testcase=1;
//cin>>testcase;
for(int p=0;p<testcase;p++){

    cin>>n>>w;
    long long weight_array[n]={0};
    int value_array[n]={0};

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

       cin >>weight_array[i]>>value_array[i];
    }
    memset(t,-1,sizeof(t));
    cout<<knapsack(n,w,weight_array,value_array)<<"\n";
}
    return 0;
}


Compiler output:
/tmp/ccMRg1d5.o: in function `main':
a.cc:(.text+0x21d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccMRg1d5.o
a.cc:(.text+0x239): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccMRg1d5.o
a.cc:(.text+0x24a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccMRg1d5.o
a.cc:(.text+0x2c9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccMRg1d5.o
a.cc:(.text+0x39b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccMRg1d5.o
a.cc:(.text+0x3c7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccMRg1d5.o
a.cc:(.text+0x3cd): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccMRg1d5.o
collect2: error: ld returned 1 exit status
Language: C++

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

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

//primitive data types
typedef long long ll;

//pair
typedef pair<ll,ll> pll;
typedef pair<string,ll> psl;
#define mp(x,y) make_pair(x,y)
#define f first
#define s second

//vector
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<string> vs;
#define pb(x) push_back(x)

//control statements
#define fori(i,start,end) for(ll i = start ; i <= end ; i++)
#define ford(i,start,end) for(ll i = start ; i >= end ; i--)

const ll INF = 1e18L;

void solve(){
  ll N,W;
  cin>>N>>W;
  vpll items(N, {0,0});
  ll max_val = 0;
  for(auto item : items){
    cin>>item.f>>item.s;
    max_val += item.s;
  }
  vll dp(max_val + 1, INF);
  dp[0] = 0;
  for(ll item = 0 ; item < N ; i++){
    for(ll v = max_val ; v >= items[item].s ; v--)
      dp[v] = min(dp[v], dp[v - items[item].s] + items[item].f);
  }
  ford(i, max_val, 0){
    if(dp[i] <= W){
      cout<<i;
      return;
    }
  }
}

int main(){
  fastIO();
  ll t;
  cin>>t;
  while(t--){
    solve();
    cout<<"\n";
  }
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:39:32: error: 'i' was not declared in this scope
   39 |   for(ll item = 0 ; item < N ; i++){
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long t[101][1000000001];

int  n=0,w=0;
long long int knapsack(int n,int w,long long int weight_array[],int value_array[]){
if(n==0||w==0)
    return 0;
if(t[n][w]!=-1)
    return t[n][w];
if(weight_array[n-1]>w)
    return t[n][w]=knapsack(n-1,w,weight_array,value_array);
else
    return t[n][w]=max(value_array[n-1]+knapsack(n-1,w-weight_array[n-1],weight_array,value_array),knapsack(n-1,w,weight_array,value_array));


}
int main() {
int testcase=1;
//cin>>testcase;
for(int p=0;p<testcase;p++){

    cin>>n>>w;
    long long weight_array[n]={0};
    int value_array[n]={0};

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

       cin >>weight_array[i]>>value_array[i];
    }
    memset(t,-1,sizeof(t));
    cout<<knapsack(n,w,weight_array,value_array)<<"\n";
}
    return 0;
}


Compiler output:
/tmp/ccfJWtyT.o: in function `main':
a.cc:(.text+0x21d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccfJWtyT.o
a.cc:(.text+0x239): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccfJWtyT.o
a.cc:(.text+0x24a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccfJWtyT.o
a.cc:(.text+0x2c9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccfJWtyT.o
a.cc:(.text+0x39b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccfJWtyT.o
a.cc:(.text+0x3c7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccfJWtyT.o
a.cc:(.text+0x3cd): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccfJWtyT.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long t[101][1000000001];

int  n=0,w=0;
long long int knapsack(int n,int w,int weight_array[],int value_array[]){
if(n==0||w==0)
    return 0;
if(t[n][w]!=-1)
    return t[n][w];
if(weight_array[n-1]>w)
    return t[n][w]=knapsack(n-1,w,weight_array,value_array);
else
    return t[n][w]=max(value_array[n-1]+knapsack(n-1,w-weight_array[n-1],weight_array,value_array),knapsack(n-1,w,weight_array,value_array));


}
int main() {
int testcase=1;
//cin>>testcase;
for(int p=0;p<testcase;p++){

    cin>>n>>w;
    long long weight_array[n]={0};
    int value_array[n]={0};

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

       cin >>weight_array[i]>>value_array[i];
    }
    memset(t,-1,sizeof(t));
    cout<<knapsack(n,w,weight_array,value_array)<<"\n";
}
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:24: error: cannot convert 'long long int*' to 'int*'
   33 |     cout<<knapsack(n,w,weight_array,value_array)<<"\n";
      |                        ^~~~~~~~~~~~
      |                        |
      |                        long long int*
a.cc:7:40: note:   initializing argument 3 of 'long long int knapsack(int, int, int*, int*)'
    7 | long long int knapsack(int n,int w,int weight_array[],int value_array[]){
      |                                    ~~~~^~~~~~~~~~~~~~
Language: Java

import java.util.HashMap;
import java.util.Scanner;

public class e {
    static long[] we;
    static long[] va;
    static long w;
    static int n;
    static HashMap<Long, Long>[] memo;

    static long go(int i, long weight) {
        if (i == n) {
            return 0;
        }
        if (memo[i].containsKey(weight)) {
            return memo[i].get(weight);
        }

        long res = 0;

        // take:
        if (weight + we[i] <= w) { // if we can
            res = Math.max(res,
                    va[i] + go(i + 1, weight + we[i])
                    );
        }

        // not take:
        res = Math.max(res,
                go(i + 1, weight)
        );

        memo[i].put(weight, res);
        return res;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        w = scan.nextLong();
        we = new long[n];
        va = new long[n];
        for (int i = 0; i < n; ++i) {
            we[i] = scan.nextLong();
            va[i] = scan.nextLong();
        }
        memo = new HashMap[n];
        for (int i = 0; i < n; ++i) {
            memo[i] = new HashMap<>();
        }
        System.out.println(go(0, 0));
    }
}


Compiler output:
Main.java:4: error: class e is public, should be declared in a file named e.java
public class e {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: Java

import java.util.*;
public class knapsack2 {

	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		int numItems = kb.nextInt();
		int maxWeight = kb.nextInt();

		//i is weight, dp[i] is value at weight i
		long[] dp = new long[(int)1e5+1];
		//fill with -1 so we know that we dont know anything there
		Arrays.fill(dp, -1);
		//base case, have nothing
		dp[0] = 0;
		
		//consider items
		//build up the array
		for(int i = 0; i < numItems; i++) {
			long weight = kb.nextInt();
			int value = kb.nextInt();
			for(int j = dp.length-1; j >= 0; j--) {
			//	System.out.println("i:"+i+" j:"+j);
				//-1 means no way to get to state, so we cant build off this
				if(dp[j] == -1) {
					continue;
				}
				//if inbounds
				if(dp[value]+dp[j] <= dp.length-1) {
					// System.out.println("this "+(dp[value]+dp[j]));
					if(dp[value+j]==-1)
						dp[value+j] = dp[j] + weight;
					else{
						dp[value+j] = Math.min(dp[value+j], dp[j]+weight);
						// System.out.println("dp[val+j] "+dp[(value+j)]+" i:"+i+" j:"+j);
					}
				}
			}
		}
		
		long max = 0;
		for(int i = 0; i < dp.length; i++) {
			if(dp[i] != -1 && dp[i] <= maxWeight){
                max = i;
            }
		}
		System.out.println(max);
	}

}

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

// C++ implementation of the approach 
#include <bits/stdc++.h> 
#define ll long long int
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() 
{ 
    ll n;
    cin>>n;
    ll W;
    cin>>W;
    ll w[n+1];
    ll val[n+1];
    for(int i=1;i<=n;i++)
        cin>>w[i]>>alv[i];

	



	cout << maxWeight(w, val, n, W); 

	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:61:20: error: 'alv' was not declared in this scope
   61 |         cin>>w[i]>>alv[i];
      |                    ^~~
a.cc:67:27: error: cannot convert 'long long int*' to 'int*'
   67 |         cout << maxWeight(w, val, n, W);
      |                           ^
      |                           |
      |                           long long int*
a.cc:37:20: note:   initializing argument 1 of 'int maxWeight(int*, int*, int, int)'
   37 | int maxWeight(int* w, int* val, int n, int c)
      |               ~~~~~^
Language: C++

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n, w;
ll ans;
ll dp[1e9+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> w;
    
    for(ll i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;
        for(ll j = 1e9+1; j >= x; --j){
            dp[j] = max(dp[j-x] + y, dp[j]);
            //cout << i << " " << j << " " << dp[j] << "\n";
        }
    }
    cout << dp[min(w, (ll)1e9)] << "\n";
    
}


Compiler output:
a.cc:16:10: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   16 | ll dp[1e9+1];
      |       ~~~^~
a.cc:16:10: error: could not convert '(1.0e+9 + (double)1)' from 'double' to 'long unsigned int'
   16 | ll dp[1e9+1];
      |       ~~~^~
      |          |
      |          double
a.cc:16:10: error: size of array 'dp' has non-integral type 'double'
Language: C++

#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pp pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>

using namespace std;

ll kp2(vi& profit,vi& wt,ll maxwt,ll maxv){
    int n=profit.size();
    vvi dp(n+1,vi(maxv+1,INT_MAX));
    ll ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=maxv;j++){
            if(j>=wt[i-1]){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-wt[i-1]]+profit[i-1]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
           if(dp[i][j]<=maxwt){
            ans=max(ans,j);
        }
        }
    }
    return ans;
}

int main(){
  ll n,W;
  cin>>n>>W;
  ll tsum=0;
  vector<ll> p(n);
  vector<ll> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i]>>p[i];
    tsum+=p[i];
  }
  cout<<kp2(p,w,W,tsum);
}


Compiler output:
a.cc: In function 'll kp2(std::vector<long long int>&, std::vector<long long int>&, ll, ll)':
a.cc:25:20: error: no matching function for call to 'max(ll&, int&)'
   25 |             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:25:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |             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:25:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |             ans=max(ans,j);
      |                 ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pp pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>

using namespace std;

ll kp2(vi& profit,vi& wt,ll maxwt,ll maxv){
    int n=profit.size();
    vvi dp(n+1,vi(maxv+1,INT_MAX));
    ll ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=maxv;j++){
            if(j>=wt[i-1]){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-wt[i-1]]+profit[i-1]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
        if(dp[i][j]<=maxwt){
            ans=max(ans,dp[i][j]);
        }
    }
    return ans;
}

int main(){
  ll n,W;
  cin>>n>>W;
  ll tsum=0;
  vector<ll> p(n);
  vector<ll> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i]>>p[i];
    tsum+=p[i];
  }
  cout<<kp2(p,w,W,tsum);
}


Compiler output:
a.cc: In function 'll kp2(std::vector<long long int>&, std::vector<long long int>&, ll, ll)':
a.cc:25:18: error: 'j' was not declared in this scope
   25 |         if(dp[i][j]<=maxwt){
      |                  ^
Language: C++

#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pp pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>

using namespace std;

ll kp2(vi& profit,vi& wt,int maxwt,maxv){
    int n=profit.size();
    vvi dp(n+1,vi(maxv+1),INT_MAX);
    ll ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=maxv;j++){
            if(j>=wt[i-1]){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-wt[i-1]]+profit[i-1]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
        if(dp[i][j]<=maxwt){
            ans=max(ans,dp[i][j]);
        }
    }
    return ans;
}

int main(){
  ll n,W;
  cin>>n>>W;
  ll tsum=0;
  vector<ll> p(n);
  vector<ll> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i]>>p[i];
    tsum+=p[i];
  }
  cout<<kp2(p,w,W,tsum);
}


Compiler output:
a.cc:12:36: error: 'maxv' has not been declared
   12 | ll kp2(vi& profit,vi& wt,int maxwt,maxv){
      |                                    ^~~~
a.cc: In function 'll kp2(std::vector<long long int>&, std::vector<long long int>&, int, int)':
a.cc:14:19: error: 'maxv' was not declared in this scope
   14 |     vvi dp(n+1,vi(maxv+1),INT_MAX);
      |                   ^~~~
a.cc:25:18: error: 'j' was not declared in this scope
   25 |         if(dp[i][j]<=maxwt){
      |                  ^
Language: Java

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

class Main {

    // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long W;
        W = sc.nextLong();
        long[] w = new long[(int)(N)];
        long[] v = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                w[i] = sc.nextLong();
                v[i] = sc.nextLong();
        }
        solve(N, W, w, v);
    }

    static void solve(long N, long W, long[] w, long[] v){
        long V = 0;
        for (int i = 0; i < v.length; i++){
            V += v[i];
        }
        long[] dp = new long[(int)(V+1)];

        for (int i = 1; i <= w.length; i++){
            for (int j = (int)V; j >= v[i-1]; j--){
                dp[j] = Math.min(dp[j], dp[j-(int)v[i-1]] + w[i-1]);
            }
        }

        for (int i = V; i >= 0; i--){
            if (dp[i] <= W){
                System.out.print(i);
                return;
            }
        }
        System.out.print(0);
        return;


    }
}


Compiler output:
Main.java:35: error: incompatible types: possible lossy conversion from long to int
        for (int i = V; i >= 0; i--){
                     ^
1 error