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:
height, width = map(int, input().split())
i, j = 0, 0
if height % 2 > 0:
    i = height // 2 + 1
else:
    i = height // 2

if width % 2 > 0:
    j = width // 2 + 1
else:
    j = width // 2
ans = 0
if height == 1 or width == 1:
    ans = 1
elif height % 2 == 0 and width % 2 == 0:
    ans = j * height
elif height % 2 > 0 and width % 2 > 0:
    ans = j * height - (height // 2)
elif width % 2 == 0:
    ans = j * height
elif height % 2 == 0:
    ans = j * height - (height // 2)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if min(H,W)==1:
  print(1)
else:
  ans=(W//2+W%2)*(H//2+H%2)+(W//2)*(H//2)
  print(int(ans))

Submission status: Accepted

Solution code:
#B
import math
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))
elif h%2==0 and w%2!=0:
    print(int(h*(w-1)/2+math.floor(h/2)))
elif h%2!=0 and w%2==0:
    print(int(w*(h-1)/2+math.floor(w/2)))
else:
    print(int((w-1)*(h-1)/2+math.floor(h/2)+math.floor(w/2)+1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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 -*-
from collections import defaultdict
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

H, W = inpl()
if (min(H, W) == 1):
    print(1)
elif (H%2 == 0):
    print(H*W//2)
else:
    print(H*(W//2) + -(-H//2)*(W%2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math


def solve(H: int, W: int):
    # print(int((H/2)*W) if H%2==0 else int((H//2)*W+math.ceil(W/2)))
    if H == 1 or W == 1:
        print(1)
        return
    print(math.ceil(H*W/2))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if W == 1 or H == 1:
    print(1)
    exit()
    
ans = (W // 2) * H

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

print(int(ans))

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    h, w = map(int, args[0].split())
    if h == 1 or w == 1:
        ret = 1
    elif h % 2 == 0:
        ret = (h//2)*w
    elif w % 2 == 0:
        ret = h*(w//2)
    else:
        ret = h*(w//2) + (h//2) + 1
    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


tmp = H // 2
tmp2 = H - tmp
wt = W // 2
wt2 = W - wt
ans = tmp * wt + tmp2 * wt2

if H == 1:
  ans = 1
elif W == 1:
  ans = 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if (w == 1 or h == 1):
    print(1)
else:
    print(math.ceil((h*w)/2))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from decimal import Decimal

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

Submission status: Accepted

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

# count = 1
# que = [(0,0)]
# check = set()
# check.add((0,0))
# while que:
#     points = que.pop()

#     ru = (points[0]+1,points[1]-1)
#     if ru[0]<W and -1<ru[1] and ru not in check:
#         que.append(ru)
#         check.add(ru)
#         count += 1
    
#     rd = (points[0]+1,points[1]+1)
#     if rd[0]<W and rd[1]<H and rd not in check:
#         que.append(rd)
#         check.add(rd)
#         count += 1
    
#     lu = (points[0]-1,points[1]-1)
#     if -1<lu[0] and -1<lu[1] and lu not in check:
#         que.append(lu)
#         check.add(lu)
#         count += 1
    
#     ld = (points[0]-1,points[1]+1)
#     if -1<ld[0] and ld[1]<H and ld not in check:
#         que.append(ld)
#         check.add(ld)
#         count += 1

block = H//2 * W
tip = W//2 if W%2==0 else W//2+1
tip = tip if H%2!=0 else 0


ans = 1 if H==1 or W==1 else block+tip
print(ans)

Submission status: Accepted

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

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:
a, b = map(int, input().split())
if min(a, b) == 1:
    print(1)
else:
    print((a*b+1)//2)

Submission status: Accepted

Solution code:
import sys
import math

for line in sys.stdin:
	a,b=map(int,line.split())
	if(a==1 or b==1):
		print(1)
	elif(a*b%2==0):
		print(int(a*b/2))
	else:
		print(math.ceil(a*b/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:
    ans = (H * W // 2)
else:
    if W % 2 == 0:
        _H = (H + 1) // 2
        ans = (2 * _H - 1) * (W // 2)
    else:
        _H = (H + 1) // 2
        ans = (2 * _H - 1) * (W // 2) + _H
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if h>1 and w>1:
    print((h*w+1)//2)
else:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

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

def check(x):
    if x%2==0:
        return x//2
    return x//2 + 1

even_row = check(W)
odd_row = check(W-1)
cH = check(H)
total_even_row = even_row * cH
total_odd_ror = odd_row * (H - cH)

if W == 1 or H == 1:
    print(1)
else:
    print(total_even_row + total_odd_ror)

Submission status: Accepted

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

if H*W % 2 == 0:
  ans = int(H*W / 2)
else:
  ans = int(H* W / 2) + 1
if H == 1 or W == 1:
  ans = 1
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.floor(H/2)*math.floor(W/2)+math.ceil(H/2)*math.ceil(W/2))

Submission status: Accepted

Solution code:
import math
x,y = map(int, input().split())
tot = x*y

if x%2==1 and y%2==1:
    tot = (tot+1)/2
else:
    tot = tot/2
if x <2:
    tot = 1
elif y<2:
    tot = 1
print(math.floor(tot))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys


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

# ----------------------------------------------------------------


def main():
    h, w = LI()
    if h == 1 or w == 1:
        print(1)
    elif h % 2 == 0 or w % 2 == 0:
        print('{:.0f}'.format(w * h / 2))
    else:
        print('{:.0f}'.format((h * w + 1) / 2))


main()

Submission status: Accepted

Solution code:
import math
n = input().split()
k = int(n[0])*int(n[1])
if int(n[0]) == 1 or int(n[1]) == 1:
  print(1)
else:
  print(math.ceil(k/2))

Submission status: Accepted

Solution code:
input = raw_input

h, w = map(int, input().split(" "))
t =  h *w 

if 1 in [h, w]:
    out = 1
else:
    if w % 2 == 1: 
        n1 = 1 + ((w-1) // 2) 
        n2 = ((w-1) // 2)
    else:
        n1 = w // 2
        n2 = n1

    if h % 2 == 1: 
        h1 = 1 + ((h-1) // 2) 
        h2 = ((h-1) // 2)
    else:
        h1 = h // 2
        h2 = h1

    out = h1 * n1 + h2 * n2
print(out)

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

Submission status: Accepted

Solution code:
import math
H, W = map(int, input().split(' '))
if H == 1 or W == 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)
else:
    print(-(-(H*W)//2))

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
HH = i[0]
WW = i[1]
atai = HH*WW
ans = int(atai/2)
if ((HH % 2) * (WW % 2) == 1):
    ans = ans +1
#amari = divmod(atai,2)
#ans = int(atai/2) + amari[1]
#ans = int(atai/2) + (atai % 2)
#print (atai)
#print (int(atai/2))
if ((HH == 1) or (WW == 1)):
    ans = 1
print (ans)

Submission status: Accepted

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

Submission status: Accepted

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

ceil_H = math.ceil(H / 2)
floor_H = math.floor(H / 2)

ceil_W = math.ceil(W / 2)
floor_W = math.floor(W / 2)

if H == 1 or W == 1:
  print(1)
else:
  print(ceil_H * ceil_W + floor_H * floor_W)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


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

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

inputs = list(map(int, (input().split())))

h = inputs[0]
w = inputs[1]

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

print(math.ceil((h*w)/2))

Submission status: Accepted

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

if h % 2 == 1:
    ch1 = math.ceil(h/2)
    ch2 = math.floor(h/2)
else:
    ch1 = h//2
    ch2 = h//2
    
if w % 2 == 1:
    cw1 = math.ceil(w/2)
    cw2 = math.floor(w/2)
else:
    cw1 = w//2
    cw2 = w//2
    
ans = ch1 * cw1 + ch2 * cw2

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

Submission status: Accepted

Solution code:
import math

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

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

print(math.ceil(ans))

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
#from functools import lru_cached
from heapq import heappop,heappush
import time
import os
import sys
import datetime
readline=readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
else:
    gu=((H+1)//2)*((W+1)//2)
    ki=(H//2)*(W//2)
    print(gu+ki)

Submission status: Accepted

Solution code:
def main():
    H, W = map(int, input().split(" "))
    # r1 + c1 = r2 + c2
    # r1 - c1 = r2 - c2
    c = H * W
    if H == 1 or W == 1:
        print('1')
        return

    if c % 2 == 0: # OK
        print(c // 2)
    else:
        print((c // 2) + 1)


# def main():
#     H, W = map(int, input().split(" "))
#     # r1 + c1 = r2 + c2
#     # r1 - c1 = r2 - c2

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

#     c = H * W
#     if c % 2 == 0:
#         print(c // w)
#     else:
#         MAX = max(H, W)
#         MIN = min(H, W)

#         out = MIN * (MIN - 1) + MAX % MIN
        


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())
if W <= 0:
    print(0)
elif h == 1:
    print(1)
elif W == 1:
    print(1)
else:
    if h % 2 != 0:
        if W % 2 != 0:
            ans = ((h-1)*W//2)+(W//2+1)
        else:
            ans = (h*W)//2
    else:
        ans = (h*W)//2
    print(ans)

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, input().split())
    n = a*b
    if a == 1 or b == 1:
        print(1)
    elif n%2==0:
        print(n//2)
    else:
        print(n//2+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:
  S = H * W
  print(S // 2 + S % 2)

Submission status: Accepted

Solution code:
from math import ceil, floor

data = input().split()
h, w = [int(i) for i in data]

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

Submission status: Accepted

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [input().split() for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    h,w=map(int,input().split())
    if h == 1 or w == 1:
        print(1)
        return 0
    res = h*w//2
    if (h*w)%2 != 0:
        res += 1
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
h, w = map(int, 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:
HK=input().split(' ')
H=int(HK[0])
K=int(HK[1])
if H==1 or K ==1:
    print(1)
else:
    if K % 2==1 and H%2==1:
        print(round(H*K/2)+1)
    else:
        print(int(H*K/2))

Submission status: Accepted

Solution code:
import numpy as np
import sys
h,w = map(int,input().split())
if h == 1:
    print(1)
    sys.exit()
if w == 1:
    print(1)
    sys.exit()
if w%2 == 0:
    if h%2 == 0:
        print((w//2)*h)
    else:
        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:
high, wigh = map(int,input().split())
if high == 1:
    print("1")
elif wigh == 1:
    print("1")
else:
    if high % 2 == 1:
        if wigh % 2 == 1:
            print(round(high * wigh/2 + 0.5))
        else:
            print(round(high * wigh/2))
    else:
        print(round(high * wigh/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H, M = map(int,input().split())
l = [H, M]

max = max(l)
min = min(l)

if min == 1:
  N = 1
  
else:
  if max == min:
    if max % 2 == 0:
      N = (H * M) / 2
    else:
      N = (((H * M) - 1)/2)+1

  else:
    r = max - min
    r2 = max - r
    r3 = r * min
    if r2 % 2 == 0:
      n1 = (r2 * r2) / 2
    else:
      n1 = (((r2 * r2) - 1)/2)+1
 
    if r3 % 2 == 0:
      n2 = r3 / 2
    else:
      n2 = (r3 - 1) / 2

    N = n1 + n2
    
print(int(N))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
h,w = map(int,input().split())
count = 0


#１,３,５...
s = math.ceil(w/2)

#2,4,6..
t = math.floor(w/2)

g = s+t


if(h%2 != 0):
    count =  (math.floor(h/2)) * g + s
elif(h%2 == 0):
    count = (h/2) * g
if(w == 1 or h == 1):
    count = 1



print(int(count))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
H , W = map  ( int , input().strip().split(" ") ) ; 
s1 = (  H //2 + H %2 ) * ( W //2  + W %2 ) ;
s2 = (  H //2  ) * ( W //2 ) ;

if H == 1 or W == 1 :
	print ( 1 ) ;
else :
	print ( s1 + s2 ) ;

Submission status: Accepted

Solution code:
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//2+1)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
import math
if n==1 or m==1:
	print(1)
	exit()
if n*m%2==0:
	print(m*n//2)
else:
	print(m*n//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//2)+(H*W)%2)

Submission status: Accepted

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

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

Submission status: Accepted

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

syou, amari = divmod(h, 2)
if w % 2 == 1:
    a = w // 2 + 1
    ans = (a + a - 1)* syou + a * amari
else:
    a = w / 2
    ans = (a + a)* syou + a * amari
if h == 1 or w == 1:
    print(1)
else:
    print(int(ans))

Submission status: Accepted

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

    odd_reach = -1
    even_reach = -1
    if (H % 2 == 1) :
        odd_reach = (H // 2 + 1)
        even_reach = (H // 2 )
    else :
        odd_reach = (H // 2)
        even_reach = (H // 2)

    # print("odd_reach : ", odd_reach, ",even_reach : ", even_reach)
    reachable = 0
    if (W % 2 == 1) :
        odd_row = (W // 2) + 1
        even_row = (W // 2)
        reachable = odd_reach * odd_row
        reachable += even_reach * even_row
    else :
        odd_row = (W // 2) 
        even_row = (W // 2) 
        reachable = odd_reach * odd_row
        reachable += even_reach * even_row

    # print("odd_row : ", odd_row, ",even_row : ", even_row)
    print(reachable)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 - 1) * (W - 1) // 2 + (H - 1) // 2 + (W - 1) // 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 / 2) + 1)

Submission status: Accepted

Solution code:
#スペース区切りの整数の入力
H, W = map(int, input().split())

ans = 0

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

Submission status: Accepted

Solution code:
import math
h,w=[int(x) for x in input().split()]
if h==1 or w==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)
else:
    ans=((h+1)//2)*((w+1)//2)+(h-(h+1)//2)*(w-(w+1)//2)
    print(ans)

Submission status: Accepted

Solution code:
import math

H, W = [int(n) for n in input().split()]
if W == 1 or H == 1:
    print(1)
    exit()
if H%2==0:
    print(math.floor(H/2)*W)
else:
    print(math.floor(H/2)*W+math.ceil(W/2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
H, W = map(int, input().split())
if 1 in [H, W]:
  print(1)
  exit()
print((H*W+1)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil
HW = input()
H, W = int(HW.split()[0]), int(HW.split()[1])
# print(ceil(2.0*float(H*W)/4.0))

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

Submission status: Accepted

Solution code:
def main():
    

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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) + int(w/2+.5))

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

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

Submission status: Accepted

Solution code:
import math
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 - 1) * w // 2 + (w + 1) // 2
else:
    ans = h * w // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

HH = H // 2
hh = H % 2
WW = W // 2
ww = W % 2

a = 0

a += HH * WW * 2
a += hh * WW
a += HH * ww
a += hh * ww

print(a)

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

if r==1 or c == 1:
    print(1)
elif (r%2==1 and c%2==1):
    print(r*c//2+1)
else:
    print(r*c//2)

Submission status: Accepted

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

q_h,mod_h = divmod(h,2)

if h == 1 or w == 1:
	print(1)
elif mod_h == 0: 	
	print(w * q_h)
else:
	q_w,mod_w = divmod(w,2)
	if mod_w == 0:
		print(w * q_h + q_w)
	else:
		print(w * q_h + q_w + 1)