Language: C++

long long int knapsack(int k,long long int wt,long long int pri,vector<long long int> weight,vector<long long int> price,int w,int n)
{
  //  cout<<"BEFORE"<<k<<" "<<wt<<" "<<pri<<" "<<wt+weight[k]<<" "<<pri+price[k]<<" "<<endl;
    if(k>n)
    {
        return pri;
    }
    if(wt>w)
    {
    // cout<<"hii";
    return pri-price[k-1];
    }
   // cout<<pri<<endl;
    return max(knapsack(k+1,wt,pri,weight,price,w,n),knapsack(k+1,wt+weight[k],pri+price[k],weight,price,w,n));
}
int main()
{
    int n=0;int w=0;
    cin>>n;
    cin>>w;
    int k=0;
    vector<long long int> weight(n);
    vector<long long int> price(n);
    
    for(int i=0;i<n;i++)
    {
        cin>>weight[i];
        cin>>price[i];
    }
    
    long long int ans =knapsack(0,0,0,weight,price,w,n);
    cout<<ans;
    return 0;
}



Compiler output:
a.cc:1:65: error: 'vector' has not been declared
    1 | long long int knapsack(int k,long long int wt,long long int pri,vector<long long int> weight,vector<long long int> price,int w,int n)
      |                                                                 ^~~~~~
a.cc:1:71: error: expected ',' or '...' before '<' token
    1 | long long int knapsack(int k,long long int wt,long long int pri,vector<long long int> weight,vector<long long int> price,int w,int n)
      |                                                                       ^
a.cc: In function 'long long int knapsack(int, long long int, long long int, int)':
a.cc:4:10: error: 'n' was not declared in this scope
    4 |     if(k>n)
      |          ^
a.cc:8:11: error: 'w' was not declared in this scope
    8 |     if(wt>w)
      |           ^
a.cc:11:16: error: 'price' was not declared in this scope; did you mean 'pri'?
   11 |     return pri-price[k-1];
      |                ^~~~~
      |                pri
a.cc:14:36: error: 'weight' was not declared in this scope
   14 |     return max(knapsack(k+1,wt,pri,weight,price,w,n),knapsack(k+1,wt+weight[k],pri+price[k],weight,price,w,n));
      |                                    ^~~~~~
a.cc:14:43: error: 'price' was not declared in this scope; did you mean 'pri'?
   14 |     return max(knapsack(k+1,wt,pri,weight,price,w,n),knapsack(k+1,wt+weight[k],pri+price[k],weight,price,w,n));
      |                                           ^~~~~
      |                                           pri
a.cc:14:49: error: 'w' was not declared in this scope
   14 |     return max(knapsack(k+1,wt,pri,weight,price,w,n),knapsack(k+1,wt+weight[k],pri+price[k],weight,price,w,n));
      |                                                 ^
a.cc:14:51: error: 'n' was not declared in this scope
   14 |     return max(knapsack(k+1,wt,pri,weight,price,w,n),knapsack(k+1,wt+weight[k],pri+price[k],weight,price,w,n));
      |                                                   ^
a.cc:14:12: error: 'max' was not declared in this scope
   14 |     return max(knapsack(k+1,wt,pri,weight,price,w,n),knapsack(k+1,wt+weight[k],pri+price[k],weight,price,w,n));
      |            ^~~
a.cc: In function 'int main()':
a.cc:19:5: error: 'cin' was not declared in this scope
   19 |     cin>>n;
      |     ^~~
a.cc:22:5: error: 'vector' was not declared in this scope
   22 |     vector<long long int> weight(n);
      |     ^~~~~~
a.cc:22:12: error: expected primary-expression before 'long'
   22 |     vector<long long int> weight(n);
      |            ^~~~
a.cc:23:12: error: expected primary-expression before 'long'
   23 |     vector<long long int> price(n);
      |            ^~~~
a.cc:27:14: error: 'weight' was not declared in this scope
   27 |         cin>>weight[i];
      |              ^~~~~~
a.cc:28:14: error: 'price' was not declared in this scope
   28 |         cin>>price[i];
      |              ^~~~~
a.cc:31:39: error: 'weight' was not declared in this scope
   31 |     long long int ans =knapsack(0,0,0,weight,price,w,n);
      |                                       ^~~~~~
a.cc:31:46: error: 'price' was not declared in this scope
   31 |     long long int ans =knapsack(0,0,0,weight,price,w,n);
      |                                              ^~~~~
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout<<ans;
      |     ^~~~