Count runs that sum to k

Write count_runs(nums, k) that returns how many runs of consecutive items (of length at least one) sum to exactly k. Values may be negative.

count_runs([1, 1, 1], 2)        ->  2
count_runs([1, 2, 3], 3)        ->  2     ([1, 2] and [3])
count_runs([1, -1, 1, -1], 0)   ->  4

The point is to practise prefix sums in a dictionary: a run ending here sums to k when an earlier prefix equals the current prefix minus k. One check has a hundred thousand items.

def count_runs(nums, k):
    ...