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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

ll n,w;

ll weight[110]={},value[110]={};

ll dp[110][10010];

int main(){
  cin >> n >> w;
  
  dp[0][0] = 0;
  
  REP(i,110){
    cin >> weight[i];   
    cin >> value[i];
  }
  
  REP(i,n){
    REP(j,w){
      
      if(dp[i][j-weight[i]] + value[i]> dp[i][j]){
        dp[i+1][j-weight] = dp[i][j-weight[i]] + value;
      }
      else{
        dp[i+1][j]=dp[i][j];
      }
      
    }
  }
  
  cout << dp[n][w] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:18: error: invalid operands of types 'll' {aka 'long long int'} and 'll [110]' {aka 'long long int [110]'} to binary 'operator-'
   33 |         dp[i+1][j-weight] = dp[i][j-weight[i]] + value;
      |                 ~^~~~~~~
      |                 | |
      |                 | ll [110] {aka long long int [110]}
      |                 ll {aka long long int}
Language: C++

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

ll n,w;

ll weight[110]={},value[110]={};

ll dp[110][10010]={};

int main(){
  cin >> n >> w;
  
  REP(i,110){
    cin >> weight[i];   
    cin >> value[i];
  }
  
  REP(i,n){
    REP(i,w){
      
      if(dp[i][w-weight[i]] + value[i]> dp[i][w]){
        dp[i+1] = dp[i][w-weight[i]] + value;
      }
      else{
        dp[i+1][w]=dp[i][w];
      }
      
    }
  }
  
  cout << dp[n][w] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: incompatible types in assignment of 'll*' {aka 'long long int*'} to 'll [10010]' {aka 'long long int [10010]'}
   31 |         dp[i+1] = dp[i][w-weight[i]] + value;
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

long long n, m, i, j, a[107][100007], w[107], c[107], z, res = -INF;

int main()
{
    cin >> n >> m;
    for(i = 1; i <= n; i ++){
        cin >> w[i];
    }
    for(i = 1; i <= n; i ++){
        cin >> c[i];
    }

    a[0][0] = 0;
    for(i = 1; i <= m; i ++)a[0][i] = -INF;

    for(i = 1; i <= n; i ++){
        for(j = 0; j <= m; j ++){
            z = a[i - 1][j];
            if(j >= w[i]){
                z = max(z, a[i - 1][j - w[i]] + c[i]);
            }
            a[i][j] = z;
        }
    }
    for(i = 0; i <= m; i++){
        if(a[n][i] > res) res = a[n][i];
    }
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc:5:65: error: 'INF' was not declared in this scope
    5 | long long n, m, i, j, a[107][100007], w[107], c[107], z, res = -INF;
      |                                                                 ^~~
a.cc: In function 'int main()':
a.cc:18:40: error: 'INF' was not declared in this scope
   18 |     for(i = 1; i <= m; i ++)a[0][i] = -INF;
      |                                        ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>

uint64_t dp[101][100001];

uint64_t knapsack1_recur(const std::vector<int> &v,
                         const std::vector<int> &w,
                         int capacity, int x) {
  if (x >= 0) {
    if (dp[x][capacity]) return dp[x][capacity];

    uint64_t a = 0;
    if (capacity >= w[x]) {
      a =
        std::max(knapsack1_recur(v, w, capacity - w[x], x - 1) + v[x],
                 knapsack1_recur(v, w, capacity, x - 1));
    }
    else {
      a = knapsack1_recur(v, w, capacity, x - 1);
    }
/*
    std::cout
      << "capacity=" << capacity
      << " x=" << x
      << " --> " << a
      << std::endl;
*/
    dp[x][capacity] = a;
    return a;
  }
  return 0;
}

int main() {
  int n, capacity;
  std::cin >> n >> capacity;
  std::vector<int> v(n), w(n);
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; ++i) {
    std::cin >> w[i] >> v[i];
  }
  std::cout
    << knapsack1_recur(v, w, capacity, n - 1)
    << std::endl;
  return 0;
}

Compiler output:
a.cc:6:1: error: 'uint64_t' does not name a type
    6 | uint64_t dp[101][100001];
      | ^~~~~~~~
a.cc:5:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    4 | #include <unordered_map>
  +++ |+#include <cstdint>
    5 | 
a.cc:8:1: error: 'uint64_t' does not name a type
    8 | uint64_t knapsack1_recur(const std::vector<int> &v,
      | ^~~~~~~~
a.cc:8:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'int main()':
a.cc:40:10: error: 'dp' was not declared in this scope
   40 |   memset(dp, 0, sizeof(dp));
      |          ^~
a.cc:40:3: error: 'memset' was not declared in this scope
   40 |   memset(dp, 0, sizeof(dp));
      |   ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <unordered_map>
  +++ |+#include <cstring>
    5 | 
a.cc:45:8: error: 'knapsack1_recur' was not declared in this scope
   45 |     << knapsack1_recur(v, w, capacity, n - 1)
      |        ^~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#define ll long long
using namespace std;
ll n, w;
ll weight[100005], value[100005];
ll dp[100005];
ll solve(ll i, ll j){
	if(j-weight[i]<0)
		return 0;
	if(i==n+1)
		return 0;
	if(dp[j] != -1)
		return dp[j];
	return dp[j] = max(value[i] + solve(i+1, j-weight[i]), solve(i+1, j));
}
int main(){
	cin>>n>>w;
	for(ll i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
	}
	memset(dp, -1, sizeof(dp));
	cout<<max(solve(1, w-weight[1]), solve(1, w));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(dp, -1, sizeof(dp));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #define ll long long
Language: C++

#include<iostream>
#define ll long long
using namespace std;
ll n, w;
ll weight[105], value[105];
ll dp[105];
ll solve(int i, int j){
	if(j-weight[i]<0)
		return 0;
	if(i==n+1)
		return 0;
	if(dp[j] != -1)
		return dp[j];
	return dp[j] = max(value[i] + solve(i+1, j-weight[i]), solve(i+1, j));
}
int main(){
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
	}
	memset(dp, -1, sizeof(dp));
	cout<<max(solve(1, w-weight[1]), solve(1, w));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(dp, -1, sizeof(dp));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #define ll long long
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: 'i' was not declared in this scope
    9 |         for(i=0;i<n;i++) cin>>a[i]>>b[i];
      |             ^
a.cc:10:13: error: 'i' was not declared in this scope
   10 |         for(i==0;i<n;i++)
      |             ^
a.cc:12:21: error: 'j' was not declared in this scope
   12 |                 for(j=0;j<w;j++)
      |                     ^
Language: C++

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

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

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

Compiler output:
a.cc:4:1: error: 'voi' does not name a type; did you mean 'void'?
    4 | voi knapsack(int W, int wt[], int val[], int n)
      | ^~~
      | void
a.cc: In function 'int main()':
a.cc:34:3: error: 'knapsack' was not declared in this scope
   34 |   knapsack(w, wt, val, n);
      |   ^~~~~~~~
Language: C++

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PL;
typedef map<long,long> ML;
typedef vector<long> VL;
#define INF (int)(1e9)
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int N,W;cin>>N>>W;
    VLL w(N+10),v(N+10);rep(i,N)cin>>w[i]>>v[i];
    vector<vector<ll>> dp(N+10,vector<ll>(W+10));
    //dp[i][sum_w]はi-1番目までの商品を使ってｗが丁度sum_wになるように選んだ時の価値の最大
    rep(i,W)dp[0][i]=-INF;
    dp[0][0]=0;//初期条件
    REP(i,N){
        rep(sum_w,W+1){
            if(sum_w>=w[i-1]){
                dp[i][sum_w]=max(dp[i][sum_w],dp[i-1][sum_w-w[i-1]]+v[i-1]);//i-1番目を使う
            }
            dp[i][sum_w]=max(dp[i-1][sum_w],dp[i][sum_w]);//i-1番目を使わない
            //printf("dp[%d][%d]=%lld\n",i,sum_w,dp[i][sum_w]);
        }
    }
    cout<<dp[N][W]<<endl;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:30:5: error: 'VLL' was not declared in this scope; did you mean 'VL'?
   30 |     VLL w(N+10),v(N+10);rep(i,N)cin>>w[i]>>v[i];
      |     ^~~
      |     VL
a.cc:30:38: error: 'w' was not declared in this scope
   30 |     VLL w(N+10),v(N+10);rep(i,N)cin>>w[i]>>v[i];
      |                                      ^
a.cc:30:44: error: 'v' was not declared in this scope
   30 |     VLL w(N+10),v(N+10);rep(i,N)cin>>w[i]>>v[i];
      |                                            ^
a.cc:37:23: error: 'w' was not declared in this scope
   37 |             if(sum_w>=w[i-1]){
      |                       ^
a.cc:38:69: error: 'v' was not declared in this scope
   38 |                 dp[i][sum_w]=max(dp[i][sum_w],dp[i-1][sum_w-w[i-1]]+v[i-1]);//i-1番目を使う
      |                                                                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endll "\n"
#define all(x) x.begin(),x.end()
#define For(i,n) for(int i=0;i<n;i++)
#define Foor(i,a,b) for(int i = a; i < b; i++)
#define speed ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
int knapsack(int w[],int v[],int n,int wt)
{
    int k[n+1][wt+1];
    loop(i,0,n+1)
    loop(j,0,wt+1)
    {
        if(i==0||j==0)k[i][j]=0;
        else if(w[i-1]<=wt)k[i][j]=max(v[i-1] + k[i-1][j-w[i-1]], k[i-1][j]);
        else k[i][j] = k[i-1][j]; 
    }
    return k[n][wt];
}
int main()
{
    speed;
    int n,wt;
    cin>>n>>wt;
    int w[n],v[n];
    loop(i,0,n)cin>>w[i]>>v[i];
    cout<<knapsack(w,v,n,wt);
}

Compiler output:
a.cc: In function 'int knapsack(int*, int*, int, int)':
a.cc:16:10: error: 'i' was not declared in this scope
   16 |     loop(i,0,n+1)
      |          ^
a.cc:16:5: error: 'loop' was not declared in this scope
   16 |     loop(i,0,n+1)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:31:10: error: 'i' was not declared in this scope
   31 |     loop(i,0,n)cin>>w[i]>>v[i];
      |          ^
a.cc:31:5: error: 'loop' was not declared in this scope
   31 |     loop(i,0,n)cin>>w[i]>>v[i];
      |     ^~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
using namespace std;

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(dp,-1,sizeof dp);
      |         ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    8 | #include <queue>
  +++ |+#include <cstring>
    9 | #include <deque>
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <stdlib.h>

using namespace std;

int main()
{
	int n,w;
	cin >> n >> w;
	vector <pair <int, int> > all(n);
	for (int i = 0; i < n; i++)
	{
		cin >> all[i].first >> all[i].second;
	}
	sort(all.begin(), all.end());
	vector < vector <int> > dp(n + 1, vector <int> (w + 1, 0));
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= w; j++)
		{
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else
			{
				if (j >= all[i - 1].first)
					dp[i][j] = max(all[i - 1].second + dp[i - 1][j - all[i -1].first], 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:18:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   18 |         sort(all.begin(), all.end());
      |         ^~~~
      |         sqrt
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,f[105][100005],w[1000],v[1000];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i];cin>>v[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(j-w[i]<0)
                f[i][j]=f[i-1][j];
            else
                f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
        }
    }
    cout<<f[n][m];
}


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

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

int main() {
    int N, W;
    cin >> N >> W;
    long long int dp[110][100100] = {0};

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

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:39: error: no matching function for call to 'max(int&, long long int&)'
   19 |     for (int i=0; i<=W; ++i) ans = max(ans, dp[N][i]);
      |                                    ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:19:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |     for (int i=0; i<=W; ++i) ans = max(ans, dp[N][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,
                 from a.cc:2:
/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:19:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |     for (int i=0; i<=W; ++i) ans = max(ans, dp[N][i]);
      |                                    ~~~^~~~~~~~~~~~~~~
Language: C++

	#define  _CRT_SECURE_NO_WARNINGS
	#include <algorithm>
	#include <iostream>
	#include <iterator>
	#include <numeric>
	#include <sstream>
	#include <fstream>
	#include <cassert>
	#include <climits>
	#include <cstdlib>
	#include <cstring>
	#include <string>
	#include <cstdio>
#include<algorithm>
	#include <vector>
	#include <math.h>
	#include <queue>
	#include<memory>
	#include <deque>
	#include <stack>
	#include <list>
	#include <map>
	#include <set>
	#include <cmath>
	#include <bitset>
	#include<list>
	#include <iomanip>
	using namespace std;
	typedef long long ll;
	int m[200005];
	void go()
	{
		m[0] = 1;
		m[1] = 1;
		for (int i = 2; i < 40000; i++)
		{
			for (int j = i * i; j < 10000; j += i)
			{
				m[j] = 1;
			}
		}
	}


	long long dp[110][100010];
	pair<ll,ll> w[(int)1e5 + 10];
	int a[600][600];
	ll x, y;
	ll solve(ll i,ll sum)
	{
		if (i == x+1)return 0;
		if (dp[i][sum] != -1)return dp[i][sum];
		if(sum+w[i].first <= y)
		return dp[i][sum]=max(w[i].second+solve(i + 1, sum + w[i].first), solve(i + 1, sum));
		else return solve(i + 1, sum);
	}
	int main()
		memset(dp, -1, sizeof dp);
		cin >> x >> y;
		for (int i = 1; i <= x; i++)cin >> w[i].first >> w[i].second;
		cout << solve(1, 0);
		return 0;
	}

Compiler output:
a.cc:58:17: error: expected initializer before 'memset'
   58 |                 memset(dp, -1, sizeof dp);
      |                 ^~~~~~
a.cc:59:17: error: 'cin' does not name a type
   59 |                 cin >> x >> y;
      |                 ^~~
a.cc:60:17: error: expected unqualified-id before 'for'
   60 |                 for (int i = 1; i <= x; i++)cin >> w[i].first >> w[i].second;
      |                 ^~~
a.cc:60:33: error: 'i' does not name a type
   60 |                 for (int i = 1; i <= x; i++)cin >> w[i].first >> w[i].second;
      |                                 ^
a.cc:60:41: error: 'i' does not name a type
   60 |                 for (int i = 1; i <= x; i++)cin >> w[i].first >> w[i].second;
      |                                         ^
a.cc:61:17: error: 'cout' does not name a type
   61 |                 cout << solve(1, 0);
      |                 ^~~~
a.cc:62:17: error: expected unqualified-id before 'return'
   62 |                 return 0;
      |                 ^~~~~~
a.cc:63:9: error: expected declaration before '}' token
   63 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll dp[110][100001];

int main(){
	int n, wmax;
	cin >> n >> wmax;
	vector<ll> w(n);
	vector<ll> v(n);
	for( int i = 0; i < n; ++i ) cin >> w[i] >> v[i];

	for( int i = 0; i <= n; ++i ){
		for( int j = 0; j <= wmax; ++j ){
			dp[i+1][j] = dp[i][j];
			if( ( j - w[i] == 0 ) || ( j - w[i] > 0 && dp[i][j-w[i]] > 0 ) ){
				dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]] + v[i] );
			}
		}
	}
	ll ans = 0;
	for( int i = 0; i <= n; ++i ){
		for( int j = 0; j <= wmax; ++j ){
			ll = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}
// 12:46

Compiler output:
a.cc: In function 'int main()':
a.cc:28:28: error: expected unqualified-id before '=' token
   28 |                         ll = max(ans, dp[i][j]);
      |                            ^
Language: Java

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int W = sc.nextInt();
		long[] dp=new long[W+1];
		int[] w=new int[n];
		long[] v=new long[n];
		for(int i = 0; i<n; i++){
			w[i] =sc.nextInt();
			v[i] = sc.nextLong();
		}
		for(int i = 0; i<n; i++){
			for(int j=w; j>=w[i]; j--){
				dp[j]=Math.max(dp[j],dp[j-w[i]]+v[i]);
			}
		}
		System.out.println(dp[w]);
	}
}


Compiler output:
Main.java:15: error: incompatible types: int[] cannot be converted to int
			for(int j=w; j>=w[i]; j--){
			          ^
Main.java:19: error: incompatible types: int[] cannot be converted to int
		System.out.println(dp[w]);
		                      ^
2 errors
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int n,xw;
  cin>>n>>xw;
  vector<int> w(n);
  vector<long long> v(n);
  for(int i=0;i<n;i++)
    cin>>w[i]>>v[i];
  vector<vector<long long>> dp(n,vector<long long>(xw+1,0));
  for(int i=0;i<=xw;i++)
    if(i>=w[0])
      dp[0][i]=v[0];
  for(int i=1;i<n;i++)
    for(int j=0;j<=xw;j++)
      

Compiler output:
a.cc: In function 'int main()':
a.cc:19:27: error: expected statement at end of input
   19 |     for(int j=0;j<=xw;j++)
      |                           ^
a.cc:19:27: error: expected '}' at end of input
a.cc:7:1: note: to match this '{'
    7 | {
      | ^
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]; 
  }
  int mat[n+1][W+1];
  memset(mat,0,sizeof(mat));
  for(int i=1; i<=n; i++)
  {
   	for(int j=1; j<=W; j++)
    {
     	if(!i || !j)
        {
         	mat[i][j]=0; 
        }
      else if(j>w[i])
      {
       	mat[i][j]=mat[i-1][j]; 
      }
      else
      {
       	mat[i][j]=max(mat[i-1][j],v[i]+mat[i-1][j-w[i]]);
      }
    }
  }
  cout<<mat[n][w]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:15: error: invalid types 'int [(W + 1)][int [n]]' for array subscript
   34 |   cout<<mat[n][w]<<endl;
      |               ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: incompatible types in assignment of 'const int' to 'int [(W + 1)]'
   19 |       v[i] = max(v[i-1][j], v[i-1][j-w[i]]+p[i]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n,w;
  cin>>n>>w;
  pair<int,int> p[n];
  for(int i=0; i<n; i++)
  {
   	int w,v;
    cin>>w>>v;
    p[i].first=w;
    p[i].second=v;
  }
  int mat[n+1][w+1];
  memset(mat,0,sizeof(mat));
  for(int i=1; i<=n; i++)
  {
   	for(int j=1; j<=w; j++)
    {
      	if(!i || !j)
        {
         	dp[i][j]=0; 
        }
      else if(p[i].first>j)
      {
       	dp[i][j]=dp[i-1][j]; 
      }
      else
      {
       	dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i].first]+p[i].second); 
      }
          
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'dp' was not declared in this scope; did you mean 'p'?
   25 |                 dp[i][j]=0;
      |                 ^~
      |                 p
a.cc:29:9: error: 'dp' was not declared in this scope; did you mean 'p'?
   29 |         dp[i][j]=dp[i-1][j];
      |         ^~
      |         p
a.cc:33:9: error: 'dp' was not declared in this scope; did you mean 'p'?
   33 |         dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i].first]+p[i].second);
      |         ^~
      |         p
a.cc:38:9: error: 'dp' was not declared in this scope; did you mean 'p'?
   38 |   cout<<dp[n][w]<<endl;
      |         ^~
      |         p
Language: C++

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

typedef long long ll;


const int MAX = 10000000;
ll wt[MAX], val[MAX];

ll mp[MAX][MAX];
ll Knapsack(ll N, ll C){

	if(mp[N][C] != 0){
    	return mp[N][C];
    }
	if(N == 0 || C == 0){
		return 0;
	}
	ll value_if_included  = 0;
	if(wt[N - 1] <= C){
		value_if_included  = val[N - 1] + Knapsack(N - 1, C - wt[N - 1]);
	}
	ll value_if_not_included = Knapsack(N - 1, C);

	mp[N][C] = max(value_if_included, value_if_not_included);
	return mp[{N, C}]; 
}
int main(){
	ll N, C;
	cin >>  N >> C;
	for(ll i =0; i < N; i++){
		cin >> wt[i] >> val[i];
	}
	cout << Knapsack(N, C);
	return 0;
}


Compiler output:
a.cc: In function 'll Knapsack(ll, ll)':
a.cc:26:18: error: invalid types 'll [10000000][10000000] {aka long long int [10000000][10000000]}[<brace-enclosed initializer list>]' for array subscript
   26 |         return mp[{N, C}];
      |                  ^
Language: C++

// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1e9+7
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for(ll i = x; i < n; i++)
#define rrep(i, x, n) for(ll i = x; i >= n; i--)
#define all(v) v.begin(),v.end()
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
double PI=3.14159265358979323846;
typedef long long int ll;
typedef long double ld;
typedef pair< ll, ll > pii;
typedef vector< ll > vi;
typedef vector< vi > vvi;

ll dp[105][10001005];
ll w[105];
ll v[105];

ll n, www;

ll solve(ll i = 0, ll ww = 0) {
  	if(dp[i][ww]) return dp[i][ww];
	if(ww > www) return LONG_MIN;
	if(i >= n or ww == www) return 0;
	return dp[i][ww] = max(solve(i + 1, ww), v[i] + solve(i + 1, ww + w[i]));
}

int main()
{
	boost
	cin >> n >> www;
	rep(i, 0, n) cin >> w[i] >> v[i];
	cout << solve();
}

Compiler output:
/tmp/cczD7RZf.o: in function `solve(long long, long long)':
a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `www' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `www' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0xb4): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cczD7RZf.o
/tmp/cczD7RZf.o: in function `main':
a.cc:(.text+0x19e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0x1ba): relocation truncated to fit: R_X86_64_PC32 against symbol `www' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0x20d): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cczD7RZf.o
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cczD7RZf.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,w,weight,value;
  cin>>n>>w;
  long dp[w+1]={0};
  for(int i=0;i<n;i++){
    cin>>weight>>value;
    for(int j=w;j>=weight;j--)dp[j]=min(dp[j],dp[j-value]+weight);
  }
  for(int i=w+1;i>0;i--)if(dp[i]<=w){cout<<<dp[i]<<endl;return 0;}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:44: error: expected primary-expression before '<' token
   11 |   for(int i=w+1;i>0;i--)if(dp[i]<=w){cout<<<dp[i]<<endl;return 0;}
      |                                            ^
a.cc:11:50: error: invalid operands of types 'long int' and '<unresolved overloaded function type>' to binary 'operator<<'
   11 |   for(int i=w+1;i>0;i--)if(dp[i]<=w){cout<<<dp[i]<<endl;return 0;}
      |                                             ~~~~~^~~~~~
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Knapsack1 {
	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	static int n, w;
	static int[][] wV;
	static long[][] memo;
	static final int  _INF = (int)-1e9;
	
	static long solve (int n, int w) {
		
		if (w<0) 
			return _INF;

		
		if (n<0) return 0;
		
		long x  = wV[n][1]+solve(n-1, w-wV[n][0]); 
		long y  = solve(n-1, w); 
		
		return memo[n][w] = Math.max(x, y);
		
	}

	public static void main(String[] args) throws NumberFormatException, IOException {

		n = input.nextInt();
		w = input.nextInt();

		wV = new int[n][2];

		for (int i = 0; i < n; i++) {
			wV[i][0] = input.nextInt();
			wV[i][1] = input.nextInt();
		}

		memo = new long[n + 5][(int) 1e5 + 100];

		for (int i = 0; i < memo.length; i++)
			Arrays.fill(memo[i], -1);
		
		
		System.out.println(solve (n-1,w));
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}
}


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

include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
        ll n,w;
        cin>>n>>w;
        vector<ll> we(n),v(n);
        for(int i=0;i<n;i++)cin>>we[i]>>v[i];
        vector<vector<ll> > dp(2,vector<ll>(w+1,0) );
        for(int i=0;i<n;i++){
                for(int j=0;j<=w&&j+we[i]<=w;j++){
                        dp[(i+1)%2][j+we[i] ] = max(dp[i%2][j+we[i]] ,dp[i%2][j]+v[i] ) ;
                }
                for(int j=0;j<we[i];j++)dp[(i+1)%2][j] = dp[i%2][j];
        }
        ll ans = 0;
        for(int  i=0;i<=w;i++)ans = max(ans,dp[n%2][i]);
        cout<<ans<<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:6:9: error: 'cin' was not declared in this scope
    6 |         cin>>n>>w;
      |         ^~~
a.cc:7:9: error: 'vector' was not declared in this scope
    7 |         vector<ll> we(n),v(n);
      |         ^~~~~~
a.cc:7:18: error: expected primary-expression before '>' token
    7 |         vector<ll> we(n),v(n);
      |                  ^
a.cc:7:20: error: 'we' was not declared in this scope; did you mean 'w'?
    7 |         vector<ll> we(n),v(n);
      |                    ^~
      |                    w
a.cc:7:26: error: 'v' was not declared in this scope
    7 |         vector<ll> we(n),v(n);
      |                          ^
a.cc:9:25: error: expected primary-expression before '>' token
    9 |         vector<vector<ll> > dp(2,vector<ll>(w+1,0) );
      |                         ^
a.cc:9:27: error: expected primary-expression before '>' token
    9 |         vector<vector<ll> > dp(2,vector<ll>(w+1,0) );
      |                           ^
a.cc:9:43: error: expected primary-expression before '>' token
    9 |         vector<vector<ll> > dp(2,vector<ll>(w+1,0) );
      |                                           ^
a.cc:9:29: error: 'dp' was not declared in this scope
    9 |         vector<vector<ll> > dp(2,vector<ll>(w+1,0) );
      |                             ^~
a.cc:12:49: error: 'max' was not declared in this scope
   12 |                         dp[(i+1)%2][j+we[i] ] = max(dp[i%2][j+we[i]] ,dp[i%2][j]+v[i] ) ;
      |                                                 ^~~
a.cc:17:37: error: 'max' was not declared in this scope
   17 |         for(int  i=0;i<=w;i++)ans = max(ans,dp[n%2][i]);
      |                                     ^~~
a.cc:18:9: error: 'cout' was not declared in this scope
   18 |         cout<<ans<<endl;
      |         ^~~~
a.cc:18:20: error: 'endl' was not declared in this scope
   18 |         cout<<ans<<endl;
      |                    ^~~~
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;
    scanf("%d %d",&n,&w);
    int weight[110],value[110];

    for(int i=0;i<n;i++)scanf("%d %d",weight[i],value[i]);
    
    int dp[1100][101000]={{0}};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=w:j++){
            if(w>=weight[i]) {
                dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w]);
            }
            else dp[i+1][w]=dp[i][w];
        }
    }
    
    printf("%d",dp[n][w]);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:25: error: expected ';' before ':' token
   18 |         for(int j=0;j<=w:j++){
      |                         ^
      |                         ;
Language: C++

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

const ll MAX = 1e5+3;
ll n;

struct knap
{
    ll a,b;
}val[102];

ll dp[102][MAX];

int main()
{
    ll n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    {
        cin>>val[i].a>>val[i].b;
    }
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j>=val[i].a)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-val[i].a]+val[i].b));
            }
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    cout<<dp[n][w]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:70: error: expected ';' before ')' token
   29 |                 dp[i][j]=max(dp[i-1][j],dp[i-1][j-val[i].a]+val[i].b));
      |                                                                      ^
      |                                                                      ;
Language: C++

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

int check(LL wt[],LL val[],LL n,LL W)
{
    LL res[n+1][W+1];
    for(LL i=0;i<=n;i++)
        for(LL j=0;j<=W;j++)
                res[i][j]=0;

    for(LL i=1;i<=n;i++)
    {
        for(LL j=1;j<=W;j++)
        {
            if(wt[i]>j)
                res[i][j]=res[i-1][j];
            else
                res[i][j]=max(res[i-1][j],val[i]+res[i-1][j-wt[i]]);
        }
    }
    return res[n][W];
}


int main()
{
    LL n,W;
    cin>>n>>W;
    LL val[n+1],wt[n+1];
    for(LL i=1;i<=n;i++)
        cin>>wt[i]>>val[i];

    cout<<check(wt,val,n,W);

}


Compiler output:
a.cc:4:9: error: declaration does not declare anything [-fpermissive]
    4 | typedef int32_t ;
      |         ^~~~~~~
a.cc:6:11: error: 'LL' was not declared in this scope
    6 | int check(LL wt[],LL val[],LL n,LL W)
      |           ^~
a.cc:6:19: error: 'LL' was not declared in this scope
    6 | int check(LL wt[],LL val[],LL n,LL W)
      |                   ^~
a.cc:6:28: error: 'LL' was not declared in this scope
    6 | int check(LL wt[],LL val[],LL n,LL W)
      |                            ^~
a.cc:6:33: error: 'LL' was not declared in this scope
    6 | int check(LL wt[],LL val[],LL n,LL W)
      |                                 ^~
a.cc:6:37: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | int check(LL wt[],LL val[],LL n,LL W)
      |                                     ^
a.cc: In function 'int main()':
a.cc:29:5: error: 'LL' was not declared in this scope
   29 |     LL n,W;
      |     ^~
a.cc:30:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   30 |     cin>>n>>W;
      |          ^
      |          yn
a.cc:30:13: error: 'W' was not declared in this scope
   30 |     cin>>n>>W;
      |             ^
a.cc:31:7: error: expected ';' before 'val'
   31 |     LL val[n+1],wt[n+1];
      |       ^~~~
      |       ;
a.cc:32:11: error: expected ';' before 'i'
   32 |     for(LL i=1;i<=n;i++)
      |           ^~
      |           ;
a.cc:32:16: error: 'i' was not declared in this scope
   32 |     for(LL i=1;i<=n;i++)
      |                ^
a.cc:33:14: error: 'wt' was not declared in this scope
   33 |         cin>>wt[i]>>val[i];
      |              ^~
a.cc:33:21: error: 'val' was not declared in this scope
   33 |         cin>>wt[i]>>val[i];
      |                     ^~~
a.cc:35:17: error: 'wt' was not declared in this scope
   35 |     cout<<check(wt,val,n,W);
      |                 ^~
a.cc:35:20: error: 'val' was not declared in this scope
   35 |     cout<<check(wt,val,n,W);
      |                    ^~~
a.cc:35:16: error: 'check' cannot be used as a function
   35 |     cout<<check(wt,val,n,W);
      |           ~~~~~^~~~~~~~~~~~
Language: C++

#include <iostream>

using namespace std;

int main(){
  
  int a=0,b=0;
  cin>>a>>b;
  int item[a+1][2]={0};
  for(int i=1;i<=a;i++){
    cin>>item[i][0]>>item[i][1];
  }
  long long int arr[b]={0};
  
  for(int i=1;i<=a;i++){
    for(int j=b;j>=item[i][0];j--)
      arr[j]=max(arr[j-item[i][0]]+item[i][1],arr[j]);
    
  cout<<arr[b]<<endl;
  return 0;
}

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

#include <iostream>

using namespace std;

int main(){
  
  int a=0,b=0;
  cin>>a>>b;
  int item[b+1][2]={0};
  for(int i=1;i<=b;i++){
    cin>>item[i][0]>>item[i][1];
  }
  long long int arr[a]={0};
  
  for(int i=1;i<=b;i++){
    for(int j=a;j>=item[i][0];j--)
      arr[j]=max(arr[j-item[i][0]]+item[i][1],arr[j]);
    
  cout<<arr[j]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: 'j' was not declared in this scope
   19 |   cout<<arr[j]<<endl;
      |             ^
a.cc:21:2: error: expected '}' at end of input
   21 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
#include <utility>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll n,w;
ll bag_weight[110];
ll bag_value[110];
ll sum_value[110][100100] = {0};

int main(){
	cin >> n >> w;
	vector<vector<ll> > sum_value(100,vector<ll>(n, 0));
	for (int i =0;i < n;i++) cin >> bag_weight.at(i) >> bag_value.at(i);
	
	for (int i = 0;i < n;i++){
		for (int sum_w = 0; sum_w <= w; sum_w++){
			if(sum_w - bag_weight.at(i) >= 0){
				chmax(sum_value.at(i+1).at(sum_w), sum_value.at(i).at(sum_w - bag_weight.at(i)) + bag_value.at(i));
			}
			chmax(sum_value.at(i+1).at(sum_w), sum_value.at(i).at(sum_w));
		}
	}
	cout << sum_value.at(n-1).at(w) << endl;;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:52: error: request for member 'at' in 'bag_weight', which is of non-class type 'll [110]' {aka 'long long int [110]'}
   17 |         for (int i =0;i < n;i++) cin >> bag_weight.at(i) >> bag_value.at(i);
      |                                                    ^~
a.cc:17:71: error: request for member 'at' in 'bag_value', which is of non-class type 'll [110]' {aka 'long long int [110]'}
   17 |         for (int i =0;i < n;i++) cin >> bag_weight.at(i) >> bag_value.at(i);
      |                                                                       ^~
a.cc:21:47: error: request for member 'at' in 'bag_weight', which is of non-class type 'll [110]' {aka 'long long int [110]'}
   21 |                         if(sum_w - bag_weight.at(i) >= 0){
      |                                               ^~
a.cc:22:106: error: request for member 'at' in 'bag_weight', which is of non-class type 'll [110]' {aka 'long long int [110]'}
   22 |                                 chmax(sum_value.at(i+1).at(sum_w), sum_value.at(i).at(sum_w - bag_weight.at(i)) + bag_value.at(i));
      |                                                                                                          ^~
a.cc:22:125: error: request for member 'at' in 'bag_value', which is of non-class type 'll [110]' {aka 'long long int [110]'}
   22 |                                 chmax(sum_value.at(i+1).at(sum_w), sum_value.at(i).at(sum_w - bag_weight.at(i)) + bag_value.at(i));
      |                                                                                                                             ^~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long N;
    long long W;
    long long w;
    long long v;
    cin >> N >> W;
    vector<long long> w_ls(N);
    vector<long long> v_ls(N);
    vector<vector<long long>> memo_ls(N);
    for(int i=0; i<N;i++){
        cin >> w >> v;
        w_ls[i] = w;
        v_ls[i] = v;
    }
    for(int i=0; i< W + 1; i++){
        memo_ls[0].push_back(0);
    }
    for(int i=1; i<N+1; i++){
        memo_ls[i].push_back(0);
        for(int j=1; j<W+1; j++){
            if(j >= w_ls[i]){
                memo_ls[i].push_back(max({memo_ls[i-1][j], memo_ls[i-1][j-w_ls[i]] + v_ls[i], memo_ls[i][j-1]}));
            }
            else{
                memo_ls[i].push_back(max({memo_ls[i-1][j], memo_ls[i][j-1]}));
            }
        }
    }
    cout << memo_ls[N-1][W-1] << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:25:41: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   25 |                 memo_ls[i].push_back(max({memo_ls[i-1][j], memo_ls[i-1][j-w_ls[i]] + v_ls[i], memo_ls[i][j-1]}));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/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, 1 provided
a.cc:28:41: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   28 |                 memo_ls[i].push_back(max({memo_ls[i-1][j], memo_ls[i][j-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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'i' was not declared in this scope
   18 |     cout<<a[i-1][W]<<endl;
      |             ^