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

#include<iostream>
#include<algorithm>
#include<array>

using namespace std;

const int maxnum=100;

int dp[maxnum][maxnum] = { { -1 } };

array<int> W(maxnum);
array<int> V(maxnum);

void solve(int N, int limit){
	for (int a = N - 1; a >= 0; a--){
		for (int j = 0; j <= limit;j++){
			if (j < W[a])dp[a][j] = dp[a + 1][j];
			else{
				dp[a][j] = max(dp[a + 1][j], dp[a + 1][j - W[a]] + V[a]);
			}
		}
	}
}

int main(){
	int N, limit;
	cin >> N >> limit;
	for (int k = 0; k < N; k++){
		cin >> V[k] >> W[k];
	}
	solve(N, limit);
	cout << dp[0][limit] << endl;

}

Compiler output:
a.cc:11:10: error: wrong number of template arguments (1, should be 2)
   11 | array<int> W(maxnum);
      |          ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:99:12: note: provided for 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:12:10: error: wrong number of template arguments (1, should be 2)
   12 | array<int> V(maxnum);
      |          ^
/usr/include/c++/14/bits/stl_pair.h:99:12: note: provided for 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc: In function 'void solve(int, int)':
a.cc:17:34: error: invalid types 'int[int]' for array subscript
   17 |                         if (j < W[a])dp[a][j] = dp[a + 1][j];
      |                                  ^
a.cc:19:77: error: invalid types 'int[int]' for array subscript
   19 |                                 dp[a][j] = max(dp[a + 1][j], dp[a + 1][j - W[a]] + V[a]);
      |                                                                             ^
a.cc:19:85: error: invalid types 'int[int]' for array subscript
   19 |                                 dp[a][j] = max(dp[a + 1][j], dp[a + 1][j - W[a]] + V[a]);
      |                                                                                     ^
a.cc: In function 'int main()':
a.cc:29:25: error: invalid types 'int[int]' for array subscript
   29 |                 cin >> V[k] >> W[k];
      |                         ^
a.cc:29:33: error: invalid types 'int[int]' for array subscript
   29 |                 cin >> V[k] >> W[k];
      |                                 ^
Language: C++

#include <stdio.h>
#include <algorithm>

const int MAX_N=100;
const int MAX_W=10000;
int w[MAX_N];
int v[MAX_N];
int dp[MAX_N][MAX_W+1];
int n,W;

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

}

Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:23:21: error: 'max' was not declared in this scope; did you mean 'std::max'?
   23 |                 res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);
      |                     ^~~
      |                     std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/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: In function 'int main()':
a.cc:32:9: error: 'memset' was not declared in this scope
   32 |         memset(dp,-1,sizeof(dp));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 |
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;

const int MAX_N=100;
const int MAX_W=10000;
int w[MAX_N];
int v[MAX_N];
int dp[MAX_N][MAX_W+1];
int n,W;

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

}

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

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

const int MAX_N=100;
const int MAX_W=10000;
int dp[MAX_N+1][MAX_W+1];
int w[MAX_N];
intv[MAX_N];

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

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

   }
}
}
printf("%d\n",dp[0][W]);
return 0;
}

Compiler output:
a.cc:13:16: warning: missing terminating " character
   13 |     scanf(%d %d",&n,&W);
      |                ^
a.cc:13:16: error: missing terminating " character
   13 |     scanf(%d %d",&n,&W);
      |                ^~~~~~~~~
a.cc:9:1: error: 'intv' does not name a type; did you mean 'int'?
    9 | intv[MAX_N];
      | ^~~~
      | int
a.cc: In function 'int main()':
a.cc:13:11: error: expected primary-expression before '%' token
   13 |     scanf(%d %d",&n,&W);
      |           ^
a.cc:13:12: error: 'd' was not declared in this scope
   13 |     scanf(%d %d",&n,&W);
      |            ^
a.cc:14:17: error: 'i' was not declared in this scope
   14 |     for(int i=0;i<n;i++){
      |                 ^
a.cc:24:44: error: 'v' was not declared in this scope
   24 |      dp[i][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |                                            ^
a.cc:24:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |      dp[i][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |               ^~~
      |               std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

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

const int MAX_N=100;
const int MAX_W=10000;
int dp[MAX_N+1][MAX_W+1];
int w[MAX_N];
int v[MAX_N];

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

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

   }
}
}
printf("%d\n",dp[0][W]);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |      dp[i][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |               ^~~
      |               std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include <stdio.h>
int rec(int i, int j);
int mymax(int a, int b);
int w[100];//??°?????????????????°
int v[100];
int n;
int main(void)
{
	int W;
	int i, j = 1;
	printf("put number:n=?\n");//??\???
	scanf_s("%d", &n);
	for (i = 0; i<n; i++){
		printf("weight:w[%d]=?\n", j);
		scanf_s("%d", &w[i]);
		printf("value:v[%d]=?\n", j);
		scanf_s("%d", &v[i]);
		j++;
	}
	printf("limit weight:W=?\n");
	scanf_s("%d", &W);
	printf("max value=%d\n", rec(0, W));
}

int rec(int i, int j)//i????????\????????????????????????????????????j??\??????????????????????????¶
{
	int res;
	if (i == n){
		res = 0;
		//????????????????????£????????????
	}
	else if (j < w[i]){
		res = rec(i + 1, j);
		//?????????????????\?????????
	}
	else{
		res = mymax(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
		//??\????????´?????¨??\???????????´?????????????????????

	}
	return res;
}
//?????§????????????
int mymax(int a, int b){
	int max;
	max = a;
	if (max<b)max = b;
	return max;
}

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

import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int WW = Integer.parseInt(sc.next());
    int[] v = new int[N+1];
    int[] w = new int[N+1];
    for(int i=1; i<N+1; i++){
      v[i] = Integer.parseInt(sc.next());
      w[i] = Integer.parseInt(sc.next());
    }

    int[][] dp = new int[N+1][WW+1];
    for(int i=1; i<N+1; i++){
        dp[i][0] = 0;
    }
  
    for (int i=1; i<=N; i++) {
      for (int W=1; W<=WW; W++) {
        if(W>=w[i]){
            dp[i][W] = Math.max(dp[i-1][W], dp[i-1][W-w[i]] + v[i]);
        }else{
          dp[i][W] = dp[i-1][WW];
        }
      
      }
    }

    Systm.out.println(dp[N][W]);
  }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
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 <stdio.h>
#include <algorithm>
int MAX_N=100;
int MAX_W=10000;
int N,W;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N+1][MAX_W+1];/*dp[n???????????§?????????][??????w?????§]*/
void solve(){ 
   for(int i=0;i<N;i++){
       for(int j=0;j<W;j++){
              if(j<w[i]){/*???????????????n??????????????????????????¶????????????w????°????????????°??\???????????¨?????§?????????*/
            dp[i+1][j]=dp[i][j];/*dp[n+1???????????§][??????w?????§]???[n???????????§][??????w?????§]?????£??\*/
                        }
                else{
             dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);/*dp[n???????????§][??¶???-??\????????????]*/
,
                   }
           }
   }

      }
int main(){
     scanf("%d%d",&N,&W);
     for(int i=0;i<N;i++){
         scanf("%d%d",&v[i],&w[i]);
         dp[i][0]=0;
         }
solve();
printf("%d\n",dp[N][W]);
return 0;
}

Compiler output:
a.cc:6:7: error: size of array 'v' is not an integral constant-expression
    6 | int v[MAX_N];
      |       ^~~~~
a.cc:7:7: error: size of array 'w' is not an integral constant-expression
    7 | int w[MAX_N];
      |       ^~~~~
a.cc:8:22: error: size of array 'dp' is not an integral constant-expression
    8 | int dp[MAX_N+1][MAX_W+1];/*dp[n???????????§?????????][??????w?????§]*/
      |                 ~~~~~^~
a.cc:8:13: error: size of array 'dp' is not an integral constant-expression
    8 | int dp[MAX_N+1][MAX_W+1];/*dp[n???????????§?????????][??????w?????§]*/
      |        ~~~~~^~
a.cc: In function 'void solve()':
a.cc:16:25: error: 'max' was not declared in this scope; did you mean 'std::max'?
   16 |              dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);/*dp[n???????????§][??¶???-??\????????????]*/
      |                         ^~~
      |                         std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/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:1: error: expected primary-expression before ',' token
   17 | ,
      | ^
a.cc:18:20: error: expected primary-expression before '}' token
   18 |                    }
      |                    ^
Language: C++

#include <stdio.h>
#include <algorithm>
const int MAX_N=100;
const int MAX_W=10000;
int N,W;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N+1][MAX_W+1];
void solve(){ 
   for(int i=0;i<N;i++){
       for(int j=0;j<W;j++){
              if(j<w[i]){
            dp[i+1][j]=dp[i][j];
                        }
                else{
             dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                   }
           }
   }

      }
int main(){
     scanf("%d%d",&N,&W);
     for(int i=0;i<N;i++){
         scanf("%d%d",&v[i],&w[i]);
         dp[i][0]=0;
         }
solve();
printf("%d\n",dp[N][W]);
return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:16:25: error: 'max' was not declared in this scope; did you mean 'std::max'?
   16 |              dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      |                         ^~~
      |                         std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
const int MAX_N=100;
const int MAX_W=10000;
int N,W;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N+1][MAX_W+1];
void solve(){ 
   for(int i=0;i<n;i++){
       for(int j=0;j<w;j++){
              if(j<w[i]){
            dp[i+1][j]=dp[i][j];
                        }
                else{
             dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                   }
           }
   }

      }
int main(){
     scanf("%d%d",&N,&W);
     for(int i=0;i<N;i++){
         scanf("%d%d",&v[i],&w[i]);
         dp[i][0]=0;
         }
solve();
printf("%d\n",dp[N][W]);
return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:11:18: error: 'n' was not declared in this scope
   11 |    for(int i=0;i<n;i++){
      |                  ^
a.cc:12:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |        for(int j=0;j<w;j++){
      |                    ~^~
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
const int MAX_N=100;
const int MAX_W=10000;
int n,w;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N+1][MAX_W+1];
void solve(){ 
   for(int i=0;i<n;i++){
       for(int j=0;j<w;j++){
              if(j<w[i]){
            dp[i+1][j]=dp[i][j];
                        }
                else{
             dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                   }
           }
   }

      }
int main(){
     scanf("%d%d",&n,&w);
     for(int i=0;i<N;i++){
         scanf("%d%d",&v[i],&w[i]);
         dp[i][0]=0;
         }
solve();
printf("%d\n",dp[N][W]);
return 0;
}

Compiler output:
a.cc:8:5: error: conflicting declaration 'int w [100]'
    8 | int w[MAX_N];
      |     ^
a.cc:6:7: note: previous declaration as 'int w'
    6 | int n,w;
      |       ^
a.cc: In function 'void solve()':
a.cc:13:21: error: invalid types 'int[int]' for array subscript
   13 |               if(j<w[i]){
      |                     ^
a.cc:17:47: error: invalid types 'int[int]' for array subscript
   17 |              dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      |                                               ^
a.cc: In function 'int main()':
a.cc:25:20: error: 'N' was not declared in this scope
   25 |      for(int i=0;i<N;i++){
      |                    ^
a.cc:26:31: error: invalid types 'int[int]' for array subscript
   26 |          scanf("%d%d",&v[i],&w[i]);
      |                               ^
a.cc:30:18: error: 'N' was not declared in this scope
   30 | printf("%d\n",dp[N][W]);
      |                  ^
a.cc:30:21: error: 'W' was not declared in this scope
   30 | printf("%d\n",dp[N][W]);
      |                     ^
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
const int MAX_N=100;
const int MAX_W=10000;
int n,w;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N+1][MAX_W+1];
void solve(){ 
   for(int i=0;i<n;i++){
       for(int j=0;j<w;j++){
              if(j<w[i]){
            dp[i+1][j]=dp[i][j];
                        }
                else{
             dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                   }
           }
   }

      }
int main(){
     scanf("%d%d",&n,&w);
     for(int i=0;i<n;i++){
         scanf("%d%d",&v[i],&w[i]);
         dp[i][0]=0;
         }
solve();
printf("%d\n",dp[n][w]);
return 0;
}

Compiler output:
a.cc:8:5: error: conflicting declaration 'int w [100]'
    8 | int w[MAX_N];
      |     ^
a.cc:6:7: note: previous declaration as 'int w'
    6 | int n,w;
      |       ^
a.cc: In function 'void solve()':
a.cc:13:21: error: invalid types 'int[int]' for array subscript
   13 |               if(j<w[i]){
      |                     ^
a.cc:17:47: error: invalid types 'int[int]' for array subscript
   17 |              dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      |                                               ^
a.cc: In function 'int main()':
a.cc:26:31: error: invalid types 'int[int]' for array subscript
   26 |          scanf("%d%d",&v[i],&w[i]);
      |                               ^
Language: C++

#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
typedef basic_ofstream<char>;

int main() {
	int dp[100][10000] = {}, W, N, i, j, w[100], v[100];
	cin >> N >> W;
	for (i = 0; i < N; i++) cin >> v[i] >> w[i];
	for (i = 1; i < N; i++){
		for (j = 1; j < W; j++) {
			if (j >= w[i])
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[i][j] << endl;

	ofstream ofs("test.txt");
	if (!ofs) cout << " hhhhh" << endl;
	ofs << dp[i][j] << endl;
}

Compiler output:
a.cc:5:9: error: declaration does not declare anything [-fpermissive]
    5 | typedef basic_ofstream<char>;
      |         ^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
typedef long long int;

#define INF INT_MAX / 3
#define LINF LLONG_MAX / 3

/*
 * ???????????§????????????????????????
 */

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

    dp[0][0] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=sumv;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 ans = 0;
    for(int i=0;i<=sumv;i++) if(dp[N][i]<=W) ans = i;
    cout << ans << endl;
}

Compiler output:
a.cc:6:19: error: declaration does not declare anything [-fpermissive]
    6 | typedef long long int;
      |                   ^~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int n, m, v[100], w[100];
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= n; i++) {
		dp[i][j] = dp[i - 1][j];
		for(int j = 1; j <= w; j++) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
	}
	cout << dp[n][w] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: 'dp' was not declared in this scope
    9 |                 dp[i][j] = dp[i - 1][j];
      |                 ^~
a.cc:9:23: error: 'j' was not declared in this scope
    9 |                 dp[i][j] = dp[i - 1][j];
      |                       ^
a.cc:10:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |                 for(int j = 1; j <= w; j++) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      |                                ~~^~~~
a.cc:12:17: error: 'dp' was not declared in this scope
   12 |         cout << dp[n][w] << endl;
      |                 ^~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int n, m, v[100], w[100], dp[102][10007];
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= n; i++) {
		dp[i][j] = dp[i - 1][j];
		for(int j = 1; j <= w; j++) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
	}
	cout << dp[n][w] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:23: error: 'j' was not declared in this scope
    9 |                 dp[i][j] = dp[i - 1][j];
      |                       ^
a.cc:10:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |                 for(int j = 1; j <= w; j++) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      |                                ~~^~~~
a.cc:12:22: error: invalid types 'int [10007][int [100]]' for array subscript
   12 |         cout << dp[n][w] << endl;
      |                      ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int n, m, v[100], w[100], dp[102][10007];
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= w; j++) {
			dp[i][j] = dp[i - 1][j];
			dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
		}
	}
	cout << dp[n][w] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |                 for(int j = 1; j <= w; j++) {
      |                                ~~^~~~
a.cc:14:22: error: invalid types 'int [10007][int [100]]' for array subscript
   14 |         cout << dp[n][w] << endl;
      |                      ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int n, m, v[100], w[100], dp[102][10007];
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			dp[i][j] = dp[i - 1][j];
			dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
		}
	}
	cout << dp[n][w] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: invalid types 'int [10007][int [100]]' for array subscript
   14 |         cout << dp[n][w] << endl;
      |                      ^
Language: C++

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

using namespace std;

const int MAX_N = 100;
const int MAX_W = 10000;

int VS[MAX_N+1];
int WS[MAX_N+1];
int X[MAX_N+1][MAX_W+1];

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

  for (int i = 1; i <= n; i++)
    cin >> VS[i] >> WS[i];

  memset(X, 0, sizeof(X));

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= w; j++) {
      if (WS[i] <= j)
        X[i][j] = max(X[i-1][j], X[i-1][j-WS[i]] + VS[i]);
      else
        X[i][j] = X[i-1][j];
    }
  }

  cout << X[n][w] << endl;
}
~ 

Compiler output:
a.cc:33:2: error: expected class-name at end of input
   33 | ~
      |  ^
Language: C++

//????????????????????????(?????¢????????°???????????§???)

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

int n,W;
int w[10010], v[101];
bool iscalc[10010][101];
int dp[10010][101];
memset(dp,-1,sizeof(dp));

int solve(int a, int b) { //a: ??????????????§??\????????? b:????????????
    if(dp[a][b]>=0) return dp[a][b];
    int res;
    if(a==n) res = 0;
    else if(b < w[a]) res = solve(a+1,b);
    else res = max(solve(a+1,b),solve(a+1,b-w[a]));
    return dp[a][b] = res;
}

int main() {
    cin >> n >> W;
    rep(i,0,n) {
        cin >> v[i];
        cin >> w[i];
    }

    cout << solve(0,W) << endl;
    return 0;
}

Compiler output:
a.cc:11:7: error: expected constructor, destructor, or type conversion before '(' token
   11 | memset(dp,-1,sizeof(dp));
      |       ^
Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100

int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N+1][MAX_N+1];

int dfs(int i, int j){
  if(dp[i][j] >= 0) return dp[i][j];
  int res;
  if(i == n) res = 0;
  else if(j < w[i]) res = dfs(i+1, j);
  else res =  max(dfs(i+1, j), dfs(i+1, j-w[i]) + v[i]);
  return dp[i][j] = res;
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d%d", w+i, v+i);
  scanf("%d", &W);
  memset(dp, -1, sizeof(dp));
  printf("%d\n", dfs(0, W));
  return 0;
}

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

#include <iostream>

using namespace std;

int memo[100][10001];
int value[100];
int weight[100];
int NEGA_INF = -10000000;

int dp(int k, int w) {
    if (w < 0) { return NEGA_INF; }
    if (k == -1 || w < 0) { return 0; }
    if (memo[k][w] != -1) { return memo[k][w]; }
    return memo[k][w] = max(
            dp(k - 1, w - weight[k]) + value[k],
            dp(k - 1, w));
}

int main() {
    int n, w;
    cin >> n >> w;
    for (int i = 0; i < n; ++i) {
        cin >> value[i] >> weight[i];
    }
    memset(memo, -1, sizeof(memo));
    cout << dp(n - 1, w) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'memset' was not declared in this scope
   25 |     memset(memo, -1, sizeof(memo));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX]
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (C[i-1][j-items[N].weight] + items[N].value > C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return c[N][W]
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute();
    return 0;
}

Compiler output:
a.cc:3:9: error: #include expects "FILENAME" or <FILENAME>
    3 | #include
      |         ^
a.cc:20:1: error: expected initializer before 'int'
   20 | int N, W;
      | ^~~
a.cc: In function 'int compute()':
a.cc:23:25: error: 'W' was not declared in this scope
   23 |     for (int i = 0; i < W; ++i)
      |                         ^
a.cc:29:25: error: 'N' was not declared in this scope
   29 |     for (int i = 0; i < N; ++i)
      |                         ^
a.cc:34:26: error: 'N' was not declared in this scope
   34 |     for (int i = 1; i <= N; ++i)
      |                          ^
a.cc:36:30: error: 'W' was not declared in this scope
   36 |         for (int j = 1; j <= W; ++j)
      |                              ^
a.cc:45:12: error: 'c' was not declared in this scope
   45 |     return c[N][W]
      |            ^
a.cc:45:14: error: 'N' was not declared in this scope
   45 |     return c[N][W]
      |              ^
a.cc:45:17: error: 'W' was not declared in this scope
   45 |     return c[N][W]
      |                 ^
a.cc:45:19: error: expected ';' before '}' token
   45 |     return c[N][W]
      |                   ^
      |                   ;
   46 | }
      | ~                  
a.cc: In function 'void input()':
a.cc:49:12: error: 'N' was not declared in this scope
   49 |     cin >> N >> W;
      |            ^
a.cc:49:17: error: 'W' was not declared in this scope
   49 |     cin >> N >> W;
      |                 ^
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value > C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute();
    return 0;
}

Compiler output:
/tmp/cc29IbhG.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc29IbhG.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc29IbhG.o
/tmp/cc29IbhG.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute();
    return 0;
}

Compiler output:
/tmp/cc77zjjv.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc77zjjv.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc77zjjv.o
/tmp/cc77zjjv.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute();
    return 0;
}

Compiler output:
/tmp/ccD6tqPt.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccD6tqPt.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccD6tqPt.o
/tmp/ccD6tqPt.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute() << endl;
    return 0;
}

Compiler output:
/tmp/ccFBnMbw.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccFBnMbw.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFBnMbw.o
/tmp/ccFBnMbw.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute() << endl;
}

Compiler output:
/tmp/ccoUHPO6.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccoUHPO6.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccoUHPO6.o
/tmp/ccoUHPO6.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute() << endl;
}

Compiler output:
/tmp/ccve3g7K.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccve3g7K.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccve3g7K.o
/tmp/ccve3g7K.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute() << endl;
}

Compiler output:
/tmp/ccZkMi2K.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccZkMi2K.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccZkMi2K.o
/tmp/ccZkMi2K.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

#define WMAX 100005
#define NMAX 100005
#define DIAGONAL 1
#define TOP 0


struct Item
{
    int value, weight;
};

Item items[NMAX];
int C[NMAX][WMAX], G[NMAX][WMAX];
int N, W;

int compute(){
    for (int i = 0; i < W; ++i)
    {
        C[0][i] = 0;
        // G[0][i] = 0;
    }

    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 0;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            if (j <= items[j].weight) continue; 
            if (C[i-1][j-items[N].weight] + items[N].value >= C[N-1][W]) {
                C[i][j] = C[i-1][j-items[i].weight] + items[i].value;
            } else {
                C[i][j] = C[i-1][j];
            }
        }
    }
    return C[N][W];
}

void input(){
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
    {
        cin >> items[i+1].value >> items[i+1].weight;
    }
}

int main(){
    input();
    cout << compute() << endl;
}

Compiler output:
/tmp/cc5qMNsF.o: in function `compute()':
a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x21f): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5qMNsF.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc5qMNsF.o
/tmp/cc5qMNsF.o: in function `input()':
a.cc:(.text+0x279): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status