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:
h, w = map(int, input().split())
if h == 1 or w == 1:
    ans = 1
elif h % 2 == 1:
    ans = (h - 1) // 2 * w + (w + 1) // 2
else:
    ans = h // 2 * w
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


num  = 1
if h != 1 and w != 1:
    num = ((w // 2) + (w % 2))*( (h // 2) + ( h% 2) ) + ((w // 2) + (w % 2)-(w%2))*( (h // 2) + (h%2) -(h%2)) 
print(num)

Submission status: Accepted

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

if h == 1 or w == 1:
    print(1)
else:
    print(-(-(h * w) >> 1))

Submission status: Accepted

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

Submission status: Accepted

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

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

if h == 1 or w == 1:
    ans = 1

print(int(ans))

Submission status: Accepted

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

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

if h % 2 == 1:
    ans += w // 2 + (w % 2)
print(ans)

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 = map(int, input().split())

if H == 1 or W == 1:
    print("1")
    exit()

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

Submission status: Accepted

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

i = h * w

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

if(i % 2 == 0):
    ans = i//2

elif (i % 2 == 1):
    ans = i//2 + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if H == 1 and W >= 1: print(1)
elif W == 1 and W >= 1: print(1)
else: print(W *(H//2) if H % 2 == 0 else W *(H//2) + a)

Submission status: Accepted

Solution code:
H,W=(int(x) for x in 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(int(h*w/2) + w*h%2)
else:
  print(1)

Submission status: Accepted

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

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

Submission status: Accepted

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

x = H * W

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    a, b = map(int, input().split())
    if a ==1 or b==1:
        print(1)
        exit()
    print((a*b+1)//2)
resolve()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
h, w = map(int, input().split())
ans = 0
if h == 1 or w == 1:
    ans = 1
else:
    if h % 2 == 0:
        ans = (h // 2) * w
    else:
        if w % 2 == 0:
            ans = (h // 2 + 1) * (w // 2) + (h // 2) * (w // 2)
        else:
            ans = (h // 2 + 1) * (w // 2 + 1) + (h // 2) * (w // 2)
print(ans)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
def main():
    h, w = map(int, input().split())
    ans = 0
    if h == 1 or w == 1:
        print(1)
        exit()
    
    if h % 2 == 0:
        ans = h * w // 2
    else:
        if w % 2 == 0:
            ans = h * w // 2
        else:
            ans = h * w // 2 + 1 
    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)
else:
  print((H*W+1)//2)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	h, w = MAP()
	if h > 1 and w > 1:
		print(ceil((h * w) / 2))
	else:
		print(1)

if __name__=='__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

panels = W * H

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    H, W = lr()
    a = H*W
    if H == 1 or W == 1:
        print(1)
    elif a%2 == 1:
        print((a+1)//2)
    else:
        print(a//2)
    return
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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 = map(int, input().split())

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

x = h*w
if x % 2 == 0:
  print(x//2)
else:
  print(x//2 + 1)
#print(math.ceil(h*w/2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

q = h * w // 2
r = h * w % 2

if h == 1 or w == 1:
    print("1")
else:
    print(q + r)

Submission status: Accepted

Solution code:
# Code for B - Bishop
# Use input() to fetch data from STDIN
from math import ceil
import sys
[H, W] = map(int, input().split())

if H <= 1:
    print(1)
    sys.exit(0)

if W <= 1:
    print(1)
    sys.exit(0)


print(ceil(H * W / 2))

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


H, W = MI()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


print(h*(w//2)+((h+1)//2)*(w%2))

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    if H == 1 or W == 1: print(1)
    else: 
        Ans = (H // 2 + H % 2) * (W // 2 + W % 2) + (H // 2) *  (W // 2)
        print(Ans)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
fx=0
sx=0
ans=0
if x%2==0:
  fx=x//2
  sx=x//2
else:
  fx=(x+1)//2
  sx=x-fx
  
if y%2==0:
  ans=(fx+sx)*y//2
else:
  ans=((fx+sx)*(y-1)//2)+fx
if x==1 or y==1:
  ans=1
print(ans)

Submission status: Accepted

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

if W % 2 == 0:
    x = W // 2
    y = W // 2
else:
    x = W // 2 + 1
    y = W // 2

if H % 2 == 0:
    ans = (x + y) * (H // 2)
else:
    ans = (x + y) * (H // 2) + x

if H == 1 or W == 1:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
H,W = map(int, input().split())
if W == 1 or H == 1:
  print(1)
else:
  print(int(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 and w%2==0:
    print(h*w//2)
if (h+w)%2!=0:
    print(h*w//2)
if h%2!=0 and w%2!=0:
    num=(min(h,w)+1)//2
    num1=(max(h,w)+1)//2
    ans=num*num1+(num1-1)*(min(h,w)-num)
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

Submission status: Accepted

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

up = (w + 1) // 2
down = w // 2

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

Submission status: Accepted

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

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

if h == 1 or w == 1:
    ans = 1

print(ans)

Submission status: Accepted

Solution code:
H,W = list(map(int,input().split()))
if H == 1 or W == 1:
    print(1)
elif H%2 == 1 & W%2 == 1:
    print((H*W)//2 + 1)
else:
    print((H*W)//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:

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:
    masu = int((H * W) / 2) + 1
    print(masu)

Submission status: Accepted

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

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

a=(h+1)//2
b=(h)//2
print(b*(w//2)+a*((w+1)//2))

Submission status: Accepted

Solution code:

h, w = map(int, input().split())
con = ((h * w) + 1) // 2

if min(h, w) == 1:
	print(1)
else:
	print(con)

Submission status: Accepted

Solution code:
H,W=map(int,input().split())
ww=-(-W//2)
w_=W-ww
hh=-(-H//2)
h_=H-hh

if (H==1 or W==1):
    print(1)
    exit()
print(ww*hh+w_*h_)

Submission status: Accepted

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

if h!=1 and w!=1:
    print((-(-h//2))*(-(-w//2))+(h//2)*(w//2))
else:
    print(1)

Submission status: Accepted

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

# 共に奇
if h == 1 or w == 1:
    print(1)
    exit(0)
if h % 2 == 1 and w % 2 ==1:
    print(int((h // 2 + 1) * (w // 2 + 1) + (h // 2) * (w // 2)))
    exit(0)
# 片方偶数
if h % 2 == 0 and w % 2 ==1:
    print(int((h // 2) * (w // 2 + 1) + (h // 2) * (w // 2)))
    exit(0)
if h % 2 == 1 and w % 2 ==0:
    print(int((h // 2 + 1) * (w // 2) + (h // 2) * (w // 2)))
    exit(0)
else:
    print(int(h * w / 2))
    exit(0)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

if 1 in [h, w]:
    print(1)
else:
    print(math.ceil((h * w) / 2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(int, input().split()))
if s[0]!=1 and s[1]!=1:
    i=(s[0]*s[1]+(s[0]%2)*(s[1]%2))/2
    print(int(i))
else:
    print(1)

Submission status: Accepted

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

def judge(H, W):
    if H == 1 or W == 1:
        return 1
    elif (H * W) % 2 == 1:
        return int(H * W // 2) + 1
    else: 
        return int(H * W / 2)
    
print(judge(H, W))

Submission status: Accepted

Solution code:
h, w = list(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*w % 2 == 1 or 0 < h*w % 2 < 1:
    ans = (h*w//2) + 1
else:
    ans = h*w//2

if h > 1 and w == 1:
    ans = 1
elif w > 1 and h == 1:
    ans = 1

print(ans)

Submission status: Accepted

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

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

elif (H*W) % 2 == 0:
    print(n)
else:
    print(n+1)

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()

ans = H*W

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

Submission status: Accepted

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

H, W = map(int, read().split())

if min(H, W) == 1:
    print(1)
elif (H % 2 == 1) & (W % 2 == 1):
    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:
  ans = 1
else:
  ans = (h * w - 1) // 2 + 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


a = int(W / 2 + 0.5)

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

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

Submission status: Accepted

Solution code:
H,W = map(int,input().split())
if H == 1 or W == 1:
    print(1)
    exit()

if H % 2 == 0:
    h = int(H/2)
    ans = h * W
    print(ans)
    exit()
else:
    h = int(H/2)+1
if W % 2 == 0:
    w = int(W/2)
else:
    w = int(W/2)+1

# print(h,w)
ans = h*w + (W-w)*(h-1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
if a!=1 and b!=1:
  if a %2 == 0:
    #たて一列でぬれるのは
    c = int(a/2)
    print(c*b)
  else:
  #たて一列目は
    d = int((a+1)/2)
    e = int((a-1)/2)
    if b %2 == 0:
      print(int((d+e)/2*b))
    else:
      print(int((d+e)/2*(b-1)+d))
else:
  print(1)

Submission status: Accepted

Solution code:
x,y=list(map(int, input().split()))

if x==1 or y==1:
	print(1)
elif y%2==1:
	print(((x*(y//2))+((x+1)//2)))
else:
	print((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+1)//2)

Submission status: Accepted

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

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 numpy as np

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

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

print(int(ans))

Submission status: Accepted

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

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

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))
elif h % 2 == 1 and w % 2 == 0:
    print(int(h*w/2))
else:
    print(int(h*(w//2)+h//2+1))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import math

H, W = map(int, input().split())
n = 0

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

Submission status: Accepted

Solution code:
import sys
# sys.stdin = open('input.txt')

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

Submission status: Accepted

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

kisuu = (w+1)//2
guusuu = w//2
tate_kisuu = (h+1)//2
tate_guusuu = h//2


res = kisuu*tate_kisuu+guusuu*tate_guusuu

if(h==1)or(w==1):
    res = 1


print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect
from math import factorial


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

    if H == 1 or W == 1:
        print(1)
        return
    
    odd_row_cell = W // 2 if W % 2 == 0 else (W+1) // 2
    even_row_cell = W // 2 if W % 2 == 0 else (W-1) // 2

    odd_row_num = H // 2 if H % 2 == 0 else (H+1) // 2
    even_row_num = H // 2 if H % 2 == 0 else (H-1) // 2

    num = odd_row_cell * odd_row_num\
        + even_row_cell * even_row_num

    print(int(num))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = [int(e) for e in input().split(" ")]
if(n[0] == 1 or n[1] == 1):
    print("1")
else:
    a = n[0] * n[1]
    if(a % 2 == 0):
        print(a // 2)
    else:
        print(a // 2 + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys

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

if H == 1 or W == 1:
    print(1)
    sys.exit()

if H%2 == 0:
    print(a*(H//2))
else:
    print(a*(H//2)+(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)//2) if (H*W)%2==0 else print((H*W)//2+1)

Submission status: Accepted

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

ans=0
ch=0

if h==1 or w==1:
    ch=1

if h%2==0:
    ans=w*int(h/2)
if h%2==1:
    if w%2==0:
        ans=int(h/2)*w +int(w/2)
    if w%2==1:
         ans=int(h/2)*w +int(w/2)+1

if ch==1:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

c = a*b
if a == c:
  print(1)
elif b == c:
  print(1)
elif c % 2 == 0:
  print(int(c/2))
else:
  print(int(c/2)+1)

Submission status: Accepted

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

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

s = h * w

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 

h, w = load_list()
if h == 1 or w == 1:
    print(1)
    exit()
if 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())

HW = H * W
if H == 1 or W == 1:
    ans = 1
elif HW % 2 == 0:
    ans = HW // 2
else:
    ans = (HW + 1) // 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:
  ans1=math.ceil(h/2)*math.ceil(w/2)
  ans2=math.floor(h/2)*math.floor(w/2)
  print(ans1+ans2)

Submission status: Accepted

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


print(math.floor(out))

Submission status: Accepted

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

    if W % 2 == 0:
        ans += (W // 2) * H
    else:
        ans += (W // 2) * H + (H // 2 + H % 2)

    print(ans // 2)

Submission status: Accepted

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

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

Submission status: Accepted

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

vertical = int(HW[0] / 2) + (HW[0] % 2)
horizontal = int(HW[1] / 2) + (HW[1] % 2)

if (HW[0] == 1 or HW[1] == 1):
    print(1)
else:
    pairV = 0
    secondV = 0
    if (HW[0] % 2 == 0):
        pairV = vertical * 2
    else:
        pairV = vertical * 2 - 1
    if (HW[1] % 2 == 0):
        print(pairV * int(HW[1] / 2))
    else:
        tmp = pairV * int(HW[1] / 2)
        tmp += vertical
        print(tmp)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    print(ans)

main()

Submission status: Accepted

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