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