Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
flag=0
for i in range(0, N+1):
    if output_flag==1:
        break
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            output_flag=1
            man = i
            gosen = j
            sen = k
            break
print(man, gosen, sen)

Fixed submission:
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            man = i
            gosen = j
            sen = k
print(man, gosen, sen)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
# i: man, j: gosen, k: sen
output_flag=0
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    while output_flag==0:
        for j in range(0, N+1-i):
            k = N-i-j
            total = 10000*i+5000*j+1000*k
            if total==Y:
                output_flag=1
                man = i
                gosen = j
                sen = k
                break
    if output_flag==1:
        break
print(man, gosen, sen)

Fixed submission:
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            man = i
            gosen = j
            sen = k
print(man, gosen, sen)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
# i: man, j: gosen, k: sen
output_flag=0
for i in range(0, N+1):
    while output_flag==0:
        for j in range(0, N+1-i):
            k = N-i-j
            if 10000*i+5000*j+1000*k==Y:
                print(i, j, k)
                output_flag=1
                break
    if output_flag==1:
        break
if output_flag==0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            man = i
            gosen = j
            sen = k
print(man, gosen, sen)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
# i: man, j: gosen, k: sen
output_flag=0
for i in range(0, N+1):
    while output_flag==0:
        for j in range(0, N+1-i):
            k = N-i-j
            if 10000*i+5000*j+1000*k==Y:
                print(i, j, k)
                not_output_flag=1
                break
    if output_flag==1:
        break
if output_flag==0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            man = i
            gosen = j
            sen = k
print(man, gosen, sen)

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
# i: man, j: gosen, k: sen
output_flag=0
for i in range(0, N+1):
    if output_flag==0:
        for j in range(0, N+1-i):
            k = N-i-j
            if 10000*i+5000*j+1000*k==Y:
                print(i, j, k)
                not_output_flag=1
                break
    else:
        break
if not_output_flag==0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            man = i
            gosen = j
            sen = k
print(man, gosen, sen)