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):
def main():
    n, y = map(int, open(0).read().split())
    y //= 1000
    found = False
    for i in range(n+1):
        for j in range(n+1):
            k = n - i - j
            if k < 0:
                continue
            if 10 * i + 5 * j + k == y:
                found = True
                break
        if found:
            break
    else:
        i, j, k = -1, -1, -1
    print(i, j, k)


if __name__ == "__main__":
    main()

Solution (Python):
n, y = map(int, input().split())
f = True
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)
            f = False
            break
    if f == False:
        break
if f:
    print('-1 -1 -1')

Solution (Python):
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, y = na()
m = -1
f = -1
t = -1
for i in range(int(y/10000)+1):
        yleft = y - i * 10000
        nleft = n - i
        for j in range(int(yleft/5000)+1):
                if (j * 5000 + (nleft - j) * 1000) == yleft:
                        m = i
                        f = j
                        t = n - i - j
                        break


print('{} {} {}'.format(m, f, t))

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

end = 0

stdz = y // 10000

o1 = -1
o2 = -1
o3 = -1

if stdz <= n:
    for i in reversed(range(stdz + 1)):
        for j in reversed(range(n - i + 1)):
            if 10000*i+5000*j+1000*(n - i - j) == y:
                o1 = i
                o2 = j
                o3 = n - i - j
                end = 1
            if end == 1:
                break
        if end == 1:
            break


print(o1, o2, o3)

Solution (Python):
def hantei(n, m, l, d ):
    if (n*10000+m*5000+l*1000)==d:
        return True
    return False

osatu,sum = map(int,input().split())




n=m=l=0
result=0

while(n <= osatu):
    while(m+n <= osatu):
        l=osatu-n-m
        if n+m+l==osatu:
            if hantei(n,m,l,sum)==True:
                print(n,m,l)
                exit (0)
        m+=1
    m=0
    n+=1


print("-1 -1 -1")

Solution (Python):
from sys import stdin

N, Y = [int(x) for x in stdin.readline().rstrip().split()]


z = Y // 1000
if z < N:
  print('-1 -1 -1')
  exit()
  

x = Y // 10000
y = (Y - x * 10000) // 5000
z = (Y - x * 10000 - y * 5000) // 1000
if x + y + z > N:
  print('-1 -1 -1')
  exit()
  
obj = N - (x + y + z)
for a in range(x+1):
  for b in range(x-a+1):
    for c in range(y+1):
      if(a + 9*b + 4*c == obj):
        print('{} {} {}'.format(str(x-a-b), str(y+2*a-c), str(z+10*b+5*c)))
        exit()

print('-1 -1 -1')

Solution (Python):
from sys import stdin

N, Y = [int(x) for x in stdin.readline().rstrip().split()]


z = Y // 1000
if z < N:
  print('-1 -1 -1')
  exit()
  

x = Y // 10000
y = (Y - x * 10000) // 5000
z = (Y - x * 10000 - y * 5000) // 1000
if x + y + z > N:
  print('-1 -1 -1')
  exit()
  
obj = N - (x + y + z)
for a in range(x+1):
  for b in range(x-a+1):
    for c in range(y+1):
      if(a + 9*b + 4*c == obj):
        print('{} {} {}'.format(str(x-a-b), str(y+2*a-c), str(z+10*b+5*c)))
        exit()

print('-1 -1 -1')

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

L='-1 -1 -1'
flag_=False
for tt in range(0,N+1):
    for ft in range(0,N-tt+1):
        ot=N-tt-ft
        if Y==(10000*tt)+(5000*ft)+(1000*ot):
            L=str(tt)+' '+str(ft)+' '+str(ot)
            flag_=True
                
if flag_:print(L)
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, j, n-i-j)
            exit()

print("-1 -1 -1")

Solution (Python):
N, Y = [int(n) for n in input().split()]
ans = (-1, -1, -1)
for x in range(N+1):
  for y in range(N-x+1):
    if Y == 10000*x+5000*y+1000*(N-x-y):
      ans = (x, y, N-x-y)
print("{} {} {}".format(ans[0],ans[1],ans[2]))

Solution (Python):
def main():
    n, y = [int(i) for i in input().split()]
    sw1 = False
    for i in range(n+1):
        for j in range(n-i+1):
            if 10000 * i + 5000 * j + 1000 * (n-i-j) == y:
                sw1 = True
                print(i, j, n-j-i)
                break
        if sw1:
            break
    else:
        print(-1, -1, -1)

if __name__ == '__main__':
    main()

Solution (Python):
N, Y = list(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('{} {} {}'.format(i, j, k))
      exit()

print('-1 -1 -1')

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

l = [-1, -1, -1]
flg = False
for i in range(N+1):
  for j in range(N+1-i):
    k = N-(i+j)
    if 10000*i + 5000*j + 1000*k == Y:
      l = [i, j, k]

print('{} {} {}'.format(l[0], l[1], l[2]))

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

xres, yres, zres = -1, -1, -1
flag = False
for x in range(0, N + 1):
  y = 0
  while (x + y) <= N:
    z = N - (x + y)
    if (10 * x + 5 * y + z) == Y / 1000:
      flag = True
      xres, yres, zres = x, y, z
      break
    y += 1
  if flag:
    break

print(xres, yres, zres)

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

Solution (Python):
i = input()
i = i.split(" ")
n = int(i[0])
y = int(i[1])
y = y / 1000
cn = []

for c in range(int(((y-n) // 9))+1):
  if (int((y-n-9*c)) % 4) == 0:
    cn.append([int((y-n-9*c) / 4), c])
  else:
    pass

if(len(cn) == 0):
  rs = [-1, -1, -1]
else:
  rs = []
  for j in cn:
    a = n - j[0] - j[1]
    if a >= 0:
      rs = [a, j[0], j[1]]
      break
    else:
      pass
  
  if len(rs) != 3:
    rs = [-1, -1, -1]
  else:
    pass
    
print(str(rs[2]) + " " + str(rs[1]) + " " + str(rs[0]))

Solution (Python):
n,y = map(int,input().split())
y = y//1000
for a in range(min((y-n)//9+1,n+1)):
    
    if (y-n-9*a)%4==0:
        b = (y-n-9*a)//4
        if a+b <= n:
            print(a,b,n-a-b)
            break
else:
    print(-1,-1,-1)

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

flg = False
for a in range(N + 1):
    if flg:
        break
    for b in range(N + 1):
        c = N-a-b
        if c < 0:
            continue
        total = a*10000 + b*5000 + c*1000
        if total == Y:
            print(str(a) + " " + str(b) + " " + str(c))
            flg = True
            break

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

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

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

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

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

Solution (Python):
import math
N, Y = map(int, input().split())
if Y % 1000 == 0:
    Y = Y // 1000
else:
    print('-1,-1,-1')
    exit()
for i in range(Y // 10 + 1):
    for j in range((Y-i*10) // 5 + 1):
        if i * 10 + j * 5 + (N - i - j) == Y and N-i-j >= 0:
            print(i, j, (N - i - j))
            exit()
print(-1, -1, -1)

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

for x in range(0, 2001):
    for y in range(0, 2001):
        if x + y > N:
            break
        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

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

for x in range(N+1):
    if x*10000 > Y:
        break
    if Y - x*10000 > (N-x)*5000:
        continue
    for y in range(N+1-x):
        if x*10000 + y*5000 > Y:
            break
        z = N - (x + y)
        if (x*10000 + y*5000 + z*1000) == Y:
            print(x,y,z)
            sys.exit()

print(-1,-1,-1)

Solution (Python):
import sys

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

for x in range(N+1):
    if x*10000 > Y:
        break
    if Y - x*10000 > (N-x)*5000:
        continue
    for y in range(N+1-x):
        z = N - (x + y)
        if (x*10000 + y*5000 + z*1000) == Y:
            print(x,y,z)
            sys.exit()

print(-1,-1,-1)

Solution (Python):
import sys

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

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

print(-1,-1,-1)

Solution (Python):
import sys

N, Y = 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)
            sys.exit()

print(-1,-1,-1)

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

r = (-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:
      print(i, j, n - i - j)
      exit()

print(*r)

Solution (Python):
N,Y = map(int,input().split())
ans = [-1,-1,-1]
flg = False
for a in range(N+1) :
    if flg :
        break
    for b in range(N+1-a) :
        c = N-a-b
        if c < 0 :
            break
        calc = 10000*a + 5000*b + 1000*c
        if calc == Y :
            ans = [a,b,c]
            flg = True
            break
print(*ans)

Solution (Python):

import sys

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


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

print('-1 -1 -1')

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

man = -1
gosen = -1
sen = -1
for m in range(N + 1):
    for g in range(N - m +1):
        s = N - m - g
        if m*10000 + g*5000 + s*1000 == Y:
            man = m
            gosen = g
            sen = s
print(man, gosen, sen)

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 = [int(_) for _ in input().split()]
Y = Y // 1000

for i in range(max(0, Y % 5), N + 1):
    for j in range(0, N + 1 - i):
        k = N - i - j
        if k < 0: continue
        
        if k * 10 + j * 5 + i == Y:
            print(k, j, i)
            exit()
print(-1, -1, -1)

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

ans = [-1,-1,-1]
for i in range(n,-1,-1):
    if i*10000 > y:
        continue
    else:
        yt = y-i*10000
        nt = n-i
        for j in range(min(yt//5000+1,nt+1)):
            yn = yt - j*5000
            nn = nt - j
            if nn*1000 == yn:
                ans = [i,j,nn]
                break
        if ans != [-1,-1,-1]:
            break
ans = map(str,ans)
a = " ".join(ans)
print(a)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n,y=map(int,input().split())
for i in range(n+1):
    if 10000*i+5000*(n-i) < y:
        continue
    for g in range(n+1-i):
        if 10000*i+5000*g+1000*(n-g-i)==y:
            print(i,g,n-g-i)
            sys.exit()
print(-1,-1,-1)

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

if not boolean:
    print(-1, -1, -1)

Solution (Python):
n, y = map(int, input().split())
b = [-1, -1, -1]
count = 0
for i in range(n + 1):
  for j in range(n + 1):
    k = n - i - j
    if k < 0:
      break
    total = 10000 * i + 5000 * j + 1000 * k
    count += 1
    if total == y and (i + j + k) == n:
      b = [i, j, k]
print('{0} {1} {2}'.format(b[0], b[1], b[2]))

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

for x in reversed(range(N+1)):
    for y in reversed(range(N+1-x)):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            print(x, y, z)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

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

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

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

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

Solution (Python):
def check(n, y):
    for i in range(y // 10000 + 1):
        for j in range(n - i + 1):
            k  = n - i - j
            if 10000 * i + 5000 * j + 1000 * k == y:
                return [i, j, k]

    return [-1, -1, -1]

n, y = map(int, input().split())
ans = check(n, y)
print(ans[0], ans[1], ans[2])

Solution (Python):
def check(n, y):
    for i in range(y // 10000 + 1):
        for j in range(n - i + 1):
            k  = n - i - j
            if 10000 * i + 5000 * j + 1000 * k == y:
                return [i, j, k]

    return [-1, -1, -1]

n, y = list(map(int, input().split()))
ans = " ".join(map(str, check(n, y)))
print(ans)

Solution (Python):
N, Y = map(int, input().split())
def total(x,y,z):
  return 10000 * x + 5000 * y + 1000 * z

for x in range(N + 1):
  for y in range(N + 1):
    z = N - x - y
    if 0<= z <= N and total(x,y,z) == Y:
      print(x,y,z)
      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+1):
        if i + j > n:
            break
        k = n - i - j
        if 10000*i + 5000*j + 1000*k == y:
            ans = "{} {} {}".format(i, j, k)

print(ans)

Solution (Python):
N, Y = map(int, input().split())
out_x = out_y = out_z = -1
for x in range(N+1):
  for y in range(N+1):
    price = x * 10000 + y * 5000
    if price > Y:
      break
    price = price + (N-x-y) * 1000
    if price == Y:
      out_x = x
      out_y = y
      out_z = N-x-y
      break
  if out_x != -1:
    break
print("{0} {1} {2}".format(out_x, out_y, out_z))

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

import sys

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)
            sys.exit()

print(-1, -1, -1)

Solution (Python):
N, Y=map(int, input().split())
max_100 = Y//10000
max_50 = Y//5000
max_10 = Y//1000
p=[[-1,-1,-1]]
flag = False
for x in range (max_100+1):
    for y in range(N-x+1):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
                p.append([x,y,N-x-y])
                flag = True
                break
    if flag:
        break
print(p[-1][0], p[-1][1], p[-1][2])

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

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

for a in range(n+1):  
    for b in range(n-a+1):  
        c = n-a-b
        if total == 10000 * a + 5000 * b + 1000 * c:
            x, y, z = a, b, c
            break

print(x, y, z)

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

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

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

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

sum = 0
cnt = 0
for x in range(N+1):
    for y in range(N+1-x):
        sum = 10000*x + 5000*y + 1000*(N-x-y)
        if sum == Y:
            cnt += 1
            print(str(x) + ' ' + str(y) + ' ' + str(N-x-y))
            break
    else:
        continue
    break
if cnt == 0:
    print('-1 -1 -1')

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

N1000 = -1
N5000 = -1
N10000 = -1

flag = False
for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        if 1000*i+5000*j+10000*k == Y:
            N1000 = i
            N5000 = j
            N10000 = k
            flag = True
            break
    if flag:
        break

print(N10000, N5000, N1000)

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

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

N, sum = map(int, input().split())
NG = '-1 -1 -1'












s1000 = (sum // 1000 - N)
for b in range(0, N+1):
    
    if (s1000 - 4*b) % 9 == 0:

        a = (s1000 - 4*b) // 9
        c = N-a-b
        if 0 <= a and 0 <= b and 0 <= c:
            print(a, b, c)
            exit()
        else:
            print(NG)
            exit()

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

result = "-1 -1 -1"

for i in range(N+1):
    if result != "-1 -1 -1":
        break
    if i * 10000 > Y:
        break
    for j in range(N-i+1):
        k = N-i-j
        if i * 10000 + j * 5000 + k * 1000 == Y:
            result = "{} {} {}".format(i, j, k)
            break
        elif i * 10000 + j * 5000 + k * 1000 > Y:
            break

print(result)

Solution (Python):
import sys
n, y = list(map(int, input().split(' ')))
y = y/1000
result = [-1,-1,-1]
for p in range(n+1):
    for q in range(n-p+1):
        if p*10+q*5+(n-p-q) == y:
            print(p, q, n-p-q)
            sys.exit()

print(' '.join(list(map(str, result))))

Solution (Python):
import sys

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



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

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

is_concerned = False

for i in range(n+1):
  for j in range(n-i+1):
      k = n - i - j
      if k < 0:
        break
      if y == 1000 * i + 5000 * j + 10000 * k:
        print( k,j,i )
        is_concerned = True
        break
  if is_concerned == True:
    break

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

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

for a in range(n + 1):
  for b in range(n + 1 - a):
    c = n - a - b
    if 10 * a + 5 * b + c == y:
      print('{} {} {}'.format(a, b, c))
      break
  else:
    continue
  break
else:
  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())
for i in range(n+1):
    for r in range(n+1-i):
        x=n-r-i
        total = 10000*i+5000*r+1000*x
        if total==y and i+r+x==n:
            print(i,r,x)
            exit()
print(-1,-1,-1)

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

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

s = y//1000

if n > s:
    print("-1 -1 -1")
elif n == s:
    print("0 0 "+str(s))
else:
    flag = False
    sup = s-n
    f = 0
    t = 0
    for i in range(sup//4+max(1-sup%4,0)):
        if (sup-4*i)%9 == 0:
            f = i
            t = (sup-4*i)//9
            if s-(f*5+t*10) >= 0:
                flag = True
                
                break
            else:
                flag = False
    if flag:
        print(t,f,s-(f*5+t*10))
    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 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())
flag = 0
yuki = 0
while True:
  if yuki * 10000 > y:
    break
  ichi = 0
  while True:
    h = (y - yuki * 10000 - ichi * 5000) // 1000
    if h < 0:
      break
    if h == n - yuki - ichi:
      print(str(yuki) + ' ' + str(ichi) + ' ' + str(h))
      flag = 1
      break
    ichi += 1
  yuki += 1
  if flag == 1:
    break
if flag == 0:
  print('-1 -1 -1')

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

k_max = Y // 1000
extra = k_max - N
if extra < 0:
    print('-1 -1 -1')
else:
    for x in range(N + 1):
        y = (extra - 9 * x) // 4
        if (extra - 9 * x) % 4 == 0 and x + y <= N and y >= 0:
            print(x, y, N - x - y)
            break
    else:
        print('-1 -1 -1')

Solution (Python):
N,Y=map(int,input().split())
Y//=1000
for i in range(N+1):
	a = Y-10*i
	for j in range(N+1-i):
		b = a-5*j
		if b == N-i-j:
			print(i,j,b)
			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+1):
        if i + j > n:
            continue
        k = n - i - j
        if i * 10000 + j * 5000 + k * 1000 == y:
            ans = list(map(str, [i, j, k]))
            break
print(" ".join(ans))

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

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

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

Solution (Python):
def otoshidama(N, Y):
        y = Y/1000
    
        for a in range(int(y/10)+1, -1, -1):
            for b in range(N - a, -1, -1):
                c = N - a - b
                if 10*a + 5*b + c == y:
                    return a, b, c


        return -1, -1, -1
    
if __name__ == '__main__':
    N, Y = map(int,input().split())
    a, b, c = otoshidama(N, Y)
    print(a, b, c)

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

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

Solution (Python):
input_data = input()
N, Y = map(int, input_data.split())
result = False
count_10000 = 0
count_5000 = 0
count_1000 = 0

for count_10000 in range(0, N + 1):
    for count_5000 in range(0, N + 1 - count_10000):
        count_1000 = N - count_10000 - count_5000
        total = count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000
        count = count_10000 + count_5000 + count_1000
        if total == Y and count == N:
            result = True
            break
    else:
        continue
    break

if result:
    print("{} {} {}".format(count_10000, count_5000, count_1000))
else:
    print("-1 -1 -1")

Solution (Python):
a,b =map(int,input().split())
 


 
i=0
j=0
flag=0
while i<= a:
  j=0
  while j <= a-i:
    k=a-i-j
    
    
    if 10000*i+5000*j+1000*k==b:
      print(i,j,k)
      flag=1
      break
    
    if flag==1:
      break
    j=j+1
  if flag==1:
    break
  
  i=i+1
if flag==0:
  print(-1,-1,-1)

Solution (Python):

import sys


def solve(N: int, Y: int):
    def f(n, y):
        if y > 10000*n:
            return "-1 -1 -1"
        if y < 1000*n:
            return "-1 -1 -1"

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

    print(f(N, Y))


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))  
    solve(N, Y)

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 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 a in range(N + 1):
  for b in range(N - a + 1):
    c = N - a - b
    if a * 10000 + b * 5000 + c * 1000 == Y:
      flag = True
      break
  if flag:
    break
if flag:
  print("{} {} {}".format(a, b, c))
else:
  print("-1 -1 -1")

Solution (Python):
import sys

num, total = list(map(int, sys.stdin.read().split(" ")))
for i in range(total // 10000, -1, -1):
  amount = total - 10000 * i
  if amount == 0 and i == num:
    print("%d 0 0"%i)
    sys.exit(0)
  for j in range(amount // 5000, -1, -1):
    amountj = amount - 5000 * j
    if amountj == 0 and i+j == num:
      print("%d %d 0"%(i, j))
      sys.exit(0)
    k = amountj // 1000
    if i+j+k == num:
      print("%d %d %d"%(i, j, k))
      sys.exit(0)
print("-1 -1 -1")

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

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

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

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

iteration_number = n + 1


def find_combination(iter_num):
    for i in range(iter_num):
        for j in range(iter_num - i):
            sum_money = (10000 * i) + (5000 * j) + (1000 * (n - i - j))
            if sum_money == y:
                return [i, j, n - i - j]
    return [-1, -1, -1]


combination_list = find_combination(iteration_number)

print(*combination_list, sep=" ")

Solution (Python):
N, Y = map(int, input().split())
res_10000 = res_5000 = res_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:
            res_10000 = a
            res_5000 = b
            res_1000 = c

print(str(res_10000) + ' ' + str(res_5000) + ' ' + str(res_1000))

Solution (Python):
def main():
    N, Y = map(int, input().split())
    for a in range(N+1):
        b = 0
        while a + b <= N:
            c = N - a - b

            total = 10000 * a + 5000 * b + 1000 * c
            if total == Y:
                print(a, b, c)
                return
            b += 1
    print(-1, -1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
def main():

    N, Y = map(int, input().split())
    count = 0
    for z in range(N + 1):
        for y in range(N - z + 1):
            X = Y - 1000 * z - 5000 * y
            if X % 10000 == 0:
                x = X // 10000
                if x + y + z == N:
                    count += 1
                    if count == 1:
                        print(x, y, z)
    if count == 0:
        print("-1 -1 -1")


if __name__ == "__main__":
    main()

Solution (Python):
def solve():
    n, y = list(map(int, input().split()))
    for man in range(n + 1):
        for gosen in range(n - man + 1):
            sen = n - man - gosen
            total = 10000 * man + 5000 * gosen + 1000 * sen
            if total == y:
                return ' '.join([str(man), str(gosen), str(sen)])
    return ' '.join(["-1", "-1", "-1"])


if __name__ == "__main__":
    print(solve())

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

for x in range(n + 1):
    for y in range(n + 1):
        if n-x-y < 0:
            break
        if x * 10000 + y * 5000 + (n - x - y) * 1000 == s:
            print('%d %d %d' % (x, y, n - x - y))
            exit()
print('-1 -1 -1')