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

using namespace std;

int n,m;

bool flag=1;

int main() {

	cin>>n>>m;

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

		for(int y=0,z; y<=n-x; y++) {

			z=n-x-y;

			if(x*10000+y*5000+z*1000==m&&x+y+z==n) {

				cout<<x<<' '<<y<<' '<<z<<endl;

				flag=0;

				return 0;

			}

		}

	if(flag)cout<<"-1 -1 -1";

	return 0;

}

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

int main() {

	int n, y;

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

	int s = 0;

	int flag = 0;

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

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

			s = i * 10000 + j * 5000;

			if(i + j <= n && s + (n - i - j) * 1000 == y) {

				flag = 1;

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

				return 0;

			}

		}

	}

	if(flag == 0) printf("-1 -1 -1\n");

	return 0;

}
// Slower C++ solution:
/**OOO**/

#include<bits/stdc++.h>

#define ll long long int

using namespace std;





int main()

{



    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;

}


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

using namespace std;

int n,m;

int main()

{

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

	for(register int x=0;x<=n;x++)

		for(register int y=0;y<=n;y++)

				if(x*10000+y*5000+(n-x-y)*1000==m && x>=0 && y>=0 && n-x-y>=0)

				{

					printf("%d %d %d",x,y,n-x-y);

					return 0;

				}

	printf("-1 -1 -1");

	return 0;

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

using namespace std;



int main() {

	int n, y,i,j,sum=0,count=0,a,b,c;

	cin >> n >> y;

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

		for(j = i; j <= n; j++){

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

			if(sum == y){

				count++;

				a=i;

				b=j-i;

				c=n-j;

			}

		}

	}

	if(count>0)cout << a << " " << b << " " << c << endl;

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

	return 0;

}


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

using namespace std;

int n,m;

int main()

{

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

	for(register int x=0;x<=n;x++)

		for(register int y=0;y<=n;y++)

				if(x*10000+y*5000+(n-x-y)*1000==m && x>=0 && y>=0 && n-x-y>=0)

				{

					printf("%d %d %d",x,y,n-x-y);

					return 0;

				}

	printf("-1 -1 -1");

	return 0;

}
// Slower C++ solution:
/**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;

}


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

using namespace std;

int n,m;

int main()

{

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

	for(register int x=0;x<=n;x++)

		for(register int y=0;y<=n;y++)

				if(x*10000+y*5000+(n-x-y)*1000==m && x>=0 && y>=0 && n-x-y>=0)

				{

					printf("%d %d %d",x,y,n-x-y);

					return 0;

				}

	printf("-1 -1 -1");

	return 0;

}
// Slower C++ solution:
#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;

}


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

using namespace std;

int n,m;

int main()

{

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

	for(register int x=0;x<=n;x++)

		for(register int y=0;y<=n;y++)

				if(x*10000+y*5000+(n-x-y)*1000==m && x>=0 && y>=0 && n-x-y>=0)

				{

					printf("%d %d %d",x,y,n-x-y);

					return 0;

				}

	printf("-1 -1 -1");

	return 0;

}
// Slower C++ solution:
// 基本テンプレート

 

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

using namespace std;

 

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

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define debug(...) fprintf(stderr, __VA_ARGS__)

#define int long long int

 

template<typename T> void chmax(T &a, T b) {a = max(a, b);}

template<typename T> void chmin(T &a, T b) {a = min(a, b);}

template<typename T> void chadd(T &a, T b) {a = a + b;}

 

typedef pair<int, int> pii;

typedef long long ll;

 

int dx[] = {0, 0, 1, -1};

int dy[] = {1, -1, 0, 0};

const ll INF = 1001001001001001LL;

const ll MOD = 1000000007LL;



int dp[5][3010];

 

signed main() {

    int N, Y; cin >> N >> Y;

    repq(x,0,N) repq(y,0,N-x) {

        int z = N - x - y;

        if(10000 * x + 5000 * y + 1000 * z == Y) {

            printf("%lld %lld %lld\n", x, y, z);

            return 0;

        }

    }

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

    return 0;

}

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

using namespace std;

using Int = long long int;



Int N, Y;

int main() {

    scanf("%lld%lld", &N, &Y);



    for(Int A=0; A<=N; A++) {

        for(Int B=0; A+B<=N; B++) {

            Int C = N - A - B;

            Int money = 10000 * A + 5000 * B + 1000 * C;



            if(money == Y) {

                printf("%lld %lld %lld\n", A, B, C);

                return 0;

            }

        }

    }



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

    return 0;

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



int main(){

  int N, Y, i, j, k;

  scanf("%d%d", &N, &Y);

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

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

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

        if(i*10000 + j*5000 + k*1000 == Y && i+j+k == N){

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

          return 0;

        }

      }

    }

  }

  if(i==N+1) printf("%d %d %d", -1, -1, -1);

  return 0;

}

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



int main(){

  int N, Y, i, j;

  scanf("%d%d", &N, &Y);

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

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

        if(i*10000 + j*5000 + (N-i-j)*1000 == Y){

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

          return 0;

        }

    }

  }

  if(i==N+1) printf("%d %d %d", -1, -1, -1);

  return 0;

}
// Slower C++ solution:
#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;

}

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

using namespace std;

int main()

{

   long long a,b,ct,ct1,ct2,ct3,n,k,y,x,z,p,q,r,flag;

   cin>>n>>k;

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

   {

       for(y=0;x+y<=n;y++)

       {

           z=n-(x+y);

           if(10000*x+5000*y+z*1000==k)

           {

               cout<<x<<" "<<y<<" "<<z;

               return 0;

           }

       }

   }

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

   return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.12228672506853x):
#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;

}
// Slower C++ solution:
#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;

}

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

using namespace std;

int main()

{

	int N,Y;cin>>N>>Y;

	for(int x=0;x<=N;x++)

	{

		for(int y=0;y<=N-x;y++)

		{

			int z = N-x-y;

			int total = x*1e4 + y*5*1e3 + 1e3*z;

			if(total==Y)

			{

				cout<<x<<" "<<y<<" "<<z<<"\n";

				return 0;

			}

		}

	}

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

	return 0;

}
// Slower C++ solution:
#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;

}

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

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,d,x,y,z;

    cin>>n>>y;

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

    {

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

        {

            k=(n-(i+j));

            l=10000*i+5000*j+1000*k;

            if(l==y)

            {

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

                return 0;

            }

        }

    }

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

    return 0;

}
// Slower C++ solution:
/**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;

}


// Faster C++ solution for the same problem (measured speedup: 3.8178753257731106x):
#include"stdio.h"



int main() {

	int n, y,i,j,sum=0,count=0,a,b,c;

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

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

		for(j = i; j <= n; j++){

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

			if(sum == y){

				count++;

				a=i;

				b=j-i;

				c=n-j;

			}

		}

	}

	if(count>0)printf("%d %d %d\n",a,b,c);

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

	return 0;

}
// Slower C++ solution:
/**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;

}


// Faster C++ solution for the same problem (measured speedup: 4.414960370939744x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 4.9967402631633435x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.097872594522888x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 4.36410442124016x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.687930549209354x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.097872594522888x):
#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;

}