Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
A = [int(x) for x in input().split()]
F = [int(x) for x in input().split()]

## Aは昇順Fは降順に並び替える
A.sort()
F.sort(reverse=True)

A=np.array(A)
F=np.array(F)

## 成績(A × F)の目標をxにしたときに何回修行が必要かを求める関数
def target(x):
    train_count = 0
    for i in range(N):
        a = A[i]
        targ_a = x // F[i] # 目標を達成した時の消費コストA
        if targ_a < a:
            train_count += a - targ_a
    return train_count <= K

## 二分探索(リストを半分ずつ削って達成可能な目標を探す)
left = -1                            # 一番左
right = A[-1] * F[0]                 # 一番右(Aの最大値 × Fの最大値)
while right > left+1:                # 一番右が一番左より大きい間（一致したら終了）
    middle = (left + right) // 2     # 真ん中
    if target(middle):               # 目標を真ん中にして達成可能なら
        right = middle               # 一番右を真ん中にする（残りの右側は無駄に時間かかってるから切り捨てる）
    else:                            # 達成できないなら(K回を超えてしまうとき）
        left = middle                # 一番左を真ん中にする（残りの左側は達成不可だから切り捨てる）
print(right)


Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

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)

def target(x):
    train_count = 0
    for i in range(N):
        a = A[i]
        targ_a = x // F[i] 
        if targ_a < a:
            train_count += a - targ_a
    return train_count <= K

left = -1                            
right = A[-1] * F[0]                 
while right > left+1:                
    middle = (left + right) // 2     
    if target(middle):               
        right = middle               
    else:              
        left = middle 
print(right)


Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

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は昇順Fは降順に並び替える
A.sort()
F.sort(reverse=True)

## 成績(A × F)の目標をxにしたときに何回修行が必要かを求める関数
def target(x):
    train_count = 0
    for i in range(N):
        a = A[i]
        targ_a = x // F[i] # 目標を達成した時の消費コストA
        if targ_a < a:
            train_count += a - targ_a
    return train_count <= K

## 二分探索(リストを半分ずつ削って達成可能な目標を探す)
left = -1                            # 一番左
right = A[-1] * F[0]                 # 一番右(Aの最大値 × Fの最大値)
while right > left+1:                # 一番右が一番左より大きい間（一致したら終了）
    middle = (left + right) // 2     # 真ん中
    if target(middle):               # 目標を真ん中にして達成可能なら
        right = middle               # 一番右を真ん中にする（残りの右側は無駄に時間かかってるから切り捨てる）
    else:                            # 達成できないなら(K回を超えてしまうとき）
        left = middle                # 一番左を真ん中にする（残りの左側は達成不可だから切り捨てる）
print(right)

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

##　Aは昇順Fは降順に並び替える
A.sort() 
F.sort(reverse = True)

##　成績(A × F)の目標をxにしたときに何回修行が必要かを求める関数
def target(x):
    train_count = 0
    for i in range(N):
        a = A[i]
        targ_a = x // F[i] #目標を達成した時の消費コストA
        if targ_a < a:
            train_count = train_count + a - targ_a 
    return train_count <= K　#ただし合計がKを超えないもの

##　二分探索(リストを半分ずつ削って達成可能な目標を探す)
left = -1                        #一番左
right = A[-1] * F[0]             #一番右(Aの最大値 × Fの最大値)
while right > left + 1:          #一番右が一番左より大きい間（一致したら終了）
    middle = (left + right) // 2 #真ん中
    if target(middle):           #目標を真ん中にして達成可能なら
        right = middle           #一番右を真ん中にする（残りの右側は無駄に時間かかってるから切り捨てる）
    
    else:                        #達成できないなら(K回を超えてしまうとき）
        left = middle            #一番左を真ん中にする（残りの左側は達成不可だから切り捨てる）

print(right)


Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
readline = sys.stdin.buffer.readline

N, K = map(int, readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort()
F.sort()
F=F[::-1]
 
new_list_a = np.array(A)
new_list_f = np.array(F)
 
for _ in range(K):
  time = new_list_f * new_list_a
  number_a = np.argmax(time)
  new_list_a[number_a] = new_list_a[number_a] - 1
  time = new_list_f * new_list_a
  
print(max(time))

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
readline = sys.stdin.buffer.readline

N, K = map(int, readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort()
F.sort()
F=F[::-1]
 
new_list_a = np.array(A)
new_list_f = np.array(F)
 
for i in range(K):
  time = new_list_f * new_list_a
  number_a = np.argmax(time)
  new_list_a[number_a] = new_list_a[number_a] - (i - (i - 1))
  time = new_list_f * new_list_a
  
print(max(time))

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
 
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
F = [int(x) for x in input().split()]

A.sort()
F.sort(reverse=True)
 
new_list_a = np.array(A)
new_list_f = np.array(F)
time = new_list_f * new_list_a
 
for i in range(K):
  number_a = np.argmax(time)
  new_list_a[number_a] = new_list_a[number_a] - (i - (i - 1))
  time = new_list_f * new_list_a
  
print(max(time))

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
 
N, K = map(int, input().split())
new_list_a = sorted(list(map(int, input().split())), reverse=True)
new_list_f = sorted(list(map(int, input().split())))
 
new_list_a = np.array(new_list_a)
new_list_f = np.array(new_list_f)
time = new_list_f * new_list_a
 
for i in range(K):
  number_a = np.argmax(time)
  new_list_a[number_a] = new_list_a[number_a] - (i - (i - 1))
  time = new_list_f * new_list_a
  
print(max(time))

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
N, K = map(int, input().split())
new_list_f = sorted(list(map(int, input().split())))
new_list_a = sorted(list(map(int, input().split())), reverse=True)
 
new_list_f = np.array(new_list_f)
new_list_a = np.array(new_list_a)
time = new_list_f * new_list_a
 
for i in range(K + 1):
  t_max = time.index(max(time))
  new_list_a[t_max] = new_list_a[t_max] - (i - (i - 1))
  if new_list_a[t_max] == 0:
    break
  
print(time)

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
 
new_list_f = sorted(F)
new_list_a = sorted(A, reverse=True)

new_list_f = np.array(new_list_f)
new_list_a = np.array(new_list_a)
time = new_list_f * new_list_a
 
for i in range(K + 1):
  t_max = time.index(max(time))
  new_list_a[t_max] = new_list_a[t_max] - (i - (i - 1))
  if new_list_a[t_max] == 0:
    break
  
print(time)

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

li_f = list.sort(F)
li_a = list.sort(A, reverse=True)

for i in range(K + 1):
  combined1 = [x * y for (x, y) in zip(li1, li2)]
  n_max = combined1.index(max(combined1))
  li_a[n_max] = li_a[n_max] - (i - (i - 1))

print(max(combined1))

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

li_f = list.sort(F)
li_a = list.sort(A, reverse=True)

combined1 = [x * y for (x, y) in zip(li1, li2)]

for i in range(K + 1):
  n_max = combined1.index(max(combined1))
  li_a[n_max] = li_a[n_max] - (i - (i - 1))

print(max(combined1))

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

li_f = list.sort(F)
li_a = list.sort(A, reverse = True)

from operator import mul
combined1 = map(mul, li_f, li_a)

for i in range(1, K):
  n_max = combined1.index(max(combined1))
  li_a[n_max] = li_a[n_max] - 1
  ans = max(combined1)
 
print(ans)

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

#Aを降順Fを昇順に並べる

li_f = list.sort(F)
li_a = list.sort(A, reverse=True)

#二つの要素同士をかける

from operator import mul
combined1 = map(mul, li_f, li_a)

#作業をK回繰り返す

for i in range(1, K):

#まずかけたやつのリストで最大のものが何番目なのかを取り出す

	n_max = combined1.index(max(combined1))

#それはli_aのインデックスと同じなのでそのインデックスのli_aの要素を取り出す
#その値から１引いて元に戻す

	li_a[n_max] = li_a[n_max] - 1
	ans = max(combined1)
    
print(ans)

Fixed submission:
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)