Language: C++

long long int solve(vector<int>&weight,vector<long long int>&value,int w){
    vector<vector< long long int>>dp(weight.size()+1,vector<long long int>(w+1,0));
    
    for(int i=1;i<=weight.size();i++){
        for(int j=1;j<=w;j++){
            if(j>=weight[i-1]) dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);
            else dp[i][j]=dp[i-1][j];
            // cout<<dp[i][j]<<" ";
        
        }
        // cout<<endl;
    }
    return dp[weight.size()][w];
}





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    int w;
    cin>>n>>w;
    vector<int>weight;
    vector<long long int>value;
    while(n-->0){
        int a,b;
        cin>>a>>b;
        
        weight.push_back(a);
        value.push_back(b);
    }
    cout<<solve(weight,value,w)<<endl;
}

Compiler output:
a.cc:1:21: error: 'vector' was not declared in this scope
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
      |                     ^~~~~~
a.cc:1:28: error: expected primary-expression before 'int'
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
      |                            ^~~
a.cc:1:40: error: 'vector' was not declared in this scope
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
      |                                        ^~~~~~
a.cc:1:47: error: expected primary-expression before 'long'
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
      |                                               ^~~~
a.cc:1:68: error: expected primary-expression before 'int'
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
      |                                                                    ^~~
a.cc:1:73: error: expression list treated as compound expression in initializer [-fpermissive]
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
      |                                                                         ^
a.cc: In function 'int main()':
a.cc:21:5: error: 'ios_base' has not been declared
   21 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
a.cc:22:5: error: 'cin' was not declared in this scope
   22 |     cin.tie(NULL);
      |     ^~~
a.cc:22:13: error: 'NULL' was not declared in this scope
   22 |     cin.tie(NULL);
      |             ^~~~
a.cc:1:1: note: 'NULL' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | long long int solve(vector<int>&weight,vector<long long int>&value,int w){
a.cc:23:5: error: 'cout' was not declared in this scope
   23 |     cout.tie(NULL);
      |     ^~~~
a.cc:27:5: error: 'vector' was not declared in this scope
   27 |     vector<int>weight;
      |     ^~~~~~
a.cc:27:12: error: expected primary-expression before 'int'
   27 |     vector<int>weight;
      |            ^~~
a.cc:28:12: error: expected primary-expression before 'long'
   28 |     vector<long long int>value;
      |            ^~~~
a.cc:33:9: error: 'weight' was not declared in this scope
   33 |         weight.push_back(a);
      |         ^~~~~~
a.cc:34:9: error: 'value' was not declared in this scope
   34 |         value.push_back(b);
      |         ^~~~~
a.cc:36:17: error: 'weight' was not declared in this scope
   36 |     cout<<solve(weight,value,w)<<endl;
      |                 ^~~~~~
a.cc:36:24: error: 'value' was not declared in this scope
   36 |     cout<<solve(weight,value,w)<<endl;
      |                        ^~~~~
a.cc:36:16: error: 'solve' cannot be used as a function
   36 |     cout<<solve(weight,value,w)<<endl;
      |           ~~~~~^~~~~~~~~~~~~~~~
a.cc:36:34: error: 'endl' was not declared in this scope
   36 |     cout<<solve(weight,value,w)<<endl;
      |                                  ^~~~