Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())))[::-1]
C = [(-A[i]*F[i], F[i], A[i]) for i in range(N)]
heapq.heapify(C)
x1, y1, z1 = heapq.heappop(C)
while z1 > 0 and K > 0:
    #print(x1, y1)
    x2, y2, z2 = heapq.heappop(C)
    a = min((x2 - x1)//z1 + 1, K, z1)
    K -= a
    heapq.heappush(C, (x1 + a*y1, y1, z1 - a))
    x1, y1, z1 = x2, y2, z2
    #print(y2)
print(- x1)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

left = - 1
right = 10**12

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#import math
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))



left = - 1
right = 10**12

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

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

Fixed submission:
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

left = - 1
right = 10**12

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#import math
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

C = A*F

left = - 1
right = 10**12

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

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

Fixed submission:
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

left = - 1
right = 10**12

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#import math
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

C = A*F

left = - 1
right = max(C)

def f(x):
    cnt = 0
    for i in range(N):
        if C[i] > x:
            #cnt += math.ceil((C[i] - x)/F[i])
            cnt += (C[i] - x + F[i] - 1)//F[i]
            if cnt > K:
                return False
    return True

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

Fixed submission:
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

left = - 1
right = 10**12

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)
C = [(-A[i]*F[i], F[i], A[i]) for i in range(N)]
heapq.heapify(C)
x1, y1, z1 = heapq.heappop(C)
while z1 > 0 and K > 0:
    #print(x1, y1)
    x2, y2, z2 = heapq.heappop(C)
    a = min((x2 - x1)//z1 + 1, K, z1)
    K -= a
    heapq.heappush(C, (x1 + a*y1, y1, z1 - a))
    x1, y1, z1 = x2, y2, z2
    #print(y2)
print(- x1)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

left = - 1
right = 10**12

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

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