Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define MOD 1000000007

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, W;
lli buf, bw;
lli P[2][100];

lli mem[400][100][100];

lli DP(lli wei, int num, int use, lli val);//重量, 番号

int main(){
  cin >> N >> W;
  for(int l = 0; l < 400; l++){
    for(int m = 0; m < 100; m++){
      for(int n = 0; n < 100; n++){
          mem[l][m][n] = -1;
      }
    }
  }
  for(int l = 0;l < N; l++){
    cin >> P[0][l] >> P[1][l];
    if(l == 0){
      bw = P[0][0];
    }
    P[0][l] = P[0][l] - bw + 1;
    mem[P[0][l]][l][1] = P[1][l];
  }

  cout << DP(0, -1, 0, 0);
  #include<iostream>
  #include<vector>
  #include<algorithm>
  
  using namespace std;
  
  #define MOD 1000000007
  
  using lli = long long int;
  using ulli = unsigned long long int;
  
  //#define EVEL 1
  
  #ifndef EVEL
  #define dbug(X) std::cout << #X << ":" <<X<<" " ;
  #define dbugf(s) std::cout << s << " ";
  #define dbugln std::cout<<"\n";
  #else
  #define dbug(X) {}
  #define dbugf(s) {}
  #define dbugln {}
  #endif
  
  lli N, W;
  lli buf, bw;
  lli P[2][100];
  
  lli mem[400][100][100];
  
  lli DP(lli wei, int num, int use, lli val);//重量, 番号
  
  int main(){
    cin >> N >> W;
    for(int l = 0; l < 400; l++){
      for(int m = 0; m < 100; m++){
        for(int n = 0; n < 100; n++){
            mem[l][m][n] = -1;
        }
      }
    }
    for(int l = 0;l < N; l++){
      cin >> P[0][l] >> P[1][l];
      if(l == 0){
        bw = P[0][0];
      }
      P[0][l] = P[0][l] - bw + 1;
      mem[P[0][l]][l][1] = P[1][l];
    }
  
    cout << DP(0, -1, 0, 0);
  
    return 0;
  
  }
  
  lli DP(lli wei, int num, int use, lli val){
  
    dbug(wei);
    dbug(num);
    dbug(use);
    dbug(val);
    dbugf(" ");
    dbugln;
  
    lli h1, h2, get;
    if(num == N-1){
      mem[wei][num][use] = val;
      get = val;
    }else if(mem[wei][num][use] != -1){
      if(val > mem[wei][num][use]){
        mem[wei][num][use] = val;
      }
      get = mem[wei][num][use];
    }else{
      if( ( wei + P[0][num+1] + (use + 1) * bw ) <= W){
        h1 = DP(wei + P[0][num+1], num+1, use+1, val + P[1][num+1]);
      }
      h2 = DP(wei, num+1, use, val);
      get = max(h1, h2);
      mem[wei][num][use] = get;
    }
  
    dbug(get);
    dbugln;
  
    return get;
  
  }

  return 0;

}

lli DP(lli wei, int num, int use, lli val){

  //dbug(wei);
  //dbug(num);
  //dbug(use);
  //dbug(val);
  //dbugf(" ");
  //dbugln;

  lli h1, h2, get;
  if(num == N-1){
    mem[wei][num][use] = val;
    get = val;
  }else if(mem[wei][num][use] != -1){
    if(val > mem[wei][num][use]){
      mem[wei][num][use] = val;
    }
    get = mem[wei][num][use];
  }else{
    if( ( wei + P[0][num+1] + (use + 1) * bw ) <= W){
      h1 = DP(wei + P[0][num+1], num+1, use+1, val + P[1][num+1]);
    }
    h2 = DP(wei, num+1, use, val);
    get = max(h1, h2);
    mem[wei][num][use] = get;
  }

  //dbug(get);
  //dbugln;

  return get;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:11: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   82 |   int main(){
      |           ^~
a.cc:82:11: note: remove parentheses to default-initialize a variable
   82 |   int main(){
      |           ^~
      |           --
a.cc:82:11: note: or replace parentheses with braces to value-initialize a variable
a.cc:82:13: error: a function-definition is not allowed here before '{' token
   82 |   int main(){
      |             ^
a.cc:106:45: error: a function-definition is not allowed here before '{' token
  106 |   lli DP(lli wei, int num, int use, lli val){
      |                                             ^