sum = 0 gets.to_i.times do a, b = gets.split.map(&:to_i) sum += (a/2.0).ceil * b end p sum