hs={} gets x=gets.split.map{|e| e.to_i} x.each{|e| hs[e]=1 } hs2={} hs2[0]=0 cs=16.times.map{0} hs.keys.sort.each{|e| p1=32768 p2=15 while (p1&e)==0 p1/=2 p2-=1 end e2=(p1-1)&e hs3={} if hs2.key?(e)==false hs2.each{|k,v| hs3[k^e]=0 } cs[p2]+=1 end hs2.update(hs3) } puts hs2.size