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):
import sys

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

for m in range(N+1):
  g = (Y//1000 - N - 9*m) / 4
  s = N - m - g
  if g >= 0 and s >= 0 and g == int(g):
    print(m, int(g), int(s))
    sys.exit()
print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split())
X_yen = 10000
Y_yen = 5000
Z_yen = 1000
x = y = z = -1
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:
            x = a
            y = b
            z = c
print(x, y, z)

Solution (Python):
from sys import stdin
import sys
if __name__ == "__main__":
    
    

    N, Y = (int(item) for item in stdin.readline().rstrip().split())

    for a in range(0, N+1):
        max_b = N-a
        for b in range(0, max_b+1):
            c = N - a - b
            if Y == a*10000 + b*5000 + c*1000:
                print(a, b, c)
                sys.exit(0)
    print("-1 -1 -1")

Solution (Python):
n,y = map(int,input().split())
a = 10000
b = 5000
c = 1000
for i in range(n+1):
    for j in range(n-i+1):
        if a*i + b*j + c*(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(n+1):
    if i*10000>y:break
    for j in range(n-i+1):
        if i*10000+j*5000>y:break
        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())
flag=False
ans=[-1,-1,-1]
for i in range(n+1):
    for j in range(n+1-i):
        otoshidama=10000*i+5000*j+1000*(n-i-j)
        if otoshidama==y:
            flag=True
            ans[0]=i
            ans[1]=j
            ans[2]=n-i-j
            break
print('{0} {1} {2}'.format(ans[0],ans[1],ans[2]))

Solution (Python):
li = list(map(int,input().split()))
num = li[0]
money = li[1]

answer = ""

for i in range(num + 1):
  for j in range(num + 1 - i):
    if i*10000 + j*5000 + 1000*(num - (i + j)) == money:
      a = num - (i + j)
      answer = "{} {} {}".format(i, j, a)

if answer == "":
  answer = "-1 -1 -1"

print(answer)

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

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

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

Solution (Python):
maisu, kingaku = [int(x) for x in input().split()]
result = [-1,-1,-1]
for itr_10000 in range(maisu+1):
    for itr_5000 in range(maisu+1-itr_10000):
        itr_1000 = maisu - itr_5000 - itr_10000
        total = itr_10000*10000 + itr_5000*5000 + itr_1000*1000
        if total == kingaku:
            result = [itr_10000, itr_5000, itr_1000]
result = map(str, result)
print(' '.join(result))

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

Solution (Python):
n,y=map(int, input().split())
a=-1
b=-1
c=-1
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:
      a=i
      b=j
      c=k
print(a,b,c)

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

item = [10000, 5000, 1000]

result = '-1 -1 -1'
for num_10000 in range(N + 1):
    for num_5000 in range(N - num_10000 + 1):
        if Y == 10000 * num_10000 + 5000 * num_5000 + 1000 * (N - num_10000 -num_5000):
            result = str(num_10000)  + " " + str(num_5000) + " " + str(N- num_10000 -num_5000)
            break
print(result)

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

Solution (Python):
N,Y = map(int,input().split())
y = Y/1000
Answer = [-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/1000:
      Answer = [i, j, N-i-j]
      print(*Answer)
      exit()
print(*Answer)

Solution (Python):
N, total = map(int, input().strip().split(" "))
bills = [-1, -1, -1]

for i in range(int(total/10000)+1):

    x = total - 10000*i

    for j in range(int(x/5000)+1):

        y = x-5000*j

        k = N - i -j

        if y-1000*k == 0:
    
            bills = [i, j, k]
            break

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, Y = LI()
    Y = Y // 1000
    for i in range(N+1):
        for j in range(N-i+1):
            k = N - i - j
            mon = 10 * i + 5 * j + k
            if mon == Y:
                print(i, j, k)
                return
    print('-1 -1 -1')

main()

Solution (Python):
osatsu, okane = map(int, input().split())





x_max = okane // 10000

for x in range(x_max + 1):
    z_max = (okane // 1000)
    tmp = z_max - osatsu - 9 * x
    if tmp % 4 != 0 or tmp < 0:
        continue
    y = tmp // 4
    z = osatsu - x - y
    if z < 0:
        continue

    print(x,y,z)
    break
else:
    print(-1, -1, -1)

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

Solution (Python):
N,Y = (int(i) for i in input().split())
a,b,c = -1,-1,-1
for n_10000 in range(N+1):
    for n_5000 in range(N-n_10000+1):
        n_1000 = N-n_10000-n_5000
        if 10000*n_10000+5000*n_5000 +1000*n_1000 == Y:
            a,b,c = n_10000,n_5000,n_1000
print(a,b,c)

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

for i in range(0,Y//10000+1):
    price = Y
    price -= i*10000
    for j in range(0, price//5000+1):
        if (i*10000 + j*5000 + (N-i-j)*1000 == 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 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 10000 * i + 5000* j + 1000 * (n-i-j) == y:
            ans = "%s %s %s"%(i, j, n-i-j)
            break
        else:
            continue
try:
    print(ans)
except:
    print("-1 -1 -1")

Solution (Python):
import math
import fractions

N, Y = map(int, input().split())
possible = 0
for x in range(N + 1):
    flag = 0
    for y in range(N - x + 1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            possible = 1
            flag = 1
            print(x, y, N - x - y)
            break
    if flag:
        break
if not possible:
    print(-1, -1, -1)

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

satsu = []

con = 0

for i in range(0,N + 1):
  total = 0
  
  
  
  for j in range(0,N + 1 - i):
    total = (10000 * i) + (5000 * j) + (1000 * (N - (i + j)))
    if total == Y:
      satsu.append([i,j,N - (i + j)])
      con += 1
      break
  if total == Y:
    break

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

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):
        k=N-i-j
        if i*10000+5000*j+k*1000==Y:
            flag=True
            break
    if flag:
         break

if flag:
    print(str(i)+' '+str(j)+' '+str(k))
else:
    print('-1 -1 -1')

Solution (Python):
import sys

n, y = map(int, sys.stdin.readline().split())
y //= 1000

def main():
    for i in range(n, -1, -1):
        for j in range(n-i, -1, -1):
            k = n - i - j
            if 10*i + 5*j + k == y:
                return i, j, k
    return -1, -1, -1

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Solution (Python):
n, y = list(map(int, input().split()))
flag = False
for a_child in range(0, n+1):
    if flag:
        break
    a_child_result = y - a_child * 10000
    for b_child in range(0, n+1-a_child):
        b_child_result = a_child_result - b_child * 5000
        c_child = n - a_child - b_child
        c_child_result = b_child_result - c_child * 1000
        if c_child_result == 0:
            print(a_child, b_child, c_child)
            flag = True            
if flag:
    pass
else:
    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):
        k = N-i-j
        if (i*10000+j*5000+k*1000 == Y) and (i+j+k == N) and (k >= 0):
            print(i,j,k)
            flag = 1
            break
    if flag == 1:
        break

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

Solution (Python):




nums=list(map(int,input().split()))
n = nums[0]
y = nums[1]

lower = max(0, int((y-10000*n)/4000))
upper = min(n, int((y-1000*n)/4000))

for b in range(lower, upper + 1):
    a = (y - 1000*n - b*4000) / 9000
    if a.is_integer():
        c = n - b - a
        if c >= 0:
            print(int(a), int(b), int(c))
            exit()

print(-1, -1, -1)

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

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

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

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

Solution (Python):
n,y=[int(i) for i in input().split()]
ex=False
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:
      ex = True
      break
  if ex:
    break
if ex:
  print('{} {} {}'.format(i,j,k))
else:
  print('-1 -1 -1')

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

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

NUMS = list(range(N+1))


ans = [-1, -1, -1]
found = False
for x in NUMS:
  for y in NUMS:
    if N - x - y >= 0:
      z = N - x - y
      m = 10000 * x + 5000 * y + 1000 * z
      if m == Y and x + y + z == N:
        ans = x, y, z
        found = True
        break
  if found:
    break
      
print(' '.join([str(n) for n in ans]))

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

Solution (Python):
def otoshi():

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

  print(-1,-1,-1)

otoshi()

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:continue
    s=10000*i+5000*j+1000*k
    if s==y:
      print(i,j,k)
      exit()
      
print(-1,-1,-1)

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

Solution (Python):

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


for i in range(y//10+1):
  for j in range((y-10*i)//5+1):
    k=n-i-j
    if 10*i+5*j+1*k==y and k>=0:
      print(i,j,k)
      exit()
      
print(-1,-1,-1)

Solution (Python):

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


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

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

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

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

ok = 0
for i in range(n+1):
  for j in range(n+1-i):
    x1 = i
    x2 = j
    x3 = n-i-j
    if (10000*x1 + 5000*x2 + 1000*x3) == y:
      ok = 1
      break
  if ok:
    break
  
print("%d %d %d"%(x1, x2, x3)) if ok else print("-1 -1 -1")

Solution (Python):
import sys

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

for i in reversed(range(N+1)):
    if Y < i * 10000:
        continue
    for j in reversed(range(N+1)):
        k = N - i - j
        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

Solution (Python):
import sys

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

for i in reversed(range(N+1)):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        k = N - i - j
        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

Solution (Python):
import sys

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

for i in range(N+1):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        if N < i + j or Y < i * 10000 + j * 5000:
            break
        k = N - i - j
        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

Solution (Python):
import sys

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

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

        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

Solution (Python):
N,Y=map(int,input().split())
flg=0
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:
            flg=1
            print(i,j,k)
            break
    if flg==1:
        break

if flg==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):
        x = 10000*i + 5000*j + 1000*(N-i-j)
        if x==Y:
            print(i,j,N-i-j)
            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-i+1):
    
    if Y == 1000*i + 5000*j + 10000*(N-i-j):
      flag = 1
      print("{} {} {}".format(N-i-j,j,i))
      break
  if flag:
     break
if flag == 0:
  print("-1 -1 -1")

Solution (Python):

import sys
input = sys.stdin.readline

def solve():
    n,y = list(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):
                return (i,j,n-i-j)
    return(-1,-1,-1)
print(" ".join(map(str,solve())))

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

Solution (Python):
n, y =  map(int, input().split())
 
res_a = -1
res_b = -1
res_c = -1
 
for i in range(n+1):
  for j in range(n+1):
      if 10000*i + 5000*j + 1000*(n-i-j) == y and i+j <= n:
        res_a, res_b, res_c = i, j, n-i-j
        break
        
print(res_a, res_b, res_c)

Solution (Python):
n,y=map(int,input().split())
anslist=[]
for i in range(n+1):
    for j in range(n-i+1):
        if i*10000+j*5000+(n-i-j)*1000 == y :
            list=[i,j,n-i-j]
            anslist.append(list)
if len(anslist)>0:
    print("{} {} {}".format(anslist[0][0],anslist[0][1],anslist[0][2],))
else:
    print("{} {} {}".format(-1,-1,-1))

Solution (Python):
n,y=map(int,input().split())
anslist=[]
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("{} {} {}".format(-1,-1,-1))

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

cnt_10000 = 0
cnt_5000 = 0
cnt_1000 = 0

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:
      cnt_10000 = i
      cnt_5000 = j
      cnt_1000 = N - i - j
      
    if 10000 * i + 5000 * j + 1000 * (N - i - j) > Y:
      break

if cnt_10000 == 0 and cnt_5000 == 0 and cnt_1000 == 0:
  print('-1 -1 -1')
else:
  print(str(cnt_10000) + ' ' + str(cnt_5000) + ' ' + str(cnt_1000))

Solution (Python):
n, m = map(int, input().split())
yu, ic, hi = -1, -1, -1
for x in range(n+1):
	for y in range(n-x+1):
		z = n - x - y
		if 10000*x + 5000*y + 1000*z == m:
			yu, ic, hi = x, y, z
			break
print(yu, ic, hi)

Solution (Python):

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

Solution (Python):
a = input().split()
m, tot = int(a[0]), int(a[1])

count = 0
for i in range(m+1):
  for j in range(m+1):
    k = m - i - j
    if k >= 0:
    	tot_sim = 10000*i + 5000*j + 1000*k
    	if tot == tot_sim:
      		print(i,j,k)
      		count += 1
      		exit()
if count == 0:
  print("-1 -1 -1")

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


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

Solution (Python):

a, b = map(int, input().split())

l, m, n = map(int, "-1 -1 -1".split())

for x in range(a + 1):
    for y in range(a + 1):
        z = a - x - y
        if z >= 0 and x*10000 + y*5000 + z*1000 == b:
            l = x
            m = y
            n = z
print(l,m,n)

Solution (Python):
def main():
    n,y = map(int, input().split())
    n1000 = y/1000
    n5000 = 0
    n10000 = 0
    a,b,c = -1, -1, -1
    flag = False
    if n <= n1000:
        for bi in range((y//5000)+1):
            for ci in range((y//10000)+1):
                if n1000-5*bi-10*ci >= 0:
                    if n1000-4*bi-9*ci == n:
                        c = n1000-5*bi-10*ci
                        b = bi
                        a = ci
                        flag = True
                        break
                else:
                    break
            if flag:
                break
    print(int(a),int(b),int(c))
        


if __name__ == "__main__":
    main()

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

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

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:
            ans = [x,y,z]
            break

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

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

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:
            ans = [x,y,z]

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

Solution (Python):
import sys
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("{} {} {}".format(i,j,n-i-j))
      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+1-i):
    if 10000*i+5000*j+1000*(n-i-j) == y:
      print("{} {} {}".format(i,j,n-i-j))
      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):
        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())
kekkas = []
for a in range(2001):
  for b in range(2001):
    kekka = 9000*a + 4000*b - (y - 1000*n)
    if kekka == 0:
      c = n - a - b
      if c >= 0:
        kekkas.append((a,b,c))
if len(kekkas) > 0 :
  print(str(kekkas[0][0]) + " " + str(kekkas[0][1]) + " " + str(kekkas[0][2]))
else:
  print("-1 -1 -1")

Solution (Python):


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

Solution (Python):


n, t = map(int, input().split(' '))

def check(n, t):
  if t % 1000 != 0:
    print(-1, -1, -1)
    return
  if t // 1000 - n < 0:
    print(-1, -1, -1)
    return
  p = t // 1000 - n
  for i in range(n + 1):
    for j in range(0, n - i + 1):
      if i * 9 + j * 4 == p:
        print(i, j, n - i - j)
        return
  print(-1, -1, -1)

check(n, t)

Solution (Python):
n,y=map(int,input().split())
y=y//1000
f=0
ans=[-1,-1,-1]
for i in range(y//10+1):
    z=y-i*10
    for j in range(z//5+1):
        w=z-j*5
        if w+i+j==n:
            ans=[i,j,w]
            f=1
            break
    if f==1:
        break
print(" ".join(list(map(str,ans))))

Solution (Python):



def solve(*args: str) -> str:
    n, y = map(int, args[0].split())

    for man in range(n+1):
        for gosen in range(n-man+1):
            sen = n-man-gosen
            if y//1000 == (10*man)+(5*gosen)+sen:
                return '{} {} {}'.format(man, gosen, sen)

    return '-1 -1 -1'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):



def solve(*args: str) -> str:
    n, y = map(int, args[0].split())

    man = 0
    while man <= n:
        gosen = 0
        while gosen <= n-man:
            sen = n-man-gosen
            if y//1000 == (10*man)+(5*gosen)+sen:
                return '{} {} {}'.format(man, gosen, sen)

            gosen += 1
        man += 1

    return '-1 -1 -1'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):



def solve(*args: str) -> str:
    n, y = map(int, args[0].split())

    man = 0
    while man <= n and man*10000 <= y:
        gosen = 0
        while gosen <= n-man and (man*10000)+(gosen*5000) <= y:
            left = y-(man*10000)-(gosen*5000)
            sen = n-man-gosen
            if left < 0 or sen < 0:
                break
            if left == sen*1000:
                return '{} {} {}'.format(man, gosen, sen)

            gosen += 1
        man += 1

    return '-1 -1 -1'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):
import sys


def solve(N: int, Y: int):
    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)
                return

    print("-1 -1 -1")
    return



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())
y = y/1000
a = 0
b = -1
c = -1
f = False
while (y-n-9*a >=0):
    if (y-n-9*a)%4 == 0:
        b = int((y-n-9*a)//4)
        c = n - a - b
        if c>=0:
            f = True
            break
    a+=1
if f == False:
    a = -1
    b = -1
    c = -1
print(a, b, c)

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

def func(n, y):
    for a in range(n+1):
        for b in range(n+1):
            if a+b <= n and 10000*a + 5000*b + 1000*(n-a-b) == y:
                print('{} {} {}'.format(a,b,n-a-b))
                return 0
    print("-1 -1 -1")
    return 0

func(n, y)

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

a=b=c = -1
if N * 10 >= Y or Y < N:
  for x in range(0,N+1):
    for y in range(0,N-x+1):
      if Y == (x + y * 5 + 10 * (N - x - y)):
        a=x
        b=y
        c=(N - x - y)
        break
      if (a != -1):
        break
print('{} {} {}'.format(c, b, a))

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

x = int(total/10000)
y = int(total/5000)
 
arr = []
for i in range(x+1):
    for j in range(y+1):
        if (9000*i + 4000*j == total - 1000*N) and (N-i-j >= 0):
            arr.append([i,j,N-i-j])
 
if len(arr) == 0:
    print('-1 -1 -1')
else:
    print(arr[0][0], arr[0][1], arr[0][2])

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

Solution (Python):
n, y = map(int, input().split())
y //= 1000
m = y // 10
for mc in range(m, -1, -1):
  m1 = y - 10 * mc
  g = m1 // 5
  for gc in range(g, -1, -1):
    sc = m1 - 5 * gc
    if mc + gc + sc == n:
      print(mc, gc, sc)
      quit()
print(-1, -1, -1)

Solution (Python):
n, y = map(int, input().split())
y //= 1000
m = y // 10
for mc in range(m, -1, -1):
  g = (y - 10 * mc) // 5
  for gc in range(g, -1, -1):
    sc = y - 10 * mc - 5 * gc
    if mc + gc + sc == n:
      print(mc, gc, sc)
      quit()
print(-1, -1, -1)

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

y = y//1000
flag = False
ans = [-1,-1,-1]
for a in range(n+1):
    for b in range(n+1):
        t = y-(a*10+b*5)
        if t >= 0 and n == a+b+t:
            ans = [a,b,t]
            flag = True
            break
    if flag:
        break
print("{} {} {}".format(ans[0],ans[1],ans[2]))

Solution (Python):
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, Y = MAP()

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:
			print("{} {} {}".format(i, j, k))
			sys.exit()
print('-1 -1 -1')

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

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