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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

    printf("%d\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: 2.8903901153683025x):
#include<bits/stdc++.h>

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

    printf("%d\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: 1.6800395445249943x):
#include<bits/stdc++.h>

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#include<cstring>

using namespace std;

int main()

{

	long long n,V;

	long long w[105],v[105],dp[100025];

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

    cin>>n>>V;

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

    {

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

    }

    long long ans=0;

    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]<=V)

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

            }

        }

    }

    cout<<ans<<endl;

    return 0;

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

using namespace std;

const int   N=1e2+10,M=1e5+10;

long long f[N][M],w[N],v[N];

int main()

{

	long long n,m;

	cin>>n>>m;

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

	{

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

	}

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

		for(int j=0;j<=M;j++)f[i][j]=1e9+1;

	f[0][0]=0;

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

	{

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

		{

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

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



		}

	}

	long long ans=0;

	for(long long  j=1;j<=M;j++)

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

	cout<<ans<<endl;

   return 0;

}


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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

using namespace std;

int f[105][100005];

int N,W;

int w[105],v[105];

int main()

{

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

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

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

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

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

	       f[i][j]=1e9+1;

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

	{

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

	    {

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

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

 	    }

	}

	int ans=0;

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

	   if(f[N][i] <= W) ans=i;//cout<<f[N][i]<<endl;

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

	return 0;

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

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

#define M 105

#define N 100005

#define MX (1LL<<60)

using namespace std;

int n,m,w[M],v[M];

long long dp[N];

int main()

{

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

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

    

    fill(dp, dp+N, MX);

    dp[0] = 0;

    REP(i,1,n) for (int j=N-1; j>=v[i]; j--) {

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

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

        }

    }



    int ans = 0;

    REP(i,0,N-1) if (dp[i]<=m) ans = i;

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

    return 0;

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

#define MOD 1000000007

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

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

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

#define mp make_pair

#define f first

#define s second

#define pb(x) push_back(x)

typedef  long long  int ll;

typedef std::vector<ll> vi;



#define input(vec,a,b) for(ll i =a;i<b;i++) cin>>vec[i]

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" " ;cout<<endl;

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

using namespace std;





void solve(){

        ll i,j , n,w,out;

        cin>>n>>w;

        ll we[n],v[n];

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

        {

                 cin>>we[i]>>v[i];

        }

        ll mv[n+1][100001]={0};

        bool p[n+1][100001]={0};

        

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

        {

                 mv[0][i]=0;

                 p[0][i]=0;

        }

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

        {

                 mv[i][0]=0;

                 p[i][0]=1;

        }

        

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

        {

                 for(j=0;j<v[i-1];j++)

                 {

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

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

                 }

                 for(j=v[i-1];j<=100000;j++)

                 {

                          if(p[i-1][j-v[i-1]])

                          {

                                   if(p[i-1][j])

                                   mv[i][j]=min(mv[i-1][j],mv[i-1][j-v[i-1]]+we[i-1]);

                                   else

                                   mv[i][j]=mv[i-1][j-v[i-1]]+we[i-1];

                                   p[i][j]=1;

                          }

                          else

                          {

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

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

                          }

                 }

        }

        out=0;

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

        {

              if(p[n][i]&&mv[n][i]<=w)

              {

                       cout<<i;

                       return;

              }

        }

       

}



int main()

{

      IO;

      ll t=1;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

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

#define MOD 1000000007

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

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

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

#define mp make_pair

#define f first

#define s second

#define pb(x) push_back(x)

typedef  long long  int ll;

typedef std::vector<ll> vi;



#define input(vec,a,b) for(ll i =a;i<b;i++) cin>>vec[i]

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" " ;cout<<endl;

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

using namespace std;





void solve(){

        ll i,j , n,w,out;

        cin>>n>>w;

        ll we[n],v[n];

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

        {

                 cin>>we[i]>>v[i];

        }

        ll mv[n+1][100001]={0};

        bool p[n+1][100001]={0};

        

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

        {

                 mv[0][i]=0;

                 p[0][i]=0;

        }

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

        {

                 mv[i][0]=0;

                 p[i][0]=1;

        }

        

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

        {

                 for(j=0;j<v[i-1];j++)

                 {

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

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

                 }

                 for(j=v[i-1];j<=100000;j++)

                 {

                          if(p[i-1][j-v[i-1]])

                          {

                                   if(p[i-1][j])

                                   mv[i][j]=min(mv[i-1][j],mv[i-1][j-v[i-1]]+we[i-1]);

                                   else

                                   mv[i][j]=mv[i-1][j-v[i-1]]+we[i-1];

                                   p[i][j]=1;

                          }

                          else

                          {

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

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

                          }

                 }

        }

        out=0;

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

        {

              if(p[n][i]&&mv[n][i]<=w)

              {

                       cout<<i;

                       return;

              }

        }

       

}



int main()

{

      IO;

      ll t=1;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

}