Problem:
Score : 200 points

Problem Statement

We have a board with H horizontal rows and W vertical columns of squares.
There is a bishop at the top-left square on this board.
How many squares can this bishop reach by zero or more movements?

Here the bishop can only move diagonally.
More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:

r_1 + c_1 = r_2 + c_2

r_1 - c_1 = r_2 - c_2

For example, in the following figure, the bishop can move to any of the red squares in one move:

Constraints

1 \leq H, W \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

H \ W

Output

Print the number of squares the bishop can reach.

Sample Input 1

4 5

Sample Output 1

10

The bishop can reach the cyan squares in the following figure:

Sample Input 2

7 3

Sample Output 2

11

The bishop can reach the cyan squares in the following figure:

Sample Input 3

1000000000 1000000000

Sample Output 3

500000000000000000

Solution in Rust (1.15.1) (judge verdict: Runtime Error)

use std::io;
fn main() {
    let mut l1 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    let trimed = l1.trim_right();
    let mut itr = trimed.split_whitespace();
    let h = itr.next().unwrap().parse::<usize>().unwrap();
    let w = itr.next().unwrap().parse::<usize>().unwrap();

    let mut v: Vec<Vec<i32>> = vec![vec![Default::default(); w]; h];

    let mut a: usize;
    if h < w {
        a = w;
    } else {
        a = h;
    }

    let mut x: i32 = 0;
    let mut y: i32 = 0;
    v[0][0] = 1;
    assinOne(a as i32, x, y, &mut v, h as i32, w as i32);

    let mut ans = 0;
    let mut xa = 0;
    for v1 in v {
        let mut ya = 0;
        for v2 in v1 {
            if v2 == 1 {
                ans += 1;
            }
            ya += 1;
        }
        xa += 1;
    }
}

fn assinOne(count: i32, x: i32, y: i32, v: &mut Vec<Vec<i32>>, h: i32, w: i32) {
    if count < 0 {
        return;
    }
    let x1 = x + 1;
    let y1 = y + 1;
    if 0 <= x1 && x1 < h && 0 <= y1 && y1 < w {
        println!("(x1,y1)=({},{})", x1, y1);
        v[x1 as usize][y1 as usize] = 1;
    }
    assinOne(count - 1, x1, y1, v, h, w);

    let x2 = x + 1;
    let y2 = y - 1;
    if 0 <= x2 && x2 < h && 0 <= y2 && y2 < w {
        println!("(x2,y2)=({},{})", x2, y2);
        v[x2 as usize][y2 as usize] = 1;
    }
    assinOne(count - 1, x2, y2, v, h, w);

    let x3 = x - 1;
    let y3 = y - 1;
    if 0 <= x3 && x3 < h && 0 <= y3 && y3 < w {
        println!("(x3,y3)=({},{})", x3, y3);
        v[x3 as usize][y3 as usize] = 1;
    }
    assinOne(count - 1, x3, y3, v, h, w);

    let x4 = x - 1;
    let y4 = y + 1;
    if 0 <= x4 && x4 < h && 0 <= y4 && y4 < w {
        println!("(x4,y4)=({},{})", x4, y4);
        v[x4 as usize][y4 as usize] = 1;
    }
    assinOne(count - 1, x4, y4, v, h, w);
}