Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())

flag = True
def f(x_1,x_2):
    global flag
    x_3 = int((Y - 10000*x_1 - 5000*x_2) / 1000)
    if x_1 + x_2 + x_3 == N:
        print(str(x_1) + " " + str(x_2) + " " + str(x_3))
        flag = False

for i in range(Y // 10000 + 1):
    spliting = i + int((Y - 10000*i) / 2 // 5000)
    
    if spliting <= N:
        for k in range(spliting + 1):
            f(i,k)
            if flag == False:
                break
    else:
        for k in range(spliting , (Y - 10000*a) // 5000 + 1):
            f(i,k)
            if flag == False:
                break
    if flag == False:
        break
    
if flag:
    print("-1 -1 -1")

Fixed submission:
N, Y = map(int, input().split())

flag = True

for i in range(Y // 10000 + 1):
    for k in range((Y - 10000*i) // 5000 + 1):
        l = int((Y - 10000*i - 5000*k) / 1000)
        if (i + k + l) == N:
            print(str(i) + " " + str(k) + " " + str(l))
            flag = False
            break
    if flag == False:
        break
if flag:
    print("-1 -1 -1")

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())

flag = True
def f(x_1,x_2):
    global flag
    x_3 = int((Y - 10000*x_1 - 5000*x_2) / 1000)
    if x_1 + x_2 + x_3 == N:
        print(str(x_1) + " " + str(x_2) + " " + str(x_3))
        flag = False

for i in range(Y // 10000 + 1):
    spliting = int((Y - 10000*i) / 2 // 5000)
    
    if spliting <= N:
        for k in range(spliting + 1):
            f(i,k)
            if flag == False:
                break
    else:
        for k in range(spliting , (Y - 10000*a) // 5000 + 1):
            f(i,k)
            if flag == False:
                break
    if flag == False:
        break
    
if flag:
    print("-1 -1 -1")

Fixed submission:
N, Y = map(int, input().split())

flag = True

for i in range(Y // 10000 + 1):
    for k in range((Y - 10000*i) // 5000 + 1):
        l = int((Y - 10000*i - 5000*k) / 1000)
        if (i + k + l) == N:
            print(str(i) + " " + str(k) + " " + str(l))
            flag = False
            break
    if flag == False:
        break
if flag:
    print("-1 -1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy

N , Y = map(int, input().split())
conc = True
a_ = Y // 10000
for i in range(a_ + 1):
	a = i
	b_ = (Y - 10000*a) // 5000
	for k in range(b_ + 1):
		b = k
		if ((Y - 10000*a - 5000*b) % 1000) == 0:
			c = int((Y - 10000*a - 5000*b) / 1000)
			if (a + b + c) == N:
				print(str(a) +" "+ str(b) + " " + str(c))
				conc = False
				break
	if conc == False:
		break
if conc:
	print("-1 -1 -1")

Fixed submission:
N, Y = map(int, input().split())

flag = True

for i in range(Y // 10000 + 1):
    for k in range((Y - 10000*i) // 5000 + 1):
        l = int((Y - 10000*i - 5000*k) / 1000)
        if (i + k + l) == N:
            print(str(i) + " " + str(k) + " " + str(l))
            flag = False
            break
    if flag == False:
        break
if flag:
    print("-1 -1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy

N , Y = map(int, input().split())
conc = True
a_ = Y // 10000
for i in range(a_ + 1):
	a = i
	b_ = (Y - 10000*a) // 5000
	for k in range(b_ + 1):
		b = k
		if ((Y - 10000*a - 5000*b) % 1000) == 0:
			c = int((Y - 10000*a - 5000*b) / 1000)
			if conc:
				if (a + b + c) == N:
					print(str(a) +" "+ str(b) + " " + str(c))
					conc = False
if conc:
	print("-1 -1 -1")

Fixed submission:
N, Y = map(int, input().split())

flag = True

for i in range(Y // 10000 + 1):
    for k in range((Y - 10000*i) // 5000 + 1):
        l = int((Y - 10000*i - 5000*k) / 1000)
        if (i + k + l) == N:
            print(str(i) + " " + str(k) + " " + str(l))
            flag = False
            break
    if flag == False:
        break
if flag:
    print("-1 -1 -1")