GoalScope — k_smallest_pairs (Qwen2.5-Coder-32B-Instruct) — hover a token to see the patched verbalization
↵
<code>↵
def k_smallest_pairs(nums1, nums2, k):↵
"""Find k pairs with smallest sums."""↵
import heapq↵
if not nums1 or not nums2 or k <= 0:↵
return []↵
min_heap = []↵
def push(i, j):↵
if i < len(nums1) and j < len(nums2):↵
heapq.heappush(min_heap, [nums1[i] + nums2[j], i, j])↵
push(0, 0)↵
pairs = []↵
while min_heap and len(pairs) < k:↵
_, i, j = heapq.heappop(min_heap)↵
pairs.append([nums1[i], nums2[j]])↵
push(i, j + 1)↵
if j == 0:↵
push(i + 1, 0)↵
return pairs↵
</code>