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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

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

		}

	}

	cout << ans;

	return 0;

}

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



#define filein freopen ("in.txt", "r", stdin)

#define fileout freopen ("out.txt", "w", stdout)

#define dbg(x) cerr << #x << ": " << x << endl



using namespace std;

typedef long long ll;



const int maxn = 102;

const ll inf = 10000000000;



ll w[maxn], v[maxn];

ll dp[100005];



int main(){

	ll n, weight;

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

	ll sum = 0;

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

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

		sum += v[i];

	}

	for (ll i = 1; i <= sum; i++)

		dp[i] = inf;

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

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

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

		}

	}

	ll ans;

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

		if (dp[i] <= weight)

			ans = i;

	}

	cout << ans << '\n';

	return 0;

}
// Slower C++ solution:
/*

    Mbak Rose Dong

*/

#include<bits/stdc++.h>

using namespace std;

long long int weight[105], value[105];

long long int dp[100100];

int main()

{

    int n, i, j, k, curr, m, ans;

    int tc;

    int w;

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

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

    {

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

    }

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

        dp[i] = 1e15;

    dp[0] = 0;

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

    {

        for(j=100000-value[i];j>=0;j--)

        {

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

        }

    }

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

    {

        if(dp[i] <= w)

        {

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

            return 0;

        }

    }

    return 0;

}


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



#define filein freopen ("in.txt", "r", stdin)

#define fileout freopen ("out.txt", "w", stdout)

#define dbg(x) cerr << #x << ": " << x << endl



using namespace std;

typedef long long ll;



const int maxn = 102;

const ll inf = 10000000000;



ll w[maxn], v[maxn];

ll dp[100005];



int main(){

	ll n, weight;

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

	ll sum = 0;

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

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

		sum += v[i];

	}

	for (ll i = 1; i <= sum; i++)

		dp[i] = inf;

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

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

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

		}

	}

	ll ans;

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

		if (dp[i] <= weight)

			ans = i;

	}

	cout << ans << '\n';

	return 0;

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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

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

		}

	}

	cout << ans;

	return 0;

}

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

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

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

#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)

#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)

#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

const int mod = (int)1e9 + 7;

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n, W;

int w[105], v[105];

ll dp[maxn];



int main()

{

	n = read(), W = read();

	rep(i, 1, n) w[i] = read(), v[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[0] = 0;

	rep(i, 1, n){

		Rep(j, maxn - 1, v[i]){

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

		}

	}

	Rep(i, maxn - 1, 0){

		if(dp[i] <= W) return 0 * printf("%d\n", i);

	}

	return 0;

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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

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

		}

	}

	cout << ans;

	return 0;

}

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

#include <cstring>

#include <algorithm>

#include <iostream>





using namespace std;



const int MaxN = 1e5 + 5;



long long dp[MaxN];

long long w[105] , W , n;

long long v[MaxN];



int main(){

	memset(dp , 0x3f , sizeof dp);

	cin >> n >> W;

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

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

	}

	dp[0] = 0;

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

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

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

		}

	}

	for(int i = MaxN - 1 ; i >= 0 ; i--){

		if(dp[i] <= W){

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

			break;

		}

	}

	return 0;

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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

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

		}

	}

	cout << ans;

	return 0;

}

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



#define pb push_back

#define se second

#define fi first



using namespace std;



int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;

long long d[(int)2e5 + 7], mx;



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cin >> n >> w;

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

        cin >> a[i] >> c[i];

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

        d[i] = 1e9 + 7;

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

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

        if(d[j] != 1e9 + 7)

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

    for(int j = 0; j <= 1e5 + 6; j++)

        if(d[j] <= w)

            mx = j;

    cout << mx;

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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

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

		}

	}

	cout << ans;

	return 0;

}

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define pb push_back

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

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

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

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

const int mod = 1e9;

const int N = 1e5 + 10;

/*=======================================================================*/



ll n, W, w[N], v[N], f[N];

ll ans = 0;

int main() {

  cin >> n >> W;

  ms(f, inf);

  f[0] = 0;

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



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

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

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

         //   debug1

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

         }

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

     }

  }

  cout << ans << endl;

  return 0;

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

#include <vector>

#include <algorithm>

#include <numeric>

#include <cmath>

#include <set>

#include <tuple>

#include <functional>

#include <map>

#include <unordered_map>

#include <queue>

#include <tuple>



using namespace std;



#define endl '\n'



using ull = unsigned long int;

using ll = long long;



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  const int precision = 13;

  cout.precision(precision);

  cout.setf(ios_base::fixed);



  int n, W; cin >> n >> W;

  vector<ll> dp(1e5+10, W+1);



  dp[0] = 0;

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

    ll w, v; cin >>  w >> v;

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

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

    }

  }



  int ans = 0;

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

    if (dp[i] <= W) {

      ans = max(ans, i);

    }

  }

  cout << ans << endl;



  return 0;

}


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

#define int long long

#define ll long long

#define ld long double

#define mod ((ll)1e9+7)

#define maxx ((ll)1e6+5)

#define pb push_back

#define ins insert

#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

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

#define test ll t; cin>>t; while(t--)

ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}

ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}

using namespace std;//ok i saw

signed main()

{

    int n,W,i,j,k;

    cin >> n >> W;

    int w[n+1],v[n+1],maxv=0;

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

    {

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

    	maxv =max(maxv , v[i]);

    }

    int d[n+1][maxv*n +1];

    int col = maxv*n;

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

		for(j=0 ; j<=col ; j++)

			d[i][j] = -1;

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

		d[0][i] = -1;

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

		d[i][0] = 0;

	int ans = 0;

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

	{

		for(j=1 ; j<=col ; j++)

		{

			if(v[i] <= j && (d[i-1][j-v[i]] != -1 ))

				d[i][j] = w[i] + d[i-1][j-v[i]];

			if(d[i-1][j] != -1 && d[i][j] != -1)

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

			else if(d[i-1][j] != -1 ) 

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

			if(d[i][j] >= 0 && d[i][j] <= W)

				ans = max(ans,j);

				//cout<<d[i][j]<<" ";

		}//cout<<"\n";

	}

	cout << ans <<"\n";

    return 0;

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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

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

		}

	}

	cout << ans;

	return 0;

}

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

#define int long long

#define ll long long

#define ld long double

#define mod ((ll)1e9+7)

#define maxx ((ll)1e6+5)

#define pb push_back

#define ins insert

#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

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

#define test ll t; cin>>t; while(t--)

ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}

ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}

using namespace std;//ok i saw

signed main()

{

    int n,W,i,j,k;

    cin >> n >> W;

    int w[n+1],v[n+1],maxv=0;

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

    {

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

    	maxv =max(maxv , v[i]);

    }

    int d[n+1][maxv*n +1];

    int col = maxv*n;

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

		for(j=0 ; j<=col ; j++)

			d[i][j] = -1;

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

		d[0][i] = -1;

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

		d[i][0] = 0;

	int ans = 0;

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

	{

		for(j=1 ; j<=col ; j++)

		{

			if(v[i] <= j && (d[i-1][j-v[i]] != -1 ))

				d[i][j] = w[i] + d[i-1][j-v[i]];

			if(d[i-1][j] != -1 && d[i][j] != -1)

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

			else if(d[i-1][j] != -1 ) 

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

			if(d[i][j] >= 0 && d[i][j] <= W)

				ans = max(ans,j);

				//cout<<d[i][j]<<" ";

		}//cout<<"\n";

	}

	cout << ans <<"\n";

    return 0;

}
// Slower C++ solution:
/*

    Mbak Rose Dong

*/

#include<bits/stdc++.h>

using namespace std;

long long int weight[105], value[105];

long long int dp[100100];

int main()

{

    int n, i, j, k, curr, m, ans;

    int tc;

    int w;

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

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

    {

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

    }

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

        dp[i] = 1e15;

    dp[0] = 0;

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

    {

        for(j=100000-value[i];j>=0;j--)

        {

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

        }

    }

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

    {

        if(dp[i] <= w)

        {

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

            return 0;

        }

    }

    return 0;

}


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

#define int long long

#define ll long long

#define ld long double

#define mod ((ll)1e9+7)

#define maxx ((ll)1e6+5)

#define pb push_back

#define ins insert

#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

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

#define test ll t; cin>>t; while(t--)

ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}

ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}

using namespace std;//ok i saw

signed main()

{

    int n,W,i,j,k;

    cin >> n >> W;

    int w[n+1],v[n+1],maxv=0;

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

    {

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

    	maxv =max(maxv , v[i]);

    }

    int d[n+1][maxv*n +1];

    int col = maxv*n;

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

		for(j=0 ; j<=col ; j++)

			d[i][j] = -1;

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

		d[0][i] = -1;

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

		d[i][0] = 0;

	int ans = 0;

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

	{

		for(j=1 ; j<=col ; j++)

		{

			if(v[i] <= j && (d[i-1][j-v[i]] != -1 ))

				d[i][j] = w[i] + d[i-1][j-v[i]];

			if(d[i-1][j] != -1 && d[i][j] != -1)

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

			else if(d[i-1][j] != -1 ) 

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

			if(d[i][j] >= 0 && d[i][j] <= W)

				ans = max(ans,j);

				//cout<<d[i][j]<<" ";

		}//cout<<"\n";

	}

	cout << ans <<"\n";

    return 0;

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

#include <cstring>

#include <algorithm>

#include <iostream>





using namespace std;



const int MaxN = 1e5 + 5;



long long dp[MaxN];

long long w[105] , W , n;

long long v[MaxN];



int main(){

	memset(dp , 0x3f , sizeof dp);

	cin >> n >> W;

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

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

	}

	dp[0] = 0;

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

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

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

		}

	}

	for(int i = MaxN - 1 ; i >= 0 ; i--){

		if(dp[i] <= W){

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

			break;

		}

	}

	return 0;

}

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

#define int long long

#define ll long long

#define ld long double

#define mod ((ll)1e9+7)

#define maxx ((ll)1e6+5)

#define pb push_back

#define ins insert

#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

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

#define test ll t; cin>>t; while(t--)

ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}

ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}

using namespace std;//ok i saw

signed main()

{

    int n,W,i,j,k;

    cin >> n >> W;

    int w[n+1],v[n+1],maxv=0;

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

    {

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

    	maxv =max(maxv , v[i]);

    }

    int d[n+1][maxv*n +1];

    int col = maxv*n;

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

		for(j=0 ; j<=col ; j++)

			d[i][j] = -1;

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

		d[0][i] = -1;

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

		d[i][0] = 0;

	int ans = 0;

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

	{

		for(j=1 ; j<=col ; j++)

		{

			if(v[i] <= j && (d[i-1][j-v[i]] != -1 ))

				d[i][j] = w[i] + d[i-1][j-v[i]];

			if(d[i-1][j] != -1 && d[i][j] != -1)

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

			else if(d[i-1][j] != -1 ) 

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

			if(d[i][j] >= 0 && d[i][j] <= W)

				ans = max(ans,j);

				//cout<<d[i][j]<<" ";

		}//cout<<"\n";

	}

	cout << ans <<"\n";

    return 0;

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



#define pb push_back

#define se second

#define fi first



using namespace std;



int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;

long long d[(int)2e5 + 7], mx;



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cin >> n >> w;

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

        cin >> a[i] >> c[i];

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

        d[i] = 1e9 + 7;

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

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

        if(d[j] != 1e9 + 7)

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

    for(int j = 0; j <= 1e5 + 6; j++)

        if(d[j] <= w)

            mx = j;

    cout << mx;

}


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

#define int long long

#define ll long long

#define ld long double

#define mod ((ll)1e9+7)

#define maxx ((ll)1e6+5)

#define pb push_back

#define ins insert

#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

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

#define test ll t; cin>>t; while(t--)

ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}

ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}

using namespace std;//ok i saw

signed main()

{

    int n,W,i,j,k;

    cin >> n >> W;

    int w[n+1],v[n+1],maxv=0;

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

    {

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

    	maxv =max(maxv , v[i]);

    }

    int d[n+1][maxv*n +1];

    int col = maxv*n;

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

		for(j=0 ; j<=col ; j++)

			d[i][j] = -1;

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

		d[0][i] = -1;

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

		d[i][0] = 0;

	int ans = 0;

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

	{

		for(j=1 ; j<=col ; j++)

		{

			if(v[i] <= j && (d[i-1][j-v[i]] != -1 ))

				d[i][j] = w[i] + d[i-1][j-v[i]];

			if(d[i-1][j] != -1 && d[i][j] != -1)

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

			else if(d[i-1][j] != -1 ) 

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

			if(d[i][j] >= 0 && d[i][j] <= W)

				ans = max(ans,j);

				//cout<<d[i][j]<<" ";

		}//cout<<"\n";

	}

	cout << ans <<"\n";

    return 0;

}