Language: C++

using namespace std;
 
using ll = long long;
using ld = long double;
 
void solve() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
 
    vector<vector<ll>> dp(n + 1, vector<ll>(1e5 + 5, 1e18));
    dp[0][0] = 0;
 
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < dp[i].size(); j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i - 1] >= 0 && dp[i - 1][j - v[i - 1]] < 1e18) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
            }
            if (j > ans && dp[i][j] <= W) {
                ans = j;
            }
        }
    }
    cout << ans;
}
 
int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    // cin >> t;
    while (t--) solve();
 
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> n >> W;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> w(n), v(n);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> w(n), v(n);
      |            ^~~
a.cc:10:40: error: 'w' was not declared in this scope
   10 |     for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
      |                                        ^
a.cc:10:48: error: 'v' was not declared in this scope
   10 |     for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
      |                                                ^
a.cc:12:21: error: expected primary-expression before '>>' token
   12 |     vector<vector<ll>> dp(n + 1, vector<ll>(1e5 + 5, 1e18));
      |                     ^~
a.cc:12:43: error: expected primary-expression before '>' token
   12 |     vector<vector<ll>> dp(n + 1, vector<ll>(1e5 + 5, 1e18));
      |                                           ^
a.cc:12:24: error: 'dp' was not declared in this scope
   12 |     vector<vector<ll>> dp(n + 1, vector<ll>(1e5 + 5, 1e18));
      |                        ^~
a.cc:19:21: error: 'v' was not declared in this scope
   19 |             if (j - v[i - 1] >= 0 && dp[i - 1][j - v[i - 1]] < 1e18) {
      |                     ^
a.cc:20:68: error: 'w' was not declared in this scope
   20 |                 dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
      |                                                                    ^
a.cc:20:28: error: 'min' was not declared in this scope
   20 |                 dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
      |                            ^~~
a.cc:27:5: error: 'cout' was not declared in this scope
   27 |     cout << ans;
      |     ^~~~
a.cc:27:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc: In function 'int main()':
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout << fixed << setprecision(20);
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:13: error: 'fixed' was not declared in this scope
   31 |     cout << fixed << setprecision(20);
      |             ^~~~~
a.cc:1:1: note: 'std::fixed' is defined in header '<ios>'; this is probably fixable by adding '#include <ios>'
  +++ |+#include <ios>
    1 | using namespace std;
a.cc:31:22: error: 'setprecision' was not declared in this scope
   31 |     cout << fixed << setprecision(20);
      |                      ^~~~~~~~~~~~
a.cc:1:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
  +++ |+#include <iomanip>
    1 | using namespace std;
a.cc:32:5: error: 'ios_base' has not been declared
   32 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
a.cc:33:5: error: 'cin' was not declared in this scope
   33 |     cin.tie(0);
      |     ^~~
a.cc:33:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'