stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
//xahid f

#include<bits/stdc++.h>

using namespace std;

int main()

{

    int val[3],k;

    cin>>val[0]>>val[1]>>val[2]>>k;

    sort(val,val+3);

    cout<<val[0]+val[1]+val[2]*pow(2,k)<<endl;

    

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<ctype.h>



int main(){

	int a, b, c;

	int k;

	scanf("%d %d %d", &a, &b, &c);

	scanf("%d", &k);

	if(a>b && a>c) printf("%d\n", (a<<k)+b+c);

	else if(b>a && b>c) printf("%d\n", a+(b<<k)+c);

	else printf("%d\n", a+b+(c<<k));

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std; 

  

int main(){

	int aux,sum,j,k,i;

	int ar[5];

	int* max;



	scanf("%d%d%d%d",&ar[0],&ar[1],&ar[2],&k);



	max=max_element(ar,ar+3);



	sum=*max<<k;



	j=max-ar;



	for(i=0;i<3;i++)

		if(i!=j)

			sum+=ar[i];



	printf("%d\n",sum);



	return 0;



}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<ctype.h>



int main(){

	int a, b, c;

	int k;

	scanf("%d %d %d", &a, &b, &c);

	scanf("%d", &k);

	if(a>b && a>c) printf("%d\n", (a<<k)+b+c);

	else if(b>a && b>c) printf("%d\n", a+(b<<k)+c);

	else printf("%d\n", a+b+(c<<k));

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <cstdio>



using namespace std;



int main(){

    long long n;

    cin>>n;

    long long result = n*(n-1)/2;

    cout<<result<<endl;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

int main() {

    long long N;

    scanf("%lld",&N);

    N--;

    printf("%lld",N+(N*N-N)/2);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#define el				'\n'

#define sz(v)			((int)((v).size()))

#define all(v)          ((v).begin()),((v).end())

#define clr(v, d)		memset(v, d, sizeof(v))



double const EPS = 1e-8, PI = acos(-1);

const int N = 2e5 + 9, M = 50 + 9, OO = (int) 1e9 + 1;

const long long MOD = 1e9 + 7;



typedef long long ll;



void OUTPUT() {

	cout << fixed << setprecision(12);

	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

}



void INPUT() {

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	//freopen("output.txt", "w", stdout);

#endif

	cout << fixed << setprecision(12);

//	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

}



vector<vector<int>> edges(N);

ll n, q, x, y;

ll counter[N];

bool vis[N];



int main() {

	OUTPUT();

//	INPUT();

	cin >> n;

	x = n;

	x--;

//	ll ans = (double(1 + x) / 2.0) * x;

	ll ans = x + (x * x);

	ans /= 2;

	cout << ans;

//	for (int i = 1; i <= n; i++) {

//		y += i % x;

//		cout << i % x << " " << i << el;

//		x--;

//	}

//	cout << y;



	return 0;



}


// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



int main()

{

	long long n;

	std::cin>>n;



	n--;

	std::cout<<(n*(n+1)/2)<<std::endl;

	

}

// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<queue>

#include<map>

#include<cstdlib>

#include<stack>

#include<algorithm>

#include<set>

#include<cmath>

#include<vector>

using namespace std;

int main()

{

	#ifdef local

	freopen("1.txt","r",stdin);

	#endif

	long long n;

	scanf("%lld",&n);

	printf("%lld",n*(n-1)/2);

}

// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#define mst(a,b) memset(a,b,sizeof(a))

#define lowbit(x) ((x)&(-x))

#define X first

#define Y second

#define lc o<<1

#define rc o<<1|1

using namespace std;

using namespace __gnu_cxx;

using namespace __gnu_pbds;

typedef long long LL;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int inf = 0x3f3f3f3f;

const ll INF = 0x3f3f3f3f3f3f3f3f;

const int maxn = 100000+10;

const int maxm = 2000+10;

const int mod = 1e9+7;

const double eps = 1e-8;

int a[maxn];

int main() {

#ifdef local

    freopen("in.txt", "r", stdin);

//    freopen("out.txt", "w", stdout);

#endif

    ios::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    int n; cin>>n;

    cout<<1ll*n*(n-1)/2<<"\n";

    return 0;

}


// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	long long int n;

	cin>>n;

	long long int sum = 0 ;

	sum = n*(n-1)/2;

	cout<<sum<<endl;

	

	return 0;

}

// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#define lp(i,n) for(int i = 0; i <n;i++)

#define all(x) (x).begin(),(x).end()

#define pb push_back

#define MP make_pair

#define SZ(v) ((int)((v).size()))

typedef long long ll;



const ll MOD = 1e9 + 7;

const int OO = (int)1e6;

const int N = (int)1e7;



void init(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}



int main() {

	#   ifdef LOCAL_PROJECT

        freopen("in.txt", "r", stdin);

    #   endif

    // int q;

    // scanf("%d",&q);

    // while (q--){

    //     ll n,k,a,b;

    //     scanf("%lld%lld%lld%lld",&k,&n,&a,&b);

    //     k-=a*n;

    //     if(k>0)printf("%d\n",n);

    //     else{

    //         k*=-1;

    //         ll diff = a-b;

    //         ll cant = (k+diff)/diff;

    //         if(cant>n)puts("-1");

    //         else printf("%lld\n",n-cant);

    //     }

    // }

    ll n;

    scanf("%lld",&n);

    printf("%lld",(n*(n-1))/2);

    

    return 0;

}

// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main()

{   /// Standing in the hall of fame

    ios_base::sync_with_stdio() , cin.tie(NULL) , cout.tie(NULL);

    long long n;

    cin >> n;

    cout << n*(n-1)/2 << "\n";

    return 0;

}

// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <iomanip>

#include <stdio.h>

#include <math.h>

#include <string>

#include <cstring>

#include <bits/stdc++.h>

#include <search.h>

#include <algorithm>

#include <vector>

#include <deque>

#include <set>

#include<stack>

#include <utility>

using namespace std;

int main()

{

    long long int n;

    cin>>n;

    cout<<(n*(n-1))/2;

return 0;

}


// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
    #include <bits/stdc++.h>

     

    using namespace std;

     

    #define lp(i,n) for(int i = 0; i <n;i++)

    #define all(x) (x).begin(),(x).end()

    #define pb push_back

    #define MP make_pair

    #define SZ(v) ((int)((v).size()))

    typedef long long ll;

     

    const ll MOD = 1e9 + 7;

    const int OO = (int)1e6;

    const int N = (int)1e7;

     

    void init(){

        ios_base::sync_with_stdio(0);

        cin.tie(0);

        cout.tie(0);

    }

     

    int main() {

    	#   ifdef LOCAL_PROJECT

            freopen("in.txt", "r", stdin);

        #   endif

        // int q;

        // scanf("%d",&q);

        // while (q--){

        //     ll n,k,a,b;

        //     scanf("%lld%lld%lld%lld",&k,&n,&a,&b);

        //     k-=a*n;

        //     if(k>0)printf("%d\n",n);

        //     else{

        //         k*=-1;

        //         ll diff = a-b;

        //         ll cant = (k+diff)/diff;

        //         if(cant>n)puts("-1");

        //         else printf("%lld\n",n-cant);

        //     }

        // }

        ll n;

        scanf("%lld",&n);

        printf("%lld",(n*(n-1))/2);

        

        return 0;

    }

// Optimized solution to the same problem (faster):
// #include<bits/stdc++.h>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'



template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 1e3 + 105;



int main(){

    ll n;

    scanf("%lld", &n);

    printf("%lld\n", (1 + n)*n/2 - n);

    // system("pause");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<queue>

#include<set>

using namespace std;

typedef long long ll;

const int inf=1<<29;

const ll Maxn=1e6;

const double pi=3.1415926536;



struct sumwv{

	int w,v;

}wv[105];



bool cmp(sumwv x,sumwv y){

	return x.v>y.v;

}



sumwv A[105],B[105],C[105],D[105];



int a=0,b=0,c=0,d=0;



ll wa[105],wb[105],wc[105],wd[105];

ll va[105],vb[105],vc[105],vd[105];



int main(void){

	int n,w;

	cin>>n>>w;

	for(int i=1;i<=n;i++){

		cin>>wv[i].w>>wv[i].v;

		if(wv[i].w==wv[1].w) A[++a]=wv[i];

		if(wv[i].w==wv[1].w+1) B[++b]=wv[i];

		if(wv[i].w==wv[1].w+2) C[++c]=wv[i];

		if(wv[i].w==wv[1].w+3) D[++d]=wv[i];

	}

	sort(A+1,A+1+a,cmp);

	sort(B+1,B+1+b,cmp);

	sort(C+1,C+1+c,cmp);

	sort(D+1,D+1+d,cmp);

	wa[0]=wb[0]=wc[0]=wd[0]=0;

	va[0]=vb[0]=vc[0]=vd[0]=0;

	for(int i=1;i<=a;i++){

		wa[i]=wa[i-1]+A[i].w;

		va[i]=va[i-1]+A[i].v;

	}

	for(int i=1;i<=b;i++){

		wb[i]=wb[i-1]+B[i].w;

		vb[i]=vb[i-1]+B[i].v;

	}

	for(int i=1;i<=c;i++){

		wc[i]=wc[i-1]+C[i].w;

		vc[i]=vc[i-1]+C[i].v;

	}

	for(int i=1;i<=d;i++){

		wd[i]=wd[i-1]+D[i].w;

		vd[i]=vd[i-1]+D[i].v;

	}

	ll sum;

	ll sim=0;

	for(int i=0;i<=a;i++){

		for(int j=0;j<=b;j++){

			for(int k=0;k<=c;k++){

				for(int l=0;l<=d;l++){

					sum=wa[i]+wb[j]+wc[k]+wd[l];

					if(sum<=w){

						sim=max(sim,va[i]+vb[j]+vc[k]+vd[l]);

					}

				}

			}

		}

	}

	printf("%lld\n",sim);

}

// Optimized solution to the same problem (faster):
#include       <set>

#include       <map>

#include     <queue>

#include     <cmath>

#include    <cstdio>

#include    <cctype>

#include    <vector>

#include   <cstring>

#include <algorithm>

using namespace std;



typedef long long ll;

const ll mod = 1e9+7;

const double eps = 1e-7;

const int maxn = 105;



ll fast_pow(ll a,ll b,ll mod){

    ll ans = 1;

    while(b){

        if(b&1)

            ans = ans*a%mod;

        a = a*a%mod;

        b>>=1;

    }

    return ans;

}



int w[maxn], v[maxn];

int dp[maxn*4][maxn];



int main(){

    int n, W, c;

    scanf("%d%d",&n,&W);

    for(int i=0;i<n;i++)

        scanf("%d%d",&w[i],&v[i]);

    for(int i=1;i<n;i++)

        w[i] -= w[0]-1;

    c = w[0]-1;

    w[0] = 1;

    for(int i=0;i<n;i++)

        for(int j=(i+1)*4;j>=w[i];j--)

            for(int k=1;k<=i+1;k++){

                dp[j][k] = max(dp[j][k],dp[j-w[i]][k-1]+v[i]);

    }

    int ans = 0;

    for(int j=n*4;j>=0;j--)

        for(int k=1;k<=n;k++){

            if(1ll*k*c+j<=W){

                ans = max(ans,dp[j][k]);

            }

    }

    printf("%d\n",ans);

    return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    long long n, w, i, j, k, t, p[200][200] = {0}, a[200], b[200], ans = 0;

    vector <long long> g[5];



    cin >> n >> w;



    for(i = 0; i < n; ++i)

    {

        cin >> a[i] >> b[i];

        g[a[i] - a[0]].push_back(b[i]);

    }

    sort(g[0].rbegin(), g[0].rend());

    sort(g[1].rbegin(), g[1].rend());

    sort(g[2].rbegin(), g[2].rend());

    sort(g[3].rbegin(), g[3].rend());



    for(i = 0; i < 4; ++i)

    {

        for(j = 1; j <= g[i].size(); ++j)

            p[i][j] = p[i][j - 1] + g[i][j - 1];

    }

    for(i = 0; i <= g[0].size(); ++i)

    {

        for(j = 0; j <= g[1].size(); ++j)

        {

            for(k = 0; k <= g[2].size(); ++k)

            {

                for(t = 0; t <= g[3].size(); ++t)

                {

                    if(i * a[0] + j * (a[0] + 1) + k * (a[0] + 2) + t * (a[0] + 3) <= w)

                        ans = max(ans, p[0][i] + p[1][j] + p[2][k] + p[3][t]);

                }

            }

        }

    }

    cout << ans;



return 0;

}


// Optimized solution to the same problem (faster):
#include<iostream>  

#include<algorithm> 

#include<cstdio>  

#include<cstring>    

using namespace std;  

int n,m,a,b,c,d;

long long sum,ans; 

struct node  

{  

    int w,v;  

}g[110];  

  

bool cmp(node a,node b)  

{  

    return a.v>b.v;  

}  

node A[110],B[110],C[110],D[110];  

  

long long swa[110],swb[110],swc[110],swd[110];  

long long sva[110],svb[110],svc[110],svd[110]; 

  

int main()  

{  

        cin>>n>>m; 

        for(int i=1;i<=n;i++)  

        {  

            cin>>g[i].w>>g[i].v;  

            if(g[i].w==g[1].w) A[++a]=g[i];  

            if(g[i].w==g[1].w+1) B[++b]=g[i];  

            if(g[i].w==g[1].w+2) C[++c]=g[i];  

            if(g[i].w==g[1].w+3) D[++d]=g[i];  

        }  

        sort(A+1,A+a+1,cmp);  

        sort(B+1,B+b+1,cmp);  

        sort(C+1,C+c+1,cmp);  

        sort(D+1,D+d+1,cmp);  

        

        for(int i=1;i<=a;i++)  

        {  

            swa[i]=swa[i-1]+A[i].w;  

            sva[i]=sva[i-1]+A[i].v;  

        }  

        for(int i=1;i<=b;i++)  

        {  

            swb[i]=swb[i-1]+B[i].w;  

            svb[i]=svb[i-1]+B[i].v;  

        }  

        for(int i=1;i<=c;i++)  

        {  

            swc[i]=swc[i-1]+C[i].w;  

            svc[i]=svc[i-1]+C[i].v;  

        }  

        for(int i=1;i<=d;i++)  

        {  

            swd[i]=swd[i-1]+D[i].w;  

            svd[i]=svd[i-1]+D[i].v;  

        }  

    

        for(int i=0;i<=a;i++)  

        for(int j=0;j<=b;j++)  

        for(int k=0;k<=c;k++)  

        for(int l=0;l<=d;l++)  

        {  

        sum=swa[i]+swb[j]+swc[k]+swd[l];  

        if(sum<=m)  

        ans=max(ans,sva[i]+svb[j]+svc[k]+svd[l]);  

              

        }  

        cout<<ans<<endl;  

    

  

    return 0;  

}  

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)

#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)

#define all(n) begin(n), end(n)

using ll = long long;

using P = pair<int, int>;

using vi = vector<int>;

using vl = vector<ll>;

using vs = vector<string>;

using vc = vector<char>;

using vb = vector<bool>;

using vd = vector<double>;

vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};



int main() {

  ll n, w;

  cin >> n >> w;

  vl c(n), v(n);

  rep(i, n) cin >> c[i] >> v[i];

  ll dp[n + 1][500][101] = {};

  rep(i, n + 1) rep(j, 500) rep(k, 101) dp[i][j][k] = -1;

  dp[0][0][0] = 0;

  rep(i, n) rep(j, 410) rep(k, 100) {

    if(dp[i][j][k] == -1) continue;

    dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);

    ll nj = j + c[i] - c[0];

    dp[i + 1][nj][k + 1] = max(dp[i + 1][nj][k + 1], dp[i][j][k] + v[i]);

  }

  ll ans = 0;

  rep(j, 410) rep(k, 101) if(j + k * c[0] <= w) ans = max(ans, dp[n][j][k]);

  cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)

using ll = long long;

using vl = vector<ll>;



int main() {

  ll n, w;

  cin >> n >> w;

  vl c(n), v(n);

  rep(i, n) cin >> c[i] >> v[i];

  ll dp[500][101] = {};

  rep(j, 500) rep(k, 101) dp[j][k] = -1;

  dp[0][0] = 0;

  rep(i, n) for(int j = 400; j >= 0; j--) for(int k = 100; k >= 0; k--) {

    if(dp[j][k] == -1) continue;

    ll nj = j + c[i] - c[0];

    dp[nj][k + 1] = max(dp[nj][k + 1], dp[j][k] + v[i]);

  }

  ll ans = 0;

  rep(j, 410) rep(k, 101) if(j + k * c[0] <= w) ans = max(ans, dp[j][k]);

  cout << ans << endl;

}


// Fastest known solution for this problem: