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

#define ll long long

#define ull unsigned ll

#define ld long double

#define pll pair<ll, ll>

#define pii pair<int, int>

#define f first

#define se second

#define pb push_back

#define ft fflush(stdout)

 

 

using namespace std;

 

 

const int N = 1e5 + 123;

const int PLS = 3e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e16;





ll n, a[N], b[N], w, dp[110][N];





int main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> w;

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

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

    dp[0][0] = 0;

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

        dp[0][i] = inf;

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

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

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

            if (j >= b[i])

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

        }

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

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

            return cout << i, 0;

}

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

#include <iomanip>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <string>

#include <stdio.h>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define ll long long

#define pb push_back

#define mp make_pair

#define f first

#define s second



using namespace std;



const int inf = 1e9 + 7;

const long long INF = 1e18 + 7;

const int maxn = 2e5 + 7;



ll n, s, w[maxn], a[maxn];

ll dp[maxn], mx;



int main(){

	ios_base::sync_with_stdio(NULL);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> s;

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

		dp[i] = inf;

	dp[0] = 0;

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

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

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

			if (dp[j] != inf && dp[j] + w[i] <= s){

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

			}

		}

	}

	for (ll i = 0; i < maxn; i++)

		if (dp[i] != inf)

			mx = max(mx, i);

	cout << mx;

	return 0;

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

 

#define ll long long

#define X first

#define Y second

#define MP make_pair

#define ld long double

 

using namespace std;

 

const int N = 5e5 + 123;

const ll mod = 1e9 + 7;



ll dp[N], res, was[N];

int n, maxw;



int main (){

	ios::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);



	cin >> n >> maxw;



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

		dp[i] = N * 1LL * N;



	was[0] = 1;

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

		ll x, y;

		cin >> x >> y;

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

			if(!was[j - y])

				continue;

			was[j] = 1;

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

		}

	}



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

		if(dp[i] <= maxw){

			res = i;

		}

	}



	cout << res;

}

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

 

#define int long long

//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

 

 

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

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

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

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

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define s second

#define f first

 

 

using namespace std;

 

 

typedef pair < long long, long long > pll;    

typedef pair < int, int > pii;

typedef unsigned long long ull;         

typedef vector < pii > vpii;

typedef vector < int > vi;

typedef long double ldb; 

typedef long long ll;  

typedef double db;                         

 

 

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;

const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);

const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;

const db eps = 1e-12, pi = 3.14159265359;

const ll INF = 1e18;





int n, m, w[maxn], c[maxn], dp[N], M = N - 12;



main () {

	cin >> n >> m;

	forn (i, 1, n)

		cin >> w[i] >> c[i];





	dp[0] = 0;

	forn (i, 1, M)

		dp[i] = INF;





	forn (i, 1, n)

		forev (j, M, c[i])

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



	forev (i, M, 0)

		if (dp[i] <= m)  {

			cout << i << endl;

			return 0;

		}

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

#define ll long long

#define ull unsigned ll

#define ld long double

#define pll pair<ll, ll>

#define pii pair<int, int>

#define f first

#define se second

#define pb push_back

#define ft fflush(stdout)

 

 

using namespace std;

 

 

const int N = 1e5 + 123;

const int PLS = 3e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e16;





ll n, a[N], b[N], w, dp[110][N];





int main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> w;

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

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

    dp[0][0] = 0;

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

        dp[0][i] = inf;

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

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

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

            if (j >= b[i])

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

        }

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

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

            return cout << i, 0;

}

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

 

#define int long long

//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

 

 

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

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

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

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

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define s second

#define f first

 

 

using namespace std;

 

 

typedef pair < long long, long long > pll;    

typedef pair < int, int > pii;

typedef unsigned long long ull;         

typedef vector < pii > vpii;

typedef vector < int > vi;

typedef long double ldb; 

typedef long long ll;  

typedef double db;                         

 

 

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;

const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);

const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;

const db eps = 1e-12, pi = 3.14159265359;

const ll INF = 1e18;





int n, m, w[maxn], c[maxn], dp[N], M = N - 12;



main () {

	cin >> n >> m;

	forn (i, 1, n)

		cin >> w[i] >> c[i];





	dp[0] = 0;

	forn (i, 1, M)

		dp[i] = INF;





	forn (i, 1, n)

		forev (j, M, c[i])

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



	forev (i, M, 0)

		if (dp[i] <= m)  {

			cout << i << endl;

			return 0;

		}

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

#include <iomanip>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <string>

#include <stdio.h>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define ll long long

#define pb push_back

#define mp make_pair

#define f first

#define s second



using namespace std;



const int inf = 1e9 + 7;

const long long INF = 1e18 + 7;

const int maxn = 2e5 + 7;



ll n, s, w[maxn], a[maxn];

ll dp[maxn], mx;



int main(){

	ios_base::sync_with_stdio(NULL);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> s;

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

		dp[i] = inf;

	dp[0] = 0;

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

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

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

			if (dp[j] != inf && dp[j] + w[i] <= s){

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

			}

		}

	}

	for (ll i = 0; i < maxn; i++)

		if (dp[i] != inf)

			mx = max(mx, i);

	cout << mx;

	return 0;

} 

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

 

#define int long long

//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

 

 

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

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

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

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

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define s second

#define f first

 

 

using namespace std;

 

 

typedef pair < long long, long long > pll;    

typedef pair < int, int > pii;

typedef unsigned long long ull;         

typedef vector < pii > vpii;

typedef vector < int > vi;

typedef long double ldb; 

typedef long long ll;  

typedef double db;                         

 

 

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;

const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);

const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;

const db eps = 1e-12, pi = 3.14159265359;

const ll INF = 1e18;





int n, m, w[maxn], c[maxn], dp[N], M = N - 12;



main () {

	cin >> n >> m;

	forn (i, 1, n)

		cin >> w[i] >> c[i];





	dp[0] = 0;

	forn (i, 1, M)

		dp[i] = INF;





	forn (i, 1, n)

		forev (j, M, c[i])

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



	forev (i, M, 0)

		if (dp[i] <= m)  {

			cout << i << endl;

			return 0;

		}

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

 

#define ll long long

#define X first

#define Y second

#define MP make_pair

#define ld long double

 

using namespace std;

 

const int N = 5e5 + 123;

const ll mod = 1e9 + 7;



ll dp[N], res, was[N];

int n, maxw;



int main (){

	ios::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);



	cin >> n >> maxw;



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

		dp[i] = N * 1LL * N;



	was[0] = 1;

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

		ll x, y;

		cin >> x >> y;

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

			if(!was[j - y])

				continue;

			was[j] = 1;

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

		}

	}



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

		if(dp[i] <= maxw){

			res = i;

		}

	}



	cout << res;

}

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

#define ll long long

using namespace std;

const ll inf=0x7F7F7F7F7F7F7F7F;

ll n,wz,w[110],v[110],dp[100010];

inline int read(){

     int x=0,f=1;char ch=getchar();

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

     while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}

     return x*f;

 }

int main ( )

{

	n=read();wz=read();

	for(int i=1;i<=n;i++) w[i]=read(),v[i]=read();

	memset(dp,inf,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]<=wz)

      {

      	cout<<i;

      	break;

	  }

	return 0;

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

#define ll long long

#define ull unsigned ll

#define ld long double

#define pll pair<ll, ll>

#define pii pair<int, int>

#define f first

#define se second

#define pb push_back

#define ft fflush(stdout)

 

 

using namespace std;

 

 

const int N = 1e5 + 123;

const int PLS = 3e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e16;





ll n, a[N], b[N], w, dp[110][N];





int main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> w;

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

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

    dp[0][0] = 0;

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

        dp[0][i] = inf;

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

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

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

            if (j >= b[i])

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

        }

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

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

            return cout << i, 0;

}

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

#define ll long long

using namespace std;

const ll inf=0x7F7F7F7F7F7F7F7F;

ll n,wz,w[110],v[110],dp[100010];

inline int read(){

     int x=0,f=1;char ch=getchar();

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

     while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}

     return x*f;

 }

int main ( )

{

	n=read();wz=read();

	for(int i=1;i<=n;i++) w[i]=read(),v[i]=read();

	memset(dp,inf,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]<=wz)

      {

      	cout<<i;

      	break;

	  }

	return 0;

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

#include <iomanip>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <string>

#include <stdio.h>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define ll long long

#define pb push_back

#define mp make_pair

#define f first

#define s second



using namespace std;



const int inf = 1e9 + 7;

const long long INF = 1e18 + 7;

const int maxn = 2e5 + 7;



ll n, s, w[maxn], a[maxn];

ll dp[maxn], mx;



int main(){

	ios_base::sync_with_stdio(NULL);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> s;

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

		dp[i] = inf;

	dp[0] = 0;

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

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

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

			if (dp[j] != inf && dp[j] + w[i] <= s){

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

			}

		}

	}

	for (ll i = 0; i < maxn; i++)

		if (dp[i] != inf)

			mx = max(mx, i);

	cout << mx;

	return 0;

} 

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

#define ll long long

using namespace std;

const ll inf=0x7F7F7F7F7F7F7F7F;

ll n,wz,w[110],v[110],dp[100010];

inline int read(){

     int x=0,f=1;char ch=getchar();

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

     while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}

     return x*f;

 }

int main ( )

{

	n=read();wz=read();

	for(int i=1;i<=n;i++) w[i]=read(),v[i]=read();

	memset(dp,inf,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]<=wz)

      {

      	cout<<i;

      	break;

	  }

	return 0;

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

 

#define ll long long

#define X first

#define Y second

#define MP make_pair

#define ld long double

 

using namespace std;

 

const int N = 5e5 + 123;

const ll mod = 1e9 + 7;



ll dp[N], res, was[N];

int n, maxw;



int main (){

	ios::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);



	cin >> n >> maxw;



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

		dp[i] = N * 1LL * N;



	was[0] = 1;

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

		ll x, y;

		cin >> x >> y;

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

			if(!was[j - y])

				continue;

			was[j] = 1;

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

		}

	}



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

		if(dp[i] <= maxw){

			res = i;

		}

	}



	cout << res;

}

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

#include <stdio.h>



#define f first

#define s second

#define pb push_back

#define ppb pop_back

#define mp make_pair

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



using namespace std;



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

                                           	

const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;

const ll INF = 1e18;



ll w[N], v[N], d[N];

bool dp[N];



int main() {

	cin.tie(0);  	

	cout.tie(0);

	ios_base::sync_with_stdio(0);

	int n, m;

	cin >> n >> m;

	int sum = 0;

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

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

		sum += v[i];

	}

	dp[0] = 1;

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

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

			if (dp[j]) {

				if (!dp[j + v[i]]) {        	

					d[j + v[i]] = d[j] + w[i];

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

				} else {

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

				}

			}

		}

	}

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

		if (dp[i]) {

			if (d[i] <= m) {

				cout << i;

				return 0;

			}

		}

	}

	return 0;

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

#define ll long long

#define ull unsigned ll

#define ld long double

#define pll pair<ll, ll>

#define pii pair<int, int>

#define f first

#define se second

#define pb push_back

#define ft fflush(stdout)

 

 

using namespace std;

 

 

const int N = 1e5 + 123;

const int PLS = 3e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e16;





ll n, a[N], b[N], w, dp[110][N];





int main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> w;

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

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

    dp[0][0] = 0;

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

        dp[0][i] = inf;

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

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

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

            if (j >= b[i])

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

        }

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

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

            return cout << i, 0;

}

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

#include <stdio.h>



#define f first

#define s second

#define pb push_back

#define ppb pop_back

#define mp make_pair

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



using namespace std;



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

                                           	

const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;

const ll INF = 1e18;



ll w[N], v[N], d[N];

bool dp[N];



int main() {

	cin.tie(0);  	

	cout.tie(0);

	ios_base::sync_with_stdio(0);

	int n, m;

	cin >> n >> m;

	int sum = 0;

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

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

		sum += v[i];

	}

	dp[0] = 1;

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

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

			if (dp[j]) {

				if (!dp[j + v[i]]) {        	

					d[j + v[i]] = d[j] + w[i];

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

				} else {

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

				}

			}

		}

	}

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

		if (dp[i]) {

			if (d[i] <= m) {

				cout << i;

				return 0;

			}

		}

	}

	return 0;

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

#include <iomanip>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <string>

#include <stdio.h>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define ll long long

#define pb push_back

#define mp make_pair

#define f first

#define s second



using namespace std;



const int inf = 1e9 + 7;

const long long INF = 1e18 + 7;

const int maxn = 2e5 + 7;



ll n, s, w[maxn], a[maxn];

ll dp[maxn], mx;



int main(){

	ios_base::sync_with_stdio(NULL);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> s;

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

		dp[i] = inf;

	dp[0] = 0;

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

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

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

			if (dp[j] != inf && dp[j] + w[i] <= s){

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

			}

		}

	}

	for (ll i = 0; i < maxn; i++)

		if (dp[i] != inf)

			mx = max(mx, i);

	cout << mx;

	return 0;

} 

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

#include <stdio.h>



#define f first

#define s second

#define pb push_back

#define ppb pop_back

#define mp make_pair

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



using namespace std;



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

                                           	

const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;

const ll INF = 1e18;



ll w[N], v[N], d[N];

bool dp[N];



int main() {

	cin.tie(0);  	

	cout.tie(0);

	ios_base::sync_with_stdio(0);

	int n, m;

	cin >> n >> m;

	int sum = 0;

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

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

		sum += v[i];

	}

	dp[0] = 1;

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

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

			if (dp[j]) {

				if (!dp[j + v[i]]) {        	

					d[j + v[i]] = d[j] + w[i];

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

				} else {

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

				}

			}

		}

	}

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

		if (dp[i]) {

			if (d[i] <= m) {

				cout << i;

				return 0;

			}

		}

	}

	return 0;

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

 

#define int long long

//#pragma GCC optimize("Ofast")

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

 

 

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

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

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

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

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define s second

#define f first

 

 

using namespace std;

 

 

typedef pair < long long, long long > pll;    

typedef pair < int, int > pii;

typedef unsigned long long ull;         

typedef vector < pii > vpii;

typedef vector < int > vi;

typedef long double ldb; 

typedef long long ll;  

typedef double db;                         

 

 

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;

const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);

const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;

const db eps = 1e-12, pi = 3.14159265359;

const ll INF = 1e18;





int n, m, w[maxn], c[maxn], dp[N], M = N - 12;



main () {

	cin >> n >> m;

	forn (i, 1, n)

		cin >> w[i] >> c[i];





	dp[0] = 0;

	forn (i, 1, M)

		dp[i] = INF;





	forn (i, 1, n)

		forev (j, M, c[i])

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



	forev (i, M, 0)

		if (dp[i] <= m)  {

			cout << i << endl;

			return 0;

		}

}                       

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

#include <stdio.h>



#define f first

#define s second

#define pb push_back

#define ppb pop_back

#define mp make_pair

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



using namespace std;



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

                                           	

const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;

const ll INF = 1e18;



ll w[N], v[N], d[N];

bool dp[N];



int main() {

	cin.tie(0);  	

	cout.tie(0);

	ios_base::sync_with_stdio(0);

	int n, m;

	cin >> n >> m;

	int sum = 0;

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

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

		sum += v[i];

	}

	dp[0] = 1;

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

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

			if (dp[j]) {

				if (!dp[j + v[i]]) {        	

					d[j + v[i]] = d[j] + w[i];

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

				} else {

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

				}

			}

		}

	}

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

		if (dp[i]) {

			if (d[i] <= m) {

				cout << i;

				return 0;

			}

		}

	}

	return 0;

}