Language: C++

#include <iostream>
#include <vector>

using namesapce std;

int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
	
  if(index >= v.size() or W <= 0)return 0;
  
  if(memo[index][W] != -1)return memo[index][W];
  
  if(w[index] <= W){
  	memo[index][W] = max(v[index] + helper(v, w, W - w[index], memo, index + 1),
                         helper(v, w, W, memo, index + 1));
  }
  return memo[index][W];
}

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
  
  vector<vector<int>> memo(N, vector<int>(W+1, -1));
  
  return helper(v, w, W, memo, 0);
  
}
  

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namesapce'
    4 | using namesapce std;
      |       ^~~~~~~~~
a.cc:6:12: error: 'vector' was not declared in this scope
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |            ^~~~~~
a.cc:6:12: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:19: error: expected primary-expression before 'int'
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                   ^~~
a.cc:6:28: error: 'vector' was not declared in this scope
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                            ^~~~~~
a.cc:6:28: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:35: error: expected primary-expression before 'int'
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                   ^~~
a.cc:6:44: error: expected primary-expression before 'int'
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                            ^~~
a.cc:6:51: error: 'vector' was not declared in this scope
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                                   ^~~~~~
a.cc:6:51: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:58: error: 'vector' was not declared in this scope
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                                          ^~~~~~
a.cc:6:58: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:65: error: expected primary-expression before 'int'
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                                                 ^~~
a.cc:6:78: error: expected primary-expression before 'int'
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                                                              ^~~
a.cc:6:87: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | int helper(vector<int>& v, vector<int>& w, int W, vector<vector<int>>& memo, int index){
      |                                                                                       ^
a.cc: In function 'int main()':
a.cc:22:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |   cin >> N >> W;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:24:3: error: 'vector' was not declared in this scope
   24 |   vector<int> v(N);
      |   ^~~~~~
a.cc:24:3: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:24:10: error: expected primary-expression before 'int'
   24 |   vector<int> v(N);
      |          ^~~
a.cc:25:10: error: expected primary-expression before 'int'
   25 |   vector<int> w(N);
      |          ^~~
a.cc:27:37: error: 'v' was not declared in this scope
   27 |   for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
      |                                     ^
a.cc:27:45: error: 'w' was not declared in this scope
   27 |   for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
      |                                             ^
a.cc:29:17: error: expected primary-expression before 'int'
   29 |   vector<vector<int>> memo(N, vector<int>(W+1, -1));
      |                 ^~~
a.cc:31:17: error: 'v' was not declared in this scope
   31 |   return helper(v, w, W, memo, 0);
      |                 ^
a.cc:31:20: error: 'w' was not declared in this scope
   31 |   return helper(v, w, W, memo, 0);
      |                    ^
a.cc:31:26: error: 'memo' was not declared in this scope
   31 |   return helper(v, w, W, memo, 0);
      |                          ^~~~
a.cc:31:16: error: 'helper' cannot be used as a function
   31 |   return helper(v, w, W, memo, 0);
      |          ~~~~~~^~~~~~~~~~~~~~~~~~