问题描述:
Write a function to find the top k integers that occur most frequently from given lists of sorted and distinct integers using heap queue algorithm.

测试用例:
['assert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]],3)==[5, 7, 1]', 'assert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]],1)==[1]', 'assert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]],5)==[6, 5, 7, 8, 1]']

生成的代码:
from collections import Counter
import heapq

def func(lists, k):
    counter = Counter()
    for sublist in lists:
        counter.update(sublist)
    
    return [num for num, _ in heapq.nlargest(k, counter.items(), key=lambda x: x[1])]