Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,W;
int v[100];
int w[100];
int dp[101][10001];
int rec_dp(int i,int j){
????if(dp[i][j]!=-1){
????????return dp[i][j];
????}
????int res;
????if(i==n){
????????res=0;
????}
????else if(j<w[i]){
????????res=rec_dp(i+1,j);
????}else{
????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
????}
????dp[i][j]=res;
????return res;
}
int main(){
????cin>>n>>W;
????for(int i=0;i<n;i++){
????????cin >>v[i]>>w[i];
????}
????for(int i=0;i<=n;i++){
????????for(int j=0;j<=W;j++){
????????????dp[i][j]= -1;
????????}
????}
????cout <<rec_dp(0,W)<<endl;
????return 0;
}

Compiler output:
a.cc: In function 'int rec_dp(int, int)':
a.cc:8:1: error: expected primary-expression before '?' token
    8 | ????if(dp[i][j]!=-1){
      | ^
a.cc:8:2: error: expected primary-expression before '?' token
    8 | ????if(dp[i][j]!=-1){
      |  ^
a.cc:8:3: error: expected primary-expression before '?' token
    8 | ????if(dp[i][j]!=-1){
      |   ^
a.cc:8:4: error: expected primary-expression before '?' token
    8 | ????if(dp[i][j]!=-1){
      |    ^
a.cc:8:5: error: expected primary-expression before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
a.cc:8:5: error: expected ':' before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
      |     :
a.cc:8:5: error: expected primary-expression before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
a.cc:8:5: error: expected ':' before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
      |     :
a.cc:8:5: error: expected primary-expression before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
a.cc:8:5: error: expected ':' before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
      |     :
a.cc:8:5: error: expected primary-expression before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
a.cc:8:5: error: expected ':' before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
      |     :
a.cc:8:5: error: expected primary-expression before 'if'
    8 | ????if(dp[i][j]!=-1){
      |     ^~
a.cc:11:1: error: expected primary-expression before '?' token
   11 | ????int res;
      | ^
a.cc:11:2: error: expected primary-expression before '?' token
   11 | ????int res;
      |  ^
a.cc:11:3: error: expected primary-expression before '?' token
   11 | ????int res;
      |   ^
a.cc:11:4: error: expected primary-expression before '?' token
   11 | ????int res;
      |    ^
a.cc:11:5: error: expected primary-expression before 'int'
   11 | ????int res;
      |     ^~~
a.cc:11:5: error: expected ':' before 'int'
   11 | ????int res;
      |     ^~~
      |     :
a.cc:11:5: error: expected primary-expression before 'int'
   11 | ????int res;
      |     ^~~
a.cc:11:5: error: expected ':' before 'int'
   11 | ????int res;
      |     ^~~
      |     :
a.cc:11:5: error: expected primary-expression before 'int'
   11 | ????int res;
      |     ^~~
a.cc:11:5: error: expected ':' before 'int'
   11 | ????int res;
      |     ^~~
      |     :
a.cc:11:5: error: expected primary-expression before 'int'
   11 | ????int res;
      |     ^~~
a.cc:11:5: error: expected ':' before 'int'
   11 | ????int res;
      |     ^~~
      |     :
a.cc:11:5: error: expected primary-expression before 'int'
   11 | ????int res;
      |     ^~~
a.cc:12:1: error: expected primary-expression before '?' token
   12 | ????if(i==n){
      | ^
a.cc:12:2: error: expected primary-expression before '?' token
   12 | ????if(i==n){
      |  ^
a.cc:12:3: error: expected primary-expression before '?' token
   12 | ????if(i==n){
      |   ^
a.cc:12:4: error: expected primary-expression before '?' token
   12 | ????if(i==n){
      |    ^
a.cc:12:5: error: expected primary-expression before 'if'
   12 | ????if(i==n){
      |     ^~
a.cc:12:5: error: expected ':' before 'if'
   12 | ????if(i==n){
      |     ^~
      |     :
a.cc:12:5: error: expected primary-expression before 'if'
   12 | ????if(i==n){
      |     ^~
a.cc:12:5: error: expected ':' before 'if'
   12 | ????if(i==n){
      |     ^~
      |     :
a.cc:12:5: error: expected primary-expression before 'if'
   12 | ????if(i==n){
      |     ^~
a.cc:12:5: error: expected ':' before 'if'
   12 | ????if(i==n){
      |     ^~
      |     :
a.cc:12:5: error: expected primary-expression before 'if'
   12 | ????if(i==n){
      |     ^~
a.cc:12:5: error: expected ':' before 'if'
   12 | ????if(i==n){
      |     ^~
      |     :
a.cc:12:5: error: expected primary-expression before 'if'
   12 | ????if(i==n){
      |     ^~
a.cc:15:1: error: expected primary-expression before '?' token
   15 | ????else if(j<w[i]){
      | ^
a.cc:15:2: error: expected primary-expression before '?' token
   15 | ????else if(j<w[i]){
      |  ^
a.cc:15:3: error: expected primary-expression before '?' token
   15 | ????else if(j<w[i]){
      |   ^
a.cc:15:4: error: expected primary-expression before '?' token
   15 | ????else if(j<w[i]){
      |    ^
a.cc:15:5: error: expected primary-expression before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
a.cc:15:5: error: expected ':' before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
      |     :
a.cc:15:5: error: expected primary-expression before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
a.cc:15:5: error: expected ':' before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
      |     :
a.cc:15:5: error: expected primary-expression before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
a.cc:15:5: error: expected ':' before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
      |     :
a.cc:15:5: error: expected primary-expression before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
a.cc:15:5: error: expected ':' before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
      |     :
a.cc:15:5: error: expected primary-expression before 'else'
   15 | ????else if(j<w[i]){
      |     ^~~~
a.cc:17:6: error: 'else' without a previous 'if'
   17 | ????}else{
      |      ^~~~
a.cc:18:1: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      | ^
a.cc:18:2: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |  ^
a.cc:18:3: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |   ^
a.cc:18:4: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |    ^
a.cc:18:5: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |     ^
a.cc:18:6: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |      ^
a.cc:18:7: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |       ^
a.cc:18:8: error: expected primary-expression before '?' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |        ^
a.cc:18:9: error: 'res' was not declared in this scope
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |         ^~~
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:18:55: error: expected ':' before ';' token
   18 | ????????res=max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i]);
      |                                                       ^
      |                                                       :
a.cc:18:55: error: expected primary-expression before ';' token
a.cc:19:1: error: expected primary-expression before '?' token
   19 | ????}
      | ^
a.cc:19:2: error: expected primary-expression before '?' token
   19 | ????}
      |  ^
a.cc:19:3: error: expected primary-expression before '?' token
   19 | ????}
      |   ^
a.cc:19:4: error: expected primary-expression before '?' token
   19 | ????}
      |    ^
a.cc:19:5: error: expected primary-expression before '}' token
   19 | ????}
      |     ^
a.cc:19:5: error: expected ':' before '}' token
   19 | ????}
      |     ^
      |     :
a.cc:19:5: error: expected primary-expression before '}' token
a.cc:19:5: error: expected ':' before '}' token
   19 | ????}
      |     ^
      |     :
a.cc:19:5: error: expected primary-expression before '}' token
a.cc:19:5: error: expected ':' before '}' token
   19 | ????}
      |     ^
      |     :
a.cc:19:5: error: expected primary-expression before '}' token
a.cc:19:5: error: expected ':' before '}' token
   19 | ????}
      |     ^
      |     :
a.cc:19:5: error: expected primary-expression before '}' token
a.cc:20:1: error: expected primary-expression before '?' token
   20 | ????dp[i][j]=res;
      | ^
a.cc:20:2: error: expected primary-expression before '?' token
   20 | ????dp[i][j]