stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<stdio.h>

#include<map>

#include<vector>

#include<map>

#include<algorithm>

using namespace std;

char p[10];

int main(){

    map<char,bool>l;

    l.clear();

   scanf("%s",p);

   int s=0;

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

    if(!l[p[i]])

        l[p[i]]=true,s++;

   }

   if(s==2)

    printf("Yes\n");

   else

    printf("No\n");

}


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

#include<string.h>

#include<algorithm>

using namespace std;

char a[5];

int main()

{

	scanf("%s",a);

	int l=strlen(a);

	sort(a,a+4);

	if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2])printf("Yes\n");

	else printf("No\n");

}

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

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <string>

#include <vector>

#include <limits>

#include <algorithm>

#include <utility>

#include <sstream>

#include <numeric>

#include <iterator>



using namespace std;



#define repd(i,a,b) for (int i=(a);i<(b);i++)

#define rep(i,n) repd(i,0,n)

// #define ll long long

typedef long long ll;

typedef pair<int, int> P;



const int V = 100005;

vector<int> to[V*2];

bool visited[V*2];

vector<int> cnt;



void dfs(int v){

  if (visited[v]) return;

  visited[v] = true;

  cnt[v/V]++;

  for (int u : to[v]) dfs(u);

}



int main(int argc, const char * argv[]) {



    string s;

    cin >> s;

    

    char first = s[0];

    char second = '\0';



    rep(i,4){

      if(first != s[i]){

        second = s[i];

        break;

      }

    }

    // cout << second << endl;

    int sum1 = 0, sum2 = 0;

    rep(i,4){

      if (first == s[i]){

        sum1 += 1;

      }else if(second == s[i]){

        sum2 += 1;

      }

    }

    bool flag = false;



    if(sum1 == 2 && sum2 ==2) flag = true;



    if (flag){

      puts("Yes");

    }else{

      puts("No");

    }







    return 0;

}


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

#include <map>



using namespace std;



#define repd(i,a,b) for (int i=(a);i<(b);++i)

#define rep(i,n) repd(i,0,n)



int main(){

  string s;

  cin >> s;

  map<char, int> mp;

  rep(i, s.size()){

    mp[s[i]] += 1;

  }

  for(auto value: mp){

    if(value.second != 2){

      cout << "No" << endl;

      return 0;

    }

  }

  cout << "Yes" << endl;

  return 0;

}

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

#include <unordered_set>

const int HALF = 2;

const int MAXS = 4;

char S[MAXS + 5];



int main() {

  scanf("%s", S);

  std::unordered_set<char> dict(S, S + MAXS);

  puts((dict.size() == HALF) ? "Yes" : "No");

  return 0;

}

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

#include <unordered_set>

const int MAXA = 26;

const int MAXS = 4;

const int TWO = 2;

int cnt[MAXA]{ };

char S[MAXS + 5];



int main() {

  scanf("%s", S);

  int two = 0;

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

    int c = S[i] - 'A';

    ++cnt[c];

    if (cnt[c] == TWO) {

      ++two;

    } else if (cnt[c] > TWO) {

      --two;

    }

  }

  puts((two == TWO) ? "Yes" : "No");

  return 0;

}

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

#include <vector>

#include <algorithm>

#include <set>



using namespace std;





int main() {

	char s;

	multiset<char> k;

	set<char> k2;

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

		cin >> s;

		k2.insert(s);

		k.insert(s);

	}

	//cout << k2.size() << ' ' << k.count(s) << ' ' << s;

	if (k2.size() == 2 & k.count(s) == 2)

		cout << "Yes";

	else

		cout << "No";

}

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

int main(){

	char a[8],c;

	scanf("%s",a);

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

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

	if(a[j]<a[j+1])

	{

	c=a[j];

	a[j]=a[j+1];

	a[j+1]=c;

    }

if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2]&&a[0]!=a[3])

	printf("Yes\n");

	else

	printf("No\n");

	return 0;

}


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

using namespace std;

#define show(x) cout << #x << " : " << x << endl;



int main ()

{

 string s;

 cin >> s;

 map < char, int > mp;

 int i, cnt = 0;

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

 {

   mp[s[i]]++;

   if(mp[s[i]] == 2) cnt++;

   if(cnt == 2)

   {

     cout << "Yes" << endl;

     exit(0);

   }

 }

 cout << "No" << endl;

}

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

#include<cstring>

using namespace std;

char a[4];

int num[180];

int main()

{

	int pd=0;

	scanf("%s",&a);

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

	{

		num[a[i]]++;

	}

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

	{

		if(num[i]%2!=0)

		pd=1;

		if(num[i]>2)

		pd=1;

	}

	if(pd==1)

	printf("No");

	else

	printf("Yes");

} 

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

#include<algorithm>

using namespace std;

int main()

{

    string s;

    cin>>s;

    sort(s.begin(),s.end());



    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])

        {

    cout<<"Yes"<<endl;

        return 0;

        }

        cout<<"No"<<endl;

}


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

#include<cstring>

using namespace std;

char a[4];

int num[180];

int main()

{

	int pd=0;

	scanf("%s",&a);

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

	{

		num[a[i]]++;

	}

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

	{

		if(num[i]%2!=0)

		pd=1;

		if(num[i]>2)

		pd=1;

	}

	if(pd==1)

	printf("No");

	else

	printf("Yes");

} 

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

#include <set>

#include <string>



using namespace std;



int main()

{

	set<char> s;

	string str;

	cin >> str;

	for (auto val : str)

		s.insert(val);

	(s.size() == 2) ? cout << "Yes" : cout << "No";

	system("pause");

	return 0;

}

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

#include<cstring>

using namespace std;

char a[4];

int num[180];

int main()

{

	int pd=0;

	scanf("%s",&a);

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

	{

		num[a[i]]++;

	}

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

	{

		if(num[i]%2!=0)

		pd=1;

		if(num[i]>2)

		pd=1;

	}

	if(pd==1)

	printf("No");

	else

	printf("Yes");

} 

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

using namespace std;



bool IsSquare(int N)

{

    int i;

    for(i=1; N>0; i+=2)  //变化步长为2， 初值为1，一直减到N大于0

    {

        N-=i;

    }

    if(N==0)

        return true;  //如果N减到最后，恰好等于0，就是平方数

    else

        return false;  //否则，就不是平方数

}



int main()

{

    int n;

    cin>>n;

    

    while(n){

        if(IsSquare(n)){

           cout << n;

            break;

        }

       else n--;

        

    }

    

    return 0;

}


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

#include <cstring>

#include <cmath>

using namespace std;

int main() {

    int n;

    scanf("%d", &n);

    n = sqrt(n);

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

    return 0;

}

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <queue>

using namespace std;



long long N;



int main()

{

    scanf("%lld",&N);

    long long a=sqrt(N);

    long long sum=a*a;

    printf("%lld",sum);

    return 0;

}


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

#include <cstring>

#include <cmath>

using namespace std;

int main() {

    int n;

    scanf("%d", &n);

    n = sqrt(n);

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

    return 0;

}

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

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

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

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

#define PB push_back

#define MP make_pair

#define FIR first

#define SEC second

#define int long long

using namespace std;

const int MOD=1000000007;

const int INF=1000000009;



signed main(){

  int n;

  cin>>n;

  vector<int> v;

  REP(i,35000)v.PB(i*i);

  LOOP(i,1,35000){

    if(v[i]>n){

      cout<<v[i-1]<<endl;

      return 0;

    }

  }

  return 0;

}


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

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

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

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

#define PB push_back

#define MP make_pair

#define FIR first

#define SEC second

//#define int long long

using namespace std;

const int MOD=1000000007;

const int INF=1000000009;



int main(){

  int n;

  cin>>n;

  vector<int> v;

  REP(i,35000)v.PB(i*i);

  LOOP(i,1,35000){

    if(v[i]>n){

      cout<<v[i-1]<<endl;

      return 0;

    }

  }

  return 0;

}


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

#include<cmath>

using namespace std;

long long a[100005];

int n;

int main()

{

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

		a[i]=i*i;

	cin>>n;

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

	{

		if(a[i]>n)

		{

			cout<<a[i-1]<<endl;

			return 0;

		}

	}

	return 0;

}

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

using namespace std;int main(){double a;scanf("%lf",&a);printf("%.0lf\n",pow(floor(sqrt(a)),2.0));return 0;}

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



using namespace std;



int main() {

    int N;

    cin >> N;

    long Squ[100100];

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

        Squ[i] = i * i;

    }

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

        if (N < Squ[i]){

        cout << Squ[i - 1] << endl;

            return 0;

        }

    }

}

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

#include <cmath>



using namespace std;



int main() {

    int N;

    cin >> N;

    int m = sqrt(N);

    cout << m*m << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/***

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 */

#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;

}

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

#include<cstring>

#include<iostream>

#include<algorithm>

#include<string.h>

#include<cmath>

using namespace std;

int main()

{

    long long n,m;

    scanf("%lld",&n);

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

        m = i * i;

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

	}

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}


// Optimized solution to the same problem (faster):
//想的时间太长了，打表不能一下找到规律的话，还是手推吧，不要浪费时间 

//用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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

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

#include <algorithm>

#include <vector>

using namespace std;

 

long long n,val[100005],w,v,k,mxw,ans;

bool dp[100005]; 

int main(){

	dp[0]=true;

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

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

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

		for (int j=mxw;j>=0;j--){

			if (dp[j]== true && j+w <= mxw){

				dp[j+w]=true;

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

			}

		}

	}

	ans=0;

	for (int i=mxw;i>=1;i--){

		ans=max(ans,val[i]);

	}

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

	return 0;

} 

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

using namespace std;

typedef long long ll;



ll dp[100005];



int main(){

    ll n,w;

    cin>>n>>w;

    ll wi,vi;

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

        cin>>wi>>vi;

        for(ll wc=w-wi;wc>=0;wc--){

            dp[wc+wi]=max(dp[wc+wi],dp[wc]+vi);

        }

    }

    ll ans=0;

    for(auto i:dp) ans=max(ans,i);

    cout<<ans;



    return 0;

}


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

#include <algorithm>

#include <vector>

using namespace std;

 

long long n,val[100005],w,v,k,mxw,ans;

bool dp[100005]; 

int main(){

	dp[0]=true;

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

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

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

		for (int j=mxw;j>=0;j--){

			if (dp[j]== true && j+w <= mxw){

				dp[j+w]=true;

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

			}

		}

	}

	ans=0;

	for (int i=mxw;i>=1;i--){

		ans=max(ans,val[i]);

	}

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

	return 0;

} 

// Fastest known solution for this problem: