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,yen = map(int,input().split())
isOK = False
for x in range(yen//10000+1):
    for y in range(yen//5000+1):
        if (n - x - y) >= 0:
            if yen == 10000 * x + 5000 * y + 1000 * (n - x - y):
                isOK = True
                break
    else:
        continue
    break
if isOK:
    print(x,y,n-x-y)
else:
    print(-1,-1,-1)

Solution (Python):
N, Y = map(int, input().split())
x, y, z = -1, -1, -1

for i in range(N + 1):
	for j in range(N + 1 - i):
		k = (Y - i * 10000 - j * 5000) / 1000
		if k == N - i - j:
			x, y = i, j
			z = int(k)
			break
	else:
		continue
	break

print(x, y, z)

Solution (Python):
n, y = map(int, input().split())
y = y // 1000
for a in range(n+1):
    b = (y - n - 9 * a) // 4
    c = n - a - b
    if 0 <= b and 0 <= c and a * 10 + b * 5 + c == y:
        print(a,b,c)
        exit(0)
print(-1,-1,-1)

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

for a in range(n+1):
    b = (y - n - 9 * a) // 4
    c = n - a - b
    if 0 <= b and 0 <= c and a * 10 + b * 5 + c == y:
        print(a,b,c)
        exit(0)
else:
    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-x+1):
        z = N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z == Y:
            ans = x,y,z
            break
        else:
            continue
        break
print(*ans)

Solution (Python):
import sys

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

x = Y // 10000

for i in range(x+1):
    y = (Y - i*10000) // 5000
    for j in range(y+1):
        zan = Y - i*10000 - j*5000
        if zan < 0:
            continue
        else:
            z = zan//1000
            if (zan % 1000 == 0) and (N==i+j+z):
                print(i,j,z)
                sys.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):
    z = N - x - y
    if z >= 0 and 10000*x + 5000*y + 1000*z == Y:
      print(str(x)+" "+str(y)+" "+str(z))
      exit()
print("-1 -1 -1")

Solution (Python):
n,Y=input().split(" ")
n=int(n)
Y=int(Y)
y=Y/1000
def counting(n,y):
    u=0
    for a in range(n+1):
        u=n-a
        for b in range(u+1):
            if 9*a+4*b-y+n==0:
                c=n-(a+b)
                a=str(a)
                b=str(b)
                c=str(c)
                l=" ".join([a,b,c])
                return (l)
                break
    else:
        return("-1 -1 -1")
print(counting(n,y))

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

Solution (Python):
N,Y = map(int,input().split())
count = 0
for x in range(N+1):
    i = 10000 * x
    for y in range(N-x+1):
        j = 5000 * y
        if((Y-i-j)/1000+x+y == N and i+j+(N-x-y)*1000 == Y):
            count = 1
            z = N - x - y
            f_x=x
            f_y=y
            f_z=z
                
if(count == 1):
    print(str(f_x)+" "+str(f_y)+" "+str(f_z))
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+1-i):
        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 = [int(x) for x in input().split()]

c10000 = -1
c5000 = -1
c1000 = -1

for a in range(N + 1):
    for b in range(N - a + 1):
        c = N - a - b
        total = 10000 * a + 5000 * b + 1000 * c
        if total == Y:
            c10000 = a
            c5000 = b
            c1000 = c
            break

print(str(c10000) + ' ' + str(c5000) + ' ' + str(c1000))

Solution (Python):
N, Y = map(int, input().split())
Y //= 1000
for nog in range(N + 1):
    for hig in range(N + 1 - nog):
        yuk = N - nog - hig
        if nog + hig * 5 + yuk * 10 == Y:
            print(yuk, hig, nog)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Solution (Python):
import sys

input = sys.stdin.readline

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

Aohashi = False
for a in range(N+1):
	for b in range(N+1-a):
		c = N-a-b
		otoshidama = 10000*a+5000*b+1000*c
		if otoshidama==Y:
			Aohashi = True
			break
	if Aohashi: break

if Aohashi:
	print(a,b,c)
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 N-i-j>=0 and 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())
 
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())

out = '-1 -1 -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:
			out = '{} {} {}'.format(x, y, z)
			break
print(out)

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

Solution (Python):
N, SUM = map(int,input().split())
X = 10000
Y = 5000
Z = 1000
ans = [-1, -1, -1]
for x in range(N+1):
    for y in range(N+1):
        z = N-x-y
        if z<0:
            break
        if X*x+Y*y+Z*z==SUM:
            ans = [x,y,z]
            break
                
print(*ans)

Solution (Python):
n,y=map(int,input().split())
y//=1000
f=False
for yu in range(n+1):
  for hi in range(n+1):
    if y<yu*10+hi*5:
      continue
    if y-(yu*10+hi*5)==n-(yu+hi):
      print(yu,hi,n-yu-hi)
      f=True
      break
  if f:
    break
else:
  print("-1 -1 -1")

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline

    N,Y = map(int,input().split())
    
    Y //= 1000
    for i in range(N+1):
        for j in range(N+1-i):
            k = (N-i-j)
            m = i*10 + j*5 + k*1
            if m == Y:
                print("{} {} {}".format(i,j,k))
                return
    print("-1 -1 -1")

if __name__ == '__main__':
    main()

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
        ans = i*10000 + j*5000 + k*1000

        if ans == Y:
            print("{0} {1} {2}" .format(i,j,k))
            sys.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):
    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())

xyz=[]
for x in range(N+1):   
    for y in range(N-x+1):
        z=N-(x+y)
        total=10000*x+5000*y+1000*z
        if total==Y:
            xyz.append([x,y,z])
if xyz:
    print(xyz[0][0],xyz[0][1],xyz[0][2])
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())
for i in range(min(N+1,Y//10000 + 1)):
    for j in range(N+1-i):
        if 10000 * i + 5000 * j + 1000 * (N-i-j) == Y:
            print(i,j,N-i-j)
            exit(0)
print(-1,-1,-1)

Solution (Python):
N, Y = map(int, input().split())
Y = Y//1000
for a in range(N+1):
    for b in range(N+1-a):
        if Y == a*10 + b*5 + (N - a - b):
            print(a,b,N-a-b)
            exit(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-i):
        k = N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

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

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

Y //= 1000

for x in range(N + 1):
    for y in range(N-x+1):
        z = N - (x + y)
        yen = x * 10 + y * 5 + z
        if Y == yen:
            print(x, y, z)
            exit()

print(-1, -1, -1)

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

Solution (Python):
N, Y = map(int, input().split())
ans = [-1,-1,-1]
flag=False
for i in range(N+1):
    if i * 10000 > Y: break
    for j in range(N-i+1):
        if (i*10000 + j*5000 + (N-i-j)*1000) == Y:
            ans = [i,j,N-i-j]
            flag =True
            break
    if flag:
        break
print('{} {} {}'.format(*ans))

Solution (Python):
N, Y = map(int, input().split())
ans = [-1,-1,-1]
flag=False
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]
            flag =True
            break
    if flag:
        break
print('{} {} {}'.format(*ans))

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 (10000*a + 5000*b + 1000*c) == y and a + b + c == n and c >= 0:
            print(a,b,c)
            exit(0)
print(-1,-1,-1)

Solution (Python):
N,Y=map(int,input().split())
for i in range(N+1):
  if 10000*i>Y:
    break
  for j in range(N+1-i):
    k=N-i-j
    S = 10000*i + 5000*j + 1000*k
    if k<0 or S>Y:
      continue
    elif S == Y:
      print(i,j,k)
      exit()
print(-1,-1,-1)

Solution (Python):
N,Y=map(int,input().split())
for i in range(N+1):
  if 10000*i>Y:
    break
  for j in range(N+1-i):
    k=N-i-j
    S = 10000*i + 5000*j + 1000*k
    if k<0 or S>Y:
      continue
    elif S == Y:
      print(i,j,k)
      exit()
print(-1,-1,-1)

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

rem = 0
for i in range(y//10000 +1):
    rem = y-10000*i
    for j in range(rem//5000 + 1):
        k = (rem - 5000*j) // 1000
        if (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())

for i in range(y//10000 + 1):
  for j in range(y//5000 + 1):
    if (y-i*10000-j*5000)//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())


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

if not found:
    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
        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())

stop = n + 1
for m in range(stop):
    for g in range(stop - m):
        s = n - m - g
        if y == 10000 * m + 5000 * g + 1000 * s:
            print(m, g, s, sep=" ")
            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-i+1):
        if i*10000+j*5000>y :
            break
        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 10000*i+5000*j+1000*(N-i-j) == Y:
            print(i,j,N-i-j)
            exit()
print('-1 -1 -1')

Solution (Python):
import itertools
import sys

N, Y = map(int,input().split())
rtn = False
 
for i,j in itertools.combinations_with_replacement(range(N+1), 2):
    if Y == 10000 * i + 5000 * (j-i) + 1000 * (N-j):
        print(i, j-i, N-j)
        rtn = True
        break

if not(rtn) :
    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 and 0<=(N-i-j)<=N:
            print(i,j,N-i-j) 
            exit() 

print(-1,-1,-1)

Solution (Python):
N,Y=map(int,input().split())
t,T,M=1000,10**6,range(N+1)
A=[(T*T*i+T*j+(N-i-j)) for i in M for j in M if (9*i+4*j+N==Y//t)*(i+j<=N)>0]
if A:
    a,b=A[0]%T,A[0]//T
    b,c=b%T,b//T
else:
    a,b,c=-1,-1,-1
print(c,b,a)

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

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

else:
    print(-1, -1, -1)

Solution (Python):
n, y = map(int, input().split())
judge = "no value"

for i in range(n+1):
    if judge == "Found it!":
        break
    for j in range(n+1):
        z = n - i - j
        value = z * 10000 + i * 5000 + j *1000
        if value == y and z >= 0:
            print(z, i , j)
            judge = "Found it!"
            break

if judge == "no value":
    print(-1, -1, -1)

Solution (Python):
N, Y = map(int, input().split())
Y_dash = Y // 1000
ans = 0
for a in range(0, N+1):
    for b in range(0, N + 1 - a):
        if -9*a - 5*b + 10*N == Y_dash:
            ans = (a, b, N-a-b)
            break
if ans == 0:
    print(-1, -1, -1)
else:
    print(ans[2], ans[1], ans[0])

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

Solution (Python):
N, Y = map(int, input().split())
res_x = -1
res_y = -1
res_z = -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:
      res_x = x
      res_y = y
      res_z = z
print('{} {} {}'.format(res_x, res_y, res_z))

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

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

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

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

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

Solution (Python):
n, y = map(int, input().split())
ans = ''
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:
      ans = f'{i} {j} {k}'
      break
  if ans:
    break
print(ans if ans else '-1 -1 -1')

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

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

a=(-1,-1,-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:
            a=(i, j, k)
            break
print('{} {} {}'.format(*a))

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:
            print(x, y, z)
            exit()
print('-1 -1 -1')

Solution (Python):

import sys


def solve(N: int, Y: int):
    for x in range(N+1):
        for y in range(N-x+1):
            z = N - x - y
            if 10_000 * x + 5_000 * y + 1_000 * z == Y:
                return x, y, z
    return -1, -1, -1



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    Y = int(next(tokens))  
    print(*solve(N, Y), sep=" ")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
n, y = map(int, input().split())
 
f = True
 
for i in range(y // 10000 + 1):
    for j in range((y - 10000 * i) // 5000 + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            ans = "{} {} {}".format(i, j, n - i - j)
            print(ans)
            f = False
            exit()
        else:
            pass
 
if f:
   print("-1 -1 -1")

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

for i in range(y // 10000 + 1):
    for j in range((y - 10000 * i) // 5000 + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            ans = "{} {} {}".format(i, j, n - i - j)
            print(ans)
            j += 1
            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:
            ans = "{} {} {}".format(i, j, n - i - j)
            print(ans)
            j += 1
            exit()

else:
    print("-1 -1 -1")

Solution (Python):



def main():
    args = input().split()
    N = int(args[0])
    Y = int(args[1])

    for num10000 in range(0, N + 1):
        for num5000 in range(0, N + 1 - num10000):
            num1000 = N - num10000 - num5000
            value = 10000 * num10000 + 5000 * num5000 + 1000 * num1000
            if value == Y:
                print(num10000, num5000, num1000)
                return

    print(-1, -1, -1)


if __name__ == "__main__":
    main()

Solution (Python):
N,Y = map(int,input().split())
for i in range(N + 1):
	a = i
	for j in range(N - a + 1):
		b = j
		c = N - a - b
		if a*10000 + b*5000 + c*1000 == Y:
			break
	if a*10000 + b*5000 + c*1000 == Y:
			print(str(a)+" "+str(b)+" "+str(c))
			break
if a*10000 + b*5000 + c*1000 != Y:
	print(str(-1)+" "+str(-1)+" "+str(-1))

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

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

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

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

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

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

Solution (Python):
N, Y = [int(s) for s in input().split(" ")]
Y = int(Y/1000)


ans = []
for i in range(N + 1):
  for j in range(N + 1 - i):
    if N - i - j >= 0 and Y - 10 * i - 5 * j == N - i - j:
      ans += [str(i), str(j), str(N - i - j)]
      break
  else:
    continue
  break


if len(ans):
  print(" ".join(ans))
else:
  print("-1 -1 -1")

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

i = y//10000
j = y//5000
k = y//1000

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

Solution (Python):
def main():
	N, Y = map(int, input().split())
	ans_10000 = -1
	ans_5000 = -1
	ans_1000 = -1

	for i in range(N + 1):
		for j in range(N - i + 1):
			k = N - i - j
			total = 10000 * i + 5000 * j + 1000 * k
			if total == Y :
				ans_10000 = i
				ans_5000 = j
				ans_1000 = k
				break				
	print(ans_10000, ans_5000, ans_1000)

  
if __name__ == "__main__":
  	main()

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):
            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())
nums=[i for i in range(n+1)]
judge = 0
for i in range(n+1):
    for j in range(n+1-i):
        price = i * 10000 + j * 5000 + (n-i-j) * 1000
        if y == price:
            judge += 1
            print(str(i) + " " + str(j) + " " + str(n-i-j))
            break
    if judge == 1:
        break
if judge == 0:
    print("-1 -1 -1")

Solution (Python):
N,Y=map(int,input().split())
answer=0
for n in range(0,N+1):
    for n_ in range(0,N+1-n):
        n__=N-n-n_
        if 10000*n+5000*n_+1000*n__==Y:
            answer=1
            kotae=str(n)+' '+str(n_)+' '+str(n__)
            break
if answer==0:
    print(-1,-1,-1)
else:
    print(kotae)

Solution (Python):

n, y = (int(x) for x in input().split())

_10000, _5000, _1000 = 0, 0, 0

exist = False

for i in range(n + 1):

    
    
    for j in range(n + 1 - i):

        

        

        if (i * 10000) + (j * 5000) + ((n - i - j) * 1000) == y :
                
                _10000, _5000, _1000 = i, j, n - i - j
                exist = True

        

        
        

        
        
        
        

    if exist == True :
        break

if exist == True :
    print("{0} {1} {2}".format(_10000, _5000, _1000))
else :
    print('-1 -1 -1')

Solution (Python):

import math

N,Money = map(int, input().split())
if(1000*N<=Money<10000*N):
    tenthousand_list=[num for num in range(0,Money+1,10000)]
    fivethousand_list=[num for num in range(0,Money+1,5000)]
    possible_tenthousand=math.floor(Money/10000)
    while (possible_tenthousand >=0):
        
        zan_number=N-possible_tenthousand
        zan_Money=(Money-tenthousand_list[possible_tenthousand])
        if(5000*zan_number>=zan_Money):
            possible_fivethousand=math.floor(zan_Money/5000)
            while (possible_fivethousand>=0):
            
                if(tenthousand_list[possible_tenthousand]+fivethousand_list[possible_fivethousand]+
                   (1000*(N-possible_tenthousand-possible_fivethousand))==Money):
                    zan_Money=0
                    break
                else:
                    possible_fivethousand-=1
        else:
            print("-1 -1 -1")
            break
        
        if((zan_Money==0) and (possible_fivethousand!=-1) ):
            print(str(possible_tenthousand) + " " + str(possible_fivethousand)+ " " + str(N-possible_tenthousand-possible_fivethousand) )
            break

            
        possible_tenthousand-=1

        
        if(possible_fivethousand==-1 and possible_tenthousand ==-1):
            print("-1 -1 -1")
            break
        

        
elif(Money==10000*N):
    print(str(N) + " 0 "+ "0") 

else:
    print("-1 -1 -1")

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

max10k = y // 10000

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

print(-1,-1,-1)

Solution (Python):
num, money = map(int, input().split())
ex = False


l = 0
count_list = [-1]*3
if num*1000 <= money and money <= num*10000:
    while ex == False and l <= num:
        for i in range((num-l) + 1):
            
            money_actual = l*10000 + i*5000 + (num-l-i)*1000
            
            if money_actual == money:
                ex = True
                count_list = [l, i, num-(l+i)]
                
        l += 1
        

print(str(count_list[0]) + " " + str(count_list[1]) + " " + str(count_list[2]))

Solution (Python):
def func(n, yen):
    n += 1
    for x in range(n):
        for y in range(n-x):
            z = n - x - y - 1
            if (x+y+z) == n-1 and 10000*x + 5000*y + 1000*z == yen:
                comb = (x, y, z)
                print(" ".join([str(i) for i in comb]))
                return
    print("-1 -1 -1")
    return


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

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())
y //= 1000
for i in range(n + 1):
    for j in range(n + 1 - i):
        if i * 10 + j * 5 + n - i - j == y:
            print(i, j, n - i - j)
            exit()
else:
    print(-1, -1, -1)

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






flag = False;
S = Y - N * 1000;
for i in range(N + 1):
  y_div, y_mod = divmod((S - 9000 * i), 4000);
  z = N - i - y_div;
  if (y_mod == 0 and z >= 0 and y_div >= 0):
    print(str(i) + " " + str(y_div) + " " + str(z));
    flag = True;
    break;

if (flag == 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):
        res=y-10000*i-5000*j-1000*(n-i-j)
        if res==0:
            print('{} {} {}'.format(i,j,n-i-j))
            exit(0)

print('-1 -1 -1')

Solution (Python):
n,y=map(int,input().split())
def money(n,y):
    for i in range(n+1):
        if y-10000*i<0:
            continue
        for j in range(n-i+1):
            if y-10000*i-5000*j<0:
                continue
            k=n-i-j
            if 10000*i+5000*j+1000*k==y:
                print(i,j,k)
                return
    print("-1 -1 -1")
money(n,y)

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

    x,y,z = 0,0,0

    an = [-1]*3
    

    for i in range(N+1):
        for j in range(N-i+1):
            if i*10000 + j *5000 +1000*(N - i - j) == Y:
                an[0] = i
                an[1] = j
                an[2] = N-i-j
                print(*an)
                return
    
    print(*an)


if __name__ == "__main__":
    cal()

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

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

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

for n1 in range(N+1):
  for n2 in range(N-n1+1):
    yen = n1 * 10000 + n2 * 5000 + (N-n1-n2) * 1000
    if yen == Y:
      ans = [n1,n2,N-n1-n2]
      break

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

Solution (Python):
import math
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())
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:
            ans = (" ".join(list(map(str, [x, y, z]))))
            break

print(ans)

Solution (Python):
N,Y = [int(i) for i in input().split()]
for i in range(N+1):
    for j in range(N-i, -1, -1):
        money = i*10000 + j*5000 + (N - i - j)*1000
        if money == Y:
            print(i,j,N-i-j)
            exit()
        elif money < Y:
            break
print(-1,-1,-1)

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