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

Solution (Python):
n,y=map(int,input().split())
for i in range(0,min(n+1,y//10000+1)):
    for j in range(0,min(n-i+1,(y-10000*i)//5000+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 , t = map(int,input().split(' '))
ans_x = -1
ans_y = -1
ans_ans = -1
for x in range(n+1):
    for y in range(n+1):
        ans = n -x - y
        if ans>= 0:
            if 10000 * x + 5000 * y + 1000 * ans == t:
                ans_x = x
                ans_y = y
                ans_ans = ans
                break
 
print(ans_x,ans_y,ans_ans)

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

print('{} {} {}'.format(A[0], A[1], A[2]))

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

man_max = Y // 10000
gosen_max = Y // 5000

for x in range(man_max+1):
  for y in range(gosen_max+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):
import sys

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:
      break
    t = i * 10000 + j * 5000 + k * 1000
    if t == y:
      print('{} {} {}'.format(i, j, k))
      sys.exit()
print('-1 -1 -1');

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

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

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

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

flag = False
for i in range(n + 1):
    for j in range(n + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            flag = True
            ans = (i, j, n - i - j)

print(*ans) if flag else print('-1 -1 -1 ')

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

for i in range(N+1):
  for j in range(N-i+1):
    k = N - i - j
    money = 10 * i + 5 * j + k
    if money == Y:
      print(i,j,k)
      sys.exit()

print(-1,-1,-1)

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

ans=0

for i in range(y//10000,-1,-1):

    nokori=(y-i*10000)

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

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

for x in range(n + 1):
    for y in range(n + 1 - x):
        if 10000*x + 5000*y + 1000*(max(0, n-x-y)) == m:
            print(x, y, n-x-y)
            exit()
print(-1, -1, -1)

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

ans = ''

for i in range(n + 1):
    for j in range(n - i + 1):
        for k in range(n - i - j, n - i - j + 1):
            if y == 10000 * i + 5000 * j + 1000 * k:
                ans = '{} {} {}'.format(i, j, k)

if ans == '':
    print('-1 -1 -1')
else:
    print(ans)

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

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

    if x == 1:
        break

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

Solution (Python):
n, y = map(int, input().split())
x = 0
for i in range(n + 1):
    if 10000*i > y:break

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

    if x == 1:
        break

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

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

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

for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if 0 <= z <= N and 10000*x+5000*y+1000*z == Y :
            print("{} {} {}".format(x,y,z))
            exit()
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):
		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 = []
for x in range(n+1):
  for p in range(n+1-x):
    z = n - x - p
    if y-10000*x-5000*p == 1000*z and x+p+z == n:
      print(x, p, z)
      ans.append((x, p, z))
      exit()

if len(ans) == 0:
  print(-1, -1, -1)

Solution (Python):
'''
制約
1≦N≦2000
1000≦Y≦2 * 10**7
N は整数である。
Yは1000の倍数である

'''



import sys
input = sys.stdin.readline




def main():
    '''メイン処理'''
    n, all_yen = map(int, input().split())

    is_OK = False
    
    
    for x in range(n+1):
        if 10000*x > all_yen:
            
            break

        for y in range((n+1)-x):
            if (10000*x)+(5000*y) > all_yen:
                
                break
            
            
            
            z = n - x - y
            if 1000*z == (all_yen - (10000*x) - (5000*y)):
                is_OK = True
                print(x, y, z)
                break

        if is_OK:
            break
    
    if not is_OK:
        print('-1 -1 -1')


if __name__ == "__main__":
    
    main()

Solution (Python):
import sys
n,y = map(int, sys.stdin.readline().split())
for a in range (n+1):
    for b in range(n+1-a):
        c = n-a-b
        if 10000*a + 5000*b + 1000*c == y:
            print(a,b,c)
            break
    else:
        continue
    break
if 10000*a + 5000*b + 1000*c != y:
    print(-1,-1,-1)

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

for i in range(0,n+1,1):
    for j in range(0,n-i+1,1):
        tmp = 10*i+5*j+1*(n-i-j)
        if tmp == y_:
            print(str(i)+' '+str(j)+' '+str(n-i-j)+' ')
            sys.exit()
print(str(-1)+' '+str(-1)+' '+str(-1)+' ')

Solution (Python):
n,Y = map(int,input().split())
for z in range(n+1):
    for y in range(n-z+1):
        if 0<=n-z-y<=2000 and (n-z-y)*10000+y*5000+z*1000==Y:
            print(n-z-y,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-i+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            print(i, j, n-i-j)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Solution (Python):
n,y=map(int,input().split())
ans=[-1]*3

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]
            break
    else:
        continue
    break

print(*ans)

Solution (Python):
N, Y = list(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)

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 Y == 10000 * x + 5000 * y + 1000 * z:
            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-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):
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):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy





sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))




def main():
    n, y = ns()

    tmp = y // 1000 - n
    calc = lambda x, y: 9 * x + 4 * y

    for x in range(2000 + 1):
        for y in range(2000 + 1):
            if calc(x, y) == tmp:
                if n - x - y > -1:
                    print(x, y, n - x - y)
                    exit(0)

    print(-1,-1,-1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy





sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))




def main():
    n, y = ns()

    tmp = y // 1000 - n
    calc = lambda x, y: 9 * x + 4 * y

    for x in range(2000 + 1):
        for y in range(2000 + 1):
            if calc(x, y) == tmp:
                if n - x - y > -1:
                    print(x, y, n - x - y)
                    exit(0)

    print(-1,-1,-1)


if __name__ == '__main__':
    main()

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

for noguchi in range(n + 1):
    for higuchi in range(n + 1 - noguchi):
        yukichi = n - noguchi - higuchi
        if noguchi + higuchi * 5 + yukichi * 10 == yen:
            print(yukichi, higuchi, noguchi)
            exit(0)
print("-1 -1 -1")

Solution (Python):
N, Y = map(int, input().split())
a = 10000
b = 5000
c = 1000

ans = [-1, -1, -1]
for y in range(min(N+1, Y//b+1)):
    for x in range(min(N-y+1, Y//a+1)):
        z = N - x - y
        if a*x + b*y + c*z == Y:
            ans = [x, y, z]
            break
    else:
        continue
    break
print(*ans)

Solution (Python):
def comp(itm):
	a, b, c = itm
	return a*100 + b*10 + c

def resolve():
	n, y = map(int, input().split())
	t = []
	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:
				t.append([i, j, k])
	if not t:
		print(-1, -1, -1)
	else:
		a, b, c = sorted(t, key=lambda x: comp(x), reverse=True)[0]
		print(a, b, c)
resolve()

Solution (Python):
def main():
    num, yen_sum = map(int, input().split())
    yen_sum /=1000
    res = [-1, -1, -1]
    for bill_10000 in range(num+1):
        if bill_10000*10 + (num-bill_10000+1)*5 <= yen_sum:
            continue
        for bill_5000 in range(num-bill_10000+1):
            bill_1000 = num - bill_10000 - bill_5000
            if bill_10000*10 + bill_5000*5 + bill_1000*1 == yen_sum:
                res = [bill_10000, bill_5000, bill_1000]
                break
    print(*res)
    
if __name__ == '__main__':
    main()

Solution (Python):
x,y=map(int,input().split())
a1=-1
b1=-1
c1=-1
for a in range(0,x+1):
    for b in range(0,x+1-a):
        c=x-a-b
        if 10000*a+5000*b+1000*c==y:
            a1=a
            b1=b
            c1=c
print(a1,b1,c1)

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

n,Y = map(int, stdin.readline().rstrip().split())

for x in range(n+1):
    for y in range(n+1):
        z = n - x - y
        money = 10000*x + 5000*y + 1000*z
        if z >= 0 and money == Y:
            print(x,y,z)
            exit()
        else:
            pass

print(-1,-1,-1)

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

ans_x = -1
ans_y = -1
ans_z = -1

for x in range(0 ,N+1):
    for y in range(0, (N+1) - x):
        z = N - (x + y)
        if 10000*x + 5000*y + 1000*z == Y:
            ans_x = x
            ans_y = y
            ans_z = z
        else:
            continue

print(ans_x,ans_y,ans_z)

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

ans_x = -1
ans_y = -1
ans_z = -1

for x in range(0 ,N+1):
    for y in range(0, (N+1) - x):
        z = N - (x + y)
        if 10000*x + 5000*y + 1000*z == Y:
            ans_x = x
            ans_y = y
            ans_z = z
        else:
            continue

print(ans_x,ans_y,ans_z)

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

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

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

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

print(-1, -1, -1)

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

print(-1, -1, -1)

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

print(-1, -1, -1)

Solution (Python):
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)

Solution (Python):
n, y=map(int, input().split())
a=y//10000
b=y//5000
c=y//1000

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

print(-1, -1, -1)

Solution (Python):

"""this is python work script"""

def solver(price, counts):
    """solve this problem"""
    answer = ['-1', '-1', '-1']
    for x in range(counts+1):
        sum_x = x * 10000
        for y in range(counts + 1 - x):
            z = counts - x - y
            sum_y = y * 5000
            sum_z = z * 1000
            sum_all = sum_x + sum_y + sum_z
            if sum_all == price:
                return list(map(str, [x, y, z]))
    return answer

def main():
    """main function"""
    N, Y = list(map(int, input().split()))
    answer = solver(Y, N)
    print(" ".join(answer))

if __name__ == '__main__':
    main()

Solution (Python):

"""this is python work script"""

def solver(price, counts):
    """solve this problem"""
    answer = ['-1', '-1', '-1']
    for z in range(counts+1):
        sum_z = z * 1000
        if sum_z > price:
            continue
        for y in range(counts + 1 - z):
            x = counts - y - z
            sum_y = y * 5000
            sum_x = x * 10000
            sum_all = sum_x + sum_y + sum_z
            if sum_all > price:
                continue
            if sum_all == price:
                return list(map(str, [x, y, z]))
    return answer

def main():
    """main function"""
    N, Y = list(map(int, input().split()))
    answer = solver(Y, N)
    print(" ".join(answer))

if __name__ == '__main__':
    main()

Solution (Python):

"""this is python work script"""

def solver(price, counts):
    """solve this problem"""
    answer = ['-1', '-1', '-1']
    for z in range(counts+1):
        sum_z = z * 1000
        for y in range(counts + 1 - z):
            x = counts - y - z
            sum_y = y * 5000
            sum_x = x * 10000
            sum_all = sum_x + sum_y + sum_z
            if sum_all == price:
                return list(map(str, [x, y, z]))
    return answer

def main():
    """main function"""
    N, Y = list(map(int, input().split()))
    answer = solver(Y, N)
    print(" ".join(answer))

if __name__ == '__main__':
    main()

Solution (Python):
N, Y = map(int, input().split())
a = -1
b = -1
c = -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:
            a = A
            b = B
            c = C
print('{} {} {}'.format(a, b, c))

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

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

main()

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 collections
import fractions
from functools import reduce
import sys
input = sys.stdin.readline


def main():
    n, y = input_list()
    y_1000 = y//1000
    if y_1000 == n:
        print(0, 0, y_1000)
        exit(0)

    for x_1000 in range(n+1):
        for x_5000 in range(n+1):
            x_10000 = n - (x_1000+x_5000)
            if x_10000 < 0:
                continue
            yen_1000 = x_1000 * 1000
            yen_5000 = x_5000 * 5000
            yen_10000 = x_10000 * 10000
            if (yen_1000 + yen_5000 + yen_10000) == y:
                print(x_10000, x_5000, x_1000)
                exit(0)
    print(-1, -1, -1)


def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()

Solution (Python):
import collections
import fractions
from functools import reduce
import sys
input = sys.stdin.readline


def main():
    n, y = input_list()
    for x_1000 in range(n+1):
        for x_5000 in range(n+1):
            x_10000 = n - (x_1000+x_5000)
            if x_10000 < 0:
                continue
            yen_1000 = x_1000 * 1000
            yen_5000 = x_5000 * 5000
            yen_10000 = x_10000 * 10000
            if (yen_1000 + yen_5000 + yen_10000) == y:
                print(x_10000, x_5000, x_1000)
                exit(0)
    print(-1, -1, -1)


def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
import os

def file_input():
    f = open('ABC085/input.txt', 'r')
    sys.stdin = f

def main():
    

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

    
    
    
    tmp=Y//1000-N
    

    for x in range(N+1):
        if (tmp-9*x)%4==0:
            y=(tmp-9*x)//4
            if y>=0:
                z=N-(x+y)
                if z>=0:
                    print(str(x)+" "+str(y)+" "+str(z))
                    break
    else:
        print("-1 -1 -1")

if __name__ == '__main__':
    main()

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

    flag = False
    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))
                flag = True
                break
        if flag == True:
            break

    if flag == False:
        print("-1 -1 -1")
resolve()

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

match = False
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        y = 10000*i + 5000*j + 1000*k
        if y == Y:
            match = True
            print(i, j, k)
            break
    if match:
        break

if not match:
    print(-1, -1, -1)

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

for x in range(n+1):
    for y in range(n+1-x):
        z= int(yen/1000) - 10*x - 5*y
        if (0<= z) and (z == n-x-y):
            
            bol = True
            ans = [x,y,z]
            break

print(ans[0],ans[1],ans[2])
'''
        if 0<= yen/1000 + 12*x + 5*y <= n+1-x-y:
            print(x,y,z)
            break
'''

Solution (Python):
import sys
a,b=map(int,input().split())
b=b/1000
for i in range(a+1):
  for j in range(a-i+1):
    if 10*i+5*j+a-i-j==b:
      print(i,j,a-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-i+1):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print("%d %d %d"%(i,j,n-i-j))
            exit()
print(-1,-1,-1)

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

for i in range(N+1):
  for j in range(N+1):
    z = N - i - j
    if i+j+z > N or z < 0:
      continue

    if 10000*i + 5000*j + 1000*z == Y:
      print("{0} {1} {2}".format(i,j,z))
      sys.exit()

print("-1 -1 -1")

Solution (Python):
n, y = map(int, input().split())
a={}
j=True


for th in range(0, n+1) :
    for fh in range(0, n-th+1) :
        if th * 10000 + fh * 5000 + (n-fh-th) * 1000 == y :
            print (th, fh, n-fh-th)
            j = False
            break
    else :
        continue
    break

if j == True:
    print(-1, -1, -1)

Solution (Python):
N, Y = list(map(int, input().split()))
can = False
for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        tot = 10000 * x + 5000 * y + 1000 * z
        if tot == Y:
            print(' '.join(list(map(str, [x, y, z]))))
            can = True
            break
    else:
        continue
    break

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

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


N,Y = map(int, input().split())
flag=0
for i in range(0,N+1):
    for j in range(0,N+1-i):
        if(Y-10000*i-5000*j)/1000 == N-i-j :
            a = i
            b = j
            c = N-i-j
            flag =1
            break
        if flag==1:
            break

if flag==1:
    print(a,b,c)

if flag!=1:
    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):
        if i*10000+j*5000+(n-i-j)*1000==y:
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

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

c = 0

for o in range(n+1):
    for f in range(n+1-o):
        if 10000*n - 9000*o -5000*f == y:
            print(n-o-f , f , o)
            c = 1
            break
    if c == 1:
        break
            
if c != 1:
    print(-1 , -1 , -1)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, Y = map(int, input().split())

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


if __name__ == "__main__":
    main()

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

summ = 0
flag = 0
for a in range(n+1):
    for b in range(n+1-a):
        if (10000 * a + 5000 * b + 1000 * (n-a-b)) == y:
            print(a, b, n-a-b)
            flag = 1
            break
    if flag == 1:
        break
if flag == 0:
    print("-1 -1 -1")

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

flag = 0
xx=-1
yy=-1
zz=-1
for i in range(n+1):
  if i > y//10000:
    continue
  for j in range(n-i+1):
    if j > (y-10000*i)//5000:
      continue
    if y == 10000*i + 5000*j + 1000*(n-i-j):
        flag = 1
        xx=i
        yy=j
        zz=n-i-j

print(xx,yy,zz)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

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

for i in range(n+1):
    for j in range(n+1-i):
        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 = (int(x) for x in input().split())
senen = Y//10000
result = False
gosenen = Y // 5000

for x in range(N, -1, -1):
    
    
    for y in range(N,-1,-1):
        
        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)

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

for i in range(0,n+1,1):
    for j in range(0,n-i+1,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())
c=0
for i in range(n+1):
    for j in range(n-i+1):
        if 9*i+4*j+n==y//1000:
            print(i,j,n-i-j)
            c=1
            break
    if c==1:
        break
if c!=1:
    print(-1,-1,-1)

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

Solution (Python):
N, Y = map(int, input().split() )
for yukichi in range(N+1,-1, -1):
  for higuchi in range(N-yukichi+1,-1, -1):
    zansa = Y - (10000*yukichi+5000*higuchi)
    if (zansa%1000 == 0) and 0<=zansa//1000==(N-yukichi-higuchi):
      print(yukichi, higuchi, zansa//1000)
      break
  else:
    continue
  break
else:
  print(-1, -1, -1)

Solution (Python):
n,Y = map(int,input().split())
Y = int(Y / 1000)
ans = [-1,-1,-1]
for x in range(n+1):
    for y in range(n+1):
        if 10*x + 5*y + (n-x-y) == Y and n-x-y >= 0:
            ans = [x,y,n-x-y]
print(*ans)

Solution (Python):
n, yen = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        z = n - (x+y)
        if 10000*x + 5000*y + 1000*z == yen and z >= 0:
            print('{} {} {}'.format(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):
    res = y - (10000*i + 5000*j)
    k = n - i-j
    if (res == 1000*k) and (k>=0):
      print(i, j, n-i-j)
      exit()
      
print('-1 -1 -1')

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

Y=int(Y/1000)
A=B=C=-1

for c in range(N+1):
  for b in range(N+1):
    a=N-b-c
    if c+5*b > Y:
      break
    if c+5*b+10*a == Y:
      A,B,C=a,b,c
      
print(A,B,C)

Solution (Python):
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)

Solution (Python):
import sys

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

print('-1 -1 -1')

Solution (Python):
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')