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):
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n+1):
    if (n-i-j) >= 0 and i*10000 + j*5000 + (n-i-j)*1000 == y:
      print(*[i,j,(n-i-j)])
      quit()
print("-1 -1 -1")

Solution (Python):
N,Y = map(int, input().split())
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 and 0 <= z <= 2000:
            print(x,y,z)
            exit()


print("-1 -1 -1")

Solution (Python):
n,y=map(int,input().split())
for a in range(0, min(n, y // 10000)+1):
    for b in range(0, min(n, y // 5000)+1):
        c=n-a-b
        if c>=0 and a*10000+b*5000+c*1000==y:
            print(a,b,c)
            exit()
print(-1,-1,-1)

Solution (Python):
s=list(map(int,input().split()))
ans=[]
a=int(s[1]/10000)
b=int(s[1]/5000)
c=int(s[1]/1000)
for i in range(0,a+1):
    for j in range(0,b+1):
        if(s[0]-i-j>=0):        
            check=10000*i+5000*j+1000*(s[0]-i-j)
            if(check==s[1]):
                ans.append(i)
                ans.append(j)
                ans.append(s[0]-i-j)
                break
                
if(ans==[]):
    print('-1 -1 -1')
else:
    print('{} {} {}'.format(ans[0],ans[1],ans[2]))

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

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

      
print(x,y,z)

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

if y % 1000 != 0:
    print('-1 -1 -1')
else:
    y //= 1000
    for man in range((y - n)//9 + 1):
        if (y - n - 9 * man) % 4 == 0:
            go = (y - n - 9 * man) // 4
            if (n - man - go) >= 0:
                print(man, go, n - man - go)
                break
    else:
        print('-1 -1 -1')

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

q = Y//1000 - N

x = [0, 4, 8, 3, 7, 2, 6, 1, 5]

B = x.index(q%9)
b = B
while 4*b <= q:
    c = (q - 4*b) // 9
    a = N-c-b
    if a<0:
        b += 9
        continue
    else:
        print(c, b, a)
        break
else:
    print(-1, -1, -1)

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

q = Y//1000 - N

x = [0, 4, 8, 3, 7, 2, 6, 1, 5]

B = x.index(q%9)
b = B
while 4*b <= q:
    c = (q - 4*b) // 9
    a = N-c-b
    if a<0:
        b += 9
        continue
    else:
        print(c, b, a)
        break
else:
    print(-1, -1, -1)

Solution (Python):
n,Y=map(int, input().split())
a=-1,-1,-1
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:
        a=x,y,z
        break
print(*a)

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

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

Solution (Python):
N, Y = map(int, input().split())
exist_comb = False
res10000 = -1
res5000 = -1
res1000 = -1

for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    Sum = 10000*i + 5000*j + 1000*k
    if Sum == Y:
      res10000 = i
      res5000 = j
      res1000 = k

print("{} {} {}".format(res10000, res5000, res1000))

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

count = 0

for x in range(N+1):
    for y in range(N+1-x):
        if 10000*x+5000*y+1000*(N-x-y) == Y:
            count += 1
            print("{} {} {}".format(x, y, N-x-y))
            if count == 1:
                break
    if count == 1:
                break

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

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

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

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

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

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

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
        A=Y-10000*x-5000*y-1000*z
        if A==0:
            answer=[x, y, z]

print(*answer)

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
        A=Y-10000*x-5000*y-1000*z
        if A==0:
            answer=[x, y, z]

print(*answer)

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

Solution (Python):

"""
Created on Wed Sep 23 15:20:49 2020

@author: liang
"""

N, Y = map(int, input().split())
y = Y //1000

a = 0
while a <= N and y - 10*a >=0:
    bt = y - N - 9*a
    ct = 5*N - y + 5*a
    if bt < 0 or ct < 0:
        a += 1
        continue
    if bt % 4 == 0 and ct % 4 == 0:
        b = bt//4
        c = ct//4
        print(a,b,c)
        break
    a += 1
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):
        k = N - j - i
        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]
if 10000 * n >= y:
    for i in range((y//10000)+1):
        for j in range(n-i+1):
                if 10000 * i + 5000 * j + 1000 * (n-i-j) == y:
                    ans = [i,j,n-i-j]
print(*ans)

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, -1, -1)

Solution (Python):
N, Y = map(int, input().split())
a = min(Y // 10000, N) + 1
for i in range(a):
  b = min((Y - (10000 * i)) // 5000, N - i) + 1
  for j in range(b):
    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())

loop_break = False
for M in range(2002):
    total = 10000 * M
    if total > Y:
        print(-1, -1, -1)
        break
    for G in range(N - M + 1):
        S = N - M - G
        total += 5000 * G + 1000 * S
        if total == Y:
            print(M, G, S)
            loop_break = True
            break
        else:
            total = 10000 * M
    if loop_break:
        break

Solution (Python):
def main():
  n, y = map(int, input().split())
  y //= 1000
  for i in range(n + 1):
    if i * 10 > y:
      break
    for j in range(n + 1):
      if i * 10 + j * 5 > y:
        break
      k = n - i - j
      if i * 10 + j * 5 + k == y:
        print(i, j, k)
        return
  print(-1, -1, -1)

main()

Solution (Python):


def main():
    n, y = map(int, input().split())

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


if __name__ == "__main__":
    main()

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

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

if __name__ == '__main__':
	main()

Solution (Python):
n,y=map(int,input().split())
count=0
for i in range(n+1):
  for j in range(n+1):
    k=n-i-j
    if k>=0 and k<=n:
      if i*10000+j*5000+k*1000==y:
        print(i,j,k)
        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) < 0:
            break
        if 9*i+4*j+n == y:
            print(i,j,n-(i+j))
            exit()
print('-1','-1','-1')

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

a = -1
b = -1
c = -1
judge = False

for x in range(N, -1, -1):
    money_max = x * 10000 + (N-x) * 5000
    money_min = x * 10000 + (N-x) * 1000
    if money_min <= Y and Y <= money_max:
        for y in range(N-x, -1, -1):
            money = x * 10000 + y * 5000 + (N - x - y)* 1000
            if money == Y:
                a = x
                b = y
                c = N - (x + y)
                judge = True
                break
    if judge:
        break
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
print(*answer)

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

for i in range(0, N+1, 1):
  isFinish = False
  for j in range(0, N+1-i, 1):
    sen = 1000 * i
    gosen = 5000 * j
    man = 10000 * (N - i - j)
    
    if sen + gosen + man == Y:
      print(N - i - j, j, i)
      isFinish = True
      break
  
  if isFinish:
    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-i+1):
        k = N- i - j
        if  2000 >= k >= 0 and 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):
    a = 10000*x
    for y in range(0, (N+1)-x):
        b = 5000*y
        z = N-(x+y)
        c = 1000*z
        if (a+b+c) == Y:
            ans = [x, y, z]
            break
ans = map(str, ans)
print(" ".join(ans))

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

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

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

y //= 1000

for a in range(0, n + 1):
    if a * 10 > y:
        break
    for b in range(0, n + 1):
        x = a * 10 + b * 5
        if x > y:
            break
        c = n - a - b
        if y == x + c:
            print(f"{a} {b} {c}")
            exit(0)
print("-1 -1 -1")

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

a1 = -1
b1 = -1
c1 = -1
for i in range(N+1):
    for j in range(N+1-i):
        total = 10000*i+5000*j+1000*(N-i-j)
        if total == Y:
            a1 = i
            b1 = j
            c1 = N-i-j

print(str(a1)+" "+str(b1)+" "+str(c1))

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) and z >= 0:
            print(x, y, z)
            exit()

print(-1, -1, -1)

Solution (Python):


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

main()

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

print('-1 -1 -1')

Solution (Python):
n,y=map(int,input().split())
for i in range(y//10000+1):
    for j in range(y//5000+1):
        if n-i-j>=0 and 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 + 1):
        k = N - i - j
        if k >= 0 and 10000 * i + 5000 * j + 1000 * k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Solution (Python):

import sys
sys.setrecursionlimit(10**6)

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


for i in range(max(n+1, y//10000)):
    y_new = y-10000*i
    n_new = n-i

    if (5000*n_new-y_new) % 4000 == 0:
        x = (5000*n_new-y_new) // 4000

        if n_new-x >= 0 and x >= 0:
            
            
            print(i, n_new-x, x)
            exit()


print(-1, -1, -1)

Solution (Python):
def main():  
  N, Y = map(int,input().split())
  Cash = [10000, 5000, 1000]
  for x in range(N+1):
    for y in range(N+1):
      Rem = Y - (10000*x + 5000*y)
      Rem = Rem//1000
      if Rem == (N - x - y) and Rem >=0:
        print(x, y, Rem)
        return 
  print(-1, -1, -1)
  return

main()

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

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

for a in range(n+1):
    for b in range(n+1):
        c = max(n - (a + b), 0)
        if a+b+c == n and 10000*a + 5000*b + 1000*c == y:
            print(a, b, c)
            exit()
print(-1, -1, -1)

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

Solution (Python):

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

Y //= 1000

for n1 in range(N+1):
    y = Y-n1
    n = N-n1

    if y%5 != 0:
        continue
    n10 = (y-5*n)//5
    n5 = n-n10

    if n10 < 0 or n5 < 0:
        continue

    if n1+n5*5+n10*10 == Y:
        n5 = n-n10
        break
else:
    n1,n5,n10 = -1,-1,-1

print(n10,n5,n1)

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

for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if k < 0:
            continue
        if i * 1000 + j * 5000 + k * 10000 == Y:
            print(k, j, i)
            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-x):
        p = x*10000 + y*5000
        if p > Y: break
        rem = Y - p
        z = rem//1000
        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):
    if (Y - 1000*N -9000*i) % 4000 == 0:
        b = (Y - 1000*N -9000*i) // 4000 
        c = N - i - b
        if b >= 0 and c >= 0:
            print(i,b,c)
            exit()
print("-1 -1 -1")

Solution (Python):
l = list(map(int,input().split()))
N = l[0]
Y = l[1]

l = list()

for i in range(N+1):
    a = i
    if (Y - 1000*N -9000*a) % 4000 == 0:
        b = (Y - 1000*N -9000*a) // 4000 
        c = N - a - b
        if a >= 0 and b >= 0 and c >= 0:
            l.append([a,b,c])
            break

if len(l) ==0:
    print("-1 -1 -1")
else:
    ans = l[0]
    print(ans[0],ans[1],ans[2])

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


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

Solution (Python):
def main():
    n_money, y_yen = map(int, input().split())
    
    a, b, c = 10000, 5000, 1000
    for x in range(n_money+1):
        for y in range(n_money-x+1):
            z = n_money - x - y
            money = a * x + b * y + c * z
            if money == y_yen:
                print(f'{x} {y} {z}')
                return 0
    print('-1 -1 -1')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n_money, y_yen = map(int, input().split())
    
    a, b, c = 10000, 5000, 1000
    for x in range(n_money+1):
        for y in range(n_money-x+1):
            z = n_money - x - y
            money = a * x + b * y + c * z
            if money == y_yen:
                print(f'{x} {y} {z}')
                return 0
    print('-1 -1 -1')


if __name__ == '__main__':
    main()

Solution (Python):


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


 



x,y,z = 0,0,0
total = 0
flg=0

for i in range(N+1):
    for j in range(0,N-i+1):
        if flg==0:
            x=i
            y=j
            z=N-x-y
            total = x*10000 + y*5000 + z*1000
            
            
    
            if total == Y:
                print(x,y,z)
                flg = 1

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

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

Solution (Python):
n,y=map(int,input().split())
for i in range(n+1):
 for j in range(n-i+1):i*9+j*4+n==y/1e3<exit(print(i,j,n-i-j))
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):
        k = N-i-j
        if 10000*i + 5000*j + 1000*k == Y:
            x = i
            y = j
            z = k
            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 1000*i + 5000*j + 10000*(n-i-j) == y:
            print(n-i-j, j, i)
            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-x+1):
        z = n-(x+y)
        if z >= 0 and 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.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-x+1):
        z = n-(x+y)
        if z >= 0 and 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)

Solution (Python):
import re
import copy
import numpy as np

def accept_input():
    N,Y = map(int,input().split())
    return N,Y

N,Y = accept_input()

man_result = -1
gosen_result = -1
sen_result = -1
for man in range(N+1):
    if man*10000 > Y:
        break
    for gosen in range(N+1-man):
        if man*10000 + gosen*5000 > Y:
            break
        elif man*10000+gosen*5000+(N-man-gosen)*1000 == Y:
            man_result = man
            gosen_result = gosen
            sen_result = (N-man-gosen)
            break
    if man_result != -1 or gosen_result != -1 or sen_result != -1:
        break
if man_result != -1 or gosen_result != -1 or sen_result != -1:
    print(str(man_result)+" "+str(gosen_result)+" "+str(sen_result)+" ")
else:
    print(str(man_result)+" "+str(gosen_result)+" "+str(sen_result)+" ")

Solution (Python):
A=10000
B=5000
C=1000
ans_A=-1
ans_B=-1
ans_C=-1
x,y=map(int,input().split())
for a in range(x+1):
  for b in range(x-a+1):
    c=x-a-b
    if a*A+b*B+c*C==y:
      ans_A=a
      ans_B=b
      ans_C=c
print(ans_A,ans_B,ans_C)

Solution (Python):
import sys
N,Y = map(int,input().split())
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)
            sys.exit()
print(-1,-1,-1)

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

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

Solution (Python):
"""
tuple
"""
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 0 <= z <=2000 and (10000*x+5000*y+z*1000)==Y:
            ans = x,y,z
            break
        else :
            continue
        break
print(*ans)

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 i*10000+j*5000+(n-i-j)*1000==y:
            ans = i, j, (n-i-j)
print(*ans)

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()
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 i*10000+j*5000+(n-i-j)*1000==y:
            ans = i, j, (n-i-j)
            break
    else:
        continue
    break
print(*ans)

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 i*10000+j*5000+(n-i-j)*1000==y:
            ans = i, j, (n-i-j)
print(*ans)

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

ans = [-1, -1, -1]
findit = False
sen = 0
for man in range(N + 1):
    if findit == True:
        break
    for gosen in range(N + 1):
        if findit == True:
            break
        sen = N - man - gosen
        if (man * 10000) + (gosen * 5000) + (sen * 1000) == Y and 0 <= sen:
            ans = [man, gosen, sen]
            findit = True

str_ans = map(str, ans)
print(" ".join(str_ans))

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

ans = [-1, -1, -1]
findit = False
sen = 0
for man in range(N + 1):
    for gosen in range(N + 1):
        sen = N - man - gosen
        if (man * 10000) + (gosen * 5000) + (sen * 1000) == Y and 0 <= sen:
            ans = [man, gosen, sen]

str_ans = map(str, ans)
print(" ".join(str_ans))

Solution (Python):
N,Y=map(int,input().split())
flag=False
for i in range(0,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)
            flag=True
            break
    if flag:
        break
else:
    print(-1,-1,-1)

Solution (Python):
mycode = r'''








ctypedef long long LL

import numpy as np


import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline 

def exit(*argv,**kwarg):
    print(*argv,**kwarg)
    sys.exit()


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)

cdef LL i,j,k,_

cdef LL N,Y
N,Y=ints()
Y//=1000

cdef LL a,b,c 
for a in range(N+1):
    for b in range(N+1):
        c = N-a-b
        if c<0 : break
        if 10*a+5*b+c==Y:
            exit(a,b,c)
print(-1,-1,-1)
        


'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

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

print(x,y,z)

Solution (Python):
import sys
input = sys.stdin.readline
N, Y = map(int, input().strip("\n").split())
for x in range(N + 1):
    for y in range(N - x + 1):
        remainder = Y - 10000 * x - 5000 * y
        if (N - x - y) * 1000 == remainder:
            print(" ".join([str(x), str(y), str(N - x - y)]))
            exit(0)
print("-1 -1 -1")

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

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

for a in range(N + 1):
    for b in range(N + 1):
        c = N - (a + b)
        if isinstance(c, float) or c < 0:
            continue
        if Y == 10000*a + 5000*b + 1000*c:
            print(a,b,c)
            count += 1
            break
    else:
        continue
    break

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

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

for ykt in range(0, N+1):
    for icy in range(0, N+1):
        hdy = N - ykt - icy
        if hdy < 0:
            continue
        if 10000 * ykt + 5000 * icy + 1000 * hdy == Y:
            print(str(ykt) + ' ' + str(icy) + ' ' + str(hdy))
            exit()

print('-1 -1 -1')

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

a,b,c=-1,-1,-1

for i in range(n+1):
  for j in range(n+1):
    h=n-i-j
    if 10000*i+5000*j+1000*h==y and h>=0:
      a,b,c=i,j,h
      break

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

Solution (Python):
N, Y = map(int, input().split())
Y //= 1000
i = 0
f = 0
while 1:
  if 10 * i > Y:
    break
  y = Y - 10 * i
  n = N - i
  if n <= y <=  5 * n and (y - n) % 4 == 0:
    print(str(i) + " " + str((y-n)//4) + " " + str((5 * n - y) // 4))
    f = 1
    break
  i += 1
if f == 0:
  print("-1 -1 -1")

Solution (Python):


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

import sys

tmp = y - 1000*n

a = y // 10000

for i in reversed(range(a+1)):
    for j in range((y - 10000*i) // 5000 + 1):
        if 9000*i + 4000*j == tmp:
            print(i,j,n-i-j)
            sys.exit()
print(-1,-1,-1)

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

main()

Solution (Python):
i = [int(i) for i in input().split()]
N = i[0]
Y = i[1]



sum = 10*N - Y/1000
for y in range(N+1):
    for z in range(N-y+1):
        if sum == 5*y + 9*z:
            print(str(N-y-z) + " " + str(y) + " " + str(z))
            exit()
print("-1 -1 -1")

Solution (Python):
i = [int(i) for i in input().split()]
N = i[0]
Y = i[1]



sum = 10*N - Y/1000
for y in range(N+1):
    for z in range(N-y+1):
        if sum == 5*y + 9*z:
            print(str(N-y-z) + " " + str(y) + " " + str(z))
            exit()
print("-1 -1 -1")

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

x = -1
y = -1
z = -1

if Y <= N*10000 :
  for i in range(N+1):
    for j in range(N-i+1):
      if Y == i*10000 + j*5000 + (N-i-j)*1000:
        x = i
        y = j
        z = N-i-j
        break

print(f"{x} {y} {z}")

Solution (Python):




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

ans_i = -1
ans_j = -1
ans_k = -1

for i in range(n+1):
    if ans_i != -1:
        break
    for j in range(n+1-i):
        if n-i-j>=0 and i + j*5 + (n-i-j)*10 == y:
            ans_i = i
            ans_j = j
            ans_k = n-i-j
            break

print(ans_k, ans_j, ans_i)

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

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,Y = mint()

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

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