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
N, Y = map(int, input().split())

for i in range((Y // 10000) + 1):
    for j in range((Y // 5000) + 1):
        tmp = N - i - j
        if tmp >= 0:
            ans = (i * 10000) + (j * 5000) + ((N - i - j) * 1000)
            if ans == Y:
                print(i, j, tmp)
                sys.exit()
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 - i):
        if 10000*i + 5000*j + 1000*(n - i - j) == y:
            print(i, j, n - i - j)
            sys.exit()
        
print(-1,-1,-1)

Solution (Python):
res1000=-1
res5000=-1
res10000=-1
n,y=map(int,input().split())
for x in range(n+1):
    for j in range(n+1-x):
        z=n-x-j
        if z>=0 and  y==10000*x+5000*j+1000*z:
            res10000=x
            res5000=j
            res1000=z
print(res10000,res5000,res1000)

Solution (Python):
res1000=-1
res5000=-1
res10000=-1
n,y=map(int,input().split())
for x in range(n+1):
    for j in range(n+1):
        z=n-x-j
        if z>=0 and  y==10000*x+5000*j+1000*z:
            res10000=x
            res5000=j
            res1000=z
print(res10000,res5000,res1000)

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

for i in range(N+1):
    for j in range(N + 1 - i):
        if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y:
            ans = "{} {} {}".format(i,j,(N - i - j))
            flg = 1
            break
if flg:
    print(ans)
else:
    print("-1 -1 -1")

Solution (Python):
import sys
n,y =map(int,input().split())
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)
      sys.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):
        c = N - a - b
        if c < 0:
            break
        total = a*10000 + b*5000 + c*1000
        if(total==Y):
            print(str(a)+' '+str(b)+' '+str(c))
            exit()

print('-1 -1 -1')

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

print(*result)

Solution (Python):
L = input().split()
N = int(L[0])
Y = int(L[1])
c = -1
d = -1
e = -1
for a in range(N + 1):
    for b in range(N + 1):
        if 10000*a + 5000*b + 1000*(N - a - b) == Y and N - a - b >= 0:
            c = a
            d = b
            e = N - a - b
        else:
            pass
print(str(c) + " " + str(d) + " " + str(e))

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

flg = True

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:
            ans = [x, y, z]
            flg = False
            break

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

print(' '.join(map(str, ans)))

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

flg = True

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:
            ans = [x, y, z]
            flg = False
            break

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

print(' '.join(map(str, ans)))

Solution (Python):
ny = list(map(int,input().split()))
n = ny[0]
y = ny[1]

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

print(" ".join(list(map(str, ans))))

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

for i in range(n+1):
    for j in range(n+1):
        k = n-(i+j) 
        sum = 10000 * i + 5000 * j
        if k >= 0 and (sum + 1000*k) == y:
            print(i,j,k)
            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):
        k = n-(i+j) 
        sum = 10000 * i + 5000 * j
        if k >= 0 and (sum + 1000*k) == y:
            print(i,j,k)
            quit()
print(-1,-1,-1)

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

count = 0
for a in range(N+1):
    y = 10000*a
    if y > Y:
        continue

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

        if total == Y and c >= 0:
            print("{} {} {}".format(a,b,c))
            count += 1
            break
    else:
        continue
    break

if count == 0:
    print("-1 -1 -1")

Solution (Python):
"""
【ABC085】
C - Otoshidama



import sys
from collections import Counter


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  
def MI(): return map(int, sys.stdin.readline().rstrip().split())        
def II(): return int(sys.stdin.readline().rstrip())                     
def S(): return sys.stdin.readline().rstrip()                           

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

Solution (Python):

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

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):
def resolve():
    n, y = map(int, input().split())

    for a in range(n + 1):
        for b in range(n + 1 - a):
            c = n - a - b
            if a * 10000 + b * 5000 + c * 1000 == y:
                print(*[a, b, c])
                return
    print("-1 -1 -1")
    
resolve()

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


flag = False
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("{} {} {}".format(x,y,z))
      flag = True
      break
  if flag:
    break

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

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

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

for i in range(N+1):
    for j in range(N+1-i):
        if 10*i+5*j+(N-i-j) == Y:
            print(i,j,N-i-j)
            flag = True
            break
    if flag:
        break

if flag is 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 i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Solution (Python):
import sys
from pprint import pprint

n, y = map(int, sys.stdin.readline().strip().split(" "))
yens = [10000, 5000, 1000]

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

print(-1, -1, -1)

Solution (Python):
n,y = map(int,input().split())
flag = 0
for i in range(int(y/10000 +1)):
    
    if flag == 0:
        for j in range(int(y/5000 + 1)):
            
            k = n - i - j
            if(k < 0):
                continue
            else:
                if(y == 10000*i + 5000*j + 1000*k):
                    print(i,j,k)
                    flag = 1
                    break
    else:break
if flag == 0:
    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-i+1):
        if y == 10000*i + 5000*j + 1000*(n-i-j):
            flag = True
            print(i,j,n-i-j)
            break
    if flag:
        break
if not flag:
    print(-1,-1,-1)

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

for a in range(N+1):
  for b in range(N+1-a):
    if 10000*a + 5000*b + 1000*(N-a-b) == Y and N-a-b >= 0:
      print("{} {} {}".format(a,b,N-a-b))
      quit()

print("-1 -1 -1")

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

for a in range(N+1):
  for b in range(N+1):
    if 10000*a + 5000*b + 1000*(N-a-b) == Y and N-a-b >= 0:
      print("{} {} {}".format(a,b,N-a-b))
      quit()

print("-1 -1 -1")

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

ans = 0
for i in range(0, N+1):
  pool = Y - i * 10000
  for j in range(0, (N+1) - i):
  
    if pool - 1000 * j - 5000 *(N - i - j) == 0:
      ans = -1
      break
  if ans != 0:
    break
  
if ans == -1:
  print(i, N - i - j, j)
else:
  print(-1, -1, -1)

Solution (Python):
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

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 10000*i + 5000*j + 1000*k == y:
                print(i, j, k)
                exit(0)
    print(-1, -1, -1)

    

input = lambda: stdin.readline().rstrip()
main()

Solution (Python):
n, y = map(int, input().split())
y /= 1000
ans = (-1, -1, -1)
flag = False
for i in range(n+1):
    for j in range(n-i+1):
        if 10*i+5*j+(n-i-j) == y and n-i-j>=0:
            ans = (i, j, n-i-j)
            flag = True
            break
    if flag:
        break
print(*ans)

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


x_max = yen // 10000
for i in range(x_max + 1):
    rest_x = yen - 10000 * i
    y_max = rest_x // 5000
    for j in range(y_max + 1):
        if (rest_x - 5000 * j) % 1000 == 0:
            k = (rest_x - 5000 * j) // 1000
            if i + j + k == n:
                print(i, j, k)
                sys.exit()

print(-1, -1, -1)

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

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

c = cond()
if c:
    print(c)
else:
    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-i+1):
    if 10000 * i + 5000 * j + (N - i - j) * 1000 == Y:
      ans = [i, j, (N-i-j)]
      
print(*ans)

Solution (Python):
def ans3_2():
    hasAnswer = False
    N, Y = map(int, input().split(" "))
    for x in range(Y // 10000 + 1):
        if hasAnswer == True: break
        for y in range((Y - x * 10000) // 5000 + 1):
            z = (Y - 10000 * x - 5000 * y) // 1000
            if z >= 0 and x + y + z == N:
                print(x, y, z, sep=" ")
                hasAnswer = True
                break
    if hasAnswer == False:
        print(-1, -1, -1, sep=" ")

ans3_2()

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

ok = False
for i in range(n + 1):
    for j in range(n - i + 1):
        s = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if y == s:
            res = ' '.join(map(str, [i, j, n - i - j]))
            ok = True
            break
    if ok:
        break
if ok:
    print(res)
else:
    print('-1 -1 -1')

Solution (Python):
def ans3():
    
    
    
    
    
    
    hasAnswer = False
    N, Y = map(int, input().split(" "))
    for x in range(Y // 10000 + 1):
        y = (Y - 1000 * N - 9000 * x) // 4000
        z = N - x - y
        nt = x + y + z
        ny = 10000 * x + 5000 * y + 1000 * z
        if y >= 0 and z >= 0 and nt == N and ny == Y:
            print(x, y, z, sep=" ")
            hasAnswer = True
            break
    if hasAnswer == False:
        print(-1, -1, -1, sep=" ")

ans3()

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 and i + j + k == n:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

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





tmp = Y // 1000 - N
b_max = tmp // 4

for i in range(b_max+1):
    uhe = tmp - 4 * i
    if uhe % 9 == 0:
        
        b = i
        c = (tmp - 4 * b) // 9
        a = N - b - c

        if a >= 0:
            print(c,b,a)
            exit()

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 9*x+4*y==Y*(10**(-3))-N and z>=0:
            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+1):
        z=N-x-y
        if 9*x+4*y==Y*(10**(-3))-N and z>=0:
            print(x,y,z)
            exit()

print("-1 -1 -1")

Solution (Python):
n, y = [ int(v) for v in input().split() ]
y =  y // 1000


ans_list = []
for i in range(y//10+1):
    y2 = y - 10*i
    for j in range(y2//5+1):
        y3 = y2 - 5*j
        if i + j + y3 == n:
            ans_list.append((i,j,y3))

if ans_list != []:
    print(*ans_list[0])
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):
        if i + j > n or i * 10000 + j * 5000 > y:
            break
        elif y - i * 10000 - j * 5000 == (n - i - j) * 1000:
            print(i, j, (n - i - j))
            exit()
print(-1, -1, -1)

Solution (Python):


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



num = [-1]*3


for i in range(0, n+1):
    
    for j in range(0, n+1-i):
        
        k = n - i - j
        
        sum = i * 10000 + j * 5000 + k * 1000
        if sum == y:
            
            num[0] = i
            num[1] = j
            num[2] = k
            break


print(" ".join(map(str, num)))

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

if l == []:
    print(' '.join(map(str, [-1, -1, -1])))
else:
    print(' '.join(map(str, l)))

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

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

for y in range(n+1):
    for z in range(n-y+1):
        x = n-(y+z)
        if 5*y+9*z == n*10-Y*(10**(-3)) and x >= 0:
            print(x,end="  ")
            print(y,end=" ")
            print(z,end="")
            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):
        k = N - i - j
        y = i * 10000 + j * 5000 + k * 1000
        if y == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Solution (Python):
N, Y = list(map(int,input().split()))
flag = 0
for i in range(N+1):
  for j in range(N+1-i):
    total = 10000 * i + 5000 * j + 1000 * (N-i-j)
    if Y == total:
      I = i
      J = j
      K = N - i - j
      flag += 1

if flag == 0:
  print(-1,-1,-1)
else:
  print(I,J,K)

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 Y == 10000*x + 5000*y + 1000*z and 0 <= z:
			print(x, y, z)
			break
	if Y == 10000*x + 5000*y + 1000*z and 0 <= z:
			break
else:
	print(-1, -1, -1)

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

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

A=0
B=0
C=int(Y/1000)
i=0
for j in range(2*10**7):
    for i in range(C,-1,-5):
        if((A+B+i)==N):
            print(A,B,i)
            exit()
        B+=1
    if((A+B+i)==N):
            print(A,B,i)
            exit()
    A+=1
    C-=10
    B=0
    if((10*A+5*B+i)>(Y/1000)):
        print("-1 -1 -1")
        exit()
print(A,B,i)

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

A=0
B=0
C=int(Y/1000)
i=0
for j in range(2*10**7):
    for i in range(C,-1,-5):
        if((A+B+i)==N):
            print(A,B,i)
            exit()
        B+=1
    if((A+B+i)==N):
            print(A,B,i)
            exit()
    A+=1
    C-=10
    B=0
    if((10*A+5*B+i)>(Y/1000)):
        print("-1 -1 -1")
        exit()
print(A,B,i)

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)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

Solution (Python):
import sys
N,Y=list(map(int,open(0).read().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 == Y:
      print(x,y,z)
      sys.exit()
print(-1,-1,-1)

Solution (Python):
import sys
N,Y=list(map(int,open(0).read().split()))


for x in range(N+1):
  for y in range(N+1):
    if sum([x,y])<=N:
      z = N - (x + y)
      if x*10000+y*5000+z*1000 == Y:
        print(x,y,z)
        sys.exit()
print(-1,-1,-1)

Solution (Python):
VALUES = [10000, 5000, 1000]

(bills, money) = (int(tok) for tok in input().split())
res = (-1, -1, -1)

for i in range(bills + 1):
  for j in range(bills - i + 1):
    k = bills - i - j
    curr_money = i * VALUES[0] + j * VALUES[1] + k * VALUES[2]
    
    if curr_money == money:
      res = (i, j, k)

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

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

    if Y > 10000*N or Y < 1000*N: return -1, -1, -1

    for i in range(N, -1, -1):
        for j in range(N-i, -1, -1):
            v = 10000 * i + 5000 * j
            if Y-v >= 0:
                k = (Y - v) // 1000
                if i + j + k == N:
                    return i, j, k
    return -1, -1, -1

if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

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

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

Solution (Python):
N,Y = map(int,input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        if x+y >N:
            break
        else:
            money = 10000*x + 5000*y + 1000*(N-x-y)
            if money == Y:
                count=1
                print('{} {} {}'.format(x,y,N-x-y))
                break
    if count == 1:
        break
if count == 0:
    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 = input().split()
n = int(n)
yen = int(y)

for x in range(n+1):
  for y in range(n+1):
    z = (yen - 10000*x - 5000*y)/1000
    if z>=0:
      z = int(z)
      if (x+y+z)==n:
        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 i+j > n:
            break
        elif 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 a in range(n+1):
    for b in range(n+1):
        if 10000*a + 5000*b + 1000*(n-(a+b)) == y and n-(a+b) >= 0:
            print(a,b,n-(a+b))
            exit()
print("-1 -1 -1")

Solution (Python):
n,y = map(int,input().split())
y /= 1000
fin = False
for i in range(n+1):
    for j in range(i,n+1):
        if 10*i + 5*(j-i) + n-j == y:
            print("{} {} {}".format(i,j-i,n-j))
            fin = True
            break
    if fin:
        break
if not fin:
    print("-1 -1 -1")

Solution (Python):


import sys

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

for a in range(n + 1):
    for b in range(n + 1 - a):
        total = 10000 * a + 5000 * b + \
            1000 * (n - a - b)
        if total == y:
            print("{} {} {}".format(a, b, n - a - b))
            sys.exit()
print("{} {} {}".format(-1, -1, -1))

Solution (Python):
def calc(num, value):
    for i in range(num + 1):
        for j in range(num - i + 1):
            k = num - i - j
            if i * 10000 + j * 5000 + k * 1000 == value:
                print(i, j, k)
                return True

    return False

num, value = input().split()
num = int(num)
value = int(value)

if not calc(num, value):
    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):
    k=n-i-j
    if 10000*i+5000*j+1000*k==y:
      print(i,j,k)
      sys.exit()
print('-1 -1 -1')

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

sen = 1000
gosen = 5000
man = 10000
flag = 0
for i in range(n+1):
  if flag == 1:
    break
  for j in range(n+1-i):
    sum = man*i + gosen*j + sen*(n-i-j)
    if sum == yen:
      print(str(i) + ' ' + str(j) + ' ' + str(n-i-j))
      flag = 1
      break

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

Solution (Python):
N,Y=map(int, input().split())
for a in range(N+1):
    for b in range(0,N-a+1):
        c=N-a-b 
        if (a*10000+b*5000+c*1000)==Y:
            print(a,b,c)
            exit()


print(-1,-1,-1)

Solution (Python):
N,Y=map(int,input().split())
Y//=1000
x,y,z=-1,-1,-1
for i in range(min(N,Y//10),-1,-1):
    n=N-i
    t=Y-10*i
    for j in range(min(n,t//5),-1,-1):
        if n-j==t-5*j:
            x,y,z=i,j,n-j
            break
    else:continue
    break
print(x,y,z)

Solution (Python):
N,Y=map(int,input().split())
Y//=1000
x,y,z=-1,-1,-1
for i in range(min(N,Y//10),-1,-1):
    n=N-i
    t=Y-10*i
    for j in range(min(n,t//5),-1,-1):
        if n-j==t-5*j:
            x,y,z=i,j,n-j
            break
    else:continue
    break
print(x,y,z)

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):
from sys import exit


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

res = 0

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

if res == 0:
    print('{} {} {}'. format(-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):
num = input().split()
 
n = int(num[0])
y = int(num[1])

m = 0
g = 0
s = 0

flag = False


for i in range(n+1):
    if flag:
        break
    m = i
    
    me = m * 10000
    
    if (y - me) / 5000 <= n: 
    
        for e in range(n+1):
            if flag:
                break
            g = e
            
            ge = g * 5000
            
            tmpS =  y - (me+ge)
            
            if (tmpS / 1000) + (m+g) == n and me+ge+tmpS == y and (tmpS / 1000) >= 0:
                flag = True
                ma = m
                ga = g
                if tmpS / 1000 > 0:
                    sa = tmpS / 1000
                    sa = int(sa)
                else: 
                    sa = 0
if flag:
    print(ma,ga,sa)
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):
		if (y-(10000*i+5000*j))/1000\
		==n-i-j and n-i-j>=0:
			print(i,j,n-i-j)
			exit()
print(-1,-1,-1)

Solution (Python):
N,Y = map(int,input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
    for j in range(N-i+1):
        bet=Y-(10000*i+5000*j+1000*(N-i-j))
        if bet == 0:
            x=i
            y=j
            z=N-i-j
            break
        
d=[x,y,z]
print(d[0])
print(d[1])
print(d[2])

Solution (Python):
n,y = map(int,input().split())
man,gosen,sen=0,0,0
man_max = y//10000
flag=False

for i in range(man_max+1):
  man = man_max-i
  
  temp_y = y - 10000*man
  temp_n = n - man
  gosen_max = temp_y//5000
  for j in range(gosen_max+1):
    gosen = gosen_max-j
    
    temp_temp_y = temp_y - 5000*gosen 
    temp_temp_n = temp_n - gosen
    if temp_temp_y/1000==temp_temp_n:
      sen = temp_temp_n
      flag=True
      break
  if flag:
    break

if flag:
  print(str(man) + " " + str(gosen) + " " + str(sen))
else:
  print("-1 -1 -1")

Solution (Python):
n,y=map(int,input().split())
ans=[-1]*3
for i in range(n+1):
    for j in range(n-i+1):
        k=(y-i*10000-j*5000)//1000
        if i+j+k==n:
            ans=[i,j,k]
            break
print(*ans)

Solution (Python):
import sys
nums , money = map(int,input().split())

for i in range(nums+1):

    for x in range( nums +1 -i):

        if (i * 10000) + (x *5000) + ((nums -(i+x))*1000) == money:
            print(str(i) +" " + str(x) +" " +str((nums -(i +x))))
            sys.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 i * 10000 + j*5000 + (N-i-j)*1000 ==Y:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

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

for x in range(N+1):
	for y in range(N+1-x):
		z = (Y - 10000*x - 5000*y) // 1000
		if z == N-x-y:
			print(x,y,z,sep = " ")
			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):
        s = y-(i*10000+j*5000)
        k = n-(i+j)
        if k*1000==s:
            print(i, j, k)
            exit(0)

print(-1, -1, -1)

Solution (Python):
n,y = map(int,input().split())
import sys
for a in range(n+1):
    for b in range(n-a+1):
        c=n-a-b
        if 10000*a+5000*b+1000*c==y:
            print(a, b, c)
            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())
detect = 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 and i + j + k == n:
            detect = True
            print(i,j,k)
            break
    if detect:
        break            
if not detect:
    print(-1,-1,-1)

Solution (Python):
N,Y = map(int,input().split())
count = 0
for i in range(N + 1):
  for j in range(N + 1 - i):
    if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y and N - i - j >= 0:
      x = str(i)+ ' ' + str(j) + ' ' + str(N - i - j)
      count += 1
      break
      
if count == 0:
  print('-1 -1 -1')
else:
  print(x)

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

Solution (Python):
n,y=map(int,input().split())
array=[-1,-1,-1]
for i1 in range(n+1):
  for i2 in range(n+1-i1):
    if 10000*i1+5000*i2+1000*(n-i1-i2)==y:
      array=[i1,i2,n-i1-i2]
      break
print(array[0],array[1],array[2])

Solution (Python):
N,Y = map(int,input().split())
x = y = z = 0
for i in range(N,-1,-1):
    if i*10000 <= Y:
        charge = Y - i*10000
        rest = N - i
        for j in range(rest,-1,-1):
            if j*5000 <= charge:
                if charge - j*5000 - (rest-j)*1000 == 0:
                    print('{0} {1} {2}'.format(i, j ,rest-j))
                    exit(0)
print('-1 -1 -1')

Solution (Python):
N,Y = map(int,input().split())
for x in range(0,N+1):
    for y in range(0,N-x+1):
        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())
ansx=-1
ansy=-1
ansz=-1
for x in range(N+1):
    for y in range(N+1-x):
        z= N-x-y
        total = 10000*x + 5000*y + 1000*z
        if total== Y:
            ansx=x
            ansy=y
            ansz=z
            break
print("{} {} {}".format(ansx, ansy, ansz))

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

foundFlg = False
for x in range(N+1):
    for y in range(N+1):
        if x + y > N:
            break
        z = N - x - y
        if z >= 0 and x*10000+y*5000+z*1000 == Y:
            print("{} {} {}".format(x, y, z))
            foundFlg = True
            break
        if foundFlg:
            break
    if foundFlg:
        break

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

Solution (Python):
N, Y = map(int, input().split())
ans = 0
found = False

Y //= 1000

T = 0
for i in range(Y // 10 + 1):
    for j in range((Y - i * 10) // 5 + 1):
        T += 1
        x = Y - i * 10 - j * 5
        if x < 0:
            break
        if i + j + x == N:
            print(i, j, x)
            found = True
            break
    if found:
        break
if not found:
    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 x * 10000 + y * 5000 + z * 1000 == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

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

ans = ['-1', '-1', '-1']

money = 0
for i in range(N+1):
  for j in range(N+1-i):
    money = 10000 * i + 5000 * j + 1000 * (N - i - j)
    if (money == Y):
      ans = [str(i), str(j), str(N - i - j)]
      break
print(" ".join(ans))