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

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */

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

int main(){
	FAST;
	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,0); 
	//dp[i] - the minimum total weight with 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) max_self(answer, (ll)i);
	}
	printf("%lld",answer);
	
	
	return 0;
}

	

Compiler output:
a.cc:48:21: error: 'llb' has not been declared
   48 | void min_self(ll &a,llb){
      |                     ^~~
a.cc: In function 'void min_self(ll&, int)':
a.cc:49:19: error: 'b' was not declared in this scope
   49 |         a = min(a,b);
      |                   ^
a.cc: In function 'll mod(ll, ll)':
a.cc:34:73: warning: control reaches end of non-void function [-Wreturn-type]
   34 | inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
      |                                                                         ^
Language: C++

#include<iostream>
#include<cmath>
#include<climits>
#include<functional>

using namespace std;
int dp[101][100005];
int main() {
   int N, W;

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

 /*  int **dp = ( int ** ) malloc( sizeof( int * ) * N );
   for( int i = 0; i < N; i++ ) {
      dp[ i ] = ( int * ) malloc( sizeof( int ) * totalMax + 1 );
   }*/
   for( int i = 0; i < N; i++ ) {
      for( int j = 0; j < totalMax + 1; j++ ) {
         dp[ i ][ j ] = INT_MAX;
      }
   }

   function< int ( int, int ) > getDp;
   getDp = [ & ] ( int cn, int cv ) -> int {
      if( cv <= 0 ) {
         return 0;
      }
      if( cn == 0 ) {
         if( cv <= v[ cn ] ) {
            return w[ cn ];
         }
         return INT_MAX - 1;
      }
      if( dp[ cn ][ cv ] != INT_MAX ) {
         return dp[ cn ][ cv ];
      }
      auto path1 = getDp( cn - 1, cv - v[ cn ] );
      path1 = path1 == INT_MAX - 1 ? path1 : path1 + w[ cn ];
      dp[ cn ][ cv ] = min( path1, getDp( cn - 1, cv ) );

      return dp[ cn ][ cv ];
   };
for(int I = totalMax; I>=0;I--) if(getDp(N-1,I)<=W) {cout<<I;. return 0;}
   // Binary search with two ends
   function< int ( int, int ) > search;
   search = [ & ] ( int start, int end ) -> int {
      if( start == end ) {
         return start;
      }
      if( start + 1 == end ) {
         if( getDp( N - 1, end ) <= W ) {
            return end;
         } else {
            return start;
         }
      }
      auto mid = ( start + end ) / 2;
      auto mV = getDp( N - 1, mid );
      if( mV <= W ) {
         return search( mid, end );
      } else {
         return search( start, mid );
      }
   };

   cout << search( 0, totalMax );
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:62: error: expected primary-expression before '.' token
   49 | for(int I = totalMax; I>=0;I--) if(getDp(N-1,I)<=W) {cout<<I;. return 0;}
      |                                                              ^
a.cc:49:64: error: expected unqualified-id before 'return'
   49 | for(int I = totalMax; I>=0;I--) if(getDp(N-1,I)<=W) {cout<<I;. return 0;}
      |                                                                ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define MAX_W 100000
#define MAX_N 100
ll dp[MAX_N+5][MAX_W+5]; 

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

    int N,W; cin >> N >> W;
    vei w(N); vel v(N); rep(i,N) cin >> w[i] >> v[i];

    ll sum = acc(all(v), 0);
    ll ans = 0;
    if(sum <= W) {
        sort(rall(v));
        rep(i,N) ans += v[i];
        cout << _ANSI_STDARG_H_ << endl;
        return 0;
        }

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



Compiler output:
a.cc: In function 'int main()':
a.cc:54:33: error: expected primary-expression before '<<' token
   54 |         cout << _ANSI_STDARG_H_ << endl;
      |                                 ^~
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class E_knapsack2 {

    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String line[] = line = bf.readLine().split("\\s");
        int n = Integer.parseInt(line[0]);
        int w = Integer.parseInt(line[1]);
        int wt[] = new int[n];
        int val[] = new int[n];

        for (int i = 0; i < n; ++i) {
            line = bf.readLine().split("\\s");
            wt[i] = Integer.parseInt(line[0]);
            val[i] = Integer.parseInt(line[1]);
        }
        int total_value = 0;
        for (int value : val) total_value += value;
        long[] dp = new long[total_value + 1];
        dp[0] = 0;
        long INF = Long.MAX_VALUE - Integer.MAX_VALUE;
        for (int i = 1; i < total_value + 1; i++) {
            dp[i] = INF;
        }

        for (int i = 0; i < n; i++) {
            for (int v = total_value - val[i]; v >= 0; v--) {
                dp[v + val[i]] = Math.min(dp[v + val[i]], dp[v] + wt[i]);
            }
        }
        long ans = 0;
        for (int i = 0; i <= total_value; i++) {
            if (dp[i] <= w) {
                ans = Math.max(ans, i);
            }
        }

        System.out.println(ans);


    }
}


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

#include<bits/stdc++.h>
using namespace std;
#define int long long
int knapsack(int n,int w,int weight[],int val[])
{
	if(n==0 or w==0)return 0
	if(w<weight[n-1])return knapsack(n-1,w,weight,val);
	else
		return max(knapsack(n-1,w,weight,val),knapsack(n-1,w-weight[n-1],weight,val));
}

#undef int
int main()
{
 #define int long long
 int n,w;
 cin>>n>>w;
 int val[n],weight[n]; 
 for(int i=0;i<n;i++)
 {
   cin>>weight[i]>>val[i];
 }
 
  cout<<knapsack(n,w,weight,val);                                                             
}  


Compiler output:
a.cc: In function 'long long int knapsack(long long int, long long int, long long int*, long long int*)':
a.cc:6:33: error: expected ';' before 'if'
    6 |         if(n==0 or w==0)return 0
      |                                 ^
      |                                 ;
    7 |         if(w<weight[n-1])return knapsack(n-1,w,weight,val);
      |         ~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
int knapsack(int n,int w,weight,val)
{
	if(n==0 or w==0)return 0
	if(w<weight[n-1])return knapsack(n-1,w,weight,val);
	else
		return max(knapsack(n-1,w,weight,val),knapsack(n-1,w-weight[n-1],weight,val));
}

#undef int
int main()
{
 #define int long long
 int n,w;
 cin>>n>>w;
 int val[n],weight[n]; 
 for(int i=0;i<n;i++)
 {
   cin>>weight[i]>>val[i];
 }
 
  cout<<knapsack(n,w,weight,val);                                                             
}  


Compiler output:
a.cc:4:26: error: 'weight' has not been declared
    4 | int knapsack(int n,int w,weight,val)
      |                          ^~~~~~
a.cc:4:33: error: 'val' has not been declared
    4 | int knapsack(int n,int w,weight,val)
      |                                 ^~~
a.cc: In function 'long long int knapsack(long long int, long long int, int, int)':
a.cc:6:33: error: expected ';' before 'if'
    6 |         if(n==0 or w==0)return 0
      |                                 ^
      |                                 ;
    7 |         if(w<weight[n-1])return knapsack(n-1,w,weight,val);
      |         ~~                       
a.cc:7:14: error: 'weight' was not declared in this scope
    7 |         if(w<weight[n-1])return knapsack(n-1,w,weight,val);
      |              ^~~~~~
a.cc:7:55: error: 'val' was not declared in this scope
    7 |         if(w<weight[n-1])return knapsack(n-1,w,weight,val);
      |                                                       ^~~
a.cc:9:50: error: 'val' was not declared in this scope
    9 |                 return max(knapsack(n-1,w,weight,val),knapsack(n-1,w-weight[n-1],weight,val));
      |                                                  ^~~
a.cc: In function 'int main()':
a.cc:24:22: error: invalid conversion from 'long long int*' to 'int' [-fpermissive]
   24 |   cout<<knapsack(n,w,weight,val);
      |                      ^~~~~~
      |                      |
      |                      long long int*
a.cc:4:26: note:   initializing argument 3 of 'long long int knapsack(long long int, long long int, int, int)'
    4 | int knapsack(int n,int w,weight,val)
      |                          ^~~~~~
a.cc:24:29: error: invalid conversion from 'long long int*' to 'int' [-fpermissive]
   24 |   cout<<knapsack(n,w,weight,val);
      |                             ^~~
      |                             |
      |                             long long int*
a.cc:4:33: note:   initializing argument 4 of 'long long int knapsack(long long int, long long int, int, int)'
    4 | int knapsack(int n,int w,weight,val)
      |                                 ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);
 
int main()
{
    AC
    int n,w,r=0;
    cin>>n>>w;
    vector<ll> dp(100001,1e10);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int wei,val;
        cin>>wei>>val;
        for(int j=100000;j>=val;j--)
            dp[j]=min(dp[j],dp[j-val]+wei);
    }
    for(int i=1;i<dp.size();i++)
        if(dp[i]<=w) r=i;
    cout<<r<<'\n';


Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: expected '}' at end of input
   22 |     cout<<r<<'\n';
      |                   ^
a.cc:7:1: note: to match this '{'
    7 | {
      | ^
Language: C++

#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll int INF = le18+5;
int main()
{
    ll int n,W,total_sum=0;
    cin >> n >> W;
    vector<ll int> w(n,0),val(n,0);
    for(ll int i=0;i<n;i++)
    {
        cin >> w[i] >> val[i];
    }
    for(int i=0;i<n;i++)
        total_sum += val[i];
    vector<ll int>dp(total_sum+1,INF);
    dp[0]=0;
    for(ll int i=0;i<n;i++){
        
        for(ll int j=total_sum-val[i];j>=0;j--){
            dp[j+val[i]]=min(dp[j+val[i]],dp[j]+w[i]);
        }
    }
             for(int i=0;i<=total_sum;i++)
                 cout << dp[i] << endl;
    ll int ans =0 ;
                      for(ll int i=0;i<=total_sum;i++)
                      {
                          if(dp[i] <= W)
                          {
                              ans = max(ans,i);
                          }
                      }
                      cout << ans;
}


Compiler output:
a.cc:4:20: error: 'le18' was not declared in this scope
    4 | const ll int INF = le18+5;
      |                    ^~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long 
#define INF le18+5
using namespace std;
 
int main()
{
    ll int n,W,total_sum=0;
    cin >> n >> W;
    vector<ll int> w(n,0),val(n,0);
    for(ll int i=0;i<n;i++)
    {
        cin >> w[i] >> val[i];
    }
    for(int i=0;i<n;i++)
        total_sum += val[i];
    vector<ll int>dp(total_sum+1,INF);
    dp[0]=0;
    for(ll int i=0;i<n;i++){
        
        for(ll int j=total_sum-val[i];j>=0;j--){
            dp[j+val[i]]=min(dp[j+val[i]],dp[j]+w[i]);
        }
    }
             for(int i=0;i<=total_sum;i++)
                 cout << dp[i] << endl;
    ll int ans =0 ;
                      for(ll int i=0;i<=total_sum;i++)
                      {
                          if(dp[i] <= W)
                          {
                              ans = max(ans,i);
                          }
                      }
                      cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:13: error: 'le18' was not declared in this scope
    3 | #define INF le18+5
      |             ^~~~
a.cc:17:34: note: in expansion of macro 'INF'
   17 |     vector<ll int>dp(total_sum+1,INF);
      |                                  ^~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N=1e9+3;
ll n,w,W[N],v[N];
ll dp[105][N];
ll solve(ll idx,ll capacity){
  if(idx==n){
    return 0;
  }
  if(dp[idx][capacity]!=-1)
    return dp[idx][capacity];
  if(capacity+W[idx]<=w){
    dp[idx][capacity]=max(solve(idx+1,capacity+W[idx])+v[idx],solve(idx+1,capacity));
  }
  else
    dp[idx][capacity]=solve(idx+1,capacity);
  return dp[idx][capacity];
}
int main()
{
    cin>>n>>w;
    for(ll i=0;i<n;i++){
        cin>>W[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
    return 0;
}


Compiler output:
/tmp/cc1UrGAC.o: in function `solve(long long, long long)':
a.cc:(.text+0x44): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc1UrGAC.o
a.cc:(.text+0x6f): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc1UrGAC.o
a.cc:(.text+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1UrGAC.o
a.cc:(.text+0x147): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc1UrGAC.o
a.cc:(.text+0x185): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc1UrGAC.o
a.cc:(.text+0x1aa): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc1UrGAC.o
/tmp/cc1UrGAC.o: in function `main':
a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1UrGAC.o
a.cc:(.text+0x267): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc1UrGAC.o
collect2: error: ld returned 1 exit status
Language: C++

#include<stdio.h> 
#include<iostream>
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   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() 
{   int n,w;
 cin>>n>>w;
 
 int wt[n],val[n];
 for(int i=0;i<n;i++)
   cin>>wt[i]>>val[i];
  
    printf("%d", knapSack(w, wt, val, n)); 
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:2: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   31 |  cin>>n>>w;
      |  ^~~
      |  std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

#include<stdio.h> 
  
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   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() 
{   int n,w;
 cin>>n>>w;
 
 int wt[n],val[n];
 for(int i=0;i<n;i++)
   cin>>wt[i]>>val[i];
  
    printf("%d", knapSack(w, wt, val, n)); 
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:2: error: 'cin' was not declared in this scope
   31 |  cin>>n>>w;
      |  ^~~
Language: C++

#include<stdio.h> 
  
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   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() 
{   int n,w;
 cin>>n>>w;
 
 int a[n]
 for(int i=0;i<n;i++)
   cin>>wt[i]>>val[i];   
 
    printf("%d", knapSack(w, wt, val, n)); 
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:2: error: 'cin' was not declared in this scope
   31 |  cin>>n>>w;
      |  ^~~
a.cc:34:2: error: expected initializer before 'for'
   34 |  for(int i=0;i<n;i++)
      |  ^~~
a.cc:34:14: error: 'i' was not declared in this scope
   34 |  for(int i=0;i<n;i++)
      |              ^
a.cc:37:30: error: 'wt' was not declared in this scope; did you mean 'w'?
   37 |     printf("%d", knapSack(w, wt, val, n));
      |                              ^~
      |                              w
a.cc:37:34: error: 'val' was not declared in this scope
   37 |     printf("%d", knapSack(w, wt, val, n));
      |                                  ^~~
Language: C++

#include<stdio.h> 
  
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   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() 
{   int n,w;
 cin>>n>>w;
 
 int a[n]
 for(int i=0;i<n;i++)
   cin>>wt[i]>>val[i];
 

    
 
    printf("%d", knapSack(W, wt, val, n)); 
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:31:2: error: 'cin' was not declared in this scope
   31 |  cin>>n>>w;
      |  ^~~
a.cc:34:2: error: expected initializer before 'for'
   34 |  for(int i=0;i<n;i++)
      |  ^~~
a.cc:34:14: error: 'i' was not declared in this scope
   34 |  for(int i=0;i<n;i++)
      |              ^
a.cc:40:27: error: 'W' was not declared in this scope
   40 |     printf("%d", knapSack(W, wt, val, n));
      |                           ^
a.cc:40:30: error: 'wt' was not declared in this scope; did you mean 'w'?
   40 |     printf("%d", knapSack(W, wt, val, n));
      |                              ^~
      |                              w
a.cc:40:34: error: 'val' was not declared in this scope
   40 |     printf("%d", knapSack(W, wt, val, n));
      |                                  ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAX 1e9+7
int dp[101][MAX];
int main()
{
	int n;long w;
	cin>>n>>w;
	vector<pair<long,int>> v;
	for(int i=0;i<n;i++)
	{
		long wt;int p;
		cin>>wt>>p;
		v.push_back(make_pair(wt,p));
	}
	sort(v.begin(), v.end());
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(j>=v[i-1].first)
				dp[i][j]=max(dp[i-1][j],v[i-1].second+dp[i-1][j-v[i-1].first]);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

Compiler output:
a.cc:3:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define MAX 1e9+7
      |             ~~~^~
a.cc:4:13: note: in expansion of macro 'MAX'
    4 | int dp[101][MAX];
      |             ^~~
a.cc:3:16: error: could not convert '(1.0e+9 + (double)7)' from 'double' to 'long unsigned int'
    3 | #define MAX 1e9+7
      |             ~~~^~
      |                |
      |                double
a.cc:4:13: note: in expansion of macro 'MAX'
    4 | int dp[101][MAX];
      |             ^~~
a.cc:3:16: error: size of array 'dp' has non-integral type 'double'
    3 | #define MAX 1e9+7
      |             ~~~^~
a.cc:4:13: note: in expansion of macro 'MAX'
    4 | int dp[101][MAX];
      |             ^~~
Language: C++

za        #include<bits/stdc++.h>
using namespace std;
#define LL                  long long
#define ull                 unsigned long long LL
#define scl(n)              scanf("%lld", &n)
#define scf(n)              scanf("%lf", &n)
#define sci(n)              scanf("%d", &n)
#define scii(n,m)           scanf("%d %d",&n,&m)
#define sciii(n,m,p)        scanf("%d %d %d",&n,&m,&p)

#define MOD                 1000000007
#define MODP                99999999999973LL
#define pb                  push_back
#define mp                  make_pair
#define pp                  pair<LL,LL>
#define memo(a,b)           memset(a,b,sizeof(a))
#define INF                 1e9+1
#define EPS                 1e-8
#define Pi                  acos(-1.0)
LL bigmod(LL b, LL p, LL md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {LL y=bigmod(b,p/2,md);return (y*y)%md;}}
#define N 100002

LL arr[110],val[110];
LL n,W;

LL  dp[110][100009];
int vis[110][100009];

LL solve(int pos,int profit)
{
    if(profit==0)
        return 0;
    if(pos==n)
        return INF;
    if(profit<0)
        return INF;

    if(vis[pos][profit]==1)
        return dp[pos][profit];
    vis[pos][profit]=1;

    int ans1=arr[pos]+solve(pos+1,profit-val[pos]);
    int ans2=solve(pos+1,profit);

    return dp[pos][profit]=min(ans1,ans2);




}

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

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

    for(int i=n*1000;i>=0;i--)
    {
        if(solve(0,i)<=W)
        {
            cout<<i<<endl;
            break;
        }
    }


    return 0;
}



/* LL dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* LL dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* LL dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* LL dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


Compiler output:
a.cc:1:11: error: stray '#' in program
    1 | za        #include<bits/stdc++.h>
      |           ^
a.cc:1:1: error: 'za' does not name a type
    1 | za        #include<bits/stdc++.h>
      | ^~
a.cc: In function 'long long int solve(int, int)':
a.cc:45:28: error: 'min' was not declared in this scope
   45 |     return dp[pos][profit]=min(ans1,ans2);
      |                            ^~~
a.cc: In function 'int main()':
a.cc:54:5: error: 'cin' was not declared in this scope
   54 |     cin>>n>>W;
      |     ^~~
a.cc:63:13: error: 'cout' was not declared in this scope
   63 |             cout<<i<<endl;
      |             ^~~~
a.cc:63:22: error: 'endl' was not declared in this scope
   63 |             cout<<i<<endl;
      |                      ^~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

long long w[100],v[100];

long long func(long long n,long long tar){
  
  long long dp[100000],ans=0;
  for(int i=0;i<100000;i++)dp[100000]=9999999999;
  
  for(int i=0;i<n;i++)
    for(int j=100000;j>=w[i];j--){
      
      dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
      if(dp[j]<=tar)
        ans=max(ans,j);
      
    }
  
  return ans;
  
}

int main(){
  
   cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  long long n,tar;
  cin>>n>>tar;
  
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  
  cout<<func(n,tar)<<endl;
  
  return 0;
}

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

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

vector<pair<int, int> > items;
vector<vector<int> > table;
int MAX = 101000;

int choose(int weight){
    int num = items.size();

    table[0][0] = 0;
    table[0][items[0].second] = items[0].first;

    for(int i = 1; i < num; i++){
        auto item = items[i]; 

        for(int value = 0; value < MAX; value++){
            int remain = value - item.second;

            int min = INT_MAX;
            if((remain >= 0) && (table[i-1][remain] != INT_MAX))
                min = item.first + table[i-1][remain];

            if(table[i-1][value] < min)
                min = table[i-1][value];

            table[i][value] = min;
        }
    }

    int max = 0;
    for(int value = 0; value < MAX; value++){
        if((table[num-1][value] <= weight) && (value > max))
            max = value;
    }

    return max;
}

int main(){
    int n, w;
    cin >> n >> w;

    items = vector<pair<int, int> >(n);
    for(int i = 0; i < n; i++) 
        cin >> items[i].first >> items[i].second;

    table = vector<vector<int>>(n, vector<int>(MAX, INT_MAX));

    int max = choose(w);
    cout << max << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int choose(int)':
a.cc:21:23: error: 'INT_MAX' was not declared in this scope
   21 |             int min = INT_MAX;
      |                       ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc: In function 'int main()':
a.cc:49:53: error: 'INT_MAX' was not declared in this scope
   49 |     table = vector<vector<int>>(n, vector<int>(MAX, INT_MAX));
      |                                                     ^~~~~~~
a.cc:49:53: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
int dp[1000000000];
vector <int> v;
main(){
	int n,w,c,i,j,a,b,mx=-1;
	cin>>n>>w;
	dp[0]=1;
	v.pb(0);
	for (i=0;i<n;++i){
		cin>>a>>b;
		c=v.size();
		for (j=0;j<c;j++){
			if (v[j]+a>w)continue;
			dp[v[j]+a]=max(dp[v[j]+a],dp[v[j]]+b);
			v.pb(v[j]+a);
		}
	}
	for (i=0;i<=w;++i){
		mx=max(dp[i],mx);
	}
	cout <<mx-1;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
/tmp/ccKDeOJ3.o: in function `main':
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0xf3): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0x12a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0x16e): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
/tmp/ccKDeOJ3.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x26b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccKDeOJ3.o
collect2: error: ld returned 1 exit status
Language: C++

/* ****AWARE**** */

#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp34       make_pair
using namespace std; 
#define MAX  3000000000
#define MODULO 2
using namespace std;   
#define hell 998244353
ll T,t;
 int  dp[101][1000000001]={0};
 vector<pair<ll,ll>>v1;
ll solve2(ll n,ll w)
{
	if(w<0)
    {  ll l=INT_MIN;
    	return l;
    }
	if(n==0 || w==0)	
		return 0;
    
   if(dp[n][w]!=0)
	{
		return dp[n][w];
	}
	return dp[n][w]=max(v1[n-1].second + solve2(n-1,w-v1[n-1].first),solve2(n-1,w));

}

void solve()
{  ll ans,i,j,k,n,w,a,b;
		cin>>n>>w;
  

  for(i=0;i<n;i++)
  {
  	cin>>a>>b;
     v1.push_back(make_pair(a,b));
  }
  cout<<solve2(n,w);
	}
               
int main(){ 
cut;               
   
//cin>>t;
//T=t;
t=1;
while(t--)
solve();

return 0;
 }  

Compiler output:
/tmp/ccMSdgFl.o: in function `solve2(long long, long long)':
a.cc:(.text+0xbd): relocation truncated to fit: R_X86_64_PC32 against symbol `v1' defined in .bss section in /tmp/ccMSdgFl.o
a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `v1' defined in .bss section in /tmp/ccMSdgFl.o
/tmp/ccMSdgFl.o: in function `solve()':
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `v1' defined in .bss section in /tmp/ccMSdgFl.o
/tmp/ccMSdgFl.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `v1' defined in .bss section in /tmp/ccMSdgFl.o
a.cc:(.text+0x2c8): relocation truncated to fit: R_X86_64_PC32 against symbol `v1' defined in .bss section in /tmp/ccMSdgFl.o
collect2: error: ld returned 1 exit status
Language: C++

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

signed main(){
	int n;
	int maxw;
	cin>>n>>maxw;
	int sum = 0;
	vector<int> w(n);
	vector<int> val(n);
	for(int i = 0 ; i < n ;i++){
		cin>>w[i]>>val[i];
		sum+= val[i];
	}
	vector<long long > dp(sum+1,1000000010);
	dp[0] = 0;
	for(int i = 0 ; i < n ;i++){
		for(int j = sum ; j >=val[i] ; j--){
			dp[j] = min(dp[j] , dp[j - val[i]] + w[i]);
		}
	}
	for(int i = dp.size() -1  ; i >= 0  ; i--){
		if(dp[i] <= maxw){
			cout<<i;
			return 0
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:33: error: expected ';' before '}' token
   25 |                         return 0
      |                                 ^
      |                                 ;
   26 |                 }
      |                 ~
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
  
  long long n,tar;
  cin>>n>>tar;
  
  long long w[n],v[n];
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  
  int dp[2][tar+1];
  for(long long int i=0;i<2;i++)dp[i][0]=0;
  for(long long int i=0;i<=tar;i++)dp[0][i]=0;
  
  for(long long int i=1;i<=n;i++){
    for(long long int j=1;j<=tar;j++){
      if(w[(i-1)]>j)
        dp[i%2][j]=dp[(i-1)%2][j];
      else
      dp[i%2][j]=max(dp[(i-1)%2][j],dp[(i-1)%2][j-w[i-1]]+v[i-1]);
      
      //cout<<dp[i][j]<<" ";
    }
   // cout<<endl;
  }
  
  cout<<dp[n%2][tar]<<endl;
  
 return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: no matching function for call to 'max(int&, long long int)'
   22 |       dp[i%2][j]=max(dp[(i-1)%2][j],dp[(i-1)%2][j-w[i-1]]+v[i-1]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   22 |       dp[i%2][j]=max(dp[(i-1)%2][j],dp[(i-1)%2][j-w[i-1]]+v[i-1]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |       dp[i%2][j]=max(dp[(i-1)%2][j],dp[(i-1)%2][j-w[i-1]]+v[i-1]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

 #include<bits/stdc++.h>
using namespace std;
#define ll long long
int number,w;
map<int ,int>dp;
int main(){
	//cin>>number>>w;
	scanf("%d%d",&number,&w);
	for(ll i=1;i<=number;i++){
		ll weight,value;
		//cin>>weight>>value;
		scanf("%d%d",&weight,&value);
		for(ll j=w-weight;j>=0;j--)
			dp[j+weight]=max(dp[j+weight],dp[j]+value);
	}
	//cout<<dp[w]<<endl;
	printf("%d\n",dp[w]);
	return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
int number,w;
long long dp[100100];
int main(){
	cin>>number>>w;
	for(int i=1;i<=n+10;i++)dp[i]=1e10;
	for(int i=1;i<=number;i++){
		int weight,value;
		cin>>weight>>value;
		for(int j=100000-value;j>=0;j--)
			dp[j+v]=max(dp[j+v],dp[j]+weight);
	}
	for(int i=100000;i>=0;i--)
		if(dp[i]<=w){
			cout<<i<<endl;
			return 0;
		}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:24: error: 'n' was not declared in this scope
    7 |         for(int i=1;i<=n+10;i++)dp[i]=1e10;
      |                        ^
a.cc:12:30: error: 'v' was not declared in this scope
   12 |                         dp[j+v]=max(dp[j+v],dp[j]+weight);
      |                              ^
Language: C++

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

int n,maxw;
long long w[128],v[128],dp[128][128000];

int main()
{
	ios::sync_with_stdio("false");
//	freopen(".in","r",stdin);
//	freopen(".out","r",stdout);
	memset(dp,0x3f3f3f3f,sizeof(dp));
	cin>>n>>maxw;
	for(int i=1;i!=n+1;++i)
		cin>>w[i]>>v[i];
//	for(int i=1;i!=10010;++i)
		dp[0][0]=0;
	for(int i=1;i!=n+;++i)
		for(int j=1;j!=10010;++j)
		{
			if(j>=v[i] && dp[i-1][j-v[i]]+w[i]<=maxw)
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			else dp[i][j]=dp[i-1][j];
		}
		
	for(int i=10009;i>0;--i)
		if(dp[n][i]<=maxw)
		{
			cout<<i<<"\n";
			break;
		}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:26: error: expected primary-expression before ';' token
   18 |         for(int i=1;i!=n+;++i)
      |                          ^
Language: C++

#include <iostream>
using namespace std;
int w[1000],v[1000];
long long  m[105][1000000];
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int main(){
    long long n,x;
    cin>>n>>x;
    for(long long i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=x;j++){
            if(w[i]>j)m[i][j]=m[i-1][j];;
        }
    }
	cout<<m[n][x];
            else m[i][j]=max(m[i-1][j],m[i-1][j-w[i]]+v[i])
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'else' without a previous 'if'
   21 |             else m[i][j]=max(m[i-1][j],m[i-1][j-w[i]]+v[i])
      |             ^~~~
a.cc:21:20: error: 'i' was not declared in this scope
   21 |             else m[i][j]=max(m[i-1][j],m[i-1][j-w[i]]+v[i])
      |                    ^
a.cc:21:23: error: 'j' was not declared in this scope
   21 |             else m[i][j]=max(m[i-1][j],m[i-1][j-w[i]]+v[i])
      |                       ^
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;

ll max(ll x, ll y)
{
	return x < y ? y : x;
}

ll n, m, w[maxn], v[maxn], f[1e7];

int main()
{
    cin >> n >> m;
    
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i] >> w[i];
    }
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = m; j >= v[i]; j --)
        {
            f[j] = max(f[j], f[j - v[i]] + w[i]);
        }
    }
    cout << f[m] << endl;
    
    return 0;
}

Compiler output:
a.cc:16:30: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   16 | ll n, m, w[maxn], v[maxn], f[1e7];
      |                              ^~~
a.cc:16:30: error: could not convert '1.0e+7' from 'double' to 'long unsigned int'
   16 | ll n, m, w[maxn], v[maxn], f[1e7];
      |                              ^~~
      |                              |
      |                              double
a.cc:16:30: error: size of array 'f' has non-integral type 'double'
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long x,n,a[1000002][1002],c,inf,s,ok,b;
pair<long long,long long>p[1002];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
     cin>>n>>x;
     inf=0x7fffff;
     for(int i=0;i<n;i++){
     	cin>>b>>c;
     	ok=ok+c;
     	p[i]=make_pair(b,c);
     }
	 for(int i=1;i<ok+1;i++){
	 	for(int j=0;j<n;j++){
	 		a[i][j]=inf;
	 	}
	 }
	 a[p[0].second][0]=p[0].first; 
	 for(int i=0;i<ok+1;i++){
	 	for(int j=1;j<n;j++){
	 		if(p[j].second<=i)
	 		     a[i][j]=min(p[j].first+a[i-p[j].second][j-1],a[i][j-1]);
		    else
		         a[i][j]=a[i][j-1];
		 }
	 }
	 s=ok;
	 while(a[s][n-1]>x){
	 	s--;
	 }
	 cout<<s;
return 0;
}

Compiler output:
/tmp/cc9XV6tO.o: in function `main':
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `inf' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0x82): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0xb0): relocation truncated to fit: R_X86_64_PC32 against symbol `ok' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `ok' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0xd2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0xf5): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `inf' defined in .bss section in /tmp/cc9XV6tO.o
a.cc:(.text+0x18a): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define INF ((1LL<<62)-(1LL<<31))
using namespace std;

int main(){
  long long int a,b;
  cin>>a>>b;
  long long int W[a+1],V[a+1],DP[a+1][1000001];
  //DP[i][j] i番目までの品物を、価値がj以上になるように選んだ時の最小の重さ
  
  for(int i=0; i<=a; ++i){
    if(i>0) cin>>W[i]>>V[i];
    for(int j=0; j<1000001; ++j){
      DP[i][j]=INF;
    }
  }
  
  DP[0][0]=0;
  
  for(int i=1; i<=a; ++i){
    for(int j=0; j<1000001; ++j){
      if(j>=V[i]) DP[i][j]=min(DP[i-1][j],DP[i-1][j-V[i]]+W[i]);
      else DP[i][j]=DP[i-1][j];
    }
  }
  
  int ans=1000000;
  while(dp[a][ans]>b) ans--;
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'dp' was not declared in this scope; did you mean 'DP'?
   34 |   while(dp[a][ans]>b) ans--;
      |         ^~
      |         DP