peterverebics/CodeNet_Python_118 huggingface dataset:
n, Y = map(int, input().split())
x = -1
y = -1
z = -1
for i in range(min(n, Y // 10000), -1, -1):
    for j in range(n - i, -1, -1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == Y:
            x = i
            y = j
            z = n - i - j
            break
print(x, y, z)
N, Y = map(int, input().split())

resx, resy, resz = (-1, -1, -1)
# xn = Y//10000
for x in range(Y//10000+1):
    for y in range((Y-10000*x)//5000+1):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z

        if total == Y:
            resx, resy, resz = (x, y, z)
            break

print(resx, resy, resz)
n, y=map(int, input().split())
a=y//10000
b=y//5000
c=y//1000

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

print(-1, -1, -1)
n,kingaku = map(int,input().split())
all1000 = n*1000
if all1000>kingaku:
    print(-1,-1,-1)
    exit()
x = 0
y = 0
z = n
for i in range(n+1):
    x=i
    for j in range(n+1):
        z=n-(i+j)
        y=j
        if z<0:
            break
        money = x*10000 + y*5000 + z*1000
        if money == kingaku:
            print(x,y,z)
            exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

max_10000 = Y // 10000
for x in range(max_10000 + 1):
    if x > N:
        continue

    rem = Y - 10000 * x

    max_5000 = rem // 5000
    for y in range(max_5000 + 1):
        if x + y > N:
            continue

        rem_2 = rem - 5000 * y
        if x + y + rem_2 // 1000 == N:
            print('{} {} {}'.format(x, y, rem_2 // 1000))
            exit()


print('{} {} {}'.format(-1, -1, -1))
n, y = map(int, input().split())
def find(n,y):
    for p in range(n+1):
        for q in range(n-p+1):
            if 9000*p + 4000*q == y - 1000*n:
                return [p,q,n-p-q]
    return [-1,-1,-1]

for i in find(n,y):
    print(i, end=" ")
print()
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)
(k, s),  = [list(map(int, s.split())) for s in open(0)]
flag = 0 
for i in range(k + 1):
    for j in range(k - i + 1):
        l = k - i - j
        if 10000 * i + 5000 * j + 1000 * l == s:
            print(i, j, l)
            flag += 1 
            break
    else:
        continue 
    break

if not flag:
    print("-1 -1 -1")
N, Y = map(int, input().split())
Y /= 1000
total = 0
flag = 0

for A in range(N+1):
    for B in range(N+1):
        C = N - A - B
        if C<0:
            break
        total = 10 * A + 5 * B + C
        if total == Y:
            print(A, B, C)
            flag = 1
            break
    if flag == 1:
        break

if flag == 0:
    print('-1 -1 -1')
nums = [int(e) for e in input().split()]

count=0
for i in range(nums[0]+1):
    for j in range(0, nums[0]+1-i):
        if 10000*i+5000*j+1000*(nums[0]-i-j)==nums[1]:
            print('{} {} {}'.format(i, j, nums[0]-i-j))
            count=1
            break
    if count==1:
        break

if count==0:
    print('-1 -1 -1')
n,y = map(int, input().split())

exist = False

for i in range(int(y/10000)+1):
    range_j = int((y - 10000*i)/5000)
    for j in range(range_j+1):
        k = n - i - j
        res = y - 10000*i - 5000*j
        if res == 1000*k:
            print("{} {} {}".format(i,j,n-i-j))
            print("\n")
            exist = True
        if exist:
            break
    if exist:
        break

if not exist:
    print("-1 -1 -1")
    print("\n")
n,y = list(map(int,input().split()))
y /= 1000


for b in range(n+1):
  for f in range(n-b+1):
    if (y - b*10 - 5*f) == n-b-f:
      ans = [b, f, n-b-f]
      print(*ans)
      exit()

ans = [-1,-1,-1]
print(*ans)
N,Y=map(int,input().split())

for x in range(Y//10000+3):
  for y in range(Y//5000+3):
    z = N-x-y
    if z < 0:break
    SUM = 10000*x + 5000*y + 1000*z
    if SUM == Y:
      print(x,y,z)
      exit()
    elif SUM > Y:break
print(-1,-1,-1)
import sys
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        ans = i*10000 + j*5000 + k*1000

        if ans == Y:
            print("{0} {1} {2}" .format(i,j,k))
            sys.exit()

print("-1 -1 -1")
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1):
        x = i
        y = j
        z = N-(x+y)

        if z < 0:
            break
        if (10000*x + 5000*y + 1000*z) == Y:
            print (x,y,z)
            exit ()
print (-1,-1,-1)
N, Y = map(int, input().split());

# 10000x + 5000y + 1000z = Y
# z = N - x - y
# → 9000x + 4000y = Y - 1000N

# Y - 1000N
flag = False;
S = Y - N * 1000;
for i in range(N + 1):
  y_div, y_mod = divmod((S - 9000 * i), 4000);
  z = N - i - y_div;
  if (y_mod == 0 and z >= 0 and y_div >= 0):
    print(str(i) + " " + str(y_div) + " " + str(z));
    flag = True;
    break;

if (flag == False):
  print("-1 -1 -1");
n, Y = map(int, input().split())
a = Y//1000

for x in range(n+1):
  for y in range(n-x+1):
    if 9*x + 4*y == a-n and n-x-y>=0:
      print(x, y, n-x-y)
      exit()
print(-1, -1, -1)
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)
import sys
N, Y = map(int,input().split())

for k in range(N+1):
	for j in range(N+1 - k):
		i = N - k -j
		if k*10000 + j*5000 + i*1000 == Y:
			print(k, j, i)
			sys.exit()
print("-1 -1 -1")
N,Y = map(int,input().split())
c = 0
for i in range(0,N+1):
    for j in range(0,N+1):
        c = ((Y-(10000*i+5000*j))/1000)
        if c.is_integer and c >= 0 and i+j+c == N:
            d = int(c)
            print(i,j,d)
            exit()
print(-1,-1,-1)
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)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')
import math
import sys
from collections import deque
a,b=map(int,input().split())
b=b//1000
for i in range(a+1):
  for j in range(a+1):
    if 10*i+5*j+a-i-j==b and i+j<=a:
      print(i,j,a-i-j,sep=" ")
      sys.exit()
print(-1,-1,-1,sep=" ")
N, Y = map(int, input().split())
res10000 =res5000 = res1000 = -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:
            res10000 = x
            res5000 = y
            res1000 = z

print(res10000, res5000, res1000)
n, y = map(int, input().split())

for i in range(y // 10000 + 1):
    for j in range((y - 10000 * i) // 5000 + 1):
        if (i*10000 + j*5000+(n-i-j)*1000) == y:
            print(i, j, (n - i - j))
            exit()
print(-1, - 1, - 1)
n,Y = map(int,input().split())
 
ans_x = -1
ans_y = -1
ans_z = -1
 
for x in range(n+1):
    for y in range(n+1-x):
        z = int((Y -10000*x - 5000*y)/1000)
        if z >= 0 and (z%1==0 or z==0) and x+y+z == n:
            ans_x = x
            ans_y = y
            ans_z = z
            break
 
print(ans_x, ans_y, ans_z)
i,j= list(map(int, input().split()))
ans1=-1
ans2=-1
ans3=-1
for k in range(i+1):
    for m in range(i-k+1):
        n=i-k-m
        if j==(k*10000)+(m*5000)+(n*1000):
            ans1=k
            ans2=m
            ans3=n
print(ans1,ans2,ans3)
# abc085

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 x*10000 + y*5000 + z*1000 == Y:
            ans = (" ".join(list(map(str, [x, y, z]))))
            break

print(ans)
bill_count, total_money = map(int, input().split())

def calc(total_money, bill_count):
  x_high_bound = int(total_money / 10000) if int(total_money / 10000) < bill_count else bill_count
  for x in range(x_high_bound + 1):
    hoge = bill_count - x
    if 10000 * x + 5000 * hoge < total_money: continue
    if 10000 * x + 1000 * hoge > total_money: continue
    for y in range(hoge + 1):
      for z in [bill_count - x - y]:
        if 10000 * x + 5000 * y + 1000 * z == total_money:
          return "{} {} {}".format(x, y, z)
  return '-1 -1 -1'

print(calc(total_money, bill_count))
n,y = map(int, input().split())

for i in range(n, -1, -1):
  if  y - 10000*i < 0: continue
  for j in range(n-i, -1, -1):
    k = n-i-j
    if y - 10000*i - 5000*j - 1000*k < 0: continue
    elif y - 10000*i - 5000*j - 1000*k == 0:
      print(i,j,k)
      exit()
print(-1,-1,-1)
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)
import sys
N, Y = map(int,input().split())
sum_ = 0
for i in range(N+1):
  for j in range(N-i+1):
    sum_ = 10000*i + 5000*j + 1000*(N-i-j)
    if sum_ == Y:
      print(i,j,N-i-j)
      sys.exit()
print(-1,-1,-1)
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline()).split())

n,y=nii()
for i in range(n+1):
  for j in range(n-i+1):
    num=n-i-j
    money=10000*i+5000*j
    zan=(y-money)//1000
    if num==zan:
      print(i,j,num)
      exit()

print(-1,-1,-1)
# C - Otoshidama
N,Y= map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        if i * 10000 + j *5000 + k *1000 ==Y:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
print("-1 -1 -1")
n ,y = map(int,input().split())

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

print(-1,-1,-1)
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
N, Y = ri_()
for i in range(N + 1):
    for j in range(N + 1):
        if 1000 * (N - i - j) == Y - 10000 * i - 5000 * j and N - i - j >= 0:
            print(i, j, N - i - j)
            exit()
print(-1, -1, -1)
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)
import sys
n, y = map(int, input().split())
a = y//10000
b = (y-a*10000)//5000
c = (y-a*10000-b*5000)//1000
if not (a+b+c<=n<=y//1000):
    print(-1, -1, -1)
    sys.exit()
for i in range(a, -1, -1):
    for j in range(b+2*(a-i), -1, -1):
        k = (y-i*10000-j*5000)//1000
        if n==i+j+k:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)
# C - Otoshidama(https://atcoder.jp/contests/abc085/tasks/abc085_c)
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)
n,y=map(int,input().split())
for i in range(2001):
  for j in range(2001):
    if i*9+j*4+n==y/1000 and i+j<=n:
      exit(print(i,j,n-i-j))
print(-1,-1,-1)
N, Y = map(int, input().split())
for x in range(N+1):
  for y in range(N+1-x):
    z = N - x - y
    if z >= 0 and 10000*x + 5000*y + 1000*z == Y:
      print(str(x)+" "+str(y)+" "+str(z))
      exit()
print("-1 -1 -1")
n, Y = map(int, input().split())
frag = 0
tmp = 0
a = 0
b = 0
c = 0
for x in range(n + 1):
    for y in range(n - x + 1):
        tmp = x * 10000 + y * 5000 + (n - x - y) * 1000
        if tmp == Y:
            frag = 1
            a = x
            b = y
            c = n - x - y
            break
if frag == 0:
    print("-1 -1 -1")
else:
    print(f"{a} {b} {c}")
import sys

n, y = map(int, input().split())
for i in range(n+1):
  for j in range(min(n-i+1, 9)):
    k = n - i - j
    money = 10000 * i + 5000 * j + 1000 * k
    if y == money:
      print("{} {} {}".format(i, j, k))
      sys.exit()
print(-1, -1, -1)
n,k = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        if x+y>n:
            continue
        z = n-(x+y)
        if x*10000+y*5000+z*1000 == k:
            print(x,y,z)
            exit(0)
print(-1,-1,-1)
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1-i):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")
 
n,y = map(int, input().split())
print(calcPattern(n,y))
N,Y = map(int, input().split())
res = [-1,-1,-1]
for x in range(N+1):
    for y in range(N+1-x):
        if 10000*x + 5000*y +1000*(N-x-y) == Y:
            res =[x,y,N-x-y]
print(res[0],res[1],res[2])
N, Y = map(int, input().split())

q = -1
w = -1
r = -1

for a in range(N + 1):
    for b in range(N + 1 - a):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            q = a
            w = b
            r = c

print('{} {} {}'.format(q, w, r))
N , Y = (int(x) for x in input().split())
senen = Y//10000
result = False
gosenen = Y // 5000

for x in range(N, -1, -1):
    #Y = Y - 10000 * x
    #print("x:",x)
    for y in range(N,-1,-1):
        #Y = Y - y * 5000
        z = N - x - y
        if x * 10000 + y * 5000 + z * 1000 == Y and x + y + z <= N and z >= 0:
            result = True
            print(x,y,z)
            break
    else:
        continue
    break





if result == False:
    print(-1,-1,-1)
N, Y = map(int, input().split())

for m10 in range(N + 1):
    for m5 in range(N + 1 - m10):
        m1 = N - m10 - m5
        if m10 * 10000 + m5 * 5000 + m1 * 1000 == Y:
            print(m10, m5, m1)
            exit(0)

print('-1 -1 -1')
I = list(map(int, input().split()))
N, Y = I[0], I[1]

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

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

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))
            find_ans = True
            sys.exit()

if find_ans == False:
    print('-1 -1 -1')
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)
N, Y = map(int, input().split())

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:
            print(a, b, c)
            exit()
else:
    print(-1, -1, -1)
flag = 0
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 and k >= 0:
      flag = 1
      print(i,j,k)
      break
  if flag == 1:
    break
    
if flag == 0:
  print(-1,-1,-1)
bill_count, total_money = map(int, input().split())

def search_pattern(bill_count, total_money):
  for x in range(bill_count + 1):
    for y in range(bill_count - x + 1):
      z = bill_count - x - y
      t = 10000 * x + 5000 * y + 1000 * z
      if t != total_money:
        continue
      return (x, y, z)
  return (-1, -1, -1)

answer = search_pattern(bill_count, total_money)
print(" ".join(map(str, answer)))
# https://atcoder.jp/contests/abc085/tasks/abc085_c

# N枚、Y円
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N + 1):
        
        z = N - (i + j)

        if z < 0:
            continue

        total = i*1000 + j*5000 + z*10000
        
        if total == Y:
            print(z, j, i)
            exit()

print('-1 -1 -1')
N, Y= map(int, input().split())
flag = 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):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)
N, Y = map(int, input().split())

a = 10000
b = 5000
c = 1000

# p = 1 q = 1
# cの枚数 = 5


def solve(n):
    for i in range(N+1):
        for j in range(N-i+1):
            tmp = Y - a * i - b * j
            k = N - i - j
            if (tmp == 0 and k == 0) or tmp // c == k:
                return i, j, k
    return -1, -1, -1


i, j, k = solve(N)
print(i, j, k)
import sys

input = sys.stdin.readline

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

Aohashi = False
for a in range(N+1):
	for b in range(N+1-a):
		c = N-a-b
		otoshidama = 10000*a+5000*b+1000*c
		if otoshidama==Y:
			Aohashi = True
			break
	if Aohashi: break

if Aohashi:
	print(a,b,c)
else:
	print(-1,-1,-1)
n,y = map(int,input().split())
a,b,c=-1,-1,-1

for i in range(n+1):
  for j in range(n-i+1):
    # print(10000*i+5000*j+1000*(n-i-j))
    if 10000*i+5000*j+1000*(n-i-j) == y:
      a,b,c=i,j,n-i-j
      break
      
print(a,b,c)
N, Y = map(int, input().split(' '))

for i in range(N+1):
    for j in range(N+1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y and N-i-j >=0:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)
n,Y=map(int,input().split())
for x in range(n+1):
    for y in range(n+1):
        if 10000*n-9000*x-5000*y==Y and x+y<=n:
            print(n-x-y,y,x)
            exit()
print(-1,-1,-1)
n, y = map(int, input().split())
y //= 1000
a = 0; b = 0; c = 0
f = False
for i in range(n+1):
    for j in range(n+1):
        if 9*i + 4*j == y - n and i + j <= n:
            a = i
            b = j
            f = True
            break
if f: print(a, b, y-10*a-5*b)
else: print(-1, -1, -1)
n,y = map(int,input().split())

for i in range(min(y//10000+1,n+1)):
    for j in range(min((y-10000*i)//5000+1,n-i+1)):
        k=n-i-j
        if i*10000+j*5000+k*1000==y and i+j+k==n:
            print(i,j,k);exit()
else:
    print(-1,-1,-1)
m = input().split()
N = int(m[0])
Y = int(m[1])
ans = [0] * 3

for a in range(N+1):
  for b in range(N - a + 1):
    c = N - (a + b)
    money = (a * 10000) + (b * 5000) + (c * 1000)

    if money == Y:
      ans[0] = a
      ans[1] = b
      ans[2] = c
      break
  else:
    continue

  break

if ans == [0, 0, 0]:
  ans = [-1, -1, -1]

x = ans[0]
y = ans[1]
z = ans[2]

print(str(x) + ' ' + str(y) + ' ' + str(z))
N,Y=map(int,input().split())
ans=[-1,-1,-1]
for i in range(N+1):
    for j in range(N-i+1):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            ans=[i,j,k]
            break
print(ans[0],ans[1],ans[2])
n,y=map(int,input().split())

n1=y//1000
n5=y//5000
n10=y//10000
for x1 in range(n1+1):
    if x1>n:continue
    for x5 in range(n5+1):
        x10=n-x1-x5
        if n10<x10:continue
        if x10<0:break
        if x1*1000+x5*5000+x10*10000==y and x1+x5+x10==n:
                print(x10,x5,x1)
                exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

y = 0
for i in range(Y // 10000 + 1):
    y = i * 10000

    for j in range((Y - y) // 5000 + 1):
        y2 = y + 5000 * j

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

a, b, c = -1, -1, -1
flag = False
for i in range(N+1):
    if flag:
        break

    for j in range(N+1-i):
        if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
            a = i
            b = j
            c = N-i-j
            flag = True
            break

print("{} {} {}".format(a,b,c))
N,Y=map(int,input().split())
for i in range(N+1):
  if 10000*i>Y:
    break
  for j in range(N+1-i):
    k=N-i-j
    S = 10000*i + 5000*j + 1000*k
    if k<0 or S>Y:
      continue
    elif S == Y:
      print(i,j,k)
      exit()
print(-1,-1,-1)
n,y=map(int,input().split())
judge=False
for i in range(n+1):
    if judge==True:
      break
    for j in range(n-i+1):
        if judge==True:
          break
        k=n-i-j
        if 1000*i+5000*j+10000*k==y:
            print(k,j,i)
            judge=True
            break
if judge==False:
    print(-1,-1,-1)
N, Y = map(int, input().split())
found = False
for k10 in range(N+1):
    if 10000 * k10 > Y:
        continue
    for k5 in range(N+1 - k10):
        k1 = N - k10 - k5
        if Y == 1000 * k1 + 5000 * k5 + 10000 * k10:
            found = True
            break
    if found:
        print(k10, k5, k1)
        break
else:
    print(-1, -1 ,-1)
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 Y == 10000 * x + 5000 * y + 1000 * z:
            print(x, y, z)
            exit()
print(-1, -1, -1)
def main():
    n, sum = list(map(int,input().split()))
    x_max = sum // 10000
    for x in reversed(range(0, x_max + 1)):
        y_max = (sum - x * 10000) // 5000
        for y in reversed(range(0, min(n - x + 1, y_max + 1))):
            z = n - x - y
            if 10000 * x + 5000 * y + 1000 * z == sum:
                    print(x, y, z)
                    return 0
    print('-1 -1 -1')
    return 0

main()
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
print(*answer)
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)
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,y=map(int, input().split())
    yy=y//1000
    if yy>n*10:
        print(-1,-1,-1)
    else:
        ans=[-1,-1,-1]
        for x in range(n+1):
            for y in range(n-x+1):
                if x*10+y*5+(n-x-y)==yy:
                    flag=True
                    ans=[x,y,n-x-y]
        print(*ans)
resolve()
N, Y = map(int, input().split())        
Anser = [-1, -1, -1]

flag = False

for i in range(N+1):
    if flag == True: break
    for j in range(N+1-i):
        if flag == True: break
        if Y == 10000*i + 5000*j +1000*(N-i-j): 
            Anser =[i, j, N-i-j]
            flag = True

print(*Anser)
n,y = [int(i)  for i in input().split()]
for i in range(2001):
  for j in range(2001):
    if 10000*(i)+5000*(j)+1000*max(0,(n-i-j)) == y:
      if n-i-j >= 0:
        print(i,j,n-i-j)
        exit()
print(-1,-1,-1)
n, purpose = map(int, input().split(" "))

resultI = resultJ = resultK = -1

def combiValue(i, j, k):
  return 10000 * i + 5000 * j + 1000 * k

for i in range(n+1):
  for j in range(n+1-i):
    k = n - i - j
    if combiValue(i, j, k) == purpose:
      resultI = i
      resultJ = j
      resultK = k

print("{0} {1} {2}".format(resultI, resultJ, resultK))
N, M = map(int, input().split())
l = [-1, -1, -1]
for i in range(N+1):
  for j in range(N-i+1):
    if 1000 * i + 5000 * j + 10000 * (N-i-j) == M:
      l = [i, j, N-i-j]
print(l[2], l[1], l[0])
n, y = map(int, input().split())

rem = 0
for i in range(y//10000 +1):
    rem = y-10000*i
    for j in range(rem//5000 + 1):
        k = (rem - 5000*j) // 1000
        if (i + j+ k) == n:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)