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

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000

if man_max > N:
    man_max = N
if go_max > N:
    go_max = N
if sen_max > N:
    sen_max = N


if Y%10000 == 0 and Y//10000 ==N:
     print(str(N) + " " +"0 0")
     sys.exit()
if Y%5000 == 0 and Y//5000 ==N:
     print("0 " + str(N) +" 0")
     sys.exit()
if Y%1000 == 0 and Y//1000 ==N:
     print("0 0 " + str(N))
     sys.exit()

for k in range(man_max+1):
    for j in range(go_max+1):
        for i in range(sen_max+1):
            if (10000*k + 5000*j + 1000*i == Y):
                if i+j+k == N:
                    print(str(k)+" "+str(j) + " " + str(i))
                    sys.exit()
            elif(10000*k + 5000*j + 1000*i > Y):


print("-1 -1 -1")

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

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000


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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Y = map(int,input().split(" "))

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000

if man_max > N:
    man_max = N
if go_max > N:
    go_max = N
if sen_max > N:
    sen_max = N

for i in range(sen_max+1):
    for j in range(go_max+1):
        for k in range(man_max+1):
            if (10000*k + 5000*j + 1000*i == Y):
                if i+j+k == N:
                    print(str(k)+" "+str(j) + " " + str(i))
                    sys.exit()

print("-1 -1 -1")

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

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000


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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Y = map(int,input().split(" "))

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000

if man_max > N:
    man_max = N
if go_max > N:
    go_max = N
if sen_max > N:
    sen_max = N

for k in range(man_max+1):
    for j in range(go_max+1):
        for i in range(sen_max+1):
            if (10000*k + 5000*j + 1000*i == Y):
                if i+j+k == N:
                    print(str(k)+" "+str(j) + " " + str(i))
                    sys.exit()

print("-1 -1 -1")

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

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000


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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Y = map(int,input().split(" "))

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000

if man_max > N:
    man_max = N
if go_max > N:
    go_max = N
if sen_max > N:
    sen_max = N

for k in range(man_max+1):
    for j in range(go_max+1):
        for i in range(sen_max+1):
            if (10000*k + 5000*j + 1000*i == Y):
                if i+j+k == N:
                    print(str(k)+" "+str(j) + " " + str(i))
                    sys.exit()

print("-1 -1 -1")

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

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000


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