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

#include "bits/stdc++.h"
using namespace std;
 
int main(){
  int n,c;
  cin >> n >>c ;
  
  long long val[n],wt[n];
  for(int i=0;i<n;i++){
 	cin >> wt[i] >> val[i] ;
  }
  
  long long  dp[n+1][c+1] ;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=c;j++){
      if(i==0 || j==0)
        dp[i][j]=0;
      else if(wt[i-1]<=j){
        dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j]) ;
      }else{
        dp[i][j]=dp[i-1][j];
      }
      
    }
  }
  
  cout<<dp[n][c] ;
  
  return 0;
}
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n,c;
  cin >> n >>c ;
  
  long long val[n],wt[n];
  for(int i=0;i<n;i++){
 	cin >> wt[i] >> val[i] ;
  }
  
  long long  dp[n+1][c+1] ;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=c;j++){
      if(i==0 || j==0)
        dp[i][j]=0;
      else if(wt[i-1]<=j){
        dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j]) ;
      }else{
        dp[i][j]=dp[i-1][j];
      }
      
    }
  }
  
  cout<<dp[n][c] ;
  
  return 0;
}
Submission Info

Compiler output:
a.cc:35:5: error: redefinition of 'int main()'
   35 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~
a.cc:63:1: error: 'Submission' does not name a type
   63 | Submission Info
      | ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define forp(x,a,b) for(int x=a; x<b; x++)
#define forn(x,a,b) for(int x=a; x>b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define w(x) while(x--)
using namespace std;
typedef long long ll;
const int mod= 1e9 + 7;
 int n, p;
 ll w[100], v[100];
 ll W[100001][101];
 ll pot(ll x,int y){
    if(y==0){
        return 1;
            }
else{
    if(y%2==0){ int k=pot(x,y/2);
        return k*k;
        }
    else{
        return x*pot(x,y-1);
        }    
    }
}


 
void solve(){ 
    
}

int main(){
 ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>p;
    forp(i,0,n){cin>>w[i]>>v[i];}
    forp(i,1,p+1){
        forn(j,n-1,-1){
          W[i][j] = W[i-1][j
          if(i>=w[j]){
            W[i][j]=max(W[i-w[j]][j+1]+v[j],W[i][j+1]);
       		 }//cout<<W[i][j]<<' ';
        }//cout<<endl;
   }
    
    
    cout<<W[p][0];
    
    return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:29: error: expected ']' before 'if'
   52 |           W[i][j] = W[i-1][j
      |                             ^
      |                             ]
   53 |           if(i>=w[j]){
      |           ~~                 
a.cc:52:29: error: expected ';' before 'if'
   52 |           W[i][j] = W[i-1][j
      |                             ^
      |                             ;
   53 |           if(i>=w[j]){
      |           ~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {	
	int t=1;
	//cin >> t;
	while (t--) {
	   
	    int n;
       cin>>n;
       long long w;
       cin>>w;
       long long*val=new long long[n];
        long long*we=new long long[n];
       
       
       for(int i=0;i<n;i++)
       {
       	 cin>>we[i];
       	 cin>>val[i];
	   }
	   long long dp[101[100001];
	   for(int i=0;i<n;i++)
	   {
	   	dp[0][i]=0;
	   }
	   for(int i=0;i<n;i++)
	   {
	   	dp[i][0]=0;
	   }
	   int k;
	    
	   for(int i=1;i<=n;i++)
	   {
	   	for(int j=1;j<=w;j++)
	   	{
	   		if(we[i-1]<=j)
	   		{
	   			dp[i][j]=max(val[i-1]+dp[i-1][j-we[i-1]],dp[i-1][j]);
			}
			else
			dp[i][j]=dp[i-1][j];
		}
	   }
	   cout<<dp[n][w];
      }
	} 
	
	
	

Compiler output:
a.cc: In function 'int main()':
a.cc:21:28: error: invalid types 'int[int]' for array subscript
   21 |            long long dp[101[100001];
      |                            ^
a.cc:21:36: error: expected ']' before ';' token
   21 |            long long dp[101[100001];
      |                                    ^
      |                                    ]
a.cc:24:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   24 |                 dp[0][i]=0;
      |                 ^~
      |                 dup
a.cc:28:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   28 |                 dp[i][0]=0;
      |                 ^~
      |                 dup
a.cc:38:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   38 |                                 dp[i][j]=max(val[i-1]+dp[i-1][j-we[i-1]],dp[i-1][j]);
      |                                 ^~
      |                                 dup
a.cc:41:25: error: 'dp' was not declared in this scope; did you mean 'dup'?
   41 |                         dp[i][j]=dp[i-1][j];
      |                         ^~
      |                         dup
a.cc:44:18: error: 'dp' was not declared in this scope; did you mean 'dup'?
   44 |            cout<<dp[n][w];
      |                  ^~
      |                  dup
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: 'W' was not declared in this scope
    7 |   cin>>n>>W;
      |           ^
a.cc:8:7: error: conflicting declaration 'int w [n]'
    8 |   int w[n],v[n];
      |       ^
a.cc:6:9: note: previous declaration as 'int w'
    6 |   int n,w;
      |         ^
a.cc:11:11: error: invalid types 'int[int]' for array subscript
   11 |     cin>>w[i]>>v[i];
      |           ^
a.cc:13:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |   dp[n+1][W+1];
      |   ^~
      |   dup
a.cc:25:11: error: invalid types 'int[int]' for array subscript
   25 |       if(w[i][j]>W)
      |           ^
a.cc:28:49: error: invalid types 'int[int]' for array subscript
   28 |       dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]];
      |                                                 ^
Language: C++

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

int main()
{
  int N,W;
  cin>>N>>W;
  int v[N+1],w[N+1];
  for(int i=1;i<=N;i++)
    cin>>v[i]>>w[i];
  int dp[N+1][W+1];
  for(int i=1;i<=W;i++)
    dp[1][i]=0;
  dp[1][w[1]]=v[1];
  for(int i=2;i<=N;i++){
    for(int j=1;j<=W;j++){
      dp[i][j]=dp[i-1][j];
      if(j-w[i]>=0)
        dp[i][j]=max(dp[i][j],v[i]+dp[i][j-w[i]]);
    }
  }
  int ans=max_element(dp[N],dp[N]+W+1);
  cout<<ans;
     
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:22: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   22 |   int ans=max_element(dp[N],dp[N]+W+1);
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                      |
      |                      int*
Language: C++

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

int main()
{
  int N,W;
  cin>>N>>W;
  int v[N+1],w[N+1];
  for(int i=1;i<=N;i++)
    cin>>v[i]>>w[i];
  int dp[N+1][W+1];
  dp[1][w[1]]=v[1];
  for(int i=2;i<=N;i++){
    dp[i]=INT_MIN;
    for(int j=1;j<=W;j++){
      dp[i][j]=dp[i-1][j];
      if(j-w[i]>=0)
        dp[i][j]=max(dp[i][j],v[i]+dp[i][j-w[i]]);
    }
  }
  int ans=max_element(dp[N],dp[N]+W+1);
  cout<<ans;
     
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: incompatible types in assignment of 'int' to 'int [(W + 1)]'
   14 |     dp[i]=INT_MIN;
      |          ^
a.cc:21:22: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   21 |   int ans=max_element(dp[N],dp[N]+W+1);
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                      |
      |                      int*
Language: C++

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

int main()
{
  int N,W;
  cin>>N>>W;
  int v[N+1],w[N+1];
  for(int i=1;i<=N;i++)
    cin>>v[i]>>w[i];
  dp[N+1][W+1];
  dp[1][w[1]]=v[1];
  for(int i=2;i<=N;i++){
    dp[i]=INT_MIN;
    for(int j=1;j<=W;j++){
      dp[i][j]=dp[i-1][j];
      if(j-w[i]>=0)
        dp[i][j]=max(dp[i][j],v[i]+dp[i][j-w[i]]);
    }
  }
  int ans=max_element(dp[N],dp[N]+W+1);
  cout<<ans;
     
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |   dp[N+1][W+1];
      |   ^~
      |   dup
Language: C++

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

int main()
{
  int N,W;
  cin>>N>>W;
  int v[N+1],w[N+1];
  for(int i=1;i<=N;i++)
    cin>>v[i]>>w[i];
  dp[N+1][W+1];
  dp[1][w[1]]=v[1];
  for(int i=2;i<=N;i++){
    dp[i]=INT_MIN;
    for(int j=1;j<=W;j++){
      dp[i][j]=dp[i-1][j];
      if(j-w[i]>=0)
        dp[i][j]=max(dp[i][j],v[i]+dp[i][j-w[i]]);
    }
  }
  int ans=max_element(dp[n],dp[n]+W+1);
  cout<<ans;
     
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |   dp[N+1][W+1];
      |   ^~
      |   dup
a.cc:21:26: error: 'n' was not declared in this scope
   21 |   int ans=max_element(dp[n],dp[n]+W+1);
      |                          ^
Language: C++

#include<bits/stdc++.h>
#define line cout<<endl;
#define space cout<<" ";
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.141592653589793238
typedef long long int ll;

using namespace std;

const int N = 1e9+7;

vector<ll> wt(100005);
vector<ll> val(100005);

ll dp[10005][10005];

ll knapsackone(ll n,ll w)
{
    if(n==0||w==0)
        return 0;

    if(dp[n][w]!=-1)
        return dp[n][w];

    if(wt[n]<=w)
    {
        return  dp[n][w] = max(val[n]+knapsackone(n-1,w-wt[n]),knapsackone(n-1,w));
    }
    else
        return dp[n][w] = knapsackone(n-1,w);
}



void solve()
{
    memset(dp,-1,sizeof(dp));
    ll n,w;
    cin>>n;
    cin>>w;

    for(int i=1;i<=n;i++)
    {
        cin>>wt[i];
        cin>>val[i];
    }

    ll ans = knapsackone(n,w);
    cout<<dp[n][c];
}


int main()
{
   ll t;
   t = 1;
  // cin>>t;

   while(t--)
   {
       solve();
       cout<<endl;
   }


}



Compiler output:
a.cc: In function 'void solve()':
a.cc:49:17: error: 'c' was not declared in this scope
   49 |     cout<<dp[n][c];
      |                 ^
Language: C++

#include <iostream>

using namespace std;
const int maxn=110;
int a[maxn][2];
const int maxx=1e6+10;
int dp[maxn][maxx];

const int MAXW = 1e5 + 10;

long long k[MAXW];
int n,w;


int main()
{
    cin >> n >> w;
    for(int j = 1; j<=N; j++)
    {
        int q,v;
        cin >> q >> v;
        for(int i = w; i>=q; i--)
        {
            k[i] = max(k[i-q] + v,k[i]);
        }
    }

    long long c = 0;
    for(int i = 0; i<=w; i++)
    {
        c = max(c,k[i]);
    }
    cout << c << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: 'N' was not declared in this scope
   18 |     for(int j = 1; j<=N; j++)
      |                       ^
Language: C++

#include <iostream>

const int N = 101;
long long w[N],v[N];
long long n,W;

long long knapsack(long long totalW , long long totalV , long long count){
    if(totalW > W)return ;
    if(count == n)return totalV;
    long long o1 = knapsack((totalW+w[count]),(totalV+v[count]),(count+1));
    long long o2 = knapsack((totalW-w[count]),(totalV-v[count]),(count+1));
    return std::max(o1,o2);
}

int main(){
        std:: cin >> n >> W;
    for(int i=0; i<n; i++){
        std:: cin >> w[i] >> v[i];
    }
       std:: cout << knapsack(0,0,0);
      return 0; 
}

Compiler output:
a.cc: In function 'long long int knapsack(long long int, long long int, long long int)':
a.cc:8:19: error: return-statement with no value, in function returning 'long long int' [-fpermissive]
    8 |     if(totalW > W)return ;
      |                   ^~~~~~
Language: C

#include <bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 200 + 9;
ll mod = 1e9L + 9;

void test() {
    int n, w;
    cin >> n >> w;
    vector<ll> weights(n), values(n);
    for (int i = 0; i < n; i++)cin >> weights[i] >> values[i];
    /*
     * dp[i] => max value with weight i
     */
    vector<ll> dp(w + 1);
    for (int item = 0; item < n; item++) {
        //item
        /* weight_item = 3
         * dp[5] = max(dp[5],dp[w-weight_item]+val_item)
         */
        vector<ll> new_dp = dp;
        int cur_w = weights[item], cur_v = values[item];
        for (int weight = cur_w; weight <= w; weight++) {
            new_dp[weight] = max(dp[weight], dp[weight - cur_w] + cur_v);
        }
        for (int i = 1; i <= w; i++)new_dp[i]=max(new_dp[i],new_dp[i-1]);
        dp = new_dp;
    }
    cout << dp[w] << endl;


}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //    freopen("input.in", "r", stdin);
    int t = 1;
//    cin >> t;
//    scanf("%d", &t);
    for (int cas = 1; cas <= t; cas++) {
//        printf("Case %d: ", cas);
        test();
    }
}

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

#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define fora(i,a,b) for(int i = a ; i<b ;i++)
typedef long long ll;
typedef int i;
typedef vector<i>vi;
typedef pair<i,i>pi;

ll v[100010][10];
ll dp[100010][10];
ll f(int i, ll W){
    if(W < 0) return -1e8LL;
    if(i == 0) return 0;
    ll &r = dp[i][W];
    if(r !=-1) return r;
    r = max( f(i-1 ,W)  , f(i-1 , W-v[i][0])+v[i][1]);
    return r;
}
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll W;
    cin>>n>>W;
    memset(dp,-1,sizeof dp);
    fora(i,1,n+1) cin>>v[i][0]>>v[i][1];
    cout<<f(n,W)<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'll f(int, ll)':
a.cc:14:23: error: unable to find numeric literal operator 'operator""LL'
   14 |     if(W < 0) return -1e8LL;
      |                       ^~~~~
Language: C++

#include<iostream>
#include<vector>
#include<queue>

using namespace std;
#define ll long long

int main()
{
    //int tc; cin>>tc;
    
        ll n,w; cin>>n>>w;
        vector<ll> val(n+1),weit(n+1);
        for(int i=0;i<n;i++)
        {
             cin>>weit[i]; cin>>val[i];
        }
        ll sum = 100005;
        ll dp[sum+5];
        for(int i=0;i<=sum;i++)
        {
            dp[i] = INT_MIN;
        }
        dp[0]=0;
        for(ll i=0;i<n;i++)
        {
            for(ll j=sum;j>=0;j--)
            {
                dp[j] = max(dp[j],j>=weit[i]?dp[j-weit[i]]+val[i]:INT_MIN);
            }
        }
        ll ans=0;
        for(int i=0;i<=w;i++)
        {
            ans = max(ans,dp[i]);
        }
        cout<<ans<<endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: 'INT_MIN' was not declared in this scope
   22 |             dp[i] = INT_MIN;
      |                     ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<queue>
  +++ |+#include <climits>
    4 | 
a.cc:29:67: error: 'INT_MIN' was not declared in this scope
   29 |                 dp[j] = max(dp[j],j>=weit[i]?dp[j-weit[i]]+val[i]:INT_MIN);
      |                                                                   ^~~~~~~
a.cc:29:67: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:22:36: error: 'd' was not declared in this scope
   22 |         dp[i][j]=max(c+dp[i][j-w1],d[i-1][j]);
      |                                    ^
a.cc:29:4: error: expected '}' at end of input
   29 |   }
      |    ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

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

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

#include <bits/stdc++.h>
#define ll long long
using namespace std;
deque <int> weights;
ll maxValue[100040];

int main() {
    int n, w, weight, value;

	cin >> n >> w;
	for (int i = 1; i <= n; i++){
		cin >> weight >> value;

		for (int currentWeight : weights)
			if ((ll) currentWeight + weight <= w) {
				if (!maxValue[currentWeight + weight])
					weights.push_front(currentWeight + weight);
				maxValue[currentWeight + weight] = max(maxValue[currentWeight + weight], maxValue[currentWeight] + value);
			}

		if (!maxValue[weight])
			weights.push_front(weight);
		maxValue[weight] = max(maxValue[weight], value);
	}

	ll result = 0;
    for (int currentWeight : weights)
    	result = max(result, maxValue[currentWeight]);
	cout << result;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:39: error: no matching function for call to 'max(long long int&, int&)'
   23 |                 maxValue[weight] = max(maxValue[weight], 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:23:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |                 maxValue[weight] = max(maxValue[weight], 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:23:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |                 maxValue[weight] = max(maxValue[weight], value);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int n,w;
  cin>>n>>w;
  int * wt= new int[n];
  int * val=new int[n];
  for(int i=0;i<n;i++)
  {  cin>>wt[i]>>val[i];
  }
  int dp[n+1][w+1];
  
  for(int item=0;item<=n;item++)
  {
    for(int weight=0;weight<=w;weight++)
    {
      if(weight==0||item==0)
      {
        dp[item][weight]=0;
      }
      else if(wt[item-1]<=weight)
      {   
        dp[item][weight]=std::max(dp[item-1][weight],val[i-1]+dp[item-1][weight-wt[item-1]]);
      }
      else
      { dp[item][weight]=dp[item-1][weight];
      }
      
  
  
  
  cout<<dp[n][w];
  
  
  
  
 return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:58: error: 'i' was not declared in this scope
   24 |         dp[item][weight]=std::max(dp[item-1][weight],val[i-1]+dp[item-1][weight-wt[item-1]]);
      |                                                          ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:15:3: note: to match this '{'
   15 |   {
      |   ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int n,w;
  cin>>n>>w;
  int * wt= new int[n];
  int * val=new int[n];
  for(int i=0;i<n;i++)
  {  cin>>wt[i]>>val[i];
  }
  int dp[n+1][w+1];
  
  for(int item=0;item<=n;item++)
  {
    for(int weight=0;weight<=w;weight++)
    {
      if(weight==0||item==0)
      {
        dp[item][weight]=0;
      }
      else if(wt[i-1]<=weight)
      {   
        dp[item][weight]=std::max(dp[item-1][weight],val[i-1]+dp[i-1][weight-wt[i-1]]);
      }
      else
      { dp[item][weight]=dp[item-1][weight];
      }
      
  
  
  
  cout<<dp[n][w];
  
  
  
  
 return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: 'i' was not declared in this scope
   22 |       else if(wt[i-1]<=weight)
      |                  ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:15:3: note: to match this '{'
   15 |   {
      |   ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int   N=1e4+10;
long long w[N],v[N];
int main()
{
	long long n,m;
	cin>>n>>m;
	for(int  i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
long long f[n+1][m+1],
	for(int  i=1;i<=n;i++)
	{
		for(int  j=0;j<=m;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=w[i])
			{
				f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
			}
		}
	}
	cout<<f[n][m]<<endl;
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected unqualified-id before 'for'
   14 |         for(int  i=1;i<=n;i++)
      |         ^~~
a.cc:14:22: error: 'i' was not declared in this scope
   14 |         for(int  i=1;i<=n;i++)
      |                      ^
Language: C++

/*
     _              ,_,                 
    / \   _ __, ___,| |__   __ _,_ __  
   / ^ \ | '_ \/ _ \| '_ \ / _` | /_/  
  /-/-\-\|-| |--| |-|-|_)-|-(_|-|-|    
 /_/   \_\_| |__| |_|_.__/ \__,_|_|    
 
*/
#include <bits/stdc++.h>
using namespace std;
 



int  main(){

    // cin>>test;

        long long  n, w; cin>>n>>w;
        long long wt[10000],val[10000];
        rep(i, 0, n)cin>>wt[i]>>val[i];
        long long  dp[n+1][w+1];
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<n+1; i++){
        	for(int j=1; j<w+1; j++){
        		if(j>=wt[i-1])dp[i][j]=max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
        		else dp[i][j]=dp[i-1][j];
        	}
        }
        cout<<dp[n][w]<<endl;
 
     
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'i' was not declared in this scope
   21 |         rep(i, 0, n)cin>>wt[i]>>val[i];
      |             ^
a.cc:21:9: error: 'rep' was not declared in this scope
   21 |         rep(i, 0, n)cin>>wt[i]>>val[i];
      |         ^~~
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
using namespace std;
const long long  N=1e5+10;
long long  f[N][N],v[N],a[N],m;
long long  w[N];
int main()
{
	long long  n;
	scanf("%lld%lld",&n,&m);
	for(long long  i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
	}
	for(long long  i=1;i<=n;i++)
	{

		for(long long  j=0;j<=m;j++)
		{
			f[i][j]=f[i-1][j];
			if(j-w[i]>=0)
			{
				f[i][j]=max(f[i][j],f[i-1][j-w[i]]+v[i]);
			}
		}
	}
	printf("%lld",f[n][m]);


   return 0;
}


Compiler output:
/tmp/cctaGqZZ.o: in function `main':
a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0xfd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0x167): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0x1d9): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cctaGqZZ.o
a.cc:(.text+0x201): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cctaGqZZ.o
collect2: error: ld returned 1 exit status
Language: Java

package AtCoderDP_Problems;

import java.util.Scanner;

public class D_Knapsack1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int k = scn.nextInt();

		int[] w = new int[n];
		int[] p = new int[n];
		for (int i = 0; i < p.length; i++) {
			w[i] = scn.nextInt();
			p[i] = scn.nextInt();
		}

		System.out.println(solve(n, k, p, w));
	}

	public static long solve(int n, int k, int[] p, int[] w) {

		long[][] dp = new long[n + 1][k + 1];

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

				if (i == 0 || j == 0) {
					dp[i][j] = 0;
					continue;
				}
				long a = dp[i - 1][j];
				long b = (j - w[i-1]) >= 0 ? p[i-1] + dp[i - 1][j - w[i-1]] : Integer.MIN_VALUE;
				dp[i][j] = Math.max(a, b);
			}

		}

		return dp[n][k];
	}

}


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

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

class b{
 public:
  int weights;
  long long int values;
  
};
bool comm(b b1, b b2)
{
  return (b1.values>b2.values);
}


long long int main(){

  int n,w;
  cin>>n>>w;
  
  b arr[n];
  for(int i=0; i<n; i++){
   int wi;
    long long int vi;
    cin>>wi>>vi;
    arr[i].weights=wi;
    arr[i].values=vi;
  }
  
  sort(arr,arr+n,comm);
  long long int V=0;
  for(int i=0; i<n; i++){
    if(w-arr[i].weights>=0){
     V=V+arr[i].values;
      w=w-arr[i].weights;
    }
  }
  return V;
}





Compiler output:
a.cc:17:11: error: '::main' must return 'int'
   17 | long long int main(){
      |           ^~~
Language: C++

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

class b{
   int weights;
  long long int values;
  
}
bool comm(b b1, b b2)
{
  return (b1.values>b2.values);
}


int main(){

  int n,w;
  cin>>n>>w;
  
  b arr[n];
  for(int i=0; i<n; i++){
   int wi;
    long long int vi;
    cin>>wi>>vi;
    arr[i].weights=wi;
    arr[i].values=vi;
  }
  
  sort(arr,arr+n,comm);
  long long int V=0;
  for(int i=0; i<n; i++){
    if(w-arr[i].weights>=0){
     V=V+arr[i].values;
      w=w-arr[i].weights;
    }
  }
  return V;
}





Compiler output:
a.cc:9:2: error: expected ';' after class definition
    9 | }
      |  ^
      |  ;
a.cc: In function 'bool comm(b, b)':
a.cc:12:14: error: 'long long int b::values' is private within this context
   12 |   return (b1.values>b2.values);
      |              ^~~~~~
a.cc:7:17: note: declared private here
    7 |   long long int values;
      |                 ^~~~~~
a.cc:12:24: error: 'long long int b::values' is private within this context
   12 |   return (b1.values>b2.values);
      |                        ^~~~~~
a.cc:7:17: note: declared private here
    7 |   long long int values;
      |                 ^~~~~~
a.cc: In function 'int main()':
a.cc:26:12: error: 'int b::weights' is private within this context
   26 |     arr[i].weights=wi;
      |            ^~~~~~~
a.cc:6:8: note: declared private here
    6 |    int weights;
      |        ^~~~~~~
a.cc:27:12: error: 'long long int b::values' is private within this context
   27 |     arr[i].values=vi;
      |            ^~~~~~
a.cc:7:17: note: declared private here
    7 |   long long int values;
      |                 ^~~~~~
a.cc:33:17: error: 'int b::weights' is private within this context
   33 |     if(w-arr[i].weights>=0){
      |                 ^~~~~~~
a.cc:6:8: note: declared private here
    6 |    int weights;
      |        ^~~~~~~
a.cc:34:17: error: 'long long int b::values' is private within this context
   34 |      V=V+arr[i].values;
      |                 ^~~~~~
a.cc:7:17: note: declared private here
    7 |   long long int values;
      |                 ^~~~~~
a.cc:35:18: error: 'int b::weights' is private within this context
   35 |       w=w-arr[i].weights;
      |                  ^~~~~~~
a.cc:6:8: note: declared private here
    6 |    int weights;
      |        ^~~~~~~
Language: C++

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

class b{
   int weights;
  long long int values;
  
}
bool comm(b b1, b b2)
{
  return (b1.values>b2.values);
}


int main(){

  int n,w;
  cin>>n>>w;
  
  b arr[n];
  for(int i=0; i<n; i++){
   int wi;
    long long int vi;
    cin>>wi>>vi;
    arr[i]->weights=wi;
    arr[i]->values=vi;
  }
  
  sort(arr,arr+n,comm());
  long long int V=0;
  for(int i=0; i<n; i++){
    if(w-arr[i]->weights>=0){
     V=v+arr[i]->values;
      w=w-arr[i]->weights;
    }
  }
  return V;
}





Compiler output:
a.cc:9:2: error: expected ';' after class definition
    9 | }
      |  ^
      |  ;
a.cc: In function 'bool comm(b, b)':
a.cc:12:14: error: 'long long int b::values' is private within this context
   12 |   return (b1.values>b2.values);
      |              ^~~~~~
a.cc:7:17: note: declared private here
    7 |   long long int values;
      |                 ^~~~~~
a.cc:12:24: error: 'long long int b::values' is private within this context
   12 |   return (b1.values>b2.values);
      |                        ^~~~~~
a.cc:7:17: note: declared private here
    7 |   long long int values;
      |                 ^~~~~~
a.cc: In function 'int main()':
a.cc:26:11: error: base operand of '->' has non-pointer type 'b'
   26 |     arr[i]->weights=wi;
      |           ^~
a.cc:27:11: error: base operand of '->' has non-pointer type 'b'
   27 |     arr[i]->values=vi;
      |           ^~
a.cc:30:22: error: too few arguments to function 'bool comm(b, b)'
   30 |   sort(arr,arr+n,comm());
      |                  ~~~~^~
a.cc:10:6: note: declared here
   10 | bool comm(b b1, b b2)
      |      ^~~~
a.cc:33:16: error: base operand of '->' has non-pointer type 'b'
   33 |     if(w-arr[i]->weights>=0){
      |                ^~
a.cc:34:8: error: 'v' was not declared in this scope
   34 |      V=v+arr[i]->values;
      |        ^
a.cc:34:16: error: base operand of '->' has non-pointer type 'b'
   34 |      V=v+arr[i]->values;
      |                ^~
a.cc:35:17: error: base operand of '->' has non-pointer type 'b'
   35 |       w=w-arr[i]->weights;
      |                 ^~
Language: Java


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

public class Trash {

	static int c;
	static int[] w;
	static int[] v;
	static long[][] dp;
	static int n;

	public static long KnapSack(int idx, int remw) {
		if (remw < 0) {
			return -(int) 1e9;
		}
		if (idx == n) {
			return 0;
		}
		if (dp[idx][remw] != -1) {
			return dp[idx][remw];
		}
		long take = v[idx] + KnapSack(idx + 1, remw - w[idx]);
		long leave = KnapSack(idx + 1, remw);
		return dp[idx][remw] = Math.max(take, leave);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		n = sc.nextInt();
		c = sc.nextInt();
		w = new int[n];
		v = new int[n];
		dp = new long[n][c+5];
		for (long[] x : dp)
			Arrays.fill(x, -1);
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		pw.println(KnapSack(0, c));
		pw.close();
	}

}

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

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

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 200005
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

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

    vector<ll> dp(w+1,0);

    for(int i=1;i<=n;i++)
    {
        int weight , value;
        cin>>weight>>value;

        for(int j=w;j>=weight;j--) { dp[j]=max(dp[j],dp[j-weight]+value); }
    }

    cout<<ans[w];

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     cout<<ans[w];
      |           ^~~
      |           abs
Language: Java

import java.io.PrintWriter;
import java.util.*;
public class main {
   
	static int c;
	static int []w;
	static int []v;
	static int [][]dp;
	static int n;
	
	public static int KnapSack(int idx,int remw) {
		if(remw<0)
			return (int) -1e9;
		if(idx==n)
			return 0;
		if(dp[idx][remw]!=-1)
			return dp[idx][remw];
		int take=v[idx]+KnapSack(idx+1,remw-w[idx]);
		int leave=KnapSack(idx+1,remw);
		return dp[idx][remw]=Math.max(take, leave);
	}
	
	public static void main(String[] args) {
    Scanner sc=new Scanner (System.in);
    PrintWriter pw=new PrintWriter(System.out);
    n=sc.nextInt();
    c=sc.nextInt();
    w=new int[n];
    v=new int[n];
    dp=new int[n][c+1];
    for(int []x:dp)
        Arrays.fill(x, -1);
    for(int i=0;i<n;i++) {
    	w[i]=sc.nextInt();
    	v[i]=sc.nextInt();
    }
    pw.println(KnapSack(0,c));
    pw.flush();
	}

}


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

#include <bits/stdc++.h>
using namespace std;
long long int dp[101][100000] ={0};
long long int solver(int *w, int *v , int n , int m,int i){
    if(m==0){
        return 0;
    }
    if(i==n){
        return 0;
    }
    long long int ans=0;
    if(dp[i][m]!=0){
        return dp[i][m];
    }
    if(m-w[i]>=0){
        if(dp[i+1][m-w[i]]!=0){
            ans=v[i]+dp[i+1][m-w[i]];
        }
        else{
            ans=v[i]+solver(w,v,n,m-w[i],i+1);
            dp[i+1][m-w[i]]=ans;
        }
        
    }
     long long int bans;
    if(dp[i+1][m]!=0){
            bans=dp[i+1][m];
        }
        else{
            bans=solver(w,v,n,m,i+1);
            dp[i+1][m]=bans;
        }

    
    return dp[i][m]=max(bans,ans);
}

int main() {
    int n,m;
    cin>>n>>m;
    long long int w[n];
    long long int v[n];
    for(int i=0; i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<solver(w,v,n,m,0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:18: error: cannot convert 'long long int*' to 'int*'
   46 |     cout<<solver(w,v,n,m,0);
      |                  ^
      |                  |
      |                  long long int*
a.cc:4:27: note:   initializing argument 1 of 'long long int solver(int*, int*, int, int, int)'
    4 | long long int solver(int *w, int *v , int n , int m,int i){
      |                      ~~~~~^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,capacity;
	cin>>n>>capacity;
	int wt[n],val[n];

	for(int i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	int dp[n+1][capacity+1]={};

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=capacity;j++)
		{
			if(wt[i-1]<=j)
				a=dp[i-1][j-wt[i-1]]+val[i-1];
			b=dp[i-1][j];
			dp[i][j]=max(a,b);
		}
	}


	cout<<dp[n][capacity];

}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:33: error: 'a' was not declared in this scope
   19 |                                 a=dp[i-1][j-wt[i-1]]+val[i-1];
      |                                 ^
a.cc:20:25: error: 'b' was not declared in this scope
   20 |                         b=dp[i-1][j];
      |                         ^
a.cc:21:38: error: 'a' was not declared in this scope
   21 |                         dp[i][j]=max(a,b);
      |                                      ^
Language: Java

import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;

public class D {

    private static final FastScanner fs = new FastScanner();

    public static void main(String[] args) {
        D ob = new D();
//        int t = fs.nextInt();
        int t = 1;
        for (int i = 1; i <= t; i++) {
            // System.out.print("Case #" + i + ": ");
            ob.solve();
        }
    }
    
    int n, w;
    int[] weights, values;
    long[][] memo;

    private void solve() {
        n = fs.nextInt();
        w = fs.nextInt();
        weights = new int[n];
        values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = fs.nextInt();
            values[i] = fs.nextInt();
        }
        memo = new long[n + 1][w + 1];
        for (int i = 0; i <= n; i++) Arrays.fill(memo[i], -1);
        for (int j = 0; j <= w; j++) memo[n][j] = 0;
        for (int i = 0; i<= n; i++) memo[i][0] = 0;
        System.out.println(dp(0, w));
    }
    
    private long dp(int i, int j) {
        if (memo[i][j] != -1) return memo[i][j];
        long val = dp(i + 1, j);
        if (weights[i] <= j) {
            val = max(val, values[i] + dp(i + 1, j - weights[i]));
        }
        memo[i][j] = val;
        return val;
    }

    private static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                } 
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] intArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] longArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

}


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

#include <iostream>

using namespace std;

int N, W;

int dp[101][10001];

int w[100];
int v[100];

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 j = 0; j < W; j++) {
      if (j+w[i] <= W) {
        dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i])
      }             
    }
  }
  
  cout << dp[N][W] << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:60: error: expected ';' before '}' token
   20 |         dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i])
      |                                                            ^
      |                                                            ;
   21 |       }
      |       ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int N, W;

int dp[101][10001];

int w[100];
int v[100];

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 j = 0; j < W; j++) {
      if (j+w[i] <= W) {
        dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i])
      }             
    }
  }
  
  cout << dp[N][W] << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:60: error: expected ';' before '}' token
   20 |         dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i])
      |                                                            ^
      |                                                            ;
   21 |       }
      |       ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
struct items{
  int wt,val;
};
ll solve(vector<items> v,int n,int W){
	int dp[n+1][W+1];
  	for(int w=0;w<=W;w++){
      dp[1][w]=0;
    }
  	dp[1][v[1].wt]=v[1].val;
    for(int i=2;i<=n;i++){
      for(int w=0;w<=W;w++){
      	dp[i][w]=dp[i-1][w];
        if(v[i].wt>w)continue;
        dp[i][w]=max(dp[i][w],v[i].val+dp[i-1][w-v[i].wt];
      }
    }
	return *max_element(dp[n],dp[n]+W+1);

}



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

	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(std::vector<items>, int, int)':
a.cc:17:58: error: expected ')' before ';' token
   17 |         dp[i][w]=max(dp[i][w],v[i].val+dp[i-1][w-v[i].wt];
      |                     ~                                    ^
      |                                                          )
Language: C++

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

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

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int N;
  ll W;
  cin >> N >> W;
  //vector<ll> w(110), v(110);
  ll w(110), v(110);
  rep(i,N) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(110, vector<ll> (100100,0));
  //ll dp[110][100100]={0};
  rep(i,N){
    rep(j,W+1){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(j - w[i] < 0) continue;
      dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: invalid types 'll {aka long long int}[int]' for array subscript
   14 |   rep(i,N) cin >> w[i] >> v[i];
      |                    ^
a.cc:14:28: error: invalid types 'll {aka long long int}[int]' for array subscript
   14 |   rep(i,N) cin >> w[i] >> v[i];
      |                            ^
a.cc:21:15: error: invalid types 'll {aka long long int}[int]' for array subscript
   21 |       if(j - w[i] < 0) continue;
      |               ^
a.cc:22:44: error: invalid types 'll {aka long long int}[int]' for array subscript
   22 |       dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
      |                                            ^
a.cc:22:50: error: invalid types 'll {aka long long int}[int]' for array subscript
   22 |       dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
      |                                                  ^
Language: C++

include <bits/stdc++.h> 
  using namespace std;
// 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 wgt[n],val[n]; 
   for(int i=0;i<n;i++)
   {
      cin>>wgt[i]>>val[i];  
   } 
    cout<<knapSack(w, wgt, val, n)<<endl; 
    return 0; 
} 

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:38:4: error: 'cin' was not declared in this scope
   38 |    cin>>n>>w;
      |    ^~~
a.cc:44:5: error: 'cout' was not declared in this scope
   44 |     cout<<knapSack(w, wgt, val, n)<<endl;
      |     ^~~~
a.cc:44:37: error: 'endl' was not declared in this scope
   44 |     cout<<knapSack(w, wgt, val, n)<<endl;
      |                                     ^~~~
Language: C++

#include <bits/stdc++.h> 
  using namespace std;
// 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; 
   vector<int> wgt(n),val(n); 
   for(int i=0;i<n;i++)
   {
      cin>>wgt[i]>>val[i];  
   } 
    cout<<knapSack(w, wgt, val, n)<<endl; 
    return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:44:23: error: cannot convert 'std::vector<int>' to 'int*'
   44 |     cout<<knapSack(w, wgt, val, n)<<endl;
      |                       ^~~
      |                       |
      |                       std::vector<int>
a.cc:12:25: note:   initializing argument 2 of 'int knapSack(int, int*, int*, int)'
   12 | int knapSack(int W, int wt[], int val[], int n)
      |                     ~~~~^~~~