Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse = True)
    f = list(map(int, input().split()))
    f.sort()
    right = a[0]*f[-1]
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        for i in range(n):
            b += max(0, a[i] - middle//f[i])
        if b <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse = True)
    f = list(map(int, input().split()))
    f.sort()
    right = 10**12
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        for i in range(n):
            b += max(0, a[i]-(middle//f[i]))
        if b <= k:
            right = middle
        else:
            left = middle + 1

    print(right)
if __name__ == '__main__':
    main()

Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import bisect
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    f = list(map(int, input().split()))
    a.sort()
    f.sort(reverse = True)
    d = [[f[i]*a[i], f[i], a[i]] for i in range(n)]
    for i in range(k):
        if d[d.index(max(d))][2] > 0:
            d[d.index(max(d))][2] -= 1
            d[d.index(max(d))][0] -= d[d.index(max(d))][1]
        else:
            break
    print(d[d.index(max(d))][0])
if __name__ == '__main__':
    main()

Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse = True)
d = [[f[i]*a[i], f[i], a[i]] for i in range(n)]
d.sort(reverse = True)
for i in range(k):
    if d[0][2] > 0:
        d[0][0] -= d[0][1]
        d[0][2] -= 1
        d.sort(reverse = True)
    else:
        break
print(d[0][0])

Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse = True)
d = [[f[i]*a[i], f[i], a[i]] for i in range(n)]
d.sort(reverse = True)
for i in range(k):
    if d[0][-1] > 0:
        a.pop(a.index(d[0][-1]))
        d[0][-1] -= 1
        a.insert(bisect.bisect_right(a, d[0][-1]) ,d[0][-1])
        d = [[f[i]*a[i], f[i], a[i]] for i in range(n)]
        d.sort(reverse = True)
    else:
        break
print(d[0][0])

Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

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()))
a.sort()
f.sort(reverse = True)
a = [[f[i]*a[i], f[i], a[i]] for i in range(n)]
a.sort(reverse = True)
for i in range(k):
    if a[0][-1] > 0:
        a[0][-1] -= 1
        a = [a[i][-1] for i in range(n)]
        a.sort()
        a = [[f[i]*a[i], f[i], a[i]] for i in range(n)]
        a.sort(reverse = True)
    else:
        break
print(a[0][0])

Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()

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()))
a.sort()
f.sort(reverse = True)
a = [[-a[i]*f[i], a[i], f[i]] for i in range(n)]
import heapq
heapq.heapify(a)

for i in range(k):
    h = heapq.heappop(a)
    if h[1] > 0:
        h[1] -= 1
        h[0] = -h[2]*h[1]
        heapq.heappush(a, h)
    else:
        heapq.heappush(a, h)
        break

result = heapq.heappop(a)
print(-result[0])


Fixed submission:
def main():

    import numpy as np
    
    n, k = map(int, input().split())
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    a = a[::-1]
    f.sort()
    right = np.max(a*f)
    left = 0
    while right > left:
        middle = (right + left)//2
        b = 0
        
        if np.sum(np.maximum(a-middle//f, 0)) <= k:
            right = middle
        else:
            left = middle+1

    print(right)
if __name__ == '__main__':
    main()