Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda : sys.stdin.readline().rstrip()

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f = sorted(f, reverse=True)
cost = []
for i in range(n):
    cost.append(a[i]*f[i])
left = -1
right = max(cost)
def solve(x):
    cnt = 0
    for i in range(n):
        d = cost[i] - x
        if d <= 0:
            continue
        cnt += d//f[i] + int(d % f[i] != 0)
    if cnt <= k:
        return True
    else:
        return False
while right - left > 1:
    mid = (right + left) // 2
    if solve(mid):
        right = mid
    else:
        left = mid
print(right)

Fixed submission:
import numpy as np
N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A = np.sort(A)
F = np.sort(F)[::-1]
Asum = A.sum()

def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K

left = -1
right = np.amax(A * F)

while right - left > 1:
    mid = (right + left)//2
    if test(mid) == 1:
        right = mid
    else:
        left = mid
print(right)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A = np.sort(A)
F = np.sort(F)[::-1]
Asum = A.sum()

def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K

left = -1
right = np.amax(A * F)

while right - left > 1:
    mid = (right + left)//2
    if test(mid) == 1:
        right = mid
    else:
        left = mid
print(right)

Fixed submission:
import numpy as np
N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A = np.sort(A)
F = np.sort(F)[::-1]
Asum = A.sum()

def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K

left = -1
right = np.amax(A * F)

while right - left > 1:
    mid = (right + left)//2
    if test(mid) == 1:
        right = mid
    else:
        left = mid
print(right)

Buggy python submission (verdict: Runtime Error):
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    F=list(map(int,input().split()))
    A.sort()
    F.sort(reverse=True)
    i = 0
    while K > 0:
        if A[0]*F[0] >= A[-1] * F[-1]:
            if K > A[0]:
                K -= A.pop(0)
            else:
                A[0] -= K
                K = 0
                break
        else:
            if K >= A[-1]:
                K -= A.pop(-1)
                F.pop(-1)
            else:
                A[-1] -= K
                K=0
                break
        
    S = 0
    for j in range(len(A)):
        S += A[j] * F[j]
    print(S)
    
if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np
N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A = np.sort(A)
F = np.sort(F)[::-1]
Asum = A.sum()

def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K

left = -1
right = np.amax(A * F)

while right - left > 1:
    mid = (right + left)//2
    if test(mid) == 1:
        right = mid
    else:
        left = mid
print(right)