gets GET_NUMBERS = gets.split.map(&:to_i) PAIR_STRING = GET_NUMBERS.group_by{|e|e}.map { |k, v| v.size }.reverse.join(" ") puts PAIR_STRING