Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int,input().split())
t = Y//1000
counter = 0
if counter==0:
    for i in range(t//10+1):
        if counter==0:   
            for j in range(t//5+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int,input().split())
t = Y//1000
counter = 0
if counter==0:
    for i in range(t+1):
        if counter==0:   
            for j in range(t+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int,input().split())
t = Y//1000
counter = 0
if counter==0:
    for i in range(t//10+1):
        if counter==0:   
            for j in range(t//5+1):
                if counter==0:
                    for k in range(t+1):
                        if (10000*i+5000*j+1000*k)==Y and (i+j+k)==N and counter == 0:
                            counter+=1
                            print(i, j, k)
                            break
if counter == 0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int,input().split())
t = Y//1000+1
counter = 0
if counter==0:
    
    for i in range(t):
        if counter==0:
        
            for j in range(t):
                if counter==0:
                    for k in range(t):
                        if (10000*i+5000*j+1000*k)==Y and (i+j+k)==N and counter == 0:
                            counter+=1
                            print(i, j, k)
                            break

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

Fixed submission:
N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int,input().split())
t = Y//1000+1
counter = 0
for i in range(t):
    for j in range(t):
        for k in range(t):
            if (10000*i+5000*j+1000*k)==Y and (i+j+k)==N and counter == 0:
                counter+=1
                print(i, j, k)
            
if counter == 0:
    print(-1, -1, -1)

Fixed submission:
N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)