Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = list(map(int, input().split()))

def G(a, b):
  while b > 0:
    a, b = b, a%b
  return a
def L(a, b):
  return a * b // G(a, b)

caps = {(N * 100 * A + M * 100 * B) for N in range(1 + F // (100 * A)) for M in range(1 + (F - N * 100 * A) // (100 * B))}

res = [0,0,0]
for water in caps:
    if water == 0: continue
    capp = min(F - water, E * water // 100)
    resug = capp % L(C, D)  
    cosug = capp - resug
    sugers = [(N * C + M * D + cosug) for N in range(resug // C + 1) for M in range((resug - N * C)//D + 1)]
    suger = max(sugers)
    ratio = suger / (water + suger)
    if res[0] < ratio: res = [ratio, suger + watter, suger] 


print(res[1], res[2])    


Fixed submission:

import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    A, B, C, D, E, F = read_values()
    W = set()
    
    for a in range(F // (A * 100) + 1):
        for b in range(F // (B * 100) + 1):
            w = a * 100 * A + b * 100 * B
            if 0 < w <= F:
                W.add(w)

    S = set()
    for c in range(F // C + 1):
        for d in range(F // D + 1):
            s = c * C + d * D
            if 0 <= s <= F:
                S.add(s)
    S = sorted(list(S))
    
    s, t = 0, 100 * A
    for w in W:
        p = min(F - w, math.ceil(E * w / 100))
        f = S[bisect.bisect_right(S, p) - 1]
        if f * 100 > E * w:
            continue

        if s * (w + f) < t * f:
            s, t = f, w + f
    print(t, s)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = list(map(int, input().split()))

cap = 0
sug = 0

def G(a, b):
  while b > 0:
    a, b = b, a%b
  return a
def L(a, b):
  return a * b // G(a, b)


caps = {(N * 100 * A + M * 100 * B) for N in range(1 + F // (100 * A)) for M in range(1 + (F - N * 100 * A) // (100 * B))}
print(caps)

res = [0,0,0]
for water in caps:
    if water == 0: continue
    capp = min(F - water, E * water // 100)
    resug = capp % L(C, D)  
    cosug = capp - resug
    sugers = [(N * C + M * D + cosug) for N in range(resug // C + 1) for M in range((resug - N * C)//D + 1)]
    print(water, sugers)
    suger = max(sugers)
    ratio = suger / (water + suger)
    if res[0] < ratio: res = [ratio, suger + watter, suger] 


print(res[1], res[2])    


Fixed submission:

import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    A, B, C, D, E, F = read_values()
    W = set()
    
    for a in range(F // (A * 100) + 1):
        for b in range(F // (B * 100) + 1):
            w = a * 100 * A + b * 100 * B
            if 0 < w <= F:
                W.add(w)

    S = set()
    for c in range(F // C + 1):
        for d in range(F // D + 1):
            s = c * C + d * D
            if 0 <= s <= F:
                S.add(s)
    S = sorted(list(S))
    
    s, t = 0, 100 * A
    for w in W:
        p = min(F - w, math.ceil(E * w / 100))
        f = S[bisect.bisect_right(S, p) - 1]
        if f * 100 > E * w:
            continue

        if s * (w + f) < t * f:
            s, t = f, w + f
    print(t, s)


if __name__ == "__main__":
    main()