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())
a = 10000
b = 5000
c = 1000
list = []
for i in range(n+1):
        for j in range((n+1)-i):
                
                        total = a*i + b*j + c*(n-(i+j))
                        if total == y:
                                new_list = [i, j, (n-(i+j))]
                                list.append(new_list)
                                print("{} {} {}".format(i, j, (n-(i+j))))
                                exit()
if not list:
        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
        if 10000*i + 5000*j + 1000*k == Y:
            a,b,c = i,j,k
            break
print(a,b,c)

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

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

Solution (Python):
"""

times = int(input())  

data = [int(input()) for i in range(times)] 

N = data[0]

cards = data[0:]


for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] < cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      


print(len(set([str(x) for x in cards])))
"""

data = input().split(" ")
N = int(data[0])
tol = int(data[1])

tmp1 = 0
tmp2 = 0
tmp3 = 0

for i in range(0, N + 1, 1):
  for j in range(0, N + 1 - i, 1):
    k = N - i - j
    if (10000 * i + 5000 * j + 1000 * k) == tol and (i + j + k) == N:
      tmp1 = i
      tmp2 = j
      tmp3 = k
      break
  if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
    break

if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
  print("{0} {1} {2}".format(tmp1, tmp2, tmp3))
else:
  print("-1 -1 -1")

Solution (Python):
def main():
  num, money  = map(int, input().split())
  
  array = [-1,-1,-1]
  for i in range(num+1):
    for j in range(num+1):
      if i + j > num:
        continue
      sum = i*10000 + j*5000 + (num-i-j)*1000
      if sum == money:
        array[0]=i
        array[1]=j
        array[2]=num-i-j
        break
  print("{0[0]} {0[1]} {0[2]}".format(array))
  
main()

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

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

Solution (Python):


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

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

print('-1', '-1', '-1')

Solution (Python):


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

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

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

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

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

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

for i in range(n+1):
    a1 = 10000 * i
    for j in range(n+1-i):
        a2 = 5000 * j
        k = n- (i+j)
        a3 = k*1000
        if a1 + a2 + a3  == y and i + j + k == n:
            print(i, j , k)
            ans += 1
            exit(0)
    if ans == 1:
        break
if ans == 0:
    print(-1, -1, -1)

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

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

Solution (Python):


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

i = 0
j = 0
k = 0

l = [-1,-1,-1]


for i in reversed(range(0,n+1)):
    
    if  y >= i*10000:
        for j in reversed(range(0,n-i+1)):
            
            k = n - i - j
            
            if  y == i*10000 + j*5000 + k*1000:
                l = [i, j, k]


                break
        else:
            continue
        break


                

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

Solution (Python):
N,Y=map(int,input().split())
for x in range(0,N+1):
    if x==N:
        x_money=10000*x
        if x_money==Y:
            print('{} {} {}'.format(x,0,0))
            exit()
    elif x<N:
        x_money=10000*x
        for y in range(0,N+1-x):
            if x+y==N:
                y_money=5000*y
                if x_money+y_money==Y:
                    print('{} {} {}'.format(x,y,0))
                    exit()     
            elif x+y<N:
                y_money=5000*y
                z=N-(x+y)
                z_money=1000*z
                if x_money+y_money+z_money==Y:
                    print('{} {} {}'.format(x,y,z))
                    exit()
print('-1 -1 -1')

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

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

Solution (Python):
n, y = map(int,input().split())
ans = 0
for a in range(0, n+1):
    for b in range(0, n+1):
        c = n - a - b
        if 10000*a + 5000*b + 1000*c == y and c >= 0 and ans ==0:
            print(a, b, c)
            ans = 1
if ans == 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 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())

i = 0
j = 0
k = 0

l = [-1,-1,-1]


for i in reversed(range(0,n+1)):
    
    if  y >= i*10000:
        for j in reversed(range(0,n-i+1)):
            
            k = n - i - j
            
            if  y == i*10000 + j*5000 + k*1000:
                l = [i, j, k]
                

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

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

flag = False
for a in range(N+1):
	for b in range(N+1-a):
		if 10000 * a + 5000 * b + 1000 * (N - a - b) == Y:
			print(a, b, N-a-b)
			flag = True
			break
	if flag:
		break

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

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

res10000,res5000,res1000 = -1,-1,-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:
            res10000 = a
            res5000 = b
            res1000 = c
print(res10000,res5000,res1000)

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

print(*ans)

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

print("-1 -1 -1")

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

def check(N, Y):
    for a in range(N+1):
        for b in range(N-a+1):
            c = N-a-b
            if 10000*a + 5000*b + 1000*c == Y:
                return "{} {} {}".format(a,b,c)
    return False

result = check(N,Y)
if result:
    print(result)
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 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())
f = 0
for a in range(N+1):
    if f != 0:break
    for b in range(N+1-a):
        if a*10000+b*5000+(N-a-b)*1000 == Y:
            print(a,b,N-a-b)
            f = 1
            break
if f == 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 (10000*i + 5000*j + 1000*(n-i-j)) == y:
            print(i,j,n-i-j)
            exit()
            
print("-1 -1 -1")

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)


n,t= (int(i) for i in input().split())       










for i in range(n+1):
    for k in range(n-i+1):
        m = n-k-i
        if 10000*i+5000*k+1000*m==t:
            print(i,k,m)
            exit(0)
print(-1,-1,-1)

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

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

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

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

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

for i in range(N+1):
    j = N - i
    y = Y - 10 * i
    y -= j
    if y < 0:
        continue
    if y % 4 == 0 and y // 4 <= j:
        print(" ".join(map(str,[i,y//4,j-y//4])))
        exit()

print("-1 -1 -1")

Solution (Python):
n,y=map(int,input().split())
a=b=c=-1

for i in range(n+1):
    total=0
    for j in range(n+1):
        k=n-i-j
        if k<0 :
            continue
        total=10000*i+5000*j+1000*k
        if total==y:
            a=i
            b=j
            c=k
print('{} {} {}'.format(a,b,c))

Solution (Python):
def main():
    N, Y = map(int, input().split())
    Y /= 1000
    for a in range(N + 1):
        for b in range(N + 1 - a):
            c = N - a - b
            
            if 10 * a + 5 * b + 1 * c == Y:
                print(a, b, c)
                return
    print(-1, -1, -1)
if __name__ == '__main__':
    main()

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

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

count = 0
for i in range(0,N+1):
    for j in  range(0,N+1):
        tmp = Y - i * 10000 - j * 5000
        k = tmp // 1000
        if 0 <= k and tmp % 1000 == 0 and i + j + k == N:
            print(i,j,tmp//1000)
            exit()
        
print(-1,-1,-1)

Solution (Python):

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


def judge(N, Y):
    for x in range(0, N+1):
        for y in range(0,N-x+1):
            a = Y - (10000 * x + 5000 * y) 
            z = a // 1000
            if x + y + z == N:
                return x, y, z
    return -1, -1, -1

lst =list(judge(N, Y))
ans = str(lst[0]) + ' ' + str(lst[1]) + ' ' + str(lst[2])

print (ans)

Solution (Python):
n, y = map(int, input().split())
found = False
for i in range(n+1):
  for j in range(n+1-i):
    if i + j+ (n-i-j) == n and 10000*i+5000*j+1000*(n-i-j) == y:
        print(i, j, n-i-j)
        found = True
        break
  else:
    continue
  break 
if not found:
  print("-1 -1 -1")

Solution (Python):




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

cashl = [10000, 5000, 1000]
ansl = [-1, -1, -1]
eflg = False


for i in range(n+1):
    for j in range((n+1)-i):
        subt = i * cashl[0] + j * cashl[1]
        k = int((y - subt) / 1000)

        total = subt + k * cashl[2]
        bcnt = i + j + k

        if total == y and bcnt == n:
            ansl[0] = i
            ansl[1] = j
            ansl[2] = k
            eflg = True
            break

    if eflg == True:
        break


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

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

ans = []
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.append([i,j,k])

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

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

for i in range(ny[0] + 1):
    for j in range(ny[0] + 1):
        if (1000 * i + 5000 * j <= ny[1]) and ((ny[1] - 1000*i - 5000*j) % 10000 == 0) and \
        ((ny[1] - 1000*i - 5000*j) // 10000 + i + j == ny[0]):
            print((ny[1] - 1000*i - 5000*j) // 10000, j, i)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Solution (Python):
import numpy as np


A = list(map(int, input().split()))
N = A[0]
Y = A[1]
Y = Y/1000
Ans = [-1,-1,-1]
for i in range(N+1):
	for j in range(N+1):
		okane = i + 5* j
		if okane + 10*(N-i-j) == Y and 0 <= N-i-j:
			Ans[0]=(N-i-j)
			Ans[1]=(j)
			Ans[2]=(i)
print(' '.join(map(str, Ans)))

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

ans = []
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.append([i,j,k])

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

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

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

Solution (Python):
N, Y = map(int, input().split())
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())

f = False
for i in range(N+1):
  if f:
    break
  for j in range(N+1-i):
    if f:
      break
    k = N - i - j
    p = 10000 * i + 5000 * j + 1000 * k
    if p == Y:
      print("{0} {1} {2}".format(i, j, k))
      f = True
if not f:
  print('-1 -1 -1')

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

existed = False
for man_ichi in range(n+1):
	for sen_go in range(n+1-man_ichi):
		if y == (man_ichi*10000 + sen_go*5000 + (n-man_ichi-sen_go)*1000):
			print(man_ichi, sen_go, n-man_ichi-sen_go)
			break
	else:
		continue
	break
else:
	print(-1, -1, -1)

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

res = "{} {} {}"
def calc(N, Y):
    tmp = 0
    for i in range(N+1):
        for k in range(N+1-i):
            w = N-i-k
            tmp = i * 10000 + k * 5000 + w * 1000
            if tmp == Y:
                return res.format(i, k, w)
    return res.format(-1, -1, -1)

print(calc(N,Y))

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

yukichi = -1
ichiyo = -1
hideyo = -1
for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        total = i*10000 + j*5000 + k*1000
        if total == y:
            yukichi = i
            ichiyo = j
            hideyo = k

print("{} {} {}".format(yukichi, ichiyo, hideyo))

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

is_possible = False

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        total = i*10000 + j*5000 + k*1000
        if total == y:
            is_possible = True
            print("{} {} {}".format(i, j, k))
            break
    if is_possible:
        break

if is_possible is False:
    print("-1 -1 -1")

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

y = y//1000

a = b = c = -1




m = y-n

for i in range(m//9+1):
  if (m-9*i)%4 == 0:
    if (m-9*i)//4 <= n-i:
      a = i
      b = (m-9*i)//4
      c = n - a - b
      break
print(a,b,c)

Solution (Python):
n, y =map(int, input().split())
for a in range(min(n + 1 , y // 10000 + 1)):
    b = (-9000 * a + y -1000 * n) / 4000
    if (b >=0 and a + b <= n and b.is_integer()):
        print(a,int(b),int(n-a-b))
        break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Solution (Python):
n, y =map(int, input().split())
for a in range(min(n + 1 , y // 10000 + 1)):
    for b in range(min(n - a + 1 , y // 5000 + 1)):
        c = n - a - b
        if a * 10000 + b * 5000 + c * 1000 == y:
            print(a,b,c)
            break
        else:
            continue
    else:
        continue
    break
else:
    print("-1 -1 -1")

Solution (Python):
n, y =map(int, input().split())
for a in range(min(n + 1 , y // 10000 + 1)):
    for b in range(min(n - a + 1 , y // 5000 + 1)):
        c = n - a - b
        if a * 10000 + b * 5000 + c * 1000 == y:
            print(a,b,c)
            break
        else:
            continue
    else:
        continue
    break
else:
    print("-1 -1 -1")

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

flag = 0
x = 0
while x <= N:
    y = 0
    while x + y <= N:
        if 9 * x + 4 * y == Y - N:
            print(x, y, Y - 10 * x - 5 * y)
            flag = 1
            break
        else:
            y += 1
    if flag == 1:
        break
    else:
         x += 1
if flag == 0:
    print('-1 -1 -1')

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

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
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):
import sys
N, Y = map(int, input().split())

for l in range(N+1):
  for m in range(N-l+1):
    n = N - l - m
    if l * 1000 + m * 5000 + n * 10000 == Y:
      print('{} {} {}'.format(n, m, l))
      sys.exit(0)
print('-1 -1 -1')

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

a1 = 0
a5 = 0
a10 = 0
s = 1

if 10000*N+1 > Y:
    for i in range(N+1):
        a10 = i
        for j in range(N - a10+1):
            a5 = j
            a1 = N - a5 - a10
            if Y == a1 * 1000 + a5 * 5000 + a10 * 10000:
                s = 0
                break
        else:
            continue
        break


if s == 1:
    print("-1 -1 -1")
else:
    print(a10, a5, a1)

Solution (Python):
import sys

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

    for n1000 in range(n + 1):
        for n5000 in range(n - n1000 + 1):
            if (1*n1000 + 5*n5000 + 10*(n-n1000-n5000)) == y:
                print(n-n1000-n5000, n5000, n1000)
                sys.exit(0)
    print(-1, -1, -1)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit

n, y = list(map(int, input().split()))
for i in range(n + 1):
    for j in range(n + 1):
        if i + j > n:
            continue
        if (y - (10000 * i + 5000 * j)) // 1000 == n - i - j:
            print(i, j, n - i - j)
            exit(0)
print('-1 -1 -1')

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

moji="-1 -1 -1"
for i in range(n+1):
    y1=y-10000*i
    for j in range(n-i+1):
        y2=y1-5000*j-1000*(n-i-j)
        if y2==0:
            moji=str(i)+ " " + str(j) + " " + str(n-i-j)
            break
        else:
            continue
print(moji)

Solution (Python):
num, sum_yen = map(int, input().split())

for n_1000 in range(num+1):
    if 1000*n_1000 > sum_yen:
        break
    if (sum_yen-1000*n_1000)%5000 != 0:
        continue
    if n_1000 == num and 1000*n_1000 == sum_yen:
        print('0 0 ' + str(n_1000))
        exit()
    for n_5000 in range(num+1-n_1000):
        if 1000*n_1000+5000*n_5000 > sum_yen:
            break
        n_10000 = num - n_1000 - n_5000
        if n_10000+n_5000+n_1000 == num and \
              10000*n_10000+5000*n_5000+1000*n_1000 == sum_yen:
            print(str(n_10000) + ' ' + str(n_5000) + ' ' + str(n_1000))
            exit()

print('-1 -1 -1')

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

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

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

Solution (Python):
N, Y = 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 Y == x*10000+y*5000+z*1000:
            print("{} {} {}".format(x, y, z))
            exit()

print("-1 -1 -1")

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

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

Solution (Python):
data = list(map(int, input().split()))
n, yen = data[0], data[1]

diff = yen/1000 - n
for i in range(int(diff/9)+1):
    if i > n:
        break
    for j in range(int(diff/4)+1):
        if i + j > n:
            break
        if i*9+j*4 == diff:
            print(i, j, n-i-j)
            quit()
print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split(' '))
solved = False
Y /= 1000
for y in range(N+1):
    for z in range(N+1):
        remain_yen = Y - 5 * y - z
        remain_num = N - y - z
        if (remain_num >= 0 and remain_yen == 10 * remain_num):
            solved = True
            break
    if solved:
        break

if solved:
    print(remain_num, y, z)
else:
    print('-1 -1 -1')

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









is_found = False
for x in range(0,N+1) :
    y = (-9000*x + Y - 1000* N) / 4000
    
    if (y >= 0 and x + y <= N and float.is_integer(y)) :
        is_found = True
        print(x,int(y),int(N-x-y))
        break

if (not is_found) :
    print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split(' '))
count = 0
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        result = 10000 * i + 5000 * j + 1000 * k
        if result == Y:
            print(i, j, k)
            count += 1
            break
    if count != 0:
        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+1):
        if(N-(x+y) < 0):
            break
        if(10000*x+5000*y+1000*(N-(x+y)) == Y):
            print('{0} {1} {2}'.format(x,y,N-(x+y)))
            exit()
print('-1 -1 -1')

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

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

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

flg = 0
for x in range(Y//10000 + 1):
    y = (Y-9000*x-1000*N)/4000
    z = N-x-y
    if y >= 0 and z >= 0:
        if int(y) == y and int(z) == z:
            flg = 1
            y, z = int(y), int(z)
            break

if flg:
    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):
    for j in range(0, n+1-i):
    	if 10000*i+5000*j+1000*(n-i-j) == y:
    		ans = (i, j, n-i-j)
print(ans[0], ans[1], ans[2])

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

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

Solution (Python):
import sys
input=sys.stdin.readline
n,y=map(int,input().split())
mm=min(n,y//10000)+1
for m in range(mm):
  ny=y-10000*m
  gg=min(n-m,ny//5000)+1
  for g in range(gg):
    if m*10000+g*5000+(n-m-g)*1000==y:print(m,g,n-m-g);exit()
print(-1,-1,-1)

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

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

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

exist = False
for i in range(N + 1):
  for j in range(N - i + 1):
      total = 10000 * i + 5000 * j + 1000 * (N - i - j)
      if total == Y:
        exist = True
        i_1 = i
        j_1 = j
        k_1 = N - i - j

if exist:
  print(i_1, j_1, k_1)
else:
  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
        if 10000*a + 5000*b + 1000*c == Y:
            print(a, b, c)
            exit(0)

print(-1, -1, -1)

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

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

print(x, y, z)

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

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

print(x, y, z)

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
    money = x*10000+y*5000+z*1000
    if money==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):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y and z >= 0:
            print(x,y,z)
            quit()

print("-1 -1 -1")