Language: C++

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

//State
//dp[i][j]: The maximum value of items we can take when there are 
//	only first j items available and knapsack can carry atmost i kg's 

//Initialization
//if W[0] <= i then dp[i][0]=V[0] else dp[i][1]=0

//Transitions: Either we put the j-th item in knapsack or we exclude it
//dp[i][j] = max(dp[i-W[j]][j-1], dp[i][j-1])

//Order of evaluation
//Row wise or Column Wise

//Answer
//dp[W][N-1]
using ll = long long;

ll dp[100005];
int W[100005];
int V[100005];

int main(){
	cin >> N >> W;
	for(int i=0; i<N; i++){
		cin >> W[i] >> V[i];
	}
	//Intializing fist row
	for(int j=0; j<N; j++){
		dp[0][i] = 0;
	}
	//Intializing the first column
	for(int i=0; i<=W; i++){
		if(i>=V[0]) dp[i][0] = W[0];
		else dp[i][0] = 0;
	}
	//Evaluation Order and Transitions
	for(int i=1; i<=W; i++){
		for(int j=0; j<N; j++){
			if(i-W[j]>=0){
				dp[i][j] = max(dp[i-W[j]][j-1]+V[j], dp[i][j-1]);
			}
			else{
				dp[i][j] = dp[i][j-1];
			}
		}
	}
	cout << dp[W][N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:16: error: 'N' was not declared in this scope
   28 |         cin >> N >> W;
      |                ^
a.cc:34:23: error: 'i' was not declared in this scope
   34 |                 dp[0][i] = 0;
      |                       ^
a.cc:37:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |         for(int i=0; i<=W; i++){
      |                      ~^~~
a.cc:38:34: error: invalid types 'll {aka long long int}[int]' for array subscript
   38 |                 if(i>=V[0]) dp[i][0] = W[0];
      |                                  ^
a.cc:39:27: error: invalid types 'll {aka long long int}[int]' for array subscript
   39 |                 else dp[i][0] = 0;
      |                           ^
a.cc:42:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   42 |         for(int i=1; i<=W; i++){
      |                      ~^~~
a.cc:45:38: error: invalid types 'll {aka long long int}[int]' for array subscript
   45 |                                 dp[i][j] = max(dp[i-W[j]][j-1]+V[j], dp[i][j-1]);
      |                                      ^
a.cc:45:58: error: invalid types 'll {aka long long int}[int]' for array subscript
   45 |                                 dp[i][j] = max(dp[i-W[j]][j-1]+V[j], dp[i][j-1]);
      |                                                          ^
a.cc:45:75: error: invalid types 'll {aka long long int}[int]' for array subscript
   45 |                                 dp[i][j] = max(dp[i-W[j]][j-1]+V[j], dp[i][j-1]);
      |                                                                           ^
a.cc:48:38: error: invalid types 'll {aka long long int}[int]' for array subscript
   48 |                                 dp[i][j] = dp[i][j-1];
      |                                      ^
a.cc:48:49: error: invalid types 'll {aka long long int}[int]' for array subscript
   48 |                                 dp[i][j] = dp[i][j-1];
      |                                                 ^
a.cc:52:19: error: invalid types 'll [100005] {aka long long int [100005]}[int [100005]]' for array subscript
   52 |         cout << dp[W][N-1] << endl;
      |                   ^