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

hantei = False
for i in range((N//10000), -1, -1):
    if i <= Y:
        for j in range( ((N - (10000*i)) // 5000), -1, -1):
            if i+j <= Y:
                if (1000 * (Y-i-j) + 5000 * j + 10000 * i) == N:
                     hantei = True
                     break
        else:
            continue
        break

if hantei:
    print("{} {} {}".format(i,j,(Y-i-j)))
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())
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(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())

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

if f is False:
    print(-1, -1, -1)

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

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

if f is False:
    print(-1, -1, -1)

Solution (Python):
n, y = map(int, input().split())
m, g, s = -1, -1, -1

for ng in range(n+1):
  for nm in range(n+1 - ng):
    ns = n - nm - ng
    if 10000*nm + 5000*ng + 1000*ns == y:
      m, g, s = nm, ng, ns
      
print(m, g, s)

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

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

if f is False:
    print(-1, -1, -1)

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

Solution (Python):
N, Y = map(int, input().split(" "))
yukichi = -1 
higuchi = -1 
noguchi = -1 
for x in range(N + 1):
	for y in range(N + 1):
		z = N - x - y
		if z >= 0:
			sum = x * 10000 + y * 5000 + z * 1000
			if sum == Y and x + y + z == N:
				yukichi = x
				higuchi = y
				noguchi = z

print(yukichi, higuchi, noguchi)

Solution (Python):


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

def solve():

    for i in range((y//10000)+1):
        for j in range((y//5000)+1):
            k=(y-i*10000-j*5000)//1000
            if k<0:break
            if i+j+k==n:
                return [i,j,k]
                
    else:
        return [-1]*3


print(*solve())

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

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

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

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

print("-1 -1 -1")

Solution (Python):

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

A = -1 
B = -1 
C = -1 

def amount(A, B, C):
    return A * 10000 + B * 5000 + C * 1000

for a in range(0, N + 1):
    
    if amount(a, 0, N - a) > Y:
        break
    
    if amount(a, N - a, 0) < Y:
        continue
    for b in range(0, N - a + 1):
        
        if amount(a, b, N - a - b) == Y:
            A = a
            B = b
            C = N - a - b
            break
    else:
        continue
    break

print("{} {} {}".format(A, B, C))

Solution (Python):
import sys
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)
            sys.exit()
print(-1,-1,-1)

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

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

l = [[] for _ in range(N+1)]

for i in range(N+1):
    for j in range(N+1-i):
        l[i].append(10000*i + 5000*j + 1000*(N-i-j))


a = 0
for i in range(N+1) :
    if Y in l[i] :
        print(str(i) + ' '+ str(l[i].index(Y)) + ' ' +  str((N-i-(l[i].index(Y)))))
        a =1
        break

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

Solution (Python):
N, Y = map(int, input().split())
I = -1
J = -1
K = -1
for i in range(N+1)[::-1]:
  for j in range(N+1-i)[::-1]:
      if i*10 + j*5 + (N-i-j) == Y/1000:
        I = i
        J = j
        K = N-i-j
        break
print('{} {} {}'.format(I, J, K))

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


def answer():
    n, y = map(int, input().split(' '))
    for i in range(n+1):
        for j in range(0, n-i+1):
            total = 10000 * i + 5000 * j + 1000 * (n-i-j)
            if total == y:
                return '{} {} {}'.format(i, j, n-i-j)


    return '{} {} {}'.format(-1, -1, -1)
print(answer())

Solution (Python):

import sys
N, Y = map(int, input().split())
k = int(Y / 1000)
t = k - N

for x in range(0, N + 1):
    for y in range(0, N + 1 - x):
        if 9 * x + 4 * y == t:
            z = N - (x + y)
            print(x, y, z)
            sys.exit()
print('-1 -1 -1')

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

Solution (Python):
N,Y = [int(i) for i in input().split()]
a=-1
b=-1
c=-1
for i in range(N+1):
    for j in range(N+1-i):
        if(Y-1000*(N-(i+j)) == 10000*i + 5000*j):
            a=i
            b=j
            c=N-i-j
print(str(a) +' '+str(b)+' '+str(c))

Solution (Python):
n,y=map(int,input().split())
y=y/1000
count=0
for i in range(min(int(y/10),n)+1):
    for j in range(min(int((y-10*i)/5),n-i)+1):
        if 10*i+5*j+n-i-j==y:
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            count=1
            break
        elif 10*i+5*j+n-i-j>y:
            break
    if count==1:
        break
if count==0:
    print("-1 -1 -1")

Solution (Python):
import sys


def resolve():
    N_BILLS, YEN_TOTAL = [int(x) for x in sys.stdin.readline().split()]

    is_answer_found = False
    for i_ten in range(N_BILLS + 1):
        for i_five in range(N_BILLS + 1 - i_ten):
            i_one = N_BILLS - i_ten - i_five
            if i_ten * 10000 + i_five * 5000 + i_one * 1000 == YEN_TOTAL:
                is_answer_found = True
                print("{} {} {}".format(i_ten, i_five, i_one))
                break
        if is_answer_found:
            break
    if not is_answer_found:
        print("-1 -1 -1")


if __name__ == "__main__":
    resolve()

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 45000"""
        output = """4 0 5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 196000"""
        output = """-1 -1 -1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000 1234000"""
        output = """14 27 959"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2000 20000000"""
        output = """2000 0 0"""
        self.assertIO(input, output)

Solution (Python):
import sys


def resolve():
    N_BILLS, YEN_TOTAL = [int(x) for x in sys.stdin.readline().split()]

    is_answer_found = False
    for i_ten in range(N_BILLS + 1):
        for i_five in range(N_BILLS + 1 - i_ten):
            i_one = N_BILLS - i_ten - i_five
            if i_ten * 10000 + i_five * 5000 + i_one * 1000 == YEN_TOTAL:
                is_answer_found = True
                print("{} {} {}".format(i_ten, i_five, i_one))
                break
        if is_answer_found:
            break
    if not is_answer_found:
        print("-1 -1 -1")


if __name__ == "__main__":
    resolve()

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 45000"""
        output = """4 0 5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 196000"""
        output = """-1 -1 -1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000 1234000"""
        output = """14 27 959"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2000 20000000"""
        output = """2000 0 0"""
        self.assertIO(input, output)

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

def solve(n, y):
    for a in range(min(y // 10000, n) + 1):
        for b in range(min(y // 5000, n) + 1):
            if a + b > n or 10000 * a + 5000 * b > y:
                continue

            c = n - a - b
            if 10000 * a + 5000 * b + 1000 * c == y:
                print(a, b, c)
                return

    print("-1 -1 -1")

solve(n, y)

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

Solution (Python):
n,y = map(int,input().split())
ans_a = -1
ans_b = -1
ans_c = -1

for i in range(n+1):
  for j in range(n+1-i):
    k = n- i- j
    if y == 10000 * i + 5000 * j + 1000 * k :
      ans_a = i
      ans_b = j
      ans_c = k
print(ans_a,ans_b,ans_c)

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

Solution (Python):
N,Y = map(int,input().split())
m,g,s=10000,5000,1000
for i in range(Y//m+1):
    for j in range((Y-m*i)//g+1):
        z = (Y-(m*i+g*j))//s
        if i+j+z==N:
            print(i,j,z)
            exit(0)
else:print(-1,-1,-1)

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

for i in range(N+1):
  for j in range(N+1):
    if count == 0:
      X = Y - 10*i - 5*j
      if (X == N-i-j) & (X>=0):
        print(i, j, X)
        count += 1
    else:
      break

if count == 0:
  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())

money = [10000, 5000, 1000]
ans = []
for i in range(N+1):
    for j in range(N+1):
        buff = N - i - j
        if buff >= 0:
            if Y == money[0]*i + money[1]*j + money[2]*buff:
                ans = [i, j, buff]
                print(*ans)
                exit()


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

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

flg = False
for i in range(n + 1):
    for j in range(n + 1):
        if n - (i + j) >= 0:
            if 1000 * (n - (i + j)) + 5000 * j + 10000 * i == y:
                flg = True
                print(str(i) + ' ' + str(j) + ' ' + str(n - (i + j)))
                break
    if flg:
        break

if not flg:
    print('-1 -1 -1')

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

flg = False
for i in range(n + 1):
    for j in range(n + 1):
        if n - (i + j) >= 0:
            if 1000 * (n - (i + j)) + 5000 * j + 10000 * i == y:
                flg = True
                print(str(i) + ' ' + str(j) + ' ' + str(n - (i + j)))
                sys.exit()
if not flg:
    print('-1 -1 -1')

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

L=[[h,i,N-h-i]for h in range(N+1) for i in range(N+1) if h*1000+i*5000+(N-h-i)*10000==Y and (N-h-i)>=0]

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

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

def find() :
    for yukichi in range(N+1) :
        if yukichi * 10000 > Y :
            break
        for higuchi in range(N+1-yukichi) :
            noguchi = N - yukichi - higuchi
            money = yukichi * 10000 + higuchi * 5000 + noguchi * 1000
            if money == Y :
                return (yukichi, higuchi, noguchi)
            if money > Y :
                break
    return (-1, -1, -1)

ans = find()

print('{} {} {}'.format(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(1+n):
    for j in range(n-i+1):
        if i*10+j*5+(n-i-j)==y and n-i-j>=0:
            ans=(i,j,n-i-j)
print(*ans)

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


for n in range(N+1):
  nm_10000_bill = n
  amount_10000 = 10000 * nm_10000_bill
  nm_5000_1000_bill = N - nm_10000_bill
  amount_5000_1000 = Y - amount_10000
  mx_amount_5000 = 5000 * nm_5000_1000_bill
  d = mx_amount_5000 - amount_5000_1000
  nm_1000_bill = d // 4000
  nm_5000_bill = nm_5000_1000_bill - nm_1000_bill
  if nm_1000_bill >= 0 and nm_5000_bill >= 0:
    if 10000 * nm_10000_bill + 5000 * nm_5000_bill + 1000 * nm_1000_bill == Y:
      print(str(nm_10000_bill) + " " + str(nm_5000_bill) + " " + str(nm_1000_bill))
      break
else:
  print("-1 -1 -1")

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



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

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

'''
10x + 5y + z = yen
x + y + z = num

として、以下を満たす整数の組が、求める答えになる

9x + 4y = yen - num

'''


sum_yen = int(sum_yen / 1000)

for x_i in range(0, num + 1):
    for y_i in range(0, num + 1 - x_i):
        if 9 * x_i + 4 * y_i == (sum_yen - num):
            print('{} {} {}'.format(x_i, y_i, num - x_i - y_i))
            sys.exit()


print('-1 -1 -1')

Solution (Python):
E = list(map(int,input().split()))
Ans = []
for i in range(E[0]+1):
    for k in range(E[0] - i+1):
        if i*10000 + k*5000 + (E[0] - i - k)*1000 == E[1]:
            Ans = [i,k,E[0] - i - k]
if len(Ans) == 0:
    print('-1 -1 -1')
else:
    print(Ans[0],Ans[1],Ans[2])

Solution (Python):
cond=list(map(int,input().split()))
X=int(cond[1]/1000 - cond[0])
T=True
x=0
while T and x<=int(cond[1]/10000):
    for y in range(int(cond[1]/5000)+1):
        if ((X-9*x)%4!=0):
           continue
        else:
           XX=x
           Y=(cond[1]/1000 - cond[0] - 9*x)/4
           Z=cond[0]-XX-Y
           if Z<0:
               XX=Y=Z=None
               continue
           elif Y<0:
               XX=Y=Z=None
               continue
           else:
               T=False
               break
    x+=1
if len(str(Z))==0 or Z==None:
    print('-1 -1 -1')
else:
    print(int(XX), int(Y), int(Z))

Solution (Python):
def otoshidama():
	N, Y = map(int, input().split())
	a = b = c = -1
	for ai in range(0, N + 1):
		for bi in range(0, N + 1 - ai):
			if 10000 * ai + 5000 * bi + 1000 * (N - ai -bi) == Y:
				a = ai
				b = bi
				c = N - ai - bi
				break
		else:
			continue
		break
	print("{0} {1} {2}".format(a,b,c))

otoshidama()

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())
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-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())
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())
resa, resb, resc = -1, -1, -1
for i in range(n+1):
	for j in range(n+1-i):
		c = n - i - j
		total = 10000*i + 5000*j + 1000*c
		if total == y:
			resa = i
			resb = j
			resc = c
print(resa,resb,resc)

Solution (Python):
import sys
N, X = map(int, input().split())

for i in range(N + 1):
    for k in range(0, N - i + 1):
        if i * 10000 + k * 5000 + (N - i - k) * 1000 == X:
            print(i, k, N - i - k)
            sys.exit()
print('-1 -1 -1')

Solution (Python):
n, y = map(int, input().split())
k = 0
y = y / 1000
for a in range(n+1):
    if(10*a+5*(n-a) < y):
        continue
    elif(10*a > y):
        break
    for b in range(n+1-a):
        c = n-a-b
        money_sum = 10*a+5*b+c
        if(money_sum == y):
            print(a, b, c)
            exit()
        elif(money_sum > y):
            break
print(-1, -1, -1)

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

for y10k in range(N + 1):
	for y5k in range(N + 1):
		if N < y10k + y5k:
			break
		y1k = N - (y10k + y5k)
		if Y == 10000 * y10k + 5000 * y5k + 1000 * y1k:
			print(y10k, y5k, y1k)
			exit()
else:
	print(-1, -1, -1)

Solution (Python):
n,goukei = map(int, input().split())
xx,yy,zz = -1,-1,-1
xmax = goukei // 10000
for x in range(0,xmax+1):
  if xx > -1:
    break
  ymax = (goukei-x*10000) // 5000
  for y in range(0, ymax+1):
    ztmp = goukei - (x*10000)- (y*5000)
    if ztmp % 1000 == 0:
      z = ztmp // 1000
      sumxyz = x+y+z
      if sumxyz == n:
        xx,yy,zz = x,y,z
        break

print(xx,yy,zz)

Solution (Python):
n,goukei = map(int, input().split())
flg = 0
xmax = goukei // 10000
for x in range(0,xmax+1):
  if flg == 1:
    break
  ymax = (goukei-x*10000) // 5000
  for y in range(0, ymax+1):
    ztmp = goukei - (x*10000)- (y*5000)
    if ztmp % 1000 == 0:
      z = ztmp // 1000
      sumxyz = x+y+z
      if sumxyz == n:
        flg = 1
        xx = x
        yy = y
        zz = z
        break
if flg == 0:
  print(-1,-1,-1)
else:
  print(xx,yy,zz)

Solution (Python):
n,y = map(int,input().split())
 
y /= 1000
 
y10 = 0
y5 = 0
y1 = 0
 
i = 0

while 1:
    y1 = i
    y5 = (10*n-y-9*y1)//5
    y10 = n-y5-y1
    if (10*n-y-9*y1)%5 == 0 and y10>=0 and y5>=0 and y1>=0:
        print(int(y10),int(y5),int(y1))
        break
    i += 1
    if i>n:
        print(-1,-1,-1)
        break

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

yukichi = 0
ichiyo = 0
hideyo = 0

complete = False

if yukichi != -1:
    for i in range(n+1):
        for j in range(n-i+1):
            if 10000*i+5000*j+1000*(n-i-j) == y:
                yukichi = i
                ichiyo = j
                hideyo = n-i-j
                complete = True
                break
        if complete:
            break

if complete == False:
    yukichi = -1
    ichiyo = -1
    hideyo = -1


print(str(yukichi)+" "+str(ichiyo)+" "+str(hideyo))

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

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

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

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


print(-1, -1, -1)

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

Solution (Python):
import sys

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

y = Y // 1000

for a in range(N+1):
    b = (y - N - 9 * a) // 4
    if a + b > N or b < 0:
        continue
    c = N - a - b
    if 10000 * a + 5000 * b + 1000 * c == Y:
        print(a, b, c)
        sys.exit(0)

print("-1 -1 -1")

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

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

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, Y = list(map(int, sys.stdin.readline().split()))


ans = -1, -1, -1
for c10 in range(N + 1):
    rn = N - c10
    ry = Y - c10 * 10000
    if (ry - rn * 1000) % 4000 == 0:
        y = (ry - rn * 1000) / 4000
        x = rn - y
        if 0 <= x <= N and 0 <= y <= N:
            ans = c10, y, x
            break
print(' '.join(map(str, map(int, ans))))

Solution (Python):


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

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

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

Solution (Python):
n, Y = map(int, input().split())
Y = Y // 1000
x, y, z = -1, -1, -1
for i in range(n + 1):
  d = Y - 10 * i
  r = n - i
  if d < 0:
    break
  if (5 * r - d) % 4 == 0:
    a = (5 * r - d) // 4
    b = r - a
    if a >= 0 and b >= 0:
      x, y, z = i, b, a
      break
print(x, y, z)

Solution (Python):
N,Y=map(int, input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
  for j in range(N+1-i):
    sum=0
    sum+=10000*i
    sum+=5000*j
    sum+=1000*(N-i-j)
    if Y==sum:
      x=i
      y=j
      z=N-i-j
      break
print(str(x)+' '+str(y)+' '+str(z))

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

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

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

Solution (Python):
N, Y = map(int, input().split())
ans = 0
for noguchi in range(N + 1):  
    if ans == 1:
        break
    for higuchi in range(N - noguchi+1):  
        if 1000 * noguchi + 5000 * higuchi + 10000 * (N - higuchi - noguchi) == Y:
            ans = 1
            print("{} {} {}".format(N - noguchi - higuchi, higuchi, noguchi))
            break
if ans == 0:
    print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split())
for i in range(N, -1, -1):
  if 10000 * i > Y:
    continue
  for j in range(N - i, -1, -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())
import sys
for i in range(n+1):
    if y>=10000*i:
        y1=y-10000*i
        n1=n-i
        for j in range(n1+1):
            if y1>=5000*j:
                y2=y1-5000*j
                n2=n1-j
                if y2==1000*n2:
                    print(i,j,n2)
                    sys.exit()
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):
        k = N-i-j
        if a*i+b*j+c*k==Y:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

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

yukichi=y//10000
higuchi=(y-yukichi*10000)//5000
noguchi=(y-yukichi*10000-higuchi*5000)//1000

for i in range(yukichi+1):
    if i!=0:
        yukichi-=1
        higuchi+=2
    for j in range(higuchi+1):
        if j!=0:
            higuchi-=1
            noguchi+=5
        
        if yukichi+higuchi+noguchi == n:
            print("{0} {1} {2}".format(yukichi,higuchi,noguchi))
            quit()
    higuchi+=noguchi//5
    noguchi-=higuchi*5
else:
    print("-1 -1 -1")

Solution (Python):
maisu,goukei=map(int ,input().split())
cou=0
for i in range(maisu+1):
  for r in range(maisu+1):
    if i+r>maisu:
      break
    if i*10000+r*5000+(maisu-i-r)*1000==goukei:
      cou=1
      print(i,r,maisu-i-r)
      break
  if cou==1:
    break
  if i==maisu:
    print(-1,-1,-1)

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

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

print('-1 -1 -1')

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

o_sum = Y//1000
o_1 = Y//1000
o_5 = 0
o_10 = 0

f = 0
while(1):
    
    if o_sum == N:
        break
    else:
        if o_sum - N >= 4:
            if o_1 >= 5:
                o_5 += 1
                o_1 -= 5
            elif o_5 >= 2:
                o_5 -= 2
                o_10 += 1
            else:
                f = 1
                break
        else:
            if o_5 >= 2:
                o_5 -= 2
                o_10 += 1
            else:
                f = 1
                break
    o_sum = o_1 + o_5 + o_10

if f == 0:
    print(o_10, o_5, o_1)
else:
    print(-1, -1, -1)

Solution (Python):
N,Y = map(int,input().split())
Y //= 1000
ans = (-1,-1,-1)
for Fuku in range(Y//10+1):
    Zankin = Y - 10*Fuku
    for Higu in range(Zankin // 5+1):
        Nogu = Zankin - 5*Higu
        if Fuku+Higu+Nogu == N:
            ans = (Fuku,Higu,Nogu)
print(*ans)

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

'''
if Y/N > 10000 or Y%1000 != 0:
  print("-1 -1 -1")
'''
flag = 0
  
for x in range(N+1):
  x = x
  if flag == 1:
    break
  for y in range(N-x+1):
    y = y
    z = N-x-y
    if x*10000+y*5000+z*1000 == Y:
      print(x,y,z)
      flag = 1
      break

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

Solution (Python):
def judge(N,Y):
    sum = 0
    for i in range(N+1):
        for j in range(N-i+1):
            sum = i*10000+ j*5000 + (N-i-j)*1000
            if sum == Y:
                return i, j, N-i-j
        if i == N:
            return -1, -1, -1

N, Y = map(int, input().split())
x, y, z = judge(N,Y)
print("{} {} {}".format(x,y,z))

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

for x in range(num +1):
  for  y in range(num-x +1):
    summary = 9000*x + 4000*y + 1000*num
    if summary == money:
      print(x,y,num-x-y)
      exit()
print("-1 -1 -1")

Solution (Python):
n,x = 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 == x:
        print(i,j,n-i-j)
        exit()
print(-1,-1,-1)