ll@n,@m,@a[n],@b[m],@c[n],d,e=0; mapf; rep(i,n){ e>?=f[d-a[i]]+=c[i]; d+=b[i%m]; } wt(sum(c(n))-e);