Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n,w; cin>>n>>w;
vl w0[105]={},w1[105]={},w2[105]={},w3[105]={};
ll a,b;cin>>a>>b;
w0.pb(b);
rep(i,n-1){
ll r,l;
cin>>r>>l;
if(r==a)w0.pb(l);
if(r==a+1)w1.pb(l);
if(r==a+2)w2.pb(l);
if(r==a+3)w3.pb(l);
}
ll l0=w0.size(),l1=w1.size(),l2=w2.size(),l3=w3.size();
ll ans = 0, ww = 0 , ca = 0;
sort(all(w0));
sort(all(w1));
sort(all(w2));
sort(all(w3));
reverse(all(w0));
reverse(all(w1));
reverse(all(w2));
reverse(all(w3));
for(ll i=1; i<=l0; i++){
for(ll k=1; k<=l1; k++){
for(ll j=1; j<=l2; j++){
for(ll m=1; m<=l3; m++){
ca = 0, ww = 0;
rep(o,i){
ca+=w0[i-1];}
ww+=r*i;
rep(o,k){
ca+=w1[k-1];}
ww+=(r+1)*k;
rep(o,j){
ca+=w2[j-1];}
ww+=(r+2)*j;
rep(o,m){
ca+=w3[m-1];}
ww+=(r+3)*m;
if(ww<=w){
ans = max(ans,ca);}
}}}}
cout << ans << endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: request for member 'push_back' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
    9 | #define pb push_back
      |            ^~~~~~~~~
a.cc:151:4: note: in expansion of macro 'pb'
  151 | w0.pb(b);
      |    ^~
a.cc:9:12: error: request for member 'push_back' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
    9 | #define pb push_back
      |            ^~~~~~~~~
a.cc:155:12: note: in expansion of macro 'pb'
  155 | if(r==a)w0.pb(l);
      |            ^~
a.cc:9:12: error: request for member 'push_back' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
    9 | #define pb push_back
      |            ^~~~~~~~~
a.cc:156:14: note: in expansion of macro 'pb'
  156 | if(r==a+1)w1.pb(l);
      |              ^~
a.cc:9:12: error: request for member 'push_back' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
    9 | #define pb push_back
      |            ^~~~~~~~~
a.cc:157:14: note: in expansion of macro 'pb'
  157 | if(r==a+2)w2.pb(l);
      |              ^~
a.cc:9:12: error: request for member 'push_back' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
    9 | #define pb push_back
      |            ^~~~~~~~~
a.cc:158:14: note: in expansion of macro 'pb'
  158 | if(r==a+3)w3.pb(l);
      |              ^~
a.cc:160:10: error: request for member 'size' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
  160 | ll l0=w0.size(),l1=w1.size(),l2=w2.size(),l3=w3.size();
      |          ^~~~
a.cc:11:20: error: request for member 'begin' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:162:6: note: in expansion of macro 'all'
  162 | sort(all(w0));
      |      ^~~
a.cc:11:32: error: request for member 'end' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:162:6: note: in expansion of macro 'all'
  162 | sort(all(w0));
      |      ^~~
a.cc:11:20: error: request for member 'begin' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:163:6: note: in expansion of macro 'all'
  163 | sort(all(w1));
      |      ^~~
a.cc:11:32: error: request for member 'end' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:163:6: note: in expansion of macro 'all'
  163 | sort(all(w1));
      |      ^~~
a.cc:11:20: error: request for member 'begin' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:164:6: note: in expansion of macro 'all'
  164 | sort(all(w2));
      |      ^~~
a.cc:11:32: error: request for member 'end' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:164:6: note: in expansion of macro 'all'
  164 | sort(all(w2));
      |      ^~~
a.cc:11:20: error: request for member 'begin' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:165:6: note: in expansion of macro 'all'
  165 | sort(all(w3));
      |      ^~~
a.cc:11:32: error: request for member 'end' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:165:6: note: in expansion of macro 'all'
  165 | sort(all(w3));
      |      ^~~
a.cc:11:20: error: request for member 'begin' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:166:9: note: in expansion of macro 'all'
  166 | reverse(all(w0));
      |         ^~~
a.cc:11:32: error: request for member 'end' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:166:9: note: in expansion of macro 'all'
  166 | reverse(all(w0));
      |         ^~~
a.cc:11:20: error: request for member 'begin' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:167:9: note: in expansion of macro 'all'
  167 | reverse(all(w1));
      |         ^~~
a.cc:11:32: error: request for member 'end' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:167:9: note: in expansion of macro 'all'
  167 | reverse(all(w1));
      |         ^~~
a.cc:11:20: error: request for member 'begin' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:168:9: note: in expansion of macro 'all'
  168 | reverse(all(w2));
      |         ^~~
a.cc:11:32: error: request for member 'end' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:168:9: note: in expansion of macro 'all'
  168 | reverse(all(w2));
      |         ^~~
a.cc:11:20: error: request for member 'begin' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:169:9: note: in expansion of macro 'all'
  169 | reverse(all(w3));
      |         ^~~
a.cc:11:32: error: request for member 'end' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
   11 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:169:9: note: in expansion of macro 'all'
  169 | reverse(all(w3));
      |         ^~~
a.cc:171:16: error: 'l1' was not declared in this scope; did you mean 'l0'?
  171 | for(ll k=1; k<=l1; k++){
      |                ^~
      |                l0
a.cc:172:16: error: 'l2' was not declared in this scope; did you mean 'l0'?
  172 | for(ll j=1; j<=l2; j++){
      |                ^~
      |                l0
a.cc:173:16: error: 'l3' was not declared in this scope; did you mean 'l0'?
  173 | for(ll m=1; m<=l3; m++){
      |                ^~
      |                l0
a.cc:176:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
  176 | ca+=w0[i-1];}
      | ~~^~~~~~~~~
a.cc:177:5: error: 'r' was not declared in this scope
  177 | ww+=r*i;
      |     ^
a.cc:179:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
  179 | ca+=w1[k-1];}
      | ~~^~~~~~~~~
a.cc:182:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
  182 | ca+=w2[j-1];}
      | ~~^~~~~~~~~
a.cc:185:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
  185 | ca+=w3[m-1];}
      | ~~^~~~~~~~~