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

#include <algorithm>

#include <cmath>

#include <cstdlib>

#include <cstdio>

#include <cstring>

#include <iomanip>

#include <string>

#include <set>

#include <vector>

#include <queue>

#include <stack>

using namespace std;

#define ms(a, x) memset(a, x, sizeof(a))

#define fore(i, a, n) for (long long i = a; i < n; i++)

#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)

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

#define sii(a, b) scanf("%d%d", &a, &b)

#define debug(a) cout << a << endl

#define endl '\n'

#define pi acos(-1.0)

#define tr t[root]

#define lson t[root << 1]

#define rson t[root << 1 | 1]

#define IO ios::sync_with_stdio(false), cin.tie(0)

const double eps = 1e-8;

inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }

typedef long long ll;

const int inf = 0x3f3f3f3f;

const int maxn=1000100;

#define maxn0 1e9+7;

//=================================================



ll sum;

ll w[maxn];

ll dp[maxn];

ll v[maxn];



// void init() {

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

//         w[i]=0;

//         v[i]=0;

//     }

// }

int main() {

    IO;

    ll n,W;

    cin>>n>>W;

    // sum=0;

    // init();

    memset(dp,inf,sizeof(dp));

    dp[0]=0;

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

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

        // sum+=v[i];

    }

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

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

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

        }

    }

    ll ans=-1;

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

        if(dp[i]<=W)

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

    }

    cout<<ans<<endl;



    return 0;

}

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

#define fr(i,a,n) for(ll i=a;i<n;i++)

#define YES cout<<"YES"<<endl

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

#define NO cout<<"NO"<<endl

#define pb(x) emplace_back(x)

#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define vi vector<ll>

#define mi map<ll,ll>

#define pi pair<ll,ll>

#define what(x) cout<<#x<<" ="<<x<<endl;

using namespace std;

using ll =long long;



ll dp[105][100005];

vi w(100005),val(100005);

ll n;





int main()

{

    fastio;

        fr(j,0,100005)dp[0][j]=1e18;



        fr(i,0,105)dp[i][0]=0LL;

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



        ll W;

        cin>>n>>W;



        ll s=0;

        fr(i,0,n)cin>>w[i]>>val[i],s+=val[i];





        fr(i,0,n)

        {

            fr(j,1,s+1)

            {

                if(j>=val[i])

                {

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

                }

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

            }

        }



            ll ans=0;

            fr(j,0,s+1)

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



            cout<<ans<<endl;





























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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";

#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";

#define     watch(a)        cout<<fixed<<setprecision(a)

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

#define     Endl            "\n";

#define     tab             "\t"

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

#define     sfl(a)          scanf(" %lld", &a);

#define     sf(a)           scanf(" %d", &a);

#define     srt(a)          sort(a.begin(),a.end());

#define     pi              2*acos(0.0)

const int sz=1e6+9;

const ll inf=1e18L+9;

ll dp[sz];





void solve(){

    reset(dp,inf);

    int n,w;

    sf(n);

    sf(w);

    vector<pair<ll,int>>v(n);

    dp[0]=0;

    int pnt=0;

    lp(i,0,n){

       sfl(v[i].first);

       sf(v[i].second);

       pnt+=v[i].second;

    }

    //bug(pnt, 1);

   // sort(v.begin(),v.end(),com);

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



        for(int j=pnt-v[i].second;j>=0;j--){

            dp[j+v[i].second]=min( dp[j+v[i].second],(ll)dp[j]+(ll)v[i].first);

        }



    }

   // bug("140 dp",dp[140]);

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

        if(dp[i]<=w){

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

            return;

        }

    }

}



int main(){

    //FasterIO;

//    #ifndef ONLINE_JUDGE

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

//    #endif

    //int t;

//cin>>t;

   // while(t--)

        solve();

}


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

#define fr(i,a,n) for(ll i=a;i<n;i++)

#define YES cout<<"YES"<<endl

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

#define NO cout<<"NO"<<endl

#define pb(x) emplace_back(x)

#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define vi vector<ll>

#define mi map<ll,ll>

#define pi pair<ll,ll>

#define what(x) cout<<#x<<" ="<<x<<endl;

using namespace std;

using ll =long long;



ll dp[105][100005];

vi w(100005),val(100005);

ll n;





int main()

{

    fastio;

        fr(j,0,100005)dp[0][j]=1e18;



        fr(i,0,105)dp[i][0]=0LL;

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



        ll W;

        cin>>n>>W;



        ll s=0;

        fr(i,0,n)cin>>w[i]>>val[i],s+=val[i];





        fr(i,0,n)

        {

            fr(j,1,s+1)

            {

                if(j>=val[i])

                {

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

                }

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

            }

        }



            ll ans=0;

            fr(j,0,s+1)

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



            cout<<ans<<endl;





























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

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

#define fst first

#define snd second

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

#define pb push_back

#define sz size()

#define FORN(i,j,n) for(long long i=j; i<(long long)n;i++) 

#define FOR(i,n) FORN(i,0,n)

#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )

#define MOD 998244353LL

#define LIM 262150

#define ones(x) __builtin_popcount(x)

#define trace(x)    cerr << #x << ": " << x << endl;

#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;

using namespace std;

 

typedef long long ll ;

typedef unsigned long long ull ;

typedef vector <int> vi;

typedef pair <int,int> ii;

typedef vector <string> vs;

typedef vector <ii> vii;

ll n,w;

ll ans = 0;

ll dp[105][100005];

ll v[105];

ll p[105];

int main() {

	fastio;

	cin>> n >> w;

	FORN(i,1,n+1) cin>> p[i] >> v[i];

	FOR(i,n+1){

		FOR(j,1e5+1){

			dp[i][j] = 1e14;

		}

	}

	FORN(i,0,n+1){

		FOR(j,1e5+1){

		    if(j == 0){ dp[i][j] = 0; continue; }

		    if(i == 0){ dp[i][j] = 1e14; continue; }

			if(j >= v[i]){

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

			}

			else{

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

			}

		}

	}

	FOR(i,1e5+1){

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

			ans = max(ans,i);

		}

	}

	cout<< ans << '\n'; 

	//cout<< dp[3][100000] << '\n';

	return 0;

}

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

#define fr(i,a,n) for(ll i=a;i<n;i++)

#define YES cout<<"YES"<<endl

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

#define NO cout<<"NO"<<endl

#define pb(x) emplace_back(x)

#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define vi vector<ll>

#define mi map<ll,ll>

#define pi pair<ll,ll>

#define what(x) cout<<#x<<" ="<<x<<endl;

using namespace std;

using ll =long long;



ll dp[105][100005];

vi w(100005),val(100005);

ll n;





int main()

{

    fastio;

        fr(j,0,100005)dp[0][j]=1e18;



        fr(i,0,105)dp[i][0]=0LL;

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



        ll W;

        cin>>n>>W;



        ll s=0;

        fr(i,0,n)cin>>w[i]>>val[i],s+=val[i];





        fr(i,0,n)

        {

            fr(j,1,s+1)

            {

                if(j>=val[i])

                {

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

                }

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

            }

        }



            ll ans=0;

            fr(j,0,s+1)

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



            cout<<ans<<endl;





























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

#define endl "\n"

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

using ll = long long;

const int INF = 0x3f3f3f3f;

using namespace std;



int n, W, w[101], v[101];

ll dp[100001], mx;

ll oo = 1e18;

int main()

{

    IOS

    cin >> n >> W;

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

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

        mx += v[i];

    }

    memset(dp, INF, sizeof dp);

    dp[0] = 0;

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

        for (int rem = mx; rem>=v[i]; --rem) {

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



        }

    }

    int ans =0;

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

        if (dp[i] <= W) {

            ans = i;

        }

    }

    cout << ans << endl;



    return 0;

}


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

#define endl "\n"

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

using ll = long long;

const int INF = 0x3f3f3f3f;

using namespace std;



int n, W, v[101], w[101];

ll mx;

int main()

{

    IOS

    //bfreopen("balalance.in", "r", stdin);

    cin >> n >> W;

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

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

        mx += v[i];

    }

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

    dp[0] = 0;

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

        for (int rem = mx; rem>= v[i]; --rem) {

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

        }

    }

    ll ans = 0;

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

        if (dp[i] <= W) {

            ans = i;

        }

    }

    cout << ans << endl;



    return 0;

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

#define int long long

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

#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)



int const MOD = 1e9 + 7;

int const N = 105;

int const MX = 1e5;

using namespace std;



int num[N], fn[N];



int wt[N], vl[N];

int dp[100010];

int32_t main(){

    memset(dp, -1, sizeof dp);

    int n, w;

    cin>>n>>w;

    

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

        cin>>wt[i]>>vl[i];

    }

    

    dp[0] = 0;

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

        int val = vl[i];

        int weight = wt[i];

        int b[100005];

        memset(b, -1, sizeof b);

        for(int j = 0; j<=MX-val; j++){

            if(dp[j] != -1){

                if(dp[j+val] == -1)

                    b[j+val] = dp[j] + weight;

                else{

                    b[j + val] = min(dp[j+val], dp[j] + weight);

                }

            }

        }

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

            if(b[j] != -1)

                dp[j] = b[j];

        }

    }

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

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

            cout<<i<<endl;

            break;

        }

    }

}


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

#define int long long

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

#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)



int const MOD = 1e9 + 7;

int const N = 105;

int const MX = 1e5;

using namespace std;



int num[N], fn[N];



int wt[N], vl[N];

int dp[100010];

int32_t main(){

    memset(dp, -1, sizeof dp);

    int n, w;

    cin>>n>>w;

    

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

        cin>>wt[i]>>vl[i];

    }

    

    dp[0] = 0;

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

        int val = vl[i];

        int weight = wt[i];

        for(int j = MX-val; j>=0; j--){

            if(dp[j] != -1){

                if(dp[j+val] == -1)

                    dp[j+val] = dp[j] + weight;

                else{

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

                }

            }

        }

    }

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

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

            cout<<i<<endl;

            break;

        }

    }

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

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

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

#define rep(i,x,n) for(int i=x;i<n;i++)

#define repd(i,x,n) for(int i=x;i<=n;i++)

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MSC0(X) memset((X), '\0', sizeof((X)))

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define eps 1e-6

#define gg(x) getInt(&x)

using namespace std;

typedef long long ll;

inline void getInt(int* p);

const int maxn=1000010;

const int inf=0x3f3f3f3f;

/*** TEMPLATE CODE * * STARTS HERE ***/

ll dp[maxn];

ll n,W;

ll v[maxn];

ll w[maxn];

int main()

{

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

    gbtb;

    cin>>n>>W;

    repd(i,1,n)

    {

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

    }

    ll ans=0ll;

    dp[0]=0;

    repd(i,1,n)

    {

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

        {

            {

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

                if(dp[j]<=W)

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

            }

        }

    }

    cout<<ans<<endl;

    return 0;

}



inline void getInt(int* p) {

    char ch;

    do {

        ch = getchar();

    } while (ch == ' ' || ch == '\n');

    if (ch == '-') {

        *p = -(getchar() - '0');

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 - ch + '0';

        }

    }

    else {

        *p = ch - '0';

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 + ch - '0';

        }

    }

}

// Faster C++ solution for the same problem (measured speedup: 4.567589336727464x):
/*

 * @Filename: 

 * @Author: shifaqiang

 * @Email: 14061115@buaa.edu.cn

 * @Github: https://github.com/luoboganer

 * @Date: 2020-07-12 00:38:24

 * @LastEditors: shifaqiang

 * @LastEditTime: 2020-07-12 23:30:58

 * @Software: Visual Studio Code

 * @Description: 

 */



#include <algorithm>

#include <iostream>

#include <math.h>

#include <string>

#include <vector>



using namespace std;



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

{

    int n, w, weight, value, ret = 0, total_values = 0;

    int max_values = 1e5; // 可能获得的最大价值

    int max_volumes = 1e9;

    cin >> n >> w;

    vector<long long> dp(max_values + 1, max_volumes); // dp[j]代表到i这个价值所需要的最小体积

    dp[0] = 0;                                         // initialization

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

    {

        cin >> weight >> value;

        total_values += value;

        for (auto j = max_values; j >= value; j--)

        {

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

            if (dp[j] <= w && j > ret && j <= total_values)

            {

                ret = j;

            }

        }

    }

    cout << ret << endl;

    return 0;

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

#include <map>

#include <set>

#include <cmath>

#include <queue>

#include <cstdio>

#include <string>

#include <vector>

#include <cstring>

#include <algorithm>

#include <unordered_map>



using namespace std;

const int INF = 0x3f3f3f3f;

//static const auto _____ = []()

//{

//	ios::sync_with_stdio(false);

//	cin.tie(nullptr);

//	return nullptr;

//}();

typedef long long ll;



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

    int N, V;

    cin >> N >> V;

    vector<ll> v(N + 1, 0);

    vector<ll> w(N + 1, 0);

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

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

    }

    int upper = N * 1000; // 由题目得到的最大价值，每件物品最大价值为1000，有N件物品

    vector<vector<ll>> dp(N + 1, vector<ll>(upper+1, INF)); // 这里求最小容量，所以初始化为-INF

    dp[0][0] = 0; //前0个物品，价值为0的所消耗的最小容量为0

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

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

            if(j < w[i]) dp[i][j] = dp[i-1][j];

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

        }

    }

    // dp[N][i] 存储的是对应前N个物品，价值为i时的最小容量

    // 题目要求我们求最大价值，所以我们更加关注的是dp[N][i]中的i，而不是dp[N][i] = x中的x

    ll res = 0; // 求最大价值

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

        if (dp[N][i] <= V){

            res = i;

        }

    }

    cout << res;

    return 0;

}

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

#include <map>

#include <set>

#include <cmath>

#include <queue>

#include <cstdio>

#include <string>

#include <vector>

#include <cstring>

#include <algorithm>

#include <unordered_map>



using namespace std;

const int INF = 0x3f3f3f3f;

//static const auto _____ = []()

//{

//	ios::sync_with_stdio(false);

//	cin.tie(nullptr);

//	return nullptr;

//}();

typedef long long ll;



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

    int N, V;

    cin >> N >> V;

    vector<ll> v(N + 1, 0);

    vector<ll> w(N + 1, 0);

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

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

    }

    int upper = N * 1000; // 由题目得到的最大价值，每件物品最大价值为1000，有N件物品

    vector<ll> dp(upper + 1, INF);// 这里求最小容量，所以初始化为-INF

    dp[0] = 0; //前0个物品，价值为0的所消耗的最小容量为0

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

        for (int j = upper; j >= w[i]; j--) {

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

        }

    }

    // dp[N][i] 存储的是对应前N个物品，价值为i时的最小容量

    // 题目要求我们求最大价值，所以我们更加关注的是dp[N][i]中的i，而不是dp[N][i] = x中的x

    ll res = 0; // 求最大价值

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

        if (dp[i] <= V) {

            res = i;

        }

    }

    cout << res;

    return 0;

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

#include <cstdio>

#include <cstring>

using namespace std;



typedef long long llt;



const int MaxN = 100 + 5, MaxV = 100000 + 5;



int N, W;

llt w[MaxN]; int v[MaxN];

llt dp[MaxV];



void init() {

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

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

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

}



void solve() {

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

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

    if (dp[i] <= W) {

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

      return;

    }

}



int main() {

  init();

  solve();

  return 0;

}

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

#include <cstring>



const int MaxN = 100 + 5, MaxV = 100000 + 5;

const long long INF = 0x7F7F7F7F7F7F7F7F;



template <typename Typ>

inline Typ min(Typ x, Typ y) { return x < y ? x : y; }



int N, M;

int W[MaxN], V[MaxN];

long long Dp[MaxV];



void init() {

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

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

    scanf("%d %d", &W[i], &V[i]);

}



void solve() {

  memset(Dp, 0x7F, sizeof Dp);

  Dp[0] = 0;

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

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

      if (Dp[j - V[i]] != INF)

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

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

    if (Dp[j] <= M) {

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

      break;

    }

}



int main() {

  init();

  solve();

  return 0;

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

using namespace std;

#define db(x) cout << #x << " = " << (x) << "\n";

using ll = long long;

using ld = long double;



int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    ll n, w;

    cin >> n >> w;

    ll vl_lmt = 1'000 * 102;

    vector<long long> dp(vl_lmt, INT_MAX);

    dp[0] = 0;

    ll wi, vi;

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

    {

        cin >> wi >> vi;

        for (int j = vl_lmt - vi - 1; j >= 0; j--)

        {

            if (wi + dp[j] <= w && dp[j + vi] > dp[j] + wi)

            {

                dp[j + vi] = dp[j] + wi;

            }

        }

    }

    for (int j = vl_lmt -1; j >= 1; j--)

    {

        if (dp[j] != INT_MAX)

        {

            cout << j;

            return 0;

        }

    }

    return 0;

}


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

using namespace std;

#define db(x) cout << #x << " = " << (x) << "\n";

using ll = long long;

using ld = long double;



int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    ll n, w;

    cin >> n >> w;

    ll vl_lmt = 1'000 * 101;

    vector<long long> dp(vl_lmt, INT_MAX);

    dp[0] = 0;

    ll wi, vi, ans = 0;

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

    {

        cin >> wi >> vi;

        for (int j = ans; j >= 0; j--)

        {

            if (wi + dp[j] <= w && dp[j + vi] > dp[j] + wi)

            {

                dp[j + vi] = dp[j] + wi;

                ans = max(ans, j + vi);

            }

        }

    }

    cout << ans;

    return 0;

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



using namespace std;



mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



#define hash sodnf9843bsd

#define ll long long

#define INF (1<<29)

#define INFF 0x7fffffff

#define LINF (1ll<<60)

#define LINFF 0x7fffffffffffffff

#define PI 3.14159265359

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

#define _fj(n) for(int j = 0;j < n;j++)

#define _fk(n) for(int k = 0;k < n;k++)

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

#define rall(x) x.rbegin(), x.rend()

#define YESNO(ans) cout << (ans?"YES":"NO") << endl

#define prec(x) cout << fixed << setprecision(x)

#define pqueue priority_queue

#define pb push_back

#define eb emplace_back

#define mp make_pair

#define mt make_tuple

#define endl '\n'



const ll maxn = 100;

const ll maxv = 100000;

ll iw[maxn+7];

ll dp[maxn+7][maxv+7] = {};

int iv[maxn+7];

int n, w;



ll solve(int i, int j){

    if (j <= 0) return 0;

    if (i == n) return LINF;



    if (dp[i][j] == 0){

        dp[i][j] = min(solve(i+1, j-iv[i])+iw[i], solve(i+1, j));

    }

    return dp[i][j];

}



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);



    cin>>n>>w;

    _fi(n) cin>>iw[i]>>iv[i];



    int ans = 0;

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

        if (solve(0, i) <= w) ans = i;

    }

    cout << ans << endl;





    return 0;

}


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



using namespace std;



mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



#define hash sodnf9843bsd

#define ll long long

#define INF (1<<29)

#define INFF 0x7fffffff

#define LINF (1ll<<60)

#define LINFF 0x7fffffffffffffff

#define PI 3.14159265359

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

#define _fj(n) for(int j = 0;j < n;j++)

#define _fk(n) for(int k = 0;k < n;k++)

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

#define rall(x) x.rbegin(), x.rend()

#define YESNO(ans) cout << (ans?"YES":"NO") << endl

#define prec(x) cout << fixed << setprecision(x)

#define pqueue priority_queue

#define pb push_back

#define eb emplace_back

#define mp make_pair

#define mt make_tuple

#define endl '\n'



const ll maxn = 100;

const ll maxv = 100000;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);



    ll iw[maxn+7];

    int iv[maxn+7];

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

    _fi(n) cin>>iw[i]>>iv[i];



    ll dp[maxv+7] = {};

    for(int i = 1;i <= maxv;i++) dp[i] = LINF;

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

        for(int j = maxv;j >= iv[i];j--){

            dp[j] = min(dp[j], iw[i]+dp[j-iv[i]]);

        }

    }



    ll ans = 0;

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

        if (dp[i] <= w) ans = i;

    }

    cout << ans << endl;



    return 0;

}