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

#define ll long long

using namespace std;

#define inf 0x3f3f3f3f 

#define MAXN 1019191130

int main(){

	ll  n , W; cin >> n >> W;

    ll w[101] , v[101] , dp[100001];

    for(int i = 0 ; i <= 100000; ++i) dp[i] = inf;

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

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

        dp[0] = 0;

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

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

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

        }

    }

    int j = 100001;

    while(j-- && dp[j] > W);



    cout<< j <<endl;

}

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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

using namespace std;

int main()

{

	 int n,W;

    cin>>n>>W;

    long long w[n];

    long long v[n];

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

    long long dp[100005];

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

    {

    	dp[i]=1e15;

	}

    dp[0]=0;

    int res=0;

    for(int i=0;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){

                res=max(res,j);

            }

        }

    }

    cout<<res<<endl;

}

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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN=1e5+7;

int N,W,ans;

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

int main()

{

	cin>>N>>W;

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

	memset(f,127,sizeof(f));

	f[0]=0;

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

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

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

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

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

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

#include <cassert>

#include <algorithm>

#define N int(1e5+1)

using namespace std;

typedef pair<int,int> pii;

int dp[N];

struct{

    int w,v;

}a[100];

int main(int argc,char ** argv)

{

    int n,w;

    cin>>n>>w;

    fill(dp+1,dp+N,w+1);

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

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

    }

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

        for(int j=N-1;j>=a[i].v;--j){

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

        }

    }

    int i;

    for(i=N-1;dp[i]>w;--i);

    cout<<i<<endl;

    return 0;

}

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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

 

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

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

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

#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)

#define ones(x) (ll) __builtin_popcount(x)

#define fs first

#define sc second

#define pb push_back

#define po pop_back

#define mp make_pair  

#define sz(a) (ll) a.size()

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

#define sor(a) sort( a.begin(), a.end() )

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

#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)

#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl

#define PI 3.1415926535

using namespace std;

typedef long long ll;

typedef long double ld; 

typedef pair<ll,ll> ii ;

typedef vector<ll>  vi ;

typedef vector<ii> vii ;

const ll mod = 1e9+7;

const ll MAX = 1e5+5;

const ll inf = 1e18+7;



ll dp[MAX];

int main() {

  fastio;

  ll n,capac;

  cin>>n>>capac;

  f(i,0,MAX+1) dp[i]=inf;

  dp[0]=0;

  f(i,0,n){

    ll w,v;

    cin>>w>>v;

    af(j,MAX,v){

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

    }

  }

  af(j,MAX,0){

  if(dp[j]<=capac){cout<<j<<"\n";break;}

  }

  return 0; 

}

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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

//#pragma GCC optimize("Ofast")

//#pragma GCC target("avx,avx2,fma")



using namespace std;



typedef long long ll;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;



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

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

#define pi pair<int,int>

#define F first

#define S second

#define pb push_back

#define pp pop_back

#define mod 1000000007

#define pai acos(-1)

#define N 100000



ll Weight[N+5],Profit[N+5],dp[2][N+5];



int main ()

{

   ios_base::sync_with_stdio(false);

   cin.tie(NULL);

   int n,w;cin>>n>>w;

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

      cin>>Weight[i]>>Profit[i];

   }

   fill(dp[0],dp[0]+2*(N+5),INT_MAX*105);

   dp[(n+1)%2][0]=0;

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

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

         ll op1=dp[(i+1)%2][p];

         ll op2=(p-Profit[i]>=0)?Weight[i]+dp[(i+1)%2][p-Profit[i]]:INT_MAX*105;

         dp[i%2][p]=min(op1,op2);

      }

   }

   int ans=0;

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

      if(dp[1][i]<=w){

         ans=max(ans,i);

      }

   }

   cout<<ans<<"\n";

   return 0;

}




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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

using namespace::std;



const int MAX = 100000 + 5;

const int inf = 1e9 + 10;



int n;

int C;

int memo[MAX];



int main(){

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

	int sum = 0;

	for(int i = 1; i < MAX; i++) memo[i] = inf;

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

		int w, v;

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

		sum += v;

		for(int j = sum; j >= v; j--){

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

		}

	}

	int ans = 0;

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

		if(memo[i] <= C) ans = i;

	}

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

	return 0;

}

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

using namespace std;

using ll=long long;

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

const int mod=1e9+7;

const int inf=1e9;

int w[M],v[M];

int dp[M][N];

 

int main(){

    int W,n;

    int val=0;

    cin>>n>>W;

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

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

        val+=v[i];

    }

    dp[0][0]=0;

    for(int i=1;i<=val;i++) dp[0][i]=inf;

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

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

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

            if(i>=v[j]){

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

            }

        }

    }

    

    int ans=0;

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

        if(dp[n][i]<=W) ans=i;

    }

    

    cout<<ans<<'\n';

    return 0;

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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

ll dp[MAX];

int main (){

    int N,W;cin >> N >> W;

    memset(dp,63,sizeof dp);

    dp[0]=0;

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

        int w,val;

        cin >> w >> val;

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

            if(j-val>=0)

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

        }



    }

    int res=0;

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

        if(dp[i]<=W) res = max(res,i);

    }

    cout<<res<<endl;

    return 0;

}


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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

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

using namespace std;



#define pb push_back

#define mk make_pair

#define fi first

#define se second

#define eb emplace_back



typedef long long ll;

typedef pair<int,int> ii;

typedef vector< pair<int,int> > vii;

const ll INF = 0x3f3f3f3f3f3fef;



const int V = 1e5+2;

const int N = 102;



ll dp[V];

ll p[N];

ll v[N];

ll n,w;

 

int main() {

    ios_base::sync_with_stdio(false);

    for(int i = 0; i < V; i++) dp[i] = INF;



    cin >> n >> w;

    for(int i = 0; i < n; i++) cin >> p[i] >> v[i];

    

    dp[0] = 0;



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

        for(ll j = V-1; j-v[i] >= 0; j--)

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



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

        if(dp[i] <= w) { cout << i << endl; return 0; }





    return 0;

}




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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

}
// Slower C++ solution:
//by Top1

#include <bits/stdc++.h>

     

#define f first

#define s second

#define int long long

#define ld long double

#define ull unsigned long long

#define pii pair <int, int>

#define pll pair <long, long>

#define mp make_pair

#define pb push_back

#define pf push_front

#define pp pop_back

#define rev reverse

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

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

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

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

#define nxtp next_permutation

#define pvtp prev_permutation

#define KZ return 

#define x1 x21212121

#define y1 y21212121

#define sqr(x) x * x 

 

const int inf = (1e9) + 1;

const int mod = 1e9 + 7;

const int maxn = 1e5 + 111;

     

using namespace std;



int q, n, w, a[maxn], b[maxn], dp[105][maxn], ans;



void solve(){    

	cin >> n >> w;



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

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



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

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

			dp[i][j] = inf;



	dp[0][0] = 0;



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

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

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

			if (j - b[i] >= 0)

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

			if (dp[i][j] <= w)

				ans = max(ans, j);

		}

		/*for (int j = 1; j <= 20; j++)

			cout << dp[i][j] << " ";

		cout << endl;	*/

		//cout << dp[i][100000] << endl;

	}



	//cout << dp[n][100000] << " ";



	/*for (int i = 0; i <= w; i++)

		cout << dp[i] << " ";

	*/

	cout << ans;

}



main(){

    boost;

	    

	q = 1;



	while (q--){

		solve();

	}

}

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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

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



using namespace std;



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

#define rloop(i, n) for(int i = int(n);i >= 0;i--)

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

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int, int> > vii;

typedef long long ll;

typedef pair<int, int> pii;



const int N = 105;

const int V = 1e5 + 5;

int dp[2][V];

int w[N], v[N];

int n, W;





int main() {



#ifndef ONLINE_JUDGE

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

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

#endif

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    cin >> n >> W;

    range(i, 1, V - 1)dp[n & 1][i] = W + 2;



    loop(i, n)cin >> w[i] >> v[i];



    rloop(i, n - 1) {

        loop(j, V) {

            dp[i & 1][j] = dp[i & 1 ^ 1][j];

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

        }

    }



    int ans = 0;

    rloop(i, V - 1) {

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

            ans = i;

            break;

        }

    }



    cout << ans << endl;



    return 0;

}


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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

}
// Slower C++ solution:
// @author: Amirul Islam



#include <bits/stdc++.h>

using namespace std;

#define LLI long long int

#define PII pair <int, int>



const int mx = 1e5+5;

const LLI INF = 1e10;



LLI dp[mx], w, val, N, W;



LLI max(LLI a, LLI b) {

    return (a > b ? a : b);

}



LLI knapsack(int N, int W) {

    for (int i = 0; i < mx; i++) dp[i] = INF;

    dp[0] = 0;

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

        scanf("%lld %lld", &w, &val);

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

            if (j >= val) dp[j] = min(dp[j], dp[j-val] + w);

        }

    }

    LLI ret = 0;

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

        if (dp[i] <= W) ret = max(ret, i);

    }

    return ret;

} 



int main() {

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

    printf("%lld\n", knapsack(N, W));

    return 0;

}

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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

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

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

const int N=1005;

const int maxn=1e5+5;

ll a[N],v[N];

ll dp[maxn];

int main(){

	int n,k;

	cin>>n>>k;

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

		cin>>a[i]>>v[i];

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

	dp[0]=0;

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

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

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

	ll ans=0;

	for(int i=1;i<=maxn-5;++i)

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

	cout<<ans<<endl;

	return 0;

} 

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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

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

#include <cstring>

using namespace std;

const int maxn=1e5+5;

using ll = long long;

ll dp[maxn];

ll w[maxn],v[maxn];

int main()

{

   ll n,m,mm;

   cin>>n>>mm;

   m=0;

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

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

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

       m+=v[i];

   }

   dp[0]=0;

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

       for(ll j=m;j>=0;--j){

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

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

       }

   }

   for(int i=m;i>=0;--i){

       if(dp[i]<=mm){

           cout<<i<<endl;

           break;

       }

   }

   return 0;

}


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

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

#define ll long long

using namespace std;

const ll INF = 1e18L + 10;

int main(){

    fast;

    int n, w;

    cin >> n >> w;

    ll wt[n], val[n];

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

        cin >> wt[i] >> val[i];

    int sum_val = 0;

    for(int x: val)

        sum_val += x;

    vector <ll> dp(sum_val + 1, INF);

    dp[0] = 0;

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

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

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

            //cout << dp[j + val[i] << "acaa\n";

    ll ans = 0;

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

        if(dp[i] <= w)

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

    cout << ans << "\n";

    return 0;

}