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

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

#define INF 1e9

long long solve(int i,vector <vector <int> >& in,int w,vector <vector <long long> >& dp){
	if(dp[i][w]>=0) return dp[i][w];
	int n=in.size();
	if(i==n){dp[i][w]=0; return 0;}
	if(w==0){dp[i][w]=0; return 0;}
	long long  m=0;
	m=max(m,solve(i+1,in,w,dp));
	if(w-in[i][0]>=0) m=max(m,in[i][1]+solve(i+1,in,w-in[i][0],dp));
	dp[i][w]=m;
	return m;
	}
int main(){
	long long n,w;
	cin>>n>>w;
	vector <vector <long long> > in (n,vector <long long> (2,0));
	for(int i=0;i<n;i++) cin>>in[i][0]>>in[i][1];
	vector <vector <long long> > dp (n+1,vector <long long> (w+1,-1));
	cout<<solve(0,in,w,dp)<<"\n";
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:23:23: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'std::vector<std::vector<long long int> >'
   23 |         cout<<solve(0,in,w,dp)<<"\n";
      |                       ^~
a.cc:6:47: note: in passing argument 2 of 'long long int solve(int, std::vector<std::vector<int> >&, int, std::vector<std::vector<long long int> >&)'
    6 | long long solve(int i,vector <vector <int> >& in,int w,vector <vector <long long> >& dp){
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~^~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:78: error: invalid types 'int [(l + 1)][int [n]]' for array subscript
   14 |             else if(w[i-1] <= j)dp[i][j] = max(v[i-1]+dp[i][j-w[i-1]],dp[i-1][w]);
      |                                                                              ^
Language: C++

long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
    if (knapsack.empty()) {
        return 0;
    }
    int n = knapsack.size();
    vector <long long> dp(capacity + 1);
    
    for (int i = 0; i < n; ++i) {
        int currWeight = knapsack[i].weight;
        int currValue = knapsack[i].value;
        for (int c = capacity; c >= currWeight; --c) {
            dp[c] = max(dp[c], dp[c - currWeight] + (long long)currValue);
        }
    }
    long long result = 0;
    for (long long v : dp) {
        result = max(result, v);
    }
    return result;
}

Compiler output:
a.cc:1:24: error: 'vector' was not declared in this scope
    1 | long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
      |                        ^~~~~~
a.cc:1:32: error: 'Knapsack' was not declared in this scope
    1 | long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
      |                                ^~~~~~~~
a.cc:1:43: error: 'knapsack' was not declared in this scope
    1 | long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
      |                                           ^~~~~~~~
a.cc:1:53: error: expected primary-expression before 'int'
    1 | long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
      |                                                     ^~~
a.cc:1:65: error: expression list treated as compound expression in initializer [-fpermissive]
    1 | long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
      |                                                                 ^
Language: C++

ong long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
    if (knapsack.empty()) {
        return 0;
    }
    int n = knapsack.size();
    vector <long long> dp(capacity + 1);
    
    for (int i = 0; i < n; ++i) {
        int currWeight = knapsack[i].weight;
        int currValue = knapsack[i].value;
        for (int c = capacity; c >= currWeight; --c) {
            dp[c] = max(dp[c], dp[c - currWeight] + (long long)currValue);
        }
    }
    long long result = 0;
    for (long long v : dp) {
        result = max(result, v);
    }
    return result;
}

Compiler output:
a.cc:1:1: error: 'ong' does not name a type; did you mean 'long'?
    1 | ong long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
      | ^~~
      | long
Language: C++

def main():
    a = [int(x) for x in input().split()]
    n, W = a[0], a[1]
    dp = [0] * (W + 1)
    for item in range(n):
        a = [int(x) for x in input().split()]
        weight, value = a[0], a[1]
        for weight_used in range(W - weight, -1, -1):
            dp[weight + weight_used] = max(dp[weight + weight_used], dp[weight_used] + value)
    a = 0
    for i in range(W+1):
        a = max(a, dp[i])
    print(a)


main()


Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;
int main(){

    int n,x;
    cin>>n>>x;

    long long int dp[10009];

    for(int i=0;i<n;i++){
        long long int a,b;
        scanf("%lld%lld",&a,&b);

        for(int j+a = x;j>= 0;j--){
            dp[j+a]=max(dp[j+a],dp[j]+b);
        }
    }

    cout<<dp[x];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: expected ';' before '+' token
   16 |         for(int j+a = x;j>= 0;j--){
      |                  ^
      |                  ;
a.cc:16:18: error: lvalue required as left operand of assignment
   16 |         for(int j+a = x;j>= 0;j--){
      |                  ^~
a.cc:16:30: error: expected ')' before ';' token
   16 |         for(int j+a = x;j>= 0;j--){
      |            ~                 ^
      |                              )
a.cc:16:31: error: 'j' was not declared in this scope
   16 |         for(int j+a = x;j>= 0;j--){
      |                               ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;
int main(){

    int n,x;
    cin>>n>>x;

    long long int dp[10009];

    for(int i=0;i<n;i++){
        int a,b;
        scanf("%lld%lld",&a,&b);

        for(int j+a = x;j>= 0;j--){
            dp[j+a]=max(dp[j+a],dp[j]+b);
        }
    }

    cout<<dp[x];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: expected ';' before '+' token
   16 |         for(int j+a = x;j>= 0;j--){
      |                  ^
      |                  ;
a.cc:16:18: error: lvalue required as left operand of assignment
   16 |         for(int j+a = x;j>= 0;j--){
      |                  ^~
a.cc:16:30: error: expected ')' before ';' token
   16 |         for(int j+a = x;j>= 0;j--){
      |            ~                 ^
      |                              )
a.cc:16:31: error: 'j' was not declared in this scope
   16 |         for(int j+a = x;j>= 0;j--){
      |                               ^
Language: C++

using namespace std;
int main(){

    int n,x;
    cin>>n>>x;

    long long int dp[10009];

    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;

        for(int j = x;j>= a;j--){
            dp[j]=max(dp[j],dp[j-a]+b);
        }
    }

    cout<<dp[x];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin>>n>>x;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:14:19: error: 'max' was not declared in this scope
   14 |             dp[j]=max(dp[j],dp[j-a]+b);
      |                   ^~~
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout<<dp[x];
      |     ^~~~
a.cc:18:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,W;
  	cin >> n;
  	cin >> W;
	int K[n+1][W+1];  
    for (int i = 0; i <= n; i++) 
    { 
       for (int 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]; 
       } 
   } 
  
   cout<< K[n][W]; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'wt' was not declared in this scope; did you mean 'w'?
   15 |            else if (wt[i-1] <= w)
      |                     ^~
      |                     w
a.cc:16:32: error: 'val' was not declared in this scope
   16 |                  K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
      |                                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,W;
	int K[n+1][W+1];  
    for (int i = 0; i <= n; i++) 
    { 
       for (int 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]; 
       } 
   } 
  
   cout<< K[n][W]; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'wt' was not declared in this scope; did you mean 'w'?
   13 |            else if (wt[i-1] <= w)
      |                     ^~
      |                     w
a.cc:14:32: error: 'val' was not declared in this scope
   14 |                  K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
      |                                ^~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>

using namespace std;

typedef pair<int, int64_t> Item;

vector<Item> items;
vector<int64_t> res;

map<Item, int64_t> cache;

int64_t f(int num_items, int64_t weight) {
  if (num_items == 0 || weight <= 0) {
    return 0;
  }

  Item key = {num_items, weight};
  auto it = cache.find(key);
  if (it != cache.end()) {
    return it->second;
  }
  int64_t result = 0;
  const Item& last = items[num_items - 1];
  int64_t v2 = f(num_items - 1, weight);
  if (last.first > weight) {
    result = v2;
  } else {
    int64_t v1 = f(num_items - 1, weight - last.first) + last.second;
    result = max(v1, v2);
  }
  cache[key] = result;
  return result;
}

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

  for (int i = 0; i < n; i++) {
    int w;
    int64_t v;
    cin >> w;
    cin >> v;
    items.push_back({w, v});
  }

  sort(items.begin(), items.end(), [](const Item& v1, const Item& v2) { return v1.first < v2.first; } );

  cout << f(n, W) << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   58 |   sort(items.begin(), items.end(), [](const Item& v1, const Item& v2) { return v1.first < v2.first; } );
      |   ^~~~
      |   sqrt
Language: C


#include <stdio.h>
long long MAX(long long a,long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}
int main()
{   
    long long n,W;
    scanf("%lld%lld",&n,&W);
    long long w[n],v[n];
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&w[i],&v[i]);
    }
    long long dp[n+1][W+2];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W+1;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            dp[i+1][j]=dp[i][j];
            if(j>=w[i])
            dp[i+1][j]=MAX(dp[i][j-w[i]]+v[i],dp[i][j]);
        }else{
            dp[i+1][j]=dp[i][j];
        }
    }
    printf("%lld",dp[n][W]);
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:29:10: error: 'else' without a previous 'if'
   29 |         }else{
      |          ^~~~
main.c:30:21: error: 'j' undeclared (first use in this function)
   30 |             dp[i+1][j]=dp[i][j];
      |                     ^
main.c:30:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
using namespace std;

typedef long long ll;

template<class T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int N,W;
int w[110],v[110];
int dp[110][100010];

int main(){
	cin>>N>>W;
	for(int i=0;i<N;i++)cin>>w[i]>>v[i];
	for(int i=0;i<N;i++){
		for(int sum=0;sum<=W;sum++){
			if(sum-w[i]>=0){
				chmax(dp[i+1][sum],dp[i][sum-w[i]]+v[i]);
			}
			chmax(dp[i+1][sum],dp[i][sum]);
		}
	}
	cout<<dp[n][w]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:18: error: 'n' was not declared in this scope
   30 |         cout<<dp[n][w]<<endl;
      |                  ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
using namespace std;

typedef long long ll;

template<class T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int n,w;
int w[110],v[110];
int dp[110][100010];

int main(){
	int n,w; cin>>n>>w;
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	for(int i=0;i<n;i++){
		for(int sum=0;sum<=w;sum++){
			if(sum-w[i]>=0){
				chmax(dp[i+1][sum],dp[i][sum-w[i]]+v[i]);
			}
			chmax(dp[i+1][sum],dp[i][sum]);
		}
	}
	cout<<dp[n][w]<<endl;
}

Compiler output:
a.cc:16:5: error: conflicting declaration 'int w [110]'
   16 | int w[110],v[110];
      |     ^
a.cc:15:7: note: previous declaration as 'int w'
   15 | int n,w;
      |       ^
a.cc: In function 'int main()':
a.cc:21:35: error: invalid types 'int[int]' for array subscript
   21 |         for(int i=0;i<n;i++)cin>>w[i]>>v[i];
      |                                   ^
a.cc:24:33: error: invalid types 'int[int]' for array subscript
   24 |                         if(sum-w[i]>=0){
      |                                 ^
a.cc:25:63: error: invalid types 'int[int]' for array subscript
   25 |                                 chmax(dp[i+1][sum],dp[i][sum-w[i]]+v[i]);
      |                                                               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long int ll;
map<ll,ll>dp;
ll w[105];
 ll v[105];
ll solve(ll i,ll W,ll n)
{
if(W<0)
return -100000000000000;
if(i>n)
return 0;
if(dp[i][W]!=-1)
return dp[i][W];
ll ans=0;
ans=max(v[i]+solve(i+1,W-w[i],n),ans);
ans=max(ans,solve(i+1,W,n));
return dp[i][W]=ans;
}
int main()
{
 ll n,W;
cin>>n>>W;
memset(dp,-1,sizeof(dp));
for(int i=1;i<=n;i++)
cin>>w[i]>>v[i];
cout<<solve(1,W,n);
}


Compiler output:
a.cc: In function 'll solve(ll, ll, ll)':
a.cc:14:9: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   14 | if(dp[i][W]!=-1)
      |         ^
a.cc:15:13: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   15 | return dp[i][W];
      |             ^
a.cc:19:13: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   19 | return dp[i][W]=ans;
      |             ^
a.cc: In function 'int main()':
a.cc:25:8: error: cannot convert 'std::map<long long int, long long int>' to 'void*'
   25 | memset(dp,-1,sizeof(dp));
      |        ^~
      |        |
      |        std::map<long long int, long long int>
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/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 <bits/stdc++.h>
using namespace std;

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 9;
using ll = long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int N, W;
    cin >> N >> W;
    vint w(N + 1), v(N + 1);
    REP1(i, N) {
        cin >> w[i] >> v[i];
    }

    //配る
    REP1(i, N) {
        REP(j, W + 1) {
            chmax(dp[i][j], dp[i - 1][j]);
            if (j + w[i] <= W)
                chmax(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
        }
    }
    cout << dp[N][W];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:19: error: 'dp' was not declared in this scope; did you mean 'dup'?
   50 |             chmax(dp[i][j], dp[i - 1][j]);
      |                   ^~
      |                   dup
a.cc:55:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
   55 |     cout << dp[N][W];
      |             ^~
      |             dup
Language: C++

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

int main() {
	// your code goes here
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1);
	ll dp[n+1][W+1]
	/*
	State
	dp[i][j]: Denotes the maximum value of items(from 1 to i) picked in the bag having total weight <=j
	Recurrence
	2 choices 1: we pick the ith element, 2: we dont pick the ith element 
	The 2 choices are checked for all weights
	dp[i][j]=maximum(value of items picked from 1 to i-1 with weight <=j,value of items picked from 1 to i-1 with weight <=(j-weight[i]) + value[i])
	*/
	for(ll i=1;i<=n;i++)
	cin>>w[i]>>v[i];
	for(ll i=0;i<=n;i++){
		dp[i][0]=0;
	}
	ll ans=0;
	for(ll i=0;i<=W;i++)
		dp[0][i]=0;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=W;j++){
			if(w[i]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: expected initializer before 'for'
   19 |         for(ll i=1;i<=n;i++)
      |         ^~~
a.cc:19:20: error: 'i' was not declared in this scope
   19 |         for(ll i=1;i<=n;i++)
      |                    ^
a.cc:22:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |                 dp[i][0]=0;
      |                 ^~
      |                 dup
a.cc:26:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   26 |                 dp[0][i]=0;
      |                 ^~
      |                 dup
a.cc:30:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   30 |                                 dp[i][j]=dp[i-1][j];
      |                                 ^~
      |                                 dup
a.cc:32:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   32 |                                 dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      |                                 ^~
      |                                 dup
a.cc:33:37: error: 'dp' was not declared in this scope; did you mean 'dup'?
   33 |                         ans=max(ans,dp[i][j]);
      |                                     ^~
      |                                     dup
Language: C++

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

int main()
{
    int no_of_items, total_weight;
    cin >> no_of_items >> total_weight;
	int weight[no_of_items+1],value[no_of_items+1];
  	vector<vector <int> >maximum_value;
    for(int i = 1; i <= no_of_items; i++)
        cin >> weight[i] >> value[i];

    memset(maximum_value, 0, sizeof(maximum_value));

    for(int i = 1; i <= no_of_items; i++)
    {
        for(int j = 1; j <= total_weight; j++)
        {
            if(j < weight[i])
                maximum_value[i][j] = maximum_value[i - 1][j];
            else
                maximum_value[i][j] = max(maximum_value[i - 1][j], value[i] + maximum_value[i - 1][j - weight[i]]);
        }
    }

    cout << maximum_value[no_of_items][total_weight];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: cannot convert 'std::vector<std::vector<int> >' to 'void*'
   13 |     memset(maximum_value, 0, sizeof(maximum_value));
      |            ^~~~~~~~~~~~~
      |            |
      |            std::vector<std::vector<int> >
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/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++

// A Dynamic Programming based solution for 0-1 Knapsack problem 
#include<stdio.h> 
#include<bits/stdc++.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:33:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   33 |         cin>>n>>W;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:3:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

// A Dynamic Programming based solution for 0-1 Knapsack problem 
#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:33:9: error: 'cin' was not declared in this scope
   33 |         cin>>n>>W;
      |         ^~~
Language: C++

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

int main()
{
    int no_of_items, total_weight;
    cin >> no_of_items >> total_weight;

    for(int i = 1; i <= no_of_items; i++)
        cin >> weight[i] >> value[i];

    memset(maximum_value, 0, sizeof(maximum_value));

    for(int i = 1; i <= no_of_items; i++)
    {
        for(int j = 1; j <= total_weight; j++)
        {
            if(j < weight[i])
                maximum_value[i][j] = maximum_value[i - 1][j];
            else
                maximum_value[i][j] = max(maximum_value[i - 1][j], value[i] + maximum_value[i - 1][j - weight[i]]);
        }
    }

    cout << maximum_value[no_of_items][total_weight];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: 'weight' was not declared in this scope
   10 |         cin >> weight[i] >> value[i];
      |                ^~~~~~
a.cc:10:29: error: 'value' was not declared in this scope
   10 |         cin >> weight[i] >> value[i];
      |                             ^~~~~
a.cc:12:12: error: 'maximum_value' was not declared in this scope
   12 |     memset(maximum_value, 0, sizeof(maximum_value));
      |            ^~~~~~~~~~~~~
a.cc:18:20: error: 'weight' was not declared in this scope
   18 |             if(j < weight[i])
      |                    ^~~~~~
a.cc:21:68: error: 'value' was not declared in this scope
   21 |                 maximum_value[i][j] = max(maximum_value[i - 1][j], value[i] + maximum_value[i - 1][j - weight[i]]);
      |                                                                    ^~~~~
Language: C++

#include<bits/stdc++.h>

#define pb push_back
#define se second
#define fi first

using namespace std;

int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;
int d[(int)1e5 + 7], mx;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> c[i];
    for(int i = 1; i <= w; i++){
        d[i] = -1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = w; j >= 0; j--){
            if(d[j] >= 0){
                d[j + a[i]] = max(d[j + a[i]], d[j] + (long long)c[i]);
            }
        }
    }
    for(int i = w; i >= 0; i--){
        mx = max(mx, d[i]);
    }
    cout << mx;
}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,w;
  cin>>n>>w;
  long long we[n],ve[n],dp[n+1],dps[n+1];
  for(int i=1;i<n+1;i++)
    dp[i]=-1;
  if(we[0]<=w)
  {
    dp[1]=ve[0];dps[1]=we[0];}
  for(int i=2;i<n+1;i++
      {
      for(int j=0;j<n;j++)
      {
      if(dps[i-1]+we[i-1]<=w)
      {
      if(dp[i]<dp[i-1]+ve[i-1])
      {
      dp[i]=dp[i-1]+ve[i-1];
        dps[i]=dps[i-1]+we[i-1];
      }
      }
      }
      }
   cout<<dp[n]; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:24: error: expected ')' before '{' token
   12 |   for(int i=2;i<n+1;i++
      |      ~                 ^
      |                        )
   13 |       {
      |       ~
Language: C

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int N, W; cin >> N >> W;
	VI v(N), w(N);
	REP(i, N) cin >> w[i] >> v[i];
	VVI dp(N + 1, VI(W + 1, 0));
	REP(i, N) {
		REP(j, W + 1) {
			if (w[i] <= j)
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			else
				dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
int b[1000][3];
int d[1000][100000];
int dp(int x,int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w);
            return d[x][w];
        }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
  
}
int main(){
    int x;
    int w;
    cin >> x >> w;
    for(int i=0; i <1000;i++){
        for(int j=0; j<10000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2];

    }
    cout << dp(x,w);
}
 

Compiler output:
a.cc: In function 'int dp(int, int)':
a.cc:18:5: error: expected '}' before 'else'
   18 |     else if( x == 1){
      |     ^~~~
a.cc:9:25: note: to match this '{'
    9 |     else if(w < b[x][1]){
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int b[1000][3];
int d[1000][100000];
int dp(int x,int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w)
            return d[x][w];
        }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
  
}
int main(){
    int x;
    int w;
    cin >> x >> w;
    for(int i=0; i <1000;i++){
        for(int j=0; j<10000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2];

    }
    cout << dp(x,w);
}
 

Compiler output:
a.cc: In function 'int dp(int, int)':
a.cc:15:32: error: expected ';' before 'return'
   15 |             d[x][w] = dp(x-1,w)
      |                                ^
      |                                ;
   16 |             return d[x][w];
      |             ~~~~~~              
a.cc:18:5: error: expected '}' before 'else'
   18 |     else if( x == 1){
      |     ^~~~
a.cc:9:25: note: to match this '{'
    9 |     else if(w < b[x][1]){
      |                         ^
a.cc:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
Language: C

#include <stdio.h>

  
int main(){
	
	int i, j;

    int N, W;
    scanf("%d", &N);
    scanf("%d", &W);
       
    long long int w[N], v[N];
       
    for(i = 0; i < N; i++){
       	scanf("%lld", &w[i]);
		scanf("%lld", &v[i]);
	}
      
	long long int mat[N+1][W+1];
	
	for(i=0;i<=W;i++){
		mat[0][i] = 0;	
	} 
	
	for(i=0;i<N;i++){
		for(j=0;j<=W;j++){
			if(j<w[i]){
				mat[i+1][j] = mat[i][j];	
			} 
			else{
				mat[i+1][j] = max(mat[i][j], mat[i][j-w[i]]+v[i]);	
			} 
		}
	}
	
	printf("%lld",mat[N][W]);
	return 0;
	
		}
       
       
       


Compiler output:
main.c: In function 'main':
main.c:31:47: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   31 |                                 mat[i+1][j] = max(mat[i][j], mat[i][j-w[i]]+v[i]);
      |                                               ^~~
Language: C

#include <stdio.h>

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

int main(void) {
	int N,W; 
	int w[N],v[N];
	for(int i=0;i<N;i++){
		scanf("%d %d",&w[i],&v[i]);
	}
	
	int vc[N+1][W+1];
	
	for(int i=0;i<=W;i++){
		vc[0][i] = 0;
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]){
				vc[i+1][j] = vc[i][j];	
			} 
			else{
			vc[i+1][j] = max(vc[i][j],vc[i][j-w[i]]+v[i]);
		}
	}
	
	printf("%d",vc[N][W]);

}

Compiler output:
main.c: In function 'main':
main.c:37:1: error: expected declaration or statement at end of input
   37 | }
      | ^
Language: C

#include <stdio.h>

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

int main(){
	
	int i, j;

    int N, W;
    scanf("%d", &N);
    scanf("%d", &W);
       
    int w[N], v[N];
       
    for(i = 0; i < N; i++){
       	scanf("%d", &w[i]);
		scanf("%d", &v[i]);
	}
      
	int mat[N+1][W+1];
	
	for(i=0;i<=W;i++){
		mat[0][i] = 0;	
	} 
	
	for(i=0;i<N;i++){
		for(j=0;j<=W;j++){
			if(j<w[i]){
				mat[i+1][j] = mat[i][j];	
			} 
			else{
				mat[i+1][j] = max(mat[i][j], mat[i][j-w[i]]+v[i]);	
			} 
		}
	}
	
	printf("%d",mat[N][W]);
	return 0;
	
		}
	}

       
       
       


Compiler output:
main.c:48:9: error: expected identifier or '(' before '}' token
   48 |         }
      |         ^
Language: C

#include <stdio.h>

//fiz em C porque deu problema de tempo de execução

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

int main(){

    int N, W;
    scanf("%d", &N);
    scanf("%d", &W);
       
    int w[N], v[N];
       
    for(int i = 0; i < N; i++){
       	scanf("%d", &w[i]);
		scanf("%d", &v[i]);
	}
      
	int mat[N+1][W+1];
	
	for(int i=0;i<=W;i++){
		mat[0][i] = 0;	
	} 
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]){
				mat[i+1][j] = mat[i][j];	
			} 
			else{
				mat[i+1][j] = max(vc[i][j],vc[i][j-w[i]]+v[i]);	
			} 
		}
	}
	
	printf("%d",mat[N][W]);
	return 0;
}
       
       
       


Compiler output:
main.c: In function 'main':
main.c:39:51: error: 'vc' undeclared (first use in this function); did you mean 'v'?
   39 |                                 mat[i+1][j] = max(vc[i][j],vc[i][j-w[i]]+v[i]);
      |                                                   ^~
      |                                                   v
main.c:39:51: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,i,j,m;
	cin>>n>>m;
	int memo[n+1];
	for(i=1;i<n+1;i++)memo[i]=-1;
	memo[0]=0;
	for(i=0;i<n;i++){
		pii novo;
		cin>>novo.ff>>novo.ss;
		for(j=n-novo.ff;j>=0;j--){
			if(memo[j]!=-1){
				memo[j+novo.ff] = max(memo[j+novo.ff],memo[j]+novo.ss);
			}
		}
	}
	int maior=-1;
	for(i=0;i<n+1;i++){
		if(memo[i]>maior)maior=memo[i]
	}	

	cout<<maior<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:47: error: expected ';' before '}' token
   30 |                 if(memo[i]>maior)maior=memo[i]
      |                                               ^
      |                                               ;
   31 |         }
      |         ~
Language: C++

#include<bits/stdc++>

using namespace std;

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,i,j,m;
	cin>>n>>m;
	int memo[n+1];
	for(i=1;i<n+1;i++)memo[i]=-1;
	memo[0]=0;
	for(i=0;i<n;i++){
		pii novo;
		cin>>novo.ff>>novo.ss;
		for(j=n-novo.ff;j>=0;j--){
			if(memo[j]!=-1){
				memo[j+novo.ff] = max(memo[j+novo.ff],memo[j]+novo.ss);
			}
		}
	}
	int maior=-1;
	for(i=0;i<n+1;i++){
		if(memo[i]>maior)maior=memo[i]
	}	

	cout<<maior<<endl;
}

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

#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,i,j,m;
	cin>>n>>m;
	int memo[n+1];
	for(i=1;i<n+1;i++)memo[i]=-1;
	memo[0]=0;
	for(i=0;i<n;i++){
		pii novo;
		cin>>novo.ff>>novo.ss;
		for(j=n-novo.ff;j>=0;j--){
			if(memo[j]!=-1){
				memo[j+novo.ff] = max(memo[j+novo.ff],memo[j]+novo.ss);
			}
		}
	}
	int maior=-1;
	for(i=0;i<n+1;i++){
		if(v[i]>maior)maior=v[i]
	}	

	cout<<maior<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:20: error: 'v' was not declared in this scope
   30 |                 if(v[i]>maior)maior=v[i]
      |                    ^
Language: C++

#include<bits/stdc++>

using namespace std;

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,i,j,m;
	cin>>n>>m;
	int memo[n+1];
	for(i=1;i<n+1;i++)memo[i]=-1;
	memo[0]=0;
	for(i=0;i<n;i++){
		pii novo;
		cin>>novo.ff>>novo.ss;
		for(j=n-novo.ff;j>=0;j--){
			if(memo[j]!=-1){
				memo[j+novo.ff] = max(memo[j+novo.ff],memo[j]+novo.ss);
			}
		}
	}
	int maior=-1;
	for(i=0;i<n+1;i++){
		if(v[i]>maior)maior=v[i]
	}	

	cout<<maior<<endl;
}

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

#include <bits/stdc++.h>
using namespace std;
int b[1000][3];
int d[1000][100000];
int dp(int x,int w){
  	if(d[x][w != 0]){
        return d[x][w];
    }
    else if(w < b[x][1]){
        else if( x == 1 ){
            return d[2][w];
        }
        else {
            d[x][w] = d[x+1][w];
            return dp(x-1,w);}
        }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }

}
int main(){
    int x;
    int w;
    cin >> x >> w;
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2];
    }
    cout << dp(x,w);
}



Compiler output:
a.cc: In function 'int dp(int, int)':
a.cc:10:9: error: expected '}' before 'else'
   10 |         else if( x == 1 ){
      |         ^~~~
a.cc:9:25: note: to match this '{'
    9 |     else if(w < b[x][1]){
      |                         ^
a.cc: At global scope:
a.cc:17:5: error: expected unqualified-id before 'else'
   17 |     else if( x == 1){
      |     ^~~~
a.cc:20:5: error: expected unqualified-id before 'else'
   20 |     else {
      |     ^~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
a.cc: In function 'int dp(int, int)':
a.cc:16:9: warning: control reaches end of non-void function [-Wreturn-type]
   16 |         }
      |         ^
Language: C++

#include<bits/stdc++.h>
#define pb push_back
//#define pair pair<int,int>
#define ll long long int
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
ll max(ll a,ll b)
{
  return a>b?a:b;
}
ll n,w;
vector<pair<ll,ll>> v(101);
map<pair<ll,ll>,ll> m;
ll maxi(ll i,ll wt)
{
  if(i>n-1 || wt<0)
    return 0;
  if(m[{i,wt}]!=0)
    return m[{i,wt}];
  if(v[i][0]>wt)
    m[{i,wt}]=maxi(i+1,wt);
  else
  m[{i,wt}]=max(v[i].se+maxi(i+1,wt-v[i].f),maxi(i+1,wt)); 
  return m[{i,wt}];
}
int main(){
   scanf("%lli %lli",&n,&w);
   for(int i=0;i<n;i++)
     scanf("%lli %lli",&v[i].f,&v[i].se);
   printf("%lli",maxi(0,w));
}

Compiler output:
a.cc: In function 'long long int maxi(long long int, long long int)':
a.cc:22:10: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} and 'int')
   22 |   if(v[i][0]>wt)
      |          ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  ll n,W,ans=0;
  cin >> n >> W;
  vector<vector<ll>>dp(n+5,vector<ll>(W+5,0));
  vector<ll>w(n);vector<ll>v(n);
  rep(i,n) cin >> w.at(i) >> v.at(i);
  rep(i,n) rep(j,W+1){
    if(j-w[i]>=0) chmax(dp[i+1][j-w[i]],dp[i][j]+v[i]);
    else chmax(dp[i+1][j],dp[i][j]);
  }
  cout << dp[n][W]3 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:19: error: expected ';' before numeric constant
   25 |   cout << dp[n][W]3 << endl;
      |                   ^
      |                   ;
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  ll n,w,ans=0;
  cin >> n >> w;
  vector<vector<ll>>dp(n+5,vector<ll>(w+5,0));
  vector<ll>w(n);vector<ll>v(n);
  rep(i,n) cin >> w.at(i) >> v.at(i);
  rep(i,n) rep(j,w+1){
    if(j-w[i]>=0) chmax(dp[i+1][j-w[i]],dp[i][j]+v[i]);
    else chmax(dp[i+1][j],dp[i][j]);
  }
  rep(i,3) ans=max(ans,dp[n][i]);
  cout << dp[n][w]3 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: conflicting declaration 'std::vector<long long int> w'
   19 |   vector<ll>w(n);vector<ll>v(n);
      |             ^
a.cc:16:8: note: previous declaration as 'll w'
   16 |   ll n,w,ans=0;
      |        ^
a.cc:20:21: error: request for member 'at' in 'w', which is of non-class type 'll' {aka 'long long int'}
   20 |   rep(i,n) cin >> w.at(i) >> v.at(i);
      |                     ^~
a.cc:22:11: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   22 |     if(j-w[i]>=0) chmax(dp[i+1][j-w[i]],dp[i][j]+v[i]);
      |           ^
a.cc:22:36: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   22 |     if(j-w[i]>=0) chmax(dp[i+1][j-w[i]],dp[i][j]+v[i]);
      |                                    ^
a.cc:26:19: error: expected ';' before numeric constant
   26 |   cout << dp[n][w]3 << endl;
      |                   ^
      |                   ;
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,w;
ll dp[125252];

int main(){
  scanf("%d%d",&n,&w);
  fill(dp,dp+w+1,-1ll<<60);
  dp[0] = 0;
  REP(i,n){
    int a,b;
    scanf("%d%d",&a,&b);
    FORR(j,0,w+1-a)CHMAX(dp[j+a],dp[j]+b);
  }
  printf("%lld\n",*(dp+w);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:26: error: expected ')' before ';' token
   46 |   printf("%lld\n",*(dp+w);
      |         ~                ^
      |                          )
Language: C++

#include<iostream>
using namespace std;

int main(){
  	int n, max_w;
  	cin >> n >> max_w;
  	int *w = new int[n];
  	int *v = new int[n];
  	int dp[n][max_w+1] = {};
  	for(int i = 0; i < n; i++){
    	cin >> w[i] >> v[i];
    }
  	for(int i = 0; i < max_w+1; i++)
      dp[0][i] = v[0];
 	for(int i = 0; i < n; i++)
      for(int j = 0; j < max_w + 1; j++){
      	int t1, t2;
        t1 = 0;
        if(j >= w[i])
          t1 = dp[i-1,j-w[i]] + v[i];
       	t2 = dp[i-1,j];
        dp[i][j] = max(t1, t2);   
      }
  	cout << dp[n-1][max_w];
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:31: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   20 |           t1 = dp[i-1,j-w[i]] + v[i];
      |                ~~~~~~~~~~~~~~~^~~~~~
      |                               |
      |                               int*
a.cc:21:22: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   21 |         t2 = dp[i-1,j];
      |              ~~~~~~~~^
      |                      |
      |                      int*
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define vec(a,b) b-a
#define Reka ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
ll w[9999999];
ll p[9999999];
int l,n;
ll c[100][1e5+1];
ll solve(int ind , ll sum)
{
    if(ind == n || sum == l )
        return c[ind][sum] = 0;
     ll r,rr,ans;
     if(c[ind][sum]!=-1)
        return c[ind][sum];
     if(w[ind]+sum>l){
        ans = solve(ind+1,sum);
     }
    else {
     ans = max(solve(ind+1,sum+w[ind])+p[ind],solve(ind+1,sum));
    }
    return c[ind][sum] = ans;
}

int main()
{
    Reka
    memset(c,-1,sizeof(c));
   cin>>n>>l;
   for(int i=0;i<n;i++)
   {
     cin>>w[i]>>p[i];
   }
   cout<<solve(0,0);
   return 0;
}


Compiler output:
a.cc:13:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   13 | ll c[100][1e5+1];
      |           ~~~^~
a.cc:13:14: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
   13 | ll c[100][1e5+1];
      |           ~~~^~
      |              |
      |              double
a.cc:13:14: error: size of array 'c' has non-integral type 'double'