stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
																//  SMOKE SHISHA PLAY FIFA  // 

#include<bits/stdc++.h>

using namespace std;



typedef long long int ll;

typedef long double ld;



#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

#define pll pair<ll,ll>

#define MP make_pair

#define ff first

#define ss second

#define PB push_back

#define mod 1000000007

#define lp(i,start,end) for(ll i=start;i<=end;i++) 

#define deb1(a) cout<<#a<<" = "<<(a)<<endl;

#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;

#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;





ll modu(ll a, ll b)

{

	ll ans =1;

	while(b>0)

	{

		if(b&1)

		ans = (ans*a)%mod;

		b/=2;

		a = (a*a)%mod;

	}

	return ans;

}



int main()

{

	fastio

	ll t=1;

	//cin >> t;

	while(t--)

	{

		ll n,wt,ma=0;

		cin>>n>>wt;

		ll w[n+1],v[n+1];

		lp(i,1,n){

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

			ma+=v[i];

		}

		ll dp[100000];

		dp[0]=0;

		lp(i,1,100000)

			dp[i]=1000000000007;

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

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

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

			}

	}

		ll ans=0;

		for(ll i=0; i<=100000; i++){

			if(dp[i]<=wt){

				ans=max(ans,i);

			}

		}

		cout<<ans<<endl;



	}

	return 0;	

}


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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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



using namespace std;

typedef long long ll;

typedef unsigned long long ull;



const int mod  = 100003;

const int maxn = 1e5+10;



ll val[105],v[105],dp[100025];

int main()

{

	int n,V;

	ll ans = 0;

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

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

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

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

    dp[0]=0;

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

    {

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

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

    }

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

    	if(dp[i]<=V)

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

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

    return 0;

}


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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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

#include<cmath>

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

ll a[110],b[110];

ll dp[100005];

const int maxn=100005;

int main()

{

	ll n,w;

	cin>>n>>w;

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

		cin>>a[i]>>b[i];

	}

    

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

    dp[0]=0;

    ll ans=0;

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

		for(ll j=maxn;j>=b[i];j--){

			dp[j]=min(dp[j],dp[j-b[i]]+a[i]);

		}

	}

	

	for(ll i=0;i<maxn;i++){

		if(w>=dp[i])

			ans=max(ans,i);

	} 

	cout<<ans<<endl;

}

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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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

#include<cstring> 

using namespace std;

int main()

{

	long long n,w;

	cin>>n>>w;

	long long wt[n+1],v[n+1];

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

	cin>>wt[i]>>v[i];

	long long dp[100005];

	memset(dp,0x3f,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]]+wt[i]);

	long long ans=0;

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

		if(dp[i]<=w)

		ans=max(ans,i);

		cout<<ans;

	

 } 

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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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

using namespace std;

const int maxn=1e5+5;

const int inf=0x3f3f3f3f;

int main()

{

	int n,m,dp[maxn],w[105],v[105];

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

	int sum=0;

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

	{

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

		sum+=v[i];

	}

	memset(dp,inf,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>=0;i--)

		if(dp[i]<=m)

		{

			printf("%d",i);

			return 0;

		}

}

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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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

using namespace std;



int main() {

    long long n,w;    cin>>n>>w;

    long long dp[100005];

    memset(dp, 1e9+1, sizeof(dp));

    long long mx_till_now=0;

    dp[0]=0;

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

        long long wi,vi;cin>>wi>>vi;

        for(long long j=mx_till_now;j>=0;j--)if( dp[j]!=1e9+1 && (dp[j] + wi==1e9+1 ||(dp[j] + wi)<=w )){

                dp[j+vi] = min ( dp[j+vi] , dp[j] + wi );

                mx_till_now=max(mx_till_now,j+vi);

        }

    }   

    cout<<mx_till_now;

    

    return 0;

}

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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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

using namespace std;

typedef unsigned long long ull;

typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;

const int maxn = 1e5 + 9;

inline int read()

{

    int data = 0, f = 1;

    char ch = getchar();

    while (!isdigit(ch))

    {

        if (ch == '-')

            f = -1;

        ch = getchar();

    }

    while (isdigit(ch))

    {

        data = (data << 3) + (data << 1) + ch - '0';

        ch = getchar();

    }

    return f * data;

}



int v[109], p[1009];

ull dp[maxn];

int main()

{

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

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

    //std::ios::sync_with_stdio(false);

    //std::cin.tie(0);

    int n = read(), w = read();

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

        p[i] = read(), v[i] = read();

    for (ull i = 1; i < maxn; ++i)

        dp[i] = INF;

    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]] + p[i]);

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

        if (dp[i] <= w)

        {

            cout << i << '\n';

            break;

        }

    //fclose(stdin);

    //fclose(stdout);

    return 0;

}

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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

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

#include <cstring>

using namespace std;



typedef long long ll;



const int maxn = 105, maxw = 1e9 + 5, maxv = 1e3 + 5;



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

{

    ll n, W, w[maxn], v[maxn], dp[maxv*maxn], ans = 0;

    //memset(dp, maxw, sizeof dp);

    for (int i = 0; i < maxv * maxn; i++)

        dp[i] = maxw;

    cin >> n >> W;

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

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



    dp[0] = 0;

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

        for (int j = maxv * maxn - 1; 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 << endl;

    return 0;

}

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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



  return 0;

}
// Slower C++ solution:
//E

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e5+10;

const int INF = 1e9+10;

int f[maxn];

int w[105],v[105];

signed main(){

	ios::sync_with_stdio(0);

	cin.tie(0);

	int n,W;

	cin >> n >> W;

	for(int i = 1;i < maxn;i++)f[i] = INF;

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

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

		for(int j = maxn-1;j >= 0;j--)if(j >= v[i])f[j] = min(f[j],f[j-v[i]] + w[i]);

	}

	int ans = 0;

	for(int i = 0;i < maxn;i++)if(f[i] <= W)ans = max(ans,i);

	cout << ans;

	return 0;

}


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

#include <set>

using namespace std;

#define mp             make_pair

#define pb             push_back

#define fi             first

#define se             second

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

#define fill(x, y)     memset(x, y, sizeof(y))

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

typedef long long      ll;

typedef pair<int, int> ii;

typedef pair<ii, int>  iii;

typedef vector<int>    vi;

typedef vector<ii>     vii;

typedef vector<iii>    viii;



const ll INF = 1000000100;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  ll N, W;

  cin >> N >> W;



  ll w[N+1];

  int v[N+1];



  int V = 0;

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

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

    V += v[i];

  }



  ll dp[N+1][V+1];

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

      dp[0][i] = INF;

  }

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

      dp[i][0] = 0;

  }



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

      for (int j = 1; j <= V; j++) {

          if (v[i] > j) {

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

          } else {

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

          }

      }

  }



  int opt = 0;

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

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

          if (dp[i][j] <= W) {

              opt = max(opt, j);

          }

      }

  }

  cout << opt << "\n";



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

using namespace std;

typedef long long int ll;

ll K[105][100005];



ll knapSack(ll n,ll v[],ll W,ll w[],ll tot)

{

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

    {

        for (ll pr=0; pr<=tot; pr++)

        {

            if (i==0 && pr==0)

                K[i][pr]=0;

            else if(i==0)

                K[i][pr]=1e11;

            /*else if(w[i-1]<=wt)

                K[i][wt]=max(v[i-1]+K[i-1][wt-w[i-1]],K[i-1][wt]);*/

            else if(v[i-1]<=pr)

                K[i][pr]=min(w[i-1]+K[i-1][pr-v[i-1]],K[i-1][pr]);

            else

                K[i][pr]=K[i-1][pr];

        }

    }

    ll val=0;

	for(ll pr=0; pr<=tot; pr++)

		if(K[n][pr]<=W)

            val=pr;

	return val;

}



int main()

{

    ll n,W;

    cin>>n>>W;

    ll v[n+5],w[n+5];

    ll tot=0;

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

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

        tot+=v[i];

    }

    ll ans=knapSack(n,v,W,w,tot);

    cout<<ans<<endl;

    return 0;

}