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())
num10000=-1
num5000=-1
num1000=-1
for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        if k*1000+j*5000+i*10000==y:
            num1000=k
            num5000=j
            num10000=i
            break
print(num10000,num5000,num1000)

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

result = []
for a in range(N+1):
  for b in range(N+1):
    c = max(N - a - b, 0)
    total = a * 10000 + b * 5000 + c * 1000
    if (total == Y) and (a + b + c == N):
      result.append([a, b, c])

if len(result) == 0:
  print("-1 -1 -1")
else:
  print(" ".join(map(str, result[0])))

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

for ykc in range(0,y+1,10000):
  for ntb in range(0,y-ykc+1,5000):
    ntm=(y-ykc-ntb)
    nntm=ntm//1000
    nntb=ntb//5000
    nykc=ykc//10000
    if ntm%1000==0 and (nntm+nntb+nykc==n):
      print(nykc, nntb, nntm)
      sys.exit()
print('-1 -1 -1')

Solution (Python):
n,y = map(int,input().split())
c = (y%5000)//1000
y -= c*1000
n -= c
for i in range(100000):
    a = (y-5000*n)//5000
    b = n - a
    if 0 <= a and 0 <= b and 0 <= c:
        print(a,b,c)
        break
    c += 5
    n -= 5
    y -= 5000
    
    if i == 100000 - 1:
        print(-1,-1,-1)

Solution (Python):
import sys
a = -1
count = 0
if __name__ == '__main__':
    N, Y = map(int, input().split())
    for x in range(N + 1):
        for y in range(N + 1):
            z = N - x - y
            if z < 0:
                break
            if 10000*x + 5000*y + 1000*z == Y:
                print(x, y, z)
                sys.exit()
    print(a, a, a)

Solution (Python):
n,y=map(int,input().split())
y//=1000
res=False
ans=["-1","-1","-1"]
for i in range(n+1):
    for j in range(n+1-i):
        if 10*i+5*j+(n-i-j)==y:
            ans=[str(i),str(j),str(n-i-j)]
            res=True
            break
    if res:
        break

print(" ".join(ans))

Solution (Python):

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

list_a = []
list_b = []
for a in range(N+1):
    for b in range(N+1):
        c = N - a - b
        if c >= 0:
            k = 10000 * a + 5000 * b + 1000 * c
            list_a.append(k)
            if Y == k:
                list_b.append(a)
                list_b.append(b)
                list_b.append(c)
        
if Y in list_a:
    print(str(list_b[0])+' '+str(list_b[1])+' ' + str(list_b[2])+' ')
if Y not in list_a:
    print('-1 ' + '-1 ' + '-1')

Solution (Python):
n, y = map(int, input().split())
ans = [-1, -1, -1]
for senen in range(n+1):
    for gosenen in range(n-senen+1):
        itimanen = n-senen-gosenen
        if senen*1000 + gosenen*5000 + 10000*itimanen == y:
            ans = [itimanen, gosenen, senen]
            break
    else:
        continue
    break


print(*ans)

Solution (Python):



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

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

print(-1,-1,-1)

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

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

Solution (Python):



import sys


import pprint as pp

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(papers, totalSum):
    result = " ".join(map(str,[ -1 , -1 , -1])) 
    for x in range(0, papers+1 , +1):
        for y in range(0, papers+1-x , +1):
            z = papers - x - y
            total_now = x * 10000 + y * 5000 + z * 1000
            if total_now == totalSum:
                result = " ".join(map(str,[x, y, z]))
    return result


if __name__ == "__main__":
    n, y = MI()
    print("{}".format(solver(n, y)))

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




found = False

for x in range(N+1):
    for y in range(N+1):
        if (x + y) > N:
            continue
        z = N - x - y
        if z < 0:
            continue
        if (x * 10000 + y * 5000 + z * 1000) == Y:
            ans_x = x
            ans_y = y
            ans_z = z
            found = True

if found:
    print("{} {} {}".format(ans_x, ans_y, ans_z))
else:
    print("{} {} {}".format(-1, -1, -1))

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

for i in range(N+1):
    for j in range(N-i+1):
        if 10*i+5*j+(N-i-j)==Y//1000:
            print(i,j,N-i-j)
            exit(0)

print(-1,-1,-1)

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

Solution (Python):
N, Y = map(int, input().split())
found = False
for k10 in range(N+1):
    if 10000 * k10 > Y:
        continue
    for k5 in range(N+1 - k10):
        k1 = N - k10 - k5
        if Y == 1000 * k1 + 5000 * k5 + 10000 * k10:
            found = True
            break
    if found:
        print(k10, k5, k1)
        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 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i)
            print(j)
            print(n - i - j)
            exit(0)
print(-1)
print(-1)
print(-1)

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

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

if n > y:
    print("-1 -1 -1")
elif 10*n < y:
    print("-1 -1 -1")
else:
    diff = 10*n - y

    for i in range(diff//9 + 1):
        for j in range(diff//5 + 1):
            ans = 9*i + 5*j

            if ans > diff:
                break
            elif (i+j) > n:
                break
            elif ans == diff:
                print(n-(i+j), j, i)
                exit()

    print("-1 -1 -1")

Solution (Python):
n,y = map(int,input().split())
y //= 1000
f = 0
for s in range(n+1):
    for t in range(n+1-s):
        if s+t*5+(n-s-t)*10 == y:
            f = 1
            print(n-s-t,t,s)
            break
    if f == 1:
        break
else:
    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-a):
            if 10000*a+5000*b+1000*(n-b-a)==y:
                print(a,b,n-a-b)
                count=count+1
                break
    else:
        continue
    break
if count==0:
    print(-1,-1,-1)
else:
    pass

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

    print(-1,-1,-1)



if __name__ == "__main__":
    main()

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

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

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

cnt = 0
for i in range(N+1):
  for j in range(N+1-i):
    k=N-i-j
    if 0 <= k and 10000*i+5000*j+1000*k == Y:
      print(i, j, k)
      cnt += 1
      break
  else:
    continue
  break
if cnt == 0:
  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-i):
        k = N-i-j
        s = 10000*i + 5000*j + 1000*k
        if s == Y:
            a = i
            b = j
            c = k             
print(a,b,c)

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

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


s = [-1,-1,-1]

for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j +1000*(n-i-j) == y:
            s = [i,j,n-i-j]
            break

print(*[x for x in s])

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    Y //= 1000

    x, y, z = -1, -1, -1
    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if k >= 0 and 10 * i + 5 * j + k == Y:
                x, y, z = i, j, k
                break

    print(x, y, z)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    Y //= 1000

    x, y, z = -1, -1, -1
    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if k >= 0 and 10 * i + 5 * j + k == Y:
                x, y, z = i, j, k
                break

    print(x, y, z)
    return


if __name__ == '__main__':
    main()

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

checker = Y // 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 + 5 * y + 10 * z) == checker:
            ans = [z, y, x]
            break
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

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):
        k = n-i-j
        sum = 10000*i + 5000*j + 1000*k
        if sum == y:
            a = i
            b = j
            c = k
                
print(a,b,c)

Solution (Python):



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

for yukichi in range(n + 1):
  for higuchi in range(n + 1 - yukichi):
    noguchi = n - yukichi - higuchi
    if (yukichi * 10000 + higuchi * 5000 + noguchi * 1000) == y:
      print(yukichi, higuchi, noguchi)
      exit()
print(-1, -1, -1)

Solution (Python):
x = list(map(int, input().split()))
ans = 0
man = 0
gosen = 0
sen = 0
y = x[0]+1
for i in range(y):
  for j in range(y-i):
    if i*10000+j*5000+(x[0]-i-j)*1000 == x[1]:
      man = i
      gosen = j
      sen = x[0]-i-j
      ans = 1
      break
if ans == 1:
  print(str(man)+' '+str(gosen)+' '+str(sen))
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):
        A,B,C=i*10000,j*5000,(N-i-j)*1000
        if A+B+C==Y and i+j+(N-i-j) and -1<N-i-j:
            print(i,j,N-i-j)
            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):
        k = N - (i + j)
        if 10000*i + 5000*j + 1000*k == Y:
            ans = [i, j, k]
            break
    else:
        continue
    break

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

Solution (Python):
n,y = map(int,input().split())
flag = 0
y_10 = 0
y_5 = 0

for i in range(n+1):
    y_10 = i * 10000
    if y_10 > y:
        break
    for j in range(0,n-i+1):
        y_5 = j*5000
        if y_10+y_5 > y:
            break
        k = n-i-j
        if y_10 + y_5 + 1000*k == y:
            print(i,j,k)
            flag = 1
            break
    if flag == 1:
        break

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

Solution (Python):
def resolve():
    N, Y = [int(i) for i in 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)
                return
    print(-1, -1, -1)

resolve()

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

for i in range(N + 1):
    for j in range(N + 1):
        if i + j > N:
            continue
        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())
if Y % 1000 != 0:
    print(-1, -1, -1)
else:
    
    for a in range(N+1):
        for b in range(N+1):
            c = N - a - b
            if c < 0:
                continue
            elif Y == 10000 * c + 5000 * b + 1000 * a:
                print(c, b, a)
                exit()
    print(-1, -1, -1)

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


def g(y,n):
	for a in range(y/10 + 1):
		b,c = f(y - a * 10, n - a)
		if b != -1:
			return [a,b,c]
	return [-1,-1,-1]
def f(y,n):
	if y < 0 or n < 0:
		return [-1,-1]
	if y == 0:
		if n == 0:

			return [0,0]
		return [-1,-1]

	for b in range(y/5 + 1):
		if y - b * 5 == n - b and n - b >= 0:
			return [b,n-b]
	return [-1,-1]

print ' '.join(map(str, g(y,n)))

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):
        k = n-i-j
        sum = 10000*i + 5000*j + 1000*k
        if sum == y:
            a = i
            b = j
            c = k
                
print(a,b,c)

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

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

Solution (Python):
N,Y=input().split()
N=int(N)
Y=int(Y)
def roop():
    for a in range(N+1):
        a_amount=10000*a
        for b in range(N+1-a):
            b_amount=5000*b
            c=N-a-b
            c_amount=1000*c
            amount_tot=a_amount+b_amount+c_amount
            X=[a,b,c]
            if Y==amount_tot and a+b+c==N:
                return X
    return -1,-1,-1
roop()
ans=roop()
print(' '.join(map(str,ans)))

Solution (Python):
import sys
N,Y=map(int,input().split())
Y=Y//1000
if N>Y or N*10<Y:
  print(-1,-1,-1)
  sys.exit()
for i in range(N+1):
  for j in range(N-i+1):
    k=N-i-j
    if i+5*j+10*k==Y:
      print(k,j,i)
      sys.exit()
print(-1,-1,-1)

Solution (Python):

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

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

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

Solution (Python):
n, Y = map(int, input().split())
frag = 0
tmp = 0
a = 0
b = 0
c = 0
for x in range(n + 1):
    for y in range(n - x + 1):
        tmp = x * 10000 + y * 5000 + (n - x - y) * 1000
        if tmp == Y:
            frag = 1
            a = x
            b = y
            c = n - x - y
            break
if frag == 0:
    print("-1 -1 -1")
else:
    print(f"{a} {b} {c}")

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

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

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

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

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

for i in range(n+1):
  for j in range(n-i+1):
    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 = list(map(int, input().split()))
x=-1
y=-1
z=-1
for a in range(N+1): 
	for b in range(N+1-a): 
		c=N-a-b 
		sum=10000*a + 5000*b + 1000*c
		if sum == Y:
			x=a
			y=b
			z=c
print(x,y,z)

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())

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

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

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

Solution (Python):
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1-i):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")
 
n,y = map(int, input().split())
print(calcPattern(n,y))

Solution (Python):
N,Y = map(int, input().split())
for i in range(0, N+1):
    for j in range(0, N+1-i):
        if i == ((Y - 1000*N - 4000*j) / 9000):
            if (N-i-j) >= 0: print(str(i) + " " + str(j) + " " +str(N-i-j))
            exit()
print ("-1 -1 -1")

Solution (Python):
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1-i):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")
    
n,y = map(int, input().split())
print(calcPattern(n,y))

Solution (Python):
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")

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

Solution (Python):
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")
    
n,y = map(int, input().split())
print(calcPattern(n,y))

Solution (Python):
N,Y = input().split()
N = int(N)
Y_k=int(Y)/1000

answer = [-1,-1,-1]
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_k:
            answer = [i,j,k]

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

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

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

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

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

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

Solution (Python):
n,y = map(int, input().split())
a = []
for i in range(0,n+1,1):
  for j in range(0,n+1,1):
    if 9000*i+4000*j == y-1000*n and n-i-j >= 0:
      a = [i,j,n-i-j]
if a == []:
  print(-1,-1,-1)
else:
  print(a[0],a[1],a[2])

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

y //= 1000

for i in range(0,y+1,5):
    for j in range(0,i+1,10):
        a,b,c = j,i-j,y-i
        a //= 10
        b //= 5
        if a+b+c == n:
            print(a,b,c)
            exit()
print(-1,-1,-1)

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

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

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

Y //= 1000
res = [-1,-1,-1]

for i in range(N+1):
  remN = N-i
  remY = Y - 10*i
  if remY < 0:
    break
  for j in range(remN+1):
    if remY - 5*j == remN - j:
      res = [i,j,N-i-j]
      
print(" ".join(map(str,res)))

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

Solution (Python):
def solve(args):
    n, y = args

    
    for i in range(n+1):
        for j in range(0, n-i+1):
            
            k = n - i - j

            
            if i*10000 + j*5000 + k*1000 == y:
                return "{} {} {}".format(i, j, k)

    return "-1 -1 -1"

print(solve(map(int, input().split())))

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

total = 0
ans = list()
for a in range(0, n+1, 1):
  for b in range(0, n+1, 1):
    if a + b <= n:
      c = n - (a+b)
      total = a*10000 + b*5000 + c*1000
      if total == y:
        lists = [a,b,c]
        ans.append(lists)
    else:
      break

if ans == []:
  answer = ['-1', '-1', '-1']
  answer = ' '.join(answer)
else:
  answer = [str(i) for i in ans[0]]
  answer = ' '.join(answer)

print(answer)

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

Solution (Python):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, Y = NMI()
    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)


if __name__ == "__main__":
    main()

Solution (Python):


def solve(n,y):
  billUnit = (10000,5000,1000)
  for i in range(0,y//billUnit[0]+1):
    for j in range(0,y//billUnit[1]+1):
      rest = y - billUnit[0] * i - billUnit[1] * j
      k = n - i - j
      if billUnit[2] * k == rest and k >= 0:
        return i,j,k
  return -1,-1,-1



def main():
  N,Y = map(int,input().split())
  print(*solve(N,Y))
  return

if __name__ == '__main__':
  main()

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

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

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

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

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

Solution (Python):
def main():
    N, Y = map(int, input().split())
    m = 10000
    ft = 5000
    t = 1000
    for i in range(N+1):
        for j in range(N-i+1):
            k = N - i - j
            if m*i + ft*j + t*k == Y and i + j + k == N:
                print(str(i) + ' ' + str(j) + ' ' + str(k))
                return
    print('-1 -1 -1')

main()

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

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

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

ans=0
for x in range(0,n+1):
  if ans>0:
    break
  for y in range(0,n+1-x):
    z=n-x-y
    if 10000*x+5000*y+1000*z==Y:
      ans+=1
      print(str(x)+' '+str(y)+' '+str(z))
      
    if ans>0:
      break
      
if ans==0:
  print(str(-1)+' '+str(-1)+' '+str(-1))

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

for sen in range(0,n+1):
    for go in range(0,n+1):
        if 1000*sen + 5000*go + 10000*(n-sen-go) == y and n-sen-go >= 0:
            print("{} {} {}".format(n-sen-go, go, sen))
            exit()

print("-1 -1 -1")

Solution (Python):
N,Y  = (int(T) for T in input().split())
Flag = False
for Y10 in range(0,N+1):
    for Y5 in range(0,N+1-Y10):
        Y1 = N-(Y10+Y5)
        if 10*Y10+5*Y5+Y1==Y//1000:
            Flag = True
            Disp = [str(T) for T in [Y10,Y5,Y1]]
            break
    if Flag:
        break
if Flag:
    print(' '.join(Disp))
else:
    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):
        total = 10000*i + 5000*j + 1000*(n-i-j)
        if(total == y and (n-i-j)>=0):
            a,b,c = i,j,(n-i-j)
print(a,b,c)

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

Solution (Python):
n_y = input().split(' ')
maisu = int(n_y[0])
total = int(n_y[1])

result_flg = True
for i in range(maisu+1):
    for j in range(maisu+1):
        if maisu - i - j < 0:
            break

        sum_kingaku = i * 10000 + j * 5000 + (maisu - i - j) * 1000

        if sum_kingaku > total:
            break

        if total == sum_kingaku:
            print(str(i) + ' ' + str(j) + ' ' + str(maisu -i -j))
            result_flg = False
            break
    if result_flg == False:
        break
    

if result_flg:
    print('-1 -1 -1')

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,y = I2()
    for i in range(n+1):
        for j in range(n+1-i):
            k = n - i - j
            if y//1000 == 10*i + 5*j + k:
                print(i,j,k)
                exit()
    print(-1,-1,-1)

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

c =False
for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            a = [str(i), str(j), str(N-i-j)]
            print(" ".join(a))
            c = True
            break
    if c:
        break
if not c:
    print("-1 -1 -1")

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

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


if __name__ == '__main__':
    main()