Buggy python submission (verdict: Time Limit Exceeded):
N,K=[int(s) for s in input().split()]
A=[int(s) for s in input().split()]
F=[int(s) for s in input().split()]
A.sort()
F.sort(reverse=1)


def success(x):
  suc_sum=0
  for i in range(N):
    a=x//F[i]
    if A[i]>a:
      suc_sum+=A[i]-a
  if suc_sum<=K:
    return True
  else:
    return False

def bisearch():
  bi_max=10**12
  bi_a=0
  bi_b=bi_max
  while bi_b-bi_a>1:
    c=(bi_a+bi_b)//2
    if success(c):
      bi_a,bi_b=[bi_a,c]
    else:
      bi_a,bi_b=[c,bi_b]
  return [bi_a,bi_b]

a,b=bisearch()
if success(a):
  print(a)
else:
  print(b)    

Fixed submission:
import math
N,K=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls1.sort()
ls2.sort()
M=max([ls1[i]*ls2[N-1-i] for i in range(N)])
#print(M)
###aまで下げることが可能か？
def pos(a):
  s=0
  for i in range(N):
    s+=max([0,math.ceil(ls1[i]-a/ls2[N-1-i])])
  if s>K:
    return 0
  else:
    return 1
x=0
y=M//2
z=M
while z-x>1:
  if pos(y)==1:
    z=y
  else:
    x=y
  y=(x+z)//2
#  print(x,y,z)
if pos(y)==1:
  print(y)
else:
  print(z)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls1.sort()
ls2.sort()
M=max([ls1[i]*ls2[N-1-i] for i in range(N)])
#print(M)
###aまで下げることが可能か？
def pos(a):
  s=0
  for i in range(N):
    s+=max([0,math.ceil(ls1[i]-a/ls2[N-1-i])])
  if s>K:
    return 0
  else:
    return 1
x=0
y=M//2
z=M
while z-x>1:
  if pos(y)==1:
    z=y
  else:
    x=y
  y=(x+z)//2
#  print(x,y,z)
if pos(y)==1:
  print(y)
else:
  print(z)
    


Fixed submission:
import math
N,K=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls1.sort()
ls2.sort()
M=max([ls1[i]*ls2[N-1-i] for i in range(N)])
#print(M)
###aまで下げることが可能か？
def pos(a):
  s=0
  for i in range(N):
    s+=max([0,math.ceil(ls1[i]-a/ls2[N-1-i])])
  if s>K:
    return 0
  else:
    return 1
x=0
y=M//2
z=M
while z-x>1:
  if pos(y)==1:
    z=y
  else:
    x=y
  y=(x+z)//2
#  print(x,y,z)
if pos(y)==1:
  print(y)
else:
  print(z)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,K=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls1.sort()
ls2.sort()
cost=[]

ls3=[ls1[i]*ls2[N-1-i] for i in range(N)]

for i in range(N):
  heapq.heappush(cost,(-ls1[i]*ls2[N-1-i],ls1[i],ls2[N-i-1]))
for i in range(K):
  xy, x, y = heapq.heappop(cost)
  if x==0:
    heapq.heappush(cost,(-1*x*y,x,y))
    break
  else:
    heapq.heappush(cost,(-1*(x-1)*y,x-1,y))
xy,x,y=heapq.heappop(cost)
print(-1*xy)  


Fixed submission:
import math
N,K=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls1.sort()
ls2.sort()
M=max([ls1[i]*ls2[N-1-i] for i in range(N)])
#print(M)
###aまで下げることが可能か？
def pos(a):
  s=0
  for i in range(N):
    s+=max([0,math.ceil(ls1[i]-a/ls2[N-1-i])])
  if s>K:
    return 0
  else:
    return 1
x=0
y=M//2
z=M
while z-x>1:
  if pos(y)==1:
    z=y
  else:
    x=y
  y=(x+z)//2
#  print(x,y,z)
if pos(y)==1:
  print(y)
else:
  print(z)