eval'N,K,*A='+`dd`.split*?, r=0 N.times{(N-K).times{|i|A[i],A[i+K]=A[i+K],A[i]if A[i]>A[i+K]&&r+=1}} p (1...N).all?{|i|A[i-1]