stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	long long N,Y;

	cin>>N>>Y;

	if(Y%1000!=0){

		cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;

		return 0;

	}else{

		Y=Y/1000;

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

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

				if((5*j+i)>Y){

					continue;

				}

				if( ((Y - (i + j*5)) % 10 == 0 ) ) {

                    if(i + j + ((Y - (i + j*5))/10) == N) {

                        printf("%d %d %d\n",((Y - (i + j*5))/10),j,i);

                        return 0;

                    }

                }

			}

		}

	}

	cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;

	return 0;

}

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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define endl "\n"

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

V<LL>v,u,w;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    cin>>n>>m;

    k=m-(1000*n);

    p=10000-(1000);

    q=5000-(1000);

    l=k/p;

    s=0;

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

    {

        if((k-(p*i))%q==0 && i<=n && ((k-(p*i))/q)<=n && (n-(i+((k-(p*i))/q)))>=0)

        {

            s=1;

            cout<<i<<" "<<(k-(p*i))/q<<" "<<n-(i+((k-(p*i))/q))<<endl;

            break;

        }

    }

    if(s==0)

    {

        cout<<"-1 -1 -1"<<endl;

    }



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/**OOO**/

#include<bits/stdc++.h>

#define ll long long

#define ull unsigned long long

#define mems(x,y) memset(x,y,sizeof(x))

#define pf printf

#define sc scanf

using namespace std;





int main()

{

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



    ll n,y,a,b,c;

    cin>>n>>y;



    if(y%10000==0 && y/10000==n)cout<<y/10000<<" "<<0<<" "<<0<<endl;

    else if(y%5000==0 && y/5000==n)cout<<0<<" "<<y/5000<<" "<<0<<endl;

    else if(y%1000==0 && y/1000==n)cout<<0<<" "<<0<<" "<<y/1000<<endl;

    else{



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

            a=10000*i;

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

                b=5000*j;

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

                    c=1000*k;

                    if(a+b+c==y && i+j+k==n){

                        cout<<i<<" "<<j<<" "<<k<<endl;

                        return 0;

                    }

                }

            }

        }

        cout<<-1<<" "<<-1<<" "<<-1<<endl;

    }



return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



int main() {

	int n, m;

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

	if (m > n * 10000) {

		puts("-1 -1 -1");

	    return 0;

	}

	if (m % 1000 != 0) {

		puts("-1 -1 -1");

	    return 0;

	}

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

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

			if (n - i - j < 0) break;

			if (m - 10000 * i - 5000 * j < 0) break;

			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == m) {

				printf("%d %d %d", i, j, n - i - j);

				return 0;

			}

		}

	}

	puts("-1 -1 -1");

	return 0;

}

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

using namespace std;

int main()

{

    int n,tk,i,j,sum;



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



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

    {

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

        {

            sum=10000*i+5000*j+(n-i-j)*1000;



            if(sum==tk)goto xx;

        }

    }

      if(i==n+1)printf("-1 -1 -1\n");



     else  xx:printf("%d %d %d\n",i,j,n-i-j);



     return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



int main() {

	int n, m;

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

	if (m > n * 10000) {

		puts("-1 -1 -1");

	    return 0;

	}

	if (m % 1000 != 0) {

		puts("-1 -1 -1");

	    return 0;

	}

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

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

			if (n - i - j < 0) break;

			if (m - 10000 * i - 5000 * j < 0) break;

			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == m) {

				printf("%d %d %d", i, j, n - i - j);

				return 0;

			}

		}

	}

	puts("-1 -1 -1");

	return 0;

}

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

using namespace std;



int main()



{

    int b1 = 10000, b2 = 5000, b3 = 1000;

    int n, y;

    cin >> n >> y;



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

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



            int tmp = b1 * i + b2 * j;

            if(tmp > y)

                break;



            if( (y - tmp) % b3 == 0) {

                int k = (y - tmp) / b3;

                if(i + j + k == n) {

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

                    return 0;

                }

            }



        }

    }



    printf("-1 -1 -1\n");



    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



int main() {

	int n, m;

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

	if (m > n * 10000) {

		puts("-1 -1 -1");

	    return 0;

	}

	if (m % 1000 != 0) {

		puts("-1 -1 -1");

	    return 0;

	}

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

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

			if (n - i - j < 0) break;

			if (m - 10000 * i - 5000 * j < 0) break;

			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == m) {

				printf("%d %d %d", i, j, n - i - j);

				return 0;

			}

		}

	}

	puts("-1 -1 -1");

	return 0;

}

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

using namespace std;



int main() {

    int n, y;

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



    int a1(0), a5(0), a10(0);



    if (y % 1000 != 0) {

        cout << "-1 -1 -1\n";

        return 0;

    }



    y = y / 1000;



    int x, z, bill = n, temp, status = 1;



    if (y%5 != 0) {

        x = y % 5;

        a1 += x;

        y -= x;

        n -= x;

    }



    while(1) {

        if (y/5 < n) {

            if (y%5 != 0) {

                x = y % 5;

                a1 += x;

                y -= x;

                n -= x;

            }

            if (n <= 0) {

                break;

            }

            else {

                if (y/5 >= n) {

                    continue;

                }

                else {

                    z = y / 5;

                    temp = n - z;

                    n = z;

                    a1 += temp;

                    y -= temp;

                }

            }

        }



        else {

            if (y%10 == 0) {

                a10 = y / 10;

            }

            else {

                a10 = y / 10;

                a5 = 1;

            }

            while(1) {

                if (a10 + a5 >= n) {

                    status = 0;

                    break;

                }

                else {

                    a10--;

                    a5 += 2;

                }

                if (a10 == 0) {

                    status = 0;

                    break;

                }

            }

        }

        if (status == 0) {

            break;

        }

    }



    if (a1+a5+a10 == bill) {

        printf("%d %d %d\n", a10, a5, a1);

    }

    else {

        cout << "-1 -1 -1\n";

    }



    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



int main() {

	int n, m;

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

	if (m > n * 10000) {

		puts("-1 -1 -1");

	    return 0;

	}

	if (m % 1000 != 0) {

		puts("-1 -1 -1");

	    return 0;

	}

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

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

			if (n - i - j < 0) break;

			if (m - 10000 * i - 5000 * j < 0) break;

			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == m) {

				printf("%d %d %d", i, j, n - i - j);

				return 0;

			}

		}

	}

	puts("-1 -1 -1");

	return 0;

}

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

using namespace std;

#define ll long long



int main()

{

	ll n,y;

	cin>>n>>y;

	

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

	{

		for(ll j=0;j<=n;j++)

		{

			ll k=n-i-j;

			if((i+j+k==n) && ((i*10000+j*5000+k*1000)==y)&&k>=0)

			{

				cout<<i<<" "<<j<<" "<<k<<endl;

				return 0;

			}

		}

	}

	

	cout<<"-1 -1 -1"<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



int main() {

	int n, m;

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

	if (m > n * 10000) {

		puts("-1 -1 -1");

	    return 0;

	}

	if (m % 1000 != 0) {

		puts("-1 -1 -1");

	    return 0;

	}

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

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

			if (n - i - j < 0) break;

			if (m - 10000 * i - 5000 * j < 0) break;

			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == m) {

				printf("%d %d %d", i, j, n - i - j);

				return 0;

			}

		}

	}

	puts("-1 -1 -1");

	return 0;

}

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

using namespace std;



int main()



{

    int b1 = 10000, b2 = 5000, b3 = 1000;

    int n, y;

    cin >> n >> y;



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

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



            int tmp = b1 * i + b2 * j;

            if(tmp > y)

                break;



            if( (y - tmp) % b3 == 0) {

                int k = (y - tmp) / b3;

                if(i + j + k == n) {

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

                    return 0;

                }

            }



        }

    }



    printf("-1 -1 -1\n");



    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



int main() {

	int n, m;

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

	if (m > n * 10000) {

		puts("-1 -1 -1");

	    return 0;

	}

	if (m % 1000 != 0) {

		puts("-1 -1 -1");

	    return 0;

	}

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

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

			if (n - i - j < 0) break;

			if (m - 10000 * i - 5000 * j < 0) break;

			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == m) {

				printf("%d %d %d", i, j, n - i - j);

				return 0;

			}

		}

	}

	puts("-1 -1 -1");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

    int n,s;

	cin>>n>>s;

    if(s % 1000 != 0) {

        printf("-1 -1 -1\n");

    } else {

        s /= 1000;

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

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

                if(i + j*5 > s) {

                    continue;

                }

                if( ((s - (i + j*5)) % 10 == 0 ) ) {

                    if(i + j + ((s - (i + j*5))/10) == n) {

                        printf("%d %d %d\n",((s - (i + j*5))/10),j,i);

                        return 0;

                    }

                }

            }

        }

        printf("-1 -1 -1\n");

    }



    return 0;

}


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

using namespace std;

int main()

{

    long long n,y;

    cin>>n>>y;

    int f=0;

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

    {

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

        {

            long long c=n-i-j;

            if(i*10000+j*5000+c*1000==y)

            {

                f=5;

                cout<<i<<" "<<j<<" "<<c<<endl;

                return 0;

            }



        }

    }

    if(f==0)

    {

        cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;

    }

return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cmath>

#include<cstdio>

#include<vector>

#include<algorithm>



#define	pb			push_back

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



using namespace std;



typedef	vector<int>	vi;



const double EPS=1e-9;



int main(){

	static bool er[100000]={};	er[0]=er[1]=true;

	rep(i,400) if(!er[i]) for(int j=i*i;j<100000;j+=i) er[j]=true;



	vi pr;

	rep(i,100000) if(!er[i]) pr.pb(i);



	for(int m,a,b;scanf("%d%d%d",&m,&a,&b),m;){

		int popt=2,qopt=2;

		rep(i,pr.size()){

			int p=pr[i];

			if(p*p>m)	continue;

			int q=*(upper_bound(pr.begin()+i,pr.end(),min(b*p/a,m/p))-1);

			if(popt*qopt<p*q)	popt=p,qopt=q;

		}

		printf("%d %d\n",popt,qopt);

	}



	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<vector>

#include<algorithm>



#define	pb			push_back

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



using namespace std;



typedef	vector<int>	vi;



int main(){

	static bool er[100000]={};	er[0]=er[1]=true;

	rep(i,400) if(!er[i]) for(int j=i*i;j<100000;j+=i) er[j]=true;



	vi pr;

	rep(i,100000) if(!er[i]) pr.pb(i);



	for(int m,a,b;scanf("%d%d%d",&m,&a,&b),m;){

		int popt=2,qopt=2;

		rep(i,pr.size()){

			int p=pr[i];

			if(p*p>m)	break;

			int q=*(upper_bound(pr.begin()+i,pr.end(),min(b*p/a,m/p))-1);

			if(popt*qopt<p*q)	popt=p,qopt=q;

		}

		printf("%d %d\n",popt,qopt);

	}



	return 0;

}

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

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

using namespace std;



bool is_prime[100000];

double prime[10000];



int main() {

	memset(is_prime, 1, sizeof(is_prime));

	is_prime[0] = is_prime[1] = false;

	int p = 0;

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

		if (is_prime[i]) {

			prime[p++] = i;

			for (int j = i * 2; j < 100000; j += i)is_prime[j] = false;

		}

	}

	int m; double a, b;

	while (scanf("%d%lf%lf", &m, &a, &b), m) {

		int Max = 0, P, Q;

		for (int i = 0; prime[i] * 2 <= m; i++) {

			int j = upper_bound(prime, prime + p, prime[i] / a*b) - prime - 1;

			int k = upper_bound(prime, prime + p, m / prime[i]) - prime - 1;

			j = min(j, k);

			if (j < 0)continue;

			if (Max < prime[i] * prime[j] && prime[j] / (double)prime[i] >= a / b) {

				Max = prime[i] * prime[j]; P = prime[i]; Q = prime[j];

			}

		}

		printf("%d %d\n", P, Q);

	}

}

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

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

using namespace std;



bool is_prime[100000];

double prime[10000];



int main() {

	memset(is_prime, 1, sizeof(is_prime));

	is_prime[0] = is_prime[1] = false;

	int p = 0;

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

		if (is_prime[i]) {

			prime[p++] = i;

			for (int j = i * 2; j < 100000; j += i)is_prime[j] = false;

		}

	}

	int m; double a, b;

	while (scanf("%d%lf%lf", &m, &a, &b), m) {

		int Max = 0, P, Q;

		for (int i = 0; prime[i] * prime[i] <= m; i++) {

			int j = upper_bound(prime, prime + p, prime[i] / a*b) - prime - 1;

			int k = upper_bound(prime, prime + p, m / prime[i]) - prime - 1;

			j = min(j, k);

			if (j < 0)continue;

			if (Max < prime[i] * prime[j] && prime[j] / (double)prime[i] >= a / b) {

				Max = prime[i] * prime[j]; P = prime[i]; Q = prime[j];

			}

		}

		printf("%d %d\n", P, Q);

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <bitset>

#include <climits>

#include <cmath>

#include <cstring>

#include <ctime>

#include <functional>

#include <iostream>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <tuple>

#include <unordered_map>

#include <utility>

#include <vector>

#include <complex>



using namespace std;



const int SIZ = 100000;



vector<int> getPrimes() {

    vector<int> primes;

    int sieve[SIZ];

    fill_n(sieve, SIZ, true);

    sieve[0] = sieve[1] = false;

    primes.push_back(2);

    for (int i=4; i<SIZ; i+=2) {

        sieve[i] = false;

    }

    for (int i=3; i*i<SIZ; i+=2) {

        if ( ! sieve[i]) continue;

        for (int j=i*2; j<SIZ; j+=i) {

            sieve[j] = false;

        }

    }

    for (int i=3; i<SIZ; i+=2) {

        if (sieve[i]) primes.push_back(i);

    }

    return primes;

}



int main() {

    ios::sync_with_stdio(false);

    vector<int> primes = getPrimes();

    int m, a, b;

    while (1) {

        cin >> m >> a >> b;

        if (!m && !a && !b) break;

        int tp, tq, p = 0, q = 0, max_m = 0;

        for (int i=0; i<(int)primes.size(); ++i) {

            for (int j=i; j<(int)primes.size(); ++j) {

                tp = primes[i];

                tq = primes[j];

                if (tp * tq < 0) break;

                if (m < tp * tq || b * tp < a * tq) {

                    break;

                }

                if (max_m < tp * tq) {

                    p = tp;

                    q = tq;

                    max_m = tp * tq;

                }

            }

        }

        cout << p << " " << q << endl;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <vector>



using namespace std;



const int MX = 100000;

bool isprime[MX];



vector<int> getPrimes() {

    vector<int> ret;

    fill_n(isprime, MX, true);

    isprime[0] = isprime[1] = false;

    for (int i=2; i<=MX; ++i) {

        if ( ! isprime[i]) continue;

        ret.push_back(i);

        for (int j=i*i; 0<j && j<=MX; j+=i) {

            isprime[j] = false;

        }

    }

    return ret;

}



int main() {

    vector<int> primes = getPrimes();

    long long m, a, b;

    while (1) {

        cin >> m >> a >> b;

        if (!m && !a && !b) break;

        long long pq = 0;

        pair<int,int> ans;

        for (int i=0; i<(int)primes.size(); ++i) {

            long long p = primes[i];

            if (p * p > m) break;

            for (int j=i; j<(int)primes.size(); ++j) {

                long long q = primes[j];

                if (p * q > m || a * q > b * p) break;

                if (pq < p * q) {

                    pq = p * q;

                    ans.first = p;

                    ans.second = q;

                }

            }

        }

        cout << ans.first << " " << ans.second << endl;

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std ;

int main()

{

	int n,x,a[105]  ; cin >> n >>x;

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

		cin >> a[i] ;

	sort(a,a+n) ;

	int m=0;

	while(x>=a[m]&&m<n-1) {x-=a[m] ;m++;}

	if(x==a[m]) m++;

	cout << m ;

	return 0 ;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int a[101];

int main(void)

{

	int n, x;

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

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

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

	sort(a + 1, a + n + 1);

	int ans = 0;

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

	{

		if (x < a[i])

		{

			printf("%d", ans);

			return 0;

		}

		++ans;

		x -= a[i];

	}

	if (x) --ans;

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdlib>

#include<cstdio>

#include<iostream>

#include<algorithm>

using namespace std;

int a[1000];

int main()

{

	int n,x;

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

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

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

	sort(a+1,a+n+1);

	int ans=0;

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

	{

		if(x>=a[i])

		{

			x-=a[i];

			ans++;

		}

	}

	if(x==a[n])

	{

		ans++;

	}

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

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int a[101];

int main(void)

{

	int n, x;

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

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

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

	sort(a + 1, a + n + 1);

	int ans = 0;

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

	{

		if (x < a[i])

		{

			printf("%d", ans);

			return 0;

		}

		++ans;

		x -= a[i];

	}

	if (x) --ans;

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

long long int happy[105];

int main()

{

    long long int k, c;

    cin >> k >> c;

    long long int totalhappy = 0;

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

    {

        cin >> happy[i];

        totalhappy = totalhappy + happy[i];

    }

    long long int maxhappy = 0, candyused = 0;

    if ( totalhappy == c )

    {

        cout << k;

    }

    else if ( totalhappy < c )

    {

        cout << k - 1;

    }

    else

    {

        long long int deposit;

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

        {

            for ( int j = i+1; j <= k; j++ )

            {

                if ( happy[j] < happy[i] )

                {

                    deposit = happy[i];

                    happy[i] = happy[j];

                    happy[j] = deposit;

                }

            }

        }

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

        {

            candyused = candyused + happy[i];

            if ( candyused <= c )

            {

                maxhappy++;

            }

            else

            {

                break;

            }

        }

        cout << maxhappy;

    }

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int a[101];

int main(void)

{

	int n, x;

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

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

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

	sort(a + 1, a + n + 1);

	int ans = 0;

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

	{

		if (x < a[i])

		{

			printf("%d", ans);

			return 0;

		}

		++ans;

		x -= a[i];

	}

	if (x) --ans;

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

	return 0;

}

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

using namespace std;

typedef long long LL;

inline LL read()

{

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

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

    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}

    return x*f;

}



const int maxn=1e5+7;

int a[maxn];

int main()

{

    int n=read(),x=read();

    for(int i=1;i<=n;i++)a[i]=read();

    sort(a+1,a+1+n);

    int ans=0;

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

        if(i==n){

            if(x==a[i])ans++;

            break;

        }

        if(x>=a[i]){

            x-=a[i];

            ans++;

        }

        else break;

    }

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

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int a[101];

int main(void)

{

	int n, x;

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

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

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

	sort(a + 1, a + n + 1);

	int ans = 0;

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

	{

		if (x < a[i])

		{

			printf("%d", ans);

			return 0;

		}

		++ans;

		x -= a[i];

	}

	if (x) --ans;

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

	return 0;

}

// Fastest known solution for this problem: