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

using namespace std;

#define MOD 1000000007

#define ll long long

#define li long

#define pb push_back

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



ll n,W;

ll w[101],v[101];

ll dp[101][100010];

bool vis[101][100010];

ll totalV=0;



ll minWeight(ll end, ll Val)

{

  if(Val<=0)

  return 0;

  if(end==0)

  return INT_MAX;

  if(vis[end][Val])

  return dp[end][Val];

  vis[end][Val]=1;

  // if(v[end-1]>Val)

  // return dp[end][Val]=minWeight(end-1,Val);

  // else

  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));

}



int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll i,j;

    cin>>n>>W;

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

    {

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

      totalV+=v[i];

    }

    mem(vis,0);

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

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

        dp[i][j]=INT_MAX;



    for(i=totalV;i>=1;i--)

    {

      if(minWeight(n,i)<=W)

      break;

    }

    cout<<i;

    return 0;

}

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define li long

#define pb push_back

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



ll n,W;

ll w[101],v[101];

ll dp[101][100010];

ll totalV=0;



ll minWeight(ll end, ll Val)

{

  if(Val<=0)

  return 0;

  if(end==0)

  return INT_MAX;

  if(dp[end][Val]!=1000000010)

  return dp[end][Val];

  // if(v[end-1]>Val)

  // return dp[end][Val]=minWeight(end-1,Val);

  // else

  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));

}



int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll i,j;

    cin>>n>>W;

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

    {

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

      totalV+=v[i];

    }



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

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

        dp[i][j]=1000000010;



    for(i=totalV;i>=1;i--)

    {

      if(minWeight(n,i)<=W)

      break;

    }

    cout<<i;

    return 0;

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define li long

#define pb push_back

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



ll n,W;

ll w[101],v[101];

ll dp[101][100010];

bool vis[101][100010];

ll totalV=0;



ll minWeight(ll end, ll Val)

{

  if(Val<=0)

  return 0;

  if(end==0)

  return INT_MAX;

  if(vis[end][Val])

  return dp[end][Val];

  vis[end][Val]=1;

  // if(v[end-1]>Val)

  // return dp[end][Val]=minWeight(end-1,Val);

  // else

  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));

}



int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll i,j;

    cin>>n>>W;

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

    {

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

      totalV+=v[i];

    }

    mem(vis,0);

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

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

        dp[i][j]=INT_MAX;



    for(i=totalV;i>=1;i--)

    {

      if(minWeight(n,i)<=W)

      break;

    }

    cout<<i;

    return 0;

}

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define li long

#define pb push_back

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



ll n,W;

ll w[101],v[101];

ll dp[101][100010];

ll totalV=0;



ll minWeight(ll end, ll Val)

{

  if(Val<=0)

  return 0;

  if(end==0)

  // return 1000000010;

  return INT_MAX;

  // 2147483647

  if(dp[end][Val]!=1000000010)

  return dp[end][Val];

  if(v[end-1]>Val)

  return dp[end][Val]=minWeight(end-1,Val);

  else

  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));

}



int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll i,j;

    cin>>n>>W;

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

    {

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

      totalV+=v[i];

    }



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

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

        dp[i][j]=1000000010;



    for(i=totalV;i>=1;i--)

    {

      if(minWeight(n,i)<=W)

      break;

    }

    cout<<i;

    return 0;

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define li long

#define pb push_back

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



ll n,W;

ll w[101],v[101];

ll dp[101][100010];

bool vis[101][100010];

ll totalV=0;



ll minWeight(ll end, ll Val)

{

  if(Val<=0)

  return 0;

  if(end==0)

  return INT_MAX;

  if(vis[end][Val])

  return dp[end][Val];

  vis[end][Val]=1;

  // if(v[end-1]>Val)

  // return dp[end][Val]=minWeight(end-1,Val);

  // else

  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));

}



int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll i,j;

    cin>>n>>W;

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

    {

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

      totalV+=v[i];

    }

    mem(vis,0);

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

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

        dp[i][j]=INT_MAX;



    for(i=totalV;i>=1;i--)

    {

      if(minWeight(n,i)<=W)

      break;

    }

    cout<<i;

    return 0;

}

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define li long

#define pb push_back

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



ll n,W;

ll w[101],v[101];

ll dp[101][100010];

ll totalV=0;



ll minWeight(ll end, ll Val)

{

  if(Val<=0)

  return 0;

  if(end==0)

  // return 1000000010;

  return INT_MAX;

  // 2147483647

  if(dp[end][Val]!=1000000010)

  return dp[end][Val];

  if(v[end-1]>Val)

  return dp[end][Val]=minWeight(end-1,Val);

  else

  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));

}



ll bottomUp()

{

  ll i,j;

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

  {

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

    {

      if(j==0)

      dp[i][j]=0;

      else if(i==0)

      dp[i][j]=INT_MAX;

      else if(j>=v[i-1])

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

      else 

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

    }

  }

  for(j=totalV;j>=1;j--)

  {

    if(dp[n][j]<=W)

    break;

  }

  return j;

}



int main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll i,j;

    cin>>n>>W;

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

    {

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

      totalV+=v[i];

    }



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

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

        dp[i][j]=1000000010;



    // for(i=totalV;i>=1;i--)

    // {

    //   if(minWeight(n,i)<=W)

    //   break;

    // }

    // cout<<i;

    cout<<bottomUp();

    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.527681124878812x):
#include<cstdio>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<iostream>

#include<queue>

#include<string>

#include<map>

#include<set>

#include<stack>

#include<vector>

#define ll long long

#define mt(a) memset(a,0,sizeof(a))

#define MAXI 2000000000

#define PAI pair<int,int>



using namespace std;



ll  f[200009],w[200009],v[200009];

int main()

{

	int n, m,vv=0;

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

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

	{

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

		vv += v[i];

	}

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

		f[i] = MAXI;

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

	{

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

		{

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

		}

	}

	ll maxx = -MAXI;

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

		if (f[i] <= m) maxx = i;

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

	return 0;

}
// Slower C++ solution:
/**

 *  Author : Coda

 *  Title : OSU!

 *  Date : 2019-08-20

 */

#include <bits/stdc++.h>

using namespace std ;



typedef long long ll ;

typedef unsigned long long ull ;

typedef double DB ;

const long long mod = 1e9+7 ;

const double pi = acos(-1) ;

#define PB push_back

#define MP make_pair

#define lb lower_bound

#define ub upper_bound

#define fs first

#define sd second

#define pii pair<int,int>

#define INF 0x3f3f3f3f

#define LLINF 0x3f3f3f3f3f3f3f3f

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

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

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

//#pragma comment(linker,"/STACK:10240000,10240000")

//#include <random>

//mt19937 rand_(time(0));

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll qpow(ll a,ll b,ll c){ll t=1;while(b){if(b&1)t=t*a%c;a=a*a%c;b>>=1;}return t;}

ll inv(ll x){return qpow(x,mod-2,mod);}

int test = 1 ;



const int maxn = 5 + 3e5 ;

const int maxm = 5 + 1e6 ;

// Write the variables here



int N,W ;

ll v[maxn],w[maxn] ;

ll dp[maxn] ;



//#define TEST

int main(){

#ifdef TEST

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

#endif

    while(test--){

        // code begins

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



        ll sum = 0 ;

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

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

        }

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

            dp[i] = LLINF ;

        }

        dp[0] = 0;

        ll ans = 0 ;

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

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

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

            }

        }

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

            if(dp[i]<=W) ans = max(ans,i*1ll) ;

        }

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



    }

#ifdef TEST

    cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;

#endif

    return 0 ;

}


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

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<iostream>

#include<queue>

#include<string>

#include<map>

#include<set>

#include<stack>

#include<vector>

#define ll long long

#define mt(a) memset(a,0,sizeof(a))

#define MAXI 2000000000

#define PAI pair<int,int>



using namespace std;



ll  f[200009],w[200009],v[200009];

int main()

{

	int n, m,vv=0;

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

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

	{

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

		vv += v[i];

	}

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

		f[i] = MAXI;

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

	{

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

		{

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

		}

	}

	ll maxx = -MAXI;

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

		if (f[i] <= m) maxx = i;

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

	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.408579896381212x):
#include<cstdio>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<iostream>

#include<queue>

#include<string>

#include<map>

#include<set>

#include<stack>

#include<vector>

#define ll long long

#define mt(a) memset(a,0,sizeof(a))

#define MAXI 2000000000

#define PAI pair<int,int>



using namespace std;



ll  f[200009],w[200009],v[200009];

int main()

{

	int n, m,vv=0;

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

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

	{

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

		vv += v[i];

	}

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

		f[i] = MAXI;

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

	{

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

		{

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

		}

	}

	ll maxx = -MAXI;

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

		if (f[i] <= m) maxx = i;

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

	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.164651814640854x):
#include <cstring>

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



const int INF = 0x3f3f3f3f;



using namespace std;

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	int n, w;

	cin >> n >> w;

	int value_max = n*1000+1;

	int n_max = n + 1;

	int dd[n_max][value_max];



	// initialize

	memset(dd, INF, sizeof dd);

	/*

	for (int nn = 0; nn < n_max; nn++) {

	  for (int v = 0; v < value_max; v++) {

	    dd[nn][v] = INF;

	  }

	}

	*/



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

	  dd[nn][0] = 0;

	}

	for (int nn = 1; nn < n_max; nn++) {

	  int www, nu;

	  cin >> www >> nu;

	  for (int v = 1; v < value_max; v++) {

	    // don't use item nn-1

	    int cur = dd[nn-1][v];



	    // use item nn-1

	    if (nu <= v) {

	      int rem_v = v - nu;

	      int cand = dd[nn-1][rem_v] + www;

	      if (cand <= w && cand < cur) {

		cur = cand;

	      }

	    }



	    dd[nn][v] = cur;

	  }

	}

	bool done = false;

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

	  if (done) {

	    break;

	  }

	  for (int nn = 0; nn < n_max; nn++) {

	    if (dd[nn][v] != INF) {

	      cout << v << '\n';

	      done = true;

	      break;

	    }

	  }

	}



	if (!done) {

	  cout << 0 << '\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: 9.770062739365816x):
#include <cstring>

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



const int INF = 0x3f3f3f3f;



using namespace std;

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	int n, w;

	cin >> n >> w;

	int value_max = n*1000+1;

	int n_max = n + 1;

	int dd[n_max][value_max];



	// initialize

	memset(dd, INF, sizeof dd);

	/*

	for (int nn = 0; nn < n_max; nn++) {

	  for (int v = 0; v < value_max; v++) {

	    dd[nn][v] = INF;

	  }

	}

	*/



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

	  dd[nn][0] = 0;

	}

	for (int nn = 1; nn < n_max; nn++) {

	  int www, nu;

	  cin >> www >> nu;

	  for (int v = 1; v < value_max; v++) {

	    // don't use item nn-1

	    int cur = dd[nn-1][v];



	    // use item nn-1

	    if (nu <= v) {

	      int rem_v = v - nu;

	      int cand = dd[nn-1][rem_v] + www;

	      if (cand <= w && cand < cur) {

		cur = cand;

	      }

	    }



	    dd[nn][v] = cur;

	  }

	}

	bool done = false;

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

	  if (done) {

	    break;

	  }

	  for (int nn = 0; nn < n_max; nn++) {

	    if (dd[nn][v] != INF) {

	      cout << v << '\n';

	      done = true;

	      break;

	    }

	  }

	}



	if (!done) {

	  cout << 0 << '\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.448872170985806x):
/*

    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;

}
// 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.501363610534492x):
#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:
/**

 *  Author : Coda

 *  Title : OSU!

 *  Date : 2019-08-20

 */

#include <bits/stdc++.h>

using namespace std ;



typedef long long ll ;

typedef unsigned long long ull ;

typedef double DB ;

const long long mod = 1e9+7 ;

const double pi = acos(-1) ;

#define PB push_back

#define MP make_pair

#define lb lower_bound

#define ub upper_bound

#define fs first

#define sd second

#define pii pair<int,int>

#define INF 0x3f3f3f3f

#define LLINF 0x3f3f3f3f3f3f3f3f

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

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

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

//#pragma comment(linker,"/STACK:10240000,10240000")

//#include <random>

//mt19937 rand_(time(0));

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll qpow(ll a,ll b,ll c){ll t=1;while(b){if(b&1)t=t*a%c;a=a*a%c;b>>=1;}return t;}

ll inv(ll x){return qpow(x,mod-2,mod);}

int test = 1 ;



const int maxn = 5 + 3e5 ;

const int maxm = 5 + 1e6 ;

// Write the variables here



int N,W ;

ll v[maxn],w[maxn] ;

ll dp[maxn] ;



//#define TEST

int main(){

#ifdef TEST

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

#endif

    while(test--){

        // code begins

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



        ll sum = 0 ;

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

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

        }

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

            dp[i] = LLINF ;

        }

        dp[0] = 0;

        ll ans = 0 ;

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

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

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

            }

        }

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

            if(dp[i]<=W) ans = max(ans,i*1ll) ;

        }

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



    }

#ifdef TEST

    cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;

#endif

    return 0 ;

}


// Faster C++ solution for the same problem (measured speedup: 2.594491614644526x):
#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;

}