stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



//int from[1009];



int main()

{ 

  ll dp[100009];

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

    dp[i] = 10000000000000ll;

  ll w[109];

  int v[109];

  dp[0]= 0;

  int n;

  ll cap;

  ll sum = 0;

  cin >> n >> cap; 

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

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

    sum = sum + v[i]; 

  }

  //cout << sum << endl;

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



      int current = sum - v[i];

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

        int index = j + v[i];

          //cout << j << " " << dp[index] << " " << dp[j]+w[i] << endl;

        dp[index] = min(dp[index],dp[j]+w[i]);

      

      }

      

      //cout << endl;

    

  }



  int ans = 0;

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

    if(dp[i]<=cap)

      ans = max(i,ans);

  }

  cout << ans << endl;



}

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

using namespace std;

typedef long long ll;

#define REPT(x, l, r) for(int x = l; x <=r; ++x)

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

int n, w;

int main(){

    cin>>n>>w;

    int arr[n+1];

    int arr2[n+1];

    int sum = 0;

    REPT(x, 1, n){

        cin>>arr[x]>>arr2[x];

        sum += arr2[x];

    }



    int dp[n+1][sum+1] = {};



    dp[0][0] = 0;



    REPT(x, 0, n){

        REPT(y, 1, sum){

            if(x == 0){

                dp[x][y] = w+1;

            }else{

                if(y < arr2[x]){

                    dp[x][y] = dp[x-1][y];

                }else{

                    dp[x][y] = min(dp[x-1][y], arr[x] + dp[x-1][y-arr2[x]]);

                }

            }

        }

    }

    int maxa = 0;

    for(int x = 1; x<= sum;x++){

        if(dp[n][x] <= w)

            maxa = x;

    }

    cout<<maxa<<endl;





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

#include<cstring>

#include<vector>

using namespace std;

const int maxn = 1e5 + 10;

long long w[maxn];

long long v[maxn];

long long dp[maxn];

int main(){

	int n,V;

	long long ans = 0;

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

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

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

    memset(dp,0x3f,sizeof(dp));

    dp[0] = 0;

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

    {

        for(int j = 100000;j>=w[i];j--)

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

    }

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

	if(dp[i]<=V) 

		ans = max(ans,(long long)i);

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

	return 0;

}


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

using namespace std;

typedef long long ll;

#define REPT(x, l, r) for(int x = l; x <=r; ++x)

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

int n, w;

int main(){

    cin>>n>>w;

    int arr[n+1];

    int arr2[n+1];

    int sum = 0;

    REPT(x, 1, n){

        cin>>arr[x]>>arr2[x];

        sum += arr2[x];

    }



    int dp[n+1][sum+1] = {};



    dp[0][0] = 0;



    REPT(x, 0, n){

        REPT(y, 1, sum){

            if(x == 0){

                dp[x][y] = w+1;

            }else{

                if(y < arr2[x]){

                    dp[x][y] = dp[x-1][y];

                }else{

                    dp[x][y] = min(dp[x-1][y], arr[x] + dp[x-1][y-arr2[x]]);

                }

            }

        }

    }

    int maxa = 0;

    for(int x = 1; x<= sum;x++){

        if(dp[n][x] <= w)

            maxa = x;

    }

    cout<<maxa<<endl;





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

#include<stdio.h>

#include<algorithm>

#include<cstring>

#include<queue>

#include<vector>

#define ll long long

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

using namespace std;

const int maxn = 1e6+5;

int v[maxn];

ll dp[maxn], w[maxn];



int main(){

	memset(dp, 0x3f, sizeof(dp));

	int n, W; cin >> n >> W;

	int sum = 0;

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

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

		sum += v[i];

	}

	dp[0] = 0;

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

		for(int j = sum; j >= v[i]; j--)

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

	}

	for(int i = sum; i >= 0; i--){

		if(dp[i] <= W){

			cout << i << endl;

			break;

		}

	}

}

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

using namespace std;

typedef long long ll;

#define REPT(x, l, r) for(int x = l; x <=r; ++x)

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

int n, w;

int main(){

    cin>>n>>w;

    int arr[n+1];

    int arr2[n+1];

    int sum = 0;

    REPT(x, 1, n){

        cin>>arr[x]>>arr2[x];

        sum += arr2[x];

    }



    int dp[n+1][sum+1] = {};



    dp[0][0] = 0;



    REPT(x, 0, n){

        REPT(y, 1, sum){

            if(x == 0){

                dp[x][y] = w+1;

            }else{

                if(y < arr2[x]){

                    dp[x][y] = dp[x-1][y];

                }else{

                    dp[x][y] = min(dp[x-1][y], arr[x] + dp[x-1][y-arr2[x]]);

                }

            }

        }

    }

    int maxa = 0;

    for(int x = 1; x<= sum;x++){

        if(dp[n][x] <= w)

            maxa = x;

    }

    cout<<maxa<<endl;





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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f

#define INF 0x3f3f3f3f

#define pb push_back

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define ms(a, x) memset(a, x, sizeof(a))

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

#define for1(i, n) for(int i = 1; i <= n; ++i)

using namespace std;

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<long long, int> pli;

typedef pair<long long, long long> pll;

const int mod = 1e9 + 7;

const int N = 1e5+10;

const int M = 1e6+10;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}

inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}

//==================================================================================================================================================================//



ll n, W, dp[N];

int ans;



int main() {

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

   ms(dp, inf); dp[0] = 0;

   for1(i, n) {

      ll w, v;

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

      for(int j = 100000; j >= v; --j) {

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

      }

   }

   for1(i, 100000) if(dp[i] <= W) ans = i;

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

   return 0;

}

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

using namespace std;

typedef long long ll;

#define REPT(x, l, r) for(int x = l; x <=r; ++x)

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

int n, w;

int main(){

    cin>>n>>w;

    int arr[n+1];

    int arr2[n+1];

    int sum = 0;

    REPT(x, 1, n){

        cin>>arr[x]>>arr2[x];

        sum += arr2[x];

    }



    int dp[n+1][sum+1] = {};



    dp[0][0] = 0;



    REPT(x, 0, n){

        REPT(y, 1, sum){

            if(x == 0){

                dp[x][y] = w+1;

            }else{

                if(y < arr2[x]){

                    dp[x][y] = dp[x-1][y];

                }else{

                    dp[x][y] = min(dp[x-1][y], arr[x] + dp[x-1][y-arr2[x]]);

                }

            }

        }

    }

    int maxa = 0;

    for(int x = 1; x<= sum;x++){

        if(dp[n][x] <= w)

            maxa = x;

    }

    cout<<maxa<<endl;





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

using namespace std;

const int inf = 2e9+7;



long long w[101], v[101];

long long f[110][100100];



int main()

{

    int N, V, i, j;



    cin>>N>>V;



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

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

    fill(f[0],f[0]+100001,inf);

    f[0][0] = 0;

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

    {

        for(j=0;j<=100000;j++)

            if(j >= v[i])

                f[i+1][j] = min(f[i][j-v[i]] + w[i], f[i][j]);

            else

                f[i+1][j] = f[i][j];

    }

    int res=0;

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

        if(f[N][i]<=V)

            res = i;



    cout<<res<<endl;



    return 0;

}

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

#define ll long long

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define scn(n) scanf("%d",&n)

#define scnll(n) scanf("%lld",&n)

#define nl printf("\n")

#define YES printf("YES\n")

#define Yes printf("Yes\n")

#define yes printf("yes\n")

#define NO printf("NO\n")

#define No printf("No\n")

#define no printf("no\n")

using namespace std;

ll n,wt;

ll dp[100002][2];

ll w[101],v[101];

int solve(int val){

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

        int prev=i%2;

        int now=(i+1)%2;

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

            if(v[i]>=j){

                if(dp[j][prev]!=-1) dp[j][now]=min(dp[j][prev],w[i]);

                else dp[j][now]=w[i];

            }

            else{

                if(dp[j-v[i]][prev]!=-1){

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

                    else dp[j][now]=dp[j-v[i]][prev]+w[i];

                }

                else dp[j][now]=dp[j][prev];

            }

        }

    }

    int now=(n+1)%2;

    while(val){

        if(dp[val][now]<=wt&&dp[val][now]!=-1){

            break;

        }

        val--;

    }

    return val;

}

int main(){

    scnll(n);

    scnll(wt);

    int val=0;

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

        dp[i][0]=-1;

        dp[i][1]=-1;

    }

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

        scn(w[i]);

        scn(v[i]);

        val+=v[i];

    }

    int ans=solve(val);

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

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



using namespace std;





typedef long long ll;



const int MAX = 1e5+5;

ll dp[MAX+MAX];



int n , W;







int main()

{



    ios_base::sync_with_stdio(0);cin.tie(0);

    cin>>n>>W;



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

        dp[j] = LONG_LONG_MAX;





    dp[0] = 0;

    ll ans = 0;

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





        ll w , v;

        cin>>w>>v;



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



            if( dp[j] != LONG_LONG_MAX ) {



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

                if( dp[j+v] <= W )

                ans = max( ans , j+v );



            }



        }



    }



    cout<<ans<<"\n";

}


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

#define ll long long

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define scn(n) scanf("%d",&n)

#define scnll(n) scanf("%lld",&n)

#define nl printf("\n")

#define YES printf("YES\n")

#define Yes printf("Yes\n")

#define yes printf("yes\n")

#define NO printf("NO\n")

#define No printf("No\n")

#define no printf("no\n")

using namespace std;

ll n,wt;

ll dp[100002][2];

ll w[101],v[101];

int solve(int val){

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

        int prev=i%2;

        int now=(i+1)%2;

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

            if(v[i]>=j){

                if(dp[j][prev]!=-1) dp[j][now]=min(dp[j][prev],w[i]);

                else dp[j][now]=w[i];

            }

            else{

                if(dp[j-v[i]][prev]!=-1){

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

                    else dp[j][now]=dp[j-v[i]][prev]+w[i];

                }

                else dp[j][now]=dp[j][prev];

            }

        }

    }

    int now=(n+1)%2;

    while(val){

        if(dp[val][now]<=wt&&dp[val][now]!=-1){

            break;

        }

        val--;

    }

    return val;

}

int main(){

    scnll(n);

    scnll(wt);

    int val=0;

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

        dp[i][0]=-1;

        dp[i][1]=-1;

    }

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

        scn(w[i]);

        scn(v[i]);

        val+=v[i];

    }

    int ans=solve(val);

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

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

#define ll long long

#define ull unsigned long long

#define IO ios::sync_with_stdio(false), cin.tie(0)

#define endl '\n'

#define main() int main()

#define ff1(i,n) for(int i=1;i<=n;++i)

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

#define pi acos(-1.0)

#define ms(a, x) memset(a, x, sizeof(a))

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

#define pb push_back

#define binarycount __builtin_popcount(x)

#define tr t[root]

#define lson t[root << 1]

#define rson t[root << 1 | 1]

#define fir first

#define sec second

#define debug(x) cout<<x<<'\n'

#define sa(a) scanf("%d", &a)

#define sab(a, b) scanf("%d%d", &a, &b)

#define pa(a) printf("%d",a)

#define pab(a,b) printf("%d%d",a,b)

#define pii pair<string,int>

using namespace std;



#define maxn 1000010

const int inf = 0x3f3f3f3f;

const int mod = 9973;

const double eps = 1e-8;

ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}

ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}

int max(int x,int y){if(x>y) return x;return y;}

ll powmod(ll a,ll b){

    ull ans = 1, pow = a%mod;

    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }

    return ans%mod;

}

ll v[105],w[105];	

ll dp[maxn],n,W,ans;

main()

{

	IO;

	cin>>n>>W;

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

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

	}

	ans=0;

	ms(dp,0x3f);

	dp[0]=0;

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

		for(int j=1e5;j>=v[i];j--){

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

			if(dp[j]<=W) ans=max(ans,(ll)j);

		}

	}

	cout<<ans<<endl;

} 

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

#define ll long long

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define scn(n) scanf("%d",&n)

#define scnll(n) scanf("%lld",&n)

#define nl printf("\n")

#define YES printf("YES\n")

#define Yes printf("Yes\n")

#define yes printf("yes\n")

#define NO printf("NO\n")

#define No printf("No\n")

#define no printf("no\n")

using namespace std;

ll n,wt;

ll dp[100002][2];

ll w[101],v[101];

int solve(int val){

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

        int prev=i%2;

        int now=(i+1)%2;

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

            if(v[i]>=j){

                if(dp[j][prev]!=-1) dp[j][now]=min(dp[j][prev],w[i]);

                else dp[j][now]=w[i];

            }

            else{

                if(dp[j-v[i]][prev]!=-1){

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

                    else dp[j][now]=dp[j-v[i]][prev]+w[i];

                }

                else dp[j][now]=dp[j][prev];

            }

        }

    }

    int now=(n+1)%2;

    while(val){

        if(dp[val][now]<=wt&&dp[val][now]!=-1){

            break;

        }

        val--;

    }

    return val;

}

int main(){

    scnll(n);

    scnll(wt);

    int val=0;

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

        dp[i][0]=-1;

        dp[i][1]=-1;

    }

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

        scn(w[i]);

        scn(v[i]);

        val+=v[i];

    }

    int ans=solve(val);

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

}
// Slower C++ solution:
// Author : Syed Mujtaba

// Seek knowledge from the Cradle to the Grave !!

// https://www.linkedin.com/in/syed-mujtaba-064a5016a 



#include <bits/stdc++.h>

using namespace std;

#define int     long long

#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main()

{

	fast_io

	int n, w;

	cin >> n >> w;

	vector < int > wt(n), val(n);

	int dp[n + 1][100008] = {0};



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

		cin >> wt[i] >> val[i];

	for(int i = 0; i <= 100000; i++) // base case

	{

		if(i == 0)

			dp[1][0] = 0;

		else if(i == val[0] && wt[0] <= w)

			dp[1][i] = wt[0];

		else

			dp[1][i] = 1e18;

	}

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

	{

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

		{

			dp[i][j] = 1e18;

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

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

				dp[i][j] = min(dp[i][j], dp[i - 1][j - val[i - 1]] + wt[i - 1]);

		}	

	}

	int ans;

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

	{

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

			ans = i;

	}

	cout << ans << endl;

}

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

#define ll long long

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define scn(n) scanf("%d",&n)

#define scnll(n) scanf("%lld",&n)

#define nl printf("\n")

#define YES printf("YES\n")

#define Yes printf("Yes\n")

#define yes printf("yes\n")

#define NO printf("NO\n")

#define No printf("No\n")

#define no printf("no\n")

using namespace std;

ll n,wt;

ll dp[100002][2];

ll w[101],v[101];

int solve(int val){

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

        int prev=i%2;

        int now=(i+1)%2;

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

            if(v[i]>=j){

                if(dp[j][prev]!=-1) dp[j][now]=min(dp[j][prev],w[i]);

                else dp[j][now]=w[i];

            }

            else{

                if(dp[j-v[i]][prev]!=-1){

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

                    else dp[j][now]=dp[j-v[i]][prev]+w[i];

                }

                else dp[j][now]=dp[j][prev];

            }

        }

    }

    int now=(n+1)%2;

    while(val){

        if(dp[val][now]<=wt&&dp[val][now]!=-1){

            break;

        }

        val--;

    }

    return val;

}

int main(){

    scnll(n);

    scnll(wt);

    int val=0;

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

        dp[i][0]=-1;

        dp[i][1]=-1;

    }

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

        scn(w[i]);

        scn(v[i]);

        val+=v[i];

    }

    int ans=solve(val);

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

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

#include<stdio.h>

#include<algorithm>

#include<cstring>

#include<queue>

#include<vector>

#define ll long long

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

using namespace std;

const int maxn = 1e6+5;

int v[maxn];

ll dp[maxn], w[maxn];



int main(){

	memset(dp, 0x3f, sizeof(dp));

	int n, W; cin >> n >> W;

	int sum = 0;

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

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

		sum += v[i];

	}

	dp[0] = 0;

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

		for(int j = sum; j >= v[i]; j--)

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

	}

	for(int i = sum; i >= 0; i--){

		if(dp[i] <= W){

			cout << i << endl;

			break;

		}

	}

}

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

#define ll long long

#define pb push_back

#define pf push_front

#define pob pop_back

#define pof pop_front

#define scn(n) scanf("%d",&n)

#define scnll(n) scanf("%lld",&n)

#define nl printf("\n")

#define YES printf("YES\n")

#define Yes printf("Yes\n")

#define yes printf("yes\n")

#define NO printf("NO\n")

#define No printf("No\n")

#define no printf("no\n")

using namespace std;

ll n,wt;

ll dp[100002][2];

ll w[101],v[101];

int solve(int val){

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

        int prev=i%2;

        int now=(i+1)%2;

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

            if(v[i]>=j){

                if(dp[j][prev]!=-1) dp[j][now]=min(dp[j][prev],w[i]);

                else dp[j][now]=w[i];

            }

            else{

                if(dp[j-v[i]][prev]!=-1){

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

                    else dp[j][now]=dp[j-v[i]][prev]+w[i];

                }

                else dp[j][now]=dp[j][prev];

            }

        }

    }

    int now=(n+1)%2;

    while(val){

        if(dp[val][now]<=wt&&dp[val][now]!=-1){

            break;

        }

        val--;

    }

    return val;

}

int main(){

    scnll(n);

    scnll(wt);

    int val=0;

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

        dp[i][0]=-1;

        dp[i][1]=-1;

    }

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

        scn(w[i]);

        scn(v[i]);

        val+=v[i];

    }

    int ans=solve(val);

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

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

#include <iostream>

#include <vector>

using namespace std;



typedef long long ll;

typedef pair<int, int> PII;

typedef pair<ll, ll> PLL;

#define INF (1e9)

#define MOD (1e9 + 7)

#define LINF (1e18)

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

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

#define ALLR(obj) (obj).rbegin(), (obj).rend()



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int n, max_w;

    cin >> n >> max_w;



    ll w[n], v[n];

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



    ll max_v = 100000;

    // dp[i] : 価値iを作れるときの重さの最小値

    vector<ll> dp(max_v + 1, LINF);



    dp[0] = 0;

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

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

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

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

        }

    }



    ll ans = 0;

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

        if (dp[i] <= max_w)

            ans = max(ans, (ll)i);

    }



    cout << ans << endl;

}

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

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

using namespace std;

typedef long long LL;

 

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

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

inline bool valid(int x, int w) { return 0 <= x && x < w; }

 

void iostream_init() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.setf(ios::fixed);

    cout.precision(12);

}

 

class Knapsack {

    typedef long long LL;

    struct item {

        LL v, w;

    };

 

    LL W;

    vector<item> items;

    LL lv;

 

    LL solve_rec(size_t k, LL v, LL w) {

        if (w + items[k].w > W) return solve_rec(k+1, v, w);

        LL cv = v, cw = w;

        for (size_t i = k; i < items.size(); ++i) {

            if (cw + items[i].w <= W) {

                cw += items[i].w;

                cv += items[i].v;

            }

        }

        if (lv < cv) lv = cv;

        double fv = v, fw = w;

        for (size_t i = k; i < items.size(); ++i) {

            if (fw + items[i].w <= W) {

                fw += items[i].w;

                fv += items[i].v;

            } else {

                fv += items[i].v * (W - fw) / items[i].w;

                break;

            }

        }

        if (fv - lv < 1 || fv < lv) return lv;

        solve_rec(k+1, v+items[k].v, w+items[k].w);

        return solve_rec(k+1, v, w);

    }

 

    public:

    // 価値v, 重みwのアイテムを追加

    void add_item(LL v, LL w) {

        items.push_back({v, w});

    }

 

    // 重みの合計がW以下になるようにアイテムを選んだときの価値の和の最大値を返す．

    LL solve(LL W_) {

        if(items.empty()) return 0;

        W = W_;

        sort(items.begin(), items.end(), [](const item &a, const item &b) {

                return a.v * b.w > a.w * b.v;

                });

        lv = 0;

        return solve_rec(0, 0, 0);

    };

};

 

int main(){

    iostream_init();

    int N, W;

    cin >> N >> W;

    Knapsack dp;

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

        int w, v;

        cin >> w >> v;

        dp.add_item(v, w);

    }

 

    cout << dp.solve(W) << endl;

    return 0;

}