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

using namespace std;

#define ll long long

#define ull unsigned long long

#define mst(a, b) memset((a), (b), sizeof(a))

#define mp(a, b) make_pair(a, b)

#define pi acos(-1)

#define pii pair<int, int>

#define pb push_back

const int INF = 0x3f3f3f3f;

const double eps = 1e-10;

const int maxn = 1e5 + 7;

const int maxm = 5e5 + 10;

ll w[maxn], v[maxn];

ll dp[maxn];

ll ans = 0;

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int n, m;

    cin >> n >> m;

    mst(dp, 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 = 1e5; j >= v[i]; --j)

        {

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

            if (dp[j] <= m)

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

        }

    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	return 0;

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

#include<algorithm>

#include<cstring>

using namespace std;

int v[105],w[105];

long long dp[100005];

const int inf =0x3f3f3f3f;

int main()

{

	int n;

	long long W,V=0;

	cin>>n>>W;

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

	dp[0]=0;

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

		cin>>w[i]>>v[i],V+=v[i];

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

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

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

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

	long long ans;

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

		if(dp[i]<=W)

		 {

		 	ans=i;

		 	break;

		 }

	cout<<ans<<endl;	

	//long long ans=-1;

//	for(int i=0;i<=W;i++)

//		ans=max(ans,dp[i]);		

//	cout<<ans<<endl;

	return 0;

}

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

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(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;

    // sum=0;

    // init();

    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.417001562614072x):
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	return 0;

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

#include<cstdio>

using namespace std;

int f[100010],w[101],v[101];

int main ()

{

	int n,z,i,j;

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

	for(i=1;i<=n;++i) scanf("%d%d",&w[i],&v[i]);

	for(i=1;i<=100000;++i) f[i]=z+1;

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

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

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

	  if(f[i]<=z)

	  {

	  	printf("%d",i);

	  	break;

	  }

}

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

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	return 0;

}
// Slower C++ solution:
//I

//01背包

#include<cstdio>

#include<iostream> 

#include<cstring>

using namespace std;

int w[110],c[110];

long long f[100010];//f[v]表示不超过v价值的最小体积 

int main()

{

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

		f[i]=1000000010;

	long long m,n,flag=0; 

	scanf("%d%d",&n,&m);//背包容量m和物品数量n 

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

		scanf("%d%d",&w[i],&c[i]);//重量和价值 

	f[0]=0;

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

		for(int v=100010;v>=c[i];v--)

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

			{

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

				if(f[v]<=m&&v>flag)

					flag=v;

			}

	printf("%lld",flag);

 } 

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

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	return 0;

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

using namespace std;

#define ll long long

ll dp[110000];

ll ww[110],v[110];

int main()

{

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

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

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

    dp[0]=0;

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

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

            if(dp[j-v[i]]+ww[i]<=w)

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

    int maxx=0;

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

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

    cout<<maxx<<endl;

    return 0;

}

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

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	return 0;

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



using namespace std;



#define nl '\n'

#define F first

#define S second

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

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

#define pb push_back



typedef long long ll;

typedef pair<int, int> pii;



const int N = (int)2e5 + 123;

const int K = 500;

const int maxn = (int)2e9;

const int mod = 100000007;

const ll inf = 1ll * 1e18 + 123;



int n;

ll w;

pair<ll, int> p[111];

ll a[100111];

int main(){



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



    #ifdef LOCAL

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

    #endif



    cin >> n >> w;

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

        cin >> p[i].F >> p[i].S;

    }

    for(int i = 0; i <= 100011; ++i) a[i] = -1;

    int sum = 0;

    a[0] = 0;

    sort(p + 1, p + n + 1);

    int ans = 0;

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

        sum += p[i].S;

        for(int j = sum; j >= p[i].S; --j){

            if(a[j - p[i].S] != -1){

                ll newW = a[j - p[i].S] + p[i].F;

                if(newW <= w){

                    ans = max(ans, j);

                }

                if(a[j] == -1 || a[j] > newW){

                    a[j] = newW;

                }

            }

        }

    }

    cout << ans;

    return 0;

}


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

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	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=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.237584945591488x):
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define ii pair <int, int>

#define endl "\n"



ll maxi(ll a, ll b){

	return ((a > b) ? a : b); 

}



ll mini(ll a, ll b){

	return ((a < b) ? a : b);

}



int main ()

{

	

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #define int ll



    int n, w;

    cin >> n >> w;



    vector <int> weight(n, 0);

    vector <int> value(n, 0);

    int sum = 0;



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

    	cin >> weight[i] >> value[i];

    	sum += value[i];

    }





    vector <int> dp(sum + 1, 9e18);//dp[i] denotes the minimum weight necessary to have value of i

    dp[0] = 0;

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

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

    		dp[j + value[i]] = mini(dp[j + value[i]], dp[j] + weight[i]);

    	}

    }

    int ans = 0;

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

    	if (dp[i] <= w)

    		ans = maxi(ans, i);

    }

    cout << ans << endl;



    

    

	return 0;

}
// 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.7263054515321743x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

const ll INF = 1e18L;



int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n,m; cin >> n >> m;

    int w[n];

    int v[n];

    int s = 0;

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

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

        s+=v[i];

    }

    ll dp[s+1];

    dp[0] = 0;

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

        dp[i] = INF;

    }

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

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

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

        }

    }

    int res = 0;

    for (int i = s; i >= 0 && res == 0; i--){

        if (dp[i] <= m) res = i;

    }

    cout << res << endl;

    return 0;

}
// 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: 5.101469552468531x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

const ll INF = 1e18L;



int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n,m; cin >> n >> m;

    int w[n];

    int v[n];

    int s = 0;

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

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

        s+=v[i];

    }

    ll dp[s+1];

    dp[0] = 0;

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

        dp[i] = INF;

    }

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

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

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

        }

    }

    int res = 0;

    for (int i = s; i >= 0 && res == 0; i--){

        if (dp[i] <= m) res = i;

    }

    cout << res << endl;

    return 0;

}
// 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: 3.377261552370081x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

const ll INF = 1e18L;



int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n,m; cin >> n >> m;

    int w[n];

    int v[n];

    int s = 0;

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

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

        s+=v[i];

    }

    ll dp[s+1];

    dp[0] = 0;

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

        dp[i] = INF;

    }

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

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

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

        }

    }

    int res = 0;

    for (int i = s; i >= 0 && res == 0; i--){

        if (dp[i] <= m) res = i;

    }

    cout << res << endl;

    return 0;

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

 

#define int long long

//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

 

 

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

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

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

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

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define s second

#define f first

 

 

using namespace std;

 

 

typedef pair < long long, long long > pll;    

typedef pair < int, int > pii;

typedef unsigned long long ull;         

typedef vector < pii > vpii;

typedef vector < int > vi;

typedef long double ldb; 

typedef long long ll;  

typedef double db;                         

 

 

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;

const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);

const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;

const db eps = 1e-12, pi = 3.14159265359;

const ll INF = 1e18;





int n, m, w[maxn], c[maxn], dp[N], M = N - 12;



main () {

	cin >> n >> m;

	forn (i, 1, n)

		cin >> w[i] >> c[i];





	dp[0] = 0;

	forn (i, 1, M)

		dp[i] = INF;





	forn (i, 1, n)

		forev (j, M, c[i])

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



	forev (i, M, 0)

		if (dp[i] <= m)  {

			cout << i << endl;

			return 0;

		}

}                       

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

using namespace std;



typedef long long ll;

const ll INF = 1e18L;



int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n,m; cin >> n >> m;

    int w[n];

    int v[n];

    int s = 0;

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

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

        s+=v[i];

    }

    ll dp[s+1];

    dp[0] = 0;

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

        dp[i] = INF;

    }

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

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

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

        }

    }

    int res = 0;

    for (int i = s; i >= 0 && res == 0; i--){

        if (dp[i] <= m) res = i;

    }

    cout << res << endl;

    return 0;

}