stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <iostream>





using namespace std;



const int MaxN = 1e5 + 5;



long long dp[MaxN];

long long w[105] , W , n;

long long v[MaxN];



int main(){

	memset(dp , 0x3f , sizeof dp);

	cin >> n >> W;

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

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

	}

	dp[0] = 0;

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

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

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

		}

	}

	for(int i = MaxN - 1 ; i >= 0 ; i--){

		if(dp[i] <= W){

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

			break;

		}

	}

	return 0;

}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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



#define pb push_back

#define se second

#define fi first



using namespace std;



int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;

long long d[(int)2e5 + 7], mx;



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cin >> n >> w;

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

        cin >> a[i] >> c[i];

    for(int i = 1e5 + 6; i > 0; i--)

        d[i] = 1e9 + 7;

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

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

        if(d[j] != 1e9 + 7)

            d[j + c[i]] = min(d[j + c[i]], d[j] + a[i]);

    for(int j = 0; j <= 1e5 + 6; j++)

        if(d[j] <= w)

            mx = j;

    cout << mx;

}


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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define pb push_back

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

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

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

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

const int mod = 1e9;

const int N = 1e5 + 10;

/*=======================================================================*/



ll n, W, w[N], v[N], f[N];

ll ans = 0;

int main() {

  cin >> n >> W;

  ms(f, inf);

  f[0] = 0;

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



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

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

        if (f[l - v[i]] + w[i] < f[l]) {

         //   debug1

            f[l] = f[l - v[i]] + w[i];

         }

         if(f[l] <= W) ans = max(ans, (ll)l);

     }

  }

  cout << ans << endl;

  return 0;

}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#define LL long long

using namespace std;

LL f[(int)1e5 + 10];

int main(){

    ios::sync_with_stdio(false);

    memset(f, 0x7f, sizeof(f));

    f[0] = 0;

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

    int maxl = 0, ans = 0;

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

        int wi, vi; cin>>wi>>vi;

        maxl += vi;

        for(int j = maxl; j >= vi; j--){

            f[j] = min(f[j], f[j - vi] + wi);

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

        }

    }

    cout<<ans;

    return 0;

}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

using namespace std;

const int N = 1e5 + 10;

int dp[N];

int w[110];

int v[110];

int main()

{

	int n, sumw;

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

	int sum = 0;

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

	{

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

		sum += v[i];

	}

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

	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] <= sumw)

		{

			printf("%d", i);

			return 0;

		}

	}

	return 0;

}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

typedef long long ll;

using namespace std;

const ll N=200010,INF=1e14;

int main(){

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

	ll n,i,j,dp[N],cap,t,val=0,a[N],b[N],best;

	cin>>n>>cap;

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

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

		val+=b[i];

	}

	for(i=1;i<=val;++i) dp[i]=INF;

	dp[0]=0;

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

		for(j=val;j>=b[i];--j){

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

		}

	}

	for(i =val;i>=0;i--){

		if(dp[i] <= cap){

			cout << i << endl;

			break;

		}

	}

	return 0;

}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

#include <algorithm>

#include <vector>

using namespace std;

 

long long n,dp[100005],w,v,k,mxw,ans,pt,lpt;

bool d[100005];

int main(){

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

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

		dp[i]=1e9+1;

	}

	d[0]=true; dp[0]=0;

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

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

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

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

				d[j+v]=true;

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

			}

		}

	}

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

		if	(d[i])

		ans=i;

	}

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

	return 0;

} 

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

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

#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";

#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";

#define     watch(a)        cout<<fixed<<setprecision(a)

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

#define     Endl            "\n";

#define     tab             "\t"

#define     reset(a,b)      memset(a,b,sizeof(a));

#define     sfl(a)          scanf(" %lld", &a);

#define     sf(a)           scanf(" %d", &a);

#define     srt(a)          sort(a.begin(),a.end());

#define     pi              2*acos(0.0)

const int sz=1e5+9;

const ll inf=1e18L+9;

ll dp[sz];





void solve(){

    reset(dp,inf);

    int n,w;

    sf(n);

    sf(w);

    vector<pair<ll,int>>v(n);

    dp[0]=0;

    int pnt=0;

    lp(i,0,n){

       sfl(v[i].first);

       sf(v[i].second);

       pnt+=v[i].second;

    }

    //bug(pnt, 1);

   // sort(v.begin(),v.end(),com);

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



        for(int j=pnt-v[i].second;j>=0;j--){

            dp[j+v[i].second]=min( dp[j+v[i].second],dp[j]+v[i].first);

        }



    }

   // bug("140 dp",dp[140]);

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

        if(dp[i]<=w){

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

            return;

        }

    }

}



int main(){

    //FasterIO;

    #ifndef ONLINE_JUDGE

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

    #endif

    //int t;

//cin>>t;

   // while(t--)

        solve();

}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

}
// Slower C++ solution:
																//  SMOKE SHISHA PLAY FIFA  // 

#include<bits/stdc++.h>

using namespace std;



typedef long long int ll;

typedef long double ld;



#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

#define pll pair<ll,ll>

#define MP make_pair

#define ff first

#define ss second

#define PB push_back

#define mod 1000000007

#define lp(i,start,end) for(ll i=start;i<=end;i++) 

#define deb1(a) cout<<#a<<" = "<<(a)<<endl;

#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;

#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;





ll modu(ll a, ll b)

{

	ll ans =1;

	while(b>0)

	{

		if(b&1)

		ans = (ans*a)%mod;

		b/=2;

		a = (a*a)%mod;

	}

	return ans;

}



int main()

{

	fastio

	ll t=1;

	//cin >> t;

	while(t--)

	{

		ll n,wt,ma=0;

		cin>>n>>wt;

		ll w[n+1],v[n+1];

		lp(i,1,n){

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

			ma+=v[i];

		}

		ll dp[100000];

		dp[0]=0;

		lp(i,1,100000)

			dp[i]=1000000000007;

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

			for(ll i=ma; i>=v[j]; i--){

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

			}

	}

		ll ans=0;

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

			if(dp[i]<=wt){

				ans=max(ans,i);

			}

		}

		cout<<ans<<endl;



	}

	return 0;	

}


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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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



using namespace std;

typedef long long ll;

typedef unsigned long long ull;



const int mod  = 100003;

const int maxn = 1e5+10;



ll val[105],v[105],dp[100025];

int main()

{

	int n,V;

	ll ans = 0;

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

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

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

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

    dp[0]=0;

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

    {

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

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

    }

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

    	if(dp[i]<=V)

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

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

    return 0;

}


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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N1 = 1e2 + 5;

const int N = 1e5 + 5;

bool possible[N][N1];

ll dp[N][N1],v[N1],w[N1];

ll n;

ll func(ll val, ll i)

{

	if(val<=0)

	 return 0;

	if(i==(n+1))

	return INT_MAX;

	if(possible[val][i])

	return dp[val][i];

	possible[val][i] = true;

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

	return dp[val][i]; 

	

	

}



void solve(){

            ll i,j,W;

            cin>>n>>W;

            //ll w[n+1]={0},v[n+1]={0};

            fo(i,1,n+1)

            {

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

			}

			//ll dp[n+1][W+1];

			ll v_max = 0;

			fo(i,1,n+1)

			v_max+=v[i];//,w_max+=w[i];

			

			

			

			for(i = v_max;i>=0;i--)

			{

				if(func(i,1)<=W)

				{

					cout<<i<<endl;

					break;

				}

			}

			



















}



int main()

{

    IO;

      ll t=1,i;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

}