<commit_before># https://leetcode.com/problems/merge-k-sorted-lists/
import heapq
class Solution(object):
    def mergeKLists(self, lists):
        """
        :type lists: List[ListNode]
        :rtype: ListNode
        """
        pq = []
        for head in lists:
            if head != None:
                heapq.heappush(pq, (head.val, head))

        sentinel = ListNode(None)
        curr = sentinel
        while len(pq) > 0:
            node = heapq.heappop(pq)[1]
            if node.next:
                heapq.heappush(pq, (node.next.val, node.next))
            curr.next = node
            curr = curr.next
        return sentinel.next<commit_msg>comments are added for clarity<commit_after># https://leetcode.com/problems/merge-k-sorted-lists/
import heapq
class Solution(object):
    def mergeKLists(self, lists):
        """
        :type lists: List[ListNode]
        :rtype: ListNode
        """
        pq = []
        for head in lists:
            if head != None:
                # push all heads of every list into our PriorityQueue
                # push in a tuple s.t it can be sorted by the first elem of
                # the tuple
                heapq.heappush(pq, (head.val, head))

        sentinel = ListNode(None)
        curr = sentinel
        # when there are still things to add in PQ
        while len(pq) > 0:
            # get the smallest node in PQ
            node = heapq.heappop(pq)[1]
            # if node has a next node, add it to our PQ to be processed later
            if node.next:
                heapq.heappush(pq, (node.next.val, node.next))
            curr.next = node
            curr = curr.next
        return sentinel.next
{'fraction_non_alphanumeric': 0.09834123222748815, 'fraction_numerical': 0.002369668246445498, 'mean_word_length': 1.5944700460829493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5923838', 'n_tokens_mistral': 523, 'n_tokens_neox': 492, 'n_words': 148}