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

#include<cstdio>

#include<cstring>

#define N 110

#define LL long long

using namespace std;

int n,m;

LL w[N],v[N],dp[100010];

int main(){

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

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

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

	memset(dp,128/3,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]);

	LL ans=0;

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

		if(dp[i]<=(LL)m) ans=(LL)i;

	cout<<ans;

	return 0;

}

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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

}
// Slower C++ solution:
// Author : Mohamed Sameh

#include <bits/stdc++.h>

#define pb push_back

#define f first

#define s second

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

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

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

#define Flush fflush(stdout);

typedef long long ll ;

using namespace std ;

const int M = 100 ;

const int MAXV = 1e5+1; 

const ll MAX = 2e18+9;

ll dp[M][MAXV];

int w[M],v[M];

int N , W ;

int ans ;

int main ()

{   

    scanf ("%d%d" , &N ,&W); 

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

    {

        scanf ("%d%d" ,w+i , v+i); 

    }

    // dp[i][j] means 

    // what is the minumum weight to get the value j in range [0 : i]

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

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

            dp[i][j] = MAX ; 

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

        dp[i][ v[i] ] = w[i];

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

    {

        for (int j = 1 ; j < MAXV ;j++)

        {

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

            if (j >= v[i])

            {

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

            }

        }

    }

    

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

    {

        if (dp[N-1][i] <= W )

            ans = max (ans , i); 

    }

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



}

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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define clr(arr, x) memset(arr, x, sizeof arr)

#define endl "\n"

#define Accepted 0

typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

const int N = 1e5 + 5;

ll dp[N];

int main()

{

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

	int n, W;

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

	vi val(n + 1), cap(n + 1);

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

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

	dp[0] = 0;

	ll ans = 0;

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

		for (int j = N-1; j>=val[i]; j--) {

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

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

		}

	}

	

	printf("%lld", ans);



	return Accepted;

}

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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

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

#define Keep_calmYou_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);//freopen("out.txt","w",stdout);

typedef long long ll;

typedef long double ld;

using namespace std;





int main()

{

    Keep_calmYou_are_still_learning;



    ll n , m;

    cin>>n>>m;

    ll w[n],v[n],ans=0;

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

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



   ll dp[(int) 1e5 + 5];

   for (ll i=0;i<1e5+5;i++)

    dp[i]= 1e10;



    dp[0]=0;



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

    {

        for (ll j=1e5-v[i];j>=0;j--)

        {

            if (dp[j]<m)

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

            if (dp[j+v[i]]<=m)

                ans=max(ans,j+v[i]);

        }

    }

    cout<<ans<<'\n';

    return 0;

}


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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

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



using namespace std;

typedef long long ll;



const int N = 107;

int w[N], v[N];

int n, W;



ll dp[2][100007];



ll infll;



int main() {

    memset(&infll, 0x3f, sizeof infll);

    cin >> n >> W;



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

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

    }



    int cur = 0;

    memset(dp, 0x3f, sizeof dp);

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

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

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

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

            if(j - v[i] >= 0 and dp[1-cur][j - v[i]] < infll) dp[cur][j] = min(dp[cur][j], w[i] + dp[1-cur][j - v[i]]);

        }

        cur = 1 - cur;

    }



    int ans = 0;

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

        if(dp[1-cur][j] <= W) ans = max(ans, j);

    }



    cout << ans << endl;

}

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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<iostream>

#include<algorithm>

#include<iomanip>

#include<string>

#include<cmath>

#include<vector>

#include<set>

#include<queue>

#include<stack>

#include<fstream>

#include<map>

#include<bitset>

#include<unordered_map>

#include<cstring>

#include<cctype>

using namespace std;

#define  ll long long

#define  ull unsigned long long

#define  ul unsigned long

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

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

#define pb(s) push_back(s);

#define format(n) fixed<<setprecision(n)

#define finl "\n"

#define Mohammed_Atef_Hassan fast();

#define mod 1000000007

#define INF LLONG_MAX

#define PI acos(-1)

#define clr(dp,n) memset(dp,n,sizeof dp)

#define ex(n) return cout<<n<<finl,0;

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

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

ll fix_mod(ll x, ll y)

{

	return (y + x % y) % y;

}

void fast() {

	std::ios_base::sync_with_stdio(false);

	cin.tie(nullptr); cout.tie(nullptr);

}

int main()

{

	Mohammed_Atef_Hassan

		int n; ll w;

	cin >> n >> w;

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

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

	vector<ll>mem(1e5 + 10, LLONG_MAX);

	mem[0] = 0;

	set<int>st{ 0 };

	vector<int>vv;

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

	{

		vv.clear();

		for (set<int>::reverse_iterator j=st.rbegin();j!=st.rend();j++)

		{

			if (*j + v[i].second <= 1e5)

				mem[*j + v[i].second] = min(mem[*j + v[i].second], v[i].first+mem[*j]),vv.push_back(*j+v[i].second);

		}

		for (auto j : vv)st.insert(j);

	}

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

	{

		if(mem[i]<=w)ex(i);

	}

}

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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

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

using namespace std;

#define INF 10e10

#define LL long long int

LL dp[100001];

int main() {

    ios_base::sync_with_stdio(false);

    int n,w,valSum=0;

    cin >> n >> w;

    int wgt[n+1],val[n+1];

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

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

        cin >> wgt[i] >> val[i];

        valSum += val[i];

    }

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

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

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

        }

    }

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

        if(dp[i]<=w) {

            cout << i << "\n";

            break;

        }

    }

}


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

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

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

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

#define forv(i, v) for(int i = 0; i < sz(v); ++i)

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

using namespace std;



typedef long long       ll;

typedef long double     ld;

typedef vector<int>     vi;

typedef vector<double>  vd;

typedef vector< vi >    vii;

typedef vector< vd >    vdd;

typedef vector<string>  vs;



const ll INF = 1e18L + 5;



int main()

{

	ll n, W;

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

	vector<ll> v(n), w(n);

	ll max_sum = 0;

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

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

		max_sum += v[i];

	}

	vector<ll> dp(max_sum + 3, INF);

	dp[0] = 0;

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

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

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

		}

	}

	ll ans = 0;

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

		if (dp[i] <= W) {

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

		}

	}

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



	return 0;

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

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

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

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

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

#define read2(x,y) scanf("%d%d",&x,&y)

#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define readll(x) scanf("%lld",&x)

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

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

#define pb push_back

#define lowbit(x) x&-x

#define lc rt<<1

#define rc rt<<1|1

#define ls lc,l,m

#define rs rc,m+1,r

#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;

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

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

const int INF =0x3f3f3f3f;

const int mod = 1e9+7;

const double eps=1e-8;

const int N = 2e5+5;

int dir[4][2]={0,1,0,-1,1,0,-1,0};

int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int c[N],w[N];

ll dp[N];

int main(){

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

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

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

	int n,W;

	read2(n,W);

	int totv = 0;

    fe(i,1,n)read2(c[i],w[i]),totv+=w[i];

    mst(dp,0x3f);

    dp[0] = 0;

    fe(i,1,n){

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

				//value =j ,use min cost

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

    	}

    }

    int res;

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

        if(dp[i] <= W){

			res = i;

			break;

        }

    }

    cout<<res<<endl;









	return 0;

}


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

using namespace std;

using ll = long long;

void max_self(ll& a, ll b) {

    a = max(a, b);

}

void min_self(ll& a, ll b) {

    a = min(a, b);

}

const ll INF = 1e18L + 5;



int main() {

    int n, W;

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

    vector<int> weight(n), value(n);

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

        scanf("%d%d", &weight[i], &value[i]);

    }

    int sum_value = 0;

    for(int x : value) {

        sum_value += x;

    }

    vector<ll> dp(sum_value + 1, INF); 

    dp[0] = 0;

    

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

        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {

         min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);

        }

    }

    ll answer = 0;

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

        if(dp[i] <= W) {

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

        }

      

    }

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

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

using namespace std;



#define pb push_back

#define mk make_pair

#define fi first

#define se second

#define eb emplace_back



typedef long long ll;

typedef pair<int,int> ii;

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

const ll INF = 0x3f3f3f3f3f3fef;



const int V = 1e5+2;

const int N = 102;



ll dp[V];

ll p[N];

ll v[N];

ll n,w;

 

int main() {

    ios_base::sync_with_stdio(false);

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



    cin >> n >> w;

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

    

    dp[0] = 0;

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

        for(ll j = V-1; j-v[i] >= 0; j--)

            if(dp[j-v[i]] != INF) dp[j] = min(dp[j], dp[j-v[i]]+p[i]);



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

        if(dp[i] <= w) { cout << i << endl; return 0; }





    return 0;

}




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

using namespace std;

using ll = long long;

void max_self(ll& a, ll b) {

    a = max(a, b);

}

void min_self(ll& a, ll b) {

    a = min(a, b);

}

const ll INF = 1e18L + 5;



int main() {

    int n, W;

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

    vector<int> weight(n), value(n);

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

        scanf("%d%d", &weight[i], &value[i]);

    }

    int sum_value = 0;

    for(int x : value) {

        sum_value += x;

    }

    vector<ll> dp(sum_value + 1, INF); 

    dp[0] = 0;

    

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

        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {

         min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);

        }

    }

    ll answer = 0;

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

        if(dp[i] <= W) {

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

        }

      

    }

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

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

#include<string.h>

#include<time.h>

#include<math.h>

#include<stdlib.h>

#include<iostream>

#include<iomanip>

#include<utility>

#include<algorithm>

#include<stack>

#include<queue>

#include<map>

#include<set>

#define ll long long

#define fi first

#define sec second

#define pb push_back

#define mp make_pair

#define rep(a,b,c) for(int a=1;a<=b;a+=c)

#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)



const double PI=acos(-1);

const double EPS=1e-12;

const int MOD=1e9+7;

const int INF=1<<30;





using namespace std;



int maxx[100005];



int main(){

	//ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);

	int in,n,t,w;

	rep(i,100000,1){

		maxx[i]=INF;

	}

	cin>>in>>n;

	rep(i,in,1){

		cin>>t>>w;

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

			maxx[j]=min(maxx[j],maxx[j-w]+t);

		}

	}

	int res=0;

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

		if(maxx[i]<=n){

			res=i;

			break;

		}

	}

	cout<<res<<endl;

	return 0;

}




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

using namespace std;

using ll = long long;

void max_self(ll& a, ll b) {

    a = max(a, b);

}

void min_self(ll& a, ll b) {

    a = min(a, b);

}

const ll INF = 1e18L + 5;



int main() {

    int n, W;

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

    vector<int> weight(n), value(n);

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

        scanf("%d%d", &weight[i], &value[i]);

    }

    int sum_value = 0;

    for(int x : value) {

        sum_value += x;

    }

    vector<ll> dp(sum_value + 1, INF); 

    dp[0] = 0;

    

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

        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {

         min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);

        }

    }

    ll answer = 0;

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

        if(dp[i] <= W) {

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

        }

      

    }

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

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

using ll = long long;



#define MAX_W ((ll)1e9)

#define MAX_N (100)

#define MAX_V (1000)

int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);



	int N, W;

	std::cin >> N >> W;

	std::vector<ll> val(N), wei(N), dp(MAX_V*MAX_N+10, (ll)1e12+1);

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

		std::cin >> wei[i] >> val[i];

	}



	ll ans = 0;

	dp[0] = 0;

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

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

			dp[v] = std::min( dp[v], dp[v - val[i]] + wei[i] );

			if( dp[v] <= W )

				ans = std::max(ans, (ll) v );

		}

	}



	std::cout << ans << '\n';

	return 0;

}

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

using namespace std;

using ll = long long;

void max_self(ll& a, ll b) {

    a = max(a, b);

}

void min_self(ll& a, ll b) {

    a = min(a, b);

}

const ll INF = 1e18L + 5;



int main() {

    int n, W;

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

    vector<int> weight(n), value(n);

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

        scanf("%d%d", &weight[i], &value[i]);

    }

    int sum_value = 0;

    for(int x : value) {

        sum_value += x;

    }

    vector<ll> dp(sum_value + 1, INF); 

    dp[0] = 0;

    

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

        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {

         min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);

        }

    }

    ll answer = 0;

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

        if(dp[i] <= W) {

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

        }

      

    }

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

}