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

using namespace std;

int main()

{

    int n,c,i;

    scanf("%d",&n);

    if(n==2)

    {

        printf("%d",n);

        return 0;

    }

    while(1)

    {

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

        {

            c=0;

            if(n%i==0)

            {

                c=1;

                break;



            }

        }

        if(c==0)

        {

            printf("%d",n);

            break;

        }

        n++;

    }

}

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



int isPrime(int n)

{

    int i,count=0;



    if(n>1)



    {

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

        {

            if(n % i == 0)

            {

                count++;

                break;

            }

        }

    }

    if(n==1)

        return 0;

    else

    {



        if(count==0)

        {

            return 1;

        }



        else

        {

            return 0;

        }

    }

}



int main()



{

    int number,ans;



    scanf("%d",&number);

    while(1)

    {

        ans = isPrime(number);

        if(ans == 1)

        {

            printf("%d",number );

            break ;

        }

        else

            number ++ ;







    }

    return 0;











}


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

using namespace std;

int main() {

    long long n;

    cin >> n;

    int flag = 0;

    for (n ; ; n++)

    {

        flag = 0;

        for (int j = 2; j*j<n; j++)

        {

            if (n % j == 0) {

                flag = 1;

                break;

            }

        }

        if (!flag) {

            cout << n << endl;

            return 0;

        }

    }

    return 0;

}

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



int isPrime(int n)

{

    int i,count=0;



    if(n>1)



    {

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

        {

            if(n % i == 0)

            {

                count++;

                break;

            }

        }

    }

    if(n==1)

        return 0;

    else

    {



        if(count==0)

        {

            return 1;

        }



        else

        {

            return 0;

        }

    }

}



int main()



{

    int number,ans;



    scanf("%d",&number);

    while(1)

    {

        ans = isPrime(number);

        if(ans == 1)

        {

            printf("%d",number );

            break ;

        }

        else

            number ++ ;







    }

    return 0;











}


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

using namespace std;

int main ()

{

    int n,i,j;

    bool flag=true;

     cin>>n;

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

   {

       flag=true;

    for(j=2;j<=(i/2);j++)

    {

        if(i%j==0)

        {

          flag=false;

          break;

        }

    }

    if(flag==true)

    {

        cout<<i<<endl;

        i=-1;

    }

   }





}






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



int isPrime(int n)

{

    int i,count=0;



    if(n>1)



    {

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

        {

            if(n % i == 0)

            {

                count++;

                break;

            }

        }

    }

    if(n==1)

        return 0;

    else

    {



        if(count==0)

        {

            return 1;

        }



        else

        {

            return 0;

        }

    }

}



int main()



{

    int number,ans;



    scanf("%d",&number);

    while(1)

    {

        ans = isPrime(number);

        if(ans == 1)

        {

            printf("%d",number );

            break ;

        }

        else

            number ++ ;







    }

    return 0;











}


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

using namespace std;

 

int main(){

	   

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	int n;

	cin>>n;

	while(1){

	   bool flag = true;

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

	        if(n%i==0){

	            flag = false;

	            break;

	        }

	    }

	    if(flag) break;

	    n++;

	}

	cout<< n <<endl;

	 

return 0;

}

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



int isPrime(int n)

{

    int i,count=0;



    if(n>1)



    {

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

        {

            if(n % i == 0)

            {

                count++;

                break;

            }

        }

    }

    if(n==1)

        return 0;

    else

    {



        if(count==0)

        {

            return 1;

        }



        else

        {

            return 0;

        }

    }

}



int main()



{

    int number,ans;



    scanf("%d",&number);

    while(1)

    {

        ans = isPrime(number);

        if(ans == 1)

        {

            printf("%d",number );

            break ;

        }

        else

            number ++ ;







    }

    return 0;











}


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

using namespace std;



int X;



int sieve_of_eratosthenes() {

  vector<bool> is_prime(100003, true);

  is_prime[0] = is_prime[1] = false;

  for(int i=2; i<=X; i++)

    if(is_prime[i]) {

      for(int k=2; k * i <= 100003; k++)

        is_prime[k*i] = false;

    }

  for(int i=X; i<=100003; i++)

    if(is_prime[i]) return i;

  return 0;

}



signed main() {

  cin >> X;

  cout << sieve_of_eratosthenes() << endl;

}


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

using namespace std;



vector<bool> sieve_of_eratosthenes(int n) {

  /* O(n log log n) */

  vector<bool> is_prime(n, true);

  is_prime[0] = is_prime[1] = false;

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

    if(is_prime[i]) 

      for(int k=2; k * i <= n; k++)

        is_prime[k*i] = false;

  return is_prime;

}



vector<int> prime_list(int n) {

  /* O(n log log n) */

  auto is_prime = sieve_of_eratosthenes(n);

  vector<int> primes;

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

    if(is_prime[i]) 

      primes.push_back(i);

  return primes;

}



map<int, int> prime_factorization(int n) {

  /* O(n log log n) */

  auto primes = prime_list((int)ceil(sqrt(n)));

  map<int,int> factors;

  for(auto i : primes) {

    while (n%i==0) {

      factors[i]++;

      n /= i;

    }

  }

  if(n!=1) factors[n]++;

  return factors;

}



bool is_prime(int n){

  /* O(log n) */

  if(n<=1) return false;

  for(int i=2;i*i<=n;i++) if(n%i==0) return false;

  return true;

}



signed main() {

#if 0

  // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009

  const int n_max = 999999;

  auto is_prime = sieve_of_eratosthenes(n_max);

  vector<int> csum(n_max, 0);

  for(int i=2; i<=n_max; i++) 

    csum[i] = csum[i-1] + (is_prime[i] ? 1 : 0);



  int n;

  while(cin >> n) cout << csum[n] << endl;



#elif 0

  // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A

  int n;

  cin >> n;

  cout << n << ":";

  auto factors = prime_factorization(n);

  for(auto f : factors) for(int i=0; i<f.second; i++) cout << " " << f.first;

  cout << endl;



#else

  // https://atcoder.jp/contests/abc149/tasks/abc149_c

  int x;

  cin>>x;



  int p=x;

  while(!is_prime(p)) p++;



  cout << p << endl;

#endif

}


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

using namespace std;

#define ll          long long int

#define pb          push_back

#define pll         pair<ll,ll>

#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mode        998244353

#define mod         1000000007

#define inf         1000000000000000000LL

#define vl          vector<ll>

#define F           first

#define S           second

#define db          long double

#define sz(x)       (ll)x.size()

#define fix(n)      cout<<fixed<<setprecision(n)

#define rep(i,a,b)  for(ll i=a;i<b;i++)

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

#define mset(x)     memset(x,0,sizeof x)

#define pi          3.14159265358979323



const int N = 1e5+5;



ll n, v[101], w[101], wt, dp[101][N];



void solve()

{

       cin>>n>>wt;

       rep(i,1,n+1) cin>>w[i]>>v[i];

       rep(i,1,N) dp[0][i]=inf;

       // imp: dp[0][0] = 0

       rep(i,1,n+1)

       {

              rep(j,0,N)

              {

                     dp[i][j]=dp[i-1][j];

                     if(j>=v[i]) dp[i][j]=min(dp[i][j], dp[i-1][j-v[i]]+w[i]);

              }

       }

       ll ans=0;

       rep(j,0,N) if(dp[n][j]<=wt) ans=j;

       cout<<ans;

}





int main() {

	ll T = 1;

	speed_up

	//cin>>T;

	while(T--)

	    solve();

	return 0;

}


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

using namespace std;

#define ll          long long int

#define pb          push_back

#define pll         pair<ll,ll>

#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mode        998244353

#define mod         1000000007

#define inf         1000000000000000000LL

#define vl          vector<ll>

#define F           first

#define S           second

#define db          long double

#define sz(x)       (ll)x.size()

#define fix(n)      cout<<fixed<<setprecision(n)

#define rep(i,a,b)  for(ll i=a;i<b;i++)

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

#define mset(x)     memset(x,0,sizeof x)

#define pi          3.14159265358979323



const int N = 1e5+5;

ll n, wt, v[101], w[101];



void solve()

{

       cin>>n>>wt;

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

       ll valsum=0;

       rep(i,0,n) valsum += v[i];

       vl dp(valsum+1, INT_MAX);

       dp[0]=0;

       for(ll item=0; item<n; item++)

       {

              ll value = v[item];

              ll weight = w[item];

              for(ll value_already = valsum - value; value_already>=0; value_already--)

              {

                     dp[value_already + value] = min(dp[value_already + value], dp[value_already] + weight);

              }

       }

       ll ans=0;

       rep(i, 0, valsum+1) if(dp[i] <= wt) ans = i;

       cout<<ans;

}







int main() {

	ll T = 1;

	speed_up

	//cin>>T;

	while(T--)

	    solve();

	return 0;

}


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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

ll dp[MAX];

int main (){

    int N,W;cin >> N >> W;

    memset(dp,63,sizeof dp);

    dp[0]=0;

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

        int w,val;

        cin >> w >> val;

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

            if(j-val>=0)

                dp[j]=min(dp[j],dp[j-val]+w);

        }



    }

    int res=0;

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

        if(dp[i]<=W) res = max(res,i);

    }

    cout<<res<<endl;

    return 0;

}


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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    scanf("%d %lld", &n, &w);

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

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

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

        {

            printf("%d", i);

            break;

        }

}


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

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



#include <cmath>

#include <iomanip>



using namespace std;



int main()

{

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  int w;

  cin >> w;

  int weights[n];

  long long int values[n];

  long long int cur;

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

    cin >> cur;

    weights[i] = cur;

    cin >> cur;

    values[i] = cur;

  }

  long long int dp[n+1][(1000*n)+1];

  //dp[n][v] represents the minimum weight needed to get value v and only using items with number up to n.

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

    dp[i][0] = 0;

    for (int j = 1; j < (1000*n)+1; j++) {

      dp[i][j] = w+1;

    }

  }

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

    for (int wanted = 0; wanted < (1000*n); wanted++) {

      dp[minInd+1][wanted] = min(dp[minInd+1][wanted], dp[minInd][wanted]);

      if (dp[minInd][wanted]+weights[minInd] <= w) {

	dp[minInd+1][wanted+values[minInd]] = min(dp[minInd+1][wanted+values[minInd]], dp[minInd][wanted]+weights[minInd]);

      }

    }

  }

  for (int i = (1000*n); i > 0; i--) {

    if (dp[n][i] <= w) {

      cout << i << "\n";

      break;

    }

  }

  return 0;

}

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    scanf("%d %lld", &n, &w);

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

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

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

        {

            printf("%d", i);

            break;

        }

}


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

using namespace std;



#define pb push_back

#define mk make_pair

#define fi first

#define se second

#define eb emplace_back



typedef long long ll;

typedef pair<int,int> ii;

typedef vector< pair<int,int> > vii;

const ll INF = 0x3f3f3f3f3f3fef;



const int V = 1e5+2;

const int N = 102;



ll dp[V];

ll p[N];

ll v[N];

ll n,w;

 

int main() {

    ios_base::sync_with_stdio(false);

    for(int i = 0; i < V; i++) dp[i] = INF;



    cin >> n >> w;

    for(int i = 0; i < n; i++) cin >> p[i] >> v[i];

    

    dp[0] = 0;



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

        for(ll j = V-1; j-v[i] >= 0; j--)

            dp[j] = min(dp[j], dp[j-v[i]]+p[i]);



    for(int i = V-1; i >= 0; i--)

        if(dp[i] <= w) { cout << i << endl; return 0; }





    return 0;

}




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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    scanf("%d %lld", &n, &w);

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

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

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

        {

            printf("%d", i);

            break;

        }

}


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

#include <bits/stdc++.h>

     

#define f first

#define s second

#define int long long

#define ld long double

#define ull unsigned long long

#define pii pair <int, int>

#define pll pair <long, long>

#define mp make_pair

#define pb push_back

#define pf push_front

#define pp pop_back

#define rev reverse

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

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

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

#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);

#define nxtp next_permutation

#define pvtp prev_permutation

#define KZ return 

#define x1 x21212121

#define y1 y21212121

#define sqr(x) x * x 

 

const int inf = (1e9) + 1;

const int mod = 1e9 + 7;

const int maxn = 1e5 + 111;

     

using namespace std;



int q, n, w, a[maxn], b[maxn], dp[105][maxn], ans;



void solve(){    

	cin >> n >> w;



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

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



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

		for (int j = 1e5; j >= 0; j--)

			dp[i][j] = inf;



	dp[0][0] = 0;



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

		for (int j = 1e5; j >= 0; j--){

			dp[i][j] = dp[i - 1][j];

			if (j - b[i] >= 0)

				dp[i][j] = min(dp[i][j], dp[i - 1][j - b[i]] + a[i]);

			if (dp[i][j] <= w)

				ans = max(ans, j);

		}

		/*for (int j = 1; j <= 20; j++)

			cout << dp[i][j] << " ";

		cout << endl;	*/

		//cout << dp[i][100000] << endl;

	}



	//cout << dp[n][100000] << " ";



	/*for (int i = 0; i <= w; i++)

		cout << dp[i] << " ";

	*/

	cout << ans;

}



main(){

    boost;

	    

	q = 1;



	while (q--){

		solve();

	}

}

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    scanf("%d %lld", &n, &w);

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

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

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

        {

            printf("%d", i);

            break;

        }

}


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



using namespace std;



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

#define rloop(i, n) for(int i = int(n);i >= 0;i--)

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

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

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

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int, int> > vii;

typedef long long ll;

typedef pair<int, int> pii;



const int N = 105;

const int V = 1e5 + 5;

int dp[2][V];

int w[N], v[N];

int n, W;





int main() {



#ifndef ONLINE_JUDGE

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

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

#endif

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    cin >> n >> W;

    range(i, 1, V - 1)dp[n & 1][i] = W + 2;



    loop(i, n)cin >> w[i] >> v[i];



    rloop(i, n - 1) {

        loop(j, V) {

            dp[i & 1][j] = dp[i & 1 ^ 1][j];

            if (j >= v[i])dp[i & 1][j] = min(dp[i & 1][j], dp[i & 1 ^ 1][j - v[i]] + w[i]);

        }

    }



    int ans = 0;

    rloop(i, V - 1) {

        if (dp[0][i] <= W) {

            ans = i;

            break;

        }

    }



    cout << ans << endl;



    return 0;

}


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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    scanf("%d %lld", &n, &w);

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

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

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

        {

            printf("%d", i);

            break;

        }

}


// Fastest known solution for this problem: