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

#include <cstring>

using namespace std;

const int maxn=1e5+5;

using ll = long long;

ll dp[maxn];

ll w[maxn],v[maxn];

int main()

{

   ll n,m,mm;

   cin>>n>>mm;

   m=0;

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

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

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

       m+=v[i];

   }

   dp[0]=0;

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

       for(ll j=m;j>=0;--j){

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

          // cout<<dp[j]<<endl;

       }

   }

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

       if(dp[i]<=mm){

           cout<<i<<endl;

           break;

       }

   }

   return 0;

}


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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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

#include <algorithm>

#include <cmath>

#include <cstdlib>

#include <cstdio>

#include <cstring>

#include <iomanip>

#include <string>

#include <set>

#include <vector>

#include <queue>

#include <stack>

using namespace std;

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

#define fore(i, a, n) for (long long i = a; i < n; i++)

#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)

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

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

#define debug(a) cout << a << endl

#define endl '\n'

#define pi acos(-1.0)

#define tr t[root]

#define lson t[root << 1]

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

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

const double eps = 1e-8;

inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }

typedef long long ll;

const int inf = 0x3f3f3f3f;

const int maxn=1000100;

#define maxn0 1e9+7;

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



ll sum;

ll w[maxn];

ll dp[maxn];

ll v[maxn];



// void init() {

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

//         w[i]=0;

//         v[i]=0;

//     }

// }

int main() {

    IO;

    ll n,W;

    cin>>n>>W;

    memset(dp,inf,sizeof(dp));

    dp[0]=0;

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

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

        // sum+=v[i];

    }

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

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

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

        }

    }

    ll ans=-1;

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

        if(dp[i]<=W)

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

    }

    cout<<ans<<endl;



    return 0;

}

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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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



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

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

#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)

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

#define pb push_back

#define eb emplace_back

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

#define F first

#define S second

#define endl '\n'

#define de(x) cout<<#x<<" = "<<(x)<<endl

#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;



using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());



const int N=1e5+5;

ll dp[N];

int v[105],w[105];

int main() {



    ios::sync_with_stdio(false);

    cin.tie(nullptr);

	int N,W;

	cin>>N>>W;

	int sum=0;

	forn(i,N){

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

		sum+=v[i];

	}

	ms(dp,INF);

	dp[0]=0;

	forn(i,N){

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

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

		}

	}

	ll ans=0;

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

		if(dp[i]<=W){

			ans=i;

			break;

		}

	}

	cout<<ans;

	return 0;

}




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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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

using namespace std;

const int N = 1e5+100;

const int M = 200;

typedef long long ll;

int a[N],b[N],n,m;

ll f[N];



int main(){

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

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

		scanf("%d%d",&a[i],&b[i]);

	memset(f, 0x3f, sizeof f);

	f[0] = 0;

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

		for (int j = N - 10; j >= 0; j--)

			if (j - b[i] >= 0) f[j] = min(f[j], f[j-b[i]] + a[i]);



	int ans = 0;

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

		if (f[i] <= m) ans = i;

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

	return 0;

}

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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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

#include<cstdlib>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<stack>

#define LL long long

using namespace std;

LL n,m;

LL dp[100011];

LL x,y,ans;

LL read()

{

	LL _=0,__=1;char ch=getchar();

	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}

	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}

	return _*__;

}

int main()

{

	n=read();m=read(); 

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

	dp[i]=1e9+7;

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

	{

		x=read();y=read();

		for(int j=100000;j>=y;j--)

		{

			dp[j]=min(dp[j],dp[j-y]+x);

		}

	}

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

	{

		if(dp[i]<=m)

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

	}

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

	return 0;

}


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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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

#define MAX 100005

#define pb push_back

#define mp make_pair

#define pii pair<long long,long long>

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

#define p1(a) cout<<"Check "<<a<<endl;

#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;

#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;

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

#define ll long long

#define clr(a) memset(a,0,sizeof(a))

#define MOD 10000000000

#define INF 10000000000000



using namespace std;



int n,cp;

ll cost[MAX];

ll weight[MAX];

ll dp[MAX];





int main()

{

    cin>>n>>cp;

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

        scanf("%lld%lld",&weight[i],&cost[i]);

    }

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

    dp[0]=0;

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

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

            if(j-cost[i]>=0 && dp[j-cost[i]]!=INF){

                dp[j]=min(dp[j],dp[j-cost[i]]+weight[i]);

            }

        }

    }

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

        if(dp[j]<=cp){

            cout<<j<<endl;

            break;

            //break;

        }

    }



    return 0;

}


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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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



using namespace std;



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

#define allr(v)				((v).rbegin()), ((v).rend())

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

#define ll long long

#define pb					push_back

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



const ll oo = 1e8;

const double pi = 3.1415926535897;





const double EPS = (1e-7);

int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}





typedef vector<int>                vi;

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

typedef vector<ll>                 vll;

typedef vector<double>             vd;

typedef vector< vi >               vvi;

typedef vector< vd >               vvd;

typedef vector<string>             vs;

typedef pair<int, int>             pii;



/**

    * PLEASEEE READDD PROBLEEEM CARFULLY ****

    * Always check for OVERFLOW ll vs int

    * Always check for array bounds

    * Check for function return

    * READ OUTPUT SECTION AGAIN!!!

**/



struct edge{

    int from, to, w;



    edge(){}

    edge(int x, int y, int we): from(x), to(y), w(we){}



    bool operator < (const edge &rhs) const{

        return w > rhs.w;

    }



};



const int N = 100 + 5, V = 1e5 + 5 ;



int dp[V];

int w[N], v[N];

int n, ans = 0;

//

//int sol(int i, int vS, int wS) {

//    if(i == n) {

//        ans = max(ans, vS);

//        return 0;

//    }

//

//    int &ret = dp[i][vS];

//    if(ret != -1) return ret;

//

//    ret = sol(i + 1, vS, wS);

//

//    if(wS - w[i] >= 0) ret = max(ret, sol(i + 1, vS + v[i], wS - w[i]));

//

//    return ret;

//}



int main(){

    fIO



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

//    freopen("", "w", stdout);



    fill(dp, dp + V, 1e9 + 5);



    int cap;

    cin >> n >> cap;



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



    dp[0] = 0;

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

        for(int j = V - 5; j >= 1; j--) {

            if(j >= v[i]) {

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

            }

        }

    }





    for(int i = V - 5; i >= 1; i--) {

        if(dp[i] <= cap) {

            cout << i << "\n";

            break;

        }

    }

}
















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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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

#define ll long long

using namespace std;

#define inf 0x3f3f3f3f 

#define MAXN 1019191130

int main(){

	ll  n , W; cin >> n >> W;

    ll w[101] , v[101] , dp[100001];

    for(int i = 0 ; i <= 100000; ++i) dp[i] = inf;

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

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

        dp[0] = 0;

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

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

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

        }

    }

    int j = 100001;

    while(j-- && dp[j] > W);



    cout<< j <<endl;

}

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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

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

using namespace std;

int main()

{

	 int n,W;

    cin>>n>>W;

    long long w[n];

    long long v[n];

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

    long long dp[100005];

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

    {

    	dp[i]=1e15;

	}

    dp[0]=0;

    int res=0;

    for(int i=0;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){

                res=max(res,j);

            }

        }

    }

    cout<<res<<endl;

}

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

using namespace std;



int main() {

int n, w;

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

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

long long valm =0, ans=0;

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

	scanf("%d %d",&wt[i] , &val[i]);

	valm+=val[i];

}





vector< vector< long long> > dp(n+1, vector<long long> (valm+1));

dp[0][0]=0;

for(int i=1; i<=valm; ++i) dp[0][i]=1e18;





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

	for(long long j=1; j<=valm; ++j){

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

		if(val[i-1]<=j){

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

		}

		

		if(dp[i][j]<=w) ans = max(ans,j);

	}

}



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

	

	



	return 0;

}
// Slower C++ solution:
#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;

}


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

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN=1e5+7;

int N,W,ans;

ll w[MAXN],v[MAXN],f[MAXN];

int main()

{

	cin>>N>>W;

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

	memset(f,127,sizeof(f));

	f[0]=0;

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

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

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

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

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

	cout<<ans<<endl;

	return 0;

}
// Slower C++ solution:
//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();

	}

}

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

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN=1e5+7;

int N,W,ans;

ll w[MAXN],v[MAXN],f[MAXN];

int main()

{

	cin>>N>>W;

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

	memset(f,127,sizeof(f));

	f[0]=0;

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

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

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

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

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

	cout<<ans<<endl;

	return 0;

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

#include <algorithm>

#include <cmath>

#include <cstdlib>

#include <cstdio>

#include <cstring>

#include <iomanip>

#include <string>

#include <set>

#include <vector>

#include <queue>

#include <stack>

using namespace std;

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

#define fore(i, a, n) for (long long i = a; i < n; i++)

#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)

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

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

#define debug(a) cout << a << endl

#define endl '\n'

#define pi acos(-1.0)

#define tr t[root]

#define lson t[root << 1]

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

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

const double eps = 1e-8;

inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }

typedef long long ll;

const int inf = 0x3f3f3f3f;

const int maxn=1000100;

#define maxn0 1e9+7;

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



ll sum;

ll w[maxn];

ll dp[maxn];

ll v[maxn];



// void init() {

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

//         w[i]=0;

//         v[i]=0;

//     }

// }

int main() {

    IO;

    ll n,W;

    cin>>n>>W;

    memset(dp,inf,sizeof(dp));

    dp[0]=0;

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

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

        // sum+=v[i];

    }

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

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

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

        }

    }

    ll ans=-1;

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

        if(dp[i]<=W)

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

    }

    cout<<ans<<endl;



    return 0;

}

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

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN=1e5+7;

int N,W,ans;

ll w[MAXN],v[MAXN],f[MAXN];

int main()

{

	cin>>N>>W;

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

	memset(f,127,sizeof(f));

	f[0]=0;

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

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

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

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

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

	cout<<ans<<endl;

	return 0;

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

using namespace std;

const int N = 1e5+100;

const int M = 200;

typedef long long ll;

int a[N],b[N],n,m;

ll f[N];



int main(){

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

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

		scanf("%d%d",&a[i],&b[i]);

	memset(f, 0x3f, sizeof f);

	f[0] = 0;

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

		for (int j = N - 10; j >= 0; j--)

			if (j - b[i] >= 0) f[j] = min(f[j], f[j-b[i]] + a[i]);



	int ans = 0;

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

		if (f[i] <= m) ans = i;

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

	return 0;

}

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

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN=1e5+7;

int N,W,ans;

ll w[MAXN],v[MAXN],f[MAXN];

int main()

{

	cin>>N>>W;

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

	memset(f,127,sizeof(f));

	f[0]=0;

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

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

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

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

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

	cout<<ans<<endl;

	return 0;

}
// Slower C++ solution:
#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;

}


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

#include <cassert>

#include <algorithm>

#define N int(1e5+1)

using namespace std;

typedef pair<int,int> pii;

int dp[N];

struct{

    int w,v;

}a[100];

int main(int argc,char ** argv)

{

    int n,w;

    cin>>n>>w;

    fill(dp+1,dp+N,w+1);

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

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

    }

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

        for(int j=N-1;j>=a[i].v;--j){

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

        }

    }

    int i;

    for(i=N-1;dp[i]>w;--i);

    cout<<i<<endl;

    return 0;

}