Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
X = []
A = sorted(A)
F = sorted(F)[::-1]
for i in range(N):
  X.append([A[i] * F[i],A[i],F[i]])

import heapq
from heapq import heapify

heapq._heapify_max(X)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt
  
for i in range(K):
    x = _heappop_max(X)
    if x[0] < 1:
        _heappush_max(X,x)
        break
    else:       
        x[1] -= 1
        x[0] = x[1] * x[2]
        _heappush_max(X,x)
from operator import itemgetter
X.sort(key=itemgetter(0))
print(X[-1][0])



Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort(); F.sort(); F=F[::-1]

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

left = -1
right = 10**13
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
X = []
A = sorted(A)
F = sorted(F)[::-1]
for i in range(N):
  X.append([A[i] * F[i],A[i],F[i]])

import heapq
from heapq import heapify

heapq._heapify_max(X)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt
  
for i in range(K):
    x = _heappop_max(X)
    if x[0] < 1:
        _heappush_max(X,x)
        break
    else:       
        x[1] -= 1
        x[0] = x[1] * x[2]
        _heappush_max(X,x)
from operator import itemgetter
X.sort(key=itemgetter(0))
print(X[-1][0])



Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort(); F.sort(); F=F[::-1]

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

left = -1
right = 10**13
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)

Buggy python submission (verdict: Runtime Error):
import copy
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
X = []
A = sorted(A)
F = sorted(F)[::-1]
for i in range(N):
  X.append(A[i] * F[i])
XX = copy.deepcopy(X)

import heapq
from heapq import heapify

heapq._heapify_max(X)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

for i in range(K):
    x = _heappop_max(X)
    id = XX.index(x)
    if x < 1:
        _heappush_max(X,x)
        break
    else:
        A[id] -= 1
        x = A[id] * F[id]
        XX[id] = x
        _heappush_max(X,x)

print(max(X))



Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort(); F.sort(); F=F[::-1]

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

left = -1
right = 10**13
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
X = []
A = sorted(A)
F = sorted(F)[::-1]
for i in range(N):
  X.append(A[i] * F[i])
XX = copy.deepcopy(X)

import heapq
from heapq import heapify

heapq._heapify_max(X)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

for i in range(K):
    x = _heappop_max(X)
    id = XX.index(x)
    if x < 1:
        _heappush_max(X,x)
        break
    else:
        A[id] -= 1
        x = A[id] * F[id]
        XX[id] = x
        _heappush_max(X,x)
print(max(X))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort(); F.sort(); F=F[::-1]

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

left = -1
right = 10**13
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)