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

#include<cstdlib>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<stack>

#define LL long long

using namespace std;

LL n,m;

LL dp[100011];

LL x,y,ans;

LL read()

{

	LL _=0,__=1;char ch=getchar();

	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}

	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}

	return _*__;

}

int main()

{

	n=read();m=read(); 

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

	dp[i]=1e9+7;

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

	{

		x=read();y=read();

		for(int j=100000;j>=y;j--)

		{

			dp[j]=min(dp[j],dp[j-y]+x);

		}

	}

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

	{

		if(dp[i]<=m)

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

	}

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

	return 0;

}


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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

    return 0;

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

#define MAX 100005

#define pb push_back

#define mp make_pair

#define pii pair<long long,long long>

#define read(a) scanf("%d",&a)

#define p1(a) cout<<"Check "<<a<<endl;

#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;

#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;

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

#define ll long long

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

#define MOD 10000000000

#define INF 10000000000000



using namespace std;



int n,cp;

ll cost[MAX];

ll weight[MAX];

ll dp[MAX];





int main()

{

    cin>>n>>cp;

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

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

    }

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

    dp[0]=0;

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

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

            if(j-cost[i]>=0 && dp[j-cost[i]]!=INF){

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

            }

        }

    }

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

        if(dp[j]<=cp){

            cout<<j<<endl;

            break;

            //break;

        }

    }



    return 0;

}


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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

    return 0;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

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

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

typedef pair<ll,ll> ii;



#define pb push_back

#define fst first

#define snd second

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

#define mset(a,b) memset(a,b,sizeof(a));

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

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

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

struct objects{

    int weight,value;

};



int main()

{

    FIN;

#ifdef LOCAL

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

    freopen("output.txt", "w", stdout);

#else

#define endl '\n'

#endif

int n,w;

   cin>>n>>w;

   objects object[n];

   int totalvalue=0;

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

       cin>>object[i].weight>>object[i].value;

       totalvalue+=object[i].value;

   }

   ll dp[n+1][totalvalue+1];

   dp[0][0]=0;

   int ans=0;

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

       dp[0][i]=1e18;

   }

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

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

           if(j>=object[i].value){

                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);

           }

           else{

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

           }

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

               ans=max(ans,j);

           }

       }

   }

   cout<<ans;

    return 0;

}
// Slower C++ solution:
//g++  5.4.0



#include <bits/stdc++.h>

using namespace std;



const long long inf=1e18;



int main()

{       ios_base::sync_with_stdio(0);

        cin.tie(0);

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

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

        long n,W;

        cin>>n>>W;

        long v[n],w[n];



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

        {

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

        }



        long long dp[2][100007]; int mx=0; dp[0][0]=0; dp[1][0]=0;



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

        {   dp[0][i]=inf; dp[1][i]=inf;   }



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

        {

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

            {

                if(j%2==0){

                    if(i>=v[j] ) { if(dp[1][i-v[j] ] !=inf ) dp[0][i]=min( min(dp[1][i],dp[0][i]),dp[1][i-v[j]]+w[j] ); }



                                            {dp[0][i]=min(dp[0][i],dp[1][i]) ; }

                                            if(dp[0][i]!=inf && dp[0][i]<=W ) mx=max(i,mx);

                }

                else{

                    if(i>=v[j] ) { if(dp[0][i-v[j] ] !=inf ) dp[1][i]=min(min(dp[0][i],dp[1][i]),dp[0][i-v[j]]+w[j] ); }



                                            { dp[1][i]=min(dp[1][i],dp[0][i]) ; }

                                            if(dp[1][i]!=inf && dp[1][i]<=W ) mx=max(i,mx);

                }



            }

        }



        cout<<mx<<endl;



    return 0;

}


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

 using namespace std;

#define ll long long

int main(){

    int n,w;

    cin>>n>>w;

    ll a[2][n],dp[n*1000+1];

    for(int i=0;i<n;i++)cin>>a[0][i]>>a[1][i];

    for(int i=0;i<=n*1000;i++) dp[i]=INT_MAX;

    ll mx=0;

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

    {  

        for(ll j=n*1000;j>=1;j--){

            if(j>a[1][i] && dp[j-a[1][i]]!=INT_MAX ){ dp[j]=min(dp[j],dp[j-a[1][i]]+a[0][i]); }

            else if(j==a[1][i] ) dp[j]=min(dp[j],a[0][i]); 

                if( dp[j]!=INT_MAX && dp[j]<=w)  mx=max(j,mx);

            

        }

    }

    cout<<mx<<endl;

    return 0;

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

using namespace std;

typedef long long ll;

const ll inf = 1e15;

typedef pair<int,int> ii;

typedef vector<int> vi;



ll W[110],V[110];

ll dp[110][(int)1e5+10];



int main(){

	ll n,w;

	cin>>n>>w;

	ll max_val=0;

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

		cin>>W[i]>>V[i];

		max_val+=V[i];



	}

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

			dp[0][i]=inf;

	}

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

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

			if(j>=V[i]){

				dp[i][j]=min(dp[i-1][j],dp[i-1][j-V[i]]+W[i]);

			}else{

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

			}

			

		}

	}



	int ans=0;

	for(int v=max_val;v>=0 && !ans;v--){

		if(dp[n][v]<=w){

			ans=v;

		}

	}

	cout<<ans;

	



	return 0;

}

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

using namespace std;

typedef long long ll;

const ll inf = 1e15;

typedef pair<int,int> ii;

typedef vector<int> vi;



const int max_item_cnt=100+10;

const int max_value_sum=1e5+10;

ll W[max_item_cnt],V[max_item_cnt];

ll dp[max_value_sum]; 

// dp[i] - min sum of weights with i value

 

int main(){

	ll n,w;

	cin>>n>>w;

	ll max_val=0;

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

		cin>>W[i]>>V[i];

		max_val+=V[i];

	}

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

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

		for(int j=max_val;j>=V[i];j--){

			dp[j]=min(dp[j-V[i]]+W[i],dp[j]);

		}

	}

	ll ans=0;

	//ans - max v such as dp[v]<=w

	for(int v=max_val;v>=0 && !ans;v--){

		if(dp[v]<=w){

			ans=v;

		}

	}

	cout<<ans;

 

	return 0;

}