stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define ll long long

#define inf 9999999999999999

#define F first

#define S second

#define eb emplace_back

#define mpp make_pair

#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'

#define dbg cout<<__LINE__ <<": 0manush\n"

#define read(x) freopen("input.txt","r",stdin)

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

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 100009

#define mod 10000007

using namespace std;

ll dp[109][mx];



int main(){//read(x);

//fast;

ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;

cin>>n>>k;

ll w[n],p[n];l=0;

for(i=0;i<n;i++){cin>>w[i]>>p[i];l+=p[i];}

dp[n][0]=0;

for(i=1;i<=l;i++)dp[n][i]=inf;

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

    for(j=0;j<=l;j++){

        dp[i][j]=min(dp[i+1][j],(j-p[i]>=0)?w[i]+dp[i+1][j-p[i]]:inf);

        //printf("%2lld ",dp[i][j]);

    }//cout<<endl;

}

a=0;

    for(j=0;j<=l;j++){

        if(dp[0][j]<=k){

            a=max(a,j);

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

        }

    }//cout<<endl;

    cout<<a<<endl;

}






// Fastest known solution for this problem:
// Original C++ solution (slower):
    #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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

        }

    }

}


// Optimized solution to the same problem (faster):
#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;

        }

    }

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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';

        }

    }

}

// Optimized solution to the same problem (faster):
/*

 * @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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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 (j < 0 || 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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define ll long long

#define ld long double

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

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

using namespace std;

const int M = 101010;

const ll inf = 1e17;

ll n, m, w[111], v[111], dp[111][M];



int main(){

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

	cin >>n >>m;

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



	dp[0][0] = 0;

	foru(i,1,M-1) dp[0][i] = inf;

	foru(i,1,n) foru(j,1,M-1){

		if(j < v[i])

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

		else

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

	}

	

	ll ans = 0;

	foru(j, 1, M-1) if(dp[n][j] <= m) ans = j;

	cout <<ans;

	return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define ll long long

#define ld long double

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

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

using namespace std;

const int M = 101010;

const ll inf = 1e17;

ll n, m, w[111], v[111], dp[M];



int main(){

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

	cin >>n >>m;

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



	dp[0] = 0;

	foru(i,1,M-1) dp[i] = inf;	//ko co cai nay la sai day nhe



	foru(i,1,n) ford(j,M-1,v[i])

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

	

	ll ans = 0;

	foru(j, 1, M-1) if(dp[j] <= m) ans = j;

	cout <<ans;

	return 0;

}


// Fastest known solution for this problem: