#!/usr/bin/ruby N,X,Y,*A=`dd`.split.map &:to_i B=[] s=0 (1...1<0} q=Y/r-(X-1)/r if d==2 B<0 s+=q else s-=q end } B.uniq! (1...1<0} q=Y/r-(X-1)/r if d%2>0 s-=q else s+=q end } p s