How to rewrite this one-liner as generator which returns k elements

How would you rewrite the following sliding window code using generator?

My issue is that each iteration I want to consume k=100 elements or the number of elements left.

n=1005
m=5 
step=2
a=[(i,j) for i in range(0,n-m+1,step) for j in range(0,n-m+1,step) if i<j]