stablegradients/pie-gem5-pairs huggingface dataset:
// 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.9476908569387577x):
#include <bits/stdc++.h>

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (ll)1e18 + 7

 

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

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

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

 

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

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;



ll n,W;

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

bool was[N];

int main(){

		

	NFS



	cin >> n >> W;

	

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

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

	}

	

	memset(dp,-1,sizeof(dp));

	

	dp[0]=0;

	

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

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

			if(dp[j-v[i]]!=-1){

				was[j]=1;

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

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

			}

		}

	}

	

	ll ans=0;

	

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

		if(was[i] && dp[i]<=W){

			ans=i;

			break;

		}

	}



	cout << ans << endl;

	

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

	

	ioi

}

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include<iostream>

#include<cstring>

#include<algorithm>

#include<vector>

#include<queue>



using namespace std;

typedef long long ll;



const int MAXN = 1e6 + 100;

const int inf = 0x3f3f3f3f;

ll n, k;

ll dp[MAXN];

ll w[MAXN];

ll v[MAXN];

ll ans;



int main(){

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

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

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

	}

	memset(dp, inf, sizeof dp);

	dp[0] = 0;

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

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

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

	}

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

		if(dp[i] <= k)ans = max(ans, (ll)i);

	}

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

	return 0;

}

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

using namespace std;

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

#define ll long long

#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

double const EPS = 1e-9, PI = acos(-1);

const int N = 2e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;

const ll inf = 1e18;



ll dp[N], weight[109];

int val[109];



int main() {

  fastIO;

#ifdef LOCAL

  freopen("input.in", "rt", stdin);

#endif

  int n, k;

  cin >> n >> k;

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

    cin >> weight[i] >> val[i];

  memset(dp, '?', sizeof dp);

  int ans = 0;

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

    dp[0] = 0;

//    dp[i][val[i]] = min(dp[i][val[i]], weight[i]);

    if(dp[val[i]] <= k)

      ans = max(ans, val[i]);

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

      if(j + val[i] >= N) continue;

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

      if(dp[j + val[i]] <= k)

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

    }

  }

  cout << ans;

  return 0;

}


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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include<cmath>

#include<cstdio>

#include<cstring>

using namespace std;

long long n,m,f[100010],w[100200],v[100200];

int main ()

{

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

	f[0]=0;

	cin>>n>>m;

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

	{

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

	}

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

	{

		for(long long j=100000;j>=w[i];j--)

		{

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

		}

	}	

	long long ans=0;

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

	{

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

	}

	cout<<ans;

}


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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

using namespace std;

typedef long long ll;

const int N=120,V=2e5;



int w[N],v[N];

ll d[V];



int main(){

	ios::sync_with_stdio(0);

	int n,W,ans=0;

	cin>>n>>W;

	memset(d,63,sizeof d);

	d[0]=0;

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

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

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

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

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

		}

	}

	cout<<ans;

	return 0;

}

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#define LL long long

using namespace std;

LL n,m,dp[1000001],v[101],w[101],sum,ans; 

int main()

{

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

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

	{

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

		sum+=v[i];

	}

	memset(dp,127/3,sizeof dp);

	dp[0]=0;

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

	{

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

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

	}

	for(int i=sum;;i--)

	{

		if(dp[i]<=m){

			ans=i;break;

		}

	}

	cout<<ans;

	return 0;

}

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

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

#include <unordered_map>

#include <unordered_set>

#define endl '\n'

#define PI acos(-1)

typedef long long ll;

using namespace std;

int n, ans;

ll **dp, w;

pair<ll, int> *x;

ll nap(int i, int rem)

{

    if(i == n && rem)

        return (ll)1e9 + 1;

    else if(!rem)

        return 0;

    if(~dp[i][rem])

        return dp[i][rem];

    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;

    if(rem >= x[i].second)

        second = x[i].first + nap(i + 1, rem - x[i].second);

    return dp[i][rem] = min(first, second);

}

int main()

{

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

    #ifndef ONLINE_JUDGE

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

        //freopen("out.txt", "w", stdout);

    #endif

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

    x = new pair<ll, int>[n];

    int mx = 0;

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

    {

        scanf("%lld %d", &x[i].first, &x[i].second);

        mx += x[i].second;

    }

    dp = new ll*[n];

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

    {

        dp[i] = new ll[mx + 1];

        memset(dp[i], -1, (mx + 1) * 8);

    }

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

        if(nap(0, i) <= w)

            ans = max(ans, i);

    printf("%d", ans);

}