Problem:
Score : 100 points

Problem Statement

You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.

An example of a trapezoid

Find the area of this trapezoid.

Constraints

1≦a≦100

1≦b≦100

1≦h≦100

All input values are integers.

h is even.

Input

The input is given from Standard Input in the following format:

a
b
h

Output

Print the area of the given trapezoid. It is guaranteed that the area is an integer.

Sample Input 1

3
4
2

Sample Output 1

7

When the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.

Sample Input 2

4
4
4

Sample Output 2

16

In this case, a parallelogram is given, which is also a trapezoid.

Solution in Ruby (2.3.3) (judge verdict: Runtime Error)

lines = $stdin.read

def gen_square(a,b,h,w)
  [
    [a-2,b-2],[a-1,b-2],[a,b-2],
    [a-2,b-1],[a-1,b-1],[a,b-1],
    [a-2,b  ],[a-1,b  ],[a,b  ],
  ].select do |elem|
    elem[0] >= 0 and elem[1] >= 0 and elem[0] < h-2 and elem[1] < w-2
  end
end

array = lines.split("\n")
H,W,N = array[0].split(" ").map(&:to_i)
ans = {}

array[1..N].each do |line|
  a,b = line.split(" ").map(&:to_i)
  a,b = a-1,b-1
  #puts "(#{a},#{b})"
  points = gen_square(a,b,H,W)
  #p points
  points.each do |coord|
    key = "#{coord[0]}-#{coord[1]}"
    if ans.has_key?(key)
      ans[key] += 1
    else
      ans[key] = 1
    end
  end
end

puts (H-2)*(W-2) - ans.length
(1..9).each do |n|
  puts ans.count{|k,v| v==n}
end