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



Sample input:
4 5


Sample output:
10

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    h, w = [int(s) for s in input().strip().split()]
    if h == 1 or w == 1:
        print(1)
        return
    result = h * (w // 2) + (w % 2) * (h + 1) // 2
    print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
if H > 1 and W > 1:
    print((H * W) // 2 + (H * W) % 2)
else:
    print(1)

Submission status: Accepted

Solution code:
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

H, W = map(int, input().split())
if H >= 2 and W >= 2:
    ans = math.ceil(H / 2) * math.ceil(W / 2) + (H // 2) * (W // 2)
else:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
import sys

h,w = map(int, input().split())

all = h*w

if h == 1 or w == 1:
    print(1)
    sys.exit()


if all % 2 == 0:
    ans = all//2
else:
    ans = all//2+1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    h, w = list(map(int, input().strip().split()))
    if h == 1 or w == 1:
        print(1)
    else:
        print((h * w + 1) // 2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import ceil
H, W = map(int,input().split())
if H == 1 or W == 1: print(1)
else: print(ceil(H/2)*ceil(W/2)+(H//2)*(W//2))

Submission status: Accepted

Solution code:
h,w = map(int,input().split())

if h == 1 or w == 1:
    print(1)
else:
    print((h*w+1)//2)

Submission status: Accepted

Solution code:
import math
x,y = map(int,input().split())
if x == 1 or y == 1:
  print(1)
else:
  print(math.ceil(x * y /2))

Submission status: Accepted

Solution code:
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(-(-H*W//2))

Submission status: Accepted

Solution code:
import sys

H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
    sys.exit()
ans = -(-(H * W) // 2)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():
     h, w = map(int, input().split())

     if h == 1 or w == 1:
          ans = 1
     else:
          ans = ((h * w) + 1) // 2
     
     print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    h, w = map(int, input().split())

    if h == 1 or w == 1:
        print(1)
    else:
        print(int(w * (h/2)) if h % 2 == 0 else int(w*(h//2) + (w+1)//2))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
H, W = list(map(int, input().split()))
n1 = None
n2 = None
if W % 2 == 0:
    n1 = W // 2
    n2 = n1
else:
    n1 = W // 2 + 1
    n2 = n1 - 1
o1 = None
o2 = None
if H % 2 == 0:
    o1 = H // 2
    o2 = H // 2
else:
    o1 = H // 2 + 1
    o2 = H // 2
if min(H, W) > 1:
    print(n1 * o1 + n2 * o2)
else:
    print(1)

Submission status: Accepted

Solution code:
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
else:
    Ho = H // 2
    He = H - Ho
    Wo = W // 2
    We = W - Wo
    print(Ho * Wo + He * We)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h,w = inpl()
if h == 1 or w == 1:
    print(1)
    quit()
if h%2 and w%2:
    print(h*w//2+1)
else:
    print(h*w//2)

Submission status: Accepted

Solution code:
# 2020/03/14
# パナソニックプログラミングコンテスト2020 - B

# Input
h, w = map(int,input().split())

# Calc
hw = h * w
if h == 1 or w == 1:
    ans = 1
else:
    if hw % 2 == 0:
        ans = hw // 2
    else:
        ans = hw // 2 + 1

# Output
print(ans)

Submission status: Accepted

Solution code:
import math
H, W = list(map(int, input().split()))

total = H * W
if(H > 1 and W > 1):
    print(math.ceil(total / 2))
else:
    print(1)

Submission status: Accepted

Solution code:
H,W = map(int,input().split())
if H==1:
  print(1)
else:
  if W==1:
    print(1)
  elif W==2:
    print(H)
  else:
    if W%2==0:
      print((W//2)*H)
    else:
      if H%2==0:
        print(((W//2)+1)*(H//2) + (W//2)*(H//2))
      else:
        print(((W//2)+1)*((H//2)+1) + (W//2)*(H//2))

Submission status: Accepted

Solution code:
H, W = map(int, input().split())

if (H == 1) | (W == 1):
    print(1)
else:
    print(((H+1)//2)*((W+1)//2) + ((H//2) *(W//2)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
    exit()
if (H * W) % 2 == 0:
    print((H * W) // 2)
else:
    print((H * W) // 2 + 1)

Submission status: Accepted

Solution code:
H, W = map(int, input().split())
if H >1 and W > 1:
    print(H*W-H*W//2)
else:
    print(1)

Submission status: Accepted

Solution code:
h, w = list(map(int, input().split(" ")))
if h != 1:
    if w != 1:
        ans = - (- (h * w) //2)
if h == 1:
    ans = 1
if w == 1:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
HW = list(map(int, input().split()))
H = HW[0]
W = HW[1]

if W==1 or H==1:
    A = 1
else:
    A = int((H+1)/2)*int((W+1)/2)+int((H)/2)*int((W)/2)
print(A)

Submission status: Accepted

Solution code:
import bisect, collections

def solution():
    h, w = [int(x) for x in input().strip().split(" ")]
    if w == 1 or h == 1:
        print(1)
    else:
        print(((h+1)//2)*((w+1)//2)+(h//2)*(w//2))
    



def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Submission status: Accepted

Solution code:
h,w = [int(x) for x in input().split()]

if h == 1 or w == 1:
    print(1)
elif h % 2 == 0 or w % 2 == 0:
    print((h*w)//2)
else:
    print(((h*w)//2)+1)

Submission status: Accepted

Solution code:
import math

h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    exit()

mini_w = int(w/2)
maxi_w = math.ceil(w/2)
mini_h = int(h/2)
maxi_h = math.ceil(h/2)
print(maxi_w*maxi_h + mini_w*mini_h)

Submission status: Accepted

Solution code:
h,w = map(int,input().split())

oneloop = w

rest = (w-w//2)

if h == 1 or w == 1:
    print(1)
else:
    if h%2 == 0:
        print(oneloop*(h//2))
    else:
        print(oneloop*(h//2)+rest)

Submission status: Accepted

Solution code:
h,w = map(int,input().split())
x = h*w
if h == 1 or w == 1 :
    print(1)
elif x % 2 == 0:
    print(x//2)
else :
    print(x//2+1)

Submission status: Accepted

Solution code:
H, W = map(int, input().rstrip().split())
tmp = H * W
if H == 1 or W == 1:
    print(1)
elif tmp % 2 == 0:
    print(int(tmp / 2))
else:
    print(int((tmp - 1) / 2 + 1))

Submission status: Accepted

Solution code:
H,W=map(int,input().split())

if H!=1 and W!=1:
    h_1=-(-H//2)
    h_2=H//2

    answer=W//2*(h_1+h_2)

    if W%2==1:
        answer+=h_1
else:
    answer=1

print(answer)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import math

def solve():
    H, W = list(map(int, input().split()))

    if H==1 or W==1:
        print(1)
        return

    odd = math.ceil(H/2)
    even = H//2

    ans = odd*math.ceil(W/2) + even*(W//2)
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
h, w = list(map(int, input().split()))
masu = h * w
ans = 0
if h >= 2 and w >= 2:
    if masu % 2 == 0:
        ans = masu/2
    else:
        ans = (masu+1)/2
else:
    ans = 1
print(int(ans))

Submission status: Accepted

Solution code:
h, w = [int(x) for x in input().split()]
if h == 1 or w == 1:
    res = 1
else:
    if w%2 == 0:
        res = h * w // 2
    else:
        res = h * (w//2) + (h + 2 - 1)//2
print(res)

Submission status: Accepted

Solution code:
H, W = map(int, input().split())

a, b = divmod(H*W, 2)

if H==1 or W==1:
    print(1)
else:
    if b==0:
        print(a)
    else:
        print(a+1)

Submission status: Accepted

Solution code:
a=input().split()
H,W=int(a[0]),int(a[1])
if(H==1 or W==1):
  print(1)
elif(H*W%2==0):
  print(int(H*W/2))
else:
  print(int(H*W/2+1))

Submission status: Accepted

Solution code:
#!python3.4.3

h, w = map(int, input().split(' '))

s = h * w

if h == 1 or w == 1:
  print(1)
  exit()

if s%2 == 0:
  print(s//2)
else:
  print(s//2 + 1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def linput():
    return list(map(int, input().split()))

def main():
    # N = int(input())
    N,M = linput()
    # vA = linput()
    # S = input()
    # mX = [linput() for _ in [0,]*N]

    # res = 0
    if N%2 and M%2:
        res = -(-N*M//2)
    else:
        res = N*M//2

    if N==1 or M==1:
        res = 1

    print(res)

main()

Submission status: Accepted

Solution code:

h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
    exit()
print(-(-h * w // 2))

Submission status: Accepted

Solution code:
import math
H, W = map(int, input().split())
if (H == 1)|(W==1):
    print('1')
else:
    print(math.ceil(H*W/2))

Submission status: Accepted

Solution code:
H,W=map(int,input().split(' '))
if H==1 or W==1:
    print(1)
    exit()
if H%2==0:
    print(H*W//2)
else:
    print(W*(H-1)//2-(-W//2))

Submission status: Accepted

Solution code:
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
else:
    if H*W % 2 == 0:
        print(H*W//2)

    else:
        print(H*W//2+1)

Submission status: Accepted

Solution code:
[H,W] = [int(s) for s in input().rstrip().split(' ')]
if H == 1 or W == 1:
  print(1)
elif H*W % 2 == 0:
  print(H*W // 2)
else:
  print(H*W // 2 + 1)

Submission status: Accepted

Solution code:
H, W = map(int, input().split())
if H == 1 and W > 1 or W == 1 and H > 1:
  print('1')
else:
  print(int(H*W/2+0.5))

Submission status: Accepted

Solution code:
import math
h,w = map(int,input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil(h*w/2))

Submission status: Accepted

Solution code:
import math 
h, w = map(int, input().split())
if h ==1 or w == 1:
    print(1)
    exit()
s =h* w
if s%2 ==1:
    print(int(math.ceil(s/2)))
else:
    print(int(s/2))

Submission status: Accepted

Solution code:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

H,W = splitintinput()

if H == 1 or W == 1:
    print(1)
    exit()
if H % 2 == 0:
    print(int(H*W/2))
else:
    print(int((H-1)*W/2 + math.ceil(W/2)))

Submission status: Accepted

Solution code:
H,W = list(map(int,input().split()))
if H == 1 or W == 1:
  print(1)
else:
	print( (H//2) * W + ((W+1)//2 if H%2==1 else 0 ))

Submission status: Accepted

Solution code:
h,w = map(int,input().split())

ans = 0
if h ==1 or w ==1:
	print(1)
elif h%2 != 0 and w %2 != 0:
	ans += (w//2+1)*(h//2+1)
	ans += (w//2)*(h//2)
	print(ans)
else:
	print(h*w//2)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    H,W=map(int,readline().split())

    if H==1:
        print(1)
    elif W==1:
        print(1)
    elif H%2==0:
        print(H*W//2)
    elif H%2==1:
        if W%2==0:
            print(H*W//2)
        elif W%2==1:
            print((H//2)*(W//2)+(H//2+1)*(W//2+1))
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
h,w = map(int,readline().split())

if h ==1 or w==1:
    print(1)
    exit()

if h%2==0:
    print((h//2)*w)
else:
    if w%2==0:
        print((h//2)*(w//2)+(h//2+1)*(w//2))
    else:
        print((h//2+1)*(w//2+1)+(h//2)*(w//2))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
if a == 1 or b == 1:
  print(1)
else:
  print(a*b//2 if a*b %2 == 0 else a*b//2+1)

Submission status: Accepted

Solution code:
import math

H, W = list(map(int, input().split()))

if H == 1 or W == 1:
    print(1)
else:
    x = (H//2)*W
    y = (H%2)*math.ceil(W/2)
    
    print(x+y)

Submission status: Accepted

Solution code:
H,W =map(int,input().split())

if H==1 or W==1:
    print(1)
else:
    print((H*W+1)//2)

Submission status: Accepted

Solution code:
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
else:
    if (h + w) % 2 == 0:
        print((h * w + 1) // 2)
    else:
        print((h * w) // 2)

Submission status: Accepted

Solution code:
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    ans = ((w+1) // 2) * ((h+1) // 2)
    ans += (w // 2) * (h // 2)
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

H,W = map(int,input().split())
ans = H*(W//2)
if W%2==1:
    ans += (H+1)//2
if H==1 or W==1:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    exit()

if h % 2 == 0 or w % 2 == 0:
    ans = h * w // 2
else:
    ans = h * w // 2 + 1

print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

H,W = imn()

if H == 1 or W == 1:
    print(1)
else:
    print(math.ceil(H*W/2))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    H,W=pin()
    if H>1 and W>1:
        print((H*W+1)//2)
    else:
        print(1)
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 5"""
        output = """10"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """7 3"""
        output = """11"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1000000000 1000000000"""
        output = """500000000000000000"""
        self.assertIO(input, output)
if __name__=="__main__":resolve()

Submission status: Accepted

Solution code:
H,W = map(int,input().split())
if H==1 or W==1:
    print(1)
else:
    print((H*W+1)//2)

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

H, W = LI()

print(1 if H == 1 or W == 1 else math.ceil(H*W/2))

Submission status: Accepted

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

H, W = MAP()

ans = 0
if H == 1 or W == 1:
    ans = 1
elif W % 2 == 0:
    ans = (W//2) * H
else:
    if H % 2 == 0:
        ans = ((W+1)//2 * (H//2)) + (((W+1)//2-1) * (H//2))
    else:
        ans = ((W+1)//2 * ((H+1)//2)) + (((W+1)//2-1) * (H//2))


print(ans)

Submission status: Accepted

Solution code:
H,M=map(int,input().split())
if H!=1 and M!=1:
  if (H*M)%2==0:
    print(H*M//2)
  else:
    print((H*M)//2+1)
else:
  print(1)

Submission status: Accepted

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w = inm()
p = h*w
if h==1 or w==1:
    print(1)
else:
    print(p//2 + (1 if p%2==1 else 0))

Submission status: Accepted

Solution code:
H, W = map(int, input().split())

a = (W + 1) // 2
b = W // 2

if (H == 1 or W == 1):
    x = 1
elif H % 2 == 0:
    x = (a + b) * H // 2
else:
    x = a * ((H // 2) + 1) + b * (H // 2)

print(x)

Submission status: Accepted

Solution code:
import math
a,b=map(int,input().split())

if a == 1 or b ==1:
  print(1)
else:
  print(math.ceil(a*b /2))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    h, w = map(int, input().split())

    if h == 1 or w == 1:
        print(1)
    elif h % 2 == 0 or w % 2 == 0:
        print(h * w // 2)
    else:
        print((h*w+1) // 2)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

h,w=mii()

if h==1 or w==1:
    print(1)
    exit()

if (h*w)%2==0:
    print(h*w//2)
else:
    print((h*w)//2 +1)

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


HW = inpl()
HW.sort()
if HW[0] == 1:
    print(1)
    exit()
print(HW[0] * HW[1] // 2 + int(HW[0] % 2 == 1 and HW[1] % 2 == 1))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
H, W = [int(x) for x in input().strip().split()]
if H == 1 or W == 1:
    print(1)
else:
    print((H // 2 + H % 2) * (W // 2 + W % 2) + (H // 2) * (W // 2))

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import math
import sys
input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

def main():
  h, w = map(int, input().split())
  ans = 0
  if h==1 or w==1:
    ans = 1
  else:
    ans = (h*w+1)//2
  print(ans)
  

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
H, W = map(int,input().split()) # 複数の数字を変数に格納

import math

if H == 1 or W == 1:
    print(1)
else:
    print(math.ceil(H*W/2))

Submission status: Accepted

Solution code:
H, W = [int(s) for s in input().split()]
if H == 1 or W == 1:
  print(1)
elif H%2 == 1 and W%2 == 1:
  print(H*W//2 + 1)
else:
  print(H*W//2)

Submission status: Accepted

Solution code:
def sol(h, w):
    if h == 1 or w == 1:
        return 1
    a = (w+1) // 2
    b = w // 2
    res = (a+b) * (h//2)
    if h & 1:
        res += a
    return res

def main():
    h, w = map(int, input().split())
    print(sol(h, w))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
h, w = map(int, input().split())
if h == 1 or w == 1:
    ans = 1
else:
    ans = math.ceil(h*w/2)
print(ans)

Submission status: Accepted

Solution code:
import math
 
H,W = map(int,input().split())

if(H==1 or W==1):
  print(1)
else:
  print(math.ceil(H*W/2))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = a*b
if a == 1 or b == 1:
    print(1)
else:
    if c%2 == 0:
        print(c//2)
    else:
        print(c//2 + 1)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
k = a[0] * a[1]
if a[0]==1 or a[1] ==1:
  print(1)
elif k % 2 == 0:
  print(k//2)
else:
  print((k // 2) + 1)

Submission status: Accepted

Solution code:
h,w =  map(int, input().split())

if (h == 1) or (w == 1):
    print(1)
elif (h*w)%2==0:
    print(int((h*w)/2))
else:
    print(int(((h*w)+1)/2))

Submission status: Accepted

Solution code:
h,w = map(int,input().split())

if h==1 or w==1:
    print(1)
elif (h*w)%2 == 0:
    print(int(h*w/2))
else:
    print(int(h*w/2+1))

Submission status: Accepted

Solution code:
h,w= list(map(int, input().split()))
a=h*w
if h == 1 or w==1:
    print("1")
    exit(0)
if a%2==0:
    print(a//2)
else:
    print(a//2+1)

Submission status: Accepted

Solution code:
import sys
import math
import collections
from collections import deque
#k = int(input())
h, w = map(int, sys.stdin.readline().split())
#s = input()
#x = sys.stdin.readline().split()
if h != 1 and w != 1:
    print(math.ceil(h*w/2))
else:
    print(1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8


def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    h, w = rli()
    if h == 1 or w == 1:
        print(1)
        return
    ans = (h*w)//2
    if (h*w%2 == 1): ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

H, W = map(int, input().split())
if W == 1 or H == 1:
    print(1)
elif H % 2 == 0:
    print(W * (H // 2))
else:
    print(W * (H // 2) + math.ceil(W / 2))

Submission status: Accepted

Solution code:
h,w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
elif h % 2 == 0:
    print(int(h*w/2))
else:
    if w % 2 == 0:
        print(int(h*w/2))
    else:
        print(int(h*w//2 + 1))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

H, W = map(int, readline().split())
ans = 0
if H == 1 or W == 1:
    ans = 1
else:
    ans = -(-H*W//2)
    
print(ans)

Submission status: Accepted

Solution code:
H, W = map(int, raw_input().split())
if H==1 or W==1:
  print 1
else:
  print (H*W+1)/2

Submission status: Accepted

Solution code:
H, W = map(int, input().split())
if H == 1 or W == 1:
  print(1)
else:
  print((H*W+1)//2)

Submission status: Accepted

Solution code:
h,w = list(map(int,input().split()))
l,m = 0,0
if h % 2 == 1:
    l = h // 2 + 1
else:
    l = h // 2
if w % 2 == 1:
    m = w // 2 + 1
else:
    m = w // 2
if h == 1 or w == 1:
    print(1)
else:
    print(w*h - l * (w // 2) - m * (h // 2))

Submission status: Accepted

Solution code:
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
else:
    print((h*w+1)//2)

Submission status: Accepted

Solution code:
import math
h, w = map(int, input().split())
if h == 1 or w == 1:
  print(1)
else:
  print(math.ceil(h * w / 2))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    ans=W*(H//2)
    if H%2:
        ans+=-(-W//2)
    if H==1 or W==1:
        print(1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    exit()


if (h*w) % 2 == 0:
    print(h * w // 2)
else:
    print(h*w//2 + 1)

Submission status: Accepted

Solution code:
import math
h, w = list(map(int,input().split()))
if h != 1 and w != 1:
	print(math.ceil((h*w)/2))
else:
	print(1)

Submission status: Accepted

Solution code:
import math
w,h=map(int, input().split())
###
if w == 1 or h == 1:
    print(1)
else:
    print(math.ceil(w*h/2))

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor
h, w  =[int(i) for i in sys.stdin.readline().split()]
if h == 1 or w == 1:
    print(1)
else:
    print(ceil(h / 2) * ceil(w / 2) + (h - ceil(h / 2)) * (w - ceil(w / 2)))

Submission status: Accepted

Solution code:
H,W = list(map(int,input().split()))

if H==1 or W==1:
    print(1)
else:
    if H%2==0 or W%2==0:
        print((H*W)//2)
    else:
        print((H*W+1)//2)

Submission status: Accepted

Solution code:
h, w = map(int, input().split())

if h == 1 or w == 1:
  print(1)
elif h*w%2 == 0:
  print(h*w//2)
else:
  print(h*w//2+1)

Submission status: Accepted

Solution code:
H,W = list(map(int,input().split()))
t = H*W


if H ==1 or W ==1:
    print(1)
else:
    if t%2==0:
        print(t//2)
    else:
        print(t//2+1)

Submission status: Accepted

Solution code:
import sys
H,W=map(int,input().split())
if H>W:
    H,W=W,H
if H==1:
    print(1)
    sys.exit()
num=H*W
if num%2==0:
    print(num//2)
else:
    print(num//2+1)