qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, K = map(int, input().split())
*A, = map(int, input().split())
*F, = map(int, input().split())
A.sort()
F.sort(reverse=True)

def f(x):
    ans = 0
    for i,j in zip(A, F):
        ans += (i*j-x+j-1)//j if i*j-x>=0 else 0
    return ans<=K

l, r = 0, 10**18
while r-l>1:
    mid = (l+r)//2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)

Fixed code:
N, K = map(int, input().split())
*A, = map(int, input().split())
*F, = map(int, input().split())
A.sort()
F.sort(reverse=True)

def f(x):
    ans = 0
    for i,j in zip(A, F):
        ans += (i*j-x+j-1)//j if i*j-x>=0 else 0
    return ans<=K

l, r = -1, 10**18+1
while r-l>1:
    mid = (r+l)//2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)
Buggy code:
from math import ceil

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

def is_valid(A, F, K, T):
    for a, f in zip(A, F):
        if a*f > T:

            k = ceil(a - T/f)
            if k <= K:
                K -= k
            else:
                return False
    return True

def solve(N, K, A, F):
    i = 0
    left, right = 0, 10**12

    while left < right:
        mid = (left + right) // 2

        if is_valid(A, F, K, mid):
            right = mid
        else:
            left = mid + 1
    return mid

Fixed code:
from math import ceil

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

def is_valid(A, F, K, T):
    for a, f in zip(A, F):
        if a*f > T:

            k = ceil(a - T/f)
            if k <= K:
                K -= k
            else:
                return False
    return True

def solve(N, K, A, F):
    i = 0
    left, right = 0, 10**12

    while left < right:
        mid = (left + right) // 2

        if is_valid(A, F, K, mid):
            right = mid
        else:
            left = mid + 1
    
    if is_valid(A, F, K, mid-1) and (not is_valid(A, F, K, mid)):
        return mid-1
    elif is_valid(A, F, K, mid):
        return mid
    else:
        return mid+1

print(solve(N, K, A, F))
Buggy code:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())))[::-1]
r = 10**12+1
l = -1
while r - l > 1:
    s = k
    mid = (r + l)//2
    for i, j in zip(a, f):
        if mid < i*j:
            s -= i-mid//j
    if s < 0:
        l = mid
    else:
        r = mid
    print('r:', r, 'l:', l, 'r-l:', r-l)
print(r)


Fixed code:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())))[::-1]
r = 10**12+1
l = -1
while r - l > 1:
    s = k
    mid = (r + l)//2
    for i, j in zip(a, f):
        if mid < i*j:
            s -= i-mid//j
    if s < 0:
        l = mid
    else:
        r = mid
#    print('r:', r, 'l:', l, 'r-l:', r-l)
print(r)
Buggy code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
l=0
r=10**13
while r-l!=1:
    m=(l+r)//2
    x=0
    for i in range(N):
        x+=max(0,A[i]-m//F[i])
    if x<=K:
        r=m
    else:
        l=m
print(r)


Fixed code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
l=-1
r=10**13
while r-l!=1:
    m=(l+r)//2
    x=0
    for i in range(N):
        x+=max(0,A[i]-m//F[i])
    if x<=K:
        r=m
    else:
        l=m
print(r)
Buggy code:
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))[::-1]
l,r=10**12+1,0
while l-r>1:
    t=(l+r)//2
    s=k
    for i,j in zip(a,b):
        if t<i*j:s-=(i*j-t-1)//j+1
    if s<0:r=t
    else:l=t
print(l)

Fixed code:
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))[::-1]
l,r=10**12+1,-1
while l-r>1:
    t=(l+r)//2
    s=k
    for i,j in zip(a,b):
        if t<i*j:s-=i-t//j
    if s<0:r=t
    else:l=t
print(l)
Buggy code:
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()
F.sort()
F = F[::-1]
dig = A.sum()


def judge(x):
    return dig - np.minimum(A, x // F).sum() <= K


l = 0
r = 10 ** 19

while l + 1 < r:
    test = (l + r) // 2
    if judge(test):
        r = test
    else:
        l = test

print(r)

Fixed code:
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()
F.sort()
F = F[::-1]
dig = A.sum()


def judge(x):
    return dig - np.minimum(A, x // F).sum() <= K


l = -1
r = 10 ** 18 + 1

while l + 1 < r:
    test = (l + r) // 2
    if judge(test):
        r = test
    else:
        l = test

print(r)
Buggy code:
import numpy as np

def main():
    N, K = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    F = np.array(list(map(int, input().split())))

    A.sort()
    F = np.sort(F)[::-1]

    time = A*F
    high = 10**12 + 1
    low = 1

    while high - low > 1:
        middle = (high + low) // 2

        temp = np.where(time>middle, time-middle, 0)
        temp = np.ceil(temp/F).sum()

        if temp <= K:
            high = middle
        else:
            low = middle

    middle = high
    temp = np.where(time>middle, time-middle, 0)
    temp = np.ceil(temp/F)
    time = (time - temp*F).max()
    print(int(time))


if __name__ == '__main__':
    main()


Fixed code:
import numpy as np

def main():
    N, K = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    F = np.array(list(map(int, input().split())))

    A.sort()
    F = np.sort(F)[::-1]

    time = A*F
    high = 10**12 + 1
    low = -1

    while high - low > 1:
        middle = (high + low) // 2

        temp = np.where(time>middle, time-middle, 0)
        temp = np.ceil(temp/F).sum()

        if temp <= K:
            high = middle
        else:
            low = middle

    middle = high
    temp = np.where(time>middle, time-middle, 0)
    temp = np.ceil(temp/F)
    time = (time - temp*F).max()
    print(int(time))


if __name__ == '__main__':
    main()
Buggy code:
import numpy as np

def is_ok(mid, k):
    s = a - mid // f
    print(s)
    s = s[s > 0].sum()
    if s <= k:
        return True
    else:
        return False

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
a.sort()
f.sort(reverse=True)
a = np.array(a)
f = np.array(f)

l, r = -1, 10**12 # l:ng, r:ok
while l + 1 < r:
    mid = (l + r) // 2
    if is_ok(mid, k):
        r = mid
    else:
        l = mid
print(r)

Fixed code:
import numpy as np

def is_ok(mid, k):
    s = a - mid // f
    s = s[s > 0].sum()
    if s <= k:
        return True
    else:
        return False

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
a.sort()
f.sort(reverse=True)
a = np.array(a)
f = np.array(f)

l, r = -1, 10**12 # l:ng, r:ok
while l + 1 < r:
    mid = (l + r) // 2
    if is_ok(mid, k):
        r = mid
    else:
        l = mid
print(r)
Buggy code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
if sum(a)<=k:
    print(0)
    exit()
f.sort(reverse=True)
m=0
for i in range(n):
    m=max(m,a[i]*f[i])
x=m//2
l=0
r=m
def check(x):
    p=0
    for i in range(n):
        if x//f[i]<a[i]:
            p+=a[i]-x//f[i]
            if p>k:
                return False
    if p>k:
        return False
    else:
        return True
while l<r:
    if check(x):
        r=x
        x=(r+l)//2
    else:
        l=x
        x=(r+l)//2
print(r)


Fixed code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
if sum(a)<=k:
    print(0)
    exit()
f.sort(reverse=True)
l=0
r=10**12
x=(r+l)//2
def check(x):
    p=0
    for i in range(n):
        if x//f[i]<a[i]:
            p+=a[i]-x//f[i]
            if p>k:
                return False
    if p>k:
        return False
    else:
        return True
while l+1<r:
    if check(x):
        r=x
        x=(r+l)//2
    else:
        l=x
        x=(r+l)//2
print(r)
Buggy code:
import sys

def jeat(a, f, x, K):
    N = 0
    for i in range(len(a)):
        if a[i]*f[i] > x:
            N += a[i] - x // f[i]
    if N > K:
        return False
    if N <= K:
        return True

N,K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
F = list(map(int, input().split(' ')))
if K >= sum(A):
    print(0)
    sys.exit()
A.sort()
F.sort(reverse = True)
a = 0
b = 10**13
while (a<b):
    z = (a+b)//2
    if jeat(A,F,z,K) == True:
        if jeat(A,F,z-1,K) == False:
            break
        b = z-1
    else:
        if jeat(A,F,z+1,K) == True:
            z -= 1
            break
        a = z+1

print(z)

Fixed code:
import sys

def jeat(a, f, x, K):
    N = 0
    for i in range(len(a)):
        if a[i]*f[i] > x:
            N += a[i] - x // f[i]
    if N > K:
        return False
    if N <= K:
        return True

N,K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
F = list(map(int, input().split(' ')))
if K >= sum(A):
    print(0)
    sys.exit()
A.sort()
F.sort(reverse = True)
a = 0
b = 10**18
while (True):
    z = (a+b)//2
    if jeat(A,F,z,K) == True:
        if jeat(A,F,z-1,K) == False:
            break
        b = z-1
    else:
        if jeat(A,F,z+1,K) == True:
            z += 1
            break
        a = z+1

print(z)
Buggy code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort(reverse=True)
f.sort()
af = [a[i]*f[i] for i in range(n)]
lower = 0
upper = max(af)
prev = 0
now = upper // 2
while now != prev:
  count = 0
  for i in range(n):
    if a[i]*f[i] > now:
      count += a[i] - now // f[i]
  if count <= k:
    upper = now
  else:
    lower = now
  prev = now
  now = (lower + upper) // 2 + 1

print(now)

Fixed code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort(reverse=True)
f.sort()
af = [a[i]*f[i] for i in range(n)]
lower = 0
upper = max(af)
prev = 0
now = upper // 2
while now != prev:
  count = 0
  for i in range(n):
    if a[i]*f[i] > now:
      count += a[i] - now // f[i]
  if count <= k:
    upper = now
  else:
    lower = now
  prev = now
  now = (lower + upper) // 2

print(upper)
Buggy code:
import numpy as np
N, K = map(int, input().split())
As = np.sort(list(map(int, input().split())))
Fs = np.sort(list(map(int, input().split())))[::-1]
l  = As*Fs
left = 0
right = max(l)
while right-left>1:
    mid = left + (right - left)/2
    if np.maximum(As-mid//Fs , 0).sum()<=K:
        right = mid
    else:
        left = mid
print(int(right))

Fixed code:
import numpy as np
N, K = map(int, input().split())
As = np.sort(list(map(int, input().split())))
Fs = np.sort(list(map(int, input().split())))[::-1]
l  = As*Fs
left = 0
right = max(l)
while right-left>=1:
    mid = left + (right - left)/2
    if np.maximum(As-mid//Fs , 0).sum()<=K:
        right = mid
    else:
        left = mid
print(int(right))
Buggy code:
N, K = map(int, input().split())
AS = list(map(int, input().split()))
FS = list(map(int, input().split()))
AS.sort(); FS.sort(reverse=True)

def isValid(x):
    import math
    trains = 0
    for i in range(N):
        num = AS[i] * FS[i]
        if num <= K: continue
        trains += math.ceil((num - K) / FS[i])
    return trains <= K

def binarySearch(lo, hi):
    if lo >= hi:
        return lo
    mid = lo + (hi - lo) // 2
    if isValid(mid):
        return binarySearch(lo, mid)
    else:
        return binarySearch(mid + 1, hi)
            
print(binarySearch(0, max(AS[i] * FS[i] for i in range(N))))


Fixed code:
N, K = map(int, input().split())
AS = list(map(int, input().split()))
FS = list(map(int, input().split()))
AS.sort(); FS.sort(reverse=True)

def isValid(x):
    import math
    trains = 0
    for i in range(N):
        num = AS[i] * FS[i]
        if num <= x: continue
        trains += math.ceil((num - x) / FS[i])
    return trains <= K

def binarySearch(lo, hi):
    if lo >= hi:
        return lo
    mid = lo + (hi - lo) // 2
    if isValid(mid):
        return binarySearch(lo, mid)
    else:
        return binarySearch(mid + 1, hi)
            
print(binarySearch(0, max(AS[i] * FS[i] for i in range(N))))
Buggy code:
import math

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

A.sort(reverse=True)
F.sort()
max_af = 0
for ind,a in enumerate(A):
    max_af = max(a*F[ind], max_af)

if(sum(A)<=K):
    print(0)
else:
    lower = 1
    higher = max_af

    while(higher-lower>1):
        k = K
        x = (lower+higher)//2
        for ind,a in enumerate(A):
            mu = a*F[ind]
            if(mu<=x):
                continue
            else:
                k -= math.ceil((mu-x)/F[ind])
        if(k>=0):
            higher = x
        else:
            lower = x

    print(x)


Fixed code:
import math

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

A.sort(reverse=True)
F.sort()
max_af = 0
for ind,a in enumerate(A):
    max_af = max(a*F[ind], max_af)

if(sum(A)<=K):
    print(0)
else:
    lower = -1
    higher = 10**12+1

    while(higher-lower>1):
        x = (lower + higher)//2
        
        k = K
        for ind,a in enumerate(A):
            mu = a*F[ind]
            if(mu<=x):
                continue
            else:
                k -= math.ceil((mu-x)/F[ind])
        if(k>=0):
            higher = x
        else:
            lower = x

    print(higher)
Buggy code:
import math
n,k = map(int, input().split())
alst = list(map(int, input().split()))
flst = list(map(int, input().split()))

sorted_flst = sorted(flst, key = lambda x: -x)
sorted_alst = sorted(alst)

pair_lst = []
for a, b in zip(sorted_flst, sorted_alst):
    pair_lst.append((a*b, a))
sorted_pair_lst = sorted(pair_lst, key = lambda x:-x[0])

def judge(sorted_pair_lst, x):
    cnt = 0
    for pair in sorted_pair_lst:
        if pair[0] <= x:
            return True
        else:
            cnt += math.ceil((pair[0] - x) / pair[1])
            if cnt > k:
                return False
    return True

low = 0
high = 10**15
while high - low > 1:
    middle = (low+high) // 2
    if judge(sorted_pair_lst, middle):
        high = middle
    else:
        low = middle
print(high) if judge(sorted_pair_lst, high) else print(low)

Fixed code:
import math
n,k = map(int, input().split())
alst = list(map(int, input().split()))
flst = list(map(int, input().split()))

sorted_flst = sorted(flst, key = lambda x: -x)
sorted_alst = sorted(alst)

pair_lst = []
for a, b in zip(sorted_flst, sorted_alst):
    pair_lst.append((a*b, a))
sorted_pair_lst = sorted(pair_lst, key = lambda x:-x[0])

def judge(sorted_pair_lst, x):
    cnt = 0
    for pair in sorted_pair_lst:
        if pair[0] <= x:
            return True
        else:
            cnt += math.ceil((pair[0] - x) / pair[1])
            if cnt > k:
                return False
    return True

low = 0
high = 10**15
while high - low > 1:
    middle = (low+high) // 2
    if judge(sorted_pair_lst, middle):
        high = middle
    else:
        low = middle
print(low) if judge(sorted_pair_lst, low) else print(high)
Buggy code:
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, Nonw).sum()

    if req < k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff)


Fixed code:
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, None).sum()

    if req <= k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff))
Buggy code:
def is_ok(x):
    result = 0
    for i in range(N):
        a = A[i]
        t = x // F[i]
        if t < a:
            result += a - t
    return result <= K


N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

ng = -1
ok = A[-1] * F[0]
while ng - ok > 1:
    m = (ok + ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)


Fixed code:
def is_ok(x):
    result = 0
    for i in range(N):
        a = A[i]
        t = x // F[i]
        if t < a:
            result += a - t
    return result <= K

N,K = map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
ok=A[-1]*F[0]
ng=-1
while(ng+1<ok):
  c=ng+(ok-ng)//2
  if is_ok(c):
    ok=c
  else:
    ng=c

print(ok)
Buggy code:
import numpy as np

a,b=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())),reverse=True))

s=A.sum()

x=-1
y=10**12
while x+1<y:
  mid=(x+y)//2
  if s-np.minimum(A,mid//F).sum()<=K:
    x=mid
  else:
    y=mid
print(mid)

Fixed code:
import numpy as np

a,b=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())),reverse=True))

s=A.sum()

x=-1
y=10**12
while x+1<y:
  mid=(x+y)//2
  if s-np.minimum(A,mid//F).sum()<=b:
    y=mid
  else:
    x=mid
print(y)
Buggy code:
import math
n, k = map(int, input().split())
# a = [int(x) for x in input().split()]
# f = [int(x) for x in input().split()]
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
lx = 0
rx = a[-1] * f[0]
while(rx-lx>1):
    cx = (lx + rx) // 2
    kk = 0
    for j in range(n):
        ta = a[j]
        y = (ta*f[j] - cx + f[j] -1) // f[j]
        kk += max(0, y)
    if kk <= k:
        rx = cx
    else:
        lx = cx
print(rx)

Fixed code:
n, k = map(int, input().split())
# a = [int(x) for x in input().split()]
# f = [int(x) for x in input().split()]
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
lx = -1
rx = a[-1] * f[0]
while rx-lx>1 :
    cx = (lx + rx) // 2
    kk = 0
    for j in range(n):
        kk += max(0, a[j] - cx//f[j])
    if kk <= k:
        rx = cx
    else:
        lx = cx
print(rx)
Buggy code:
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()
f.sort()
a = a[::-1]
left = -1
right = np.max(a * f)
while left + 1 < right:
    mid = (left + right) // 2
    print(np.sum(np.maximum(a - mid // f, 0)))
    if np.sum(np.maximum(a - mid // f, 0)) <= k:
        right = mid
    else:
        left = mid

print(right)


Fixed code:
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()
f.sort()
a = a[::-1]
left = -1
right = np.max(a * f)
while left + 1 < right:
    mid = (left + right) // 2
    if np.sum(np.maximum(a - mid // f, 0)) <= k:
        right = mid
    else:
        left = mid

print(right)
Buggy code:
from math import ceil
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


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

low = 0
high = A[-1]*F[0]

while low <= high:
    mid = (low+high)//2
    train = K
    for a, f in zip(A, F):
        if a*f > mid:
            need_train = ceil((a*f-mid)/a)
            if train >= need_train:
                train -= need_train
            else:
                low = mid+1
                break
    else:
        high = mid-1
print(mid)


Fixed code:
from math import ceil
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


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

low = 0
high = A[-1]*F[0]

while low <= high:
    mid = (low+high)//2
    train = K
    for a, f in zip(A, F):
        if a*f > mid:
            need_train = ceil((a*f-mid)/f)
            if train >= need_train:
                train -= need_train
            else:
                low = mid+1
                break
    else:
        high = mid-1
print(low)
Buggy code:
import math
import numpy as np


def main():
    s = input().split(" ")
    N = int(s[0])
    K = int(s[1])
    A = np.array([int(a) for a in input().split(" ")])
    F = np.array([int(a) for a in input().split(" ")])
    A = np.sort(A)
    F = np.sort(F)[::-1]
    AF = A * F
    m = np.max(AF)

    if(func(0, AF, F, N, K)):
        print(0)
        return
    a = 0
    b = m
    for aaa in range(m):
        if((b - a) <= 1):
            print(b)
            return
        mid = int((b - a) / 2.) + a
        if(func(mid, AF, F, N, K)):
            b = mid
        else:
            a = mid
    print("???????")


def func(saidai, AF, F, N, K):
    count = np.sum((AF[(AF - saidai) > 0] - saidai) // F[(AF - saidai) > 0])
    return count <= K


if(__name__ == "__main__"):
    main()


Fixed code:
import math
import numpy as np


def main():
    s = input().split(" ")
    N = int(s[0])
    K = int(s[1])
    A = np.array([int(a) for a in input().split(" ")])
    F = np.array([int(a) for a in input().split(" ")])
    A = np.sort(A)
    F = np.sort(F)[::-1]
    AF = A * F
    m = np.max(AF)

    if(func(0, AF, F, N, K)):
        print(0)
        return
    a = 0
    b = m
    for aaa in range(m):
        if((b - a) <= 1):
            print(b)
            return
        mid = int((b - a) / 2.) + a
        if(func(mid, AF, F, N, K)):
            b = mid
        else:
            a = mid
    print("???????")


def func(saidai, AF, F, N, K):
    count = np.sum(np.ceil((AF[(AF - saidai) > 0] - saidai) / F[(AF - saidai) > 0]))
    return count <= K


if(__name__ == "__main__"):
    main()
Buggy code:
import numpy as np
N, train_max = map(int, input().split())
members = np.sort(list(map(int, input().split())))
members_sum = members.sum()
foods = np.sort(list(map(int, input().split())))[::-1]

inferenced_time_max = int(1e+6 * 1e+6)
inferenced_time_min = 1

while inferenced_time_max > inferenced_time_min + 1:
  inferenced_time = (inferenced_time_max + inferenced_time_min) // 2
  inferenced_members = np.minimum(members, inferenced_time // foods)
  if members_sum - inferenced_members.sum() <= train_max:
    inferenced_time_max = inferenced_time
  else:
    inferenced_time_min = inferenced_time

print(inferenced_time_max)


Fixed code:
import numpy as np
N, train_max = map(int, input().split())
members = np.sort(list(map(int, input().split())))
members_sum = members.sum()
foods = np.sort(list(map(int, input().split())))[::-1]

inferenced_time_max = int(1e+6 * 1e+6)
inferenced_time_min = -1

while inferenced_time_max > inferenced_time_min+1:
  inferenced_time = (inferenced_time_max + inferenced_time_min) // 2
  inferenced_members = np.minimum(members, inferenced_time // foods)
  if members_sum - inferenced_members.sum() <= train_max:
    inferenced_time_max = inferenced_time
  else:
    inferenced_time_min = inferenced_time

print(inferenced_time_max)