Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <utility>

using ll = long long;
using pr = pair<ll, ll>;

ll KnapsackDP(vector<pr>&sack, int w) {
	vector<vector<ll>>dp(sack.size() + 1, vector<ll>(w + 1, 0));
	sort(sack.begin(), sack.end());
 
	ll m = 0;
 
	for (int i = 0; i < sack.size(); ++i)
		for (int j = sack[i].first; j <= w; ++j) {
			dp[i + 1][j] = max(dp[i][j], dp[i][j - sack[i].first] + sack[i].second);
			m = max(m, dp[i + 1][j]);
		}
 
	return m;
}
 
int main() {
	int N, W, w, c;
	cin >> N >> W;
	vector<pr>sack;
	for (int i = 0; i < N; ++i) {
		cin >> w >> c;
		sack.push_back({ w, c });
	}
	cout << KnapsackDP(sack, W) << endl;
}

Compiler output:
a.cc:9:12: error: 'pair' does not name a type
    9 | using pr = pair<ll, ll>;
      |            ^~~~
a.cc:11:15: error: 'vector' was not declared in this scope
   11 | ll KnapsackDP(vector<pr>&sack, int w) {
      |               ^~~~~~
a.cc:11:15: 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:11:22: error: 'pr' was not declared in this scope
   11 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                      ^~
a.cc:11:26: error: 'sack' was not declared in this scope
   11 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                          ^~~~
a.cc:11:32: error: expected primary-expression before 'int'
   11 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                                ^~~
a.cc:11:37: error: expression list treated as compound expression in initializer [-fpermissive]
   11 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                                     ^
a.cc: In function 'int main()':
a.cc:28:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   28 |         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:29:9: error: 'vector' was not declared in this scope
   29 |         vector<pr>sack;
      |         ^~~~~~
a.cc:29:9: 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:29:16: error: 'pr' was not declared in this scope
   29 |         vector<pr>sack;
      |                ^~
a.cc:29:19: error: 'sack' was not declared in this scope
   29 |         vector<pr>sack;
      |                   ^~~~
a.cc:34:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   34 |         cout << KnapsackDP(sack, W) << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:34:27: error: 'KnapsackDP' cannot be used as a function
   34 |         cout << KnapsackDP(sack, W) << endl;
      |                 ~~~~~~~~~~^~~~~~~~~
a.cc:34:40: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   34 |         cout << KnapsackDP(sack, W) << endl;
      |                                        ^~~~
      |                                        std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~