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

flag=0
for x in range(N+1):
	for y in range(N+1):
		z = N -(x + y)
		if 0<=z<=N and en_sum==Y:
			en_sum = 10000*x + 5000*y + 1000*z
			print(x, y, z)
			flag+=1
		break

if flag==0:
	print(-1, -1, -1)

Fixed submission:
#入力
N, Y = map(int, input().split())


#総当たりで合計金額を算出
x = []
y = []
z = []

for num_ten_thousand in range(0, N+1):
    for num_five_thousand in range(0, N+1):
            
            #千円の枚数を算出
            if N-(num_ten_thousand+num_five_thousand)>=0:
                num_one_thousand = N-(num_ten_thousand+num_five_thousand)
            
            #合計金額を算出
            total = num_ten_thousand*10000 + num_five_thousand*5000 + num_one_thousand*1000
            
            #（合計金額がYと等しいか・合計枚数がNと等しいか）を確認し答えをリストに格納
            if Y==total and N==num_ten_thousand+num_five_thousand+num_one_thousand:
                x.append(num_ten_thousand)
                y.append(num_five_thousand)
                z.append(num_one_thousand)
                
                
#答えを出力
if not x:
    print(-1, -1, -1, sep=" ")
    
else:
    print(x[0], y[0], z[0], sep=" ")

Buggy python submission (verdict: Time Limit Exceeded):
#入力
N, Y = map(int, input().split())


#総当たりで合計金額を算出
x = []
y = []
z = []

for num_ten_thousand in range(0, N+1):
    for num_five_thousand in range(0, N+1):
        for num_one_thousand in range(0, N+1):
            
            #合計金額を算出
            total = num_ten_thousand*10000 + num_five_thousand*5000 + num_one_thousand*1000
            
            #（合計金額がYと等しいか・合計枚数がNと等しいか）を確認し答えをリストに格納
            if Y==total and N==num_ten_thousand+num_five_thousand+num_one_thousand:
                x.append(num_ten_thousand)
                y.append(num_five_thousand)
                z.append(num_one_thousand)
                
                
#答えを出力
if not x:
    print(-1, -1, -1, sep=" ")
    
else:
    print(x[0], y[0], z[0], sep=" ")

Fixed submission:
#入力
N, Y = map(int, input().split())


#総当たりで合計金額を算出
x = []
y = []
z = []

for num_ten_thousand in range(0, N+1):
    for num_five_thousand in range(0, N+1):
            
            #千円の枚数を算出
            if N-(num_ten_thousand+num_five_thousand)>=0:
                num_one_thousand = N-(num_ten_thousand+num_five_thousand)
            
            #合計金額を算出
            total = num_ten_thousand*10000 + num_five_thousand*5000 + num_one_thousand*1000
            
            #（合計金額がYと等しいか・合計枚数がNと等しいか）を確認し答えをリストに格納
            if Y==total and N==num_ten_thousand+num_five_thousand+num_one_thousand:
                x.append(num_ten_thousand)
                y.append(num_five_thousand)
                z.append(num_one_thousand)
                
                
#答えを出力
if not x:
    print(-1, -1, -1, sep=" ")
    
else:
    print(x[0], y[0], z[0], sep=" ")

Buggy python submission (verdict: Runtime Error):
#入力
N = int(input())
Y = int(input())


#一万円の枚数を算出
if int(Y/10000)>0:
    x = int(Y/10000)
    
else:
    x = 0
    
    
#五千円の枚数を算出

#お年玉から万の位を除いた値
under_tenthousand = Y-x*10000

if int(under_tenthousand/5000)>0:
    y = int(under_tenthousand/5000)
    
else:
    y = 0
    
    
#千円の枚数を算出

#この時点でお年玉は五千円未満となっている
under_fivethousand = under_tenthousand-y*5000

if (under_fivethousand/1000)>0:
    z = under_fivethousand/1000
    
else:
    z = 0
    
    
#合計枚数の確認
if N==x+y+z:
    print(x, y, z, sep=" ")
    
else:
    print(-1, -1, -1, sep=" ")

Fixed submission:
#入力
N, Y = map(int, input().split())


#総当たりで合計金額を算出
x = []
y = []
z = []

for num_ten_thousand in range(0, N+1):
    for num_five_thousand in range(0, N+1):
            
            #千円の枚数を算出
            if N-(num_ten_thousand+num_five_thousand)>=0:
                num_one_thousand = N-(num_ten_thousand+num_five_thousand)
            
            #合計金額を算出
            total = num_ten_thousand*10000 + num_five_thousand*5000 + num_one_thousand*1000
            
            #（合計金額がYと等しいか・合計枚数がNと等しいか）を確認し答えをリストに格納
            if Y==total and N==num_ten_thousand+num_five_thousand+num_one_thousand:
                x.append(num_ten_thousand)
                y.append(num_five_thousand)
                z.append(num_one_thousand)
                
                
#答えを出力
if not x:
    print(-1, -1, -1, sep=" ")
    
else:
    print(x[0], y[0], z[0], sep=" ")