Problem:
 Score : 300 points    Problem Statement The commonly used bills in Japan are 10000 -yen, 5000 -yen and 1000 -yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.      Constraints  1 ≤ N ≤ 2000  1000 ≤ Y ≤ 2 × 10^7  N is an integer.  Y is a multiple of 1000 .         Input Input is given from Standard Input in the following format:  N  Y       Output If the total value of N bills cannot be Y yen, print -1 -1 -1 .  If the total value of N bills can be Y yen, let one such set of bills be " x  10000 -yen bills, y  5000 -yen bills and z  1000 -yen bills", and print x , y , z with spaces in between. If there are multiple possibilities, any of them may be printed.        Sample Input 1 9 45000      Sample Output 1 4 0 5  If the envelope contained 4  10000 -yen bills and 5  1000 -yen bills, he had 9 bills and 45000 yen in total. It is also possible that the envelope contained 9  5000 -yen bills, so the output 0 9 0 is also correct.       Sample Input 2 20 196000      Sample Output 2 -1 -1 -1  When the envelope contained 20 bills in total, the total value would be 200000 yen if all the bills were 10000 -yen bills, and would be at most 195000 yen otherwise, so it would never be 196000 yen.       Sample Input 3 1000 1234000      Sample Output 3 14 27 959  There are also many other possibilities.       Sample Input 4 2000 20000000      Sample Output 4 2000 0 0

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, Y = inm()
FALSE = (-1, -1, -1)


def solve():
    if Y % 1000 != 0:
        return FALSE
    y = Y // 1000
    for c in range(N + 1):
        b4 = y - 9 * c - N
        if b4 < 0 or b4 > 4 * N or b4 % 4 != 0:
            continue
        b = b4 // 4
        a = N - b - c
        if a < 0 or a > N:
            continue
        return c, b, a
    return FALSE


print(*solve())

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

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

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

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

Solution (Python):
N,Y = list(map(int, input().split()))
for i in reversed(range(N+1)):
    for j in reversed(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 = list(map(int, input().split()))
for i in reversed(range(min(N+1, Y//10000+1))):
    for j in reversed(range(min(N-i+1, (Y-10000*i)//5000+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())

ans = [-1] * 3
for i in range(N+1): 
    for j in range(N+1 - i): 
        if i * 10000 + j * 5000 + ( N - i - j) * 1000 == Y:
            ans[0] = i
            ans[1] = j
            ans[2] = N - i - j
print(" ".join(map(str, ans)))

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

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

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


resultA = -1
resultB = -1
resultC = -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):
            resultA = a
            resultB = b
            resultC = c

print("{} {} {}".format(resultA, resultB, resultC))

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)
        n = 10000 * x + 5000 * y + 1000 * z
        if n == Y:
            print(x, y, z)
            exit()

print(-1, -1, -1)

Solution (Python):
import sys

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

for a in range(0,n+1):
    for b in range(0,n-a+1):
        c = n - a - b
        if a*10000 + b*5000 + c*1000 == y:
            if c >= 0:
                print("{} {} {}".format(a, b, c))
                sys.exit()

print('-1 -1 -1')

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

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

for i in range(min(N, Y//10000)+1):
  n = N-i
  y = Y-i*10000
  if 1000*n<=y<=5000*n and (5000*n-y)%4000 == 0:
    a, b, c = i, n-(5000*n-y)//4000, (5000*n-y)//4000
    break
  else:
    pass
print(a, b, c)

Solution (Python):






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

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

Solution (Python):






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

for a in range(N + 1):
    for b in range(N + 1):
        c = (Y - 10000 * a - 5000 * b) // 1000
        if c < 0:
            continue
        if a + b + c == N:
            print(a, b, c)
            exit()
print(-1, -1, -1)

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

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, Y = il()

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


if __name__ == '__main__':
    main()

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

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

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

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

if Y % 1000 != 0:
    print(-1,-1,-1)

n1 = Y // 10000
n2 = Y // 5000

for i in range(n1+1):
    for j in range(n2+1):
        if (N-i-j) < 0: continue
        if i*10000 + j*5000 + (N-i-j)*1000 == Y:
            print(i,j,(N-i-j))
            exit()
        if Y < i*10000 + j*5000 + (N-i-j)*1000: break
print(-1,-1,-1)

Solution (Python):
N,Y=map(int,input().split())
Y=Y//1000
if Y-N<0:
  print('-1 -1 -1')
else:
  a=Y-N
  for i in range(a//9+1):
    for j in range(a//4+1):
      if a==9*i+4*j:
        if N-i-j>=0:
          print(str(i)+' '+str(j)+' '+str(N-i-j))
          exit()
  print('-1 -1 -1')

Solution (Python):

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

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

Solution (Python):
a,b=map(int,input().split())
for i in range(a+1):
    for j in range(0,a-i+1):
        k=a-(i+j)
        if i*10000+j*5000+k*1000==b:
            print(i,j,k)
            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 z<0:
      continue
    else:
      if 10000*x+5000*y+1000*z==Y:
        print(x,y,z)
        exit()
print("-1 -1 -1")

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

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

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):
import sys
n,y=map(int,input().split())

if y >10000*n:
  print("-1 -1 -1")
  sys.exit()
for i in reversed(range(y//10000+1)):
  for j in reversed(range((y-i*10000)//5000+1)):
    d=10000*i+5000*j+1000*(n-i-j)
    if y==d:
      print(i,j,n-i-j)
      sys.exit()
else:
  print("-1 -1 -1")

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

if y >10000*n:
  print("-1 -1 -1")
  sys.exit()
for i in reversed(range(y//10000+1)):
  for j in reversed(range((y-i*10000)//5000+1)):
    d=10000*i+5000*j+1000*(n-i-j)
    if y==d:
      print(i,j,n-i-j)
      sys.exit()
else:
  print("-1 -1 -1")

Solution (Python):
n,yy = map(int,input().split())
ans=-1,-1,-1

for x in range(n+1):
  for y in range(n+1-x):
    z=n-x-y
    if x*10000+y*5000+z*1000 == yy:
      ans=x,y,z
      break
    else:
      continue
print(*ans)

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

num = min(N, Y//10000)
if 10000*N < Y:
    print('-1 -1 -1')
    sys.exit()

for i in reversed(range(0, num+1)):
    for j in reversed(range(0, N-i+1)):
        if 10000*i + 5000*j > Y:
            continue
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            print('%d %d %d' % (i, j, N-i-j))
            sys.exit()
print('-1 -1 -1')

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

Solution (Python):
from sys import stdin
data = stdin.read().splitlines()

n = int(data[0].split()[0])
y = int(data[0].split()[1])

ans_a = -1
ans_b = -1
ans_c = -1

a = y // 10000

while a >= 0:
    y -= 10000*a
    b = y // 5000
    while b >= 0:
        y -= 5000*b
        c = y // 1000
        if n == a + b + c:
            ans_a = a
            ans_b = b
            ans_c = c
        y = y + 5000*b
        b -= 1
    y = y + 10000*a
    a -= 1
print("{} {} {}".format(ans_a, ans_b, ans_c))

Solution (Python):
def main():
    N, Y = map(int,input().split())
    bill = [10000, 5000, 1000]
    for num_10000 in range(N+1):
        for num_5000 in range(N-num_10000+1):
            if Y == bill[0] * num_10000 + bill[1] * num_5000 + bill[2] * (N-num_10000-num_5000):
                print(' '.join([str(num_10000),str(num_5000),str(N-num_10000-num_5000)]))
                return

    print('-1 -1 -1')

    return 

main()

Solution (Python):
N,Y=map(int,input().split())
answer=-1,-1,-1
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:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)

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

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, y = MI()
    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("{} {} {}".format(i, j, k))
                sys.exit()
    print("-1 -1 -1")

if __name__ == '__main__':
    main()

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


bill = [10000,5000,1000]

for i in range(N+1):
    for j in range(N-i+1):
            if bill[0]*i+bill[1]*j+bill[2]*(N-i-j) == M:
                print(i,j,N-i-j)
                sys.exit()
            
        
    

print(-1,-1,-1)

Solution (Python):
n,y=map(int,input().split())
if y>10000*n:
  print('-1 -1 -1')
else:
  for p in range(n+1):
    for q in range(n-p+1):
      if 10000*p+5000*q+1000*(n-p-q)==y:
        print(p,q,n-p-q)
        exit()
  print('-1 -1 -1')

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

if __name__ == "__main__":
    main()

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

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

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

total = 0
sen = -1
gosen = -1
ichiman = -1

for a in range(n+1):
  for b in range(n+1-a):
    total = a*1000 + b*5000 + (n-a-b)*10000
    if(total==y):
      sen = a
      gosen = b
      ichiman = n-a-b
      
print(ichiman,gosen,sen)

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

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



goodBills = [-1, -1, -1]
foundGoodBills = False


for i10k in range(N + 1):
    for i5k in range(N + 1 - i10k):
        i1k = N - i10k - i5k
        money = 10000 * i10k + 5000 * i5k + 1000 * i1k

        
        if 0 <= i1k <= N and money == Y:
            goodBills = [i10k, i5k, i1k]
            foundGoodBills = True
            break

        if foundGoodBills:
            break

    if foundGoodBills:
        break

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

Solution (Python):
N,Y=map(int,input().split())
answer=-1,-1,-1
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:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)

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('{} {} {}'.format(i, j, n-i-j))
            exit(0)
print('-1 -1 -1')

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


if(__name__ == '__main__'):
  main()

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

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

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

Solution (Python):
n,y=map(int,input().split())
y=y//1000
ans10=-1
ans5=-1
ans1=-1
for i in range(y//10+2):
    num=n-i
    num2=y-(i*10)
    if num<=num2:
        num3=num2-num
        if num3%4==0 and num3//4<=num:
            ans10=i
            ans5=num3//4
            ans1=num-ans5
            break
print(ans10,ans5,ans1)

Solution (Python):
N,Y=map(int,input().split())
answer=-1,-1,-1
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:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)

Solution (Python):
N, Y = map(int, input().split())
 
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:
            print(x,y,z)
            exit()
print('-1 -1 -1')

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

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

Solution (Python):
import itertools
n, y = map(int, input().split())
k = [i for i in range(n + 1)]
ans = 0
for a, b in itertools.product(k, k):
  if n >= a + b and a * 10000 + b * 5000 + (n - a - b) * 1000 == y:
    print(a, b, n - a - b)
    ans = 1
    break
if ans == 0:
  print('-1 -1 -1')

Solution (Python):
N, Y = list(map(int, input().split()))
list_m = [-1, -1, -1]
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:
      list_m = [a, b, c]
    else:
      continue
print(list_m[0], list_m[1], list_m[2])

Solution (Python):
"""
int 
float 


for name in fruits: 
    print(name)
    

list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

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

Solution (Python):
"""
int 
float 


for name in fruits: 
    print(name)
    

list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

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

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

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

Solution (Python):
N, Y = map(int, input().split())
ans = [-1, -1, -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:
      ans = x, y, z
      break

print(*ans)

Solution (Python):
N,Y=map(int,input().split())
answer=-1,-1,-1
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:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)

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):
n, Y = map(int,input().split())
ans = 0
goukei = 0

flag = False
for x in range(n+1):
    for y in range(n+1):
            z = n - x - y
            goukei = 10000*x + 5000*y + 1000*z
            if 0 <= z <= 2000 and goukei == Y:
                print(x, y, z)
                flag = True
                break
            elif x == n:
                print(-1, -1, -1)
                flag = True
                break
    if flag:
        break

Solution (Python):

n,y = map(int,input().split())
flg = False
for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if k >= 0:
            if 10000 * i + 5000 * j + 1000 * k == y:
                flg = True
                money = [i,j,k]
                break
if flg:
    print(*money)
else:
    print('-1 -1 -1')

Solution (Python):
import sys

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

"""
a = 0 
b = 0 
c = 0 

X = 0 
"""

for a in range(N+1):
    for b in range(N-a+1):

        if 10000*a + 5000*b + 1000*(N-a-b) == Y:
            print(a, b, N-a-b)
            sys.exit()


print("-1 -1 -1")

Solution (Python):


val = [10000, 5000, 1000]

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

mx = [y // i for i in val]
nm = [0, 0, 0]
an = [-1, -1, -1]  
is_find = False

for nm[0] in range(min(n, mx[0]) + 1):
    for nm[1] in range(min(n, mx[1]) + 1):
        nm[2] = n - nm[0] - nm[1]
        if nm[2] < 0:
            break
        elif nm[0] * val[0] + nm[1] * val[1] + nm[2] * val[2] == y and nm[2] >= 0:
            an = nm
            is_find = True
            break
    if is_find:
        break

print("{} {} {}".format(an[0], an[1], an[2]))
pass

Solution (Python):

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

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


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

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


def read():
    N, Y = map(int, input().strip().split())
    return N, Y


def solve(N, Y):
    for i in range(0, 2001):
        for j in range(0, 2001):
            k = N - i - j
            if k >= 0 and 10000 * i + 5000 * j + 1000 * k == Y:
                return "%d %d %d" % (i, j, k)
    return "-1 -1 -1"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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

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

Y //= 1000

for y in range(0, (10*N-Y)//5+1):
    for z in range(0, (10*N-Y-5*y)//9+1):
        if 10*N - Y == 5*y + 9*z:
            if N-y-z < 0:
                continue
            print(N-y-z, y, z)
            sys.exit()

print(-1, -1, -1)

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


def solve(N,Y):
    if Y > 10000*N:
        print("-1 -1 -1")
        return
    for a in range(N+1):
        for b in range(N+1-a):
            if a*1000+b*5000+(N-a-b)*10000 == Y:
                print(N-a-b, b, a)
                return
    print("-1 -1 -1")

solve(N,Y)

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

Solution (Python):

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

for n_10000 in range(int(Y/10000)+1):
    y_10000 = n_10000*10000
    for n_5000 in range(int((Y-y_10000)/5000)+1):
        y_5000 = n_5000*5000
        
        n_1000 = N-n_10000-n_5000
        if n_1000 >= 0 and Y-y_10000-y_5000 == 1000*n_1000:
            print('{} {} {}'.format(n_10000, n_5000, n_1000))
            exit(0)

print('-1 -1 -1')

Solution (Python):

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

yy = y//1000

amax = yy //10

for i in range(amax+1):
    resty = yy- i*10
    restn = n-i
    bmax = resty //5
    for j in range(bmax+1):
        restyz = resty - j*5
        restyn = restn - j
        if restyn == restyz:
            print(str(i)+" "+str(j)+" "+str(restyn))
            exit()

print("-1 -1 -1")

Solution (Python):
n,Y = map(int,input().split())
x,y,z = 0,0,0
flag = 0
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:
            flag = 1
            break
    if flag == 1:
        break
if(flag == 1):
    print(x,y,z)
else:
    print(-1,-1,-1)

Solution (Python):

from sys import exit
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):
def resolve():
    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")
resolve()

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

print(-1, -1, -1)

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

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

print(-1, -1, -1)

Solution (Python):
N, Y = map(int, input().split())
ans = False
for a in range(N+1):
  for b in range(N+1):
    c = N - a - b
    if (0 <= c <= N) and (10000*a + 5000*b + 1000*c == Y):
      print('{} {} {}'.format(a, b, c))
      exit()
if not ans:
  print('-1 -1 -1')

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

flg = False
for i in range(n+1):
  for j in range(n+1-i):
    
    if (10000*i + 5000*j + (n-i-j)*1000) == money:
      flg = True
      break
  if flg:
    break
if flg:
  print('{} {} {}'.format(i,j,n-(i+j)))
else:
  print('{} {} {}'.format(-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):
import sys

def main2():
    n,y=map(int,input().split())
    for i in range(n+1):
        for j in range(n+1-i):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                print("{} {} {}".format(i,j,n-i-j))
                sys.exit()
    print(-1,-1,-1)

if __name__=="__main__":
    main2()

Solution (Python):
import math

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

flag = 0
for i in range(n+1):
    for j in range(n+1-i):
        if( y == 10000*i + 5000*j + 1000*(n-i-j)):
            flag = 1
            break
    if(flag == 1):
        break

if(flag == 1):
    print(i,j,n-i-j)
else:
    print("-1 -1 -1")

Solution (Python):

import sys

def main2():
    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)
                sys.exit()
    print(-1,-1,-1)

if __name__=="__main__":
    main2()

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
        num = a*10000 + b*5000 + c*1000
        if num == Y:
            print("{} {} {}".format(a, b, c))
            exit()
 
print('-1 -1 -1')

Solution (Python):


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

ans1 = -1
ans2 = -1
ans3 = -1


for i in range(n + 1):
  for j in range(n + 1):
    sum = 10000 * i + 5000 * j + 1000 * (n - i -j)

    if sum == y and n - i -j >= 0:
      ans1 = i
      ans2 = j
      ans3 = n - i - j

print("{} {} {}".format(ans1, ans2, ans3))

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

if fin:
    print('-1 -1 -1')

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

print(-1,-1,-1)