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

 

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

#define ll long long

#define ff first

#define ss second

 

const int maxn=105 ;

const int maxv=1005 ;

const int inf=1e9+10 ;

 

using namespace std ;

 

ll dp[maxn*maxv] ;

pair<ll,ll> v[maxn] ;

int ans ;

 

int main()

{

  lp(i,1,maxn*maxv) dp[i]=inf ;

  dp[0]=0;

 

  int n, w ;

 

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

  lp(i,0,n) scanf("%lld%lld", &v[i].ff, &v[i].ss) ;

 

  lp(i,0,n)

  {

    for(int j=ans+v[i].ss ; j >= v[i].ss ; j -- )

    {

      if(dp[ j-v[i].ss ] + v[i].ff <= w )

      {

        dp[j] = min(dp[j] , dp[ j-v[i].ss ] + v[i].ff ) , ans=max(ans,j) ;

      }

    }

  }

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

}

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

#include <limits.h>

#include <algorithm>  

#include <numeric>

 

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

 

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define endl '\n'

using ll = long long;

 

const int precision = 3;

const int modulo =  1000000007; // 10^9 + 7

const ll lmodulo =  1000000007; // 10^9 + 7

 

const double EPS = 1e-9;

const ll inf = 1e18;



void solve () {

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

	vector<int> weight(n), value(n);

	

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

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

	}



	int maxVal = accumulate(value.begin(), value.end(), 0);



	vector<vector<ll>> dp(weight.size() + 1, vector<ll>(maxVal + 1, inf));

	dp[0][0] = 0;



	for (auto i = 1; i < dp.size(); ++i) {

		const auto & w = weight[i - 1];

		const auto & cv = value[i - 1];

		for (int v = maxVal; v >= 0; --v) {

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

			if (v - cv >= 0) {

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

			}

		}

	}



	int ret = 0;

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

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

			ret = max(ret, i);

		}

	}

	cout << ret;

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  cout.precision(precision);

  cout.setf(ios_base::fixed);

  solve();

  return 0;

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

using namespace std;

const int inf = 2e9+7;



long long w[101], v[101];

long long f[110][100100];



int main()

{

    int N, V, i, j;



    cin>>N>>V;



    for(i=0;i<N;i++)

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

    fill(f[0],f[0]+100001,inf);

    f[0][0] = 0;

    for(i=0;i<N;i++)

    {

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

            if(j >= v[i])

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

            else

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

    }

    int res=0;

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

        if(f[N][i]<=V)

            res = i;



    cout<<res<<endl;



    return 0;

}

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

#include <limits.h>

#include <algorithm>  

#include <numeric>

 

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

 

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define endl '\n'

using ll = long long;

 

const int precision = 3;

const int modulo =  1000000007; // 10^9 + 7

const ll lmodulo =  1000000007; // 10^9 + 7

 

const double EPS = 1e-9;

const ll inf = 1e18;



void solve () {

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

	vector<int> weight(n), value(n);

	

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

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

	}



	int maxVal = accumulate(value.begin(), value.end(), 0);



	vector<vector<ll>> dp(weight.size() + 1, vector<ll>(maxVal + 1, inf));

	dp[0][0] = 0;



	for (auto i = 1; i < dp.size(); ++i) {

		const auto & w = weight[i - 1];

		const auto & cv = value[i - 1];

		for (int v = maxVal; v >= 0; --v) {

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

			if (v - cv >= 0) {

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

			}

		}

	}



	int ret = 0;

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

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

			ret = max(ret, i);

		}

	}

	cout << ret;

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  cout.precision(precision);

  cout.setf(ios_base::fixed);

  solve();

  return 0;

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

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

ll n,W;

int w[100+10],v[100+10];

int dp[100+10][100000+10];

int main()

{

    cin>>n>>W;

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

    fill(dp[0],dp[0]+100000+1,inf);

    dp[0][0]=0;

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

    {

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

        {

            if(j<v[i])  dp[i+1][j]=dp[i][j];

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

        }

    }

    int res=0;

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

    {

        if(dp[n][i]<=W) res=i;

    }

    cout<<res;

    return 0;

}

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

#include <limits.h>

#include <algorithm>  

#include <numeric>

 

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

 

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define endl '\n'

using ll = long long;

 

const int precision = 3;

const int modulo =  1000000007; // 10^9 + 7

const ll lmodulo =  1000000007; // 10^9 + 7

 

const double EPS = 1e-9;

const ll inf = 1e18;



void solve () {

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

	vector<int> weight(n), value(n);

	

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

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

	}



	int maxVal = accumulate(value.begin(), value.end(), 0);



	vector<vector<ll>> dp(2, vector<ll>(maxVal + 1, inf));

	dp[0][0] = 0;



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

		const auto & w = weight[i - 1];

		const auto & cv = value[i - 1];

		auto cur = i % 2;

		auto prev = (i - 1) % 2;

		for (int v = maxVal; v >= 0; --v) {

			dp[cur][v] = dp[prev][v];

			if (v - cv >= 0) {

				dp[cur][v] = min(dp[cur][v], dp[prev][v - cv] + w);

			}

		}

	}



	int ret = 0;

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

		if(dp[n % 2][i] <= W) {

			ret = max(ret, i);

		}

	}

	cout << ret;

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  cout.precision(precision);

  cout.setf(ios_base::fixed);

  solve();

  return 0;

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

 

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

#define ll long long

#define ff first

#define ss second

 

const int maxn=105 ;

const int maxv=1005 ;

const int inf=1e9+10 ;

 

using namespace std ;

 

ll dp[maxn*maxv] ;

pair<ll,ll> v[maxn] ;

int ans ;

 

int main()

{

  lp(i,1,maxn*maxv) dp[i]=inf ;

  dp[0]=0;

 

  int n, w ;

 

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

  lp(i,0,n) scanf("%lld%lld", &v[i].ff, &v[i].ss) ;

 

  lp(i,0,n)

  {

    for(int j=ans+v[i].ss ; j >= v[i].ss ; j -- )

    {

      if(dp[ j-v[i].ss ] + v[i].ff <= w )

      {

        dp[j] = min(dp[j] , dp[ j-v[i].ss ] + v[i].ff ) , ans=max(ans,j) ;

      }

    }

  }

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

}

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

#include <limits.h>

#include <algorithm>  

#include <numeric>

 

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

 

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define endl '\n'

using ll = long long;

 

const int precision = 3;

const int modulo =  1000000007; // 10^9 + 7

const ll lmodulo =  1000000007; // 10^9 + 7

 

const double EPS = 1e-9;

const ll inf = 1e18;



void solve () {

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

	vector<int> weight(n), value(n);

	

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

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

	}



	int maxVal = accumulate(value.begin(), value.end(), 0);



	vector<vector<ll>> dp(2, vector<ll>(maxVal + 1, inf));

	dp[0][0] = 0;



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

		const auto & w = weight[i - 1];

		const auto & cv = value[i - 1];

		auto cur = i % 2;

		auto prev = (i - 1) % 2;

		for (int v = maxVal; v >= 0; --v) {

			dp[cur][v] = dp[prev][v];

			if (v - cv >= 0) {

				dp[cur][v] = min(dp[cur][v], dp[prev][v - cv] + w);

			}

		}

	}



	int ret = 0;

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

		if(dp[n % 2][i] <= W) {

			ret = max(ret, i);

		}

	}

	cout << ret;

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  cout.precision(precision);

  cout.setf(ios_base::fixed);

  solve();

  return 0;

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

using namespace std;

const int inf = 2e9+7;



long long w[101], v[101];

long long f[110][100100];



int main()

{

    int N, V, i, j;



    cin>>N>>V;



    for(i=0;i<N;i++)

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

    fill(f[0],f[0]+100001,inf);

    f[0][0] = 0;

    for(i=0;i<N;i++)

    {

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

            if(j >= v[i])

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

            else

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

    }

    int res=0;

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

        if(f[N][i]<=V)

            res = i;



    cout<<res<<endl;



    return 0;

}

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

#include <limits.h>

#include <algorithm>  

#include <numeric>

 

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

 

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define endl '\n'

using ll = long long;

 

const int precision = 3;

const int modulo =  1000000007; // 10^9 + 7

const ll lmodulo =  1000000007; // 10^9 + 7

 

const double EPS = 1e-9;

const ll inf = 1e18;



void solve () {

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

	vector<int> weight(n), value(n);

	

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

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

	}



	int maxVal = accumulate(value.begin(), value.end(), 0);



	vector<vector<ll>> dp(2, vector<ll>(maxVal + 1, inf));

	dp[0][0] = 0;



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

		const auto & w = weight[i - 1];

		const auto & cv = value[i - 1];

		auto cur = i % 2;

		auto prev = (i - 1) % 2;

		for (int v = maxVal; v >= 0; --v) {

			dp[cur][v] = dp[prev][v];

			if (v - cv >= 0) {

				dp[cur][v] = min(dp[cur][v], dp[prev][v - cv] + w);

			}

		}

	}



	int ret = 0;

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

		if(dp[n % 2][i] <= W) {

			ret = max(ret, i);

		}

	}

	cout << ret;

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  cout.precision(precision);

  cout.setf(ios_base::fixed);

  solve();

  return 0;

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

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

ll n,W;

int w[100+10],v[100+10];

int dp[100+10][100000+10];

int main()

{

    cin>>n>>W;

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

    fill(dp[0],dp[0]+100000+1,inf);

    dp[0][0]=0;

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

    {

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

        {

            if(j<v[i])  dp[i+1][j]=dp[i][j];

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

        }

    }

    int res=0;

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

    {

        if(dp[n][i]<=W) res=i;

    }

    cout<<res;

    return 0;

}

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




#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };



















































const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, 63, sizeof(f));

	f[0] = 0;

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

		int w, v;

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

		for (int i = maxn - 3; i >= v; i--)if (f[i - v] + w <= C) {

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

		}

	}

	LL ans = 0;

	for (int i = 0; i <= maxn - 3; i++)if (f[i] <= C)ans = max(ans, (LL)i);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

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

using namespace std;

const int inf = 2e9+7;



long long w[101], v[101];

long long f[110][100100];



int main()

{

    int N, V, i, j;



    cin>>N>>V;



    for(i=0;i<N;i++)

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

    fill(f[0],f[0]+100001,inf);

    f[0][0] = 0;

    for(i=0;i<N;i++)

    {

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

            if(j >= v[i])

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

            else

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

    }

    int res=0;

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

        if(f[N][i]<=V)

            res = i;



    cout<<res<<endl;



    return 0;

}

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




#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<stack>

#include<queue>

#include<vector>

#include<set>

#include<string>

#include<cmath>

#include<map>

#include<bitset>

#include<utility>

//#include<unordered_map>

#ifdef LOCAL

#include"file.h"

#endif



using namespace std;



typedef long long LL;

typedef unsigned long long ULL;

const double eps = 1e-12;

const double Pi = 3.1415926535897932;

const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };

//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };



















































const int maxn = 1e5 + 5;

LL f[maxn];





int main() {

#ifdef LOCAL

	fileopen();

#endif

	int n, C;

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

	memset(f, 63, sizeof(f));

	f[0] = 0;

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

		int w, v;

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

		for (int i = maxn - 3; i >= v; i--)if (f[i - v] + w <= C) {

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

		}

	}

	LL ans = 0;

	for (int i = 0; i <= maxn - 3; i++)if (f[i] <= C)ans = max(ans, (LL)i);

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



#ifdef LOCAL

	fileclose();

#endif

	return 0;

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

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

ll n,W;

int w[100+10],v[100+10];

int dp[100+10][100000+10];

int main()

{

    cin>>n>>W;

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

    fill(dp[0],dp[0]+100000+1,inf);

    dp[0][0]=0;

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

    {

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

        {

            if(j<v[i])  dp[i+1][j]=dp[i][j];

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

        }

    }

    int res=0;

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

    {

        if(dp[n][i]<=W) res=i;

    }

    cout<<res;

    return 0;

}

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

* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.

*       Example:-   $ g++ -std=c++11 main.cpp -o main

*

*/



#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



using namespace std;

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	int n, w;

	cin >> n >> w;

	int mmax = n*1000+1;

	int bn = n + 1;

	int dd[bn][mmax];



	// initialize

	for (int nn = 0; nn < bn; nn++) {

	  for (int v = 0; v < mmax; v++) {

	    dd[nn][v] = -1;

	  }

	}



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

	  dd[nn][0] = 0;

	}

	for (int nn = 1; nn < bn; nn++) {

	  int www, nu;

	  cin >> www >> nu;

	  for (int v = 1; v < mmax; v++) {

	    // don't use item nn-1

	    int cur = -1;

	    if (dd[nn-1][v] != -1) {

	      cur = dd[nn-1][v];

	    }



	    // use item nn-1

	    if (nu <= v) {

	      int rem_v = v - nu;

	      if (dd[nn-1][rem_v] != -1) {

		int cand = dd[nn-1][rem_v] + www;

		if (cand <= w && (cur == -1 || cand < cur)) {

		  cur = cand;

		}

	      }

	    }



	    if (cur != -1) {

	      dd[nn][v] = cur;

	    }

	  }

	}

	bool done = false;

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

	  if (done) {

	    break;

	  }

	  for (int nn = 0; nn < bn; nn++) {

	    if (dd[nn][v] != -1) {

	      cout << v << '\n';

	      done = true;

	      break;

	    }

	  }

	}



	if (!done) {

	  cout << 0 << '\n';

	}

	return 0;

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

 

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

#define ll long long

#define ff first

#define ss second

 

const int maxn=105 ;

const int maxv=1005 ;

const int inf=1e9+10 ;

 

using namespace std ;

 

ll dp[maxn*maxv] ;

pair<ll,ll> v[maxn] ;

int ans ;

 

int main()

{

  lp(i,1,maxn*maxv) dp[i]=inf ;

  dp[0]=0;

 

  int n, w ;

 

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

  lp(i,0,n) scanf("%lld%lld", &v[i].ff, &v[i].ss) ;

 

  lp(i,0,n)

  {

    for(int j=ans+v[i].ss ; j >= v[i].ss ; j -- )

    {

      if(dp[ j-v[i].ss ] + v[i].ff <= w )

      {

        dp[j] = min(dp[j] , dp[ j-v[i].ss ] + v[i].ff ) , ans=max(ans,j) ;

      }

    }

  }

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

}

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

* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.

*       Example:-   $ g++ -std=c++11 main.cpp -o main

*

*/



#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



using namespace std;

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	int n, w;

	cin >> n >> w;

	int mmax = n*1000+1;

	int bn = n + 1;

	int dd[bn][mmax];



	// initialize

	for (int nn = 0; nn < bn; nn++) {

	  for (int v = 0; v < mmax; v++) {

	    dd[nn][v] = -1;

	  }

	}



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

	  dd[nn][0] = 0;

	}

	for (int nn = 1; nn < bn; nn++) {

	  int www, nu;

	  cin >> www >> nu;

	  for (int v = 1; v < mmax; v++) {

	    // don't use item nn-1

	    int cur = -1;

	    if (dd[nn-1][v] != -1) {

	      cur = dd[nn-1][v];

	    }



	    // use item nn-1

	    if (nu <= v) {

	      int rem_v = v - nu;

	      if (dd[nn-1][rem_v] != -1) {

		int cand = dd[nn-1][rem_v] + www;

		if (cand <= w && (cur == -1 || cand < cur)) {

		  cur = cand;

		}

	      }

	    }



	    if (cur != -1) {

	      dd[nn][v] = cur;

	    }

	  }

	}

	bool done = false;

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

	  if (done) {

	    break;

	  }

	  for (int nn = 0; nn < bn; nn++) {

	    if (dd[nn][v] != -1) {

	      cout << v << '\n';

	      done = true;

	      break;

	    }

	  }

	}



	if (!done) {

	  cout << 0 << '\n';

	}

	return 0;

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

using namespace std;

const int inf = 2e9+7;



long long w[101], v[101];

long long f[110][100100];



int main()

{

    int N, V, i, j;



    cin>>N>>V;



    for(i=0;i<N;i++)

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

    fill(f[0],f[0]+100001,inf);

    f[0][0] = 0;

    for(i=0;i<N;i++)

    {

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

            if(j >= v[i])

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

            else

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

    }

    int res=0;

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

        if(f[N][i]<=V)

            res = i;



    cout<<res<<endl;



    return 0;

}

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

* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.

*       Example:-   $ g++ -std=c++11 main.cpp -o main

*

*/



#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



using namespace std;

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	int n, w;

	cin >> n >> w;

	int mmax = n*1000+1;

	int bn = n + 1;

	int dd[bn][mmax];



	// initialize

	for (int nn = 0; nn < bn; nn++) {

	  for (int v = 0; v < mmax; v++) {

	    dd[nn][v] = -1;

	  }

	}



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

	  dd[nn][0] = 0;

	}

	for (int nn = 1; nn < bn; nn++) {

	  int www, nu;

	  cin >> www >> nu;

	  for (int v = 1; v < mmax; v++) {

	    // don't use item nn-1

	    int cur = -1;

	    if (dd[nn-1][v] != -1) {

	      cur = dd[nn-1][v];

	    }



	    // use item nn-1

	    if (nu <= v) {

	      int rem_v = v - nu;

	      if (dd[nn-1][rem_v] != -1) {

		int cand = dd[nn-1][rem_v] + www;

		if (cand <= w && (cur == -1 || cand < cur)) {

		  cur = cand;

		}

	      }

	    }



	    if (cur != -1) {

	      dd[nn][v] = cur;

	    }

	  }

	}

	bool done = false;

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

	  if (done) {

	    break;

	  }

	  for (int nn = 0; nn < bn; nn++) {

	    if (dd[nn][v] != -1) {

	      cout << v << '\n';

	      done = true;

	      break;

	    }

	  }

	}



	if (!done) {

	  cout << 0 << '\n';

	}

	return 0;

}