Language: C++

#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

ll n, wt;
vii arr;
vvi dp;

ll solve (ll w, ll i) {
    if (i == n)
        return 0;
    if (dp[{w, i}])
        return dp[{w, i}];
    ll v = 0;
    if (w >= arr[i].first)
        v = solve(w - arr[i].first, i+1) + arr[i].second;
    v = max(v, solve(w, i+1));
    return dp[{w, i}] = v;
}

int main() {
    fast;
    cin >> n >> wt;
    arr.resize(n);
    dp.resize(n, vi (w));
    REP(i, 0, n)
        cin >> arr[i].first >> arr[i].second;
    cout << solve(wt, 0) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:31:11: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<long long int> >' and '<brace-enclosed initializer list>')
   31 |     if (dp[{w, i}])
      |           ^
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:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; reference = std::vector<long long int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; const_reference = const std::vector<long long int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:32:18: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<long long int> >' and '<brace-enclosed initializer list>')
   32 |         return dp[{w, i}];
      |                  ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; reference = std::vector<long long int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; const_reference = const std::vector<long long int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:37:14: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<long long int> >' and '<brace-enclosed initializer list>')
   37 |     return dp[{w, i}] = v;
      |              ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; reference = std::vector<long long int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; const_reference = const std::vector<long long int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:44:22: error: 'w' was not declared in this scope; did you mean 'wt'?
   44 |     dp.resize(n, vi (w));
      |                      ^
      |                      wt