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 Haskell (GHC 7.10.3) (judge verdict: Runtime Error)

import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
  ah <- BS.unpack <$> BS.getLine :: IO String
  bh <- BS.unpack <$> BS.getLine :: IO String
  ch <- BS.unpack <$> BS.getLine :: IO String
  let table = (P A ah, P B bh, P C ch)
  putStr $ game table A

type Hands = String 
type Card = Char
data Name = A | B | C deriving Show
data Player = P Name Hands deriving Show
type Table = (Player, Player, Player)

class Play p where
  nextCard :: p -> Maybe Card
  nextHands :: p -> Hands

instance Play Player where
  nextCard (P _ "") = Nothing
  nextCard (P _ (x:_)) = Just x
  nextHands (P _ "") = ""
  nextHands (P _ (_:xs)) = xs
  
showNext :: Maybe Char -> Name
showNext (Just 'a') = A
showNext (Just 'b') = B
showNext (Just 'c') = C

game :: Table -> Name -> String
game (a,b,c) A 
  | isNothing (nextCard a) = "A"
  | otherwise = game (P A hands, b, c) (showNext card)
    where card = nextCard a
          hands = nextHands a
game (a,b,c) B
  | isNothing (nextCard b) = "B"
  | otherwise = game (a, P B hands, c) (showNext card)
    where card = nextCard b
          hands = nextHands b
game (a,b,c) C
  | isNothing (nextCard c) = "C"
  | otherwise = game (a, b, P C hands) (showNext card)
    where card = nextCard c
          hands = nextHands c