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

Solution (Python):
n,m = map(int,input().split())
total = 0

for a in range(n+1):
  for b in range(n+1):
    total=10000*a+5000*b+1000*(n-a-b)
    if total == m and a+b <=n:
      print(a,b,n-a-b)
      exit()
    
print(-1,-1,-1)

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

s=False
for a in range(N+1):
    for b in range(a,N+1):
        sumN=a*10000+(b-a)*5000+(N-b)*1000
        if sumN==Y:
            s=True
            x=a
            y=b-a
            z=N-b
    if s:
        break

if s==True:
    print("{} {} {}".format(x,y,z))
else:
    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):
        k = N - i - j
        if k >= 0 and i * 10 + j * 5 + k == Y:
            print(i, j, k)
            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
        if 10000*i+5000*j+1000*k==y:
            print(i,j,k)
            exit()

print("-1 -1 -1")

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

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

Solution (Python):

import sys
input = sys.stdin.readline










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]

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

Solution (Python):
n,y = map(int,input().split()) 
a = -1
b = -1
c = -1
for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if i*10000+j*5000+k*1000 == y and k >= 0 :
            a = i
            b = j
            c = k
            break

print(a,b,c)

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

Solution (Python):

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

"""
x 
y 
z 
z = n - x - y
"""

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

print(-1,-1,-1)

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


l=0
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:
            l=[i,j,k]
            pass
if l==0:
    l=[-1,-1,-1]
print(*l,sep=' ')

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

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

print(-1 ,-1 ,-1)

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

print(-1 ,-1 ,-1)

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

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

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

flag = False
for x in range(N+1):
    for y in range(N+1-x):
        z = N-x-y
        if x*10000 + y*5000 + z*1000 == Y:
            print(x,y,z, sep=' ')
            flag = True
            break
    if flag:
        break
if not flag:
    print("-1 -1 -1")

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

check = False
for i in range(n+1):
    if check:
        break
    for j in range(n+1-i):
        p = (i*10000)+(j*5000)+((n-i-j)*1000)
        if p == y:
            check = True
            print(i,j,(n-i-j))
            break

if not check:
    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+1):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            answer = str(x) + ' ' + str(y) + ' ' + str(z) 
            break
print(answer)

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):
def resolve():
    N, Y = map(int, input().split())
    if Y - (10000 * N) > 0:
        print("-1 -1 -1")
        return
    for x in reversed(range(N+1)):
        if Y - (10000 * x) < 0:
            continue
        if Y - (10000 * x) - (5000 * (N-x)) > 0:
            break
        for y in reversed(range(N-x+1)):
            if Y == 10000 * x + 5000 * y + 1000 * (N-x-y):
                print(x, y, N-x-y)
                return
    print("-1 -1 -1")


resolve()

Solution (Python):
n,a=map(int,raw_input().split())
for x in range(n+1):
    for y in range(n+1):
        z = n-(x+y)
        if a==(10000*x)+(5000*y)+(1000*z) and z >= 0:
            print '%d %d %d' % (x,y,z)
            quit()
print '-1 -1 -1'

Solution (Python):
n,a=map(int,raw_input().split())
for x in range(n+1):
    for y in range(n+1):
        z = n-(x+y)
        if a==(10000*x)+(5000*y)+(1000*z) and z >= 0:
            print '%d %d %d' % (x,y,z)
            quit()
print '-1 -1 -1'

Solution (Python):
n,a=map(int,raw_input().split())
for x in range(n+1):
    for y in range(n+1):
        z = n-(x+y)
        if a==(10000*x)+(5000*y)+(1000*z) and z >= 0:
            print '%d %d %d' % (x,y,z)
            quit()
print '-1 -1 -1'

Solution (Python):
n,a=map(int,raw_input().split())
for x in range(n+1):
    for y in range(n+1):
        z = n-(x+y)
        if a==(10000*x)+(5000*y)+(1000*z) and z >= 0:
            print '%d %d %d' % (x,y,z)
            quit()
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 * 10**4 + j * 5000 + (n-i-j)*1000 == y:
            ans = ' '.join(list(map(str, [i, j, n-i-j])))
print(ans)

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

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

if ans == 0:
    print('-1','-1','-1')

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

	yukichi = Y // 10000

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

	for i in range(yukichi+1):
		n = N - i
		y = Y - 10000 * i
		if n == 0 and y == 0:
			ans = [i,0,0]
			break
		for p in range(n+1):
			q = n-p
			if 5000 * p + 1000 * q == y:
				ans = [i,p,q]
				break
				break

	print("{} {} {}".format(ans[0],ans[1],ans[2]))

Solution (Python):

"""
Created on Fri Apr  3 16:28:12 2020

@author: 藤原聖士
"""

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

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

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

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

Solution (Python):
N, Y = map(int,input().split())
a = -1
b = -1
c = -1
for i in range(N+1):
  for j in range(N+1-i):
    if i*9000 + j*4000 == Y - 1000*N:
      a = i
      b = j
      c = N-i-j
print(a, b, c)

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

flag=False
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)
            flag=True
            break

    if flag==True:
        break
     
else:
    print("-1 -1 -1")

Solution (Python):
n,y = [int(e) for e in 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)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Solution (Python):
n,y = [int(e) for e in input().split()]
for i in range(0,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)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

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

Solution (Python):
N,Y = map(int, input().split())
S=[Y//10000,(Y%10000)//5000,((Y%10000)%5000)//1000]
flag=0

for x in range(Y//10000+(Y%10000)//5000+1):
	if sum(S) == N:
		flag = 1
		break
	elif sum(S)+9<=N and S[0]>0:
		S[0] -=1
		S[2] +=10
	elif sum(S)+4<=N and S[1]>0:
		S[1] -=1
		S[2] +=5
	elif sum(S)+1<=N and S[0]>0:
		S[0] -=1
		S[1] +=2
		
if flag ==1:
	print(S[0],S[1],S[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):
    if y == 10000*i + 5000*j + 1000*(n-i-j):
      print(i,j,n-i-j)
      exit()
print("-1 -1 -1")

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

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


if __name__ == '__main__':
    solve()

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

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


if __name__ == '__main__':
    solve()

Solution (Python):


N, Y=(int(x) for x in input().split())

A = Y // 10000 
B = Y // 5000
C = Y // 1000

roop = 0
for i in range(A+1):
    if roop == 1:
        break
    for j in range(B+1):
        if i + j > N:
            break
        c = N - i - j 
        if 10*i + 5*j + c == Y//1000 and c >= 0:
            
            a = i
            b = j
            roop = 1
            break

if roop == 1:
    print("{0} {1} {2}".format(a, b, c))
else:
    a, b, c = -1, -1, -1
    print("{0} {1} {2}".format(a, b, c))

Solution (Python):
import sys
input = sys.stdin.readline
from collections import Counter

INF = float('inf')

""" Input
S = input()
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
"""

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

    ans_10000 = -1
    ans_5000 = -1
    ans_1000 = -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:
                ans_10000 = a
                ans_5000 = b
                ans_1000 = c

    print(ans_10000, ans_5000, ans_1000)


if __name__ == '__main__':
    main()

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

print(-1,-1,-1)

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

print(*ans)

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

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 1<=N<=2000 and 10000*i+5000*j+1000*(N-i-j)==Y:
                ans=i,j,N-i-j
print(*ans)

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

Solution (Python):
import sys
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:
      continue
    if 10000*i+5000*j+1000*k==y:
      print(' '.join([str(i),str(j),str(k)]))
      sys.exit()
print(' '.join(['-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 z <= 2000 and \
                x*10000 + y*5000 + z*1000 == Y:
            ans = x, y, z
            break
    else:
        continue
    break

print(*ans)

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

Solution (Python):
n,y=map(int,input().split())
a=False
for i in range(n+1):
    for j in range(n-i+1):
        nog=1000*i
        hig=5000*j
        fuk=10000*(n-i-j)
        if nog+hig+fuk==y and i>-1 and j>-1 and n-i-j>-1:
            print(n-i-j,j,i)
            a=True
            break
    if a==True:
        break
if a==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):
    b=10000*i+5000*j+1000*(n-i-j)
    if y==b:
      print(i,j,n-i-j)
      exit()
print(-1,-1,-1)

Solution (Python):
N,Y = map(int, input().split())
yukichi = -1
higuchi = -1
noguchi = -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 (Y == total):
            yukichi = a
            higuchi = b
            noguchi = c
print("%d %d %d"%(yukichi,higuchi,noguchi))

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

def func():
    for x in range(Y//10000+1):
        for y in range(Y//5000+1):
            if N-x-y>=0:
                if 1000*N+9000*x+4000*y==Y:
                    print(x, y, N-x-y)
                    return None
    print(-1, -1, -1)
    return None

func()

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

Solution (Python):
n, y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(n + 1):
    if a + b + c > 0:
        break
    else:    
        for j in range(n - i + 1):
            if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
                a = i
                b = j
                c = n - i - j
                break
            else:
                pass
if a + b + c > 0:
    print(str(a), ' ', str(b), ' ', str(c))
else:
    print("-1 -1 -1")

Solution (Python):
n, y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(n + 1):
    for j in range(n - i + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            a = i
            b = j
            c = n - i - j
            break
        else:
            pass
if a + b + c > 0:
    print(str(a), ' ', str(b), ' ', str(c))
else:
    print("-1 -1 -1")

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

Solution (Python):
N,Y = list(map(int,input().split()))
for i in range(0,N+1):
    for j in range(0,N+1):
        if i*10000+j*5000+(N-i-j)*1000 == Y and N-i-j >= 0:
          print('{0} {1} {2}'.format(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-i):
        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 = list(map(int,input().split()))
for i in range(0,N+1):
    for j in range(0,N+1):
        if i*10000+j*5000+(N-i-j)*1000 == Y and N-i-j >= 0:
          print('{0} {1} {2}'.format(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):
N_Y = list(map(int,input().split()))
N = N_Y[0]
Y = N_Y[1]

Y_divt = Y/1000
abc_list = []
break_flag = 0
for b in range(N+1):
    for a in range(N+1):
        if(9*a+4*b == Y_divt-N)&(N-(a+b) >= 0):
            abc_list.append(a)
            abc_list.append(b)
            abc_list.append(N-(a+b))
            break_flag = 1
            break
            
            
            
if(break_flag == 1):           
    print("{} {} {}".format(abc_list[0],abc_list[1],abc_list[2]))
else:
    print("{} {} {}".format(-1,-1,-1))

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

print(-1,-1,-1)

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

Solution (Python):
import sys
input = sys.stdin.readline
N, Y = map(int, input().split())
Y //= 1000
for i in range(N + 1):
  x = Y - 10 * i
  for j in range(N - i + 1):
    y = x - 5 * j
    if y < 0: continue
    if i + j + y == N:
      print(i, j, y)
      exit(0)
  if x + i == N:
    print(i, 0, x)
    exit(0)
print(-1, -1, -1)

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

lst = [-1, -1, -1]
for x in range(N+1):
    for y in range(N-x+1):
      if N-x-y<0:continue
      s = x*10000 + y * 5000 + (N-x-y)*1000
      if s == Y:
          lst = [x, y, N-x-y]
          break
print(*lst)

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

for man in range(Y // 10000 + 1):
    for go in range(Y // 5000 + 1):
        X = Y - man * 10000 - go * 5000
        if X < 0:
            continue
        sen = X // 1000
        if man + go + sen == N:
            print(man, go, sen)
            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):
        yen=0
        k=n-i-j
        yen=10000*i+5000*j+1000*k
        if yen==y:
            print(i,j,k)
            exit()
print(-1,-1,-1)

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


if __name__ == '__main__':
    main()

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

print(*ans)

Solution (Python):
def resolve():

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

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

Solution (Python):
from sys import stdin
def main():
    readline=stdin.readline
    N,Y=map(int,readline().split())

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

if __name__=="__main__":
    main()

Solution (Python):

dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

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)
            exit()
print(-1, -1, -1)

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



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

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

n = c[0]
all = c[1]

okflag = False

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) ) == all):
      print(str(x) + " " + str(y) + " " + str(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-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):
from sys import exit
n,y=map(int,input().split())
y//=1000
for i in range(y//10+1):
    
    
    k1=y-i*10
    for j in range(k1//5+1):
        k=k1-j*5
        l=i+j
        if k==n-l and i>=0 and j>=0 and k>=0:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
print("-1 -1 -1")

Solution (Python):
import sys
c = list(map(int,input().split()))

for i in range(int(c[0])+1):
    for j in range(int(c[0]) - i + 1):
        if (10000*j + 5000*(int(c[0]) - i - j) + 1000*i) == int(c[1]):
            print("{} {} {}".format(j, int(c[0]) - i - j, i))
            sys.exit()

print("-1 -1 -1")

Solution (Python):
n,y = map(int,input().split())
huku = y//10000
higuchi = y // 5000
flag = False
for i in range(huku+1):
    for j in range(higuchi+1):
        nokori = y - (10000*i + 5000*j)
        if nokori < 0:
            break
        l = nokori // 1000
        
        if i+j+l == n:
            if 10000*i + 5000*j + 1000*l==y:
                flag = True
                ans1 = i
                ans2 = j
                ans3 = l
                

if flag ==True:
    print(ans1,ans2,ans3)
else:
    print("-1 -1 -1")

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

for a in range(aa+1) :
    
    yf=y-a*10
    nf=n-a
    b1=(yf-nf)%4
    b2=(yf-nf)//4 
    if yf<nf or 5*nf-yf<0:continue
    elif b1==0:
        print(a,b2,nf-b2)
        break
    else: continue

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

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


for b in range(n+1):
  for f in range(n-b+1):
    if (y - b*10 - 5*f) == n-b-f:
      ans = [b, f, n-b-f]
      print(*ans)
      exit()

ans = [-1,-1,-1]
print(*ans)

Solution (Python):
def main2():
    t = (input().split(' '))
    t = [int(v) for v in t]
    if t[0] * 10000 < t[1]:
        print('-1 -1 -1')
        exit(0)
    for i in range(t[0] + 1):
        for j in range((t[0] + 1) - i):
            if (10000 * i) + (5000 * j) + ((t[0] - i - j) * 1000) == t[1]:
                print(i, j, (t[0] - i - j))
                exit(0)

    print('-1 -1 -1')


if __name__ == '__main__':
    main2()

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:
            ans = [a, b, n - a - b]
            print(*ans, 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 + 1):
        
        z = N - (i + j)

        if z < 0:
            continue

        total = i*1000 + j*5000 + z*10000
        
        if total == Y:
            print(z, j, i)
            exit()

print('-1 -1 -1')

Solution (Python):

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

    def main():
        for i in range(N+1):
            for j in range(N+1-i):

                if i*10000+j*5000+(N-i-j)*1000==Y:
                    return [i,j,N-i-j]
        return [-1,-1,-1]

    for i in main():
        print(i,end=' ')





resolve()

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

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def calot(i, g, N):
    return i * 10000 + g * 5000 + (N - i - g) * 1000


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, Y = il()
    for i in range(0, N+1):
        for g in range(0, N - i + 1):
            if calot(i, g, N) == Y:
                print(i, g, N - i - g)
                exit()
    else:
        print(-1, -1, -1)


if __name__ == '__main__':
    main()

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

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

Solution (Python):




def main():
    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)
            yen = i * 10**4 + j * 5 * 10**3 + k * 10**3
            if Y == yen:
                result = [i, j, k]
    print(*result)


if __name__ == "__main__":
    main()