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

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=201,MAX2=200001;
const ll INF=(1LL<<60);
ll dp[MAX][MAX2];

int main(){
    
    int N;
    ll W;cin>>N>>W;
    vector<ll> v(N),w(N);
    bool vcheck=true;
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
        if(v[i]>1000) vcheck=false;
    }
    
    if(N<=30){
        if(N<=15){
            ll ans=0;
            for(int i=0;i<(1<<N);i++){
                ll vsum=0,wsum=0;
                for(int j=0;j<N;j++){
                    if(i&(1<<j)){
                        vsum+=v[j];
                        wsum+=w[j];
                    }
                }
                if(wsum<=W) ans=max(ans,vsum);
            }
            cout<<ans<<endl;
        }else{
            vector<pair<ll,ll>> S(1<<(N-15));
            for(int i=0;i<(1<<(N-15));i++){
                ll vsum=0,wsum=0;
                for(int j=15;j<N;j++){
                    if(i&(1<<(j-15))){
                        vsum+=v[j];
                        wsum+=w[j];
                    }
                }
                S[i].first=wsum;
                S[i].second=vsum;
            }
            sort(all(S),compare);
            for(int i=1;i<(1<<(N-15));i++){
                S[i].second=max(S[i-1].second,S[i].second);
                //cout<<S[i].first<<" "<<S[i].second<<endl;
            }
            
            ll ans=0;
            for(int i=0;i<(1<<15);i++){
                ll vsum=0,wsum=0;
                for(int j=0;j<15;j++){
                    if(i&(1<<j)){
                        vsum+=v[j];
                        wsum+=w[j];
                    }
                }
                if(wsum>W) continue;
                //cout<<W-wsum<<" "<<vsum<<endl;
                auto it=upper_bound(all(S),make_pair(W-wsum,0),compare);
                if(distance(it,S.end())==0) continue;
                ans=max(ans,(*it).second+vsum);
            }
            cout<<ans<<endl;
        }
    }else if(vcheck){
        for(int i=0;i<=N;i++){
            for(int j=0;j<=200000;j++){
                dp[i][j]=INF;
            }
        }
        dp[0][0]=0;
        for(int i=1;i<=N;i++){
            for(int j=0;j<=200000;j++){
                dp[i][j]=min(dp[i-1][j],dp[i][j]);
                if(j-v[i-1]>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
            }
        }
        ll ans=0;
        for(int i=0;i<=200000;i++){
            if(dp[N][i]<=W) ans=i;
        }
        cout<<ans<<endl;
    }else{
        for(int i=0;i<N;i++){
            for(int j=0;j<1+i*1000;j++){
                dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
                dp[i+1][j]=dp[i][j];
            }
        }
        ll ans=0;
        for(int j=0;j<=min(W,ll(200000));j++){
            ans=max(ans,dp[N][j]);
        }
        cout<<ans<<endl;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:48:25: error: 'compare' was not declared in this scope
   48 |             sort(all(S),compare);
      |                         ^~~~~~~
Language: C++

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

// dp[N][W]
unsigned long long dp[110][100100];


unsigned long long main() {
	unsigned long long N, W;

	cin >> N >> W;

	vector<unsigned long long> w(N);
	vector<unsigned long long> v(N);

	for(unsigned long long i=0; i<N; i++) {
		cin >> w.at(i) >> v.at(i);
	}

	for(unsigned long long i=0; i<110; i++) {
		for(unsigned long long j=0; j<100100; j++){
			dp[i][j] = 0;
		}
	}

	for(unsigned long long j=1; j<=N; j++) {
		for(unsigned long long i=0; i<=W; i++) {
			if(i-w.at(j-1) >= 0) {
				if(dp[j][i] < (v.at(j-1) + dp[j-1][i-w.at(j-1)])) {
					dp[j][i] = v.at(j-1) + dp[j-1][i-w.at(j-1)];
				}
			}

			if(dp[j][i] < dp[j-1][i]) {
				dp[j][i] = dp[j-1][i];
			}
		}
	}

	cout << dp[N][W] << endl;


}


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

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

// dp[N][W]
int dp[110][100100];


int main() {
	int N, W;

	cin >> N >> W;

	vector<int> w(N);
	vector<int> v(N);

	for(int i=0; i<N; i++) {
		cin >> w.at(i >> v.at(i);
	}

	for(int i=0; i<100; i++) {
		for(int j=0; j<100000; j++){
			dp[i][j] = 0;
		}
	}

	for(int j=1; j<=N; j++) {
		for(int i=0; i<=W; i++) {
			if(i-w.at(j-1) >= 0) {
				if(dp[j][i] < (w.at(j-1) + dp[j-1][i])) {
					dp[j][i] = w.at(j-1) + dp[j-1][i];
				}
			}

			if(dp[j][i] < dp[j-1][i]) {
				dp[j][i] = dp[j-1][i];
			}
		}
	}

	cout << dp[N][W] << endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:41: error: expected ')' before ';' token
   21 |                 cin >> w.at(i >> v.at(i);
      |                            ~            ^
      |                                         )
Language: C++

#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define nMAX numeric_limits<long long>::max()
int main(void){
	int N;
	ll W;
	int i,k;
	ll j;
	cin >> N>>W;
	int v[N+1];
	ll w[N+1];
	rep(i,N){
		cin >> w[i+1]>>v[i+1];
	}
	ll **dp = (ll**)malloc(sizeof(llabs *)*(N+1));
	rep(i,N+1){
		dp[i]=(ll *)malloc(sizeof(ll)*(W+1));
		if (dp[i] == NULL) {
        	printf("Memory cannot be allocated.");
    	}
	}
	rep(i,N+1){
		dp[i][0] = 0;
	}
	rep(i,W+1){
		dp[0][j]=0;
	}
	for(i=1;i<N+1;i++){
		for(j=1;j<W+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];
			}
		}
	}
	cout << dp[N][W] <<endl;
	rep(i,N+1)free(dp[i]);
	free(dp);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:46: error: expected primary-expression before ')' token
   22 |         ll **dp = (ll**)malloc(sizeof(llabs *)*(N+1));
      |                                              ^
Language: Java

import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int c=sc.nextInt();
    long val[]=new long[n+1];
    long wt[]=new long[n+1];
    for(int i=1;i<=n;i++)
    {
      
        wt[i]=sc.nextInt();
        val[i]=sc.nextInt();
      
    }
   long[][] t=new long[n+1][c+1];
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=c;j++)
      {
		 if(wt[i]<=j)
		 {
		 t[i][j]=Math.max(val[i]+t[i-1][(int)(c-wt[i])],t[i-1][j]);}
		 else
		 {
			 t[i][j]=t[i-1][j];
		 }
      }
    }
    System.out.println(t[n][c]);
  }
}import java.util.*;
public class knapsack
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int c=sc.nextInt();
    long val[]=new long[n+1];
    long wt[]=new long[n+1];
    for(int i=1;i<=n;i++)
    {
      
        wt[i]=sc.nextInt();
        val[i]=sc.nextInt();
      
    }
   long[][] t=new long[n+1][c+1];
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=c;j++)
      {
		 if(wt[i]<=j)
		 {
		 t[i][j]=Math.max(val[i]+t[i-1][(int)(c-wt[i])],t[i-1][j]);}
		 else
		 {
			 t[i][j]=t[i-1][j];
		 }
      }
    }
    System.out.println(t[n][c]);
  }
}

Compiler output:
Main.java:34: error: class, interface, enum, or record expected
}import java.util.*;
 ^
1 error
Language: Java

import java.util.*;
public class knapsack
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int c=sc.nextInt();
    long val[]=new long[n+1];
    long wt[]=new long[n+1];
    for(int i=1;i<=n;i++)
    {
      
        wt[i]=sc.nextInt();
        val[i]=sc.nextInt();
      
    }
   long[][] t=new long[n+1][c+1];
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=c;j++)
      {
		 if(wt[i]<=j)
		 {
		 t[i][j]=Math.max(val[i]+t[i-1][(int)(c-wt[i])],t[i-1][j]);}
		 else
		 {
			 t[i][j]=t[i-1][j];
		 }
      }
    }
    System.out.println(t[n][c]);
  }
}import java.util.*;
public class knapsack
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int c=sc.nextInt();
    long val[]=new long[n+1];
    long wt[]=new long[n+1];
    for(int i=1;i<=n;i++)
    {
      
        wt[i]=sc.nextInt();
        val[i]=sc.nextInt();
      
    }
   long[][] t=new long[n+1][c+1];
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=c;j++)
      {
		 if(wt[i]<=j)
		 {
		 t[i][j]=Math.max(val[i]+t[i-1][(int)(c-wt[i])],t[i-1][j]);}
		 else
		 {
			 t[i][j]=t[i-1][j];
		 }
      }
    }
    System.out.println(t[n][c]);
  }
}

Compiler output:
Main.java:34: error: class, interface, enum, or record expected
}import java.util.*;
 ^
1 error
Language: C++

//#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define ll long long

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> sw(n), v(n);
	for(int i = 0;i < n;i++)
		cin >> sw[i] >> v[i];
	ll dp[110][110000] = { 0 };
	for(int i = 0; i < n;i++){
		for (int j = 0; j <= w; j++){
			if (j - sw[i] >= 0)
				dp[i + 1][j] = max(dp[i][j - sw[i]] + v[i], dp[i][j]);
			else
				dp[i + 1][j] = dp[i][j];
		}
	}
	/*for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= w; j++) {
			cout << dp[i][j] << ' ';
		}
		cout << '\n';
	}*/
	cout << dp[n][w];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin >> n >> w;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | //#include <bits/stdc++.h>
a.cc:11:9: error: 'vector' was not declared in this scope
   11 |         vector<int> sw(n), v(n);
      |         ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | //#include <bits/stdc++.h>
a.cc:11:16: error: expected primary-expression before 'int'
   11 |         vector<int> sw(n), v(n);
      |                ^~~
a.cc:13:24: error: 'sw' was not declared in this scope; did you mean 'w'?
   13 |                 cin >> sw[i] >> v[i];
      |                        ^~
      |                        w
a.cc:13:33: error: 'v' was not declared in this scope
   13 |                 cin >> sw[i] >> v[i];
      |                                 ^
a.cc:17:33: error: 'sw' was not declared in this scope; did you mean 'w'?
   17 |                         if (j - sw[i] >= 0)
      |                                 ^~
      |                                 w
a.cc:18:71: error: 'v' was not declared in this scope
   18 |                                 dp[i + 1][j] = max(dp[i][j - sw[i]] + v[i], dp[i][j]);
      |                                                                       ^
a.cc:18:48: error: 'max' was not declared in this scope
   18 |                                 dp[i + 1][j] = max(dp[i][j - sw[i]] + v[i], dp[i][j]);
      |                                                ^~~
a.cc:29:9: error: 'cout' was not declared in this scope
   29 |         cout << dp[n][w];
      |         ^~~~
a.cc:29:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'V' was not declared in this scope
   12 |       cin >> w[i] >> V[i];
      |                      ^
a.cc:20:28: error: 'V' was not declared in this scope
   20 |             DP[i][j] = max(V[i-1] + DP[i-1][j-w[i-1]],  DP[i-1][j]);
      |                            ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<numeric>
#include<map>
#include<limits>
#include<cstring>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int mod = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int n, W;
    int weight[110], value[110];
    vector<vector<<int> > dp(110, vector<int> (11010));
    cin >> n >> W;
    rep(i,n) cin >> weight[i] >> value[i];
    //dp初期化
    for(int w = 0; w <= W; ++w)dp[0][w] = 0;
    //dpループ
    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:22:23: error: template argument 1 is invalid
   22 |     vector<vector<<int> > dp(110, vector<int> (11010));
      |                       ^
a.cc:22:23: error: template argument 2 is invalid
a.cc:22:25: error: expected unqualified-id before '>' token
   22 |     vector<vector<<int> > dp(110, vector<int> (11010));
      |                         ^
a.cc:26:32: error: 'dp' was not declared in this scope
   26 |     for(int w = 0; w <= W; ++w)dp[0][w] = 0;
      |                                ^~
a.cc:30:31: error: 'dp' was not declared in this scope
   30 |             if(w >= weight[i])dp[i+1][w] = max(dp[i][w-weight[i]+value[i], dp[i][w]]);
      |                               ^~
a.cc:32:18: error: 'dp' was not declared in this scope
   32 |             else dp[i+1][w] = dp[i][w];
      |                  ^~
a.cc:35:13: error: 'dp' was not declared in this scope
   35 |     cout << dp[n][W] << endl;
      |             ^~
Language: C++

#include<iostream>
#define ll unsigned long long int
int main()
{
  ll n,w,v1,w1;
  cin>>n>>w;
  ll dp[n+1][w+1];
  ll weights[n];
  ll values[n];
  for(int i=0;i<n;i++)
  {
    cin>>w1>>v1;
    weights[i]=w1;
    values[i]=v1
  }
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0 || j==0)
        dp[i][j]=0;
      else{
        if(j>=weights[i]){
        dp[i][j]=max(values[i]+dp[i-1][j-weights[i]],dp[i-1][j]);
        }
        else dp[i][j]=dp[i-1][j];
      }
    }}
  cout<<dp[n][w];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin>>n>>w;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:14:17: error: expected ';' before '}' token
   14 |     values[i]=v1
      |                 ^
      |                 ;
   15 |   }
      |   ~              
a.cc:24:18: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |         dp[i][j]=max(values[i]+dp[i-1][j-weights[i]],dp[i-1][j]);
      |                  ^~~
      |                  std::max
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:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:29:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |   cout<<dp[n][w];
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int mod = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int N;
ll W, weight[110], value[110],dp[110][100100] = {0};
int main(){
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> weight[i] >> value[i];
    }
    for (int i = 0; i < N; i++)
    {
        for (int sum_w = 0; sum_w < W; sum_w++)
        {
            if(sum_w-weight[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w - weihgt[i]]+value[i]);
            }

            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:53: error: 'weihgt' was not declared in this scope; did you mean 'weight'?
   22 |                 chmax(dp[i+1][sum_w], dp[i][sum_w - weihgt[i]]+value[i]);
      |                                                     ^~~~~~
      |                                                     weight
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,w;
  cin>>n>>w;
  int arr[n][2];
  for(int idx = 0;idx<n;idx++){
    cin>>arr[idx][0]>>arr[idx][1];
  }
  int result[n][w+1]={{0}};
  for(int val = 0;val<n;val++){
    for(int W = 1;W<=w;W++){
      if(W>=arr[val][0]){
        result[val][W]=max(result[val][W],arr[val][1]+result[val][W-arr[val][0]);
        }
          else if(val!=0)
               result[val][W]=result[val-1][W];
     }
   }
         
   cout<<result[n-1][W];
      return 0;
                                                                  }                                 
                                                                  
                                                                  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:16:80: error: expected ']' before ')' token
   16 |         result[val][W]=max(result[val][W],arr[val][1]+result[val][W-arr[val][0]);
      |                                                                                ^
      |                                                                                ]
a.cc:23:22: error: 'W' was not declared in this scope
   23 |    cout<<result[n-1][W];
      |                      ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
 
int main () {
  int n, wmax;
  std::cin >> n >> wmax;
  
  std::vector<int> w(n);
  std::vector<size_t> v(n);
  for (int i = 0; i < n; ++i) std::cin >> w[i] >> v[i];
  
  std::vector<int> dp(wmax+1);
  dp[0] = 0;
  
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= wmax; ++j) {
      if (j - w[i] < 0) continue;
      dp[j] = std::max(dp[j], dp[j-w[i]] + v[i]);
    }
  }

  const auto it = std::max_element(dp.begin(), dp.end());
  std::cout << *it << std::endl;
}

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

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

int main () {
  int n, wmax;
  std::cin >> n >> wmax;
  
  std::vector<int> w(n);
  std::vector<size_t> v(n);
  for (int i = 0; i < n; ++i) std::cin >> w[i] >> v[i];
  
  std::vector<int> id(n);
  std::iota(id.begin(), id.end(), 0);
  
  std::sort(id.begin(), id.end(), [&v](auto i, auto j) {
    return v[i] > v[j];
  });
  
  int ws = 0;
  size_t vs = 0;
  for (auto&& i : id) {
    ws += w[i];
    if (ws > wmax) break;
    vs += v[i];
  }
  std::cout << vs << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:8: error: 'iota' is not a member of 'std'
   14 |   std::iota(id.begin(), id.end(), 0);
      |        ^~~~
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numOfItems = sc.nextInt();
        int knapSackWeight = sc.nextInt();
        long[] itemValue = new long[numOfItems+1];
        long[] itemWeight = new long[numOfItems+1];
        for(int i =1;i<=numOfItems;i++){
            itemWeight[i] = sc.nextInt();
            itemValue[i] = sc.nextInt();
        }
       // Arrays.sort(itemWeight);
        System.out.println(findMaxValue(numOfItems,knapSackWeight,itemWeight,itemValue));
    }
    public static long findMaxValue(int items, int knapSackWeight, long[] itemWeight, long[] itemValue){
        long[][] T = new long[items+1][knapSackWeight+1];
        for(int i=1;i<=items;i++){
            for(int j=1;j<=knapSackWeight;j++){
                if(itemWeight[i]>j){
                    T[i][j] = T[i-1][j];
                }
                else{
                    T[i][j] = Math.max(T[i-1][j],itemValue[i]+T[i-1][(int)(j-itemWeight[i])]);
                }
            }
        }
        return T[items][knapSackWeight];
    }
}

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

#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}



using namespace std;
int main(){
    ll n,w;
    cin >> n >> w;

    vector<vector<ll>> dp(n+100, vector<ll>(n+100,0));
    
    ll wa,b;
    


    for(ll i=0, i< n+1;i++){
        if(i==0) continue;
        else{
        cin >> wa >> b;

        for(ll j=0;j<w+1;j++){
            
            if(j-wa>=0){
                if(dp[i-1][j] <= (dp[i-1][j-wa]) + b){
                    dp[i][j] = (dp[i-1][j-wa]) +b ;
                    
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }else{
                dp[i][j] = dp[i-1][j];
            }
            
            
        }
        }
    }
    
    cout << dp[n][w] <<endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:18: error: expected ';' before '<' token
   51 |     for(ll i=0, i< n+1;i++){
      |                  ^
      |                  ;
a.cc:51:18: error: expected primary-expression before '<' token
Language: C++

#include<bits/stdc++.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;

const int maxN=101;
const int maxW=1e7+1;
int N,W;
int F[maxN][maxW], w[maxN], v[maxN];

int main()
{
	//IN;			
	FASTIO;
	cin >> N >> W;
	for (int i=1; i<=N; i++) {
		cin >> w[i] >> v[i];
		F[i][0] = 0;
	}
	for (int i=1; i<=W; i++) F[0][i] = -(1e9);
	for (int i=1; i<=N; i++) 
		for (int j=1; j<=W; j++) {
			int V = F[i-1][j];
			if (j>=w[i]) V = max(V, F[i-1][j-w[i]]+v[i]);
			F[i][j] = V;
		}
	cout << F[N][W];
	return 0;
}


Compiler output:
/tmp/ccPgKQfD.o: in function `main':
a.cc:(.text+0x81): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPgKQfD.o
a.cc:(.text+0xad): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccPgKQfD.o
a.cc:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPgKQfD.o
a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPgKQfD.o
a.cc:(.text+0x1d0): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccPgKQfD.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,W;cin>>n>>W;
  ll w[n],v[n];
  rep(i,n)cin>>w[i]>>v[i];
  ll dp[n+1][w+1]={};
  rep(i,n){
    rep(j,1,W+1){
      dp[i+1][j]=max(dp[i+1][j-1],dp[i][j-w[i+1]]+v[i]);
    }
  }
  cout<<dp[n][W]<<endl;
}
    



  


Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: conversion from 'll*' {aka 'long long int*'} to 'long unsigned int' in a converted constant expression
   18 |   ll dp[n+1][w+1]={};
      |              ~^~
a.cc:18:15: error: could not convert '(((ll*)(& w)) + 8)' from 'll*' {aka 'long long int*'} to 'long unsigned int'
   18 |   ll dp[n+1][w+1]={};
      |              ~^~
      |               |
      |               ll* {aka long long int*}
a.cc:18:15: error: size of array 'dp' has non-integral type 'll*' {aka 'long long int*'}
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,w;cin>>n>>w;
  ll w[n],v[n];
  rep(i,n)cin>>w[i]>>v[i];
  ll dp[n+1][w+1]={};
  rep(i,n){
    rep(j,1,w+1){
      dp[i+1][j]=max(dp[i+1][j-1],dp[i][j-w[i+1]]+v[i]);
    }
  }
  cout<<dp[n][w]<<endl;
}
    



  


Compiler output:
a.cc: In function 'int main()':
a.cc:16:6: error: conflicting declaration 'll w [n]'
   16 |   ll w[n],v[n];
      |      ^
a.cc:15:9: note: previous declaration as 'int w'
   15 |   int n,w;cin>>n>>w;
      |         ^
a.cc:17:17: error: invalid types 'int[int]' for array subscript
   17 |   rep(i,n)cin>>w[i]>>v[i];
      |                 ^
a.cc:21:44: error: invalid types 'int[int]' for array subscript
   21 |       dp[i+1][j]=max(dp[i+1][j-1],dp[i][j-w[i+1]]+v[i]);
      |                                            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{     

      ios_base::sync_with_stdio(0);
      cin.tie(0);
      int n,wt;
      cin>>n>>wt;
    
      int w[n+1],v[n+1];
      
      long long int dp[n+1][wt+1];
    
      for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    
      for(i=0;i<n;i++)
      	dp[i][0]=0;
      for(int i=0;i<n;i++)
      {
        for(int j=1;j<=wt;j++)
        {
          if(i==0)
          {
            if(j>=w[i])
              dp[i][j]=v[i];
            else
              dp[i][j]=0;
          }
          else
          {
          if(j-w[i]<0)
            dp[i][j]=dp[i-1][j];
          else
          	dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
          }
        }
      }
      cout<<dp[n-1][wt];


return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'i' was not declared in this scope
   15 |       for(i=0;i<n;i++)
      |           ^
a.cc:18:11: error: 'i' was not declared in this scope
   18 |       for(i=0;i<n;i++)
      |           ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> VI;
typedef vector<VI> VVI;

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

    VI w(N); VI v(N);
    VVI T(N,vector<long long>(W+1,0));

    REP(i,N){
        cin >> w[i] >> v[i];
    }

    FOR(k,w[0],W+1){        //初期化
        T[0][k] = v[0];
    }

    FOR(i,1,N)
    {
       FOR(j,W+1)
       {
           if( j >= w[i] ){
                long long m;
                m = T[i-1][j-w[i]] + v[i];
                if (m > T[i-1][j]){
                   T[i][j] = m;
                }
                else {
                   T[i][j] = T[i-1][j];
                }
           }
           else{
               T[i][j] =  T[i-1][j];
           }
       } 
    }
    cout << T[N-1][W]<< endl;  
    /*REP(i,N){
        REP(j,W+1){
            cout << T[i][j]  << " "; 
        }
        cout << endl;
    }*/
    return 0;
}
   


Compiler output:
a.cc:27:17: error: macro "FOR" requires 3 arguments, but only 2 given
   27 |        FOR(j,W+1)
      |                 ^
a.cc:5:9: note: macro "FOR" defined here
    5 | #define FOR(i, m, n) for(int i = m; i < n; i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:27:8: error: 'FOR' was not declared in this scope
   27 |        FOR(j,W+1)
      |        ^~~
Language: C++

#include<bits/stdc++.h>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
const long long INF = 1e9;

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

  //dp[i][w]i-1番目までの品物から重さがwを超えないように選んだ時の最大値
  vector<vector<ll> > dp(n + 1, vector<ll>(100000, 0));
  for (int i = 0; i < n; i++){
    for (int sum_w = 0; sum_w < W; sum_w++)
    {
      if(sum_w - w[i] >= 0){ //選ぶとき
        chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
      }

      //選ばなかったとき
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }
  
  cout << dp[N][W] << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:22: error: 'n' was not declared in this scope
   18 |   for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
      |                      ^
a.cc:21:26: error: 'n' was not declared in this scope
   21 |   vector<vector<ll> > dp(n + 1, vector<ll>(100000, 0));
      |                          ^
Language: C++

#include<bits/stdc++.h>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
const long long INF = 1e9;

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

  //dp[i][w]i-1番目までの品物から重さがwを超えないように選んだ時の最大値
  vector<vector<ll> > dp(n + 1, vector<ll>(100000, 0));
  for (int i = 0; i < n; i++){
    for (int sum_w = 0; sum_w < W; sum_w++)
    {
      if(sum_w - w[i] >= 0){ //選ぶとき
        chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
      }

      //選ばなかったとき
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }
  
  cout << dp[N][W] << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'n' was not declared in this scope
   17 |   vector<int> w(n), v(n);
      |                 ^
Language: C++

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

long long p[105];
long long w[105];
long long dp[1005][1005];

long long f(long long i, long long k){
    if(k < 0) return 1;
    if(i == n) return 0;
    long long &r = dp[i][k];
    if(r == -1){
        r = f(i + 1, k);
        if(w[i] <= k){
            r = max(r, f(i + 1, k - w[i]) + p[i]);
        }
    }
    return r;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    memset(dp, -1, sizeof dp);
    long long n, k;
    cin >> n >> k;
    for(long long i = 0; i < n; i++){
        cin >> w[i] >> p[i];
    }
    cout << f(0, k);
}


Compiler output:
a.cc: In function 'long long int f(long long int, long long int)':
a.cc:10:13: error: 'n' was not declared in this scope
   10 |     if(i == n) return 0;
      |             ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int n,W,weight[200],value[200];
long long dp[200][100005];
int main()
{
   cin>>n>>W;
   for (int i=1;i<=n;i++)
    cin>>weight[i]>>value[i];
    for (int i=1;i<=n ;i++)
    for (int w=1;w<=W ;w++)
      if (weght[i]<=w)
    dp[i][w]=max(dp[i-1][w],(dp[i-1][w-weight[i]]+value[i]));
    else
        dp[i][w]=dp[i-1][w];
   cout<<dp[n][W]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'weght' was not declared in this scope; did you mean 'weight'?
   13 |       if (weght[i]<=w)
      |           ^~~~~
      |           weight
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  long long n,W,weight[110],value[110];
  cin >> n;
  long long dp[110][100005];
  for(int i=0; i<n; i++) {
    cin >> weight[i] >> v[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],dp[i][w-weight[i]]+v[i]);
      }
      else {
        dp[i+1][w]=dp[i][w];
      }
    }
  }
    cout << dp[n][W] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: 'v' was not declared in this scope
    9 |     cin >> weight[i] >> v[i];
      |                         ^
a.cc:17:52: error: 'v' was not declared in this scope
   17 |         dp[i+1][w]=max(dp[i][w],dp[i][w-weight[i]]+v[i]);
      |                                                    ^
Language: C++

#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int main() {
  int n,W,weight[100],value[100];
  cin >> n;
  long long dp[100][100000];
  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],dp[i][w-weight[i]]+value[i]);
      }
      else {
        dp[i+1][w]=dp[i][w];
      }
    }
    cout << dp[n][W] << endl;
  }
  


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

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int n,W,weight[100],value[100];
  cin >> n;
  long long dp[100][100000];
  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],dp[i][w-weight[i]]);
      }
      else {
        dp[i+1][w]=dp[i][w];
      }
    }
    cout << dp[n][W] << endl;
  }
  

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

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,W;
  cin>>N>>M;
  int w[N],v[N];
  rep(i,N){
    cin>>w[i]>>v[i];
  }
  int dp[N][W];
  rep(i,N){
    rep(j,W){
      dp[i][j]=-INF;
    }
  }
  dp[0][0]=0;
  dp[0][w[0]]=v[0];
  rep(i,N-1){
    rep(j,W){
       dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
       if(j+w[i+1]<=W)
          dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
    }
  }
  int ans=-INF;
  rep(i,W){
    ans=max(dp[N-1][i],ans)
  }
  cout<<ans<<endl;
  

}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:22:11: error: 'M' was not declared in this scope
   22 |   cin>>N>>M;
      |           ^
a.cc:44:28: error: expected ';' before '}' token
   44 |     ans=max(dp[N-1][i],ans)
      |                            ^
      |                            ;
   45 |   }
      |   ~
Language: C++

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

int main() {
	/*int N;
	cin >> N;
	vector<int>h(N);
	int i;
	for (i = 0; i < N; i++) {
		cin >> h[i];
	}
	vector<int>c(N);
	c[0] = 0;
	c[1] = abs(h[1]-h[0]);
	for (i = 1; i < N - 1; i++) {
		c[i + 1] = min(c[i] + abs(h[i + 1] - h[i]), c[i - 1] + abs(h[i + 1] - h[i - 1]));
	}
	cout << c[N - 1] << endl;*/



	/*int N, K;
	cin >> N >> K;
	vector<int>h(N);
	int i, j;

	for (i = 0; i < N; i++) {
		cin >> h[i];
	}
	vector<int>c(N);
	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
	for (i = 1; i < N - 1; i++) {
		c[i + 1] = c[i] + abs(h[i + 1] - h[i]);
		for (j = 1; j <= K && i + 1 - j >= 0; j++) {
			c[i + 1] = min(c[i + 1], c[i + 1 - j] + abs(h[i + 1] - h[i + 1 - j]));
		}
	}
	cout << c[N - 1] << endl;*/


	/*int N;
	cin >> N;
	vector<int>a(N), b(N), c(N);
	int i;
	for (i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<int>A(N), B(N), C(N);
	A[0] = a[0];
	B[0] = b[0];
	C[0] = c[0];
	for (i = 0; i < N - 1; i++) {
		A[i + 1] = a[i + 1] + max(B[i], C[i]);
		B[i + 1] = b[i + 1] + max(A[i], C[i]);
		C[i + 1] = c[i + 1] + max(A[i], B[i]);
	}
	cout << max({ A[N - 1], B[N - 1],C[N - 1] }) << endl;*/


	int N, W;
	cin >> N >> W;
	long long int dp[100005];
	for (int i = 0; i < N; i++) {
		int a, b;
		scanf_s("%d%d", &a, &b);
		for (int j = W - a; j >= 0; --j) {
			dp[j + a] = max(dp[j + a], dp[j] + b);
		}
	}
	cout << dp[W] << endl;
	return 0;

}

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'll' was not declared in this scope
    8 |     ll dp[w+1];
      |     ^~
a.cc:10:27: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |     for(int i=0;i<=w;i++) dp[i]=0;
      |                           ^~
      |                           dup
a.cc:11:7: error: expected ';' before 'mx'
   11 |     ll mx=0;
      |       ^~~
      |       ;
a.cc:15:29: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |             if(j>a[0][i] && dp[j-a[0][i]]!=0 ){ dp[j]=max(dp[j],dp[j-a[0][i]]+(ll)a[1][i]); }
      |                             ^~
      |                             dup
a.cc:17:25: error: 'mx' was not declared in this scope
   17 |                         mx=max(mx,dp[j]);
      |                         ^~
a.cc:17:35: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |                         mx=max(mx,dp[j]);
      |                                   ^~
      |                                   dup
a.cc:20:11: error: 'mx' was not declared in this scope
   20 |     cout<<mx<<endl;
      |           ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
IOS;
lli n,w,x,y,i,j;
cin>>n>>w;
vector<pair<lli,lli> > v;
for(i=0;i<n;i++){
    cin>>x;
    cin>>y;
    v.pb(mp(x,y));
}
lli dp[n][w+1]={0};
sort(v.begin(),v.end());
for(j=0;j<=w;j++){
    if(j<v[0].first)
        dp[0][j]=0;
    else dp[0][j]=v[0].second;
}
for(i=0;i<n;i++){
    dp[i][0]=0;
}
for(i=1;i<n;i++){
    for(j=1;j<=w;j++){
        if(j<v[i].first)
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        else{
            dp[i][j]=max(v[i].second+dp[i-1][j-v[i].first],max(dp[i][j-1],dp[i-1][j]));
        }
    }
}
cout<<dp[n-1][w]<<endl;
}
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
IOS;
lli n,w,x,y,i,j;
cin>>n>>w;
vector<pair<lli,lli> > v;
for(i=0;i<n;i++){
    cin>>x;
    cin>>y;
    v.pb(mp(x,y));
}
lli dp[n][w+1]={0};
sort(v.begin(),v.end());
for(j=0;j<=w;j++){
    if(j<v[0].first)
        dp[0][j]=0;
    else dp[0][j]=v[0].second;
}
for(i=0;i<n;i++){
    dp[i][0]=0;
}
for(i=1;i<n;i++){
    for(j=1;j<=w;j++){
        if(j<v[i].first)
        dp[i][j]=dp[i-1][j];
        else{
            dp[i][j]=max(v[i].second+dp[i-1][j-v[i].first],dp[i-1][j]);
        }
    }
}
cout<<dp[n-1][w]<<endl;
}


Compiler output:
a.cc:48:5: error: redefinition of 'int main()'
   48 | int main(){
      |     ^~~~
a.cc:9:5: note: 'int main()' previously defined here
    9 | int main(){
      |     ^~~~