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

#include <iostream>

using namespace std;
int N,W;
long long pesos[120];
long long valores[120];

int main(){
    cin>>N>>W;
    long long matriz[N+10][W+10];

    for (int i=1;i<=N;i++){
        cin>>pesos[i]>>valores[i];
    }

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

    /*for (int i= 0; i <= N; i++){
        for (int j=0; j <= W; j++){
            cout<<matriz[i][j]<<" ";          
        }
        cout<<endl;
    }*/
    cout<<matriz[N][W];

}

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

#include <iostream>

using namespace std;
int N,W;
long long int pesos[120];
int valores[120];

int main(){
    cin>>N>>W;
    long long matriz[N+10][W+10];

    for (int i=1;i<=N;i++){
        cin>>pesos[i]>>valores[i];
    }

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

    /*for (int i= 0; i <= N; i++){
        for (int j=0; j <= W; j++){
            cout<<matriz[i][j]<<" ";          
        }
        cout<<endl;
    }*/
    cout<<matriz[N][W];

}

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

// C++ program to demonstrate insertion 
// into a vector of vectors 



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


main() 
{ 
    
	unsigned long long int  n, w;
	cin >> n;
	cin >> w;
	vector<unsigned long long int> wi(n);
	vector<unsigned long long int> pi(n);
	for(int i=0; i< n; i++){
	    cin >> wi[i];
	    wi.push_back(wi[i]);
	    cin >> pi[i];
	    pi.push_back(pi[i]);
	}
	
	vector<vector <unsigned long long int> > dp(n+1, vector <unsigned long long int> (w+1));
	for(unsigned unsigned long long int i=0; i <= n; i++ ){
	    for(unsigned long long int j= 0; j <= w; j++ ){ 
	        if(i==0 || j==0){
	            dp[i][j]=0;
	            continue;
	        }
	        if(wi[i-1] > j)
	            dp[i][j] = dp[i-1][j];
	        else {
	            unsigned long long int temp = j-wi[i-1];
	            dp[i][j] = max(pi[i-1]+dp[i-1][temp], dp[i-1][j]);
	        }
	    }
	}
	
	cout << dp[n][w];
} 


Compiler output:
a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:22: error: duplicate 'unsigned'
   27 |         for(unsigned unsigned long long int i=0; i <= n; i++ ){
      |                      ^~~~~~~~
      |                      --------
Language: C++

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:52:14: error: expected '}' at end of input
   52 |     return 0;
      |              ^
a.cc:16:1: note: to match this '{'
   16 | {
      | ^
Language: C++

#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef int long long;
int n , we , Max=0,s=0;
int const oo=1000005;
int w[100005] , v[100005];
int f[105][1005];

int main()
{
    cin >> n >> we;
    memset(f , oo , sizeof(f));
    for(int i=1 ;i<=n ; i++)
    {
        cin >> w[i] >> v[i];
        s+=v[i];
    }
    for(int j=1 ; j<=s ;j++)
    {
        f[0][j]=oo;
    }
    for(int i=0 ; i<=n ; i++)
    {
        f[i][0]=0;
    }
    for(int i=0 ; i<n; i++)
    {
        for(int j=0 ; j<=s ; j++)
        {
            if(f[i][j]!=oo){
            f[i+1][j]=min(f[i+1][j],f[i][j]);
            if(f[i][j]+w[i+1]<=we)
            {
                f[i+1][j+v[i+1]]=min(f[i+1][j+v[i+1]], f[i][j]+w[i+1]);
            }
            }
        }
    }
    for(int i=0 ; i<=s ; i++)
    {
        if(f[n][i]<=we){
            Max=max(Max , i);
        }
    }
    cout << Max;
}



Compiler output:
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | typedef int long long;
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  int n, w;
  cin >> n >> w;
  vector<int> val(n+1);
  vector<int> wt(n+1);
  int total_val = 0;
  for(int i=1; i<=n; i++){
  	cin >> wt[i] >> val[i];
    total_val += val[i];
  }
  vector<vector<ll>> dp(n+1, vector<ll>(total_val+1, LLONG_MAX));
  for(int i=0; i<=n; i++) dp[i][0] = 0;
  for(int i=1; i<n; i++){
  	for(int j=1; j<=total_val; j++){
    	if(val[i]<=j){
      		dp[i][j] = min(wt[i] + dp[i-1][j-val[i]], dp[i-1][j]);
        }
      	else{
          dp[i][j] = dp[i-1][j];
        }
    }
  }
  for(int i=total_val; i>=0; i--){
  	if(dp[n][i])
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: expected primary-expression before '}' token
   29 |   }
      |   ^
Language: C++

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

const int MAXN = 105;
const int MAXW = 10e9+5;

int n, w, v[MAXN], b[MAXN];
long long dp[MAXN][MAXW];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> w;
    for (int i = 0; i < n; i++) cin >> b[i] >> v[i];
    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 (b[i-1] <= j) dp[i][j] = max(dp[i-1][j], v[i-1]+dp[i-1][j-b[i-1]]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][w] << "\n";
    return 0;
}


Compiler output:
a.cc:5:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000005e+10' to '2147483647' [-Woverflow]
    5 | const int MAXW = 10e9+5;
      |                  ~~~~^~
a.cc:8:20: error: size of array 'dp' exceeds maximum object size '9223372036854775807'
    8 | long long dp[MAXN][MAXW];
      |                    ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
#include <set>
using namespace std;
long long i,j,t;
const int z = 1e5 + 5;
pair <long long ,long long>p[2000];
set <pair <int,int> > s;
long long n,k;
map<pair<int,int>,int >h;
long long req (long long r, long long c){
	long long res = 0;
	if (r==-1 || c<=0) return 0;
	if (s.find({r,c})!=s.end()) return h[{r,c}];
	else if (c<p[r].first) res = req(r-1, c);
	else {
		long long t1 = req(r-1,c);
		long long t2 = p[r].second + req(r-1, c - p[r].first);
		res = max(t1,t2);
	}
	h[{r,c}] = res;
    s.insert({r,c});
	return res;
	
}
int main(){
	cin>>n>>k;
    memset(h,-1 ,sizeof(h));
	for (i=0; i<n; i++){
		cin>>p[i].first>>p[i].second;
	}
	cout<<req(n-1, k);
}


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

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
#include <set>
using namespace std;
long long i,j,t;
const int z = 1e5 + 5;
pair <long long ,long long>p[2000];
set <pair <int,int> > s;
long long n,k;
map<pair<int,int>,int >h;
long long req (long long r, long long c){
	long long res = 0;
	if (r==-1 || c<=0) return 0;
	if (s.find({r,c}!=s.end()) return h[{r,c}];
	else if (c<p[r].first) res = req(r-1, c);
	else {
		long long t1 = req(r-1,c);
		long long t2 = p[r].second + req(r-1, c - p[r].first);
		res = max(t1,t2);
	}
	h[{r,c}] = res;
    s.insert({r,c});
	return res;
	
}
int main(){
	cin>>n>>k;
    memset(h,-1 ,sizeof(h));
	for (i=0; i<n; i++){
		cin>>p[i].first>>p[i].second;
	}
	cout<<req(n-1, k);
}


Compiler output:
a.cc: In function 'long long int req(long long int, long long int)':
a.cc:17:25: error: expected ')' before '!=' token
   17 |         if (s.find({r,c}!=s.end()) return h[{r,c}];
      |                   ~     ^~
      |                         )
a.cc:17:35: error: expected ';' before 'return'
   17 |         if (s.find({r,c}!=s.end()) return h[{r,c}];
      |                                   ^~~~~~~
      |                                   ;
a.cc:17:50: error: expected primary-expression before ']' token
   17 |         if (s.find({r,c}!=s.end()) return h[{r,c}];
      |                                                  ^
a.cc:17:50: error: expected ')' before ']' token
   17 |         if (s.find({r,c}!=s.end()) return h[{r,c}];
      |            ~                                     ^
      |                                                  )
a.cc:17:50: error: expected primary-expression before ']' token
a.cc: In function 'int main()':
a.cc:31:12: error: cannot convert 'std::map<std::pair<int, int>, int>' to 'void*'
   31 |     memset(h,-1 ,sizeof(h));
      |            ^
      |            |
      |            std::map<std::pair<int, int>, int>
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:5:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
// ****  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fl(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define fi(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> dmap;
typedef set<int> dset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
/********** solver function **********/
 int solve(int i, vector<long long int>&w, vector<int>&v, long long int we, vector<vector<int>>&dp){
    if( we==0) return 0;
    cout<<"hi";
    if( i==v.size()-1){ if( w[i]<=we) return v[i];
    else return 0;
    }
    cout<<"H";
    if( we<0 || i>=v.size())  return INT_MIN;
    if( dp[i][we]!=-1) return dp[i][we];
     int a=INT_MIN, b=INT_MIN;
    if( w[i]<=we)
    {a=v[i]+solve( i+1, w, v, we-w[i], dp);b=solve( i+1, w,v,we, dp);
    return dp[i][we]= max(a,b);
    }
    else{
        return dp[i][we]=solve( i+1, w,v,we,dp);
    }
}
int main()
{std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
    long long int we; cin>>we;
    vector<long long int>w(n);
    vector<int>v(n);
    vector<vector<int>>dp(n,vector<int>(2*we,-1));
     for( int i=0;i<n;i++){
         cin>>w[i]>>v[i];
     }
    cout<<solve(0, w, v, we, dp)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve(int, std::vector<long long int>&, std::vector<int>&, long long int, std::vector<std::vector<int> >&)':
a.cc:60:38: error: 'INT_MIN' was not declared in this scope
   60 |     if( we<0 || i>=v.size())  return INT_MIN;
      |                                      ^~~~~~~
a.cc:25:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   24 | #include <assert.h>
  +++ |+#include <climits>
   25 | using namespace std;
a.cc:62:12: error: 'INT_MIN' was not declared in this scope
   62 |      int a=INT_MIN, b=INT_MIN;
      |            ^~~~~~~
a.cc:62:12: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:64:44: error: 'b' was not declared in this scope
   64 |     {a=v[i]+solve( i+1, w, v, we-w[i], dp);b=solve( i+1, w,v,we, dp);
      |                                            ^
Language: C++

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


const ll INF = 1e18;

ll knapsack2(int n, int W){
    
    ll weight[n] = {};
    ll value[n] = {};
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
    }
    
    int val_sum = 0;
    for(int x : value) val_sum += x;

    // 2-D array solving

    // vector<vector<ll>> dp(n+1,vector<ll>(val_sum+1,INF));
    // dp[0][0] = 0;
    // for(int i = 1; i <= n; i++){
        
    //     for(int j = 0; j < value[i-1]; j++) dp[i][j] = dp[i-1][j];
    //     for(int j = val_sum; j >= value[i-1]; j--){
    //         dp[i][j] = min(dp[i-1][j], weight[i-1] + dp[i-1][j-value[i-1]]);
    //     }
        
    // }
    
    // ll ans = 0;
    // for(ll j = 0; j <= val_sum; j++){
    //     if(dp[n][j] <= W) ans = max(ans, j);
    // }
    
    
    1d array solving
    vector<ll>dp(val_sum+1, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = val_sum; j >= value[i]; j--){
            dp[j] = min( dp[j] , (dp[j-value[i]]+weight[i]));
            
        }
    }
    
    ll ans = 0;
    for(ll j = 0 ; j <= val_sum; j++){
        if(dp[j] <= W) ans = max(ans,j);
    }
    
    
    return ans;
}
 
 
int main(){
    int n,W ; cin >> n >> W;
    cout << knapsack2(n,W) ;
    return 0;
}

Compiler output:
a.cc: In function 'long long int knapsack2(int, int)':
a.cc:38:5: error: unable to find numeric literal operator 'operator""d'
   38 |     1d array solving
      |     ^~
a.cc:40:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   40 |     dp[0] = 0;
      |     ^~
      |     dup
Language: C++

# include <bits/stdc++.h>
# define int long long
# define fi first
# define se second

using namespace std ;

const int N = 1e7 + 4;
int n, w, W[200], V[200], dp[200][N], mx;

int32_t main() {
    //freopen("haybales.in", "r", stdin ) ;
    //freopen("haybales.out", "w", stdout ) ;
    cin >> n >> w ;
    for( int i = 1 ; i <= n ; i ++ ) {
        cin >> W[i] >> V[i] ;
    }
    for( int i = 0 ; i <= n ; i ++ )  {
        for( int j = 1 ; j < N ; j ++ ) {
            dp[i][j] = 1e7 ;
        }
    }
    for( int i = 1 ; i <= n ; i ++ ) {
        for( int j = 1 ; j < N ; j ++ ) {
            dp[i][j] = dp[i-1][j] ;
            if( V[i] <= j ) {
                dp[i][j] = min( dp[i][j], dp[i-1][j-V[i]] + W[i] ) ;
            }
        }
    }
    for( int i = 1 ; i < N ; i ++ ) {
        if( dp[n][i] <= w ) mx = i ;
    }
    cout << mx << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main() {
  int n,wt ;cin >> n>> wt;
  vector<int>w(n),v(n) ;
  for(int i=0;i<n;i++)
    cin >> w[i] >> v[i] ;
  vector<vector<int>>dp(n,vector<int>((int)1e5+1));
  // dp[i][j]->min wt.after processing first i wts. and having a value of j  
  //dp[i][j]=min(dp[i-1][j-w[i]]+v[i],dp[i-1][j])
  for(int i=0;i<(int)1e5+1;i++)
    dp[0][i]=(v[0]==i?w[0]:(int)1e12) ;
  dp[0][0]=0 ;
  for(int i=1;i<n;i++)
    for(int j=0;j<(int)1e5+1;j++)
      dp[i][j] =min(dp[i-1][j],(j>=v[i]?dp[i-1][j-v[i]]+w[i]:(int)1e12)) ;
  int ans ;
  for(int i=0;i<(int)1e5+1;i++){
    ans=(dp[n-1][i]<=wt?i:ans) ;
  cout << ans  ;
}

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

/*-------------------------------*
| Name: Ayush Kumar              |
| Site: atcoder                  |
| Email: ayushkr667@gmail.com    |
*-------------------------------*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF (ll) 1e18
const double PI = 3.141592653589793238460;

ll weigh[101], val[101];

ll solve(ll n, ll w)
{
    if(w == 0)
        return 0;
    if(n == 0)
        return 0;
    
    if(weigh[n] > w)
        return solve(n-1, w);

    else
    {
        return max( (val[n] + solve(n-1, w-weigh[n])), solve(n-1, w));
    }    
}


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


Compiler output:
a.cc: In function 'int main()':
a.cc:38:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   38 |     memset(dp, -1, sizeof(dp));
      |            ^~
      |            dup
Language: Java

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
     public static int minCost(int []w , int []v , int curr_ind , int n , int [][]dp , int k_w){
	        if(curr_ind > n || k_w <= 0 )
	        return 0;
	        
	        if(dp[curr_ind][k_w]!=-1) return dp[curr_ind][k_w];
	        
	        int a = Long.MIN_VALUE;
	        
	        // do not pick
	        a = Math.max(a , minCost(w,v,curr_ind + 1 , n , dp , k_w ) );
	        
	        //pick the element
	       
	         
	        
	        if(w[curr_ind] <= k_w ){
	            
	       //      System.out.println("pick the ele :");
	       //  System.out.println("item w : "+ w[curr_ind]);
	       //   System.out.println("knap w : "+ k_w);
	            
	          
	             a = Math.max(a , (v[curr_ind] + minCost(w , v , curr_ind + 1 ,n, dp ,  k_w - w[curr_ind])) );
	        }
	        
	        
	       
	        
	        return dp[curr_ind][k_w] = a;
	        
	        
	    }
    
	public static void main (String[] args) throws java.lang.Exception
	{
	    
	   
	    
	    
		// your code goes here
		 Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = sc.nextInt();
		int k_w = sc.nextInt();
		
	//	System.out.println("W : "+k_w);
		    int w[] = new int[n+1];
			int v[] = new int[n+1];
			
			
		for(int i = 1 ;i<=n;i++){
		  
		    w[i] = sc.nextInt();
		    v[i] = sc.nextInt();
		    
			}
			
			
			int dp[][]=new int[n + 1][k_w + 1];
			
			for(int i=0;i<n+1;i++){
		      for(int j =0;j<k_w + 1;j++){
			dp[i][j] = -1 ;
			}}
			
			System.out.println(minCost(w , v, 1 , n , dp , k_w));
	}
}


Compiler output:
Main.java:16: error: incompatible types: possible lossy conversion from long to int
	        int a = Long.MIN_VALUE;
	                    ^
1 error
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);


Compiler output:
a.cc: In function 'int main()':
a.cc:69:30: error: expected '}' at end of input
   69 |     printf("%lld\n", answer);
      |                              ^
a.cc:43:12: note: to match this '{'
   43 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#include <fstream>
#include <iostream>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define maxim INT_MAX
#define fi first
#define se second

/* 1. If you can't keep solution in mind, then visualize it on a paper.
 * 2. Try to identify the type of problem - DP, Greedy, Graph, Constructive,
 * 	  Prefix/Suffix, Difference Array, BIT/Segment Tree, etc.
 * 3. Look at the problems from different perspectives - reverse the problem,
 * 	  add instead of delete (maybe?)
 * 4. Divide difficult solutions into cases and/or sequences.
 * 5. Use math rules to solve Nested Summation.
 * 6. Optimisation problems are generally solved with DP, greedy, binary search or brute-force.
 * 7. Try fixing a solution then proving we can't do better or worse than that.
 * ------------------------------------------------------------------
 */
 ll n,w;
 ll ar[105];
 ll dp[105][1000000005];
 ll br[105];
 ll ans=0;
 ll holiday(ll i, ll W)
 {
    if(i==0||W==0)
        return 0;
    if(dp[i][W]!=0)
        return dp[i][W];
    if(ar[i]<=W)
    {
        ans=max(holiday(i-1,W-ar[i])+br[i],holiday(i-1,W));
    }
    else
    {
        ans=holiday(i-1,W);
    }
    return dp[i][W]=ans;
 }
int main()
{
    cin>>n>>w;
    for(ll i=1;i<=n;i++)
        cin>>ar[i]>>br[i];
    memset(dp,0,sizeof(dp));
    ll ans=holiday(n,w);
    cout<<ans<<endl;

}


Compiler output:
/tmp/ccIdtUMa.o: in function `holiday(long long, long long)':
a.cc:(.text+0xf8): relocation truncated to fit: R_X86_64_PC32 against symbol `br' defined in .bss section in /tmp/ccIdtUMa.o
a.cc:(.text+0x120): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccIdtUMa.o
a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccIdtUMa.o
a.cc:(.text+0x147): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccIdtUMa.o
/tmp/ccIdtUMa.o: in function `main':
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `br' defined in .bss section in /tmp/ccIdtUMa.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;
public class Main{
public static void sortbyColumn(long arr[][], int col) 
    { 
        // Using built-in sort function Arrays.sort 
        Arrays.sort(arr, new Comparator<int[]>() { 
            
          @Override              
          // Compare values according to columns 
          public int compare(final int[] entry1,  
                             final int[] entry2) { 
  
            // To sort in descending order revert  
            // the '>' Operator 
            if (entry1[col] > entry2[col]) 
                return 1; 
            else
                return -1; 
          } 
        });  // End of function call sort(). 
    } 
public static void main(String args[]){
     long N,W;
    Scanner obj=new Scanner(System.in);
    N=obj.nextLong();
    W=obj.nextLong();
    long arr[][]=new long[N+1][2];
    arr[0][0] = 0;
    arr[0][1] = 0;
    for(int i=1;i<=N;i++){
    for(int j=0;j<2;j++){
     arr[i][j]=obj.nextLong();
   }
   
   }

sortbyColumn(arr,0);

long dp[][]=new  long[N+1][W+1];
for(int i=1;i<=N;i++){
   for(int j=1;j<=W;j++){
     if(j-arr[i][0] >= 0) {
    	 dp[i][j]=arr[i][1];
    	 dp[i][j]+=dp[i-1][j-arr[i][0]];
     }
     dp[i][j]=Math.max(dp[i-1][j], dp[i][j]);
     //System.out.print(dp[i][j]+" ");
   }
   //System.out.println();
}


System.out.println(dp[N][W]);
 
}

}


Compiler output:
Main.java:6: error: no suitable method found for sort(long[][],<anonymous Comparator<int[]>>)
        Arrays.sort(arr, new Comparator<int[]>() { 
              ^
    method Arrays.<T#1>sort(T#1[],Comparator<? super T#1>) is not applicable
      (inference variable T#1 has incompatible bounds
        upper bounds: int[],Object
        lower bounds: long[])
    method Arrays.<T#2>sort(T#2[],int,int,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (actual and formal argument lists differ in length))
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>sort(T#1[],Comparator<? super T#1>)
    T#2 extends Object declared in method <T#2>sort(T#2[],int,int,Comparator<? super T#2>)
Main.java:27: error: incompatible types: possible lossy conversion from long to int
    long arr[][]=new long[N+1][2];
                           ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
long dp[][]=new  long[N+1][W+1];
                       ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
long dp[][]=new  long[N+1][W+1];
                            ^
Main.java:44: error: incompatible types: possible lossy conversion from long to int
    	 dp[i][j]+=dp[i-1][j-arr[i][0]];
    	                    ^
Main.java:53: error: incompatible types: possible lossy conversion from long to int
System.out.println(dp[N][W]);
                      ^
Main.java:53: error: incompatible types: possible lossy conversion from long to int
System.out.println(dp[N][W]);
                         ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 errors
Language: C++

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

#define int long long
int INF = 1e18LL;

void maxself(int &a, int b) {a=max(a,b);}
void minself(int &a, int b) {a=min(a,b);}

int32_t main(){
    int n,w;cin>>n>>w;
    vector<int> values(n), wieght(n);

    for(int i=0;i<n;i++){
        cin>>wieght[i]>>values[i];
    }
    int sum_value=0;
    for(auto x: values){
        sum_value+=x;
    }
    vector<int> dp(sum_value+1, INF);
    dp[0]=0;
    //dp[i] is the minimum total weight of items with total value exactly i
    for(int i=0;i<n;i++){
        for(int value_already=sum_value-values[i]; value_already>=0; value_already--){
            minself(dp[value_already+values[i]], dp[value_already]+wieght[i]);
        }
    }
    int ans=0;
    for(int i=sum_value;i>=0;i--){
        if(dp[i]<=w){
            maxself(ans, (int)i);
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Compiler output:
a.cc:5:11: error: unable to find numeric literal operator 'operator""LL'
    5 | int INF = 1e18LL;
      |           ^~~~~~
Language: C++

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

#define int long long
int INF = 1e18ll;

void maxself(int &a, int b) {a=max(a,b);}
void minself(int &a, int b) {a=min(a,b);}

int32_t main(){
    int n,w;cin>>n>>w;
    vector<int> values(n), wieght(n);

    for(int i=0;i<n;i++){
        cin>>wieght[i]>>values[i];
    }
    int sum_value=0;
    for(auto x: values){
        sum_value+=x;
    }
    vector<int> dp(sum_value+1, INF);
    dp[0]=0;
    //dp[i] is the minimum total weight of items with total value exactly i
    for(int i=0;i<n;i++){
        for(int value_already=sum_value-values[i]; value_already>=0; value_already--){
            minself(dp[value_already+values[i]], dp[value_already]+wieght[i]);
        }
    }
    int ans=0;
    for(int i=sum_value;i>=0;i--){
        if(dp[i]<=w){
            maxself(ans, (int)i);
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Compiler output:
a.cc:5:11: error: unable to find numeric literal operator 'operator""ll'
    5 | int INF = 1e18ll;
      |           ^~~~~~
Language: C++

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

#define int long long
#define INF LLONG_MAX

void maxself(int &a, int b) {a=max(a,b);}
void minself(int &a, int b) {a=min(a,b);}

int32_t main(){
    int n,w;cin>>n>>w;
    vector<int> values(n), wieght(n);

    for(int i=0;i<n;i++){
        cin>>wieght[i]>>wieght[i];
    }
    int sum_value=0;
    for(auto x: values){
        sum_value+=values[i];
    }
    vector<int> dp(sum_value, INF);
    dp[0]=0;
    //dp[i] is the minimum total weight of items with total value exactly i
    for(int i=0;i<n;i++){
        for(int value_already=sum_value-value[i]; value_already>=0; value_already--){
            minself(dp[value_already+value[i]], dp[value_already]+wieght[i]);
        }
    }
    int ans=0;
    for(int i=0;i<sum_value;i++){
        if(dp[i]<=W){
            max(ans, i);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:19:27: error: 'i' was not declared in this scope
   19 |         sum_value+=values[i];
      |                           ^
a.cc:25:41: error: 'value' was not declared in this scope; did you mean 'values'?
   25 |         for(int value_already=sum_value-value[i]; value_already>=0; value_already--){
      |                                         ^~~~~
      |                                         values
a.cc:31:19: error: 'W' was not declared in this scope
   31 |         if(dp[i]<=W){
      |                   ^
a.cc:32:16: warning: ignoring return value of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = long long int]', declared with attribute 'nodiscard' [-Wunused-result]
   32 |             max(ans, i);
      |             ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: declared here
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define row 100
#define col 1000000000
int dp[row][col];
memset(dp, -1, sizeof(dp));
int knapsack(int si, int wt[], int val[], int capacity, int n)
{
    if(si==n)         //base case
    {
    	dp[si][capacity]=0;
        return 0;
    }

    if(dp[si][capacity] != -1)
    	return dp[si][capacity];

    int include =INT_MIN;

    if(wt[si] <= capacity)
    {
        include =val[si] + knapsack(si+1, wt, val, capacity-wt[si], n);
    }

    int skip =knapsack(si+1, wt, val, capacity, n);
    int result =max(include, skip);

    dp[si][capacity]=result;
    return result;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,w;
    cin>>n>>w;
     int weight[row];
    int value[row];
  for(int i=0; i<n; i++)
  {
    cin>>weight[i]>>value[i];
  }
       
 
	cout<<knapsack(0, weight, value, w, n)<<'\n';
    return 0;
}


Compiler output:
a.cc:7:7: error: expected constructor, destructor, or type conversion before '(' token
    7 | memset(dp, -1, sizeof(dp));
      |       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define row 1000000
#define col 1000000001
vector<vector<int> > dp(row,vector<int>(col,-1));
int knapsack(int si, int wt[], int val[], int capacity, int n,)
{
    if(si==n)         //base case
    {
    	dp[si][capacity]=0;
        return 0;
    }

    if(dp[si][capacity] != -1)
    	return dp[si][capacity];

    int include =INT_MIN;

    if(wt[si] <= capacity)
    {
        include =val[si] + knapsack(si+1, wt, val, capacity-wt[si], n);
    }

    int skip =knapsack(si+1, wt, val, capacity, n);
    int result =max(include, skip);

    dp[si][capacity]=result;
    return result;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,w;
    cin>>n>>w;
     int weight[102];
    int value[102];
  for(int i=0; i<n; i++)
  {
    cin>>weight[i]>>value[i];
  }
       
 
	cout<<knapsack(0, weight, value, w, n)<<'\n';
    return 0;
}


Compiler output:
a.cc:7:63: error: expected identifier before ')' token
    7 | int knapsack(int si, int wt[], int val[], int capacity, int n,)
      |                                                               ^
a.cc: In function 'long long int knapsack(long long int, long long int*, long long int*, long long int, long long int, int)':
a.cc:22:36: error: too few arguments to function 'long long int knapsack(long long int, long long int*, long long int*, long long int, long long int, int)'
   22 |         include =val[si] + knapsack(si+1, wt, val, capacity-wt[si], n);
      |                            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:7:5: note: declared here
    7 | int knapsack(int si, int wt[], int val[], int capacity, int n,)
      |     ^~~~~~~~
a.cc:25:23: error: too few arguments to function 'long long int knapsack(long long int, long long int*, long long int*, long long int, long long int, int)'
   25 |     int skip =knapsack(si+1, wt, val, capacity, n);
      |               ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:7:5: note: declared here
    7 | int knapsack(int si, int wt[], int val[], int capacity, int n,)
      |     ^~~~~~~~
a.cc: In function 'int32_t main()':
a.cc:48:23: error: too few arguments to function 'long long int knapsack(long long int, long long int*, long long int*, long long int, long long int, int)'
   48 |         cout<<knapsack(0, weight, value, w, n)<<'\n';
      |               ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:7:5: note: declared here
    7 | int knapsack(int si, int wt[], int val[], int capacity, int n,)
      |     ^~~~~~~~
Language: C++

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

int main(void){
    int n,x;
    cin >> n >> x;
    
    int w[n],v[n],mx = 0;
    for(int i = 0;i < n;i++){
        cin >> w[i] >> v[i];
        mx = max(v[i],mx);
    }
    mx *= n;  
  
    int dp[n+1][mx+1];
  
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= mx;j++)dp[i][j] = 1e9;
    }
    dp[0][0] = 0;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= mx;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 alina = 0;
    for(int i = 0;i <= mx;i++){
        if(dp[n][i] <= x){
            alina = i;
        }
    }
    cout << alina << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:40:27: error: expected '}' at end of input
   40 |     cout << alina << endl;
      |                           ^
a.cc:6:15: note: to match this '{'
    6 | int main(void){
      |               ^
Language: C++

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


struct item
{
    int wt;
    int val;
};

int solve(vector<item> ar,int n,int W)
{
    int maxVal=n*1000;
    int dp[n+1][maxVal+1];
    for(int val=0;val<=maxVal;val++)
    {
        dp[1][val]=inf;
    }
    dp[1][0]=0;
    dp[1][ar[1].val]=arr[1].wt;
    for(int i=2;i<=n;i++)
    {
        for(int v=0;v<=maxVal;v++)
        {
            dp[i][v]=dp[i-1][v];
            if(ar[i].val>v)
                continue;
            dp[i][v]=min(dp[i][v],ar[i].wt+dp[i-1][v-ar[i].val]);
        }
    }
    int ans=0;
    for(int x=0;x<=maxVal;x++)
    {
        if(dp[n][x]<=W)
            ans=x;
    }
    return ans;
} 

int32_t main()
{
    int n,w;
    cin>>n>>w;
    vector<item>ar(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i].wt>>ar[i].val;
    }
    cout<<solve(ar,n,w);
}



Compiler output:
a.cc: In function 'long long int solve(std::vector<item>, long long int, long long int)':
a.cc:22:22: error: 'arr' was not declared in this scope; did you mean 'ar'?
   22 |     dp[1][ar[1].val]=arr[1].wt;
      |                      ^~~
      |                      ar
Language: C++

/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 8/28/2020
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
const double PI = acos(-1);
const int MOD = 1000000007;

const int mxN = 100, mxW = 1e9;
ll n, w;
ll dp[mxN+1][mxW+1];
vector<pair<ll, ll>> arr(mxN+1, {0, 0});

ll go(int i, int taken) {
	if(i == n) {
		return (taken+arr[i].first <= w ? arr[i].second : 0);
	}
	if(i > n || taken > w) {
		return (ll)-1e18;
	}
	if(dp[i][taken] != -1) {
		return dp[i][taken];
	}
	ll c1 = go(i+1, taken);
	ll c2 = (ll)-1e18;
	if(taken+arr[i].first <= w) c2 = go(i+1, taken+arr[i].first) + arr[i].second;
	ll ans = max(c1, c2);
	return dp[i][taken] = ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	return 0;
}


Compiler output:
/tmp/ccLGGdXp.o: in function `go(int, int)':
a.cc:(.text+0x32): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
a.cc:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
a.cc:(.text+0x13e): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
a.cc:(.text+0x1a2): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
/tmp/ccLGGdXp.o: in function `main':
a.cc:(.text+0x2aa): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
a.cc:(.text+0x2d6): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
/tmp/ccLGGdXp.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3d9): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
a.cc:(.text+0x3ff): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccLGGdXp.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,w;
  cin>>n>>w;
  vector<pair<int,int>>a;
  int i,w1,v,j;
  for(i=0;i<n;i++)
  {
    cin>>w1>>v;
    a.push_back(make_pair(v,w1));
  }
  vector<long long int> ans(100001,1000000000000);
  ans[0]=0;
  for(i=0;i<n;i++)
  {
    for(j=a[i].first;j<100001;j++)
    {
      ans[j]=min(ans[j],ans[j-a[i].first]+a[i].second])
    }
  }
  long int an=0;
  for(i=0;i<100001;i++)
  {
    if(ans[i]<=w)
      an=i;
  }
  cout<<i<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:54: error: expected ')' before ']' token
   21 |       ans[j]=min(ans[j],ans[j-a[i].first]+a[i].second])
      |                 ~                                    ^
      |                                                      )
Language: C++

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,w;
  cin>>n>>w;
  vector<pair<int,int>>a;
  int i,w1,v;
  for(i=0;i<n;i++)
  {
    cin>>w1>>v;
    a.push_back(make_pair(v,w1));
  }
  vector<long long int> ans(100001,1000000000000);
  ans[0]=0;
  for(i=0;i<n;i++)
  {
    for(j=a[i].first;j<100001;j++)
    {
      ans[j]=min(ans[j],ans[j-a[i].first]+a[i].second])
    }
  }
  long int an=0;
  for(i=0;i<100001;i++)
  {
    if(ans[i]<=w)
      an=i;
  }
  cout<<i<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'j' was not declared in this scope
   19 |     for(j=a[i].first;j<100001;j++)
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

void showDP(vector<vector<ll>> dp)
{
	f(i,0,dp.size())
	{
		f(j,0,dp[i].size())
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
}




ll knapSack(vector<pair<ll,ll>> p, ll w, ll currSum=0, ll n=0)
{
     // showDP(dp);

	if(n==p.size() ||currSum==0) 
		return 0


//if(dp[n][currSum]!=-1) return dp[n][currSum];
   // cout<<"value is: "<<p[n].first<<endl;


   // cout<<n<<" "<<currSum<<endl; 

  if(currSum + p[n].first <= w) 
  	{
  		ll ans1= p[n].second+knapSack(p,w,currSum+p[n].first,n+1);
  		ll ans2=knapSack(p,w,currSum,n+1);
  		return max(ans1,ans2);
  	}

  else return knapSack(p,w,currSum,n+1);

}



int main()
{
    fast

    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>> p;

    f(i,0,n)
    {
    	ll a,b;
    	cin>>a>>b;
    	p.pb(make_pair(a,b));
    }

    // sort(p.begin(),p.end());
// cout<<p.size()<<endl;
    // cout<<p.size()<<endl;
    //vector<vector<ll>> dp(n+1, vector<ll>(w+1,-1));
    cout<<knapSack(p,w);




   
    bye
}


Compiler output:
a.cc: In function 'long long int knapSack(std::vector<std::pair<long long int, long long int> >, long long int, long long int, long long int)':
a.cc:34:25: error: expected ';' before 'if'
   34 |                 return 0
      |                         ^
      |                         ;
......
   43 |   if(currSum + p[n].first <= w)
      |   ~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:27:10: error: expected primary-expression before ':' token
   27 |         }:
      |          ^
a.cc:28:26: error: 'i' was not declared in this scope
   28 |         for (int i = mx; i >= 0; i--) {
      |                          ^