Buggy python submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    if(n == 1):
        print(MA//k)
        return
    while(True):
        m = mi + (MA - mi)//2
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 0):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m
        





if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0 or n == 1):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 0):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m
        





if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 0):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m
        





if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]//2
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        #print(mi,m,MA)
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1
        




if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 0):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m
        





if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]//2
    while(True):
        m = mi + (MA - mi)//2 if (MA - mi)%2 == 0 else mi + (MA-mi)//2 + 1
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(m)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1




if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 0):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m
        





if __name__ == "__main__":
    main()