stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
/***

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 */

#include <iostream>

#include <queue>

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>

#include <string>

#include <stack>

using namespace std;

//int n,m,x,y;

//char a[1010][1010];

//int vis[1010][1010];

//void dfs()

//{

//

//}

//int main()

//{

//    while(~scanf("%d%d",&n,&m))

//    {

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

//        scanf("%s",a[i]);

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

//            for(int j=0;j<m;j++)

//        {

//            if(a[i][j]=='*')

//                vis[i][j]=2;

//                if(a[i][j]=='+')

//                    vis[i][j]=1;

//                if(a[i][j]=='F')

//                    vis[i][j]=3;

//                if(a[i][j]=='G')

//                {

//                    x=i;

//                    y=j;

//                }

//                if(i==0&&a[i][j]=='+')

//                    vis[i][j]=4;

//                if(i==n&&a[i][j]=='+')

//                    vis[i][j]=4;

//                if(j==0&&a[i][j]=='+')

//                    vis[i][j]=4;

//                if(j==m&&a[i][j]=='+')

//                    vis[i][j]=4;

//

//        }

//

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

//            {

//                for(int j=0;j<m;j++)

//                printf("%d ",vis[i][j]);

//                printf("\n");

//            }

// }

//    return 0;

//}

long long a[100000];

int main()

{

    long long n;

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

   a[i]=i*i;

   while(~scanf("%lld",&n))

   {int flag=0;

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

       {

           if(a[i]==n)

           {

               printf("%lld\n",a[i]);

               break;

           }

           if(a[i]>n)

           {

               printf("%lld\n",a[i-1]);

               break;

           }

       }

   }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7981636169136441x):
#include<iostream>

//#include<CastingInterop.h>

#include<string>

#include<array>

#include<math.h>

#include<sstream>

using namespace std;



int main()

{



	int num1,num3;

	cin >> num1;

	

	

		num3 = sqrt(num1);

			if (num3 % 10 != 0)

			{

				

				num3 = sqrt(num1);

				cout << num3 * num3;



			}

			else

			{

				cout << num3 * num3;

			}

}
// Slower C++ solution:
/***

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 *      百年修得同船渡，千年修得代码重.

 */

#include <iostream>

#include <queue>

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>

#include <string>

#include <stack>

using namespace std;

//int n,m,x,y;

//char a[1010][1010];

//int vis[1010][1010];

//void dfs()

//{

//

//}

//int main()

//{

//    while(~scanf("%d%d",&n,&m))

//    {

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

//        scanf("%s",a[i]);

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

//            for(int j=0;j<m;j++)

//        {

//            if(a[i][j]=='*')

//                vis[i][j]=2;

//                if(a[i][j]=='+')

//                    vis[i][j]=1;

//                if(a[i][j]=='F')

//                    vis[i][j]=3;

//                if(a[i][j]=='G')

//                {

//                    x=i;

//                    y=j;

//                }

//                if(i==0&&a[i][j]=='+')

//                    vis[i][j]=4;

//                if(i==n&&a[i][j]=='+')

//                    vis[i][j]=4;

//                if(j==0&&a[i][j]=='+')

//                    vis[i][j]=4;

//                if(j==m&&a[i][j]=='+')

//                    vis[i][j]=4;

//

//        }

//

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

//            {

//                for(int j=0;j<m;j++)

//                printf("%d ",vis[i][j]);

//                printf("\n");

//            }

// }

//    return 0;

//}

long long a[100000];

int main()

{

    long long n;

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

   a[i]=i*i;

   while(~scanf("%lld",&n))

   {int flag=0;

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

       {

           if(a[i]==n)

           {

               printf("%lld\n",a[i]);

               break;

           }

           if(a[i]>n)

           {

               printf("%lld\n",a[i-1]);

               break;

           }

       }

   }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7821903945037731x):
#include <iostream>

#include<cmath>

using namespace std;

int main()

{

    int n,a;

    cin>>n;

    for(int i=n;i>=1;i--)

    {

        a=sqrt(i);

        if(i%a==0&&i/a==a)

        {

            cout<<i<<endl;

            return 0;

        }

    }



	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <string>

#include <cmath>

#include <map>

#include <set>

#include <vector>

#include <iterator>

#include <list>

#include <stack>

#include <queue>

#include <cstdlib>

using namespace std;

int check(int s)

{

    int n = (int)sqrt(s);

    if(n*n == s)return 1;

    return 0;

}

int main()

{

    int n;

    cin >> n;

    for(int i = n;i >= 0;i--)

    {

        if(check(i))

        {

            cout << i << endl;

            break;

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.167806092291106x):
#include <algorithm>

#include <stdio.h>

#include <math.h>

#include <string.h>

#include <time.h>

#include <queue>

using namespace std;

int main()

{

    long long m,i,sum,flag;

    while(~scanf("%lld",&m))

    {

        for(i=1; i<=m; i++)

        {

            sum=i*i;

            if(sum==m)

            {

                flag=i;

                break;

            }

            if(sum>m)

            {

                flag=i-1;

                break;

            }

        }

        flag*=flag;

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

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>



using namespace std;



int main(){

    long long n,ans;

    scanf("%lld",&n);

    for(long long i=1; i*i<=n; i++){

        ans = i*i;

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.095066160675261x):
#include <algorithm>

#include <stdio.h>

#include <math.h>

#include <string.h>

#include <time.h>

#include <queue>

using namespace std;

int main()

{

    long long m,i,sum,flag;

    while(~scanf("%lld",&m))

    {

        for(i=1; i<=m; i++)

        {

            sum=i*i;

            if(sum==m)

            {

                flag=i;

                break;

            }

            if(sum>m)

            {

                flag=i-1;

                break;

            }

        }

        flag*=flag;

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

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>



using namespace std;

int main() {

	long n;

	cin >> n;

	for (long i = n; ; i--) {

		if (floor(sqrt(i))*floor(sqrt(i)) == i) {

			cout << i << endl;

			break;

		}

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.1666875404341095x):
#include <algorithm>

#include <stdio.h>

#include <math.h>

#include <string.h>

#include <time.h>

#include <queue>

using namespace std;

int main()

{

    long long m,i,sum,flag;

    while(~scanf("%lld",&m))

    {

        for(i=1; i<=m; i++)

        {

            sum=i*i;

            if(sum==m)

            {

                flag=i;

                break;

            }

            if(sum>m)

            {

                flag=i-1;

                break;

            }

        }

        flag*=flag;

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

    }

    return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<iostream>

#include<math.h>

using namespace std;



int main()

{

	int N;

	while(~scanf("%d",&N))

	{   

	    int max=0;

		for(int i=0;i<=sqrt(N);i++)

		{

			if(i*i>=max)

			max=i*i;

			else

			break;

		}

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

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.198700565664994x):
#include <algorithm>

#include <stdio.h>

#include <math.h>

#include <string.h>

#include <time.h>

#include <queue>

using namespace std;

int main()

{

    long long m,i,sum,flag;

    while(~scanf("%lld",&m))

    {

        for(i=1; i<=m; i++)

        {

            sum=i*i;

            if(sum==m)

            {

                flag=i;

                break;

            }

            if(sum>m)

            {

                flag=i-1;

                break;

            }

        }

        flag*=flag;

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

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include<cmath>

#include<cstdio>

using namespace std;

int main()

{

    long long a,b,c;

    while(~scanf("%lld",&a))

    {

        while(1)

        {

            b=sqrt(a);

            c=b*b;

            if(a==c)

            {

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

                break;

            }



            else

                a--;

        }



    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.118609213896891x):
#include<stdio.h>

int main()

{

    long long n,j;

    while(~scanf("%lld",&n))

    {

        long long ans;

        for(j=1;j*j<=n;j++)

        {

            ans = j*j;

        }

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

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

	long long  ans=0;

	ll n,m;

	cin>>n>>m;

	if(m==0){

		cout<<n*n<<endl;

		return 0;

	}

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

		ans=ans+n/i*j;

		ll tmp=0;

		tmp=max((ll)0,n%i-m+1);

		ans=ans+tmp;

	}

	cout<<ans<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.255836806265547x):
#include<stdio.h>

int max(int a,int b){return a>b?a:b;}

int main()

{

	long long n,k,sum=0;

	scanf("%lld%lld",&n,&k);

	if(k==0)sum=n*n;

	else for(int i=k+1;i<=n;i++)sum+=(n/i)*(i-k)+max(0,(int)n%i-(int)k+1);

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

}
// Slower C++ solution:
#include<algorithm>

#include<cstdio>

#include<cmath>

#include<iostream>

using namespace std;

long long K,N;

int main()

{

    long long sum=0;

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

    scanf("%lld%lld",&N,&K);

    if(K==0)

    {

        cout<<N*N<<endl;

        return 0;

    }

    for(int i=K+1;i<=N;++i)

    {

        for(int j=i;j<=N;j+=i)

        {

            sum+=i-K;

        }

        if(N%i>=K)

        {

            sum+=N%i-K+1;

        }

    }

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

}


// Faster C++ solution for the same problem (measured speedup: 5.250187732267968x):
//想的时间太长了，打表不能一下找到规律的话，还是手推吧，不要浪费时间 

//用long long！！ 

#include <cstdio>

#include <cstring>

long long k, ans, x, y, n, m;



int main(){

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

	scanf("%lld%lld", &n, &k);

	if (k == 0){

		printf("%lld", n * n);

		return 0;

	}

	ans = 0;

	ans += (n - k) * (n - k + 1) / 2;

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

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

		x = n / i;

		y = n % i;

		ans += (x - 1) * (i - k);

		if (y >= k) ans += y - k + 1;

	} 

	printf("%lld", ans);

	

	//以下为打表找规律（其实最后也没找到，还是手推的） 

	/*n = 100;

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

		for (int j=0; j<=i-1; j++){

			ans = 0;

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

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

					if (a % b >= j) ans++;

			}

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

			//ans = 0;

		}

	}*/

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

using namespace std;



int main() {

	char s[100000];

	cin >> s;

	int n = strlen(s);

	if(s[0] == s[n - 1]){

		if(n % 2 == 0) cout << "First" << endl;

		else cout << "Second" << endl;

	}else{

		if(n % 2 == 0) cout << "Second" << endl;

		else cout << "First" << endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.327981867693445x):
#include<cstdio>

#include<cstring>

using namespace std;



int main() {

	char s[100000];

	scanf("%s", s);

	int n = strlen(s);

	if(s[0] == s[n - 1]){

		if(n % 2 == 0) printf("First\n");

		else printf("Second\n");

	}else{

		if(n % 2 == 0) printf("Second\n");

		else printf("First\n");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };











const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, -1, sizeof(f));

	f[0] = 0;

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

		int w, v;

		scanf("%d%d", &w, &v);

		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {

			f[i] = max(f[i], f[i - w] + v);

		}

	}

	LL ans = 0;

	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7760741275964833x):
#include <bits/stdc++.h>

using namespace std;



#define fr(i,n) _back

#define pb	push_back

#define eb	emplace_back

#define mk	make_pair

#define fi	first

#define se	second

#define endl	'\n'



typedef long long ll;

typedef pair<int,int> ii;

typedef vector<ii> vii;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int N = 1e5 + 3;

ll dp[N];



int main() {

    ios_base::sync_with_stdio(false);

    int n,c,w,v; cin >> n >> c;

    ll ans = 0;



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

        cin >> w >> v;

        for(int j = c; j-w >= 0; j--) {

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

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

        }

    }



    cout << ans << endl;

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };











const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, -1, sizeof(f));

	f[0] = 0;

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

		int w, v;

		scanf("%d%d", &w, &v);

		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {

			f[i] = max(f[i], f[i - w] + v);

		}

	}

	LL ans = 0;

	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7934669554709308x):
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <iostream>





using namespace std;



const int MaxN = 1e5 + 5;



long long dp[MaxN];

int w[105] , W , n;

long long v[105];



int main(){

	cin >> n >> W;

	for(int i = 1; i <= n ; i++)cin >> w[i] >> v[i];

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

		for(int j = W ; j >= w[i] ; j--)dp[j] = max(dp[j] , dp[j - w[i]] + v[i]);

	}

	cout << dp[W] << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };











const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, -1, sizeof(f));

	f[0] = 0;

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

		int w, v;

		scanf("%d%d", &w, &v);

		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {

			f[i] = max(f[i], f[i - w] + v);

		}

	}

	LL ans = 0;

	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7793688859321173x):
#include <bits/stdc++.h>

using namespace std;



int main()

{

	int N, W;

	cin >> N >> W;

	vector<long long> dp(W+1, 0);

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

	{

		long long w, v;

		cin >> w >> v;

		for (long long j = W - w; j >= 1; j--)

		{

			if (dp[j] != 0)

				dp[j+w] = max(dp[j+w], dp[j] + v);

		}

		dp[w] = max(dp[w], v);

	}

	cout << *max_element(dp.begin(), dp.end());

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };











const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, -1, sizeof(f));

	f[0] = 0;

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

		int w, v;

		scanf("%d%d", &w, &v);

		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {

			f[i] = max(f[i], f[i - w] + v);

		}

	}

	LL ans = 0;

	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7550001718131525x):
#include<bits/stdc++.h>

using ll = long long;



int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);



	int N, W;

	std::cin >> N >> W;

	std::vector<ll> V(N), wei(N), dp(W+1, 0);

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

		std::cin >> wei[i] >> V[i];

	}

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

		for(int w=W; w >= wei[i]; w--){

			dp[w] = std::max( dp[w], dp[w-wei[i]] + V[i] );

		}

	}

	std::cout << dp[W] << '\n';

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };











const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, -1, sizeof(f));

	f[0] = 0;

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

		int w, v;

		scanf("%d%d", &w, &v);

		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {

			f[i] = max(f[i], f[i - w] + v);

		}

	}

	LL ans = 0;

	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7924418831367785x):
#include <iostream>



using namespace std;



int n_itens, capacidade;



long long valores[101][3];



long long inventario[100001][101];



int main(){

    cin >> n_itens >> capacidade;



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

        cin >> valores[i][1];

        cin >> valores[i][2];

    }



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

        for(int j = 1; j <= n_itens; j++){

            inventario[i][j] = 0;

        }

    }



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

        for(int j = 1; j <= capacidade; j++){

            long long custoAnterior = inventario[j][i - 1];



            long long custoItem = 0;



            if(j - valores[i][1] >= 0){

                 custoItem = valores[i][2] + inventario[j - valores[i][1]][i - 1];

            }



            long long maximo = max(custoAnterior, custoItem);



            inventario[j][i] = maximo;

        }

    }



    cout << inventario[capacidade][n_itens] << endl;



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };











const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, -1, sizeof(f));

	f[0] = 0;

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

		int w, v;

		scanf("%d%d", &w, &v);

		for (int i = C; i >= w; i--)if(f[i-w]!=-1) {

			f[i] = max(f[i], f[i - w] + v);

		}

	}

	LL ans = 0;

	for (int i = 0; i <= C; i++)ans = max(ans, f[i]);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7964012732719252x):
#include <bits/stdc++.h>

#define int2 long long int



using namespace std;



int main(){

	int2 N, W;

	scanf("%lld%lld", &N, &W);



	pair<int2, int2> v[N];

	vector<vector<int2> > problem, itens;

	problem.resize(W+1);

	itens.resize(W+1);



	for(int2 i=0; i<W+1; i++){

		problem[i].resize(N+1);

		itens[i].resize(N+1);

		for(int2 j=0; j<N+1; j++){

			problem[i][j] = itens[i][j] = 0;

		}

	}



	for(int2 i=0; i<N+1; i++){

		scanf("%lld%lld", &v[i].first, &v[i].second);

	}





	for(int2 i=1; i<N+1; i++){

		for(int2 j=1; j<W+1; j++){

			int2 aceitaItem=-1, recusaItem;

			if(j-v[i-1].first>=0){

				aceitaItem = v[i-1].second + problem[j-v[i-1].first][i-1];

			}

			recusaItem = problem[j][i-1];

			problem[j][i] = max(aceitaItem, recusaItem);

		}

	}

	

	printf("%lld\n", problem[W][N]);

}