Buggy python submission (verdict: Time Limit Exceeded):
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

num_max_10k = total // 10000
num_max_5k = total // 5000
num_max_1k = total // 1000

for num_10k in range (num_max_10k + 1):
    for num_5k in range(num_max_5k + 1):
        if (num_10k + num_5k >= n):
            num_1k = 0
        else:
            num_1k = n - (num_10k + num_5k)

        if (total == (num_10k * 10000 + num_5k * 5000 + num_1k * 1000)
            and n == (num_10k + num_5k + num_1k)):
            x, y, z = num_10k, num_5k, num_1k

print(x, y, z, sep=" ")


Fixed submission:
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

for x_tmp in range(0, n + 1):
    for y_tmp in range(0, (n - x_tmp) + 1):
        z_tmp = n - (x_tmp + y_tmp) if n >= (x_tmp + y_tmp) else 0
        if total == (x_tmp * 10000 + y_tmp * 5000 + z_tmp * 1000):
            x, y, z = x_tmp, y_tmp, z_tmp

print(x, y, z, sep = " ")

Buggy python submission (verdict: Runtime Error):
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

num_max_10k = total // 10000
num_max_5k = total // 5000
num_max_1k = total // 1000

for num_10k in range (num_max_10k + 1):
    for num_5k in range(num_max_5k + 1):
        if (num_10k + num_5k >= n):
            num_1k = 0
        else:
            num_1k = n - (num_10k + num_5k)

        #print(num_10k, num_5k, num_1k, sep=" ")
        if (total == (sum_10k * 10000 + sum_5k * 5000 + sum_1k * 1000)
            and n == (num_10k + num_5k + num_1k)):
            x, y, z = num_10k, num_5k, num_1k

print(x, y, z, sep=" ")


Fixed submission:
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

for x_tmp in range(0, n + 1):
    for y_tmp in range(0, (n - x_tmp) + 1):
        z_tmp = n - (x_tmp + y_tmp) if n >= (x_tmp + y_tmp) else 0
        if total == (x_tmp * 10000 + y_tmp * 5000 + z_tmp * 1000):
            x, y, z = x_tmp, y_tmp, z_tmp

print(x, y, z, sep = " ")

Buggy python submission (verdict: Time Limit Exceeded):
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

num_max_10k = total // 10000
num_max_5k = total // 5000
num_max_1k = total // 1000

for num_10k in range (num_max_10k + 1):
    sum_10k = num_10k * 10000
    for num_5k in range(num_max_5k + 1):
        sum_5k = num_5k * 5000
        if (num_10k + num_5k >= n):
            num_1k = 0
        else:
            num_1k = n - (num_10k + num_5k)
        sum_1k = num_1k * 1000

        #print(num_10k, num_5k, num_1k, sep=" ")
        if (total == (sum_10k + sum_5k + sum_1k)
            and n == (num_10k + num_5k + num_1k)):
            x, y, z = num_10k, num_5k, num_1k

print(x, y, z, sep=" ")


Fixed submission:
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

for x_tmp in range(0, n + 1):
    for y_tmp in range(0, (n - x_tmp) + 1):
        z_tmp = n - (x_tmp + y_tmp) if n >= (x_tmp + y_tmp) else 0
        if total == (x_tmp * 10000 + y_tmp * 5000 + z_tmp * 1000):
            x, y, z = x_tmp, y_tmp, z_tmp

print(x, y, z, sep = " ")

Buggy python submission (verdict: Time Limit Exceeded):
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

num_max_10k = total // 10000
num_max_5k = total // 5000
num_max_1k = total // 1000

for num_10k in range (num_max_10k + 1):
    sum_10k = num_10k * 10000
    for num_5k in range(num_max_5k + 1):
        sum_5k = num_5k * 5000
        if (num_10k + num_5k >= n):
            num_1k = 0
        else:
            num_1k = n - (num_10k + num_5k)
        sum_1k = num_1k * 1000

        #print(num_10k, num_5k, num_1k, sep=" ")
        if (total == (sum_10k + sum_5k + sum_1k)
            and n == (num_10k + num_5k + num_1k)):
            x, y, z = num_10k, num_5k, num_1k
            break
    else:
        continue
    break

print(x, y, z, sep=" ")


Fixed submission:
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

for x_tmp in range(0, n + 1):
    for y_tmp in range(0, (n - x_tmp) + 1):
        z_tmp = n - (x_tmp + y_tmp) if n >= (x_tmp + y_tmp) else 0
        if total == (x_tmp * 10000 + y_tmp * 5000 + z_tmp * 1000):
            x, y, z = x_tmp, y_tmp, z_tmp

print(x, y, z, sep = " ")