Buggy python submission (verdict: Time Limit Exceeded):
# 2019/04/29
# AtCoder Beginner Contest 085 - C

# Input
n, y = map(int,input().split())

cashl = [10000, 5000, 1000]
ansl = [-1, -1, -1]
eflg = False

# Search AC and make Accumed sum
for i in range(n+1):
    for j in range(n+1):
        if i + j > n:
            break
        
        subt = i * cashl[0] + j * cashl[1]
        k = int((y - subt) / 1000)

        total = i * cashl[0] + j * cashl[1] + k * cashl[2]
        bcnt = i + j + k

        if total == y and bcnt == n:
            ansl[0] = i
            ansl[1] = j
            ansl[2] = k
            eflg = True
            break

    if eflg == True:
        break

# Output
print(ansl[0], ansl[1], ansl[2])


Fixed submission:
# 2019/04/29
# AtCoder Beginner Contest 085 - C

# Input
n, y = map(int,input().split())

cashl = [10000, 5000, 1000]
ansl = [-1, -1, -1]
eflg = False

# Search AC and make Accumed sum
for i in range(n+1):
    for j in range((n+1)-i):
        subt = i * cashl[0] + j * cashl[1]
        k = int((y - subt) / 1000)

        total = subt + k * cashl[2]
        bcnt = i + j + k

        if total == y and bcnt == n:
            ansl[0] = i
            ansl[1] = j
            ansl[2] = k
            eflg = True
            break

    if eflg == True:
        break

# Output
print(ansl[0], ansl[1], ansl[2])

Buggy python submission (verdict: Time Limit Exceeded):
# 2019/04/29
# AtCoder Beginner Contest 085 - C

# Input
n, y = map(int,input().split())

cashl = [1000, 5000, 10000]
ansl = [-1, -1, -1]
eflg = False

# Search AC and make Accumed sum
for i in range(n+1):
    for j in range(0, n+1):
        if i + j > n:
            break
        
        subt = i * cashl[0] + j * cashl[1]
        st = int((y - subt) / 10000)
        
        for k in range(st, n+1):
            total = i * cashl[0] + j * cashl[1] + k * cashl[2]
            bcnt = i + j + k
            if bcnt > n or total > y:
                break
            if total == y and bcnt == n:
                ansl[0] = i
                ansl[1] = j
                ansl[2] = k
                eflg = True
                break
        if eflg == True:
            break
    if eflg == True:
        break

# Output
print(ansl[2], ansl[1], ansl[0])


Fixed submission:
# 2019/04/29
# AtCoder Beginner Contest 085 - C

# Input
n, y = map(int,input().split())

cashl = [10000, 5000, 1000]
ansl = [-1, -1, -1]
eflg = False

# Search AC and make Accumed sum
for i in range(n+1):
    for j in range((n+1)-i):
        subt = i * cashl[0] + j * cashl[1]
        k = int((y - subt) / 1000)

        total = subt + k * cashl[2]
        bcnt = i + j + k

        if total == y and bcnt == n:
            ansl[0] = i
            ansl[1] = j
            ansl[2] = k
            eflg = True
            break

    if eflg == True:
        break

# Output
print(ansl[0], ansl[1], ansl[2])

Buggy python submission (verdict: Time Limit Exceeded):
# 2019/04/29
# AtCoder Beginner Contest 085 - C

# Input
n, y = map(int,input().split())

cashl = [1000, 5000, 10000]
ansl = [-1, -1, -1]
eflg = False

# Search AC and make Accumed sum
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            total = i * cashl[0] + j * cashl[1] + k * cashl[2]
            bcnt = i + j + k
            if bcnt > n or total > y:
                break
            if total == y and bcnt == n:
                ansl[0] = i
                ansl[1] = j
                ansl[2] = k
                eflg = True
                break
        if eflg == True:
            break
    if eflg == True:
        break

# Output
print(ansl[2], ansl[1], ansl[0])


Fixed submission:
# 2019/04/29
# AtCoder Beginner Contest 085 - C

# Input
n, y = map(int,input().split())

cashl = [10000, 5000, 1000]
ansl = [-1, -1, -1]
eflg = False

# Search AC and make Accumed sum
for i in range(n+1):
    for j in range((n+1)-i):
        subt = i * cashl[0] + j * cashl[1]
        k = int((y - subt) / 1000)

        total = subt + k * cashl[2]
        bcnt = i + j + k

        if total == y and bcnt == n:
            ansl[0] = i
            ansl[1] = j
            ansl[2] = k
            eflg = True
            break

    if eflg == True:
        break

# Output
print(ansl[0], ansl[1], ansl[2])