Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


def is_ok(mid, K, A, F):
    used = 0
    for a, f in zip(A, F):
        upper = int(mid / f)
        if upper < a:
            used += a - upper
        if K < used:
            return False
    return True


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A.sort()
    F.sort(reverse=True)

    ng = -1
    ok = int(1e12)
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if is_ok(mid, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)


def input_line(*types):
    if isinstance(types[0], list):
        return list(map(types[0][0], input().split()))
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import numpy as np


def is_ok(mid, K, A, F):
    return np.maximum(A - mid // F, 0).sum() <= K


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A = np.array(sorted(A))
    F = np.array(sorted(F, reverse=True))

    ng = -1
    ok = int(1e12)
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if is_ok(mid, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)


def input_line(*types):
    if isinstance(types[0], list):
        return [types[0][0](x) for x in input().split()]
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


def argmax(scores):
    index = 0
    mx = 0
    for i, s in enumerate(scores):
        if mx < s[0]:
            mx = s[0]
            index = i
    return index


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A.sort()
    F.sort(reverse=True)
    scores = [[a*f, a, f] for a, f in zip(A, F)]
    index = argmax(scores)
    while K > 0 and scores[index][1] > 0:
        scores[index][1] -= 1
        scores[index][0] = scores[index][1] * scores[index][2]
        K -= 1
        index = argmax(scores)
    print(scores[index][0])


def input_line(*types):
    if isinstance(types[0], list):
        return list(map(types[0][0], input().split()))
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import numpy as np


def is_ok(mid, K, A, F):
    return np.maximum(A - mid // F, 0).sum() <= K


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A = np.array(sorted(A))
    F = np.array(sorted(F, reverse=True))

    ng = -1
    ok = int(1e12)
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if is_ok(mid, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)


def input_line(*types):
    if isinstance(types[0], list):
        return [types[0][0](x) for x in input().split()]
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


def argmax(scores):
    index = 0
    mx = 0
    for i, s in enumerate(scores):
        if mx < s[0]:
            mx = s[0]
            index = i
    return index


def main():
    N, K = input_line(int, int)
    A = input_line(*[int for i in range(N)])
    F = input_line(*[int for i in range(N)])
    A.sort()
    F.sort(reverse=True)
    scores = [[a*f, a, f] for a, f in zip(A, F)]
    scores.sort(key=lambda x: x[0], reverse=True)
    index = argmax(scores)
    while K > 0 and scores[index][1] > 0:
        scores[index][1] -= 1
        scores[index][0] = scores[index][1] * scores[index][2]
        K -= 1
        index = argmax(scores)
    print(scores[index][0])


def input_line(*types):
    if len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import numpy as np


def is_ok(mid, K, A, F):
    return np.maximum(A - mid // F, 0).sum() <= K


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A = np.array(sorted(A))
    F = np.array(sorted(F, reverse=True))

    ng = -1
    ok = int(1e12)
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if is_ok(mid, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)


def input_line(*types):
    if isinstance(types[0], list):
        return [types[0][0](x) for x in input().split()]
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


def main():
    N, K = input_line(int, int)
    A = input_line(*[int for i in range(N)])
    F = input_line(*[int for i in range(N)])
    A.sort()
    F.sort(reverse=True)
    scores = [[a*f, a, f] for a, f in zip(A, F)]
    scores.sort(key=lambda x: x[0], reverse=True)
    while K > 0 and scores[0][1] > 0:
        scores[0][1] -= 1
        scores[0][0] = scores[0][1] * scores[0][2]
        K -= 1
        scores.sort(key=lambda x: x[0], reverse=True)
    print(scores[0][0])


def input_line(*types):
    if len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import numpy as np


def is_ok(mid, K, A, F):
    return np.maximum(A - mid // F, 0).sum() <= K


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A = np.array(sorted(A))
    F = np.array(sorted(F, reverse=True))

    ng = -1
    ok = int(1e12)
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if is_ok(mid, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)


def input_line(*types):
    if isinstance(types[0], list):
        return [types[0][0](x) for x in input().split()]
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()