Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)

Fixed submission:
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
import heapq
import math
def main():
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  d=list(map(int,input().split()))
  if b>=sum(c):
    print(0)
  else:
    c.sort()
    d.sort(reverse=True)
    e=[c[i]*d[i] for i in range(a)]
    f=[]
    for i in range(a):
      heapq.heappush(f,-e[i])
    k=0
    while k<b or f[0]==0:
      x=-heapq.heappop(f)
      y=e.index(x)
      z=min(b-k,(x+f[0])//d[y]+1)
      k+=z
      c[y]=c[y]-z
      e[y]=c[y]*d[y]
      heapq.heappush(f,-e[y])
    print(-f[0])
  
if __name__ == '__main__':
  main()

Fixed submission:
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
if b>=sum(c):
  print(0)
else:
  c.sort()
  d.sort(reverse=True)
  e=[c[i]*d[i] for i in range(a)]
  f=[]
  for i in range(a):
    heapq.heappush(f,-e[i])
  k=0
  while k<b or f[0]==0:
    x=-heapq.heappop(f)
    y=e.index(x)
    z=min(b-k,(x+f[0])//d[y]+1)
    k+=z
    c[y]=c[y]-z
    e[y]=c[y]*d[y]
    heapq.heappush(f,-e[y])
  print(-f[0])

Fixed submission:
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)

Buggy python submission (verdict: Runtime Error):
import heapq
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
if b>=sum(c):
  print(0)
else:
  c.sort()
  d.sort(reverse=True)
  e=[c[i]*d[i] for i in range(a)]
  f=[]
  for i in range(a):
    heapq.heappush(f,-e[i])
  k=0
  while k<b or f[0]==0:
    x=-heapq.heappop(f)
    y=e.index(x)
    z=min(b-k,(x+f[0])//d[y]+1)
    k+=z
    c[y]=c[y]-z
    e[y]=c[y]*d[y]
    heapq.heappush(f,-e[y])
    print(f)
  print(-f[0])

Fixed submission:
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)