Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <sstream>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)


struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
        for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int nCr(int n, int r) {
    int result = 1;
    rep(i, r) {
        result *= (n - i);
    }
    rep(i, r) {
        result = result / (i + 1);
    }

    return result;
}

int main() {
    int N, W; cin >> N >> W;
    vector<int> w(N), v(N); rep(i, N) cin >> w[i] >> v[i];

    vector<vector<int64>> dp(N+1, vector<int64>(W+1, 0));
    rep(i, N) {
        dp[i+1] = dp[i];
        rep(j, W) {
            if (w[i] + j <= W) {
                dp[i+1][w[i]+j] = max(dp[i+1][w[i]+j], dp[i][j] + v[i]);
            } else {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            }
        }
    }

    cout << dp[N][W] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:19: error: 'int64' was not declared in this scope; did you mean 'int64_t'?
   70 |     vector<vector<int64>> dp(N+1, vector<int64>(W+1, 0));
      |                   ^~~~~
      |                   int64_t
a.cc:70:19: error: template argument 1 is invalid
a.cc:70:19: error: template argument 2 is invalid
a.cc:70:24: error: template argument 1 is invalid
   70 |     vector<vector<int64>> dp(N+1, vector<int64>(W+1, 0));
      |                        ^~
a.cc:70:24: error: template argument 2 is invalid
a.cc:70:47: error: template argument 2 is invalid
   70 |     vector<vector<int64>> dp(N+1, vector<int64>(W+1, 0));
      |                                               ^
a.cc:70:56: error: expression list treated as compound expression in initializer [-fpermissive]
   70 |     vector<vector<int64>> dp(N+1, vector<int64>(W+1, 0));
      |                                                        ^
a.cc:72:11: error: invalid types 'int[int]' for array subscript
   72 |         dp[i+1] = dp[i];
      |           ^
a.cc:72:21: error: invalid types 'int[int]' for array subscript
   72 |         dp[i+1] = dp[i];
      |                     ^
a.cc:75:19: error: invalid types 'int[int]' for array subscript
   75 |                 dp[i+1][w[i]+j] = max(dp[i+1][w[i]+j], dp[i][j] + v[i]);
      |                   ^
a.cc:75:41: error: invalid types 'int[int]' for array subscript
   75 |                 dp[i+1][w[i]+j] = max(dp[i+1][w[i]+j], dp[i][j] + v[i]);
      |                                         ^
a.cc:75:58: error: invalid types 'int[int]' for array subscript
   75 |                 dp[i+1][w[i]+j] = max(dp[i+1][w[i]+j], dp[i][j] + v[i]);
      |                                                          ^
a.cc:77:19: error: invalid types 'int[int]' for array subscript
   77 |                 dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      |                   ^
a.cc:77:36: error: invalid types 'int[int]' for array subscript
   77 |                 dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      |                                    ^
a.cc:77:48: error: invalid types 'int[int]' for array subscript
   77 |                 dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      |                                                ^
a.cc:82:15: error: invalid types 'int[int]' for array subscript
   82 |     cout << dp[N][W] << endl;
      |               ^