Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
#print(a)
#print(b)
c = []
for i in range(n):
  c.append([-a[i]*b[i],b[i]])
#print(c)
import heapq
heapq.heapify(c)
cnt = 0
while True:
  now = heapq.heappop(c)
  if now[0] == 0:
    heapq.heappush(c,now)
    break
  red = (c[0][0] - now[0]) // now[1]
  #print(red)
  if red > k - cnt:
    heapq.heappush(c, [now[0]+(k-cnt)*now[1],now[1]] )
    break
  elif red == 0:
    heapq.heappush(c, [now[0]+now[1],now[1]] )
    cnt += 1
  else:
    heapq.heappush(c, [now[0]+red*now[1],now[1]] )
    cnt += red
  if k == cnt:
    break
  #print(cnt,c)
#print(c)
ans = 0
for i in range(n):
  if ans > c[i][0]:
    ans = c[i][0]
print(-1*ans)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
#print(a)
#print(b)
big = 44
stand = 2 ** big
width = 2 ** (big-1)
if sum(a) <= k:
  print(0)
else:
  while True:
    tmp = []
    for i in range(n):
       tmp.append(max(0,a[i]-stand//b[i]))
    if width == 0:
      if sum(tmp) <= k:
        print(stand)
      else:
        print(stand+1)
      break
    if sum(tmp) <= k:
      stand -= width
      width //= 2
    else:
      stand += width
      width //= 2
    #print(stand,tmp)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
#print(a)
#print(b)
c = []
for i in range(n):
  c.append([-a[i]*b[i],b[i]])
#print(c)
import heapq
heapq.heapify(c)
for _ in range(k):
  now = heapq.heappop(c)
  if now[0] == 0:
    heapq.heappush(c,now)
    break
  heapq.heappush(c, [now[0]+now[1],now[1]] )
#print(c)
ans = 0
for i in range(n):
  if ans > c[i][0]:
    ans = c[i][0]
print(-1*ans)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
#print(a)
#print(b)
big = 44
stand = 2 ** big
width = 2 ** (big-1)
if sum(a) <= k:
  print(0)
else:
  while True:
    tmp = []
    for i in range(n):
       tmp.append(max(0,a[i]-stand//b[i]))
    if width == 0:
      if sum(tmp) <= k:
        print(stand)
      else:
        print(stand+1)
      break
    if sum(tmp) <= k:
      stand -= width
      width //= 2
    else:
      stand += width
      width //= 2
    #print(stand,tmp)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
#print(a)
#print(b)
c = []
for i in range(n):
  c.append([-a[i]*b[i],b[i]])
#print(c)
import heapq
heapq.heapify(c)
for _ in range(k):
  now = heapq.heappop(c)
  if now[0] == 0:
    heapq.heappush(c,now)
    break
  heapq.heappush(c, [now[0]+now[1],now[1]] )
#print(c)
ans = 0
for i in range(n):
  if ans > c[i][0]:
    ans = c[i][0]
print(-1*ans)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
#print(a)
#print(b)
big = 44
stand = 2 ** big
width = 2 ** (big-1)
if sum(a) <= k:
  print(0)
else:
  while True:
    tmp = []
    for i in range(n):
       tmp.append(max(0,a[i]-stand//b[i]))
    if width == 0:
      if sum(tmp) <= k:
        print(stand)
      else:
        print(stand+1)
      break
    if sum(tmp) <= k:
      stand -= width
      width //= 2
    else:
      stand += width
      width //= 2
    #print(stand,tmp)