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

#include <vector>

#include <algorithm>

#include <numeric>

#include <cmath>

#include <set>

#include <tuple>

#include <functional>

#include <map>

#include <unordered_map>

#include <queue>

#include <tuple>



using namespace std;



#define endl '\n'



using ull = unsigned long int;

using ll = long long;



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  const int precision = 13;

  cout.precision(precision);

  cout.setf(ios_base::fixed);



  int n, W; cin >> n >> W;

  vector<ll> dp(1e5+10, W+1);



  dp[0] = 0;

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

    ll w, v; cin >>  w >> v;

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

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

    }

  }



  int ans = 0;

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

    if (dp[i] <= W) {

      ans = max(ans, i);

    }

  }

  cout << ans << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.42626595883856x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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

#include<cstring>

#include<cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

ll dp[maxn];

ll n, W;

ll v[maxn];

ll w[maxn];

inline ll max(ll x, ll y) {

	return x > y ? x : y;

}

inline ll min(ll x, ll y) {

	return x < y ? x : y;

}

int main() {

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

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> W;

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

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

	ll ans = 0ll;

	dp[0] = 0;

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

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

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

			if (dp[j] <= W) ans = max(ans, (ll)(j));

		}

	}

	cout << ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 10.950846912150277x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

}
// Slower C++ solution:
/*

    Mbak Rose Dong

*/

#include<bits/stdc++.h>

using namespace std;

long long int weight[105], value[105];

long long int dp[100100];

int main()

{

    int n, i, j, k, curr, m, ans;

    int tc;

    int w;

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

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

    {

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

    }

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

        dp[i] = 1e15;

    dp[0] = 0;

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

    {

        for(j=100000-value[i];j>=0;j--)

        {

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

        }

    }

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

    {

        if(dp[i] <= w)

        {

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

            return 0;

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.4614883258656834x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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

#include <cstring>

#include <algorithm>

#include <iostream>





using namespace std;



const int MaxN = 1e5 + 5;



long long dp[MaxN];

long long w[105] , W , n;

long long v[MaxN];



int main(){

	memset(dp , 0x3f , sizeof dp);

	cin >> n >> W;

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

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

	}

	dp[0] = 0;

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

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

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

		}

	}

	for(int i = MaxN - 1 ; i >= 0 ; i--){

		if(dp[i] <= W){

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

			break;

		}

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.468779803789647x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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



#define pb push_back

#define se second

#define fi first



using namespace std;



int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;

long long d[(int)2e5 + 7], mx;



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cin >> n >> w;

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

        cin >> a[i] >> c[i];

    for(int i = 1e5 + 6; i > 0; i--)

        d[i] = 1e9 + 7;

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

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

        if(d[j] != 1e9 + 7)

            d[j + c[i]] = min(d[j + c[i]], d[j] + a[i]);

    for(int j = 0; j <= 1e5 + 6; j++)

        if(d[j] <= w)

            mx = j;

    cout << mx;

}


// Faster C++ solution for the same problem (measured speedup: 2.595688349058781x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define pb push_back

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

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

#define for1(i, n) for(int i = 1; i <= n; ++i) 

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

const int mod = 1e9;

const int N = 1e5 + 10;

/*=======================================================================*/



ll n, W, w[N], v[N], f[N];

ll ans = 0;

int main() {

  cin >> n >> W;

  ms(f, inf);

  f[0] = 0;

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



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

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

        if (f[l - v[i]] + w[i] < f[l]) {

         //   debug1

            f[l] = f[l - v[i]] + w[i];

         }

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

     }

  }

  cout << ans << endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.376843887609679x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#define LL long long

using namespace std;

LL f[(int)1e5 + 10];

int main(){

    ios::sync_with_stdio(false);

    memset(f, 0x7f, sizeof(f));

    f[0] = 0;

    int n, W; cin>>n>>W;

    int maxl = 0, ans = 0;

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

        int wi, vi; cin>>wi>>vi;

        maxl += vi;

        for(int j = maxl; j >= vi; j--){

            f[j] = min(f[j], f[j - vi] + wi);

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

        }

    }

    cout<<ans;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7609464822968184x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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

using namespace std;

const int N = 1e5 + 10;

int dp[N];

int w[110];

int v[110];

int main()

{

	int n, sumw;

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

	int sum = 0;

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

	{

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

		sum += v[i];

	}

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

	dp[0] = 0;

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

	{

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

		{

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

		}

	}

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

	{

		if (dp[i] <= sumw)

		{

			printf("%d", i);

			return 0;

		}

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3472494814634983x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

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

#include <algorithm>

#include <vector>

using namespace std;

 

long long n,dp[100005],w,v,k,mxw,ans,pt,lpt;

bool d[100005];

int main(){

	scanf("%lld%lld",&n,&mxw);

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

		dp[i]=1e9+1;

	}

	d[0]=true; dp[0]=0;

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

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

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

			if (d[j] == true && j+v <= 100000 && dp[j]+w <= mxw){

				d[j+v]=true;

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

			}

		}

	}

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

		if	(d[i])

		ans=i;

	}

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

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.557124390654463x):
// Author : ZERO_IQ

// Practice is the only shortcut to improve



#pragma GCC optimize ("O3")

#pragma GCC optimize ("unroll-loops")



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl

#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl

#define endl '\n'



ll const N = 1e7 + 1;



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*#ifndef ONLINE_JUDGE

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

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

    #endif*/

    long long n, m;

    cin >> n >> m;

    vector<pair<long long, long long >> input;

    long long summ = 0;

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

        long long q, qq;

        cin >> q >> qq;

        input.push_back({q, qq});

        summ += qq;

    }

    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));

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

        dp[var][0] = 0;

    }

    ll maxx = 0;

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

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

            if (!j) {

                if (i == input[j].second)

                    dp[j][i] = input[j].first;

            } else if (input[j].second > i) {

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

            } else {

                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]

                               + input[j].first);

            }

        }

    }

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

        if (dp[n - 1][i] <= m) {

            maxx = i;

        }

    }

    cout << maxx << endl;

    return 0;

}