stablegradients/pie-gem5-pairs huggingface dataset:
// 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=1e6+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],(ll)dp[j]+(ll)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: 9.362469358990044x):
#include<bits/stdc++.h>

#define ll long long

#define inf 9999999999999999

#define F first

#define S second

#define eb emplace_back

#define mpp make_pair

#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'

#define dbg cout<<__LINE__ <<": 0manush\n"

#define read(x) freopen("input.txt","r",stdin)

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

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 100009

#define mod 10000007

using namespace std;

ll dp[109][mx];



int main(){//read(x);

//fast;

ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;

cin>>n>>k;

ll w[n],p[n];l=0;

for(i=0;i<n;i++){cin>>w[i]>>p[i];l+=p[i];}

dp[n][0]=0;

for(i=1;i<=l;i++)dp[n][i]=inf;

for(i=n-1;i>=0;i--){

    for(j=0;j<=l;j++){

        dp[i][j]=min(dp[i+1][j],(j-p[i]>=0)?w[i]+dp[i+1][j-p[i]]:inf);

        //printf("%2lld ",dp[i][j]);

    }//cout<<endl;

}

a=0;

    for(j=0;j<=l;j++){

        if(dp[0][j]<=k){

            a=max(a,j);

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

        }

    }//cout<<endl;

    cout<<a<<endl;

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

using namespace std;

typedef long long ll;

const ll max_n=2e5+100;

const ll inf=0x3f3f3f3f;

ll t,n,m,p[max_n],v[max_n],q[max_n],dp[max_n];

int main(){

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

    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin>>n>>m;

    ll wmax=0,sum=0;

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

        cin>>q[i]>>p[i];

        sum+=p[i];

    }

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

    ll ans=0;

    dp[0]=0;

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

        for(ll j=sum;j>=p[i];j--){

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

            if(dp[j]<=m){

                ans=max(ans,j);

            }

        }

    }cout<<ans<<endl;

    return 0;

}


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

#define ll long long

#define inf 9999999999999999

#define F first

#define S second

#define eb emplace_back

#define mpp make_pair

#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'

#define dbg cout<<__LINE__ <<": 0manush\n"

#define read(x) freopen("input.txt","r",stdin)

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

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 100009

#define mod 10000007

using namespace std;

ll dp[109][mx];



int main(){//read(x);

//fast;

ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;

cin>>n>>k;

ll w[n],p[n];l=0;

for(i=0;i<n;i++){cin>>w[i]>>p[i];l+=p[i];}

dp[n][0]=0;

for(i=1;i<=l;i++)dp[n][i]=inf;

for(i=n-1;i>=0;i--){

    for(j=0;j<=l;j++){

        dp[i][j]=min(dp[i+1][j],(j-p[i]>=0)?w[i]+dp[i+1][j-p[i]]:inf);

        //printf("%2lld ",dp[i][j]);

    }//cout<<endl;

}

a=0;

    for(j=0;j<=l;j++){

        if(dp[0][j]<=k){

            a=max(a,j);

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

        }

    }//cout<<endl;

    cout<<a<<endl;

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

using namespace std;

typedef long long ll;

//dp[j]==>价值为j时体积为dp[j]

//体积dp[j]<w时的最大价值 



ll c[100005];

ll ans;

ll n,w;

ll a[100005],b[1000005];

int main()

{

	ll i,j,k,x,y,t;

	cin>>n>>w;//w是容积 

	memset(c,1e9+5,sizeof(c));

	//cout<<"ans="<<c[5]<<endl;

	c[0]=0;

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

	cin>>a[i]>>b[i];//a是体积 b是价值 

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

	{

		for(j=1e5;j>=b[i];--j)//1e2*1e3

		{

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

			if(c[j]<=w)

		    ans=max(ans,j);		

		}	

	}	

	cout<<ans;

	return 0;

}

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

#define ll long long

#define inf 9999999999999999

#define F first

#define S second

#define eb emplace_back

#define mpp make_pair

#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'

#define dbg cout<<__LINE__ <<": 0manush\n"

#define read(x) freopen("input.txt","r",stdin)

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

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 100009

#define mod 10000007

using namespace std;

ll dp[109][mx];



int main(){//read(x);

//fast;

ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;

cin>>n>>k;

ll w[n],p[n];l=0;

for(i=0;i<n;i++){cin>>w[i]>>p[i];l+=p[i];}

dp[n][0]=0;

for(i=1;i<=l;i++)dp[n][i]=inf;

for(i=n-1;i>=0;i--){

    for(j=0;j<=l;j++){

        dp[i][j]=min(dp[i+1][j],(j-p[i]>=0)?w[i]+dp[i+1][j-p[i]]:inf);

        //printf("%2lld ",dp[i][j]);

    }//cout<<endl;

}

a=0;

    for(j=0;j<=l;j++){

        if(dp[0][j]<=k){

            a=max(a,j);

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

        }

    }//cout<<endl;

    cout<<a<<endl;

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

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

#define fst first

#define snd second

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

#define pb push_back

#define sz size()

#define FORN(i,j,n) for(long long i=j; i<(long long)n;i++) 

#define FOR(i,n) FORN(i,0,n)

#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )

#define MOD 998244353LL

#define LIM 262150

#define ones(x) __builtin_popcount(x)

#define trace(x)    cerr << #x << ": " << x << endl;

#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;

using namespace std;

 

typedef long long ll ;

typedef unsigned long long ull ;

typedef vector <int> vi;

typedef pair <int,int> ii;

typedef vector <string> vs;

typedef vector <ii> vii;

ll n,w;

ll ans = 0;

ll dp[105][100005];

ll v[105];

ll p[105];

int main() {

	fastio;

	cin>> n >> w;

	FORN(i,1,n+1) cin>> p[i] >> v[i];

	FOR(i,n+1){

		FOR(j,1e5+1){

			dp[i][j] = 1e14;

		}

	}

	FORN(i,0,n+1){

		FOR(j,1e5+1){

		    if(j == 0){ dp[i][j] = 0; continue; }

		    if(i == 0){ dp[i][j] = 1e14; continue; }

			if(j >= v[i]){

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

			}

			else{

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

			}

		}

	}

	FOR(i,1e5+1){

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

			ans = max(ans,i);

		}

	}

	cout<< ans << '\n'; 

	//cout<< dp[3][100000] << '\n';

	return 0;

}

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

#define ll long long

#define inf 9999999999999999

#define F first

#define S second

#define eb emplace_back

#define mpp make_pair

#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'

#define dbg cout<<__LINE__ <<": 0manush\n"

#define read(x) freopen("input.txt","r",stdin)

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

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 100009

#define mod 10000007

using namespace std;

ll dp[109][mx];



int main(){//read(x);

//fast;

ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;

cin>>n>>k;

ll w[n],p[n];l=0;

for(i=0;i<n;i++){cin>>w[i]>>p[i];l+=p[i];}

dp[n][0]=0;

for(i=1;i<=l;i++)dp[n][i]=inf;

for(i=n-1;i>=0;i--){

    for(j=0;j<=l;j++){

        dp[i][j]=min(dp[i+1][j],(j-p[i]>=0)?w[i]+dp[i+1][j-p[i]]:inf);

        //printf("%2lld ",dp[i][j]);

    }//cout<<endl;

}

a=0;

    for(j=0;j<=l;j++){

        if(dp[0][j]<=k){

            a=max(a,j);

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

        }

    }//cout<<endl;

    cout<<a<<endl;

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

 

#define ll long long

#define X first

#define Y second

#define MP make_pair

#define ld long double

 

using namespace std;

 

const int N = 5e5 + 123;

const ll mod = 1e9 + 7;



ll dp[N], res, was[N];

int n, maxw;



int main (){

	ios::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);



	cin >> n >> maxw;



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

		dp[i] = N * 1LL * N;



	was[0] = 1;

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

		ll x, y;

		cin >> x >> y;

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

			if(!was[j - y])

				continue;

			was[j] = 1;

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

		}

	}



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

		if(dp[i] <= maxw){

			res = i;

		}

	}



	cout << res;

}

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)

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

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

#define EPS 1e-9

#define PI acos(-1)

#define MOD 1000000007

#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





using namespace std;

typedef long long int ll;





ll inf = 1e12 + 5;



int main(){

    FIN;

    //freopen("../../input.txt", "r", stdin);freopen("../../output.txt", "w", stdout); 

    int n,w;cin>>n>>w;

    int N = n*1000 + 1;

    ll dp[n+1][N];



    fore(i,0,n+1){

        fore(j,0,N){

            dp[i][j] = inf;

        }

    }

    vector<pair<int,int>> values;

    fore(i,0,n){

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

        values.pb({wi,vi});

    }



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



    



    fore(i,1,n+1){

        int wi = values[i-1].first;

        int vi = values[i-1].second;

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

        fore(j,1,N){

            dp[i][j] = min(dp[i-1][max(j-vi,0)]+wi,dp[i-1][j]);

        }

    }



    /*fore(i,0,n+1){

        fore(j,0,N){

            if(dp[i][j] != inf){

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

            }else{

                cout<<"-1 ";

            }



        }cout<<"\n";

    }*/



    ll ans = 0;

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

        bool posible = false;



        fore(i,0,n+1){

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

                posible = true;

            }

        }

        if(posible){

            ans = j;

            break;

        }

    }

    cout<<ans;

    return 0;

}



// ============== Notes =============== //

// common bugs

// - remove reader 

// - fastio

// - int overflow (especially intermediate expressionns)

// - array bounds (indices bigger than MAXN?, is MAXN correct?)

// - special cases (n=1, graph not connected?)

// - re-initialize efficiently between test cases
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ull unsigned ll

#define ld long double

#define pll pair<ll, ll>

#define pii pair<int, int>

#define f first

#define se second

#define pb push_back

#define ft fflush(stdout)

 

 

using namespace std;

 

 

const int N = 1e5 + 123;

const int PLS = 3e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e16;





ll n, a[N], b[N], w, dp[110][N];





int main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> w;

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

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

    dp[0][0] = 0;

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

        dp[0][i] = inf;

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

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

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

            if (j >= b[i])

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

        }

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

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

            return cout << i, 0;

}

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)

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

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

#define EPS 1e-9

#define PI acos(-1)

#define MOD 1000000007

#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





using namespace std;

typedef long long int ll;





ll inf = 1e12 + 5;



int main(){

    FIN;

    //freopen("../../input.txt", "r", stdin);freopen("../../output.txt", "w", stdout); 

    int n,w;cin>>n>>w;

    int N = n*1000 + 1;

    ll dp[n+1][N];



    fore(i,0,n+1){

        fore(j,0,N){

            dp[i][j] = inf;

        }

    }

    vector<pair<int,int>> values;

    fore(i,0,n){

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

        values.pb({wi,vi});

    }



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



    



    fore(i,1,n+1){

        int wi = values[i-1].first;

        int vi = values[i-1].second;

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

        fore(j,1,N){

            dp[i][j] = min(dp[i-1][max(j-vi,0)]+wi,dp[i-1][j]);

        }

    }



    /*fore(i,0,n+1){

        fore(j,0,N){

            if(dp[i][j] != inf){

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

            }else{

                cout<<"-1 ";

            }



        }cout<<"\n";

    }*/



    ll ans = 0;

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

        bool posible = false;



        fore(i,0,n+1){

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

                posible = true;

            }

        }

        if(posible){

            ans = j;

            break;

        }

    }

    cout<<ans;

    return 0;

}



// ============== Notes =============== //

// common bugs

// - remove reader 

// - fastio

// - int overflow (especially intermediate expressionns)

// - array bounds (indices bigger than MAXN?, is MAXN correct?)

// - special cases (n=1, graph not connected?)

// - re-initialize efficiently between test cases
// Slower C++ solution:
#include <iostream>

#include <iomanip>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <string>

#include <stdio.h>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define ll long long

#define pb push_back

#define mp make_pair

#define f first

#define s second



using namespace std;



const int inf = 1e9 + 7;

const long long INF = 1e18 + 7;

const int maxn = 2e5 + 7;



ll n, s, w[maxn], a[maxn];

ll dp[maxn], mx;



int main(){

	ios_base::sync_with_stdio(NULL);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> s;

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

		dp[i] = inf;

	dp[0] = 0;

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

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

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

			if (dp[j] != inf && dp[j] + w[i] <= s){

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

			}

		}

	}

	for (ll i = 0; i < maxn; i++)

		if (dp[i] != inf)

			mx = max(mx, i);

	cout << mx;

	return 0;

} 

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)

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

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

#define EPS 1e-9

#define PI acos(-1)

#define MOD 1000000007

#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





using namespace std;

typedef long long int ll;





ll inf = 1e12 + 5;



int main(){

    FIN;

    //freopen("../../input.txt", "r", stdin);freopen("../../output.txt", "w", stdout); 

    int n,w;cin>>n>>w;

    int N = n*1000 + 1;

    ll dp[n+1][N];



    fore(i,0,n+1){

        fore(j,0,N){

            dp[i][j] = inf;

        }

    }

    vector<pair<int,int>> values;

    fore(i,0,n){

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

        values.pb({wi,vi});

    }



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



    



    fore(i,1,n+1){

        int wi = values[i-1].first;

        int vi = values[i-1].second;

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

        fore(j,1,N){

            dp[i][j] = min(dp[i-1][max(j-vi,0)]+wi,dp[i-1][j]);

        }

    }



    /*fore(i,0,n+1){

        fore(j,0,N){

            if(dp[i][j] != inf){

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

            }else{

                cout<<"-1 ";

            }



        }cout<<"\n";

    }*/



    ll ans = 0;

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

        bool posible = false;



        fore(i,0,n+1){

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

                posible = true;

            }

        }

        if(posible){

            ans = j;

            break;

        }

    }

    cout<<ans;

    return 0;

}



// ============== Notes =============== //

// common bugs

// - remove reader 

// - fastio

// - int overflow (especially intermediate expressionns)

// - array bounds (indices bigger than MAXN?, is MAXN correct?)

// - special cases (n=1, graph not connected?)

// - re-initialize efficiently between test cases
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const ll inf=0x7F7F7F7F7F7F7F7F;

ll n,wz,w[110],v[110],dp[100010];

inline int read(){

     int x=0,f=1;char ch=getchar();

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

     while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}

     return x*f;

 }

int main ( )

{

	n=read();wz=read();

	for(int i=1;i<=n;i++) w[i]=read(),v[i]=read();

	memset(dp,inf,sizeof(dp));dp[0]=0;

	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]);

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

      if(dp[i]<=wz)

      {

      	cout<<i;

      	break;

	  }

	return 0;

}

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)

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

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

#define EPS 1e-9

#define PI acos(-1)

#define MOD 1000000007

#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





using namespace std;

typedef long long int ll;





ll inf = 1e12 + 5;



int main(){

    FIN;

    //freopen("../../input.txt", "r", stdin);freopen("../../output.txt", "w", stdout); 

    int n,w;cin>>n>>w;

    int N = n*1000 + 1;

    ll dp[n+1][N];



    fore(i,0,n+1){

        fore(j,0,N){

            dp[i][j] = inf;

        }

    }

    vector<pair<int,int>> values;

    fore(i,0,n){

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

        values.pb({wi,vi});

    }



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



    



    fore(i,1,n+1){

        int wi = values[i-1].first;

        int vi = values[i-1].second;

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

        fore(j,1,N){

            dp[i][j] = min(dp[i-1][max(j-vi,0)]+wi,dp[i-1][j]);

        }

    }



    /*fore(i,0,n+1){

        fore(j,0,N){

            if(dp[i][j] != inf){

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

            }else{

                cout<<"-1 ";

            }



        }cout<<"\n";

    }*/



    ll ans = 0;

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

        bool posible = false;



        fore(i,0,n+1){

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

                posible = true;

            }

        }

        if(posible){

            ans = j;

            break;

        }

    }

    cout<<ans;

    return 0;

}



// ============== Notes =============== //

// common bugs

// - remove reader 

// - fastio

// - int overflow (especially intermediate expressionns)

// - array bounds (indices bigger than MAXN?, is MAXN correct?)

// - special cases (n=1, graph not connected?)

// - re-initialize efficiently between test cases
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int MX = 200005;

long long dp[MX];  // dp[i]表示价值为i时的最小体积

int main()

{

	int n,w;

	cin >> n >> w;

	for(int i = 0; i < MX; ++i) dp[i] = 1001002003004005006ll;

	dp[0] = 0;

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

	{

		int a,b;

		cin >> a >> b;

		for (int j = MX-1; j >= b; --j) 

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

	}

	int ans = 0;

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

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

	cout << ans << endl;

	return 0;

}

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)

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

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

#define EPS 1e-9

#define PI acos(-1)

#define MOD 1000000007

#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





using namespace std;

typedef long long int ll;





ll inf = 1e12 + 5;



int main(){

    FIN;

    //freopen("../../input.txt", "r", stdin);freopen("../../output.txt", "w", stdout); 

    int n,w;cin>>n>>w;

    int N = n*1000 + 1;

    ll dp[n+1][N];



    fore(i,0,n+1){

        fore(j,0,N){

            dp[i][j] = inf;

        }

    }

    vector<pair<int,int>> values;

    fore(i,0,n){

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

        values.pb({wi,vi});

    }



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



    



    fore(i,1,n+1){

        int wi = values[i-1].first;

        int vi = values[i-1].second;

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

        fore(j,1,N){

            dp[i][j] = min(dp[i-1][max(j-vi,0)]+wi,dp[i-1][j]);

        }

    }



    /*fore(i,0,n+1){

        fore(j,0,N){

            if(dp[i][j] != inf){

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

            }else{

                cout<<"-1 ";

            }



        }cout<<"\n";

    }*/



    ll ans = 0;

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

        bool posible = false;



        fore(i,0,n+1){

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

                posible = true;

            }

        }

        if(posible){

            ans = j;

            break;

        }

    }

    cout<<ans;

    return 0;

}



// ============== Notes =============== //

// common bugs

// - remove reader 

// - fastio

// - int overflow (especially intermediate expressionns)

// - array bounds (indices bigger than MAXN?, is MAXN correct?)

// - special cases (n=1, graph not connected?)

// - re-initialize efficiently between test cases