Buggy python submission (verdict: Time Limit Exceeded):
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys
import math
import heapq


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [(-float(i), 0, float(i)) for i in sys.stdin.readline().split()]
    heapq.heapify(logs)
    for _ in range(cut_count):
        curr_length, cuts, init_length = heapq.heappop(logs)
        curr_length, cuts = -curr_length, -cuts
        cuts += 1
        curr_length = init_length / (cuts + 1)
        heapq.heappush(logs, (-curr_length, -cuts, init_length))
    print(math.ceil(-logs[0][0]))


if __name__ == '__main__':
    main()

Fixed submission:
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys
from math import ceil


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [int(i) for i in sys.stdin.readline().split()]
    high = max(logs)
    low = 1
    soln = high
    # Binary search for the answer.
    while low <= high:
        mid = (low + high) // 2
        cuts_needed = sum([int(ceil(log / mid)) - 1 for log in logs])
        if cuts_needed <= cut_count:
            soln = min(soln, mid)
            high = mid - 1
        else:
            low = mid + 1
    print(soln)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys
import math
import heapq

class Log:
    def __init__(self, length):
        self.init_length = length
        self.curr_length = length
        self.cuts = 0

    def cut(self):
        self.cuts += 1
        self.curr_length = self.init_length / (self.cuts + 1)

    def __lt__(self, other):
        """Reversed, for heapq"""
        if self.curr_length == other.curr_length:
            return self.cuts > other.cuts
        else:
            return self.curr_length > other.curr_length


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [Log(float(i)) for i in sys.stdin.readline().split()]
    heapq.heapify(logs)
    for _ in range(cut_count):
        log = heapq.heappop(logs)
        log.cut()
        heapq.heappush(logs, log)
    print(math.ceil(logs[0].curr_length))


if __name__ == '__main__':
    main()


Fixed submission:
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys
from math import ceil


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [int(i) for i in sys.stdin.readline().split()]
    high = max(logs)
    low = 1
    soln = high
    # Binary search for the answer.
    while low <= high:
        mid = (low + high) // 2
        cuts_needed = sum([int(ceil(log / mid)) - 1 for log in logs])
        if cuts_needed <= cut_count:
            soln = min(soln, mid)
            high = mid - 1
        else:
            low = mid + 1
    print(soln)


if __name__ == '__main__':
    main()