Snew=0 for i,(l,r) in enumerate(I): for s in range(l,r-47): Y=tuple(range(s,s+49)) t=(2*s-22715)%p if t in Y:continue x0=t*((p+1)//2)%p X=tuple(sorted([x0]+[(u-x0)%p for u in Y])) if len(set(X))==50 and X not in Z: Snew+=1 print('NEW49',i,s,t,flush=True) print('NEW49TOTAL',Snew,'Z',len(Z))