Language: C++

#include <bits/stdc++.h>
int main(){
  int n,c;
  cin>>n>>c;
  vector<int> w(n);
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>w[i];
  for(int i=0;i<n;i++) cin>>v[i];
  vector<vector<int>> k(n+1)(c+1);
  for (int i = 0; i <= n; i++) 
   { 
       for (int j = 0; j<=c; j++) 
       { 
           if (i==0 || j==0) 
               k[i][j] = 0; 
           else if (w[i-1] <= j) 
                 k[i][j] = max(v[i-1] + k[i-1][j-w[i-1]],  k[i-1][j]); 
           else
                 k[i][j] = k[i-1][j]; 
       } 
   } 
   cout<<k[n][c];
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   cin>>n>>c;
      |   ^~~
      |   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:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> w(n);
      |   ^~~~~~
a.cc:5:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/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:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> w(n);
      |          ^~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> v(n);
      |          ^~~
a.cc:7:29: error: 'w' was not declared in this scope
    7 |   for(int i=0;i<n;i++) cin>>w[i];
      |                             ^
a.cc:8:29: error: 'v' was not declared in this scope
    8 |   for(int i=0;i<n;i++) cin>>v[i];
      |                             ^
a.cc:9:17: error: expected primary-expression before 'int'
    9 |   vector<vector<int>> k(n+1)(c+1);
      |                 ^~~
a.cc:15:16: error: 'k' was not declared in this scope
   15 |                k[i][j] = 0;
      |                ^
a.cc:16:21: error: 'w' was not declared in this scope
   16 |            else if (w[i-1] <= j)
      |                     ^
a.cc:17:18: error: 'k' was not declared in this scope
   17 |                  k[i][j] = max(v[i-1] + k[i-1][j-w[i-1]],  k[i-1][j]);
      |                  ^
a.cc:17:32: error: 'v' was not declared in this scope
   17 |                  k[i][j] = max(v[i-1] + k[i-1][j-w[i-1]],  k[i-1][j]);
      |                                ^
a.cc:17:28: error: 'max' was not declared in this scope; did you mean 'std::max'?
   17 |                  k[i][j] = max(v[i-1] + k[i-1][j-w[i-1]],  k[i-1][j]);
      |                            ^~~
      |                            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:19:18: error: 'k' was not declared in this scope
   19 |                  k[i][j] = k[i-1][j];
      |                  ^
a.cc:22:4: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |    cout<<k[n][c];
      |    ^~~~
      |    std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:22:10: error: 'k' was not declared in this scope
   22 |    cout<<k[n][c];
      |          ^