Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        x = 100 * (a * A + b * B)
        for c in range((x // 100 * E) // C + 1):
            for d in range(((x // 100 * E) - c) // D + 1):
                y = c * C + d * D
                if x + y > F or y > x * E // 100:
                    break
                if x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

if ans_A == 0:
    print(100 * A, 0)
else:
    print(ans_A, ans_B)


Fixed submission:
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        x = 100 * (a * A + b * B)
        if x > F:
            break
        for c in range((x // 100 * E) // C + 1):
            for d in range(((x // 100 * E) - c) // D + 1):
                y = c * C + d * D
                if x + y > F or y > x * E // 100:
                    break
                if x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

if ans_A == 0:
    print(100 * A, 0)
else:
    print(ans_A, ans_B)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        x = 100 * (a * A + b * B)
        for c in range((x // 100 * E) // C + 1):
            for d in range((x // 100 * E) // D + 1):
                y = c * C + d * D
                if x + y > F or y > x * E // 100:
                    break
                if x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

if ans_A == 0:
    print(100 * A, 0)
else:
    print(ans_A, ans_B)


Fixed submission:
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        x = 100 * (a * A + b * B)
        if x > F:
            break
        for c in range((x // 100 * E) // C + 1):
            for d in range(((x // 100 * E) - c) // D + 1):
                y = c * C + d * D
                if x + y > F or y > x * E // 100:
                    break
                if x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

if ans_A == 0:
    print(100 * A, 0)
else:
    print(ans_A, ans_B)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                x = 100 * (a * A + b * B)
                y = c * C + d * D
                if x + y <= F and y <= x * E // 100 and x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

print(ans_A, ans_B)


Fixed submission:
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        x = 100 * (a * A + b * B)
        if x > F:
            break
        for c in range((x // 100 * E) // C + 1):
            for d in range(((x // 100 * E) - c) // D + 1):
                y = c * C + d * D
                if x + y > F or y > x * E // 100:
                    break
                if x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

if ans_A == 0:
    print(100 * A, 0)
else:
    print(ans_A, ans_B)