Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(0, n+1):
  for j in range(0, n+1-i):
	k = n - (i + j)
	sum_price = 10000*i + 5000*j + 1000*k
	if n == i + j + k and sum_price == y:
		print(i, j, k)
		exit()
print(-1, -1, -1)

Fixed submission:
if __name__ == '__main__':
    one_thousand, five_thousand, ten_thousand = 1000, 5000, 10000
    n, y = map(int, input().split())
    ans = []
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            one = one_thousand * i
            five = five_thousand * j
            ten = ten_thousand * k
            sum_price = one + five + ten
            if k >= 0 and n == i + j + k and sum_price == y:
                ans.append([k, j, i])
                break
        if ans != []:
            print(ans[0][0], ans[0][1], ans[0][2])
            break
    if ans == []:
        print(-1, -1, -1)

Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(0, n+1):
	for j in range(0, n+1-i):
        k = n - (i + j)
        sum_price = 10000*i + 5000*j + 1000*k
        if n == i + j + k and sum_price == y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Fixed submission:
if __name__ == '__main__':
    one_thousand, five_thousand, ten_thousand = 1000, 5000, 10000
    n, y = map(int, input().split())
    ans = []
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            one = one_thousand * i
            five = five_thousand * j
            ten = ten_thousand * k
            sum_price = one + five + ten
            if k >= 0 and n == i + j + k and sum_price == y:
                ans.append([k, j, i])
                break
        if ans != []:
            print(ans[0][0], ans[0][1], ans[0][2])
            break
    if ans == []:
        print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    one_thousand, five_thousand, ten_thousand = 1000, 5000, 10000
    n, y = map(int, input().split())
    ans = []
    for i in range(0, n+1):
        for j in range(0, n+1):
            k = n - (i + j)
            one = one_thousand * i
            five = five_thousand * j
            ten = ten_thousand * k
            sum_price = one + five + ten
            if k >= 0 and n == i + j + k and sum_price == y:
                ans.append([k, j, i])
                break
        if ans != []:
            print(ans[0][0], ans[0][1], ans[0][2])
            break
    if ans == []:
        print(-1, -1, -1)


Fixed submission:
if __name__ == '__main__':
    one_thousand, five_thousand, ten_thousand = 1000, 5000, 10000
    n, y = map(int, input().split())
    ans = []
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            one = one_thousand * i
            five = five_thousand * j
            ten = ten_thousand * k
            sum_price = one + five + ten
            if k >= 0 and n == i + j + k and sum_price == y:
                ans.append([k, j, i])
                break
        if ans != []:
            print(ans[0][0], ans[0][1], ans[0][2])
            break
    if ans == []:
        print(-1, -1, -1)