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 = [int(x) for x in input().split()]
ans = [-1,-1,-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):
            ans = [i,j,k]
            break

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

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

for x in range(N+1):

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

	if flag == 1:
		break

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

Solution (Python):
N,Y = list(map(int, input().split()))
total = 0
find = False
for x in range(N+1) :
    a = 10000 * x
    for y in range(N + 1 - x) :
        b = 5000 * y
        z = N - x - y
        c = 1000 * z
        total = a + b + c
        if total == Y :
            print(x, y, z)
            find = True
            break
    if find :
        break
if not find :
    print(-1,-1,-1)

Solution (Python):
N,Y = map(int,input().split(" "))
K = Y//1000 -N
     
l = int(-K/4)-1
r = -(2*K)/9+1

if l<=r:
    i=l
    while i <=r:
        a = K+4*i
        b = -2*K-9*i
        c = N-a-b

        if a>=0 and b>=0 and c >=0:
            print(a," ",b," ",c)
            break

        i+=1
    else:
        print(-1," ",-1," ",-1)

else:
    print(-1," ",-1," ",-1)

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

Solution (Python):
n,y=map(int,input().split())
y=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())
for i in range(N + 1):
  for j in range(N- i + 1):
    k = N - i - j
    if Y == 10000 * i + 5000 * j + 1000 * k:
        print(" ".join(map(str, [i, j, k])))
        quit(0)
print("-1 -1 -1")

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

Solution (Python):
n, y = map(int, input().split())
y /= 1000
def calc(a, b, c):
    li = [10, 5, 1]
    return a * li[0] + b * li[1] + c * li[2]
res1 = -1
res2 = -1
res3 = -1
for a in range(0,n+1):
    for b in range(0,n-a+1):
        c = n - a - b
        if y == calc(a, b, c):
            res1 = a
            res2 = b
            res3 = c
print(res1,res2,res3)

Solution (Python):
n, y = map(int, input().split())
can = True
c = []
d = []
for i in range(n+1):
    for j in range(n+1-i):
        calc = 10000 * i + 5000 * j + 1000 * (n-i-j)
        d.append(calc)
        if calc == y:
            s = " ".join([str(i), str(j), str(n-i-j)])
            c.append(s)
            can = False
            break
if can:
    s = " ".join([str(-1)]*3)
    print(s)
else:
    print(c[0])

Solution (Python):
N, Y = map(int, input().split())
for a in range(0, N+1):
    for b in range(0, N+1-a):
        c = N-a-b
        if 10000*a+5000*b+1000*c == Y:
            print(a, b, c)
            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 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())
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):
def otosi(n,y):
  ans=None
  for i in range(n+1):
    ii=0
    while n-i>=ii:
      if i*10000+ii*5000+(n-i-ii)*1000==y:
        ans=str(i)+" "+str(ii)+" "+str(n-i-ii)
        return ans
      else:
        ii+=1
  else:
    ans="-1 -1 -1"
    return ans
n,y=map(int,input().split())
print(otosi(n,y))

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

for i in range((Y // 10000) + 1):
    for j in range((Y // 5000) + 1):
        k = N - i - j
        if k >= 0:
            
            if 10000 * i + 5000 * j + 1000 * k == Y:
                print(' '.join(map(str, [i, j, k])))
                break
    else:
        continue
    break
else:
    print('-1 -1 -1')

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

flg = 0
for a in range(N+1):
  for b in range(N-a+1):
    c = (N-a-b)
    if (a+b+c) == N and a *10000 + b *5000 + c *1000 == Y:
      print(a,b,c)
      flg = True
      break
  if flg:
    break
if flg == 0:
  print(-1, -1, -1)

Solution (Python):
import sys
N, Y = map(int, input().split())
Y = Y//1000
x = 0
while Y-N-9*x >= 0:
    if (Y-N-9*x)%4 == 0 and (Y-N-9*x)//4 >=0 and x+(Y-N-9*x)//4 <= N:
        print(x, (Y-N-9*x)//4, N-(Y-N-9*x)//4-x)
        sys.exit()
    x += 1
print(-1, -1, -1)

Solution (Python):
n, y = map(int, input().split())
ans = [-1, -1, -1]
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        temp = i * 10000 + j * 5000 + (n-i-j) * 1000
        if temp == y:
            ans = [i, j, n-i-j]
            falg = 1
            break
    if flag == 1:
        break

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

Solution (Python):
n, y = list(map(int, input().split()))
nasi = True
for d in range(0,n+1):
    if nasi == False:
        break
    for e in range(0,(n+1)-d):
        if nasi == False:
            break
        f = n - d - e
        if ((10000 * d) + (5000 * e) + (1000 * f) == y):
            nasi = False
            print(d,e,f)
            break
if nasi == True:
    print('-1 -1 -1')

Solution (Python):
import sys
def p(*a):
  s=" ".join(map(str,a))
  
  sys.stderr.write(s+"\n")

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

NAmax=min(N,Y//10000)
NBmax=min(N,Y//5000)
NCmax=min(N,Y//1000)
p(NAmax, NBmax, NCmax)

NA=NAmax
for a in range(NA,-1,-1):
  NB=min(NBmax,N-a)

  for b in range(NB,-1,-1):
    c = N-a-b
    y = (a*10000)+(b*5000)+(c*1000)
    if y==Y:
      print(a,b,c,sep=" ")
      exit()
      
i=-1
print(i,i,i, sep=" ")

Solution (Python):
[N,Y] = list(map(int,input().split()))
x = [0,0,0]
x[0] = Y//10000
x[1] = (Y - (10000*x[0]))//5000
x[2] = (Y - (10000*x[0]) - (5000*x[1]))//1000
ans = [-1,-1,-1]
for i in range(x[0]+1):
    for j in range(x[1]+(2*i)+1):
        N_temp = (x[0]-i) + (x[1]+2*i-j) + (x[2]+5*j)
        if N_temp == N:
            ans = [(x[0]-i) , ((x[1]+2*i-j)) , (x[2]+5*j)]
            print('{0[0]} {0[1]} {0[2]}'.format(ans))
            exit()
        elif N_temp > N:
            break
print('{0[0]} {0[1]} {0[2]}'.format(ans))

Solution (Python):
[N,Y] = list(map(int,input().split()))
x = [0,0,0]
x[0] = Y//10000
x[1] = (Y - (10000*x[0]))//5000
x[2] = (Y - (10000*x[0]) - (5000*x[1]))//1000
ans = [-1,-1,-1]
for i in range(x[0]+1):
    for j in range(x[1]+(2*i)+1):
        N_temp = (x[0]-i) + (x[1]+2*i-j) + (x[2]+5*j)
        if N_temp == N:
            ans = [(x[0]-i) , ((x[1]+2*i-j)) , (x[2]+5*j)]
            print('{0[0]} {0[1]} {0[2]}'.format(ans))
            exit()
print('{0[0]} {0[1]} {0[2]}'.format(ans))

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] = list(map(int,input().split()))
x = [0,0,0]
x[0] = Y//10000
x[1] = (Y - (10000*x[0]))//5000
x[2] = (Y - (10000*x[0]) - (5000*x[1]))//1000
ans = [-1,-1,-1]
for i in range(x[0]+1):
    for j in range(x[1]+(2*i)+1):
        N_temp = (x[0]-i) + (x[1]+2*i-j) + (x[2]+5*j)
        if N_temp == N:
            ans = [(x[0]-i) , ((x[1]+2*i-j)) , (x[2]+5*j)]
print('{0[0]} {0[1]} {0[2]}'.format(ans))

Solution (Python):
N, Y = map(int, input().split())
li = [[10*a+5*b+(N - a - b), a, b, N- a-b] for a in range(N+1) for b in range(N+1-a) if 10*a+5*b+(N - a - b) == Y//1000]
if len(li) == 0:
    print('-1 -1 -1')
else:
    x = li[0]
    print('{} {} {}'.format(x[1], x[2], x[3]))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007



def A():
    a,b = LI()
    if not (a*b)%2:
        print("Even")
    else:
        print("Odd")
    return


def B():
    s = S()
    print(s.count("1"))
    return


def C():
    n = I()
    a = LI()
    f = 0
    for j in range(100000):
        for i in range(n):
            if a[i]%2:
                f = 1
                break
            a[i] //= 2
        if f:break
    print(j)
    return


def D():
    a,b,c,x = IR(4)
    su = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500*i+100*j+50*k == x:su += 1
    print(su)
    return


def E():
    n,y = LI()
    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)
                quit()
    print(-1,-1,-1)
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    E()

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

calc()

Solution (Python):
n, m = map(int, input().split())
end = 0
for x in range(n+1):
    for y in range(n-x+1):
        if(10000*x + 5000*y + 1000*(n-x-y) == m):
            print(str(x)+' '+str(y)+' '+str(n-x-y))
            end += 1
            break
    if(end==1):
        break
if(end==0):
    print('-1 '+'-1 '+'-1')

Solution (Python):
n,m = map(int,input().split())
m = m//1000
for x in range(n+1):
    for y in range(n-x+1):
        z = n-x-y
        if 10*x+5*y+1*z == m:
            print(x,y,z)
            exit(0)
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-i+1):
                z=n-i-j
                if y==i*10000+j*5000+z*1000:
                        print(str(i)+' '+str(j)+' '+str(z))
                        exit()
print('-1 -1 -1')

Solution (Python):

inputList = list(map(int, input().split()))
N = inputList[0]
Y = inputList[1]

outX = outY = outZ = -1
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            outX = x
            outY = y
            outZ = z

print(outX, outY, outZ)

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

Solution (Python):
def solve():
    N,Y=map(int,input().split())
    for x in range(N+1):
        for y in range(N-x+1):
            z = N - x - y
            if Y == x * 10000 + y * 5000 + z * 1000:
                return [x,y,z]
    return [-1,-1,-1]

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

Solution (Python):
N,Y=map(int,input().split(' '))
c,b,a=-1,-1,-1
for A in range(Y//10000+1):
	B = (Y/1000 - 9*A - N)/4
	if int(B)==B and 0<=int(B)<=N-A:
		a,b=int(A),int(B)
		break
	else:
		continue
if a>=0:
	c = N-a-b
print(a,b,c)

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

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

Solution (Python):


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

r = y - 1000 * n

for i in range(0,n+1):
    temp = r - 9000 * i
    if temp % 4000 == 0:
        j = temp / 4000
        k = n - i - j
        if j >= 0 and k >= 0:
            print(int(i),int(j),int(k))
            break
else:
    print(-1,-1,-1)

Solution (Python):
N,Y = map(int,input().split())
flag = False
for x in range(N+1):
    t_t = x
    for y in range(N+1 - x):
        f_t = y
        o_t = (N -x -y)
        if Y == 10000*t_t + 5000*f_t + 1000*o_t:
            flag = True
            break
    if flag == True:
        break
if flag == True:
    print(t_t,f_t,o_t)
else :
    print(-1,-1,-1)

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

for n10000 in range(n+1):
    for n5000 in range(n - n10000 + 1):
        n1000 = n - n5000 - n10000
        money_total = n10000 * 10000 + n5000 * 5000 + n1000 * 1000
        if money_total == y:
            print(n10000, n5000, n1000)
            exit()

print(-1, -1, -1)

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

for sen in range(N+1):
    for gosen in range(N-sen+1):
        man = N - sen - gosen
        if man < 0:
            continue
        if sen*1000 + gosen*5000 + man * 10000 == Y:
            print(man, gosen, sen)
            exit()

print(-1, -1, -1)

Solution (Python):
def solve(string):
    n, y = map(int, string.split())
    currents = [10000, 5000, 1000]
    for i in range(0, n + 1):
        _y = y - i * currents[0]
        for j in range(0, n + 1 - i):
            __y = _y - j * currents[1]
            if currents[2] * (n - i - j) == __y:
                return "{} {} {}".format(i, j, n - i - j)
    return "-1 -1 -1"


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
 
n,y = map(int, input().split())
 
 
a,b,c = -1,-1,-1
 
for ai in range(n+1):
 
    if ai*1000>y:
        break
 



 
    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai * 1000 + bi * 5000 + ci * 10000:
            a,b,c = ai,bi,ci
 
print('{} {} {}'.format(c,b,a))

Solution (Python):


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

y //= 1000
a,b,c = -1,-1,-1


fit = False
for ai in range(n+1):

    if ai*10> y or fit:
        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai *10  + bi * 5 + ci :
            a,b,c = ai,bi,ci
            fit = True

print('{} {} {}'.format(a,b,c))

Solution (Python):


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

y //= 1000
a,b,c = -1,-1,-1


fit = False
for ai in range(n+1):

    if ai*10> y or fit:
        break
    if ai == y:
        a,b,c = ai,0,0

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai *10  + bi * 5 + ci :
            a,b,c = ai,bi,ci
            fit = True

print('{} {} {}'.format(a,b,c))

Solution (Python):


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

y //= 1000
a,b,c = -1,-1,-1


fit = False
for ai in range(n+1):

    if ai*10> y or fit:
        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai *10  + bi * 5 + ci :
            a,b,c = ai,bi,ci
            fit = True

print('{} {} {}'.format(a,b,c))

Solution (Python):


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

y //= 1000
a,b,c = -1,-1,-1

for ai in range(n+1):

    if ai*10> y:
        break

    if ai  == y:
        a,b,c = ai,0,0
        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai *10  + bi * 5 + ci :
            a,b,c = ai,bi,ci


print('{} {} {}'.format(a,b,c))

Solution (Python):
N, Y = map(int, input().split())
count = 0
list=[]
for i in range(2001):
    if count == 1:
        break
    for j in range(2001):
        k = N - i - j
        if k < 0:
            break
        if 10000*i + 5000*j + 1000*k == Y:
            list +=[i, j, k]
            count += 1
            break
if count == 0:
    print("-1 -1 -1")
else:
    print(*list)

Solution (Python):
""" AtCoder """

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

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())
Y = Y // 1000

for y10 in range(0, N + 1):
    remain = N - y10
    if y10 * 10 > Y:
        break
    for y5 in range(0, remain + 1):
        y1 = N - y10 - y5
        t = y1 + y5 * 5 + y10 * 10
        if t == Y:
            print(y10, y5, y1)
            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):
        k = (n - i - j)
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Solution (Python):
ia = input().split(" ")
n = int(ia[0])
price = int(ia[1])

for x in range(n + 1):
  for y in range(n + 1 - x):
    z = n - x - y
    sum = 10000 * x + 5000 * y + 1000 * z
    if sum == price:
      print(str(x) + " " + str(y) + " " + str(z))
      break
  else:
    continue
  break
else:
  print("-1 -1 -1")

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

if solve() == 0:
    print("-1 -1 -1")

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

Solution (Python):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

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

Solution (Python):

import sys
input = sys.stdin.readline

N,Y = map(int,input().split())
p = Y//1000
x,y,z = 0,0,0
judge = 0 






if((p-N) >= 0):
 for k in range((p-N)//4 + 1):
  x = -4*k+p-N
  y = 9*k-2*p+2*N
  z = N-x-y
  if((x>=0)and(y>=0)and(z>=0)):
    judge = 1
    break

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

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

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

Solution (Python):
n, Y = map(int,input().split())
c = 0
for y in range(n+1):
        for z in range(n+1):
                if y + z > n:
                        break
                else:
                        x = n - y - z
                        if c == 1:
                                break
                        elif 10000 * x + 5000 * y + 1000 * z == Y:
                                c = 1
                                s = x
                                t = y
                                r = z

if c == 1:
        print("{} {} {}".format(s,t,r))
else:
        print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split())
ans = "-1 -1 -1"
if Y < 1000 * N or Y > 10000 * N:
    print(ans)
    quit()
for i in range(N + 1):
    sen = i
    go = int((10000 * (N - i) - (Y - 1000 * sen)) / 5000)
    man = N - sen - go
    if 1000 * sen + 5000 * go + 10000 * man == Y and sen >= 0 and go >= 0 and man >= 0:
        ans = [man, go, sen]
        ans = map(str, ans)
        result = " ".join(ans)
        print(result)
        quit()

print(ans)

Solution (Python):
N, Y = list(map(int, input().split()))
answer = [-1, -1, -1]

for x in range(N + 1):
    if Y < 0: break
    elif Y == 0 and x == N:
        answer = [x, 0, 0]
        break
    else:
        for y in range(N + 1 - x):
            if Y == (y * 5000 + (N - x - y) * 1000):
                answer = [x, y, N - x - y]
                Y = 0
                break
            elif Y < (y * 5000 + (N - x - y) * 1000): break
    Y -= 10000

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

Solution (Python):
n,m = map(int,input().split())
x_max = int(m/10000)
answer = '-1 -1 -1'
for i in range(x_max+1):
    for j in range(n-i+1):
        m_tmp = m
        flag=0
        m_tmp -= i*10000
        m_tmp -= j*5000
        k = int(m_tmp/1000)
        if i+j+k==n:
            answer = '{0} {1} {2}'.format(i,j,k)
            flag=1
            break
    if flag:
        break
print(answer)

Solution (Python):

input_lines = input().split()
N = int(input_lines[0])
Y = int(input_lines[1])

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

Solution (Python):
n,y=(int(i) for i in input().split())
must_one=int((y%5000)/1000)
max_five=int(y/5000)
 
a,b,c = 0,max_five,must_one

while True:
    z = n - a - b - c 
    if z == 0:
        break
    elif z > 0 :
        if z >=9 and a>=1:
            a,b,c = a - 1 , b  , c + 10
        else:
            a,b,c = a , b - 1 , c + 5
    elif z  < 0 :
        if z <= -9 and c >=10 + must_one:
            a,b,c = a + 1 , b , c - 10
        else:
            a,b,c = a + 1, b -2 , c 

    if b < 0:
        a,b,c= -1,-1,-1
        break

print("%d %d %d"%(a,b,c))

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

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

print('-1 -1 -1')

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

ans=(-1,-1,-1)
for a in range(n + 1):
    for b in range(n - a + 1):
        c = n -a -b 
        if a* 10 + b* 5 + c == y/1000:
            ans=(a,b,c)
            break
print("%d %d %d"%ans)

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

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return



N, Y = 0, 0


def set_inputs():
    global N, Y
    N, Y = get_list_of_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    for i, j in itertools.combinations(range(N+2), 2):
        x, y, z = i, j - i - 1, N - j + 1
        if x * 10000 + y * 5000 + z * 1000 == Y:
            print(x, y, z)
            break
    else:
        print(-1, -1, -1)
    return


if __name__ == '__main__':
    main()

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

print(" ".join(list(map(str, ans))))

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,y=IL()
f=True
for i in range(n+1):
    for j in range(n+1):
        if n-i-j>=0:
            if (10*i+5*j+(n-i-j))*1000==y:
                if f:
                    print(i,j,n-i-j)
                    f=False
if f:
    print(-1,-1,-1)

Solution (Python):
N,Y = map(int, input().split(" "))
f = False
t = int(Y/10000)
for a in range(t+1):
    for b in range(N+1):
        if a+b>N:
            break
        c=N-a-b
        num = a*10000+b*5000+c*1000
        if num==Y:
            print(str(a)+" "+ str(b)+" "+str(c))
            f=True
            break
    if f:
        break
if f==False:
    print('-1 -1 -1')

Solution (Python):
N,Y = map(int,input().split(" "))
 
t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        if x+y>N:
            break
        z = N-x-y
        num = x*10000+y*5000+z*1000
        if num==Y:
            print(str(x)+" "+str(y)+" "+str(z))
            end=True
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")

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

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)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')

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

for i in range(N+1):
    y = 10000*i
    if y > Y:
        break

    for j in range(N+1-i):
        k = N-i-j
        y1 = y+5000*j+1000*k
        if y1 == Y:
            flag = True
            break
        elif y1 > Y:
            break

    if flag:
        break

if flag:
    print(i, j, N-i-j)
else:
    print(-1, -1, -1)

Solution (Python):
N,Y = map(int,input().split())
 
a = -1
b = -1
c = -1
for i in range(int(N+1)):
  for j in range(int(N+1-i)):
    k = int(N - i - j)
    total = int(10000*i + 5000*j + 1000*k)
    if (total == Y) and int(i + j + k) == N:
      a = i
      b = j
      c = k
      break
print("{} {} {}".format(a,b,c))

Solution (Python):
n, Y = list(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()
else:
    print('-1 -1 -1')

Solution (Python):
def solve(N, Y):
    for i in range(N + 1):
        for j in range(N + 1):
            if i + j > N:
                continue
            S = 10000 * i + 5000 * j + 1000 * (N - i - j)
            if S == Y:
                print(i, j, N - i - j)
                return
    print(-1, -1, -1)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    n, m = LI()
    print((n-1)*(m-1))
    return


def B():
    s = S()
    print(s[0]+str(len(s)-2)+s[-1])
    return


def C():
    n, m = LI()
    x = -1
    y = -1
    z = -1
    for i in range(n + 1):
        a = m - 9000 * i - 1000 * n
        if a % 4000 == 0 and a >= 0 and n - i - a / 4000 >= 0:
            y = a / 4000
            z = n - i - y
            x = i
            break
    print(int(x),int(y),int(z))
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()