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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[100005];
int n,w[105],ww;
ll v[105];
int main(){
	cin>>n>>ww;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<100005;i++) dp[i] = -1e18;
	dp[0] = 0;
	for(int i=1;i<=n;i++){
		for(int j=w;j<=ww;j++){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	ll ans = 0;
	for(int i=0;i<=ww;i++) ans=max(ans,dp[i]);
cout<<ans<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:27: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   30 |                 for(int j=w;j<=ww;j++){
      |                           ^
      |                           |
      |                           int*
Language: C++

#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int n, w;
ll dp[1000000][100000000000];
vector<pair<int, int>> coins(100);

ll solve(int left, ll value, vector<pair<int, int>> c) {
    if (dp[left][value] > 0) {
        return dp[left][value];
    } else {
        bool possible = false;
        ll best = 0;
        FOR(i, 0, c.size()) {
            if (left - c[i].first >= 0) {
                possible = true;
                vector<pair<int, int>> cp = c;
                cp.erase(cp.begin() + i);
                best = max(best,
                           solve(left - c[i].first, value + c[i].second, cp));
            }
        }
        if (!possible) {
            return dp[left][value] = value;
        }
        return dp[left][value] = best;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> w;
    FOR(i, 0, n) { cin >> coins[i].first >> coins[i].second; }
    cout << solve(w, 0, coins) << '\n';
    return 0;
}

Compiler output:
/tmp/ccXCcfKU.o: in function `main':
a.cc:(.text+0x35e): relocation truncated to fit: R_X86_64_PC32 against symbol `coins' defined in .bss section in /tmp/ccXCcfKU.o
a.cc:(.text+0x38a): relocation truncated to fit: R_X86_64_PC32 against symbol `coins' defined in .bss section in /tmp/ccXCcfKU.o
a.cc:(.text+0x3bb): relocation truncated to fit: R_X86_64_PC32 against symbol `coins' defined in .bss section in /tmp/ccXCcfKU.o
/tmp/ccXCcfKU.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x454): relocation truncated to fit: R_X86_64_PC32 against symbol `coins' defined in .bss section in /tmp/ccXCcfKU.o
a.cc:(.text+0x47a): relocation truncated to fit: R_X86_64_PC32 against symbol `coins' defined in .bss section in /tmp/ccXCcfKU.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

short dp [105] [1000000005], w [105], val[105]; 

int f (short pos,short x) {
	if (pos == -1) return 0;
	//cout << pos << " " << x << " " << dp [pos] [x] << endl;
	if (dp [pos] [x]) return dp [pos] [x];
	if (x - w [pos] < 0) {
		dp [pos] [x] = f  (pos - 1, x);
		return dp [pos] [x];
	}
	dp [pos] [x] = max (f (pos - 1, x), f (pos - 1,x - w [pos]) + val [pos]);
	return dp [pos] [x];
}

int main  () {
	short W,n,i;
	cin >> n >> W;
	for  (i = 0; i < n; i++) {
		cin >> w [i] >> val [i];
	}
	short a = f (n-1,W);
	cout << a;
	return 0;
}



Compiler output:
/tmp/ccdu13GJ.o: in function `f(short, short)':
a.cc:(.text+0x8d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccdu13GJ.o
a.cc:(.text+0x117): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccdu13GJ.o
a.cc:(.text+0x143): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccdu13GJ.o
/tmp/ccdu13GJ.o: in function `main':
a.cc:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccdu13GJ.o
a.cc:(.text+0x23d): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/ccdu13GJ.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fi   first
#define se   second
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)

const int N = 105, maxW = 1e5 + 5;
ll dp[N][maxW], v[N];
int w[N], W, n;

void input() {
	scanf("%d %d", &n, &W);
	FOR(i, 1, n) {
		scanf("%d %I64d", &w[i], &v[i]);
	}
}

void solve() {
	ll res = 0;
	FOR(i, 1, n) {
		FOR(j, 0, W) {
			dp[i][j] = dp[i - 1][j];
			if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}
	printf("%I64d\n", dp[i][W]);
}

int main(int argc, char const *argv[])
{

	input();
	solve();

	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:58:30: error: 'i' was not declared in this scope
   58 |         printf("%I64d\n", dp[i][W]);
      |                              ^
Language: C++

#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define MAXN 101
int n,w;
ll dp[100001];
int main() {
  cin>>n>>w;
  for(int i = 0,a,v; i < n; i++){
    cin>>a>>v;
    for(int j = w; j >= a; j--){
      dp[j] = max(dp[j], dp[j-a] + v);
    }
  }
  cout<<dp[w];
}

Compiler output:
a.cc:6:1: error: 'll' does not name a type
    6 | ll dp[100001];
      | ^~
a.cc: In function 'int main()':
a.cc:12:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |       dp[j] = max(dp[j], dp[j-a] + v);
      |       ^~
      |       dup
a.cc:15:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |   cout<<dp[w];
      |         ^~
      |         dup
Language: Java

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

Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:1: error: class, interface, enum, or record expected
#include <iostream>
         ^
Main.java:6: error: not a statement
	cin >> n >> W;
	         ^
Main.java:7: error: not a statement
	int v[n+1];
	       ^
Main.java:8: error: not a statement
	int w[n+1];
	       ^
Main.java:9: error: not a statement
	for(int i = 1 ; i <= n ; i++) cin >> w[i] >> v[i];
	                                          ^
Main.java:10: error: not a statement
	long long int dp[n+1][W+1];
	^
Main.java:10: error: not a statement
	long long int dp[n+1][W+1];
	     ^
Main.java:10: error: not a statement
	long long int dp[n+1][W+1];
	                  ^
Main.java:10: error: not a statement
	long long int dp[n+1][W+1];
	                       ^
Main.java:20: error: not a statement
	cout << (dp[n][W]);
	     ^
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
int main() 
^
  (use --enable-preview to enable unnamed classes)
Main.java:7: error: ']' expected
	int v[n+1];
	      ^
Main.java:7: error: ';' expected
	int v[n+1];
	         ^
Main.java:8: error: ']' expected
	int w[n+1];
	      ^
Main.java:8: error: ';' expected
	int w[n+1];
	         ^
Main.java:10: error: ';' expected
	long long int dp[n+1][W+1];
	    ^
Main.java:10: error: ';' expected
	long long int dp[n+1][W+1];
	         ^
Main.java:10: error: ']' expected
	long long int dp[n+1][W+1];
	                 ^
Main.java:10: error: ';' expected
	long long int dp[n+1][W+1];
	                    ^
Main.java:10: error: ';' expected
	long long int dp[n+1][W+1];
	                         ^
21 errors
Language: C++

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

long long dp[105][100005];
//map <long long,long long> cek[105];
long long weight[105];
long long value[105];
long long z,x;

long long rekur(int a,long long s)
{
	if(a>z)return 0;
	if(dp[a][s]!=-1)return dp[a][s];
//	cek[a][s]=1;
	long long temp;
	if(s-weight[a]>=0)
	{
		dp[a][s]=max(value[a]+rekur(a+1,s-weight[a]),rekur(a+1,s));
	}
	else dp[a][s]=rekur(a+1,s);
//	asd[a][s]=temp;
	return dp[a][s]
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin>>z>>x;
	for(int q=1;q<=z;q++)
	{
		cin>>weight[q]>>value[q];
	}
	long long ans=rekur(1,x);
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'long long int rekur(int, long long int)':
a.cc:22:24: error: expected ';' before '}' token
   22 |         return dp[a][s]
      |                        ^
      |                        ;
   23 | }
      | ~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 10000007;

ll n,w, cost[100000], weight[100000],memo[100001][101],ans=-1;

ll dp(int weight,int num);
int main() {
	fill(memo[0], memo[100001], -1);
	cin >> n>>w;
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> cost[i];
	}
	for (int i = 0; i < 101; i++) {
		memo[0][i] = 0;
	}
	for (int i = 0; i < 100001; i++) {
		memo[i][0] = 0;
	}
	for (int i = 0; i <= w; i++) {
		ans = max(ans, dp(i, n));
	}
	cout << ans << endl;
}
ll dp(int w,int num) {
	if (w < 0)return LLONG_MIN;
	if (memo[w][num] == -1) {
		memo[w][num] = max(dp(w,num - 1), dp(w - weight[num - 1],num - 1) + cost[num - 1]);
	}
	return memo[w][num];
}


Compiler output:
a.cc: In function 'll dp(int, int)':
a.cc:40:26: error: 'LLONG_MIN' was not declared in this scope
   40 |         if (w < 0)return LLONG_MIN;
      |                          ^~~~~~~~~
a.cc:15:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include<functional>
  +++ |+#include <climits>
   15 | using namespace std;
Language: C++

#include <bits/stdc++.h>


using namespace std;
const long long inf=LONG_MIN;
vector <int> v1 , v2;
vector <long long> v;

int main(){
	long long maxi=0;
	int N , W , w , v;
	cin>>N>>W;
	v.push_back(0);
	for (int i=1;i<W+1;i++)
		v.push_back(inf);
	
	for (int i=0;i<N;i++){
		cin>>w>>v;
		v[w]=v;
		v1.push_back(w);
		v2.push_back(v);
	}
	
	for (int i=0;i<N;i++)
		for (int j=W-1;j>=0;j--)
			if (j+v1[i]<W)
				v[j+v1[i]]=v[j]+v2[i];
	
	for (int i=W;i>=0;i--)
		if (v[j]>maxi)
			maxi=v[j];
			
	cout<<maxi;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   13 |         v.push_back(0);
      |           ^~~~~~~~~
a.cc:15:19: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   15 |                 v.push_back(inf);
      |                   ^~~~~~~~~
a.cc:19:18: error: invalid types 'int[int]' for array subscript
   19 |                 v[w]=v;
      |                  ^
a.cc:27:34: error: invalid types 'int[int]' for array subscript
   27 |                                 v[j+v1[i]]=v[j]+v2[i];
      |                                  ^
a.cc:27:45: error: invalid types 'int[int]' for array subscript
   27 |                                 v[j+v1[i]]=v[j]+v2[i];
      |                                             ^
a.cc:30:23: error: 'j' was not declared in this scope
   30 |                 if (v[j]>maxi)
      |                       ^
Language: C++

#include <bits/stdc++.h>
#include <vector>

using namespace std;
const long long inf=LONG_MIN;
vector <int> v1 , v2;
vector <long long> v;

int main(){
	long long maxi=0;
	int N , W , w , v;
	cin>>N>>W;
	v.push_back(0);
	for (int i=1;i<W+1;i++)
		v.push_back(inf);
	
	for (int i=0;i<N;i++){
		cin>>w>>v;
		v[w]=v;
		v1.push_back(w);
		v2.push_back(v);
	}
	
	for (int i=0;i<N;i++)
		for (int j=W-1;j>=0;j--)
			if (j+v1[i]<W)
				v[j+v1[i]]=v[j]+v2[i];
	
	for (int i=W;i>=0;i--)
		if (v[j]>maxi)
			maxi=v[j];
			
	cout<<maxi;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   13 |         v.push_back(0);
      |           ^~~~~~~~~
a.cc:15:19: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   15 |                 v.push_back(inf);
      |                   ^~~~~~~~~
a.cc:19:18: error: invalid types 'int[int]' for array subscript
   19 |                 v[w]=v;
      |                  ^
a.cc:27:34: error: invalid types 'int[int]' for array subscript
   27 |                                 v[j+v1[i]]=v[j]+v2[i];
      |                                  ^
a.cc:27:45: error: invalid types 'int[int]' for array subscript
   27 |                                 v[j+v1[i]]=v[j]+v2[i];
      |                                             ^
a.cc:30:23: error: 'j' was not declared in this scope
   30 |                 if (v[j]>maxi)
      |                       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,W;
  cin>>N>>W;
  ll w[N],v[N];
  for(int i=0;i<N;i++) cin>>w[i]>>v[i];
  vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j>=w[i-1]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[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:12:69: error: expected ')' before ';' token
   12 |       if(j>=w[i-1]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1];
      |                                 ~                                   ^
      |                                                                     )
Language: C++

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

using namespace std;
using namespace __gnu_pbds;

#define DIM 107
#define DIMM 100007
#define INF 1000000009.0
#define X 500007
#define epc 0.0000001
#define pi 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

typedef tree<
I,
null_type,
less<I>,
rb_tree_tag,
tree_order_statistics_node_update> mset;

ll n,W,w[DIM],v[DIM],d[DIM][DIMM],maxv;

int main()
{
    //freopen("suffarray.in", "r", stdin);
    //freopen("suffarray.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //ll x1,y1,xs,ys,y1,y2,x3,x4,y3,y4;

    cin>>n>>W;
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];

    for(int j=1;j<=w;j++)d[0][j]=(-INF);

    for(int i=1;i<=n;i++){
     for(int j=0;j<=W;j++){
      d[i][j]=d[i-1][j];
      if(j>=w[i] && d[i-1][j-w[i]]!=(-INF))d[i][j]=max(d[i-1][j-w[i]]+v[i],d[i][j]);
     }
    }
    for(int j=0;j<=W;j++)maxv=max(maxv,d[n][j]);
    cout<<maxv<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   60 |     for(int j=1;j<=w;j++)d[0][j]=(-INF);
      |                 ~^~~
Language: C++

/*Rajeev Ranjan
  CSE @MNNIT */

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define S second
#define F first
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long int ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N = 1e5 + 5;

ll dp[105][N];
ll w[105],v[105];

ll fun(ll i,ll wt)
{
    if(i<0)
        return 0;

    if(dp[i][wt]!=-1)
        return dp[i][wt];

    if(w[i]>wt)6 15
6 5
5 6
6 4
6 6
3 5
7 2
        dp[i][wt] = fun(i-1,wt);
    else
        dp[i][wt] = max(fun(i-1,wt) , v[i]+fun(i-1,wt-w[i]));
    return dp[i][wt];
}

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

    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];

    memset(dp,-1,sizeof(dp));

    cout<<fun(n-1,wt)<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'll fun(ll, ll)':
a.cc:34:17: error: expected ';' before numeric constant
   34 |     if(w[i]>wt)6 15
      |                 ^~~
      |                 ;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N = 1000; // nの最大値
const int MAX_W = 5000; // Wの最大値

// 入力
int n, W;
int w[MAX_N], v[MAX_N];

// DPテーブル
// dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。
int dp[MAX_N + 1][MAX_W + 1];

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

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;

// 入力
int n, W;
int w[MAX_N], v[MAX_N];

// DPテーブル
// dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。
int dp[MAX_N + 1][MAX_W + 1];

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

Compiler output:
a.cc:9:7: error: 'MAX_N' was not declared in this scope
    9 | int w[MAX_N], v[MAX_N];
      |       ^~~~~
a.cc:9:17: error: 'MAX_N' was not declared in this scope
    9 | int w[MAX_N], v[MAX_N];
      |                 ^~~~~
a.cc:13:8: error: 'MAX_N' was not declared in this scope
   13 | int dp[MAX_N + 1][MAX_W + 1];
      |        ^~~~~
a.cc:13:19: error: 'MAX_W' was not declared in this scope
   13 | int dp[MAX_N + 1][MAX_W + 1];
      |                   ^~~~~
a.cc: In function 'void solve_dp2()':
a.cc:17:5: error: 'dp' was not declared in this scope
   17 |     dp[n][j] = 0;
      |     ^~
a.cc:21:15: error: 'w' was not declared in this scope
   21 |       if (j < w[i])
      |               ^
a.cc:22:9: error: 'dp' was not declared in this scope
   22 |         dp[i][j] = dp[i + 1][j];
      |         ^~
a.cc:24:9: error: 'dp' was not declared in this scope
   24 |         dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      |         ^~
a.cc:24:60: error: 'v' was not declared in this scope
   24 |         dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      |                                                            ^
a.cc:27:11: error: 'dp' was not declared in this scope
   27 |   cout << dp[0][W] << endl;
      |           ^~
Language: C++

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

int n,W;
int weight[110],value[110];

int dp[110][100010];

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


Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: 'weught' was not declared in this scope; did you mean 'weight'?
   19 |    if(w >= weught[i]) dp[i + 1][w] = max(dp[i][w - weight[i]],dp[i][w]);
      |            ^~~~~~
      |            weight
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
unsigned long long n, W;
unsigned long long weight[110], value[110];
unsigned long long dp[110][10010];
 
int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >>weight[i]>>value[i];
 
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;
 
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      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];
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:6: error: expected '}' at end of input
   18 |     }
      |      ^
a.cc:14:31: note: to match this '{'
   14 |   for (int i = 0; i < n; ++i) {
      |                               ^
a.cc:18:6: error: expected '}' at end of input
   18 |     }
      |      ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll dp[110][100010];

int main() {
    ll N, W;
    cin >> N >> W;
    ll w[N], v[N];
    REP(i, 0, N) {
        cin >> w[i] >> v[i];
    }
    REP(i, 0, 110) {
        fill(dp[i], dp[i] + 100010, -1);
    }
    dp[0][0] = 0;
    REP(i, 0, N) {
        REP(j, 0, W) {
            if (dp[i][j] >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            }
            if (dp[i][j] >= 0 && j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    // }
    // REP(i, 0, N + 1) {
    //     REP(j, 0, W + 1) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll ans = 0;
    REP(i, 0, W + 1) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}


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

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N, W;
    std::cin >> N >> W;
    std::vector<int> ws(N);
    std::vector<bint> vs(N);
    for (int i = 0; i < N; i++) {
        std::cin >> ws.at(i) >> vs.at(i);
    }
    std::vector<std::vector<bint>> dp(N + 1, std::vector<bint>(W + 1, 0));
    for (int i = 1; i < N + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            if (j >= ws.at(i - 1)) {
                dp.at(i).at(j) = boost::multiprecision::max(
                        dp.at(i - 1).at(j),
                        dp.at(i - 1).at(j - ws.at(i - 1)) + vs.at(i - 1));
            } else {
                dp.at(i).at(j) = dp.at(i - 1).at(j);
            }
        }
    }
    std::cout << *std::max_element(dp.at(N).begin(), dp.at(N).end()) << std::endl;
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back

typedef long long     ll;

//-*-*-*-*-*-*-*-*-

ll n,k;

ll arr[1000][2];
ll sol(ll i,ll v,ll kn){
if(i==n){
    return v;
}
if(kn+arr[i][1]>k){
    sol(i+1,v,kn);
}else{
return max(sol(i+1,v,kn),sol(i+1,v+arr[i][0],kn+arr[i][1]));
}

}
int main()
{
    cin>>n>>k;
    clr(dp,-1);
    //dp[0]=0;dp[1]=arr[1];
   for(int i=0;i<n;i++){
    cin>>arr[i][1]>>arr[i][0];
   }  
  
//am awsome
cout<<sol(0,0,0);
 

 }


Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   28 |     clr(dp,-1);
      |         ^~
a.cc:4:30: note: in definition of macro 'clr'
    4 | #define clr(i, j)     memset(i, j, sizeof(i))
      |                              ^
a.cc: In function 'll sol(ll, ll, ll)':
a.cc:24:1: warning: control reaches end of non-void function [-Wreturn-type]
   24 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long int n=100,c=100000;
long int solve(long int i,long int cap,vector<vector<long int>> &dp,vector<long int> &w,vector<long int> &v){
	if(i==n)
		return 0;
	if(dp[i][cap]!=-1)
		return dp[i][cap];
	if(cap>=w[i])
		dp[i][cap]=v[i]+solve(i+1,cap-w[i],dp,w,v);
	dp[i][cap]=max(solve(i+1,cap,dp,w,v),dp[i][cap]);
	return dp[i][cap];	
}

long int main(){
	cin>>n>>c;
	vector<long int> w(n);
	vector<long int> v(n);
	for(long int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	vector<vector<long int>> dp(n);
	vector<long int> z(c+1);
	for(long int i=0;i<c+1;i++)
		z[i]=-1;
	for(long int i=0;i<n;i++)
		dp[i]=z;
	cout<<solve(0,c,dp ,w,v);
	return 0;
}

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

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

/*int f1(vector<int> masa,int n,vector<int> cena,int m,vector<vector<int> > &dp1, int nosivost) //preko DP matrice
{
    for (int i=1;i<=n;i++)
        for (int j=1;j<=nosivost;j++)
        {
            if(masa[i-1]<=j)
                dp1[i][j]=max(dp1[i-1][j],cena[i-1]+dp1[i-1][j-masa[i-1]]);
            else
                dp1[i][j]=dp1[i-1][j]; //pogledati da li treba ova linija!
        }
    return dp1[n][nosivost];*/
}



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

Compiler output:
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

#include<bits/stdc++.h> 
using namespace std;
int max(int a, int b) { return (a > b)? a : b; } 
int knapSack(int W, int wt[], int val[], int n) 
{ 
int i, w; 
int 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() 
{ long long int val[100000];
  long long int wt[100000];
	long long int W;
	long int n;
    cin >> n;
    cin >> W;
    for(int i=0;i<n;i++){
      cin >> wt[i] >> val[i];
    }
	cout << knapSack(W, wt, val, n) << endl;; 
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:36:29: error: cannot convert 'long long int*' to 'int*'
   36 |         cout << knapSack(W, wt, val, n) << endl;;
      |                             ^~
      |                             |
      |                             long long int*
a.cc:4:25: note:   initializing argument 2 of 'int knapSack(int, int*, int*, int)'
    4 | int knapSack(int W, int wt[], int val[], int n)
      |                     ~~~~^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, i, j;
int w;
ll dp[101][100001];

int main(){
    scanf("%d %d", &n, &w);
    memset(dp, 0, sizeof dp);
    for(i=1;i<=n;++i){
        scanf("%d %d", &a, &b);
        for(j=w;j>=a;--j){
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-a]+b);
        }
    }
    printf("%lld\n", *max_element(dp[n], dp[n]+w+1));
    return 0;
}







Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: 'a' was not declared in this scope
   15 |         scanf("%d %d", &a, &b);
      |                         ^
a.cc:15:29: error: 'b' was not declared in this scope
   15 |         scanf("%d %d", &a, &b);
      |                             ^
Language: C++

N, W = map(int, input().split())
dp = [[0 for i in range(W + 1)] for j in range(N+1)]

for j in range(N):
    w, v = map(int, input().split())
    for k in range(W + 1):
        if k >= w:
            dp[j+1][k] = max(dp[j][k-w] + v, dp[j][k])
        else:
            dp[j+1][k] = dp[j][k]
ans = 0
for i in range(W + 1):
    ans = max(ans, dp[N][i])
print(dp[N][W])


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, W = map(int, input().split())
      | ^
Language: C++

#include<iostream>
#include<stdint>
using namespace std; // 575

const int MAX = 100;
const int MAX2 = 100001;
int main() {
	static int N, W, w[MAX], v[MAX];
	cin >> N >> W;
	for (int i = 0;i < N;++ i) cin >> w[i] >> v[i];
	static int64_t dp[MAX2];
	for (int i = 0;i <= W;++ i) dp[i] = 0;
	for (int i = 0;i < N;++ i) for (int j = W;j >= w[i];-- j) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
	int64_t ans = 0;
	for (int i = 0;i <= W;++ i) ans = max(ans, dp[i]);
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

ナップサック問題はO(NW)だよ
*/

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

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

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

    ll dp[N + 1][W + 1];
    fill(dp[0], dp[1], -INF);
    dp[0][0] = 0;
    for (int i = 1; i <= N; ++i) {
        memcpy(dp[i], dp[i - 1], sizeof(dp[i]));
        int w;
        ll v;
        cin >> w >> v;

        for (int ws = 0; ws + w <= W; ++ws) {
            dp[i][ws + w] = max(dp[i][ws + w], dp[i - 1][ws] + v);
        }
    }

    cout << *max_element(dp[N], dp[N + 1]) << endl;
    return 0;
}


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

#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

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

    ll dp[N + 1][W + 1];
    fill(dp[0], dp[1], -INF);
    dp[0][0] = 0;
    for (int i = 1; i <= N; ++i) {
        memcpy(dp[i], dp[i - 1], sizeof(dp[i]));
        int w;
        ll v;
        cin >> w >> v;

        for (int ws = 0; ws + w <= W; ++ws) {
            dp[i][ws + w] = max(dp[i][ws + w], dp[i - 1][ws] + v);
        }
    }

    cout << *max_element(dp[N], dp[N + 1]) << endl;
    return 0;
}


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

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,x,y,sum,pos,k,w[ohara],v[ohara],W,dp[105][ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>W;
    rep(i,n)cin>>w[i]>>v[i];
    dp[0][w[0]]=v[0];
    rrep(i,1,n){
        rep(j,W+1){
            if(j>=w[i]){
            dp[i][j]=max({dp[i-1][j-w[i]]+v[i],dp[i-1][j],dp[i][j]});
            }
            else{
                dp[i][j]=nax(dp[i-1][j],dp[i][j]);
            }
        }
    }
    Cout(dp[n-1][W]);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:26: error: 'nax' was not declared in this scope; did you mean 'nan'?
   40 |                 dp[i][j]=nax(dp[i-1][j],dp[i][j]);
      |                          ^~~
      |                          nan
Language: C++

#include<bits/stdc++.h>
#include<algorithm>
using namespace std; 
#define int long long
#define float double
#define MAX 2000000
const int  mod = 998244353;
#define LMT 100000000000
#define int long long 
#define pb push_back 
#define lp(i,n) for( i=0;i<n;i++) 
#define lop(j,n)for( j=0;j<=n;j++)
typedef pair<int,int> pii;
typedef pair<pii,pii> ppi;
#define m_p make_pair
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minheap priority_queue<int,vector<int>,greater<int>>
#define maxheap priority_queue<int>
#define kickstart  cout<<"Case #"<<cc<<": "
#define pair_pq priority_queue<pii,vector<pii>,greater<pii>>
#define ff first
#define ss second
#define pff pair<float,float>
#define piii pair<int,pii>
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = a * a;
        b >>= 1;
    }
    return res;
}
 
int fact(int a){int ans=1;
  while(a>1){ans=(ans*a)%mod;a--;}return ans;
}
int n,m,i,j,k,l,wt;
int dp[101][100001];
int dp(int pos,int wt,int w[],int v[]){
  if(pos < 0)return INT_MIN;
  if(dp[pos][wt]!=-1)return dp[pos][wt];
  int ans=max(dp(),)



}
 int32_t main(){
  fastio
 #ifndef ONLINE_JUDGE 
  freopen("input.txt", "r", stdin); 
  freopen("output.txt", "w", stdout); 
 #endif
int t=1;
while(t--){
cin>>n;
int w[n],v[n];
lp(i,n)cin>>w[i]>>v[i];
memset(dp,-1,sizeof(dp));
}
return 0;
 }

Compiler output:
a.cc:41:38: error: 'long long int dp(long long int, long long int, long long int*, long long int*)' redeclared as different kind of entity
   41 | int dp(int pos,int wt,int w[],int v[]){
      |                                      ^
a.cc:40:5: note: previous declaration 'long long int dp [101][100001]'
   40 | int dp[101][100001];
      |     ^~
a.cc: In function 'long long int dp(long long int, long long int, long long int*, long long int*)':
a.cc:44:17: error: 'dp' cannot be used as a function
   44 |   int ans=max(dp(),)
      |               ~~^~
a.cc:44:20: error: expected primary-expression before ')' token
   44 |   int ans=max(dp(),)
      |                    ^
a.cc:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
Language: C++

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

const ll N = 1e9 + 1;
vector<vector<ll>> t(N, vector<ll> (101));

ll knapsackdpTab(ll val[], ll wt[], ll w, ll n) // Tabulation
{
    for (int i = 0; i < w + 1; i++)
    {
        for (int j = 0; j < n + 1; j++)
        {
            if (i == 0 || j == 0)
                t[i][j] = 0;
        }
    }

    for (int i = 1; i < w + 1; i++)
    {
        for (int j = 1; j < n + 1; j++)
        {
            if (wt[j - 1] <= i)
                t[i][j] = max(val[j - 1] + t[i - wt[j - 1]][j - 1], t[i][j - 1]);
            else
                t[i][j] = t[i][j - 1];
        }
    }

    return t[w][n];
}

int main()
{
    memset(t, -1, sizeof(t));
    ll n, w;
    cin >> n >> w;
    ll wt[n];
    ll val[n];
    for(int i=0; i<n; i++)
        cin >> wt[i] >> val[i];


    cout << knapsackdpTab(val, wt, w, n);
}


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

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

const ll N = 1e9 + 1;
vector<vector<ll>> dp(N, vector<ll> (101));

ll knapsackdpTab(ll val[], ll wt[], ll w, ll n) // Tabulation
{
    for (int i = 0; i < w + 1; i++)
    {
        for (int j = 0; j < n + 1; j++)
        {
            if (i == 0 || j == 0)
                t[i][j] = 0;
        }
    }

    for (int i = 1; i < w + 1; i++)
    {
        for (int j = 1; j < n + 1; j++)
        {
            if (wt[j - 1] <= i)
                t[i][j] = max(val[j - 1] + t[i - wt[j - 1]][j - 1], t[i][j - 1]);
            else
                t[i][j] = t[i][j - 1];
        }
    }

    return t[w][n];
}

int main()
{
    memset(t, -1, sizeof(t));
    ll n, w;
    cin >> n >> w;
    ll wt[n];
    ll val[n];
    for(int i=0; i<n; i++)
        cin >> wt[i] >> val[i];


    cout << knapsackdpTab(val, wt, w, n);
}


Compiler output:
a.cc: In function 'long long int knapsackdpTab(long long int*, long long int*, long long int, long long int)':
a.cc:15:17: error: 't' was not declared in this scope
   15 |                 t[i][j] = 0;
      |                 ^
a.cc:24:17: error: 't' was not declared in this scope
   24 |                 t[i][j] = max(val[j - 1] + t[i - wt[j - 1]][j - 1], t[i][j - 1]);
      |                 ^
a.cc:26:17: error: 't' was not declared in this scope
   26 |                 t[i][j] = t[i][j - 1];
      |                 ^
a.cc:30:12: error: 't' was not declared in this scope; did you mean 'wt'?
   30 |     return t[w][n];
      |            ^
      |            wt
a.cc: In function 'int main()':
a.cc:35:12: error: 't' was not declared in this scope; did you mean 'tm'?
   35 |     memset(t, -1, sizeof(t));
      |            ^
      |            tm
Language: C++

#include<iostream>
#include<algorithm>
#define ll long long int

using namespace std;

ll ans[101][1000000001];
pair<ll, ll> arr[101];

int main(){
    ll n, w;
    cin >> n >> w;
    for(int i=1;i<=n;i++) cin >> arr[i].first >> arr[i].second;
    sort(arr, arr+n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(j-arr[i].first<0) ans[i][j] = ans[i-1][j];
            else{
                ans[i][j] = max(ans[i-1][j], arr[i].second + ans[i-1][j-arr[i].first]);
            }
        }
    }
    cout << ans[n][w] << endl; 
    return 0;
}

Compiler output:
/tmp/cc6AppAH.o: in function `main':
a.cc:(.text+0x48): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
a.cc:(.text+0x73): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
a.cc:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
a.cc:(.text+0x168): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc6AppAH.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define mod 10000000007
#define mod2 998244353
#define pb push_back
#define ru(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define mp make_pair
#define inp(a,n) ru(i,n){cin>>a[i];}
#define sv(v) sort(v.begin(),v.end())
#define sa(a) sort(a,a+size(a)/size(a[0]))
using namespace std;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

const int mw=1e9+10;
ll dp[110][mw];

ll n,w,a[110],b[110];

ll po(ll a,ll b,ll m)
{	a%=m;
	ll res=1;
	while(b>0)
	{if(b&1)
	res=(res*a)%m;
	a=(a*a)%m;
	b>>=1;}
	return res;
}
ll inv(ll a,ll m)
{
	return po(a,m-2,m)%m;
}

ll solve(ll i,ll j)
{
	if(i>n||j==0)
	return 0;
	if(dp[i][j]!=-1)
	return dp[i][j];
	if(b[i]<=j)
	dp[i][j]=max(a[i]+solve(i+1,j-b[i]),solve(i+1,j));
	else
	dp[i][j]=solve(i+1,j);
	return dp[i][j];
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
		memset(dp,-1,sizeof(dp));
		cin>>n>>w;
		ru(i,n)
		cin>>b[i+1]>>a[i+1];
		cout<<solve(1,w);
	}
return 0;
}


Compiler output:
/tmp/ccTOEsJP.o: in function `solve(long long, long long)':
a.cc:(.text+0x12d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x1ac): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x1e8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x1ff): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTOEsJP.o
/tmp/ccTOEsJP.o: in function `main':
a.cc:(.text+0x336): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x352): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x37d): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x3ac): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x3cb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccTOEsJP.o
a.cc:(.text+0x3d7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccTOEsJP.o
collect2: error: ld returned 1 exit status
Language: C++

ll solnD(ll n,ll cap,vector<ll> &w,vector<ll> &v){
	ll dp[n][cap+1];
	for(int i=0;i<n;i++){
		for(int ws=0;ws<=cap;ws++){
			if(i==0){
				if(ws==w[i]) dp[i][ws] = v[i];
				else dp[i][ws] = 0;
				continue;
			}
			bool condn = ws>=w[i];
			if(ws==w[i]) dp[i][ws] = v[i];
			else dp[i][ws] = 0;
			ll kk = max(dp[i-1][ws],condn?(dp[i-1][ws-w[i]]+v[i]):0);
			dp[i][ws] = max(dp[i][ws],kk);
		}
	}
	return dp[n-1][cap];
}
int main(){
	ll n,cap;
	cin>>n>>cap;
	vector<ll> v(n);
	vector<ll> w(n);
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	cout<<solnD(n,cap,w,v)<<endl;
}


Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll solnD(ll n,ll cap,vector<ll> &w,vector<ll> &v){
      | ^~
a.cc: In function 'int main()':
a.cc:20:9: error: 'll' was not declared in this scope
   20 |         ll n,cap;
      |         ^~
a.cc:21:9: error: 'cin' was not declared in this scope
   21 |         cin>>n>>cap;
      |         ^~~
a.cc:21:14: error: 'n' was not declared in this scope
   21 |         cin>>n>>cap;
      |              ^
a.cc:21:17: error: 'cap' was not declared in this scope
   21 |         cin>>n>>cap;
      |                 ^~~
a.cc:22:9: error: 'vector' was not declared in this scope
   22 |         vector<ll> v(n);
      |         ^~~~~~
a.cc:22:20: error: 'v' was not declared in this scope
   22 |         vector<ll> v(n);
      |                    ^
a.cc:23:20: error: 'w' was not declared in this scope
   23 |         vector<ll> w(n);
      |                    ^
a.cc:25:9: error: 'cout' was not declared in this scope
   25 |         cout<<solnD(n,cap,w,v)<<endl;
      |         ^~~~
a.cc:25:15: error: 'solnD' was not declared in this scope
   25 |         cout<<solnD(n,cap,w,v)<<endl;
      |               ^~~~~
a.cc:25:33: error: 'endl' was not declared in this scope
   25 |         cout<<solnD(n,cap,w,v)<<endl;
      |                                 ^~~~