Problem:
 Score : 300 points    Problem Statement The commonly used bills in Japan are 10000 -yen, 5000 -yen and 1000 -yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.      Constraints  1 ≤ N ≤ 2000  1000 ≤ Y ≤ 2 × 10^7  N is an integer.  Y is a multiple of 1000 .         Input Input is given from Standard Input in the following format:  N  Y       Output If the total value of N bills cannot be Y yen, print -1 -1 -1 .  If the total value of N bills can be Y yen, let one such set of bills be " x  10000 -yen bills, y  5000 -yen bills and z  1000 -yen bills", and print x , y , z with spaces in between. If there are multiple possibilities, any of them may be printed.        Sample Input 1 9 45000      Sample Output 1 4 0 5  If the envelope contained 4  10000 -yen bills and 5  1000 -yen bills, he had 9 bills and 45000 yen in total. It is also possible that the envelope contained 9  5000 -yen bills, so the output 0 9 0 is also correct.       Sample Input 2 20 196000      Sample Output 2 -1 -1 -1  When the envelope contained 20 bills in total, the total value would be 200000 yen if all the bills were 10000 -yen bills, and would be at most 195000 yen otherwise, so it would never be 196000 yen.       Sample Input 3 1000 1234000      Sample Output 3 14 27 959  There are also many other possibilities.       Sample Input 4 2000 20000000      Sample Output 4 2000 0 0

Solution (Python):



import sys


YEN_10000 = 10000
YEN_5000 = 5000
YEN_1000 = 1000


N,Y = list(map(int, input().split()))


is_correct = False
for n_10000 in range(N+1):
    for n_5000 in range(N+1-n_10000):
        n_1000 = N - n_10000 - n_5000
        amount = YEN_10000*n_10000 + YEN_5000*n_5000 + YEN_1000*n_1000
        if amount == Y:
            is_correct = True
            print(n_10000, n_5000, n_1000)
            sys.exit()

if not is_correct:
    print("-1 -1 -1")

Solution (Python):
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k10=i*10000
        k5=j*5000
        k1=(n-i-j)*1000
        if k10+k5+k1==y:
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

Solution (Python):
import sys

n, y = map(int, input().split())

for i in range(n+1):
  for j in range(n+1):
    k = n - i - j
    if (k < 0):
      continue
    total = 10000 * i + 5000 * j + 1000 * k
    if i + j + k == n and total == y:
      print('{0} {1} {2}'.format(i, j, k))
      sys.exit()

print('-1 -1 -1')

Solution (Python):
n,y=map(int, input().split())

for i in range(n + 1):
    for j in range(n - i + 1):
        if i *10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i, j, n-i-j)
            exit()
print("-1 -1 -1")

Solution (Python):
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Solution (Python):

n, y = map(int, input().split())


xx = -1
yy = -1
zz = -1

for man in range(n+1):
    for gosen in range(n+1):
        sen = n - man - gosen
        if 0 <= sen and y == man*10000 + gosen*5000 + sen*1000:
            xx = man
            yy = gosen
            zz = sen
            break
    if xx != -1:
        break

print(str(xx) + " " + str(yy) + " " + str(zz))

Solution (Python):
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, y = MI()

    for i in range(n + 1):
        for j in range(n + 1 - i):
            otoshidama = 10000 * i + 5000 * j + 1000 * (n - i - j)
            if otoshidama == y:
                print("{} {} {}".format(i, j, n - i - j))
                exit()
    print("-1 -1 -1")

    pass


if __name__ == "__main__":
    main()

Solution (Python):
n,y=map(int,input().split())
for p in range(n+1):
  for q in range(n+1-p):
    if 10000*p+5000*q+1000*(n-p-q)==y:
      print(p,q,n-p-q)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')

Solution (Python):
N, Y = map(int, input().split())

n, m, l = -1, -1, -1
flag = False
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        if Y == 10000 * i + 5000 * j + 1000 * k:
            n, m, l = i, j, k
            flag = True
            break
    if flag:
        break

print(n, m, l)

Solution (Python):
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 -i):
    if 10000*i + 5000*j + 1000*(n - i -j) == y:
      print(i, j, n - i -j)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')

Solution (Python):
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 -i):
    if 10000*i + 5000*j + 1000*(n - i -j) == y:
      print(i, j, n - i -j)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')

Solution (Python):
N,Y=map(int,input().split())

flag=False

for i in range(N+1):
  for j in range(N+1):
    if(9000*i+4000*j==Y-1000*N):
      flag=True
      x=i
      y=j
      z=N-i-j
      
if(flag==True and z>=0):
  print(str(x)+" "+str(y)+" "+str(z))
else:
  print("-1 -1 -1")

Solution (Python):
n, y = map(int, input().split())

def main():
    if (5000*n) == y:
        print('{} {} {}'.format(0, n, 0))
        return
    if (10000*n) == y:
        print('{} {} {}'.format(n, 0, 0))
        return
    for i in range(n):
        for j in range(n-i):
            k = n - (i+j)
            if (10000*i + 5000*j + 1000*k) == y:
                print('{} {} {}'.format(i, j, k))
                return
    print('-1 -1 -1')

main()

Solution (Python):
n, y = map(int, input().split())

def main():
    if (5000*n) == y:
        print('{} {} {}'.format(0, n, 0))
        return
    if (10000*n) == y:
        print('{} {} {}'.format(n, 0, 0))
        return
    if (1000*n) == y:
        print('{} {} {}'.format(0, 0, n))
        return
    for i in range(n):
        for j in range(n-i):
            k = n - (i+j)
            if (10000*i + 5000*j + 1000*k) == y:
                print('{} {} {}'.format(i, j, k))
                return
    print('-1 -1 -1')

main()

Solution (Python):
N,Y = map(int,input().split())
flag = False
for i in range(N+1):
    for j in range(N+1-i):
        x = N - i - j
        if x*1000 + j*5000 +i*10000 == Y:
            print(i,j,x)
            flag = True
            break
    if flag == True:
        break


if flag == False:
    print('-1 -1 -1')

Solution (Python):
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i, j, n-i-j)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Solution (Python):
import sys
N, Y = map(int,input().split())

for k in range(N+1):
	for j in range(N+1 - k):
		i = N - k -j
		if k*10000 + j*5000 + i*1000 == Y:
			print(k, j, i)
			sys.exit()
print("-1 -1 -1")

Solution (Python):
i,j= list(map(int, input().split()))
ans1=-1
ans2=-1
ans3=-1
for k in range(i+1):
    for m in range(i-k+1):
        n=i-k-m
        if j==(k*10000)+(m*5000)+(n*1000):
            ans1=k
            ans2=m
            ans3=n
print(ans1,ans2,ans3)

Solution (Python):
ny = input().split()
n = int(ny[0])
yen = int(ny[1])

ichiman = -1
gosen = -1
sen = -1
flg = False

for x in range(n + 1):
	if flg : break
	for y in range(n-x+1):
		if 10000*x + 5000*y + 1000*(n-x-y) == yen:
			flg = True
			ichiman = x
			gosen = y
			sen = n-x-y
			break

print(ichiman,gosen,sen)

Solution (Python):
m = input().split()
N = int(m[0])
Y = int(m[1])
ans = [0] * 3

for a in range(N+1):
  for b in range(N - a + 1):
    c = N - (a + b)
    money = (a * 10000) + (b * 5000) + (c * 1000)

    if money == Y:
      ans[0] = a
      ans[1] = b
      ans[2] = c
      break
  else:
    continue

  break

if ans == [0, 0, 0]:
  ans = [-1, -1, -1]

x = ans[0]
y = ans[1]
z = ans[2]

print(str(x) + ' ' + str(y) + ' ' + str(z))

Solution (Python):
N, Y = map(int, input().split())

Y //= 1000

ans = False
for i in range(N + 1):
    for j in range((N - i) + 1):
        if 10 * i + 5 * j + 1 * (N - i - j) == Y:
            ans = True
            break
    else:
        continue
    break

if ans:
    print(i, j, N - i - j)
else:
    print(-1, -1, -1)

Solution (Python):
import sys
N, Y = map(int,input().split())

for k in range(N+1):
	for j in range(N+1 - k):
		i = N - k -j
		if k*10000 + j*5000 + i*1000 == Y:
			print(k, j, i)
			sys.exit()
print("-1 -1 -1")

Solution (Python):
def otoshidama():
    N,Y = map(int, input().split())

    for i in range(N + 1):
        for j in range(N + 1 - i):
            k = N - i - j
            if i * 10000 + j * 5000 + k *1000 == Y:
                print('{0} {1} {2}'.format(i,j,k))
                return

    print('{0} {1} {2}'.format(-1,-1,-1))

def main():
    otoshidama()

if __name__ == '__main__':
    main()

Solution (Python):
N,Y = map(int, input().split())
A = []
for i in range(N+1):
    if A != []:
        break
    else:
        for j in range(N+1-i):
            if A != []:
                break
            elif 10000*i + 5000*j + 1000*(N-i-j) == Y:
                A = [i,j,N-i-j]
                break
            elif 10000*i + 5000*j + 1000*(N-i-j) > Y:
                break
if A != []:
    print('{} {} {}'.format(A[0],A[1],A[2]))
else:
    print('{} {} {}'.format(-1,-1,-1))

Solution (Python):
N, Y = map(int, input().split())

ans = [-1,-1,-1]
for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    if Y == 10000*i+5000*j+1000*k:
      ans = [i,j,k]
      break
    else:
        continue
    break


print(*ans)

Solution (Python):
N, Y= map(int, input().split())
flag = False
for i in range(N+1):
	for j in range(N+1-i):
		k = N - i - j
		if(10000*i+5000*j+1000*k == Y):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)

Solution (Python):
N, Y= map(int, input().split())
flag = False
for i in range(N+1):
	zandaka = Y - (10000*i)
	for j in range(N+1-i):
		k = (zandaka - 5000*j)//1000
		if(i + j + k == N):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)

Solution (Python):
N, Y= map(int, input().split())
try:	
	for i in range(N+1):
		zandaka = Y - (10000*i)
		for j in range(N+1-i):
			k = (zandaka - 5000*j)//1000
			if(i + j + k == N):
				print(i, j, k)
				raise Exception
	print(-1,-1,-1)
except Exception:
	pass

Solution (Python):
N, Y= map(int, input().split())

flag = False
for i in range(N+1):
	for j in range(N+1-i):
		k = (Y - (10000*i+5000*j))//1000
		if(i + j + k == N):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)

Solution (Python):
n,y = map(int,input().split())

for i in range(y // 10000 + 1):
    for k in range(( y - i*10000) // 5000 + 1):
        if i*10000 + k*5000 + (n - i - k)*1000 == y:
            print(i,k,(n - i - k))
            quit()
print("-1 -1 -1")

Solution (Python):
n,y=list(map(int,input().split()))
y//=1000
ans=0
for x in range(y//10+1):
    for j in range(y//5+1):
        if 0 <= y-10*x-5*j == n-x-j:
            print(x,j,n-x-j)
            exit(0)
print("-1 -1 -1")

Solution (Python):
a = list(map(int, input().split()))
for i in range(a[0]+1):
    for j in range(a[0]-i+1):
        b = 10000*i + 5000*j + 1000*(a[0]-(i+j))
        if b == a[1]:
            print(i, end=" ")
            print(j, end=" ")
            print(a[0]-(i+j))
            exit()
print(-1, end=" ")
print(-1, end=" ")
print(-1)

Solution (Python):
from itertools import product
N,Y=map(int, input().split())

def total_check(n, y):
    for b in range(N+1):
        for a in range(N+1):
            if a + b > N:
                break
            c = N - a - b
            t = 10000 * a + 5000 * b + 1000 * c
            if t==y:
                return a, b, c
    return -1,-1,-1
a,b,c=total_check(N,Y)
print(a,b,c)

Solution (Python):
N, Y = map(int,input().split())

for i in range(Y // 10000 + 1):
    for k in range((Y - i*10000) // 5000 + 1):
        if i*10000 + k*5000 + (N - i - k)*1000 == Y:
            print(i,k,(N - i - k))
            quit()
print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split())
flag = 0

for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if z >= 0 and Y == (x*10000 + y*5000 + z*1000):
            flag = 1
            break
    
    if flag == 1:
        break

if flag == 1:
    print(x,y,z)
else:
    print("-1 -1 -1")

Solution (Python):
n,y=map(int,input().split())
for i in range(n+1):
    y_=y-10000*i
    for j in range(n-i+1):
        y__=y_-5000*j
        if y__//1000==n-i-j:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)

Solution (Python):
N, Y = map(int, input().split())
for i in range(N+1):
    y = Y-10000*i
    for j in range(N-i+1):
        y_ = y-5000*j
        if y_//1000 == N-i-j:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

Solution (Python):
n,y = map(int,input().split())
for a in range(n+1):
  for b in range(n+1-a):
    c = n-a-b
    if 0<=c<=2000 and 1000*a+5000*b+10000*c == y:
      print(c,b,a)
      break
  else:
    continue
  break
else:
  print(-1,-1,-1)

Solution (Python):
N, Y = [int(n) for n in input().split(' ')]

def solver():
    for a in range(N+1):
        for b in range(N+1-a):
            if (10000*a + 5000*b + 1000*(N-a-b))==Y:
                print(a, b, N-a-b)
                return 1
    print(-1, -1, -1)
    return 0

solver()

Solution (Python):
N, Y = map(int, input().split())
isFound = False
for x in range(N+1):
    if isFound:
        break
    for y in range(N+1):
        z = N-x-y
        if (10000*x+5000*y+1000*z==Y)&(z>=0):
            print('{} {} {}'.format(x,y,z))
            isFound = True
            break
if isFound == False:
    print('-1 -1 -1')

Solution (Python):
n, y = list(map(int, input().split(' ')))

for i in range(n + 1):
    for j in range(n + 1 - i):
        val = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if val == y:
            print(i, j, (n - i - j))
            exit()


print(-1, -1, -1)

Solution (Python):
def solve():
    N, Y = map(int, input().split())
    for i in range(0,2000+1):
        for j in range(0, 2000+1-i):
            k = (Y - i * 10000 - j * 5000) // 1000
            if k >= 0 and i + j + k == N:
                print(i,j,k)
                return
    
    print(-1,-1,-1)
    

if __name__ == '__main__':
    solve()

Solution (Python):
N, Y = map(int, input().split())

a, b, c = [-1] * 3

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if Y == i * 10000 + j * 5000 + 1000 * k:
            a = i; b = j; c = k; break

print('{} {} {}'.format(a, b, c))

Solution (Python):
n ,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        noguti = (y - (i * 10000 + j * 5000)) // 1000
        if noguti + i + j == n and noguti >= 0:
            print(i,j,noguti)
            quit()

print(-1,-1,-1)

Solution (Python):
n ,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        noguti = (y - (i * 10000 + j * 5000)) // 1000
        if noguti + i + j == n and noguti >= 0:
            print(i,j,noguti)
            quit()

print(-1,-1,-1)

Solution (Python):

import math
import itertools
import statistics
import collections




n, y = list(map(int, input().split()))

for i in range(0, n+1):
    money = 1000*i
   
    for j in range(0, n+1-i):
        money = 1000*i
        money += (5000*j + 10000*(n-i-j))
        if money == y and n==i+j+(n-i-j):
           
            print(str(n-i-j)+" "+str(j)+" "+str(i))
            exit()
        

print("-1 -1 -1")

Solution (Python):
n,y = map(int,input().split())
ans = [-1,-1,-1]

for i in range(n+1):
    for j in range(n+1):
            if 10000*i+5000*j+1000*(n-i-j)==y and n-i-j>=0:
                ans = [i,j,n-i-j]

print(*ans)

Solution (Python):
S = input().split(" ")
N = int(S[0])
Y = int(S[1])


def calculate(n, Y):
    

    xmax = (Y - 1000*n) // 9000

    hasValue = False

    for i in range(0,xmax+1):
        y = ((Y - 1000*n) - 9000*i) / 4000

        if i + y > n:
            continue

        if float.is_integer(y):
            y = int(y)
            print(i,y,(n-i-y))
            hasValue = True
            break

    if hasValue == False:
        print("-1 -1 -1")



calculate(N, Y)

Solution (Python):
a,b=map(int,input().split()) 
c=10000 
d=5000 
e=1000 
ans=False 
for i in range(a+1): 
	for j in range(a+1-i): 
		if i*c+j*d+(a-i-j)*e==b and a-i-j>=0: 
			ans=True 
			break 
	if(ans):break 
if(ans):print(i,j,a-i-j) 
else:print(-1,-1,-1)

Solution (Python):
a,b=map(int,input().split()) 
c=10000 
d=5000 
e=1000 
ans=False 
for i in range(a+1): 
	for j in range(a+1): 
		if i*c+j*d+(a-i-j)*e==b and a-i-j>=0: 
			ans=True 
			break 
	if(ans):break 
if(ans):print(i,j,a-i-j) 
else:print(-1,-1,-1)

Solution (Python):
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if 10000*i + 5000*j + 1000*k == y:
            print(i, j, k)
            exit()

print(-1, -1 ,-1)

Solution (Python):
N,Y=map(int,input().split())
ans=(-1,-1,-1)
for x in range(N+1):
    for y in range(N+1-x):
        z=N-x-y
        if 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Solution (Python):
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if 1000*(n-i-j)+10000*i+5000*j==y and n-i-j>=0:
            print(i,j,n-i-j)
            exit()            
print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split())
flag = True
for x in range(N+1):
    for y in range(N+1):
        z = N-x-y
        if z>=0 and 10000*x + 5000*y + 1000*z == Y:
            print(str(x) + ' ' + str(y) + ' ' + str(z))
            flag = False
            break
            
    if not flag:
        break
    
if flag:
    print('-1 -1 -1')

Solution (Python):
N, Y = map(int, input().split())

for x in range(N+1):
    for y in range(N+1):
        z = N - (x+y)
        if z >= 0 and 10000*x + 5000*y + 1000*z == Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Solution (Python):
N, Y = map(int, input().split())
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000*x+5000*y+1000*z == Y:
      print(x, y, z)
      exit()
print(*[-1]*3)

Solution (Python):
N, Y = map(int, input().split())
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if z>=0 and 10000*x+5000*y+1000*z == Y:
      print(x, y, z)
      exit()
print(*[-1]*3)

Solution (Python):
n,y=map(int,input().split())
for i in range (n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print("{} {} {}".format(i,j,k))
            exit(0)
print("-1 -1 -1")

Solution (Python):



import sys
sys.setrecursionlimit(10000000)


dxdy=((1,0),(0,1))

def pin(type=int):
    return map(type,input().rstrip().split())
    

def resolve():
    N,K=pin()
    ans=0
    k=K//1000
    for z in range(k//10,-2,-1):
        if z==-1:
            print(-1,-1,-1)
            return
        for y in range(N-z,-1,-1):
            x=N-(y+z)
            if z*10+y*5+x==k:
                print(z,y,x)
                return
"""         


"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 45000"""
        output = """4 0 5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 196000"""
        output = """-1 -1 -1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000 1234000"""
        output = """14 27 959"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2000 20000000"""
        output = """2000 0 0"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Solution (Python):
ny_list = input().split(" ")
n = int(ny_list[0])
y = int(ny_list[1])/1000

for a in range(0,n+1):
    for b in range(0,n+1-a):
        if a*10+b*5+n-a-b == y:
            print(str(a)+" "+str(b)+" "+str(n-a-b))
            exit()
print("-1 -1 -1")

Solution (Python):
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(i, j, n-i-j)
            exit()
print('-1 -1 -1')

Solution (Python):
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(2001):
    for j in range(2001):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y :
            if N-i-j >= 0:
                print(str(i) + ' '+str(j) + ' '+ str(N-i-j))
                sys.exit()
print(ans)

Solution (Python):
n,y=map(int,input().split());print(*([(i,j,n-i-j)for i in range(n+1)for j in range(9)if n>=i+j and 9*i+4*j+n==y//1000]+[(-1,-1,-1)])[0])

Solution (Python):
n,y=map(int,input().split());print(*([(i,j,n-i-j)for i in range(n+1)for j in range(n-i+1)if 9*i+4*j+n==y/1e3]+[(-1,-1,-1)])[0])

Solution (Python):
n,y=map(int,input().split())
for i in range(n+1):
 for j in range(n-i+1):
  if 9*i+4*j+n==y/1e3:print(i,j,n-i-j);exit()
print(-1,-1,-1)

Solution (Python):
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    if 9*i+4*j+n==y/1e3:print(i,j,n-i-j);exit()
print(-1,-1,-1)

Solution (Python):
n,y=map(int,input().split());y//=1000
for i in range(n+1):
  for j in range(n-i+1):
    if n-i-j==y-10*i-5*j:print(i,j,n-i-j);exit()
print(-1,-1,-1)

Solution (Python):
n,y=map(int,input().split())
    
n10max=y//10000
n5max=y//5000

iskip=0
for n10 in range(n10max,-1,-1):
    if n10*10000>y:
        continue
    for n5 in range(min(n-n10,n5max)+1):
        n1=n-n10-n5
        if n10*10000+n5*5000+n1*1000==y and n1>=0:
            print(n10,n5,n-n10-n5)
            iskip=1
            break
        else:
            continue
    if iskip==1:
        break
    else:
        continue
        
if iskip==0:
    print(-1,-1,-1)

Solution (Python):
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1):
        num_sen = n - i - j
        if num_sen < 0:
            continue

        if 10000 * i + 5000 * j + 1000 * num_sen == y:
            print(i, j, num_sen)
            exit()
print(-1, -1, -1)

Solution (Python):
N, Y = list(map(int, input().split()))
final_ans = None
for i in range(N + 1):
    for j in range(N + 1):
        if i + j > N:
            continue
        ans = i * 10000 + j * 5000 + (N - i - j) * 1000
        if ans == Y:
            final_ans = " ".join([str(i), str(j), str(N - i - j)])
            break

if final_ans is None:
    print('-1 -1 -1')
else:
    print(final_ans)

Solution (Python):

import math
import sys



N, Y = list(map(int, input().split()))


max_x = math.floor(Y / 10000)


for i in range(max_x + 1):
    x = max_x - i
    
    max_y = N - x
    for j in range(max_y + 1):
        y = max_y - j
        z = N - x - y
        otoshidama = 10000 * x + 5000 * y + 1000 * z
        if(otoshidama == Y):
            print('{} {} {}'.format(x,y,z))
            sys.exit()

print('{} {} {}'.format(-1,-1,-1))

Solution (Python):
N, Y = map(int, input().split(' '))

for man in range(N+1):
    for go in range(N-man+1):
        if (10000*man+5000*go+1000*(N-man-go)) == Y:
            print('{} {} {}'.format(man, go, N-man-go))
            exit()

print('{} {} {}'.format(-1, -1, -1))

Solution (Python):
N,Y=map(int,input().split())
flag=False

for i in range(0,N+1):
  if flag==False:
    for j in range(0,N-i+1):
      P=10000*i+5000*j+1000*(N-i-j)
      if Y==P:
        print(i,j,N-i-j)
        flag=True
        break
      
if flag==False:
  print(-1,-1,-1)

Solution (Python):
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if 10000 * i + 5000 * j + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print('-1 -1 -1')

Solution (Python):
def main():
    N, Y = map(int, input().split())

    x_max = int(Y/10000)

    for x in range(x_max+1):
        tmp_Y = Y - x*10000
        y_max = int(tmp_Y/5000)

        for y in range(y_max+1):
            tmp_Y2 = tmp_Y - y*5000
            z = int(tmp_Y2/1000)

            if x + y + z == N:
                print(x, y, z)
                exit()

    print(-1, -1, -1)

if __name__ == "__main__":
    main()

Solution (Python):
n,Y = map(int,input().split())
 
ans_x = -1
ans_y = -1
ans_z = -1
 
for x in range(n+1):
    for y in range(n+1-x):
        z = int((Y -10000*x - 5000*y)/1000)
        if z >= 0 and (z%1==0 or z==0) and x+y+z == n:
            ans_x = x
            ans_y = y
            ans_z = z
            break
 
print(ans_x, ans_y, ans_z)

Solution (Python):
n,Y=map(int,input().split())
ans=-1,-1,-1
for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    if x*10000+y*5000+z*1000==Y and 0<=z<=2000:
      ans=x,y,z
      break
  else:
    continue
  break
print(*ans)

Solution (Python):
N, Y = map(int, input().split())
flag = False
for x in range(N, -1, -1):
    for y in range(N - x, -1, -1):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            bool = True
            exit()

if not flag:
    print(-1, -1, -1)

Solution (Python):
n, total = [int(i) for i in input().split()]

for a in range(n+1):
  for b in range(n+1-a):
    c = n-a-b
    if c >= 0:
      if 10000*a + 5000*b + 1000*c == total:
        print('{} {} {}'.format(a, b, c))
        exit()
print('-1 -1 -1')

Solution (Python):
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Solution (Python):
n,y=map(int,input().split())
for i in range(2*(10**3)+1):
  for j in range(4*(10**3)+1):
    res=y-i*10000-j*5000
    if res>=0 and res%1000==0 and res//1000+i+j==n :
      print(i,j,res//1000)
      exit()
print(-1,-1,-1)

Solution (Python):
import sys
n,xyz=map(int,input().split())




for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    if (x*10000+y*5000+z*1000)==xyz:
      print(str(x)+" "+str(y)+" "+str(z))
      sys.exit()
print("-1 -1 -1")

Solution (Python):
N,Y = [int(x) for x in input().split()]

def func(N,Y):
    for m in range(N,-1,-1):
        for i in range(0,N-m+1):
            if 10000*m+5000*i+1000*(N-m-i)==Y:
                return m,i,N-m-i
                
    return -1,-1,-1
    
a,b,c=func(N,Y)
print(a,b,c)

Solution (Python):

"""
Created on Wed Mar 18 20:30:45 2020

@author: naoki
"""
import sys
N, Y = map(int, input().split())

for k in range(N+1):
    for j in range(N+1):
        if k+j > N:
            continue
        elif 10000*k + 5000*j + 1000*(N-k-j) == Y:
            print(k, j, N-k-j)
            sys.exit()
            
print(-1,-1,-1)

Solution (Python):
N,Y = map(int,input().split())
ans = []
for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    if 10000*i + 5000*j + 1000*k == Y:
      ans = [i,j,k]
if ans == []:
  ans = [-1, -1, -1]
print(ans[0],ans[1],ans[2],end =' ')

Solution (Python):


def main():
  N, Y = map(int, input().split())
  for i in range(0, N+1):
    for j in range(0, N+1):
      k = N - i - j
      if k < 0:
        continue
      if Y == 10000 * i + 5000 * j + 1000 * k:
        print(i, j, k)
        return
  print("-1 -1 -1")


if __name__ == "__main__":
    main()

Solution (Python):
N, Y = map(int, input().split())
ans = []
for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = [i, j, k]

if ans == []:
    ans = [-1, -1, -1]

print(ans[0], ans[1], ans[2])

Solution (Python):
N, Y = map(int, input().split())
ans = []
for i in range(N + 1):
    
    for j in range(N - i + 1):
        k = N - i - j
        if k < 0:
            break

        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = [i, j, k]

if ans == []:
    ans = [-1, -1, -1]

print(ans[0], ans[1], ans[2])

Solution (Python):
N, Y = map(int, input().split())
ans = []
for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if k < 0:
            break

        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = [i, j, k]

if ans == []:
    ans = [-1, -1, -1]

print(ans[0], ans[1], ans[2])

Solution (Python):
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        sen = Y - i*10000 - j*5000
        if sen >= 0 and (sen//1000+i+j) == N:
            print(i,j,sen//1000)
            exit()

print(-1,-1,-1)

Solution (Python):
n, y = [int(x) for x in input().split()]
a = b = c = -1
for i in range(n + 1):
    for j in range(n + 1):
        k = n - i - j
        if k < 0:
            continue
        else:
            if 10000 * i + 5000 * j + 1000 * k == y:
                a = i
                b = j
                c = k
print(a, b, c)

Solution (Python):
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)

Solution (Python):
import sys
n,y=map(int,input().split())
y//=1000
for i in range(n+1):
    for j in range(n-i+1):
        if i*10+j*5+(n-i-j)==y:
            print(i,j,n-i-j)
            sys.exit()

print(-1,-1,-1)

Solution (Python):
N, Y = map(int, input().split())
for i in range(N+1):
  for j in range(N - i + 1):
    if 10000 * i + 5000 * j + 1000 * (N-i-j) == Y:
      print('{} {} {}'.format(i,j,N-i-j))
      exit()
else:
  print('-1 -1 -1')

Solution (Python):
N,Y=map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            print(i,j,(N-i-j))
            exit()
else:
    print("-1 -1 -1")

Solution (Python):
import sys

N, Y = map(int, input().split())

for i in range(N + 1):
	for j in range(N - i + 1):
		if (10000 * i + 5000 * j + 1000 * (N - i - j)) == Y:
			print(i, j, N - i - j)
			sys.exit(0)

print("-1 " * 3)

Solution (Python):
n,y = map(int, input().split())
err = '-1 -1 -1'

for i in range(n+1):
    for j in range(n+1-i):
        if y == 10000 * (n-i-j) + 5000 * j + 1000 * i:
            ans = str(n-i-j) + " " + str(j) + " " +  str(i)
            break
        else:
            ans = err
    
    else:
        continue
    break

print(ans)

Solution (Python):
n, t = map(int, input().split())
sen = -1
gos = -1
man = -1
for i in range(n+1):
    for j in range(n-i+1):
        if i * 1000 + j*5000 + (n-i-j)*10000 == t:
            sen = i
            gos = j
            man = n-i-j
print(man, gos, sen)