Buggy python submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(i, j, YY3)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    exit()

Fixed submission:
N,Y=map(int,input().split())
flag=False
for i in range(N+1):
    if flag==True:
        break
    else:
        pass
    for j in range(N+1-i):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    pass

Buggy python submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(i, j, YY3)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    exit

Fixed submission:
N,Y=map(int,input().split())
flag=False
for i in range(N+1):
    if flag==True:
        break
    else:
        pass
    for j in range(N+1-i):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    pass

Buggy python submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(str(i),"",str(j),"",str(YY3))
            flag=True
            break
        else:
            continue
if flag==False:
    print(str(-1),"",str(-1),"",str(-1) )
else:
    exit


Fixed submission:
N,Y=map(int,input().split())
flag=False
for i in range(N+1):
    if flag==True:
        break
    else:
        pass
    for j in range(N+1-i):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    pass

Buggy python submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(str(i),str(j),str(YY3))
            flag=True
            break
        else:
            continue
if flag==False:
    print(str(-1),str(-1),str(-1) )
else:
    exit

Fixed submission:
N,Y=map(int,input().split())
flag=False
for i in range(N+1):
    if flag==True:
        break
    else:
        pass
    for j in range(N+1-i):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    pass