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, sum = map(int, input().split())
for x in range(n + 1):
    for y in range(n - x + 1):
        if x * 10000 + y * 5000 + (n-x-y) * 1000 == sum:
            print(x, y, n-x-y)
            exit()

print(-1, -1, -1)

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

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

print(-1, -1, -1)

Solution (Python):
n, yen = [int(s) for s in input().split()]
yen //= 1000
for x in range(n + 1):
    for y in range(n - x + 1):
        z = n - x - y
        p = 10 * x + 5 * y + z
        if p == yen:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Solution (Python):
n, yen = [int(s) for s in input().split()]
yen //= 1000
for x in range(n + 1):
    p_x = 10 * x
    if p_x > yen:
        break
    for y in range(n - x + 1):
        p_x_y = p_x + 5 * y
        if p_x_y > yen:
            break
        z = n - x - y
        p_x_y_z = p_x_y + z
        if p_x_y_z == yen:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Solution (Python):
n, yen = [int(s) for s in input().split()]
yen //= 1000
for x in range(n + 1):
    p_x = 10 * x
    if p_x > yen:
        break
    for y in range(n + 1):
        p_x_y = p_x + 5 * y
        if p_x_y > yen:
            break
        z = n - x - y
        p_x_y_z = p_x_y + z
        if p_x_y_z == yen:
            print(x, y, z)
            exit()
print(-1, -1, -1)

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

ans = [-1,-1,-1]
ck = 0
for i in range(n+1):
  if i * 10000 > x :
    break

  for j in range(n+1-i):

    if i * 10000 + j * 5000 > x :
      break

    k = n - i - j
    if i * 10000 + j * 5000 + k * 1000 == x:
      ans = [i,j,k]
      ck = 1
      break

  if ck :
    break

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

Solution (Python):
a, b , c = -1,-1,-1
n, y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if i+ j > n:
            break
        elif ((y - (i*10000 + j*5000))%1000 == 0) and ((i+j+(y - (i*10000 + j*5000))/1000) == n):
            if (y - (i*10000 + j*5000))/1000 >= 0:
                a,b,c = i, j, int((y - i*10000 - j*5000)/1000)
                break
print(a, b, c)

Solution (Python):

import sys
a=10000
b=5000
c=1000

def check(y, i,j,k):
    if(y == i * a + j * b + k * c):
        print(i,j,k)
        sys.exit(0)

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

for i in range(n,-1,-1):
    for j in range(n-i,-1,-1):
        k = n-i-j
        check(y,i,j,k)

print(-1,-1,-1)

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

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

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

print(-1,-1,-1)

Solution (Python):
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N, Y = LI()
y = 1000 * N
for i in range(N+1):
    for j in range(N-i+1):
        if i * 10000 + 5000 * j + 1000 * (N-i-j) == Y:
            print(i, j, N-i-j)
            exit()
print("-1 -1 -1")

Solution (Python):



import os
import sys







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

    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)
                exit()
    print("-1 -1 -1")
    return


if __name__ == '__main__':
    main()

Solution (Python):



import os
import sys







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

    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)
                exit()
    print("-1 -1 -1")
    return


if __name__ == '__main__':
    main()

Solution (Python):
n, money = (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) == money:
            print(i, j, n-i-j)
            break
    else:
        if i == n:
            print(-1, -1, -1)
            break
        continue
    break

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

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    n,y=map(int,readline().split())

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

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

if __name__=="__main__":
    main()

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

def main():
    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)
                return
    print(-1, -1, -1)

if __name__ == '__main__':
    main()

Solution (Python):
n, y = map(int, input().split())
k = y - 1000*n
count = 0
for i in range(0, 2001):
    for j in range(0, 4001):
        if 9000*i + 4000*j == k and n-i-j >= 0:
            a = i
            b = j
            c = n - i - j
            count = 1
            break
        else:
            pass
if count == 1:
    print(a, b, c)
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')

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

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

import sys
for yukichi in range(n+1):
    for ichiyo in range(n+1):
        if 0 <= n - (yukichi + ichiyo) <= n and n - (yukichi + ichiyo) == (y - (10000 * yukichi + 5000 * ichiyo))/1000:
            print(yukichi, ichiyo, n - yukichi - ichiyo)
            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):
        k=N-i-j
        if 10000*i+5000*j+1000*k == Y:
            print(i,j,k)
            exit()
print('-1 -1 -1')

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

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 = 0
      break
    if not flag:
      break
  if not flag:
    break
  if i == n:
    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):
        if 10000*x + 5000*y + 1000*(N-x-y) == Y:
            print(x, y, N-x-y)
            exit() 
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 1000*(n-i-j)+5000*i+10000*j==y:
            print(j,i,n-i-j)
            exit()
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 1000*(n-i-j)+5000*i+10000*j==y:
            print(j,i,n-i-j)
            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-i):
    if 10000*i+5000*j+1000*(n-i-j)==y and n-i-j>=0:
      print(i,j,n-i-j)
      sys.exit()
print(-1,-1,-1)

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

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

mx = y // 1000

for i in range(mx):
    for j in range(mx-i):
        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 = map(int,input().split())
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if i*10000 + j*5000 + k*1000 == Y and k>=0:
            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):
        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")

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')








def solve():
    N, Y = MI()

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


if __name__ == '__main__':
    solve()

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):
import sys
n,y=map(int,input().split())
t=True
for i in range(n+1):
    for j in range(n+1):
        if ((10000*i+5000*j+1000*(n-i-j))==y) & (i+j<=n):
            t=False
            print(i, j, n-i-j)
            sys.exit(0) 
if t:
    print("-1 -1 -1")

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

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

a = 0
b = 0

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)
            break
        elif a == n:
            print("-1 -1 -1")
    else:
        continue
    break

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

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

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

Solution (Python):
n,Y = map(int,(input().split()))
x = 0
y = 0
z = 0
f = True
for i in range(n+1):
    for j in range(n+1):
        k=Y-i*10000-j*5000
        if k==(n-i-j)*1000 and k>=0:
            x=i
            y=j
            z=int(k/1000)
            f=False
if f :
    x = -1
    y = -1
    z = -1
print(x,y,z)

Solution (Python):
def main():
    m = 10000
    ft = 5000
    ot = 1000

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

    for i in range(N + 1):
        m_count = m * i

        for j in range(N - i + 1):
            ft_count = ft * j
            k = N - i - j
            ot_count = ot * k

            if Y == m_count + ft_count + ot_count:
                print(str(i) + ' ' + str(j) + ' ' + str(k))
                return

    print(str(-1) + ' ' + str(-1) + ' ' + str(-1))
main()

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

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

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

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

print(-1,-1,-1)

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

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n, y = MI()
    y = y // 1000
    result = "-1 -1 -1"
    for i in range(n, -1, -1):
        a = i * 10
        if a <= y:
            for j in range(n-i, -1, -1):
                b = a + j * 5
                if b <= y:
                    if b + (n-i-j) == y:
                        result = str(i)+" "+str(j)+" "+str((n-i-j))
                        print(result)
                        sys.exit()
    print(result)

main()

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

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n, y = MI()
    result = "-1 -1 -1"
    for i in range(n, -1, -1):
        a = i * 10000
        if a <= y:
            for j in range(n-i, -1, -1):
                b = a + j * 5000
                if b <= y:
                    if b + 1000 * (n-i-j) == y:
                        result = str(i)+" "+str(j)+" "+str(n-i-j)
                        print(result)
                        sys.exit()
    print(result)

main()

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

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n, y = MI()
    result = "-1 -1 -1"
    for i in range(n, -1, -1):
        a = i * 10000
        if a <= y:
            for j in range(n-i, -1, -1):
                b = a + j * 5000
                if b <= y:
                    if b + 1000 * (n-i-j) == y:
                        result = str(i)+" "+str(j)+" "+str(n-i-j)
                        print(result)
                        sys.exit()
    print(result)

main()

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(" ".join([str(i), str(j), str(k)]))
            exit(0)
print('-1 -1 -1')

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]




N, Y = mi()
Y /= 1000

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

print(-1, -1, -1)

Solution (Python):

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

def main():
    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):
                print(x,y,z)
                return
    print("-1 -1 -1")


main()

Solution (Python):
a = list(map(int, input().split()))
b = 0
for i in range(a[0] + 1):
  for f in range(a[0] - i + 1):
    if b != 0:
      break
    elif 10000 * i + 5000 * f + 1000 * (a[0] - i - f) == a[1]:
      print(str(i) + " " + str(f) + " " + str(a[0] - i - f))
      b += 1
      break
if b == 0:
  print("-1 -1 -1")

Solution (Python):
import sys

input = sys.stdin.readline

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

result = "-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):
            result = "{} {} {}".format(x, y, z)
            print(result)
            exit()

print(result)

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

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)

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

print(-1,-1,-1)

Solution (Python):
def solve(N, Y):
  res = '-1 -1 -1'
  for i in range(0, N + 1):
    for j in range(0, N + 1):
      if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y and N - i - j >= 0:
        res = '{0} {1} {2}'.format(i, j, N - i - j)
        return res
  return res
N, Y = map(int, input().split(' '))
print(solve(N, Y))

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

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

Solution (Python):


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

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

for xi in range(N+1):
  for yi in range(N+1-xi):
    zi = N -xi -yi
    if xi + 5*yi + 10*zi == Y:
      print(zi, yi, xi)
      exit()
else:
  print(-1, -1, -1)

Solution (Python):


n,y = map(int,input().split())
total = 0
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())

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

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

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

Y //= 1000

noguti = N

y_n = Y - N

if (Y - N < 0):
    print(-1, -1, -1)
elif (Y - N == 0):
    print(0, 0, N)
else:
    yukiti = y_n // 9
    higuti = y_n // 4
    while True:
        if (yukiti < 0):
            print(-1, -1, -1)
            exit()

        if (yukiti + higuti > N):
            higuti -= 1
            continue

        if(9 * yukiti + 4 * higuti == y_n):
            print(yukiti, higuti, N - yukiti - higuti)
            exit()

        if (9 * yukiti + 4 * higuti > y_n and yukiti >= 0):
            higuti -= 1
            if (higuti < 0):
                yukiti -= 1
                higuti = y_n // 4

        elif (9 * yukiti + 4 * higuti < y_n):
            yukiti -= 1
            higuti = y_n // 4

Solution (Python):
import sys
n,y=map(int,input().split())
if n*10000<y:
    print("-1 -1 -1")
    sys.exit()
if y//1000<n:
    print("-1 -1 -1")
    sys.exit()
m=y//10000
for i in range(m+1):
    g=(y-i*10000)//5000
    for j in range(g+1):
        s=(y-10000*i-5000*j)//1000
        if i+j+s==n and s>=0:
            print(i,j,s)
            sys.exit()
print("-1 -1 -1")

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

def otosidama(N,Y):
    for y in range(N+1,-1,-1):
        if y*10000 > Y:
            continue
        for i in range(N+1-y):
            if (N-y-i)*1000 > Y-y*10000:
                break
            else:
                if y*10000 + i*5000 + (N-y-i)*1000 == Y:
                    return y,i,N-y-i
    
    return -1,-1,-1

if Y > N*10000:
    print(-1,-1,-1)
else:
    y,i,h = otosidama(N,Y)
    print(y,i,h)

Solution (Python):
n, y = map(int, input().split())
a = 0
a += (y%5000)//1000
n -= a
y -= a*1000
if n*10000>=y and y>=n*1000:
  if y>= 5000*n:
    m = (y-5000*n)//5000
    print(m,n-m,a)
  else:
    m = y-1000*n+9000
    for i in range(n):
      m -= 9000
      if m < 0:
        print(-1,-1,-1)
        exit(0)
      if m%4000 == 0:
        j = m//4000
        print(i,j,n-i-j+a)
        exit(0)       
else:
  print(-1,-1,-1)

Solution (Python):
n, y = map(int, input().split())
a = 0
a += (y%5000)//1000
n -= a
y -= a*1000
if n*10000>=y and y>=n*1000:
  if y>= 5000*n:
    m = (y-5000*n)//5000
    print(m,n-m,a)
  else:
    m = y-1000*n+9000
    for i in range(n):
      m -= 9000
      if m < 0:
        print(-1,-1,-1)
        exit(0)
      if m%4000 == 0:
        j = m//4000
        print(i,j,n-i-j+a)
        exit(0)
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):
        a = i
        b = j
        c = N - i - j
        if a*10000 + b*5000 + c*1000 == Y:
            print(a, b, c)
            exit()

print(-1, -1, -1)

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

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

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

print('-1 -1 -1')

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

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

print('-1 -1 -1')

Solution (Python):
N, Y = map(int, input().split())
L = Y // 1000 - N
H = L * 7 % 9
F = (L - 4 * H) // 9
if F < 0 or H + F > N:
    print("-1 -1 -1")
else:
    print("{} {} {}".format(F, H, N - F - H))

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

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

for yukiti in range(0, 1 + (y // 10000)):
  for higuti in range(0, 1 + (y - 10000 * yukiti) // 5000):
    noguti = (y - 10000 * yukiti - 5000 * higuti) // 1000
    paper = yukiti + higuti + noguti 
    
    if paper == n:
      print("{0} {1} {2}".format(yukiti, higuti, noguti))
      exit(0)

print("-1 -1 -1")

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

il = y // 10000
jl = y // 5000

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

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

p=[]

for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            p.append([i,j,n-i-j])

if p==[]:
    print("-1 -1 -1")
else:
    print(p[0][0],p[0][1],p[0][2])

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

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

    print(-1, -1, -1)


if __name__ == "__main__":
    main()

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

money = money // 1000

for i_1 in range(n+1):
  for j_5 in range(n - i_1 + 1):
    if (money - i_1 - j_5 * 5) == 10 * (n - i_1 - j_5):
      flag = True
      ans = [i_1, j_5, n - i_1 - j_5]
      
  if flag:
    break

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

Solution (Python):
import sys

num = sys.stdin.readline().split(' ')
N = int(num[0])
Y = int(num[1])


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

print('-1 -1 -1')

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

sign = 0
ans = [y//10000,0,0]
y = y - 10000*ans[0]
n = n - ans[0]
ans[1] = y//5000
y = y - 5000*ans[1]
n = n - ans[1]
ans[2] = y//1000
y = y - 1000*ans[2]
n = n - ans[2]

if (y != 0) or (n < 0):
  sign = 1

if n <= 3:
  if ans[0] < n:
    sign = 1
  else:
    ans[0] -= n
    ans[1] += 2*n
else:
  temp = n%4
  if ans[0]-temp < 0:
    sign = 1
  else:
    temp_1 = temp + 4*min((ans[0]-temp)//4,(n-temp)//4)
    ans[1] +=temp_1*2
    ans[0] -= temp_1
    n -= temp_1

judge = n//4
if ans[1] < judge:
  sign = 1
else:
  ans[1] -= judge
  ans[2] += judge*5
  
if sign == 1:
  print("-1 -1 -1")
else:
  print(ans[0],ans[1],ans[2])

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

print(*ans)

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)

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

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 a in range(n + 1):
    for b in range(n + 1):
        c = n - (a+b)
        if 10000*a + 5000*b + 1000*c == y and c>=0:

                print(a,b,c)
                exit()
print(-1,-1,-1)