Language: C++

#include <bits/stdc++.h>
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() {
	/*fio;
	int n = 10;
	vector<vector<short>>board(n, vector<short>(n, 0));

	MoveOfAKnight(board, 0, 0);

	for (auto &x : board) {
		for (auto y : x)
			cout << ((y < 10) ? "0" : "") << y << " ";
		cout << endl;
	}*/
	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:3:12: error: 'pair' does not name a type
    3 | using pr = pair<ll, ll>;
      |            ^~~~
a.cc:4:15: error: 'vector' was not declared in this scope
    4 | ll KnapsackDP(vector<pr>&sack, int w) {
      |               ^~~~~~
a.cc:4:15: 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,
                 from a.cc:1:
/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:4:22: error: 'pr' was not declared in this scope
    4 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                      ^~
a.cc:4:26: error: 'sack' was not declared in this scope
    4 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                          ^~~~
a.cc:4:32: error: expected primary-expression before 'int'
    4 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                                ^~~
a.cc:4:37: error: expression list treated as compound expression in initializer [-fpermissive]
    4 | ll KnapsackDP(vector<pr>&sack, int w) {
      |                                     ^
a.cc: In function 'int main()':
a.cc:32:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   32 |         cin >> N >> W;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:33:9: error: 'vector' was not declared in this scope
   33 |         vector<pr>sack;
      |         ^~~~~~
a.cc:33: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:33:16: error: 'pr' was not declared in this scope
   33 |         vector<pr>sack;
      |                ^~
a.cc:33:19: error: 'sack' was not declared in this scope
   33 |         vector<pr>sack;
      |                   ^~~~
a.cc:38:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   38 |         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:38:27: error: 'KnapsackDP' cannot be used as a function
   38 |         cout << KnapsackDP(sack, W) << endl;
      |                 ~~~~~~~~~~^~~~~~~~~
a.cc:38:40: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   38 |         cout << KnapsackDP(sack, W) << endl;
      |                                        ^~~~
      |                                        std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~