Use print(flush=True)
Import names from heapq directly