Buggy python submission (verdict: Time Limit Exceeded):
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

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=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    
import math

left=0
right=a[0]*b[-1]
P=0
for i in range(41):
    if 2**i<=right<2**(i+1):
        P=i+1
        break

for _ in range(P):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))

Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    
import math

left=0
right=a[0]*b[-1]
for _ in range(math.ceil(math.log2(right))):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))
   


Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    
import math

left=0
right=a[0]*b[-1]
for _ in range(math.ceil(math.log2(right))):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))
   


Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    
import math

left=0
right=a[-1]*b[0]+1
for _ in range(math.ceil(math.log2(right))+1):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))
   


Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

input=sys.stdin.readline

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    


left=0
right=10**12

for _ in range(40):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))
   


Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

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=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    
import math

left=0
right=10**12
for _ in range(40):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))
   


Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

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=sorted(a,reverse=True)
b=sorted(b)

def ok(N):
    sums=0
    for i in range(n):
        sums+=max(0,a[i]-N//b[i])
    if sums<=k:
        return True
    else:
        return False
    
import math

left=0
right=10**12
for _ in range(40):
    if ok(math.floor((left+right)/2)):
      left=left
      right=(left+right)/2
    elif not ok(math.floor((left+right)/2)):
      left=(left+right)/2
      right=right
print(math.floor(right))
   


Fixed submission:
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)