class Powerup attr_reader :n, :abc def initialize(n: 0, abc: []) @n, @abc = n, abc end def cause begin @n = Integer(gets.chomp) @abc = @n.times.map { gets.chomp.split.map { |v| Integer(v) } } rescue end end def powerup_cnt(array) powerup = 0 items = array.flatten.sort item_uniq = items.uniq item_uniq.each do |i| powerup += items.count(i)/2 if 2 <= items.count(i) end powerup += (items.size - (powerup*2)) / 4 powerup end def result puts powerup_cnt(@abc) end def run cause result end end if $0 == __FILE__ Powerup.new.run end