Language: C++

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N;
	cin >> N;
	ll W,w,w0,vv;
	vector<ll> v(4);
	cin >> W >> w0 >> vv;
	v[0].push_back(vv);
	REP(i,N-1){
		cin >> w >> vv;
		v[w-w0].push_back(vv);
	}
	REP(i,4){
		sort(v[i].begin(),v[i].end());
		reverse(v[i].begin(),v[i].end());
	}
	ll mac=0,sum[4][110]={}; //[0]が0の累積和
	REP(i,4)
		REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j];
	REP(w1,W/w0+1){
		REP(w2,W/(w0+1)+1){
			REP(w3,W/(w0+2)+1){
				REP(w4,W/(w0+3)+1){
					if(w1*w0+w2*(w0+1)+w3*(w0+2)+w4*(w0+3)>W) break;
					if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break;
					mac = max(mac,sum[0][w1]+sum[1][w2]+sum[2][w3]+sum[3][w4]);
				}
			}
		}
	}
	cout << mac << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: request for member 'push_back' in 'v.std::vector<long long int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   23 |         v[0].push_back(vv);
      |              ^~~~~~~~~
a.cc:26:25: error: request for member 'push_back' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)(w - w0)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   26 |                 v[w-w0].push_back(vv);
      |                         ^~~~~~~~~
a.cc:29:27: error: request for member 'begin' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   29 |                 sort(v[i].begin(),v[i].end());
      |                           ^~~~~
a.cc:29:40: error: request for member 'end' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   29 |                 sort(v[i].begin(),v[i].end());
      |                                        ^~~
a.cc:30:30: error: request for member 'begin' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   30 |                 reverse(v[i].begin(),v[i].end());
      |                              ^~~~~
a.cc:30:43: error: request for member 'end' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   30 |                 reverse(v[i].begin(),v[i].end());
      |                                           ^~~
a.cc:34:28: error: request for member 'size' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   34 |                 REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j];
      |                            ^~~~
a.cc:5:43: note: in definition of macro 'FOR'
    5 | #define FOR(i,a,b) for(long long i=(a);i<(b);i++)
      |                                           ^
a.cc:34:17: note: in expansion of macro 'REP'
   34 |                 REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j];
      |                 ^~~
a.cc:34:65: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[long long int]' for array subscript
   34 |                 REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j];
      |                                                                 ^
a.cc:40:52: error: request for member 'size' in 'v.std::vector<long long int>::operator[](3)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   40 |                                         if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break;
      |                                                    ^~~~
a.cc:40:68: error: request for member 'size' in 'v.std::vector<long long int>::operator[](2)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   40 |                                         if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break;
      |                                                                    ^~~~
a.cc:40:84: error: request for member 'size' in 'v.std::vector<long long int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   40 |                                         if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break;
      |                                                                                    ^~~~
a.cc:40:100: error: request for member 'size' in 'v.std::vector<long long int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   40 |                                         if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break;
      |                                                                                                    ^~~~