Language: C++

#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj;
ll n,m,num,ans;
ll a,b,c,d,e,g,h,r,bag;
ll wn1,wn2,wn3,wn4;
ll w[5005],v[5005];
ll dp[5][5005];
ll index[5];

int main(){
    cin >> n >> bag;
	for(i=0;i<n;i++){
		cin >> w[i] >> v[i];
	}
	for(i=0;i<=3;i++){
		index[i] = 1;
	}
	for(i=0;i<n;i++){
		for(num = 0;num <= 3;num ++){
			if(w[i] == w[0] + num){
				dp[num][index[num]++] = v[i];
			}
		}
	}
	for(num=0;num<=3;num++){
		sort(dp[num] + 1,dp[num] + index[num] + 1);
		reverse(dp[num] + 1,dp[num] + index[num] + 1);
	}
	for(i=0;i<=3;i++){
		for(j=1;j<=index[i];j++){
			dp[i][j] += dp[i][j-1];
			//pe(dp[i][j]);
		}
		//el;
	}
	for(int num1=0;num1 <= index[0];num1 ++){
		for(int num2=0;num2 <= index[1];num2 ++){
			for(int num3=0;num3 <= index[2];num3++){
				if((bag-w[0]*num1-w[0]*num2-num2-w[0]*num3-2*num3) < 0)continue;
				ll kosuu = (bag-w[0]*num1-w[0]*num2-num2-w[0]*num3-2*num3) / (w[0] + 3);
				ll kati = dp[0][num1] + dp[1][num2] + dp[2][num3] + dp[3][kosuu];
				ans = max(ans,kati);
			}
		}
	}

	p(ans);
    return 0;
}

Compiler output:
a.cc:82:11: error: 'll index [5]' redeclared as different kind of entity
   82 | ll index[5];
      |           ^
In file included from /usr/include/string.h:462,
                 from a.cc:16:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:90:22: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   90 |                 index[i] = 1;
      |                      ^
a.cc:95:46: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   95 |                                 dp[num][index[num]++] = v[i];
      |                                              ^
a.cc:100:49: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
  100 |                 sort(dp[num] + 1,dp[num] + index[num] + 1);
      |                                                 ^
a.cc:101:52: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
  101 |                 reverse(dp[num] + 1,dp[num] + index[num] + 1);
      |                                                    ^
a.cc:104:33: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
  104 |                 for(j=1;j<=index[i];j++){
      |                                 ^
a.cc:110:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  110 |         for(int num1=0;num1 <= index[0];num1 ++){
      |                                     ^
a.cc:111:45: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  111 |                 for(int num2=0;num2 <= index[1];num2 ++){
      |                                             ^
a.cc:112:53: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  112 |                         for(int num3=0;num3 <= index[2];num3++){
      |                                                     ^