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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: 'W' was not declared in this scope
    7 |     cin>>n>>W;
      |             ^
a.cc:8:14: error: conflicting declaration 'int w [n]'
    8 |     int v[n],w[n];
      |              ^
a.cc:6:11: note: previous declaration as 'int w'
    6 |     int n,w;
      |           ^
a.cc:9:31: error: invalid types 'int[int]' for array subscript
    9 |     for(int i=0;i<n;i++)cin>>w[i]>>v[i];
      |                               ^
a.cc:11:27: error: 'a' was not declared in this scope
   11 |     for(int i=0;i<W+1;i++)a[0][i]=(i<w[0])?0:v[0];
      |                           ^
a.cc:11:39: error: invalid types 'int[int]' for array subscript
   11 |     for(int i=0;i<W+1;i++)a[0][i]=(i<w[0])?0:v[0];
      |                                       ^
a.cc:14:20: error: invalid types 'int[int]' for array subscript
   14 |              if(i<w[i])a[i][j]=a[i-1][j];
      |                    ^
a.cc:14:24: error: 'a' was not declared in this scope
   14 |              if(i<w[i])a[i][j]=a[i-1][j];
      |                        ^
a.cc:15:19: error: 'a' was not declared in this scope
   15 |              else a[i][j]=(v[i]+a[i][j-w[i]])>a[i-1][j]?(v[i]+a[i][j-w[i]]):a[i-1][j]
      |                   ^
a.cc:15:41: error: invalid types 'int[int]' for array subscript
   15 |              else a[i][j]=(v[i]+a[i][j-w[i]])>a[i-1][j]?(v[i]+a[i][j-w[i]]):a[i-1][j]
      |                                         ^
a.cc:15:71: error: invalid types 'int[int]' for array subscript
   15 |              else a[i][j]=(v[i]+a[i][j-w[i]])>a[i-1][j]?(v[i]+a[i][j-w[i]]):a[i-1][j]
      |                                                                       ^
a.cc:18:11: error: 'a' was not declared in this scope
   18 |     cout<<a[n-1][W];
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
//int dp[104][100005];
int dp[100005];
int main()
{
  int n,we,i,j;
  cin>>n>>we;
  int w[n+1],v[n+1];
  for(i=1;i<=n;i++)
  {
    cin>>w[i]>>v[i];
  }
  //2d dp
 /*for(i=1;i<=n;i++)
  {
    for(j=we;j>=w[i];j--)
    {
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
  }
  cout<<dp[n][we];*/
  //1d dp
  for(int i=1;i<=n;i++){
		for(int j=we;j>=w[i];j--){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	long long ans = 0;
	for(int i=0;i<=we;i++) ans=max(ans,dp[i]);
cout<<ans<<endl;
//	cout<<dp[we];
	
	

  return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
//int dp[104][100005];
int dp[100005];
int main()
{
  int n,we,i,j;
  cin>>n>>we;
  int w[n+1],v[n+1];
  for(i=1;i<=n;i++)
  {
    cin>>w[i]>>v[i];
  }
  //2d dp
 /*for(i=1;i<=n;i++)
  {
    for(j=we;j>=w[i];j--)
    {
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
  }
  cout<<dp[n][we];*/
  //1d dp
  for(int i=1;i<=n;i++){
		for(int j=we;j>=w[i];j--){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	ll ans = 0;
	for(int i=0;i<=we;i++) ans=max(ans,dp[i]);
cout<<ans<<endl;
//	cout<<dp[we];
	
	

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'll' was not declared in this scope
   29 |         ll ans = 0;
      |         ^~
a.cc:30:32: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |         for(int i=0;i<=we;i++) ans=max(ans,dp[i]);
      |                                ^~~
      |                                abs
a.cc:31:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 | cout<<ans<<endl;
      |       ^~~
      |       abs
Language: C

#include<stdio.h> 
  
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 

int main(){
   int wt[101],val[101];
    int  W ,n;
  cin>>n>>W;
  for(i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    printf("%d", knapSack(W, wt, val, n)); 
    return 0; 
} 

Compiler output:
main.c: In function 'main':
main.c:32:3: error: 'cin' undeclared (first use in this function)
   32 |   cin>>n>>W;
      |   ^~~
main.c:32:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:33:7: error: 'i' undeclared (first use in this function)
   33 |   for(i=0;i<n;i++)
      |       ^
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
const ll INF 1e9;

ll N.W;
int main(){
	cin >>N >>W;
  vector<ll> mem(W),w(N),v(N);
  for(int i=0;i<N;
  for(ll i=0;i<W;i++)mem[i]=0;
  for (int i=0;i<N;i++){
    for (ll j=0;W-j>=0;j++){
		if (j>=w[i])mem[j]=max(mem[j],mem[j-w[j]]+v[j]));
    }}
  cout <<mem[0]<<endl;
}

Compiler output:
a.cc:4:14: error: expected initializer before numeric constant
    4 | const ll INF 1e9;
      |              ^~~
a.cc:6:5: error: expected initializer before '.' token
    6 | ll N.W;
      |     ^
a.cc: In function 'int main()':
a.cc:8:15: error: 'N' was not declared in this scope
    8 |         cin >>N >>W;
      |               ^
a.cc:8:19: error: 'W' was not declared in this scope
    8 |         cin >>N >>W;
      |                   ^
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<ll> mem(W),w(N),v(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:9:12: error: expected primary-expression before '>' token
    9 |   vector<ll> mem(W),w(N),v(N);
      |            ^
a.cc:9:14: error: 'mem' was not declared in this scope
    9 |   vector<ll> mem(W),w(N),v(N);
      |              ^~~
a.cc:9:21: error: 'w' was not declared in this scope
    9 |   vector<ll> mem(W),w(N),v(N);
      |                     ^
a.cc:9:26: error: 'v' was not declared in this scope
    9 |   vector<ll> mem(W),w(N),v(N);
      |                          ^
a.cc:11:3: error: expected primary-expression before 'for'
   11 |   for(ll i=0;i<W;i++)mem[i]=0;
      |   ^~~
a.cc:10:19: error: expected ')' before 'for'
   10 |   for(int i=0;i<N;
      |      ~            ^
      |                   )
   11 |   for(ll i=0;i<W;i++)mem[i]=0;
      |   ~~~
Language: C++

#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;


int main(){
    int N,W;cin >> N >> W;
    vector<pair<int,int>> vec;
    for(int i = 0;i < N;i++){
        int b;cin >>b;
        int c;cin >> c;
        vec.push_back({b,c});
    }
    vector<vector<LL>> dp(N+1, vector<LL>(W+1,-LINF));
    dp.at(0).at(0)=0;
    for(int a = 1;a <= N;a++){
        for(int b = 1;b <= W;b++){
            if(b - vec.at(a-1).first >= 0){
                    dp[a][b] = max(dp[a][b-vec.at(a-1).first] + vec.at(a-1).second,dp[a][b]);
            }
            dp[a][b] = max(dp[a][b],dp[a-1][b]);
        }
    }
    /*
    for(int a = 0;a <= N;a++){
        for(int b = 0;b <= W;b++){
            cout<<dp[a][b]<<" ";
        }
        cout<<endl;
    }
    */
    cout<<*max_element(dp.back().begin(),dp.back().end())<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:48: error: 'LINF' was not declared in this scope
   15 |     vector<vector<LL>> dp(N+1, vector<LL>(W+1,-LINF));
      |                                                ^~~~
Language: C++

#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

pair<int,int> v[105];
ll dp[105][100005];
int n, w;
bool mark[105][100005];

ll f(int i, int j) {
	if(i == n) return 0;
	if(mark[i][j]) return dp[i][j];
	mark[i][j] = true;

	ll ret = f(i+1, j);
	if(j >= v[i].ff)
		ret = max(ret, f(i+1, j-v[i].ff) + v[i].ss);

	return dp[i][j] = ret;
}

int main() {
	scanf("%d%d", &n, &w);

	for(int i = 0; i < n; i++)
		scanf("%d%d", &v[i].ff, &v[i].ss);

	printf("%lld\n", f(0,w));
    
    return 0;
}

Compiler output:
a.cc:10:1: error: 'll' does not name a type
   10 | ll dp[105][100005];
      | ^~
a.cc:14:1: error: 'll' does not name a type
   14 | ll f(int i, int j) {
      | ^~
a.cc: In function 'int main()':
a.cc:32:26: error: 'f' was not declared in this scope
   32 |         printf("%lld\n", f(0,w));
      |                          ^
Language: C++

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

// recursive approach
long long func(vector<pair<int, long long>> &wv, int w, int i){
    if(w < 0)
        return LONG_LONG_MIN;
    if(w == 0 or i < 0){
        return 0;
    }

    return max(func(wv, w - wv[i].first, i-1) + wv[i].second,
                func(wv, w, i-1));
}

// dynamic programming approach
long long func(vector<pair<int, int>> &wv, int w){
    vector<vector<long long>> dp(wv.size() + 1, vector<long long>(w + 1, 0));

    for(int i = 0;i <= wv.size();i++){
        for(int wt = 0;wt <= w;wt++){
            if(i == 0 || wt == 0)
                dp[i][wt] = 0;
            else if(wv[i-1].first <= wt){
                dp[i][wt] = max(wv[i-1].second + dp[i-1][wt - wv[i-1].first], dp[i-1][wt]);
            }else{
                dp[i][wt] = dp[i-1][wt];
            }
        }
    }

    return dp[wv.size()][w];
}

int main(){
    int n, w;
    cin >> n >> w;
    vector<pair<int, long long>> wv(n);

    for(int i = 0;i < n;i++){
        cin >> wv[i].first >> wv[i].second;
    }

    cout << func(wv, w) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:17: error: no matching function for call to 'func(std::vector<std::pair<int, long long int> >&, int&)'
   44 |     cout << func(wv, w) << endl;
      |             ~~~~^~~~~~~
a.cc:17:11: note: candidate: 'long long int func(std::vector<std::pair<int, int> >&, int)'
   17 | long long func(vector<pair<int, int>> &wv, int w){
      |           ^~~~
a.cc:17:40: note:   no known conversion for argument 1 from 'std::vector<std::pair<int, long long int> >' to 'std::vector<std::pair<int, int> >&'
   17 | long long func(vector<pair<int, int>> &wv, int w){
      |                ~~~~~~~~~~~~~~~~~~~~~~~~^~
a.cc:5:11: note: candidate: 'long long int func(std::vector<std::pair<int, long long int> >&, int, int)'
    5 | long long func(vector<pair<int, long long>> &wv, int w, int i){
      |           ^~~~
a.cc:5:11: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 105;
const int maxw = 1e5+5;

int w[maxn], v[maxn];

int n, W;

int dp[maxn][maxw];

int main()
{
	scanf("%d %d", &n, &W);
	for(int i = 1; i<= n; i++) scanf("%d %d", &w[i], &v[i]);
	for(int i = 1; i<= n; i++)
	{
		for(int j = W; j>= w[i]; j--)
		{
			dp[j] = max(dp[j], dp[j-W[i]]+v[i]);
		}
	}
	printf("%d\n", dp[W]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:50: error: invalid types 'int[int]' for array subscript
   26 |                         dp[j] = max(dp[j], dp[j-W[i]]+v[i]);
      |                                                  ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class D_Knapsack1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[][] dp = new long[N + 1][W + 1];

        for (int i = 1; i <= N; i++) {
            int wi = sc.nextInt(); // Weight of the item(i)
            int vi = sc.nextInt(); // Value of the item(i)
            for (int j = 0; j <= W; j++) {
                // Get max total value of items under weight j.
                if (wi <= W && wi <= j) {
                    // Compare weight of item, previous value, and summed value
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - wi] + vi);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        System.out.println(Arrays.stream(dp[N]).max().getAsLong());
    }
}

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

/* package whatever; // don't place package name! */

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class MM {
    static N[] ns;
    static HashMap<MKey,Long> map = new HashMap<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        ns = new N[N];
        for(int i = 0 ; i < N;i++)
        {
            ns[i] = new N(sc.nextInt(),sc.nextInt());
        }
        //Arrays.sort(ns);
        System.out.println(calculate(W,0,N));

    }
    static long calculate(int w,long v,int n)
    {
        if(map.containsKey(new MKey(w,n)))
            return map.get(new MKey(w,n));

        if(w == 0 || n == 0)
            return v;

        if(w < ns[n-1].w)
            return calculate(w,v,n-1);
        else
        {
            long max= Math.max(calculate(w-ns[n-1].w,v+ns[n-1].v,n-1),calculate(w,v,n-1));
            map.put(new MKey(w,n),max);
            return max;
        }

    }
    static class MKey implements Comparable<MKey> {
        int n ,w;

        @Override
        public int compareTo(MKey o) {
            if(w == o.w)
                return 0;
            return w>o.w?1:-1;
        }


        public MKey(int n , int w)
        {
            this.n = n;
            this.w = w;
        }

        @Override
        public boolean equals(Object obj) {
            MKey k = (MKey) obj;
            return k.n == n && k.w == w;
        }

        @Override
        public int hashCode() {
            return (Integer.hashCode(n)+Integer.hashCode(w))%10000;
            //return n+w%10000;
        }
    }
    static class N implements Comparable<N>
    {
        @Override
        public int compareTo(N o) {
            if(w == o.w)
                return 0;
            return w>o.w?1:-1;
        }

        int w,v;
        public N(int w,int v)
        {
            this.w = w;
            this.v = v;
        }

    }
}


Compiler output:
Main.java:7: error: class MM is public, should be declared in a file named MM.java
public class MM {
       ^
1 error
Language: Java

import java.util.*;

public class Main
{
  static int n, w;
  static int[] W, V;
  static Long[][] memo;
  public static void main(String[] args)
  {
	Scanner in = new Scanner(System.in);
    n = in.nextInt();
    w = in.nextInt();
    W = new int[n];
    V = new int[n];
    for (int i = 0; i < n; i++)
    {
      W[i] = in.nextInt();
      V[i] = in.nextInt();
    }
    
    memo = new Long[n][w+1];
    System.out.println(dp(0, 0));    
    in.close();
  }
  
  public static long dp(int at, int free)
  {
    if (free > w)
      return -(long)1e14;
    if (at == n)
      return 0;
    if (memo[at][free] != null)
      return memo[at][free];
    
    long ans = 0;
    ans = Math.max(ans, V[at]+dp(at+1, free+W[at]));
    ans = Math.max(ans, dp(at+1, free));
    return memo[at][free] = ans;
}


Compiler output:
Main.java:39: error: reached end of file while parsing
}
 ^
1 error
Language: Java

import java.util.*;

public class Main
{
  static int n, w;
  static int[] W, V;
  static Long[][] memo;
  public static void main(String[] args)
  {
	Scanner in = new Scanner(System.in);
    n = in.nextInt();
    w = in.nextInt();
    W = new int[n];
    V = new int[n];
    for (int i = 0; i < n; i++)
    {
      W[i] = in.nextInt();
      V[i] = in.nextInt();
    }
    
    memo = new Long[n][w+1];
    System.out.println(dp(0, 0));    
    in.close();
  }
  
  public static long dp(int at, int free)
  {
    if (free > w)
      return -(long)1e14;
    if (at == n)
      return 0;
    if (memo[at][free] != null)
      return memo[at][free];
    
    long ans = 0;
    ans = Math.max(ans, V[at]+dp(at+1, free+W[at]));
    ans = Math.max(ans, dp(at+1, free));
    return memo[at][free] = ans;
}

Compiler output:
Main.java:39: error: reached end of file while parsing
}
 ^
1 error
Language: C++

def solve(n, w, items):
    # 1-origin
    dp = [[0] * (w + 1) for i in range(n + 1)]

    for i in range(1, n + 1):
        prev = i - 1
        weight, value = items[i - 1][0], items[i - 1][1]
        for j in range(1, w + 1):
            dp[i][j] = dp[prev][j]
            if j - weight >= 0:
                dp[i][j] = max(dp[i][j], dp[prev][j - weight] + value)

    return dp[n][w]


def main():
    n, w = map(int, input().split())

    items = []
    for i in range(n):
        items.append(list(map(int, input().split())))

    ans = solve(n, w, items)
    print(ans)


main()

Compiler output:
a.cc:2:8: error: "-" is not a valid filename
    2 |     # 1-origin
      |        ^
a.cc:1:1: error: 'def' does not name a type
    1 | def solve(n, w, items):
      | ^~~
Language: C

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

int main(){
    int n, c;
    cin >> n >> c;
    unsigned long w[n+1], v[n+1], dp[n+1][c+1]; //dp[item][weight]
    w[0] = 0;
    v[0] = 0;
    for(int i=1; i<n+1; i++)
	cin >> w[i] >> v[i];
    
    for(int j=0; j<c+1; j++)
	dp[0][j] = 0;
    // main
    for(int i=1; i<n+1; i++){
	for(int j=0; j<c+1; j++){
	    if(j >= w[i]){
		dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
	    }else{
		dp[i][j] = dp[i-1][j];
	    }
	}
    }
    //
    // for(int i=0; i<n+1; i++){
    // 	for(int j=0; j<c+1; j++){
    // 	    cout << dp[i][j] << " ";        
    // 	}
    // 	cout << endl;        
    // }


    cout << dp[n][c] << "\n";        
}


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

/*
ID: allengu01
TASK: 
LANG: C++
*/
#include "pch.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define INF 1000000007
long long n, w, dp[100007];
pair<long long, long long> items[100];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> w;
	for (long long i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		items[i] = { a, b };
	}

	dp[0] = 0;

	for (long long i = 0; i <= n; i++) {
		for (long long j = w; j >= 0; j--) {
			if (j-items[i].first == 0 || (j-items[i].first > 0 && dp[j-items[i].first])) {
				dp[j] = max(dp[j-items[i].first] + items[i].second, dp[j]);
			}
		}
	}

	long long ans;
	for (long long i = 0; i <= w; i++) {
		if (dp[i] != INF) {
			ans = max(ans, dp[i]);
		}
	}
	cout << ans;

	return 0;
}



Compiler output:
a.cc:6:10: fatal error: pch.h: No such file or directory
    6 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

/*
ID: allengu01
TASK: 
LANG: C++
*/
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define INF 1000000007
long long n, w, dp[100007];
pair<long long, long long> items[100];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> w;
	for (long long i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		items[i] = { a, b };		ans	-3689348814741910324	__int64

	}

	dp[0] = 0;

	for (long long i = 0; i <= n; i++) {
		for (long long j = w; j >= 0; j--) {
			if (j-items[i].first == 0 || (j-items[i].first > 0 && dp[j-items[i].first])) {
				dp[j] = max(dp[j-items[i].first] + items[i].second, dp[j]);
			}
		}
	}

	long long ans;
	for (long long i = 0; i <= w; i++) {
		if (dp[i] != INF) {
			ans = max(ans, dp[i]);
		}
	}
	cout << ans;

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:23:49: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |                 items[i] = { a, b };            ans     -3689348814741910324    __int64
      |                                                 ^~~
      |                                                 abs
Language: C++

#include <bits/stdc++.h> using namespace std; long long n, w; using ii=pair<long long, long long>; queue< ii > q; long long a, b; long long maks[102][100005]; int main(void) { cin >> n >> w; for(long long i=0;i<n;i++) { cin >> a >> b; q.push( {a, b} ); } ii r=q.front(); q.pop(); for(long long i=0;i<w;i++) { if(r.first<=i+1) { cout << ( maks[0][i]=r.second ) << ' '; } else { cout << 0 << ' '; } } cout << '\n'; for(long long i=1;i<n;i++) { r=q.front(); q.pop(); for(long long a=0;a<w;a++) { long long p1=0; if(r.first<a+1) { p1=maks[i-1][a-r.first]+r.second; } cout << (maks[i][a]=max(p1, maks[i-1][a]) ) << ' '; } cout << '\n'; } cout << maks[n-1][w-1]; return(0); }

Compiler output:
a.cc:1:26: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h> using namespace std; long long n, w; using ii=pair<long long, long long>; queue< ii > q; long long a, b; long long maks[102][100005]; int main(void) { cin >> n >> w; for(long long i=0;i<n;i++) { cin >> a >> b; q.push( {a, b} ); } ii r=q.front(); q.pop(); for(long long i=0;i<w;i++) { if(r.first<=i+1) { cout << ( maks[0][i]=r.second ) << ' '; } else { cout << 0 << ' '; } } cout << '\n'; for(long long i=1;i<n;i++) { r=q.front(); q.pop(); for(long long a=0;a<w;a++) { long long p1=0; if(r.first<a+1) { p1=maks[i-1][a-r.first]+r.second; } cout << (maks[i][a]=max(p1, maks[i-1][a]) ) << ' '; } cout << '\n'; } cout << maks[n-1][w-1]; return(0); }
      |                          ^~~~~
/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 <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N], dp[101][N];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 1, n+1) cin>>A[i]>>B[i];
    rep(i, 1, n+1) rep(j, A[i], k+1)
        dp[i][j] = max(dp[i][j], dp[i-1][j-A[i]]+B[i]);
    cout<<dp[n][k];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:31: error: 'B' was not declared in this scope
   22 |     rep(i, 1, n+1) cin>>A[i]>>B[i];
      |                               ^
a.cc:24:50: error: 'B' was not declared in this scope
   24 |         dp[i][j] = max(dp[i][j], dp[i-1][j-A[i]]+B[i]);
      |                                                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 110
#define Pair pair<int,int>
ll INF = 1e18;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
ll INF = 1e18;
int main(){
    ll N,W; cin >> N >> W;
    ll w[N],v[N];
    ll dp[105][100100] = {0};
    for(ll i = 0; i < N; i++){
        cin >> w[i] >> v[i];
        dp[i][0] = 0;
    }
    for(ll i = 1; i < N; i++){
        for(ll j = 1; j <= 100000; j++){
            if(j >= w[i]){
                dp[i][j] = min(dp[i-1][j-w[i]]+v[i] ,dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    ll ans = 0;
    for(ll i = W; i >= 0; i--){
        ans = max(ans, dp[N-1][i]);
    }
    cout << ans << endl;
}


Compiler output:
a.cc:12:4: error: redefinition of 'll INF'
   12 | ll INF = 1e18;
      |    ^~~
a.cc:9:4: note: 'll INF' previously defined here
    9 | ll INF = 1e18;
      |    ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 110
#define Pair pair<int,int>
ll INF = 1e18;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
ll INF = 1e18;
int main(){
    ll N,W; cin >> N >> W;
    ll w[N],v[N];
    ll dp[105][100100] = {0};
    for(ll i = 0; i < N; i++){
        cin >> w[i] >> v[i];]
        dp[i][0] = 0;
    }
    for(ll i = 1; i < N; i++){
        for(ll j = 1; j <= 100000; j++){
            if(j >= w[i]){
                dp[i][j] = min(dp[i-1][j-w[i]]+v[i] ,dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    ll ans = 0;
    for(ll i = W; i >= 0; i--){
        ans = max(max, dp[N-1][i]);
    }
    cout << ans << endl;
}


Compiler output:
a.cc:12:4: error: redefinition of 'll INF'
   12 | ll INF = 1e18;
      |    ^~~
a.cc:9:4: note: 'll INF' previously defined here
    9 | ll INF = 1e18;
      |    ^~~
a.cc: In function 'int main()':
a.cc:18:29: error: expected primary-expression before ']' token
   18 |         cin >> w[i] >> v[i];]
      |                             ^
a.cc:32:18: error: no matching function for call to 'max(<unresolved overloaded function type>, ll&)'
   32 |         ans = max(max, dp[N-1][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: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = long long int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const long long int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/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:32:18: note:   couldn't deduce template parameter '_Tp'
   32 |         ans = max(max, dp[N-1][i]);
      |               ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>

typedef long long int ll;

int main(){
    int N,W;
    scanf("%d%d",&N,&W);
    int w[N+1];
    int v[N+1];
    for(int i=1;i<=N;i++){
        scanf("%d%d",&w[i],&v[i]);
    }

    int used[W+1][N+1];
    for(int i=0;i<=W;i++){
        for(int j=1;j<=N;j++) used[i][j]=0;
    }
    ll dp[W+1];
    for(int i=0;i<=W;i++) dp[i]=0;
    for(int i=1;i<=W;i++){
        for(int j=1;j<=N;j++){
            if(i-w[j]>=0){
                if(dp[i-w[j]]+v[j]>dp[i] && used[i-w[j]][j]==0){
                    dp[i]=dp[i-w[j]]+v[j];
                    for(int k=1;k<=N;k++){
                        used[i][k]=used[i-w[j]][k];
                    }
                    used[i][j]=1;
                }
            }
        }
    }
    
    ll ans = 0;
    for(int i=0;i<=W;i++) {
        ans = max(nas, dp[i]);
    }
    
    printf("%lld\n", ans);
    return 0;



Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: 'nas' was not declared in this scope; did you mean 'ans'?
   37 |         ans = max(nas, dp[i]);
      |                   ^~~
      |                   ans
a.cc:37:15: error: 'max' was not declared in this scope
   37 |         ans = max(nas, dp[i]);
      |               ^~~
a.cc:41:14: error: expected '}' at end of input
   41 |     return 0;
      |              ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define f first
#define s second

ll dp[100100];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout);
	int n, w;
	cin >> n >> w;	
	int a[n], b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = w - a[i]; j >= 0; j--){
			dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
		}
	}
	int ans = 0;
	for(int i = 0; i <= w; i++){
		ans = max(ans, dp[i]);
	}	
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:33:26: error: no matching function for call to 'max(int&, ll&)'
   33 |                 ans = max(ans, dp[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:33:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   33 |                 ans = max(ans, dp[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:33:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |                 ans = max(ans, dp[i]);
      |                       ~~~^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define f first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
typedef long long ll ;
typedef long double ld ;
typedef long long int lli;

using namespace std;
//reference: geeks
ll mult(ll a,ll b, ll p=mod){	return ((a%p)*(b%p))%p;	}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll sub(ll a, ll b, ll p=mod){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
#define INF 10000000000
map<ll,ll>dp;
ll n;
ll wei[100005],p[100005];
ll rec(ll i,ll w)
{
	if(i>=n||w==0)	return 0;
	if(dp[i].find(w)!=dp[i].end())	return dp[i][w];
	
	if(wei[i]>w)
		dp[i][w]= rec(i+1,w);
	else
		dp[i][w]= max(rec(i+1,w),rec(i+1,w-wei[i])+p[i]);
	return dp[i][w];
}

int main()
{	
	ios
	ll W;
	cin>>n>>W;
	for(int i=0;i<n;i++)	cin>>wei[i]>>p[i];
	
	cout<<rec(0,W);
}



Compiler output:
a.cc: In function 'll rec(ll, ll)':
a.cc:27:18: error: request for member 'find' in 'dp.std::map<long long int, long long int>::operator[](i)', which is of non-class type 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'}
   27 |         if(dp[i].find(w)!=dp[i].end())  return dp[i][w];
      |                  ^~~~
a.cc:27:33: error: request for member 'end' in 'dp.std::map<long long int, long long int>::operator[](i)', which is of non-class type 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'}
   27 |         if(dp[i].find(w)!=dp[i].end())  return dp[i][w];
      |                                 ^~~
a.cc:27:53: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   27 |         if(dp[i].find(w)!=dp[i].end())  return dp[i][w];
      |                                                     ^
a.cc:30:22: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   30 |                 dp[i][w]= rec(i+1,w);
      |                      ^
a.cc:32:22: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   32 |                 dp[i][w]= max(rec(i+1,w),rec(i+1,w-wei[i])+p[i]);
      |                      ^
a.cc:33:21: error: invalid types 'std::map<long long int, long long int>::mapped_type {aka long long int}[ll {aka long long int}]' for array subscript
   33 |         return dp[i][w];
      |                     ^
Language: C++

#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
 
int n;
long long W, weight[110], value[110];
 
int dp[110][100100];
 
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];
    }
  }
  cout << dp[n][W] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:42: error: no matching function for call to 'max(long long int, int&)'
   19 |       if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:19:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   19 |       if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:19:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |       if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
 
int n, W;
int weight[110];
long long value[110];
 
int dp[110][100100];
 
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];
    }
  }
  cout << dp[n][W] << endl;
}

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

#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
 
int n, W;
int weight[110], value[110];
 
int dp[110][100100];
 
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] = dp[i+1][w] = max(dp[i+1][w], dp[i][w - weight[i]] + value[i])
      dp[i+1][w] = max(dp[i+1][w], dp[i][w]);
    }
  }
  cout << dp[n][W] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:100: error: expected ';' before 'dp'
   19 |       if(w >= weight[i]) dp[i+1][w] = dp[i+1][w] = max(dp[i+1][w], dp[i][w - weight[i]] + value[i])
      |                                                                                                    ^
      |                                                                                                    ;
   20 |       dp[i+1][w] = max(dp[i+1][w], dp[i][w]);
      |       ~~
Language: C++

#include <climits>
#include <algorithm>
using namespace std;
 
int n, W;
int weight[110], value[110];
 
int dp[110][100100];
 
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];
    }
  }
  cout << dp[n][W] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'cin' was not declared in this scope
   11 |   cin >> n >> W;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:22:3: error: 'cout' was not declared in this scope
   22 |   cout << dp[n][W] << endl;
      |   ^~~~
a.cc:22:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:23: error: 'endl' was not declared in this scope
   22 |   cout << dp[n][W] << endl;
      |                       ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <algorithm>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;
const int N = 101;
const int W = 100000 + 50;

LL cache[N][W];

int n, w;

LL weight[N];
LL value[N];

LL solve(int idx, int total)
{
	if (total > w)
		return INT_MIN;
	if (idx > n)
		return 0;
	LL &ans = cache[idx][total];
	if (ans != -1)
		return ans;
	ans = min (solve(idx + 1, total), solve(idx + 1, total + weight[idx]) + value[idx]);
	return ans;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(cache, -1, sizeof(cache));

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

    cout << max(0,solve(1, 0)) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:16: error: no matching function for call to 'max(int, long long int)'
   55 |     cout << max(0,solve(1, 0)) << endl;
      |             ~~~^~~~~~~~~~~~~~~
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:3:
/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:55:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   55 |     cout << max(0,solve(1, 0)) << endl;
      |             ~~~^~~~~~~~~~~~~~~
/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:55:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   55 |     cout << max(0,solve(1, 0)) << endl;
      |             ~~~^~~~~~~~~~~~~~~