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

#include<bits/stdc++.h>
using namespace std;
int n,W,sum;
int w[101],v[101];
int dp[101][100001];
int main()
{
	cin>>n>>W;
	sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	
	for(int i=0;i<n;i++)
	{
		dp[i][0]=0;
		for(int j=1;j<=sum;j++)
			dp[i][j]=1000000000;
	}
	
	dp[0][v[0]]=w[0];
	
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=sum;j++)
		{
			if(j<v[i])
			{
				dp[i][j]=dp[i-1][j];
				
			}
			else
			dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
		}
	}
	
	for(int i=sum;i<=0;i--)
		if(dp[n-1][i]<=W)
			{
			    cout<<i;
			    exit();
			}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:33: error: too few arguments to function 'void exit(int)'
   43 |                             exit();
      |                             ~~~~^~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:756:13: note: declared here
  756 | extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
      |             ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int N, W, w[101], v[101];
ll dp[101][200020];

int main() {
  cin >> N >> W;
  rep(i, 0, N) cin >> w[i] >> v[i];
  
  rep(i, 0, N) rep(val, 0, N * 1010) dp[i][val] = inf
  dp[0][0] = 0;

  rep(i, 0, N) rep(val, 0, N * 1010) {
    chmin(dp[i+1][val], dp[i][val]);
    chmin(dp[i+1][val + v[i]], dp[i][val] + w[i]);
  }

  ll res = 0;
  rep(val, 0, N * 1010) if (dp[N][val] <= W) chmax(res, val);
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:54: error: expected ';' before 'dp'
   42 |   rep(i, 0, N) rep(val, 0, N * 1010) dp[i][val] = inf
      |                                                      ^
      |                                                      ;
   43 |   dp[0][0] = 0;
      |   ~~                                                  
a.cc:51:51: error: no matching function for call to 'chmax(ll&, int&)'
   51 |   rep(val, 0, N * 1010) if (dp[N][val] <= W) chmax(res, val);
      |                                              ~~~~~^~~~~~~~~~
a.cc:27:34: note: candidate: 'template<class T> bool chmax(T&, T)'
   27 | template<typename T> inline bool chmax(T& x, T y) {
      |                                  ^~~~~
a.cc:27:34: note:   template argument deduction/substitution failed:
a.cc:51:51: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   51 |   rep(val, 0, N * 1010) if (dp[N][val] <= W) chmax(res, val);
      |                                              ~~~~~^~~~~~~~~~
Language: C++

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'cin' was not declared in this scope
   17 |     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 | using namespace std;
a.cc:43:5: error: 'cout' was not declared in this scope
   43 |     cout << res << endl;
      |     ^~~~
a.cc:43:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:20: error: 'endl' was not declared in this scope
   43 |     cout << res << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author hamaron
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class EKnapsack2 {
public:
    void solve(std::istream &in, std::ostream &out) {
        int N;
        long W;
        in >> N >> W;
        long long dp[N + 1][N * 1000 + 1];

        for (int i = 0; i < N + 1; i++) {
            for (long j = 0; j < N * 1000 + 1; j++) {
                dp[i][j] = INT_MAX;
            }
        }

        dp[0][0] = 0;
        for (int i = 1; i < N + 1; i++) {
            int w, v;
            in >> w >> v;
            for (long j = 0; j < N * 1000 + 1; j++) {
                if (j - v < 0) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j]);
                }
            }
        }

        int maxValue = -1;
        for (int j = N * 1000; j >= 0; j--) {
            if (dp[N][j] <= W) {
                maxValue = j;
                break;
            }
        }

        out << maxValue;
    }
};


int main() {
	EKnapsack2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Compiler output:
a.cc: In member function 'void EKnapsack2::solve(std::istream&, std::ostream&)':
a.cc:24:28: error: 'INT_MAX' was not declared in this scope
   24 |                 dp[i][j] = INT_MAX;
      |                            ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <fstream>
  +++ |+#include <climits>
    9 |
Language: C++

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

int main()
{
  int n, W;
  cin >> n >> W;
  vector<long long> weight(n), value(n);
  for(int i = 0 ; i < n ; i++ )
  {
    cin >>weight[i]>>value[i];
  }
  
  vector<vector<long long> > dp(n+1, vector<long long>(pow(10,5)+1, std::numeric_limits<double>::infinity()));
  dp[0][0] = 0

for(int i = 0 ; i < N+1 ; i++)
{
  for(int j = 0 ; j < pow(10,5)+1 ; j++)
  {
    if(j-value[i-1] >= 0)
    {
      dp[i][j] = min(dp[i-1][j-value[i-1] + weight[i-1] , dp[i][j]);
    }
    dp[i][j] = min(dp[i][j],dp[i-1][j]);
  }                             
}                             
                             
for(int i = pow(10,5)+1 ; i >= 0 ; i--)
    if(dp[N][i] <= W)
       cout<<i;


Compiler output:
a.cc: In function 'int main()':
a.cc:14:106: warning: overflow in conversion from 'double' to 'std::vector<long long int>::value_type' {aka 'long long int'} changes value from '+Inf' to '9223372036854775807' [-Woverflow]
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(pow(10,5)+1, std::numeric_limits<double>::infinity()));
      |                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
a.cc:15:15: error: expected ';' before 'for'
   15 |   dp[0][0] = 0
      |               ^
      |               ;
   16 | 
   17 | for(int i = 0 ; i < N+1 ; i++)
      | ~~~            
a.cc:17:17: error: 'i' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                 ^
a.cc:17:21: error: 'N' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                     ^
a.cc:31:16: error: expected '}' at end of input
   31 |        cout<<i;
      |                ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

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

int main()
{
  int n, W;
  cin >> n >> W;
  vector<long long> weight(n), value(n);
  for(int i = 0 ; i < n ; i++ )
  {
    cin >>weight[i]>>value[i];
  }
  
  vector<vector<long long> > dp(n+1, vector<long long>(pow(10,5)+1, std::numeric_limits<double>::infinity();));
  dp[0][0] = 0

for(int i = 0 ; i < N+1 ; i++)
{
  for(int j = 0 ; j < pow(10,5)+1 ; j++)
  {
    if(j-value[i-1] >= 0)
    {
      dp[i][j] = min(dp[i-1][j-value[i-1] + weight[i-1] , dp[i][j]);
    }
    dp[i][j] = min(dp[i][j],dp[i-1][j]);
  }                             
}                             
                             
for(int i = pow(10,5)+1 ; i >= 0 ; i--)
    if(dp[N][i] <= W)
       cout<<i;


Compiler output:
a.cc: In function 'int main()':
a.cc:14:55: error: expected primary-expression before '(' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(pow(10,5)+1, std::numeric_limits<double>::infinity();));
      |                                                       ^
a.cc:14:108: error: expected ')' before ';' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(pow(10,5)+1, std::numeric_limits<double>::infinity();));
      |                                                       ~                                                    ^
      |                                                                                                            )
a.cc:14:109: error: expected primary-expression before ')' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(pow(10,5)+1, std::numeric_limits<double>::infinity();));
      |                                                                                                             ^
a.cc:15:15: error: expected ';' before 'for'
   15 |   dp[0][0] = 0
      |               ^
      |               ;
   16 | 
   17 | for(int i = 0 ; i < N+1 ; i++)
      | ~~~            
a.cc:17:17: error: 'i' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                 ^
a.cc:17:21: error: 'N' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                     ^
a.cc:31:16: error: expected '}' at end of input
   31 |        cout<<i;
      |                ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

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

int main()
{
  int n, W;
  cin >> n >> W;
  vector<long long> weight(n), value(n);
  for(int i = 0 ; i < n ; i++ )
  {
    cin >>weight[i]>>value[i];
  }
  
  vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
  dp[0][0] = 0

for(int i = 0 ; i < N+1 ; i++)
{
  for(int j = 0 ; j < 10**5+1 ; j++)
  {
    if(j-value[i-1] >= 0)
    {
      dp[i][j] = min(dp[i-1][j-value[i-1] + weight[i-1] , dp[i][j]);
    }
    dp[i][j] = min(dp[i][j],dp[i-1][j]);
  }                             
}                             
                             
for(int i = 10**5+1 ; i >= 0 ; i--)
    if(dp[N][i] <= W)
       cout<<i;


Compiler output:
a.cc: In function 'int main()':
a.cc:14:59: error: invalid type argument of unary '*' (have 'int')
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                                                           ^~
a.cc:14:55: error: expected primary-expression before '(' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                                                       ^
a.cc:14:59: error: invalid type argument of unary '*' (have 'int')
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                                                           ^~
a.cc:14:104: error: expected ')' before ';' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                                                       ~                                                ^
      |                                                                                                        )
a.cc:14:105: error: expected primary-expression before ')' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                                                                                                         ^
a.cc:15:15: error: expected ';' before 'for'
   15 |   dp[0][0] = 0
      |               ^
      |               ;
   16 | 
   17 | for(int i = 0 ; i < N+1 ; i++)
      | ~~~            
a.cc:17:17: error: 'i' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                 ^
a.cc:17:21: error: 'N' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                     ^
a.cc:29:16: error: invalid type argument of unary '*' (have 'int')
   29 | for(int i = 10**5+1 ; i >= 0 ; i--)
      |                ^~
a.cc:31:16: error: expected '}' at end of input
   31 |        cout<<i;
      |                ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include <iostream>
using namespace std;

int main()
{
  int n, W;
  cin >> n >> W;
  vector<long long> weight(n), value(n);
  for(int i = 0 ; i < n ; i++ )
  {
    cin >>weight[i]>>value[i];
  }
  
  vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
  dp[0][0] = 0

for(int i = 0 ; i < N+1 ; i++)
{
  for(int j = 0 ; j < 10**5+1 ; j++)
  {
    if(j-value[i-1] >= 0)
    {
      dp[i][j] = min(dp[i-1][j-value[i-1] + weight[i-1] , dp[i][j]);
    }
    dp[i][j] = min(dp[i][j],dp[i-1][j]);
  }                             
}                             
                             
for(int i = 10**5+1 ; i >= 0 ; i--)
    if(dp[N][i] <= W)
       cout<<i;


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<long long> weight(n), value(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:8:10: error: expected primary-expression before 'long'
    8 |   vector<long long> weight(n), value(n);
      |          ^~~~
a.cc:11:11: error: 'weight' was not declared in this scope
   11 |     cin >>weight[i]>>value[i];
      |           ^~~~~~
a.cc:11:22: error: 'value' was not declared in this scope
   11 |     cin >>weight[i]>>value[i];
      |                      ^~~~~
a.cc:14:17: error: expected primary-expression before 'long'
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                 ^~~~
a.cc:14:105: error: expected primary-expression before ')' token
   14 |   vector<vector<long long> > dp(n+1, vector<long long>(10**5+1, std::numeric_limits<double>::infinity();));
      |                                                                                                         ^
a.cc:15:3: error: 'dp' was not declared in this scope
   15 |   dp[0][0] = 0
      |   ^~
a.cc:17:17: error: 'i' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                 ^
a.cc:17:21: error: 'N' was not declared in this scope
   17 | for(int i = 0 ; i < N+1 ; i++)
      |                     ^
a.cc:29:16: error: invalid type argument of unary '*' (have 'int')
   29 | for(int i = 10**5+1 ; i >= 0 ; i--)
      |                ^~
a.cc:31:16: error: expected '}' at end of input
   31 |        cout<<i;
      |                ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long int b[1000][3];
long long int d[109][1000000];
long long int dp(int x,long long int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w);
            return d[x][w];
        }
    }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
}
int main(){
    int x;
    long long int w;
    cin >> x >> w;
    for(int i=0; i <109;i++){
        for(int j=0; j<1000000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2]; 
    }
    cout << dp(x,w);
}
 
#include <bits/stdc++.h>
using namespace std;
long long int b[1000][3];
long long int d[109][1000000];
long long int dp(int x,long long int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w);
            return d[x][w];
        }
    }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
}
int main(){
    int x;
    long long int w;
    cin >> x >> w;
    for(int i=0; i <109;i++){
        for(int j=0; j<1000000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2]; 
    }
    cout << dp(x,w);
}
 

Compiler output:
a.cc:45:15: error: redefinition of 'long long int b [1000][3]'
   45 | long long int b[1000][3];
      |               ^
a.cc:3:15: note: 'long long int b [1000][3]' previously declared here
    3 | long long int b[1000][3];
      |               ^
a.cc:46:15: error: redefinition of 'long long int d [109][1000000]'
   46 | long long int d[109][1000000];
      |               ^
a.cc:4:15: note: 'long long int d [109][1000000]' previously declared here
    4 | long long int d[109][1000000];
      |               ^
a.cc:47:15: error: redefinition of 'long long int dp(int, long long int)'
   47 | long long int dp(int x,long long int w){
      |               ^~
a.cc:5:15: note: 'long long int dp(int, long long int)' previously defined here
    5 | long long int dp(int x,long long int w){
      |               ^~
a.cc:69:5: error: redefinition of 'int main()'
   69 | int main(){
      |     ^~~~
a.cc:27:5: note: 'int main()' previously defined here
   27 | int main(){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long int b[1000][3];
long long int d[109][1000000];
long long int dp(int x,long long int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w);
            return d[x][w];
        }
    }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
}
int main(){
    int x;
    long long int w;
    cin >> x >> w;
    for(int i=0; i <109;i++){
        for(int j=0; j<1000000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2]; 
    }
    cout << dp(x,w);
}
 
#include <bits/stdc++.h>
using namespace std;
long long int b[1000][3];
long long int d[109][1000000];
long long int dp(int x,long long int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w);
            return d[x][w];
        }
    }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
}
int main(){
    int x;
    long long int w;
    cin >> x >> w;
    for(int i=0; i <109;i++){
        for(int j=0; j<1000000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2]; 
    }
    cout << dp(x,w);
}
 
Submission Info

Compiler output:
a.cc:45:15: error: redefinition of 'long long int b [1000][3]'
   45 | long long int b[1000][3];
      |               ^
a.cc:3:15: note: 'long long int b [1000][3]' previously declared here
    3 | long long int b[1000][3];
      |               ^
a.cc:46:15: error: redefinition of 'long long int d [109][1000000]'
   46 | long long int d[109][1000000];
      |               ^
a.cc:4:15: note: 'long long int d [109][1000000]' previously declared here
    4 | long long int d[109][1000000];
      |               ^
a.cc:47:15: error: redefinition of 'long long int dp(int, long long int)'
   47 | long long int dp(int x,long long int w){
      |               ^~
a.cc:5:15: note: 'long long int dp(int, long long int)' previously defined here
    5 | long long int dp(int x,long long int w){
      |               ^~
a.cc:69:5: error: redefinition of 'int main()'
   69 | int main(){
      |     ^~~~
a.cc:27:5: note: 'int main()' previously defined here
   27 | int main(){
      |     ^~~~
a.cc:85:1: error: 'Submission' does not name a type
   85 | Submission Info
      | ^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long int b[1000][3];
long long int d[109];
long long int dp(int x,long long int w){
    if(d[x] != -1){
        return d[x];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x] = 0;
            return 0;
        }
        else {
            
            return dp(x-1,w);
        }
    }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x];
    }
}
int main(){
    int x;
    long long int w;
    cin >> x >> w;
    for(int i=0; i <109;i++){
            d[i]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2]; 
    }
    cout << dp(x,w);
}
 

Compiler output:
a.cc:35:5: error: expected unqualified-id before 'for'
   35 |     for(int i=1;i<x+1;i++){
      |     ^~~
a.cc:35:17: error: 'i' does not name a type
   35 |     for(int i=1;i<x+1;i++){
      |                 ^
a.cc:35:23: error: 'i' does not name a type
   35 |     for(int i=1;i<x+1;i++){
      |                       ^
a.cc:39:5: error: 'cout' does not name a type
   39 |     cout << dp(x,w);
      |     ^~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <algorithm>

int prev[1000000000];

int main()
{
    int n,w;
    int value[110];
    int weight[110];
    scanf("%d %d",&n,&w);

    int i,j,k;

    for(i=0;i<n;i++)
        scanf("%d %d", &weight[i], &value[i]);

    memset(prev, 0, sizeof(prev));
    memset(next, 0, sizeof(next));

    for(i=weight[0];i<=w;i++) {
        prev[i] = value[0];
    }


    for(i=2;i<=n;i++) {
        for (j = 0; j <= w; j++) {
            if (j - weight[i - 1] >= 0)
                next[j] = std::max(prev[j - weight[i - 1]] + value[i - 1], prev[j]);
            else next[j] = prev[j];
        }
        for(j=0;j<=w;j++)
            prev[j] = next[j];
    }

    int max = INT_MIN;

    for(i = 1; i<=w; i++)
    {
        if( next[i]> max)
            max = next[i];
    }
    printf("%d \n", max);

    return 0;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'next' was not declared in this scope; did you mean 'std::next'?
   22 |     memset(next, 0, sizeof(next));
      |            ^~~~
      |            std::next
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: 'std::next' declared here
  232 |     next(_InputIterator __x, typename
      |     ^~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <algorithm>

int prev[1000000000];
int next[1000000000];

int main()
{
    int n,w;
    int value[110];
    int weight[110];
    scanf("%d %d",&n,&w);

    int i,j,k;

    for(i=0;i<n;i++)
        scanf("%d %d", &weight[i], &value[i]);

    memset(prev, 0, sizeof(prev));
    memset(next, 0, sizeof(next));

    for(i=weight[0];i<=w;i++) {
        prev[i] = value[0];
    }


    for(i=2;i<=n;i++) {
        for (j = 0; j <= w; j++) {
            if (j - weight[i - 1] >= 0)
                next[j] = std::max(prev[j - weight[i - 1]] + value[i - 1], prev[j]);
            else next[j] = prev[j];
        }
        for(j=0;j<=w;j++)
            prev[j] = next[j];
    }

    int max = INT_MIN;

    for(i = 1; i<=w; i++)
    {
        if( next[i]> max)
            max = next[i];
    }
    printf("%d \n", max);

    return 0;

}



Compiler output:
/tmp/cchxZDWs.o: in function `main':
a.cc:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `next' defined in .bss section in /tmp/cchxZDWs.o
a.cc:(.text+0x191): relocation truncated to fit: R_X86_64_PC32 against symbol `next' defined in .bss section in /tmp/cchxZDWs.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `next' defined in .bss section in /tmp/cchxZDWs.o
a.cc:(.text+0x1f2): relocation truncated to fit: R_X86_64_PC32 against symbol `next' defined in .bss section in /tmp/cchxZDWs.o
a.cc:(.text+0x24d): relocation truncated to fit: R_X86_64_PC32 against symbol `next' defined in .bss section in /tmp/cchxZDWs.o
a.cc:(.text+0x269): relocation truncated to fit: R_X86_64_PC32 against symbol `next' defined in .bss section in /tmp/cchxZDWs.o
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#include <math.h>

double n,max_weight;

int main() {
  scanf("%d%d", &n, &max_weight);
  double weight[n];
  double value[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%lf%lf", &weight[i], &value[i]);
  }
  double dp[n + 1][max_weight + 1];//上からn個目までの価値の最大値
  //初期化
  for (size_t i = 0; i <= max_weight; i++) {
    for (size_t j = 0; j <= n; j++) {
      dp[j][i] = 0;
    }
  }
  //DPなう
  for (size_t i = 0; i < n; i++) {
    for (size_t remain = 0; remain <= max_weight; remain++) {
      dp[i + 1][remain] = fmax(dp[i + 1][remain], dp[i][remain]);
      if(remain >= weight[i]){
        dp[i + 1][remain - (int)weight[i]] = fmax(dp[i][remain] + value[i], dp[i + 1][remain - (int)weight[i]]);
      }
    }
  }
  //最大値の算出
  double max_value;
  for (size_t i = 0; i <= max_weight; i++) {
    max_value = fmax(dp[n][i], max_value);
  }
  //出力
  printf("%lld", (long long int)max_value);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:8:10: error: size of array 'weight' has non-integer type
    8 |   double weight[n];
      |          ^~~~~~
main.c:9:10: error: size of array 'value' has non-integer type
    9 |   double value[n];
      |          ^~~~~
main.c:13:10: error: size of array 'dp' has non-integer type
   13 |   double dp[n + 1][max_weight + 1];//上からn個目までの価値の最大値
      |          ^~
main.c:13:10: error: size of array 'dp' has non-integer type
main.c:32:24: error: array subscript is not an integer
   32 |     max_value = fmax(dp[n][i], max_value);
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INF (2147483647)
#define MAXV (int)1e5+10

int N,W;
vector<int64_t>dp(MAXV,INF);
    
void solve()
{
    cin>>N>>W;
    dp[0]=0;
	REP(i,N){
        int a,b;cin>>a>>b;
        for(int j=MAXV;j>=b;j--)
            dp[j]=min(dp[j],dp[j-b]+a);
    }
    for(int i=dp.size()-1;i>=0;i--)
        if(dp[i]<=W){
            cout<<i<<endl;
            break;
        }
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:13:13: error: 'i' was not declared in this scope
   13 |         REP(i,N){
      |             ^
a.cc:13:9: error: 'REP' was not declared in this scope
   13 |         REP(i,N){
      |         ^~~
Language: C++


#include<bits/stdc++.h> 
#define int long long
using namespace std; 
int KnapSack(int val[], int wt[], int n, int W) 
{ 
	int dp[W+1]; 
	memset(dp, 0, sizeof(dp)); 
	for(int i=0; i < n; i++) 
		for(int j=W; j>=wt[i]; j--) 
			dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
	return dp[W]; 
} 

signed main() 
{ 
    int n, W; cin>>n>>W;
    for(int i=0; i<n; i++)
      cin>>wt[i]>>val[i];
	cout << KnapSack(val, wt, n, W); 
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: 'wt' was not declared in this scope
   19 |       cin>>wt[i]>>val[i];
      |            ^~
a.cc:19:19: error: 'val' was not declared in this scope
   19 |       cin>>wt[i]>>val[i];
      |                   ^~~
a.cc:20:26: error: 'val' was not declared in this scope
   20 |         cout << KnapSack(val, wt, n, W);
      |                          ^~~
a.cc:20:31: error: 'wt' was not declared in this scope
   20 |         cout << KnapSack(val, wt, n, W);
      |                               ^~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
typedef long long ll;

int main(){
	int n, w;
  	cin>>n>>w;
  	ll dp[200005];
  	rep(i, n){
    	int a, b;
      	cin>>a>>b;
      	rrep(j, w-a+1){
        	dp[j+a] = max(dp[j+a], dp[j] + b);
        }
    }
    cout>>dp[w];
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |         cin>>n>>w;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:27: error: 'max' was not declared in this scope; did you mean 'std::max'?
   14 |                 dp[j+a] = max(dp[j+a], dp[j] + b);
      |                           ^~~
      |                           std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:17:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   17 |     cout>>dp[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 <iostream>
#include <bits/stdc++.h>
using namespace std;
int values[150];
int weights[150];
int n ;
map <pair <int,int>, int > dp;
map <pair <int,int> , bool> visited;

int solve(int i,int weight){
    if(weight < 0) {
        return -1e15;
    }
    if(i == n){
        return 0;
    }
    if(visited[{i,weight}]) return dp[{i,weight}];
    visited[{i,weight}] = 1;
    dp[{i,weight}] = max(solve(i+1, weight - weights[i]) + values[i], solve(i+1,weight));
    return dp[{i,weight}];
}

int main()
{
    int w;
    scanf("%lld%lld",&n,&w);
    int x,y;
    for (int i = 0; i < n ;i++){
            scanf("%lld%lld",&x,&y);
            weights[i] = x;
            values[i] = y;
    }
    cout<<solve(0int,w)<<"\n";
    return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:12:16: warning: overflow in conversion from 'double' to 'int' changes value from '-1.0e+15' to '-2147483648' [-Woverflow]
   12 |         return -1e15;
      |                ^~~~~
a.cc: In function 'int main()':
a.cc:33:17: error: unable to find numeric literal operator 'operator""int'
   33 |     cout<<solve(0int,w)<<"\n";
      |                 ^~~~
Language: C++

import java.util.*;

public class Main {
	final int MOD = 100000000;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 100000;
	Scanner sc = new Scanner(System.in);


	void doIt() {
		int N = sc.nextInt();
		int W = sc.nextInt();
		int w[] = new int[N + 1];
		int v[] = new int[N + 1];
		long dp[][] = new long[N + 1][1001];
		for(int i = 1; i <= N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		Arrays.fill(dp[0], (int)1e9 + 1);
		dp[0][0] = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j <= 1000; j++) {
				dp[i][j] = dp[i - 1][j];
				if(j - v[i] >= 0) {
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
				}
			}
		}
		/*for(int i = 0; i <= N; i++) {
			for(int j = 0; j < 150; j++) {
				System.out.println(dp[i][j] + " ");
			}
			System.out.println();
		}*/
		for(int i = 1000; i >= 0; i--) {
			if(dp[N][i] <= W) {
				System.out.println(i);
				return;
			}
		}
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<(int)n;i++)
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
const int maxn = 105;
const int maxw = 1e9 + 5 ;
#define int long long
int dp[maxn][maxw];
int arr[2][maxn];
int32_t main(){
    IOS;
    int n,w;
    cin>>n>>w;
    rep(i,n)
        rep(j,2)
            cin>>arr[j][i];
    memset(dp,0,sizeof(dp));
    for(int i=arr[0][0];i<=w;i++)
        dp[0][i]=arr[1][0];
    int sit=0;
    rep1(i,n){
        rep(j,w+1){
            if(j-arr[0][i]>=0)
                dp[sit^1][j]=max(dp[sit][j],dp[sit][j-arr[0][i]]+arr[1][i]);
            else
                dp[sit^1][j]=dp[sit][j];
        }
        sit^=1;
    }
    cout<<max(dp[sit][w],dp[sit^1][w])<<endl;
    
    return 0;
}

Compiler output:
/tmp/ccrHyi4v.o: in function `main':
a.cc:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccrHyi4v.o
a.cc:(.text+0xe7): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccrHyi4v.o
a.cc:(.text+0xf4): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccrHyi4v.o
a.cc:(.text+0x14f): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccrHyi4v.o
a.cc:(.text+0x176): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccrHyi4v.o
a.cc:(.text+0x1b9): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccrHyi4v.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>

const long long INF = 1e18L+5;

int main(){

    int n, k;
    std::cin >> n >> k;

    std::vector<long long> w;
    std::vector<long long> v;

    for(int i = 0; i < n; i++)
    {
        long long weight, value;
        std::cin >> weight >> value;
        w.push_back(weight);
        v.push_back(value);
    }

    long long sum = 0;
    for(int i = 0; i < n; i++){
        sum += v[i];
    }

    std::vector<int> dp(sum + 5, INF);
    dp[0] = 0;

    for(int i = 0; i < n; i++)
    {
        int x = sum - v[i];
        for(int j = x; j >= 0; j--)
        {
            dp[j+v[i]] = std::min(dp[j]+w[i],dp[j + v[i]]);
        }
    }

    int sol=0;
    for(int i = 0; i <= sum; i++)
    {
        if(k >= dp[i])
        {
            sol = std::max(i,sol);
        }
    }
    std:: cout << sol;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:34: warning: overflow in conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1000000000000000005' to '-1486618619' [-Woverflow]
   27 |     std::vector<int> dp(sum + 5, INF);
      |                                  ^~~
a.cc:35:34: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   35 |             dp[j+v[i]] = std::min(dp[j]+w[i],dp[j + 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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:35:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   35 |             dp[j+v[i]] = std::min(dp[j]+w[i],dp[j + v[i]]);
      |                          ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include<iostream>
using namespace std;

int MAX_V = 100010;
long INF = 1 << 50;

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

Compiler output:
a.cc:5:14: warning: left shift count >= width of type [-Wshift-count-overflow]
    5 | long INF = 1 << 50;
      |            ~~^~~~~
a.cc: In function 'int main()':
a.cc:24:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   24 |     if(dp[i] <= w) max = i;
      |        ~~~~~~^~~~
Language: C++

#include<iostream>
using namespace std;

int MAX_V = 100010;

int main(){
  int n, W;
  cin >> n >> W;
  int w[n];
  int v[n];
  int dp[MAX_V];
  for(int i = 0;i < n;i++)
    cin >> w[i] >> v[i];
  for(int i = 0;i < MAX_V;i++)
    dp[i]=0;
  for(int i = 0;i < n;i++){
    for(int j = MAX_V;j >= v[i];j--){
      dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
    }
  }
  int max;
  for(int i = 0;i < MAX_V;i++){
    if(dp[i] <= w) max = i;
  }
  cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |     if(dp[i] <= w) max = i;
      |        ~~~~~~^~~~
Language: Java

import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String[] hiki = scan.nextLine().split(" ");
    int n = Integer.parseInt(hiki[0]);
    int w = Integer.parseInt(hiki[1]);
    int[] weight = new int[n];
    int[] value = new int[n];
    for(int i = 0;i < n;i ++){
      hiki = scan.nextLine().split(" ");
      weight[i] = Integer.parseInt(hiki[0]);
      value[i] = Integer.parseInt(hiki[1]);
    }
    long[][] dp = new long[n][100010];
    dp[0][value[0]]=weight[0];
    for(int i = 1;i < n;i ++){
      for(int j = 0;j < dp.length[i];j ++){
        if(dp[i-1][j] > 0){
          dp[i][j] = Math.min(dp[i-1][j], dp[i][j]);
          if(dp[i-1][j]+weight[i] <= w)
          	dp[i][j+value[i]] = Math.min(dp[i-1][j] + weight[i], dp[i][j+value[i]]);
        }
      }
      dp[i][value[i]] = Math.min(weight[i], dp[i][weight[i]]);
    }
    long max = 0;
    for(int i = 0;i < 10010;i ++){
      if(dp[n-1][i] > 0) max = i;
    }
    System.out.println(max);
  }
}


Compiler output:
Main.java:19: error: array required, but int found
      for(int j = 0;j < dp.length[i];j ++){
                                 ^
1 error
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {

	uint N, W;
	cin >> N >> W;

	vector<pair<uint, uint>> wv(N);
	for(uint i=0; i<N; i++) {
		uint w, uint v;
		cin >> w >> v;
		wv[i] = make_pair(w, v);
	}

	sort(wv.begin(), wv.end());

	vector<vector<ull>> dp(W+1, vector<ull>(N+1, 0));



	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:30: error: expected initializer before 'v'
   15 |                 uint w, uint v;
      |                              ^
a.cc:16:29: error: 'v' was not declared in this scope
   16 |                 cin >> w >> v;
      |                             ^
Language: C++

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

using namespace std;
int MAXV = 0;
auto M = INT_MAX/10;
int main()
{
	int N, W;
	cin >> N >> W;
	vector<int>w(N + 1), v(N + 1);
	
	for (int k = 0; k < N; k++)
	{

		cin >> w[k] >> v[k];
		MAXV += v[k];
	}
	vector<vector<int>> dp(N + 1, vector<int>(MAXV+1));
	for (int k = 0; k <= MAXV; k++)
	{
		dp[0][k] = M;
	}

	dp[0][0] = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= MAXV; j++)
		{
			if (j < v[i])
				dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
		}
	}
	int res = 0;
	for (int i = 0; i <= MAXV; i++)
	{
		if (dp[N][i] <= W)
		{
			res = i;
		}
	}
	cout << res;
}




Compiler output:
a.cc:7:10: error: 'INT_MAX' was not declared in this scope
    7 | auto M = INT_MAX/10;
      |          ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18L + 5;
int32_t main()
{
 int n, W;
  cin>>n>>W;
  vector<int> weight(n);
  vector<int> value(n);
  int sum_value = 0;
  for(int i=0; i<n; i++){
    	cin>>weight[i]>>value[i];
    	sum_value += value[i];
  }
  vector<int> dp(sum_value + 1, INF);
  for(int item =0; item < n; item++){
    for(int j = sum_value; j>=value[item]; j--){
      dp[j] = min(dp[j], dp[j-value[item]] + weight[item]);
    }
  }
 int ans = 0;
 for(int i=0; i<=sum_value; i++){
   if( dp[i] <=W)
     	ans = max(ans, i);
   cout<<ans;
 }

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:27:3: error: expected '}' at end of input
   27 |  }
      |   ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

#include<bits/stdc++.h>
#define ll  long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define f(i,n)   for(long long i=0;i<n;i++)
#define INF 1e9+5
#define LINF 1e18L+5;
#define pb push_back
#define mk make_pair
using namespace std;
/************************BELIAL**********DEVIL*********BELIAL***********DEVIL*************************/
void min_self(long long &a,long long b)
{
  a= min(dpea,b);
  return;

}
int main()
{
    int n,w;

    cin>>n>>w;


    vector<int> wt(n),val(n);

     for(int i=0;i<n;i++)
     {
        cin>>wt[i]>>val[i];	
     }
   
   int tval=0;

   for(int i=0;i<n;i++)
   	 tval+= val[i];

  vector<ll> dp(tval+1, INF);  // dp[i] stores min wt having value exactly equal to i,INF initialisn makes that sure.
  dp[0]=0;                     // if its not possible to make val i then dp[i] will have inf
   	for(int item =0;item<n;item++)
   	{
        
       for(int value_already=tval-val[item];value_already>=0;value_already--)
       {

             min_self(dp[value_already+ val[item]],dp[value_already]+wt[item]);



       }
   	}

  int ans=0;

  for(int i=0;i<=tval;i++)
  {
     if(dp[i]<=w)
     	  ans= max(ans,i);

  } 

  cout<<ans;


}

Compiler output:
a.cc: In function 'void min_self(long long int&, long long int)':
a.cc:14:10: error: 'dpea' was not declared in this scope
   14 |   a= min(dpea,b);
      |          ^~~~
Language: Java

import java.util.Scanner;

public class Main {

    private static long[][] dp;
    private static int[] w;
    private static int[] v;

    public static void main( String[] args ) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long w1 = sc.nextLong();

        dp = new long[n + 1][(int)w1];
        w = new int[n + 1];
        v = new int[n + 1];

        w[0] = 0;
        v[0] = 0;

        for (int i = 1; i <= n; i++) {
            w[i] = Integer.parseInt(sc.next());
            v[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= w1; j++) {
                dp[i][j] = -1;
            }
        }

        System.out.println(nap(n, w1));
        sc.close();
    }

    private static long nap( int i, long j ) {
        if (dp[i][j] >= 0)
            return dp[i][j];

        long rem;

        if (i == 0) {
            rem = 0;
        }
        //if weight of item is more than remainingWeight then try next item by skipping current item
        else if (j < w[i]) {
            rem = nap(i - 1, j);
        } else {  //try to get maximumValue of either by picking the currentItem or not picking currentItem
            rem = Math.max(nap(i - 1, j - w[i]) + v[i], nap(i - 1, j));
        }

        dp[i][j] = rem;

        return rem;
    }
}

Compiler output:
Main.java:38: error: incompatible types: possible lossy conversion from long to int
        if (dp[i][j] >= 0)
                  ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
            return dp[i][j];
                         ^
Main.java:53: error: incompatible types: possible lossy conversion from long to int
        dp[i][j] = rem;
              ^
3 errors