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

// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

#define V_SUM_MAX 1000 
#define N_MAX 100 
#define W_MAX 10000000 

// To store the states of DP 
int dp[V_SUM_MAX + 1][N_MAX]; 
bool v[V_SUM_MAX + 1][N_MAX]; 

// Function to solve the recurrence relation 
int solveDp(int r, int i, int* w, int* val, int n) 
{ 
	// Base cases 
	if (r <= 0) 
		return 0; 
	if (i == n) 
		return W_MAX; 
	if (v[r][i]) 
		return dp[r][i]; 

	// Marking state as solved 
	v[r][i] = 1; 

	// Recurrence relation 
	dp[r][i] 
		= min(solveDp(r, i + 1, w, val, n), 
			w[i] + solveDp(r - val[i], 
							i + 1, w, val, n)); 
	return dp[r][i]; 
} 

// Function to return the maximum weight 
int maxWeight(int* w, int* val, int n, int c) 
{ 

	// Iterating through all possible values 
	// to find the the largest value that can 
	// be represented by the given weights 
	for (int i = V_SUM_MAX; i >= 0; i--) { 
		if (solveDp(i, 0, w, val, n) <= c) { 
			return i; 
		} 
	} 
	return 0; 
} 

// Driver code 
int main() 
{ 
	 int n, W;cin>>n>>W;
    int w[n], v[n];
    int sum = 0;
    for(ll i = 0;i<n;i++)cin>>w[i]>>v[i], sum += v[i];

	cout << maxWeight(w, v, n, W); 

	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:56:9: error: 'll' was not declared in this scope
   56 |     for(ll i = 0;i<n;i++)cin>>w[i]>>v[i], sum += v[i];
      |         ^~
a.cc:56:18: error: 'i' was not declared in this scope
   56 |     for(ll i = 0;i<n;i++)cin>>w[i]>>v[i], sum += v[i];
      |                  ^
Language: Java

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

        long[][] dp = new long[N+1][100_001];
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {//
            for (int j = 1; j < 100_001 ; j++) {
                dp[i][j] = (long)Integer.MAX_VALUE;
            }
        }

        for (int i = 1; i <= N ; i++) {//item
            for (int j = 1; j <=100_000 ; ++j) {// sum(v)
                if(j-v[i-1] >=0){
                    long w1 = dp[i-1][j-v[i-1]]+w[i-1];
                    long w2 = dp[i-1][j];
                    dp[i][j] = Math.min(w1,w2);
                }else{
                    dp[i][j] =  dp[i-1][j];
                }
            }
        }

        int ans = -1;
        for (int i = 0; i <=100_000; i++) {
            if(dp[N][i] <= W){
                ans = i;
            }
        }

        System.out.println(ans);
    }

}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.Scanner;

public class AtCoder {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

        long[][] dp = new long[N+1][100_001];
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {//
            for (int j = 1; j < 100_001 ; j++) {
                dp[i][j] = (long)Integer.MAX_VALUE;
            }
        }

        for (int i = 1; i <= N ; i++) {//item
            for (int j = 1; j <=10_000 ; ++j) {// sum(v)
                if(j-v[i-1] >=0){
                    long w1 = dp[i-1][j-v[i-1]]+w[i-1];
                    long w2 = dp[i-1][j];
                    dp[i][j] = Math.min(w1,w2);
                }else{
                    dp[i][j] =  dp[i-1][j];
                }
            }
        }

        int ans = -1;
        for (int i = 0; i <=10_000; i++) {
            if(dp[N][i] <= W){
                ans = i;
            }
        }

        System.out.println(ans);
    }

}


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

  1 #include <bits/stdc++.h>
  2 using namespace std;
  3 
  4 const int INF = 1e9 + 5;
  5 
  6 int main(){
  7   int n, w;
  8   cin >> n >> w;
  9   
 10   vector<int> peso(n), valor(n);
 11   for(int i=0; i < n; i++){
 12     cin >> peso[i] >> valor[i];
 13   } 
 14   int total_valor = 0;
 15   
 16   for(int x : valor){
 17     total_valor += x;
 18   }
 19   
 20   // Ahora recorrere un vector de 'total_valor' casillas, para asignar en cada casilla.. un valor de peso menor o igual a 'W'
 21   
 22   vector<int> dp(total_valor + 1, INF);
 23   dp[0] = 0;
 24   
 25   for(int item=0; item < n; item++){
 26     for(int valor_actual=total_valor-valor[item]; valor_actual >= 0; valor_actual--){
 27       dp[valor_actual+valor[item]] = min(dp[valor_actual+valor[item]], dp[valor_actual] + peso[item]);
 28     }
 29   }
 30   int ans = 0; 
 31   for(int i=0; i < total_valor + 1; i++){
 32     if(dp[i] <= w){
 33       ans = max(ans, i);
 34     }
 35   }
 36   cout << ans << endl;
 37 }         
 38   

Compiler output:
a.cc:1:5: error: stray '#' in program
    1 |   1 #include <bits/stdc++.h>
      |     ^
a.cc:1:3: error: expected unqualified-id before numeric constant
    1 |   1 #include <bits/stdc++.h>
      |   ^
a.cc:3:3: error: expected unqualified-id before numeric constant
    3 |   3
      |   ^
a.cc:5:3: error: expected unqualified-id before numeric constant
    5 |   5
      |   ^
a.cc:38:2: error: expected unqualified-id before numeric constant
   38 |  38
      |  ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <utility>
#include <map>

int n, w;
const int N = 100005;

std::pair<int, int> elem[N];
std::map<std::pair<int, int>, long long> mp;

long long Solve(long long weight, int e)
{
	if (e == n)
		return 0;
	auto iter = mp.find({ weight, e });
	if (iter != mp.end())
		return iter->second;
	long long ans = Solve(weight, e + 1);
	if (weight + elem[e].first <= w)
		ans = std::max(ans, elem[e].second + Solve(weight + elem[e].first, e + 1));
	return mp[{ weight, e }] = ans;
}

int main()
{
	scanf_s("%d %d", &n, &w);
	for (int i = 0; i < n; ++i)
		std::cin >> elem[i].first >> elem[i].second;
	printf("%lld", Solve(0, 0));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   27 |         scanf_s("%d %d", &n, &w);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<iostream>
#include<cstring>
#define ll long long
#define ld long double
using namespace std;
ll n;
ll C;
ll w[101],v[101];
ll dp[101][1000000001];
ll ans=0;
ll solve(ll x,ll W)
{

if(x==0 || W<=0)
{
return 0;	
}
if(dp[x][W]!=-1)
{
return dp[x][W];	
}

if(W-w[x]>=0)
dp[x][W]=max( v[x]+solve(x-1,W-w[x]),solve(x-1,W) );	
else
dp[x][W]= solve(x-1,W);	

return dp[x][W];
}
	

int main()
{
cin>>n>>C;
memset(dp,-1,sizeof(dp));
for(ll i=1;i<=n;i++)
{
cin>>w[i]>>v[i];	
}
ans=0;

ans=solve(n,C);
cout<<ans<<endl;
return 0;
}


Compiler output:
/tmp/ccCubPHS.o: in function `main':
a.cc:(.text+0x275): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccCubPHS.o
a.cc:(.text+0x299): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccCubPHS.o
a.cc:(.text+0x2a0): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccCubPHS.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstring>
#define ll long long
#define ld long double
using namespace std;
ll n;
ll C;
ll w[101],v[101];
ll dp[101][1000000001];
ll ans=0;
ll solve(ll x,ll W)
{

if(x==0 || W<=0)
{
return 0;	
}
if(dp[x][W]!=-1)
{
return dp[x][W];	
}

if(W-w[x]>=0)
dp[x][W]=max( v[x]+solve(x-1,W-w[x]),solve(x-1,W) );	
else
dp[x][W]= solve(x-1,W);	

return dp[x][W];
}
	

int main()
{
cin>>n>>C;
memset(dp,-1,sizeof(dp));
for(ll i=1;i<=n;i++)
{
cin>>w[i]>>v[i];	
}
ans=0;

ans=solve(n,C);
cout<<ans<<endl;
return 0;
}


Compiler output:
/tmp/cc6W6bmQ.o: in function `main':
a.cc:(.text+0x275): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc6W6bmQ.o
a.cc:(.text+0x299): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc6W6bmQ.o
a.cc:(.text+0x2a0): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc6W6bmQ.o
collect2: error: ld returned 1 exit status
Language: Java

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

public class taro {
	public static void main(String args[]) throws IOException{
		BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(kb.readLine());
		
		int n = Integer.parseInt(st.nextToken()), maxw = Integer.parseInt(st.nextToken());
		
		int[] v = new int[n];
		int[] w = new int[n];
		
		for(int i = 0; i < n; i++) {
			st = new StringTokenizer(kb.readLine());
			w[i] = Integer.parseInt(st.nextToken());
			v[i] = Integer.parseInt(st.nextToken());
		}
		System.out.println(dp(maxw, w, v));
	}
	static long dp(int maxw, int[] w, int[] v) {
		long[][] cache = new long[2][maxw+1];
		int pre = 0, cur = 1;
		
		for(int i = 1; i <= w.length; i++) {
			for(int x = 0; x <= maxw; x++) {
				if(w[i-1] > x) {
					cache[cur][x] = cache[pre][x];
				}else {
					cache[cur][x] = Math.max(cache[pre][x], cache[pre][x-w[i-1]]+v[i-1]);
				}
			}
			int temp = cur;
			cur = pre;
			pre = temp;
		}
		return cache[pre][maxw];
	}
}


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

#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll n;
const int MAXN= 101;
const int m = 100000;
ll dp[MAXN][m+1];
ll val[MAXN];
ll we[MAXN];
ll solve(int pos,ll want){
    if(pos==n){
        if(want==0)return 0;
        return 1e16;
    }

    ll &r = dp[pos][want];
    if(r!=-1)return r;
    ll a = 1e16; ll b = 1e16;
    a = solve(pos+1,want-val[pos])+we[pos];
    b = solve(pos+1,want);
    r = min(a,b);
    return r;
}
int main() {FIN;
    
    cin>>n;
    ll weight;cin>>weight;
    fill(dp,-1);
    fore(i,0,n){
       cin>>we[i]; cin>>val[i];
    }
    fore(i,0,m+1){
         if(solve(0,i)<=weight)
            ans=max(i,ans);

    }
    ll ans = 0;
    cout<<ans<<"\n";
    return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:52:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |             ans=max(i,ans);
      |             ^~~
      |             abs
Language: C++

/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int n, w;
int dp[101][N];
int a[101][2];
int rec(int pos, int v, int mx) {
    if (pos > n)
        return INT_MAX;
    if (pos == n) {
        if (v >= mx)
            return 0;
        else
            return INT_MAX;
    }
    int &ans  = dp[pos][v];
    if (ans != -1)
        return ans ;
    ans  = min(a[pos][0] + rec(pos + 1, v + a[pos][1], mx), rec(pos + 1, v, mx));
    //return ans ;
    if (ans > w)
        return INT_MAX;
    return ans ;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//pen("a.txt", "w", stdout);
#endif
    ms(dp, -1);
    cin >> n >> w;
    int jokey = 0 ;
    forr(i, n) {
        forr(j, 2) {
            cin >> a[i][j];
        }
        jokey += a[i][1];
    }
    int ans  = rec(0, 0, 91);

    int l = 0;
    int e = jokey + 1;
    int as = 0;
    while (l <= e) {
        int mid  = (l + e) / 2;
        ms(dp, -1);
        int ans  = rec(0, 0, mid);
        ans  = (ans == INT_MAX) ? -1 : ans;
        if (l == e) {
            if (ans != -1)
                as  = max(as, mid);
            break;
        }
        if (ans != -1) {
            as = max(as, mid);
            l = mid + 1;
        }
        else {
            e =  mid - 1;
        }
    }
    cout << as << "\n";
    return 0;
}

Compiler output:
a.cc:54:2: error: #endif without #if
   54 | #endif
      |  ^~~~~
Language: C++

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

int main()
{
  int n,w;
  cin>>n;
  cin>>w;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<unsigned long long> wt(n);
  vector<unsigned long long> val(n);
  int sumv=0;
  for(int i=0;i<n;i++){
    cin>>wt[i]>>val[i];
  }
  for(int x:val)
    sumv+=x;
  vector<unsigned long long> dp(sumv+1,1e18L);
  //min weight of value v
  dp[0]=0;
  //dp[1]=abs(v[1]-v[0]);
  for(int i=1;i<=n;i++)
  {
      for(int j=sumv;j>=val[i-1];j--)
      {
        if(val[i-1]<=j)
        dp[j]=min({dp[j],dp[j-val[i-1]]+wt[i-1]});
      }
  }
  unsigned long long ans=0;
  for(int i=0;i<=sumv;i++)
  {
      if(dp[i]<=w)
      ans=max(ans,i);
  }
  cout<<ans<<endl;
  return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
 
 
   vector<int> v(n);

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

}

Compiler output:
a.cc:5:18: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |    vector<int> v(n);
      |                  ^
      |                  yn
Language: C++

#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC target("avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) \
  it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

int N;
ll W;
vii a;
ll memo[105][1000000050];


int dp(int at, int w){
    if (memo[at][w] != -1) return memo[at][w];
    if (at > N - 1) return 0;
    int mx = dp(at + 1, w);
    if (w + a[at].first <= W) mx = max(mx, dp(at + 1, w + a[at].first) + a[at].second);
    //cout << a[at].first << ' ' << a[at].second << ' ' << mx << endl;
    return memo[at][w] = mx;
}

int main(){
    cin >> N >> W;
    a = vii(N);
    memset(memo, -1, sizeof(memo));
    for (int i = 0; i < N; i++) {
        cin >> a[i].first >> a[i].second;
    }
    cout << dp(0, 0);
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<int, int>]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 1e9 + 5;

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

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Compiler output:
a.cc:13:10: error: conflicting declaration 'const long long int INF'
   13 | const ll INF = 1e18L + 5;
      |          ^~~
a.cc:4:11: note: previous declaration as 'const int INF'
    4 | const int INF = 1e9 + 5;
      |           ^~~
Language: C++

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

int n,w;
int const pp=10e9+1;
int arr[102][2] ;
long long dp[102][pp];

long long solve(int idx ,int rem)
{
    if(idx>=n)
        return 0;
    long long &ret=dp[idx][rem] ;
    if(ret)
        return ret;
    if(rem-arr[idx][0]>=0)
        ret=arr[idx][1]+solve(idx+1,rem-arr[idx][0]);
    return  ret=max(solve(idx+1,rem) ,ret);
}
int main()
{
     //freopen("input.txt", "rt", stdin);
    // freopen("output.txt", "wt", stdout);
    
    cin>>n>>w;
    for (int i=0 ;i<n ;i++)
        cin>>arr[i][0]>>arr[i][1];
    printf("%lld\n",solve(0 , w));
    return 0;
}

Compiler output:
a.cc:6:18: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000001e+10' to '2147483647' [-Woverflow]
    6 | int const pp=10e9+1;
      |              ~~~~^~
a.cc:8:19: error: size of array 'dp' exceeds maximum object size '9223372036854775807'
    8 | long long dp[102][pp];
      |                   ^~
Language: C++

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

int n,w;
int const pp=10e9;
int arr[102][2] ;
long long dp[102][pp+100];

long long solve(int idx ,int rem)
{
    if(idx>=n)
        return 0;
    long long &ret=dp[idx][rem] ;
    if(ret)
        return ret;
    if(rem-arr[idx][0]>=0)
        ret=arr[idx][1]+solve(idx+1,rem-arr[idx][0]);
    return  ret=max(solve(idx+1,rem) ,ret);
}
int main()
{
     //freopen("input.txt", "rt", stdin);
    // freopen("output.txt", "wt", stdout);
    
    cin>>n>>w;
    for (int i=0 ;i<n ;i++)
        cin>>arr[i][0]>>arr[i][1];
    printf("%lld\n",solve(0 , w));
    return 0;
}

Compiler output:
a.cc:6:14: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
    6 | int const pp=10e9;
      |              ^~~~
a.cc:8:21: error: size '-2147483549' of array 'dp' is negative
    8 | long long dp[102][pp+100];
      |                   ~~^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int maxn = 200;
const int maxw = 1e9+10;
const int INF = 1e9+10;

ll dp[maxn][maxw];
int v[maxn];
int n,w;
int wt[maxn];

ll knapsack(int i,int wgt){
	if(wgt < 0)
		return -INF;
	if(i == n) 
		return 0;
	ll& pdm = dp[i][wgt];
	if(pdm != -1) return pdm;
	return pdm = max(knapsack(i+1,wgt),
		knapsack(i+1,wgt-wt[i])+v[i]);
}

void solve(){
	cin >> n >> w;
	for(int i=0;i<n;++i){
		cin >> wt[i];
		cin >> v[i];
	}
	memset(dp,-1,sizeof dp);
	cout << knapsack(0,w) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Compiler output:
/tmp/ccRkgoRz.o: in function `knapsack(int, int)':
a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0x89): relocation truncated to fit: R_X86_64_PC32 against symbol `wt' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccRkgoRz.o
/tmp/ccRkgoRz.o: in function `solve()':
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0x151): relocation truncated to fit: R_X86_64_PC32 against symbol `wt' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0x17a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRkgoRz.o
a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccRkgoRz.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;
public class Solution{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int w=s.nextInt();
    int[] weights=new int[n];
    int[] value=new int[n];
    for(int i=0;i<n;i++){
      weights[i]=s.nextInt();
      value[i]=s.nextInt();
    }
    int total=0;
    for(int i:value){
      total+=i;
    }
    long[] dp=new long[total+1];
    dp[0]=0;
    Arrays.fill(dp,w+1);
    for(int i=0;i<weights.length;i++){
      for(int j=total;j>=0;j--){
        if(j>=value[i]){
          dp[j]=Math.min(dp[j],dp[j-value[i]]+weights[i]);
        }
      }
    }
    long max=Long.MIN_VALUE;
    for(int i=0;i<=total;i++){
      if(dp[i]<=w)
      max=Math.max(i,max);
    }
      System.out.println(max);
    }
  }
  
  
        
        
    
    
  

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

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

#define MP make_pair
#define PB push_back
#define ll long long int
#define F first
#define S second
#define MAX(x,y) (x)>(y)?(x):(y)
#define MIN(x,y) (x)<(y)?(x):(y)
#define REP(i,a,n) for(i=a;i<(n);i+=1)
#define REPL(i,a,n) for(i=a;i<=(n);i+=1)
#define REPr(i,n) for(i=n-1;i>=0;i-=1)

typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int>::iterator sit;
typedef unordered_set<int>::iterator usit;
typedef multiset<int>::iterator msit;
typedef unordered_multiset<int>::iterator umsit;
typedef vector<ll>::iterator vllit;

//cin.ignore(numeric_limits<streamsize>::max(),'\n');

ll MAX3(ll x, ll y, ll z){
    ll temp = max(x,y);
    return max(temp,z);
}

const int N = 101;
const ll W = 1000000001;
ll dp[N][W];
vector<pair<ll, ll>> items;

ll n,w;

void solve(){
    int i,k,x;
    REPL(i,0,w)
        dp[0][i] = 0;
    REPL(i,0,n)
        dp[i][0] = 0;

    REPL(k,1,n){
        REPL(x,1,w){
            dp[k][x]=0;
            if(x -items[k].F >= 0)
                dp[k][x] = items[k].S + dp[k-1][x-items[k].F];
            dp[k][x] = max(dp[k][x], dp[k-1][x]);
        }
    }  
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    items.clear();
    items.shrink_to_fit();
    cin>>n>>w;
    ll a,b;
    int i;
    pair<ll,ll> p;
    p = MP(0,0);
    items.PB(p);
    REP(i,0,n){
        cin>>a>>b;
        p = MP(a,b);
        items.PB(p);
    }
    solve();
    cout<<dp[n][w]<<endl;
    return 0;
}

Compiler output:
/tmp/ccC3yqX8.o: in function `solve()':
a.cc:(.text+0x85): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0xc6): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x124): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x17e): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x275): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x28f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccC3yqX8.o
/tmp/ccC3yqX8.o: in function `main':
a.cc:(.text+0x2d2): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x2e1): relocation truncated to fit: R_X86_64_PC32 against symbol `items' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x2f0): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccC3yqX8.o
a.cc:(.text+0x30c): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
struct comp
{
	template<typename T>
	bool operator()(const T &l, const T &r) const
	{
		if (l.first == r.first)
			return l.second > r.second;

		return l.first < r.first;
	}
};
map<pair<int,int>, bool, comp>prev;
map<pair<int,int>, int, comp>val;


int c=0;

int solve(int idx, int wt)
{
    c++;
    if(idx==n)
        return 0;
    if(prev[make_pair(idx,wt)]==true)
        return val[make_pair(idx,wt)];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[make_pair(idx,wt)]=true;
    return val[make_pair(idx,wt)] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);
    //cout<<endl<<c;

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:39:8: error: reference to 'prev' is ambiguous
   39 |     if(prev[make_pair(idx,wt)]==true)
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:28:31: note:                 'std::map<std::pair<int, int>, bool, comp> prev'
   28 | map<pair<int,int>, bool, comp>prev;
      |                               ^~~~
a.cc:47:5: error: reference to 'prev' is ambiguous
   47 |     prev[make_pair(idx,wt)]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:28:31: note:                 'std::map<std::pair<int, int>, bool, comp> prev'
   28 | map<pair<int,int>, bool, comp>prev;
      |                               ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map<pair<int,int>, bool>prev;
map<pair<int,int>, int>val;

int c=0;

int solve(int idx, int wt)
{
    c++;
    if(idx==n)
        return 0;
    /*if(prev[make_pair(idx,wt)]==true)
        return val[make_pair(idx,wt)];*/
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[make_pair(idx,wt)]=true;
    return val[make_pair(idx,wt)] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);
    //cout<<endl<<c;

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:35:5: error: reference to 'prev' is ambiguous
   35 |     prev[make_pair(idx,wt)]=true;
      |     ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:25: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map<pair<int,int>, bool>prev;
      |                         ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int c=0;

int solve(int idx, int wt)
{
    c++;
    if(idx==n)
        return 0;
    if(prev[make_pair(idx,wt)]==true)
        return val[make_pair(idx,wt)];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[make_pair(idx,wt)]=true;
    return val[make_pair(idx,wt)] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);
    //cout<<endl<<c;

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:27:8: error: reference to 'prev' is ambiguous
   27 |     if(prev[make_pair(idx,wt)]==true)
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:35:5: error: reference to 'prev' is ambiguous
   35 |     prev[make_pair(idx,wt)]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
Language: C++

//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using std::map;
using std::pair;
using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int solve(int idx, int wt)
{
    if(idx==n)
        return 0;
    pair<int,int>state;
    state.first=idx;
    state.second=wt;
    if(prev[state]==true)
        return val[state];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[state]=true;
    return val[state] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:29:8: error: reference to 'prev' is ambiguous
   29 |     if(prev[state]==true)
      |        ^~~~
In file included from /usr/include/c++/14/string:47,
                 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:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   19 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:37:5: error: reference to 'prev' is ambiguous
   37 |     prev[state]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   19 | map< pair<int,int>, bool >prev;
      |                           ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using std::map;
using std::pair;
using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int solve(int idx, int wt)
{
    if(idx==n)
        return 0;
    pair<int,int>state;
    state.first=idx;
    state.second=wt;
    if(prev[state]==true)
        return val[state];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[state]=true;
    return val[state] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:29:8: error: reference to 'prev' is ambiguous
   29 |     if(prev[state]==true)
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   19 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:37:5: error: reference to 'prev' is ambiguous
   37 |     prev[state]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   19 | map< pair<int,int>, bool >prev;
      |                           ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using std::map;
using std::pair;
using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int solve(int idx, int wt)
{
    if(idx==n)
        return 0;
    if(prev[{ idx,wt }]==true)
        return val[{ idx,wt }];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[{ idx,wt }]=true;
    return val[{ idx,wt }] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:26:8: error: reference to 'prev' is ambiguous
   26 |     if(prev[{ idx,wt }]==true)
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   19 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:34:5: error: reference to 'prev' is ambiguous
   34 |     prev[{ idx,wt }]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   19 | map< pair<int,int>, bool >prev;
      |                           ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int solve(int idx, int wt)
{
    if(idx==n)
        return 0;
    if(prev[{ idx,wt }]==true)
        return val[{ idx,wt }];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[{ idx,wt }]=true;
    return val[{ idx,wt }] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:24:8: error: reference to 'prev' is ambiguous
   24 |     if(prev[{ idx,wt }]==true)
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:32:5: error: reference to 'prev' is ambiguous
   32 |     prev[{ idx,wt }]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int solve(int idx, int wt)
{
    if(idx==n)
        return 0;
    if(prev[{idx,wt}]==true)
        return val[{idx,wt}];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[{idx,wt}]=true;
    return val[{idx,wt}] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:24:8: error: reference to 'prev' is ambiguous
   24 |     if(prev[{idx,wt}]==true)
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:32:5: error: reference to 'prev' is ambiguous
   32 |     prev[{idx,wt}]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N=100500;
int OO=0x3f3f3f3f;
ll linf=1e15;

int n,W;
int *v, *w;
map< pair<int,int>, bool >prev;
map< pair<int,int>, int >val;

int solve(int idx, int wt)
{
    if(idx==n)
        return 0;
    if(prev[{idx,wt}])
        return val[{idx,wt}];
    int op1=-1,op2;
    if(wt>=w[idx])
    {
        op1=solve(idx+1,wt-w[idx])+v[idx];
    }
    op2=solve(idx+1,wt);
    prev[{idx,wt}]=true;
    return val[{idx,wt}] = max(op1,op2);
}

int main() {

    cin>>n>>W;

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

    cout<<solve(0,W);

	return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:24:8: error: reference to 'prev' is ambiguous
   24 |     if(prev[{idx,wt}])
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~
a.cc:32:5: error: reference to 'prev' is ambiguous
   32 |     prev[{idx,wt}]=true;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:17:27: note:                 'std::map<std::pair<int, int>, bool> prev'
   17 | map< pair<int,int>, bool >prev;
      |                           ^~~~