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



#define SORT(v) sort(v.begin(),v.end())

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

#define sii(n,m) scanf("%d %d",&n,&m)

#define sl(n) scanf("%lld",&n)

#define sll(n,m) scanf("%lld %lld",&n,&m)

#define ss(cad) scanf("%s",cad)

#define fst first

#define scn second

#define DBG(x) cerr << #x << " = " << (x) << endl; 

#define M 1000000007

#define N_MAX 100010



using namespace std;



typedef long long ll;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<ll> vl;

typedef pair<int,int> pi;

typedef pair<ll, ll> pll;

typedef vector<pi> vp;



ll dp[110][100100];

ll pesos[110];

ll costo[110];



int main(){

	int n, w;

	sii(n, w);



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

		sl(pesos[i]);

		sl(costo[i]);

	}



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

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

			ll ans = 0;

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

			if(j-pesos[i] >= 0)

				ans = max(ans, costo[i] + dp[i-1][j-pesos[i]]);

			dp[i][j] = ans;

		}

	}

	printf("%lld\n", dp[n][w]);

    return 0;

}

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

using namespace std;

#define ll long long

#define ld long double

#define uu unsigned

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

#define MOD 1000000007

#define pi pair<int,int>

#define pl pair<ll,ll>

#define mkp make_pair

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

#define ss second

#define ff first

#define mit map<ll,ll>::iterator

#define sit unordered_set<ll>::iterator

#define lit list<ll>::iterator

#define vi vector<int>

#define vl vector<ll>

#define pb push_back

#define pf push_front

#define printf __mingw_printf

#define printcas cout<<"Case "<<cas<<": "

#define _ continue;

#define endl '\n'

#define __ cout<<endl;continue;

#define vec4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))

int main()

{

     io;

    //string hudai(1000000,'a');

    int T=1;

   // cin>>T;

     for(int cas=1;cas<=T;cas++)

    {

        ll N,W;

        cin>>N>>W;

        vl w(N+1),v(N+1);

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

        {

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

        }

        vector<vl> dp(N+1,vl(W+1,0));

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

        {

            for(ll j=1;j<=W;j++)

            {

                if(w[i]<=j)

                {

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

                }

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

            }

        }

        cout<<dp[N][W];



    }

    return 0;

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

#include <stdio.h>

#include <cmath>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define f first

#define s second

#define mp make_pair

#define pb push_back

#define ll long long



using namespace std;



const int inf = 1e9 + 5;

const ll INF = 1e18 + 5;

const int maxn = 2e5 + 5;



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

ll dp[maxn];



int main(){

    cin.tie(0);

    cout.tie(0);

    ios_base::sync_with_stdio(NULL);

	cin >> n >> s;

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

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

		int w, cost;

		cin >> w >> cost;

		for (int j = s - w; j >= 0; j--) {

			if (dp[j] != -1)

				dp[j + w] = max(dp[j + w], dp[j] + cost);

		}

	}

	ll ans = -1;

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

		ans = max(ans, dp[i]);

	cout << ans;

	return 0;

}

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

#define ll long long

#define ld long double

#define str string

#define fori(i,N) for(long long i=1;i<=N;++i)

#define forj(j,m) for(long long j=1;j<=m;++j)

#define fork(k,n) for(long long k=1;k<=n;++k)

#define fors(i,ssz) for(long long i=0;i<s.size();++i)

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

using namespace std;

ll N,W,w[101],v[101],dp[101][100001],s,i;

int main(){

	cin>>N>>W;

	fori(i,N)

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

	

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

    dp[0][i]=0;

    

	for(s=1;s<=N;++s){                   

    	for(i=0;i<=W;++i){

    		

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

			 

        	if(i >= w[s] && (dp[s - 1][ i - w[s] ] + v[s] > dp[s][i]))

            dp[s][i] = dp[s-1][i-w[s]]+v[s];

    	}

	}

	cout<<dp[N][W];

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

using namespace std;

const int maxn = 1e5 + 5;

typedef long long ll;

int main(){

	ll dp[maxn];

	ll n,W;

	ll w[105],v[105];

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

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

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

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

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

		for(ll j = W;j >= 1;j--){

			if(j >= w[i]) dp[j] = max(dp[j],dp[j-w[i]] + v[i]);

		}

	}

	printf("%lld\n",dp[W]);

	return 0;

}

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

#define ll long long

#define ld long double

#define str string

#define fori(i,N) for(long long i=1;i<=N;++i)

#define forj(j,m) for(long long j=1;j<=m;++j)

#define fork(k,n) for(long long k=1;k<=n;++k)

#define fors(i,ssz) for(long long i=0;i<s.size();++i)

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

using namespace std;

ll N,W,w[101],v[101],dp[101][100001],s,i;

int main(){

	cin>>N>>W;

	fori(i,N)

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

	

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

    dp[0][i]=0;

    

	for(s=1;s<=N;++s){                   

    	for(i=0;i<=W;++i){

    		

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

			 

        	if(i >= w[s] && (dp[s - 1][ i - w[s] ] + v[s] > dp[s][i]))

            dp[s][i] = dp[s-1][i-w[s]]+v[s];

    	}

	}

	cout<<dp[N][W];

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



#define SORT(v) sort(v.begin(),v.end())

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

#define sii(n,m) scanf("%d %d",&n,&m)

#define sl(n) scanf("%lld",&n)

#define sll(n,m) scanf("%lld %lld",&n,&m)

#define ss(cad) scanf("%s",cad)

#define fst first

#define scn second

#define DBG(x) cerr << #x << " = " << (x) << endl; 

#define M 1000000007

#define N_MAX 100010



using namespace std;



typedef long long ll;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<ll> vl;

typedef pair<int,int> pi;

typedef pair<ll, ll> pll;

typedef vector<pi> vp;



ll dp[110][100100];

ll pesos[110];

ll costo[110];



int main(){

	int n, w;

	sii(n, w);



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

		sl(pesos[i]);

		sl(costo[i]);

	}



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

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

			ll ans = 0;

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

			if(j-pesos[i] >= 0)

				ans = max(ans, costo[i] + dp[i-1][j-pesos[i]]);

			dp[i][j] = ans;

		}

	}

	printf("%lld\n", dp[n][w]);

    return 0;

}

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

#define ll long long

#define ld long double

#define str string

#define fori(i,N) for(long long i=1;i<=N;++i)

#define forj(j,m) for(long long j=1;j<=m;++j)

#define fork(k,n) for(long long k=1;k<=n;++k)

#define fors(i,ssz) for(long long i=0;i<s.size();++i)

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

using namespace std;

ll N,W,w[101],v[101],dp[101][100001],s,i;

int main(){

	cin>>N>>W;

	fori(i,N)

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

	

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

    dp[0][i]=0;

    

	for(s=1;s<=N;++s){                   

    	for(i=0;i<=W;++i){

    		

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

			 

        	if(i >= w[s] && (dp[s - 1][ i - w[s] ] + v[s] > dp[s][i]))

            dp[s][i] = dp[s-1][i-w[s]]+v[s];

    	}

	}

	cout<<dp[N][W];

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

#include <stdio.h>

#include <cmath>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define f first

#define s second

#define mp make_pair

#define pb push_back

#define ll long long



using namespace std;



const int inf = 1e9 + 5;

const ll INF = 1e18 + 5;

const int maxn = 2e5 + 5;



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

ll dp[maxn];



int main(){

    cin.tie(0);

    cout.tie(0);

    ios_base::sync_with_stdio(NULL);

	cin >> n >> s;

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

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

		int w, cost;

		cin >> w >> cost;

		for (int j = s - w; j >= 0; j--) {

			if (dp[j] != -1)

				dp[j + w] = max(dp[j + w], dp[j] + cost);

		}

	}

	ll ans = -1;

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

		ans = max(ans, dp[i]);

	cout << ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.5766680112594313x):
#pragma GCC optimize(2)

#pragma warning(disable:4996)

#include <iostream>

#include <cmath>

#include <cstdio>

#include <algorithm>

#include<cstring>

#include <stack>

#include<vector>

#include<queue>

#include<set>

#include<map>

#include <string>

#include<iomanip>

#include<assert.h>

#define itn int

#define endl "\n"

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

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

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

const int maxn = 100 + 6;

const int maxa = 1000 * 1000 * 1000 + 7;

typedef long long ll;

const int mod = 1000 * 1000 * 1000 + 7;

using namespace std;

int t, n, m, T;

int main()

{

#ifdef _DEBUG

	freopen("D:\\input.txt", "r", stdin);

	//	freopen("E:\\output.txt", "w", stdout);

#endif

	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);

	int n, weight;

	cin >> n;

	cin >> weight;

	vector<ll>w(n);

	vector <ll > v(n);

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

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

	}

	vector<ll>dp(weight+1);

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

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

			if (j - w[i] >= 0)

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

		}



	cout << dp[weight]<<endl;

	return 0;

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

using namespace std;

const int maxn = 1e5 + 5;

typedef long long ll;

int main(){

	ll dp[maxn];

	ll n,W;

	ll w[105],v[105];

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

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

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

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

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

		for(ll j = W;j >= 1;j--){

			if(j >= w[i]) dp[j] = max(dp[j],dp[j-w[i]] + v[i]);

		}

	}

	printf("%lld\n",dp[W]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.772120358717945x):
#pragma GCC optimize(2)

#pragma warning(disable:4996)

#include <iostream>

#include <cmath>

#include <cstdio>

#include <algorithm>

#include<cstring>

#include <stack>

#include<vector>

#include<queue>

#include<set>

#include<map>

#include <string>

#include<iomanip>

#include<assert.h>

#define itn int

#define endl "\n"

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

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

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

const int maxn = 100 + 6;

const int maxa = 1000 * 1000 * 1000 + 7;

typedef long long ll;

const int mod = 1000 * 1000 * 1000 + 7;

using namespace std;

int t, n, m, T;

int main()

{

#ifdef _DEBUG

	freopen("D:\\input.txt", "r", stdin);

	//	freopen("E:\\output.txt", "w", stdout);

#endif

	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);

	int n, weight;

	cin >> n;

	cin >> weight;

	vector<ll>w(n);

	vector <ll > v(n);

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

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

	}

	vector<ll>dp(weight+1);

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

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

			if (j - w[i] >= 0)

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

		}



	cout << dp[weight]<<endl;

	return 0;

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



#define SORT(v) sort(v.begin(),v.end())

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

#define sii(n,m) scanf("%d %d",&n,&m)

#define sl(n) scanf("%lld",&n)

#define sll(n,m) scanf("%lld %lld",&n,&m)

#define ss(cad) scanf("%s",cad)

#define fst first

#define scn second

#define DBG(x) cerr << #x << " = " << (x) << endl; 

#define M 1000000007

#define N_MAX 100010



using namespace std;



typedef long long ll;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<ll> vl;

typedef pair<int,int> pi;

typedef pair<ll, ll> pll;

typedef vector<pi> vp;



ll dp[110][100100];

ll pesos[110];

ll costo[110];



int main(){

	int n, w;

	sii(n, w);



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

		sl(pesos[i]);

		sl(costo[i]);

	}



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

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

			ll ans = 0;

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

			if(j-pesos[i] >= 0)

				ans = max(ans, costo[i] + dp[i-1][j-pesos[i]]);

			dp[i][j] = ans;

		}

	}

	printf("%lld\n", dp[n][w]);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.33502849044703x):
#pragma GCC optimize(2)

#pragma warning(disable:4996)

#include <iostream>

#include <cmath>

#include <cstdio>

#include <algorithm>

#include<cstring>

#include <stack>

#include<vector>

#include<queue>

#include<set>

#include<map>

#include <string>

#include<iomanip>

#include<assert.h>

#define itn int

#define endl "\n"

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

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

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

const int maxn = 100 + 6;

const int maxa = 1000 * 1000 * 1000 + 7;

typedef long long ll;

const int mod = 1000 * 1000 * 1000 + 7;

using namespace std;

int t, n, m, T;

int main()

{

#ifdef _DEBUG

	freopen("D:\\input.txt", "r", stdin);

	//	freopen("E:\\output.txt", "w", stdout);

#endif

	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);

	int n, weight;

	cin >> n;

	cin >> weight;

	vector<ll>w(n);

	vector <ll > v(n);

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

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

	}

	vector<ll>dp(weight+1);

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

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

			if (j - w[i] >= 0)

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

		}



	cout << dp[weight]<<endl;

	return 0;

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

#include <stdio.h>

#include <cmath>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define f first

#define s second

#define mp make_pair

#define pb push_back

#define ll long long



using namespace std;



const int inf = 1e9 + 5;

const ll INF = 1e18 + 5;

const int maxn = 2e5 + 5;



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

ll dp[maxn];



int main(){

    cin.tie(0);

    cout.tie(0);

    ios_base::sync_with_stdio(NULL);

	cin >> n >> s;

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

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

		int w, cost;

		cin >> w >> cost;

		for (int j = s - w; j >= 0; j--) {

			if (dp[j] != -1)

				dp[j + w] = max(dp[j + w], dp[j] + cost);

		}

	}

	ll ans = -1;

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

		ans = max(ans, dp[i]);

	cout << ans;

	return 0;

}

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

using namespace std;

int main()

{

    unsigned long long int n,weight,i,j;

    static unsigned long long int w[103],v[103],t[100002][103];

    cin>>n>>weight;

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

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

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

        t[i][0]=0;

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

        t[0][i]=0;

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

    {

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

        {

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

            if(i>=w[j-1])

            {

                t[i][j]=max(t[i][j-1],t[i-w[j-1]][j-1]+v[j-1]);

            }

        }

    }

    cout<<t[weight][n]<<endl;

    return 0;

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

using namespace std;

const int maxn = 1e5 + 5;

typedef long long ll;

int main(){

	ll dp[maxn];

	ll n,W;

	ll w[105],v[105];

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

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

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

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

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

		for(ll j = W;j >= 1;j--){

			if(j >= w[i]) dp[j] = max(dp[j],dp[j-w[i]] + v[i]);

		}

	}

	printf("%lld\n",dp[W]);

	return 0;

}

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

using namespace std;

int main()

{

    unsigned long long int n,weight,i,j;

    static unsigned long long int w[103],v[103],t[100002][103];

    cin>>n>>weight;

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

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

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

        t[i][0]=0;

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

        t[0][i]=0;

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

    {

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

        {

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

            if(i>=w[j-1])

            {

                t[i][j]=max(t[i][j-1],t[i-w[j-1]][j-1]+v[j-1]);

            }

        }

    }

    cout<<t[weight][n]<<endl;

    return 0;

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



#define SORT(v) sort(v.begin(),v.end())

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

#define sii(n,m) scanf("%d %d",&n,&m)

#define sl(n) scanf("%lld",&n)

#define sll(n,m) scanf("%lld %lld",&n,&m)

#define ss(cad) scanf("%s",cad)

#define fst first

#define scn second

#define DBG(x) cerr << #x << " = " << (x) << endl; 

#define M 1000000007

#define N_MAX 100010



using namespace std;



typedef long long ll;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<ll> vl;

typedef pair<int,int> pi;

typedef pair<ll, ll> pll;

typedef vector<pi> vp;



ll dp[110][100100];

ll pesos[110];

ll costo[110];



int main(){

	int n, w;

	sii(n, w);



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

		sl(pesos[i]);

		sl(costo[i]);

	}



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

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

			ll ans = 0;

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

			if(j-pesos[i] >= 0)

				ans = max(ans, costo[i] + dp[i-1][j-pesos[i]]);

			dp[i][j] = ans;

		}

	}

	printf("%lld\n", dp[n][w]);

    return 0;

}

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

using namespace std;

int main()

{

    unsigned long long int n,weight,i,j;

    static unsigned long long int w[103],v[103],t[100002][103];

    cin>>n>>weight;

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

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

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

        t[i][0]=0;

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

        t[0][i]=0;

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

    {

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

        {

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

            if(i>=w[j-1])

            {

                t[i][j]=max(t[i][j-1],t[i-w[j-1]][j-1]+v[j-1]);

            }

        }

    }

    cout<<t[weight][n]<<endl;

    return 0;

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

#include <stdio.h>

#include <cmath>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define f first

#define s second

#define mp make_pair

#define pb push_back

#define ll long long



using namespace std;



const int inf = 1e9 + 5;

const ll INF = 1e18 + 5;

const int maxn = 2e5 + 5;



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

ll dp[maxn];



int main(){

    cin.tie(0);

    cout.tie(0);

    ios_base::sync_with_stdio(NULL);

	cin >> n >> s;

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

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

		int w, cost;

		cin >> w >> cost;

		for (int j = s - w; j >= 0; j--) {

			if (dp[j] != -1)

				dp[j + w] = max(dp[j + w], dp[j] + cost);

		}

	}

	ll ans = -1;

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

		ans = max(ans, dp[i]);

	cout << ans;

	return 0;

}

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

using namespace std;

#define ll long long

#define N 100005

int n,m;

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

int main()

{

    cin>>n>>m;

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

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

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

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

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

        //cout<<j<<i<<" "<<dp[j]<<endl;

        }

    }

    cout<<dp[m];

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

using namespace std;

const int maxn = 1e5 + 5;

typedef long long ll;

int main(){

	ll dp[maxn];

	ll n,W;

	ll w[105],v[105];

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

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

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

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

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

		for(ll j = W;j >= 1;j--){

			if(j >= w[i]) dp[j] = max(dp[j],dp[j-w[i]] + v[i]);

		}

	}

	printf("%lld\n",dp[W]);

	return 0;

}

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

using namespace std;

#define ll long long

#define N 100005

int n,m;

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

int main()

{

    cin>>n>>m;

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

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

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

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

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

        //cout<<j<<i<<" "<<dp[j]<<endl;

        }

    }

    cout<<dp[m];

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



#define SORT(v) sort(v.begin(),v.end())

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

#define sii(n,m) scanf("%d %d",&n,&m)

#define sl(n) scanf("%lld",&n)

#define sll(n,m) scanf("%lld %lld",&n,&m)

#define ss(cad) scanf("%s",cad)

#define fst first

#define scn second

#define DBG(x) cerr << #x << " = " << (x) << endl; 

#define M 1000000007

#define N_MAX 100010



using namespace std;



typedef long long ll;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<ll> vl;

typedef pair<int,int> pi;

typedef pair<ll, ll> pll;

typedef vector<pi> vp;



ll dp[110][100100];

ll pesos[110];

ll costo[110];



int main(){

	int n, w;

	sii(n, w);



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

		sl(pesos[i]);

		sl(costo[i]);

	}



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

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

			ll ans = 0;

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

			if(j-pesos[i] >= 0)

				ans = max(ans, costo[i] + dp[i-1][j-pesos[i]]);

			dp[i][j] = ans;

		}

	}

	printf("%lld\n", dp[n][w]);

    return 0;

}

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

using namespace std;

#define ll long long

#define N 100005

int n,m;

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

int main()

{

    cin>>n>>m;

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

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

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

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

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

        //cout<<j<<i<<" "<<dp[j]<<endl;

        }

    }

    cout<<dp[m];

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

#include <stdio.h>

#include <cmath>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define f first

#define s second

#define mp make_pair

#define pb push_back

#define ll long long



using namespace std;



const int inf = 1e9 + 5;

const ll INF = 1e18 + 5;

const int maxn = 2e5 + 5;



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

ll dp[maxn];



int main(){

    cin.tie(0);

    cout.tie(0);

    ios_base::sync_with_stdio(NULL);

	cin >> n >> s;

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

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

		int w, cost;

		cin >> w >> cost;

		for (int j = s - w; j >= 0; j--) {

			if (dp[j] != -1)

				dp[j + w] = max(dp[j + w], dp[j] + cost);

		}

	}

	ll ans = -1;

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

		ans = max(ans, dp[i]);

	cout << ans;

	return 0;

}

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

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

const long long maxn=100000+50;

long long n,m,w[maxn],v[maxn],dp[maxn];

int main()

{

	cin>>n>>m;

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

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

	{

		for(long long j=m;j>=w[i];j--)

		{

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

		}

	}

	cout<<dp[m]<<endl;

	return 0;

}

//Phoenix-ZH
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

typedef long long ll;

int main(){

	ll dp[maxn];

	ll n,W;

	ll w[105],v[105];

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

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

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

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

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

		for(ll j = W;j >= 1;j--){

			if(j >= w[i]) dp[j] = max(dp[j],dp[j-w[i]] + v[i]);

		}

	}

	printf("%lld\n",dp[W]);

	return 0;

}

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

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

const long long maxn=100000+50;

long long n,m,w[maxn],v[maxn],dp[maxn];

int main()

{

	cin>>n>>m;

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

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

	{

		for(long long j=m;j>=w[i];j--)

		{

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

		}

	}

	cout<<dp[m]<<endl;

	return 0;

}

//Phoenix-ZH