Buggy python submission (verdict: Time Limit Exceeded):
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))


Fixed submission:
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1-i):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))

Buggy python submission (verdict: Time Limit Exceeded):
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        if mass==0:
            break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))


Fixed submission:
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1-i):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))

Buggy python submission (verdict: Time Limit Exceeded):
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    mass=0
                    break
    if sum(bill)==number:
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))


Fixed submission:
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1-i):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))

Buggy python submission (verdict: Time Limit Exceeded):
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    mass=0
                    break
    if sum(bill)==number:
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))

Fixed submission:
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1-i):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))