Language: C++

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
  
using namespace std;
  
#define pb(n)   push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi  first
#define se  second
#define all(r) (r).begin(),(r).end()
  
#define REP(i,s,e)  for(int i=(s); i<(e); i++)
#define rep(i,n)    REP(i,0,n)
#define REPE(i,s,e) for(int i=s; i>e; i--)
#define repe(i,n)   REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
  
typedef vector<vi> vvi;
  
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 
 
 
const int MAX_N = 1000;
const int MAX_W = 200000000;
 
// int dp[MAX_N + 1][MAX_W + 1][5];
// int v[MAX_N], w[MAX_N];
// int N,W;
 
 
// int solve() {
//     for(int i = 0; i < N; i++) {
//         for(int j = 0; j <= W; j++){
//             for(int k = 0; k < 5; k++){
//                 if(j < w[i] || k <1) {
//                     dp[i + 1][j][k] = dp[i][j][k];
//                 }
//                 else{
//                     dp[i + 1][j][k] = max(/*max(*/dp[i][j][k]/*,dp[i][j-w[i]][k-1] + v[i])*/, dp[i + 1][j - w[i]][k-1] + v[i]);
//                 }
//             }
//         }
//     }
//     return dp[N][W][4];
// }

int dp[MAX_W + 1][5];

int solve(){
	for(int i = 0; i < N; i++){
		for(int j = w[i]; j <= W; j++){
			for(int k = 0; k < 5; k++){
				if(k>=1)dp[j][k] = max(dp[j][k], dp[j-w[i]][k-1] + v[i]);
			}
		}
	}
}
 
int main(){
    int n, m;
    while(cin>>n>>m){
        N = n;
        W = m;
        for(int i = 0; i < n; i++){
            cin >> v[i];
            w[i] = v[i];
        }
        cout<<solve()<<endl;
    }
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:73:28: error: 'N' was not declared in this scope
   73 |         for(int i = 0; i < N; i++){
      |                            ^
a.cc:74:29: error: 'w' was not declared in this scope
   74 |                 for(int j = w[i]; j <= W; j++){
      |                             ^
a.cc:74:40: error: 'W' was not declared in this scope
   74 |                 for(int j = w[i]; j <= W; j++){
      |                                        ^
a.cc:76:84: error: 'v' was not declared in this scope
   76 |                                 if(k>=1)dp[j][k] = max(dp[j][k], dp[j-w[i]][k-1] + v[i]);
      |                                                                                    ^
a.cc:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
   80 | }
      | ^
a.cc: In function 'int main()':
a.cc:85:9: error: 'N' was not declared in this scope
   85 |         N = n;
      |         ^
a.cc:86:9: error: 'W' was not declared in this scope
   86 |         W = m;
      |         ^
a.cc:88:20: error: 'v' was not declared in this scope
   88 |             cin >> v[i];
      |                    ^
a.cc:89:13: error: 'w' was not declared in this scope
   89 |             w[i] = v[i];
      |             ^