class Calc0073 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @cs = args.map(&:first).map(&:to_i).map.with_index { |c, i| [(i + 'a'.ord).chr, c] }.to_h end def run rs = %w(h e w r d).map { |a| @cs[a] } rs += [calc_o, calc_l] rs.inject(:*) end def calc_o o = @cs['o'] if o < 2 0 else (1..(o / 2)).map { |k| k * (o - k) }.max end end def calc_l c = @cs['l'] if c < 3 0 else (2..(c - 1)).map { |k| (1..k).to_a.combination(2).size * (c - k) }.max end end end puts Calc0073.new(STDIN.readlines).run if __FILE__ == $0