Buggy python submission (verdict: Time Limit Exceeded):
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

i_max = min(n,y//10000)
for i in range(i_max,-1,-1):
    left = y - 10000*i
    
    j_max = min(n-i,left//5000)
    for j in range(j_max,-1,-1):
        left = y - 10000*i - 5000*j
        
        k_max = min(n-i-j,left//1000)
        for k in range(k_max,-1,-1):
            left = y - 10000*i - 5000*j - 1000*k
            if left == 0:
                if i+j+k == n:
                    print (i,j,k)
                    sys.exit()

print (-1,-1,-1)

Fixed submission:
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

i_max = min(n,y//10000)
for i in range(i_max,-1,-1):
    left = y - 10000*i
    
    j_max = min(n-i,left//5000)
    for j in range(j_max,-1,-1):
        left = y - 10000*i - 5000*j
        
        k = left // 1000
        if i+j+k == n:
            print (i,j,k)
            sys.exit()

print (-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

for i in range(min(n,y//10000),-1,-1):
    left = y - 10000*i
    
    for j in range(min(n-i,left//5000),-1,-1):
        left = y - 10000*i - 5000*j
        
        for k in range(min(n-i-j,left//1000),-1,-1):
            left = y - 10000*i - 5000*j - 1000*k
            if left == 0:
                if i+j+k == n:
                    print (i,j,k)
                    sys.exit()

print (-1,-1,-1)

Fixed submission:
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

i_max = min(n,y//10000)
for i in range(i_max,-1,-1):
    left = y - 10000*i
    
    j_max = min(n-i,left//5000)
    for j in range(j_max,-1,-1):
        left = y - 10000*i - 5000*j
        
        k = left // 1000
        if i+j+k == n:
            print (i,j,k)
            sys.exit()

print (-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

for i in range(y//10000,-1,-1):
    left = y - 10000*i
    
    for j in range(left//5000,-1,-1):
        left = y - 10000*i - 5000*j
        
        for k in range(left//1000,-1,-1):
            left = y - 10000*i - 5000*j - 1000*k
            if left == 0:
                if i+j+k == n:
                    print (i,j,k)
                    sys.exit()

print (-1,-1,-1)

Fixed submission:
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

i_max = min(n,y//10000)
for i in range(i_max,-1,-1):
    left = y - 10000*i
    
    j_max = min(n-i,left//5000)
    for j in range(j_max,-1,-1):
        left = y - 10000*i - 5000*j
        
        k = left // 1000
        if i+j+k == n:
            print (i,j,k)
            sys.exit()

print (-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

for i in range(y//10000,-1,-1):
    left = y - 10000*i
    
    for j in range(left//5000,-1,-1):
        left = y - 10000*i - 5000*j
        
        for k in range(left//1000,-1,-1):
            left = y - 10000*i - 5000*j - 1000*k
            if left == 0:
                if i+j+k == n:
                    print (i,j,k)
                    sys.exit()

print (-1,-1,-1)

Fixed submission:
import sys

(str_n,str_y) = input().split()
n = int(str_n)
y = int(str_y)

if y % 1000 != 0:
    print (-1,-1,-1)
    sys.exit()

i_max = min(n,y//10000)
for i in range(i_max,-1,-1):
    left = y - 10000*i
    
    j_max = min(n-i,left//5000)
    for j in range(j_max,-1,-1):
        left = y - 10000*i - 5000*j
        
        k = left // 1000
        if i+j+k == n:
            print (i,j,k)
            sys.exit()

print (-1,-1,-1)