Language: C++

#include <bits/stdc++.h>
using ll = long long;
using pr = pair<ll, ll>;
ll KnapsackDPW(vector<pr>&sack, int w) {
	ll sum = 0;
	for (auto &x : sack)
		sum += x.second;
	vector<ll>dp(sum + 1, (~(1 << 31)));
	dp[0] = 0;
	for (int i = 0; i < sack.size(); ++i)
		for (int j = sum - sack[i].second; j >= 0; --j)
			dp[j + sack[i].second] = min(dp[j + sack[i].second], dp[j] + sack[i].first);

	for (auto &x : dp)
		cout << x << " ";
	cout << endl;

	ll mn = 0;
	for (ll i = 0; i <= sum; ++i) {
		if(dp[i] <= w)
			mn = max(mn, i);
	}
	return mn;
}
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 << KnapsackDPW(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:16: error: 'vector' was not declared in this scope
    4 | ll KnapsackDPW(vector<pr>&sack, int w) {
      |                ^~~~~~
a.cc:4:16: 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:23: error: 'pr' was not declared in this scope
    4 | ll KnapsackDPW(vector<pr>&sack, int w) {
      |                       ^~
a.cc:4:27: error: 'sack' was not declared in this scope
    4 | ll KnapsackDPW(vector<pr>&sack, int w) {
      |                           ^~~~
a.cc:4:33: error: expected primary-expression before 'int'
    4 | ll KnapsackDPW(vector<pr>&sack, int w) {
      |                                 ^~~
a.cc:4:38: error: expression list treated as compound expression in initializer [-fpermissive]
    4 | ll KnapsackDPW(vector<pr>&sack, int w) {
      |                                      ^
a.cc: In function 'int main()':
a.cc:38:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   38 |         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:39:9: error: 'vector' was not declared in this scope
   39 |         vector<pr>sack;
      |         ^~~~~~
a.cc:39: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:39:16: error: 'pr' was not declared in this scope
   39 |         vector<pr>sack;
      |                ^~
a.cc:39:19: error: 'sack' was not declared in this scope
   39 |         vector<pr>sack;
      |                   ^~~~
a.cc:44:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   44 |         cout << KnapsackDPW(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:44:28: error: 'KnapsackDPW' cannot be used as a function
   44 |         cout << KnapsackDPW(sack, W) << endl;
      |                 ~~~~~~~~~~~^~~~~~~~~
a.cc:44:41: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   44 |         cout << KnapsackDPW(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)
      |     ^~~~