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: Wrong Answer

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

ans = (H*W+1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

H, W = [int(i) for i in input().split()]
print(ceil(H*W/2))

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    h,w=MI()
    print((h*w+1)//2)

main()

Submission status: Wrong Answer

Solution code:

a,b = map(int,input().split())
print((a*b+1)//2)

Submission status: Wrong Answer

Solution code:
x,y = map(int,input().split())
print((x*y+1)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
print(h*w-(h*w)//2)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

print(int(ceil(H * W / 2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    return min(H, W)


print(main())

Submission status: Time Limit Exceeded

Solution code:
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)]
mod = 10 ** 9 + 7

#　DFSで解いてみる

h, w = LI()

b = [[0 for i in range(w)] for j in range(h)]
b[0][0] = 0

ans = 0

def DFS(x, y):
    # print(x,y)
    if not(0 <= x < w) or not(0 <= y < h) or (b[y][x]==1):
        return
    
    b[y][x] = 1
    global ans
    ans += 1

    # for l in b:
    #     print(l)
    # print("右下探索")
    DFS(x+1,y+1)
    
    # print("右上探索") 
    DFS(x+1,y-1) 
    
    # print("左上探索") 
    DFS(x-1,y-1)

    # print("左下探索") 
    DFS(x-1,y+1) 

DFS(0, 0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
h,w=map(int,input().split())
canMove=sum([[(i+j)%2==0 for i in range(w)]for j in range(h)],[])
print(canMove.count(True))

Submission status: Time Limit Exceeded

Solution code:
H,W=map(int,input().split())
n=0
for i in range(1,H+1):
    for j in range(1,W+1):
        if (i+j)%2==0:
            n+=1
print(n)

Submission status: Time Limit Exceeded

Solution code:
#B - Bishop
H,W = map(int,input().split())

count = 0
for i in range(H):#縦の動き
    for j in range(W):#横の動き
        if (i + j) % 2 == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

for x in range(H):
    for y in range(W):
        if (x+y) % 2 == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

L=[]
for i in range(1,H+1):
  for j in range(1,W+1):
    L.append([i+j,i-j])

conn =[[2,0]]
prev=0
while(prev!=len(conn)):
  prev=len(conn)
  temp=[]
  for i in range(len(conn)):
    for j in range(len(L)):
      if (L[j][0]-conn[i][0])*(L[j][1]-conn[i][1])==0:
        if 1-(L[j] in temp):
          temp.append(L[j])
  for i in range(len(temp)):
    conn.append(temp[i])
    L.remove(temp[i])
print(len(conn)-1)

Submission status: Time Limit Exceeded

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

area = h*w
ans = 0
for i in range(1,area+1):
  if i%2 == 1:
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
H, W =  list(map(int, input().split()))
ans = 0
for i in range(H):
  for j in range(W):
    if (i+j) % 2 == 0:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

board = [[(i+j+1) % 2 for i in range(w)] for j in range(h)]
print(np.sum(board))

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
c=len([i for i in range(1,a+1) if i%2==0])
d=len([i for i in range(1,a+1) if i%2!=0])
e=len([i for i in range(1,b+1) if i%2==0])
f=len([i for i in range(1,b+1) if i%2!=0])
if a%2==0 and b%2==0:
    print((a*b)//2)
elif a%2==0 and b%2!=0:
    print((a//2)*b)
elif a%2!=0 and b%2==0:
    print((b//2)*a)
else:
    print(d*f+c*e)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
c=len([i for i in range(1,a+1) if i%2==0])
d=len([i for i in range(1,a+1) if i%2!=0])
e=len([i for i in range(1,b+1) if i%2==0])
f=len([i for i in range(1,b+1) if i%2!=0])
print(d*f+c*e)

Submission status: Time Limit Exceeded

Solution code:
h,w=map(int,input().split())
cnt=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if (i+j)%2==0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

List = list(range(H) for i in range(W))
count = 0

for i in range(W):
  for j in range(H):
    if List[i][j]%2 == 0 and i%2 ==0 or List[i][j]%2 == 1 and i%2 ==1:
      count +=1

print(count)

Submission status: Time Limit Exceeded

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

List = list(range(H) for i in range(W))
count = 0

for i in range(W):
  for j in range(H):
    if List[i][j]%2 == 0 and i%2 ==0:
      count +=1
    elif List[i][j]%2 != 0 and i%2 !=0:
      count +=1

print(count)

Submission status: Time Limit Exceeded

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

List = list(range(H) for i in range(W))
count = 0

for i in range(W):
  for j in range(H):
    if List[i][j]%2 == 0 and i%2 ==0:
      count +=1
    elif List[i][j]%2 == 1 and i%2 ==1:
      count +=1
      
print(count)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(H):
    for j in range(W):
        if (i+j) % 2 == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
H, W = map(int, input().split())
count = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if (i + j) % 2 == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
num = input().split(" ")
ki = 0
gu = 0
sum_kaku = 0
for a in range(int(num[1])):
  if (a+1) % 2 == 0:
    gu += 1
  else:
    ki += 1
a = 0
while a < int(num[0]):
  if a % 2 == 0:
    sum_kaku += ki
  else:
    sum_kaku += gu
  a += 1
print(sum_kaku)

Submission status: Time Limit Exceeded

Solution code:
H,W=map(int,input().split())
sum=0
for i in range(H):
    for j in range(W):
        if (i-j)%2==0:
            sum+=1
print(sum)

Submission status: Time Limit Exceeded

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

def bfs(cx,cy,H,W,l,num):
  dx = [1,1,-1,-1]
  dy = [1,-1,-1,1]
  
  for i in range(4):
    nx = cx + dx[i]
    ny = cy + dy[i]
    if nx >= 0 and ny >= 0 and nx< W and ny < H:
      if l[ny][nx] == -1:
        l[ny][nx] = 1
        num.append(1)
        
        bfs(nx,ny,H,W,l,num)
      
      
l = [[-1 for _ in range(W)] for _ in range(H)]

sx = sy = 0
l[0][0] = 1
dx = [1,1,-1,-1]
dy = [1,-1,-1,1]

d = deque()
d.appendleft((sx,sy))
#while d :
#  c = d.pop()
#  cx = c[0]
#  cy = c[1]
  
#  for i in range(4):
#    nx = cx + dx[i]
#    ny = cy + dy[i]
#    if nx >= 0 and ny >= 0 and nx< W and ny < H:
#      if l[ny][nx] == -1:
#        l[ny][nx] = 1
#        d.appendleft((nx,ny))

#print(l)        



num = []
bfs(sx,sy,H,W,l,num)
print(len(num)+1)

#count = 0
#for i in range(H):
##  for j in range(W):
#    if l[i][j] == 1:
#      count += 1

#print(count)

Submission status: Time Limit Exceeded

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

def bfs(cx,cy,H,W,l,num):
  dx = [1,1,-1,-1]
  dy = [1,-1,-1,1]
  
  for i in range(4):
    nx = cx + dx[i]
    ny = cy + dy[i]
    if nx >= 0 and ny >= 0 and nx< W and ny < H:
      if l[ny][nx] == -1:
        l[ny][nx] = 1
        num.append(1)
        
        bfs(nx,ny,H,W,l,num)
      
      
l = [[-1 for _ in range(W)] for _ in range(H)]

sx = sy = 0
l[0][0] = 1
dx = [1,1,-1,-1]
dy = [1,-1,-1,1]

d = deque()
d.appendleft((sx,sy))
while d :
  c = d.pop()
  cx = c[0]
  cy = c[1]
  
  for i in range(4):
    nx = cx + dx[i]
    ny = cy + dy[i]
    if nx >= 0 and ny >= 0 and nx< W and ny < H:
      if l[ny][nx] == -1:
        l[ny][nx] = 1
        d.appendleft((nx,ny))

#print(l)        



#num = []
#bfs(sx,sy,H,W,l,num)
#print(len(num))

count = 0
for i in range(H):
  for j in range(W):
    if l[i][j] == 1:
      count += 1

print(count)

Submission status: Time Limit Exceeded

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

def bfs(cx,cy,H,W,l):
  dx = [1,1,-1,-1]
  dy = [1,-1,-1,1]
  
  for i in range(4):
    nx = cx + dx[i]
    ny = cy + dy[i]
    if nx >= 0 and ny >= 0 and nx< W and ny < H:
      if l[ny][nx] == -1:
        l[ny][nx] = 1
        bfs(nx,ny,H,W,l)
      
      
l = [[-1 for _ in range(W)] for _ in range(H)]

sx = sy = 0
l[0][0] = 1
bfs(sx,sy,H,W,l)

count = 0
for i in range(H):
  for j in range(W):
    if l[i][j] == 1 :
      count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
h, w = map(int, input().split(' '))
a1 = 0
for i in range(0, h + w):
    if(((h * w) % 2) == 1):
        a1 = ((h * w) // 2) + 1
    elif(((h * w) % 2) == 0):
        a1 = (h * w) // 2
print(a1)

Submission status: Time Limit Exceeded

Solution code:
h, w = map(int, input().split(' '))
a1 = 0
for i in range(0, h + w):
    if((h % (2 ** 32) == 0) or (w % (2 ** 32) == 0) or ((h * w) % (2 ** 32) == 0)):
        a1 = 0
    elif(((h * w) % 2) == 1):
        a1 = ((h * w) // 2) + 1
    elif(((h * w) % 2) == 0):
        a1 = (h * w) // 2
print(a1)

Submission status: Time Limit Exceeded

Solution code:
H, W = map(int, input().split())
n = 0
Count = 0
for i in range(W):
    if (i+1) % 2 != 0:
        n += 1
Judge = 0 if W % 2 == 0 else 1
for i in range(H):
    if (i+1) % 2 != 0:
        Count += n
    elif Judge == 1:
        Count += n-1
    else:
        Count += n
print(Count)

Submission status: Time Limit Exceeded

Solution code:
import math

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

l = []

for i in range(h):
    for j in range(w):
        m = [i,j]
        l.append(m)
count = 0

for x, y in enumerate(l):
    #print(y[0] , ' ',  y[1], bool((y[0] + y[1]) % 2 == 0))
    if bool((y[0] + y[1]) % 2 == 0):
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

board = [[0 for i in range(w)] for j in range(h)]

board[0][0] = 1
queue = [[0,0]]


def dfsx(y, x):
    dx = [-1, -1, 1, 1]
    dy = [-1, 1, -1, 1,]

    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if (0 <= xx < w and 0 <= yy < h and board[yy][xx] == 0):
            board[yy][xx] = 1
            queue.append([yy, xx])


while(len(queue) != 0):
    dfsx(queue[0][0], queue[0][1])
    queue.pop(0)

print(sum([sum(board[i]) for i in range(h)]))

Submission status: Time Limit Exceeded

Solution code:
H,W= input().split()
count = 0

for i in range(int(H)):
    for j in range(int(W)):
        if (i+j)%2 == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

cnt = 0
for h in range(1, H+1):
    for w in range(1, W + 1):
        if h % 2 == 1 and w % 2 == 1:
            cnt += 1
        elif h % 2 == 0 and w % 2 == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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:
		count = 0
		for i in range(a):
			if(i%2==0):
				count+=math.ceil(b/2)
			else:
				count+=math.floor(b/2)
		print(count)

Submission status: Time Limit Exceeded

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

a = H * W
b = 0

for i in range(a):
    if(i % 2 == 0):
        b = b + 1

print(b)

Submission status: Time Limit Exceeded

Solution code:
in_list = list(map(int,input().split()))
cnt = 0
for i in range(0,in_list[0]):
    for j in range(0,in_list[1]):
        if (i+j) % 2 == 0:
            cnt += 1
print (cnt)

Submission status: Time Limit Exceeded

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


ans = count
print(ans)

Submission status: Time Limit Exceeded

Solution code:
h,w=map(int, input().split())
cnt = 0
if h==1 or w == 1:
    print(1)
    exit(0)
    
for i in range(1, w+1):
    cnt += h//2 + (i%2 if h%2!=0 else 0)

print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(H):
    for j in range(W):
        if i%2 == 0:
            if j%2 ==0:
                ans +=1
        if i%2 ==1:
            if j%2 ==1:
                ans +=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
H, W = map(int, input().split())
cnt = 0
for i in range(W):
  for j in range(H):
    if (i + j) % 2 == 0:
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
h,w = (int(x) for x in input().split())
a = 0
for i in range(0,h):
    for j in range(0,w):
            if (i + j)%2 ==0:
                a += 1
print(a)

Submission status: Time Limit Exceeded

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

H = i[0]
W = i[1]
amount = 0
count = 0
for j in range(H):
    for k in range(W):
        if count % 2 != 0:
            count += 1
        else:
            count += 1
            amount += 1

print(amount)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
h, w = map(int, input().split())
c = 0

for i in range(h):
  for j in range(w):
    if (i + j) % 2 == 0:
      c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
h,w=map(int,input().split())
count=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if (i+j)%2==0:
            count=count+1
print(count)

Submission status: Time Limit Exceeded

Solution code:
h, w = map(int, input().split())
count = 0
for i in range(h):
  for j in range(w):
    if (i + j) % 2 == 0:
      count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
H,W = map(int,input().split())
cnt = 0
for h in range(H):
    for w in range(W):
        if (h+w) % 2 == 0:
            cnt += 1
print(cnt)

Submission status: Accepted

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

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

h, w = LI()

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

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

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

Submission status: Accepted

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

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

if total % 2:
    ans = (total + 1)//2

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
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:
#!/usr/local/bin/python3
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
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())

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

Submission status: Accepted

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


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


# Generated by 1.1.7.1 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:
def resolve():
    H, W = map(int, input().split())
    print(1 if H == 1 or W == 1 else (H * W + 2 - 1) // 2)
    
resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
H, W = map(int, input().split())
A = math.ceil((H * W)/2)

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

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    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(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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:
import math
h,w = map(int,input().split())

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

Submission status: Accepted

Solution code:
import sys
from itertools import islice, tee


def resolve(in_):
    H, W = map(int, next(in_).split())
    h0, h1 = divmod(H, 2)
    w0, w1 = divmod(W, 2)

    if H == 1 or W == 1:
        return 1

    answer = h0 * w0 * 2
    if h1:
        answer += w0
    if w1:
        answer += h0
    if h1 and w1:
        answer += 1

    return answer


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

h_odd = (h+1)//2
h_even = h//2
w_odd = (w+1)//2
w_even = w//2

if h == 1 or w ==1:
    print(1)
else:
    ans = h_odd * w_odd + h_even *w_even
    print(ans)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

if __name__=="__main__":
    main()

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(H*W//2)

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

Submission status: Accepted

Solution code:
# B - Bishop
H,W = map(int,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:
    print(math.floor((h * w + 1) / 2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
h,w = map(int,input().split())

if h == 1 or w == 1:
    print(1)
elif w %2 == 0:
    print(h * w //2)
elif h % 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>2 and w>1:
    print(math.ceil(h*w/2))
if h==1 or w==1:
    print(1)

Submission status: Accepted

Solution code:
# パナソニックプログラミングコンテスト2020: B – Bishop
H, W = [int(i) for i in input().split()]

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

print(can_reach)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 回答を読んで作成
# 全体の半分に到達可能、ただし１行もしくは１列の時は動けない
h,w = map(int, input().split())
if h==1 or w==1:
  ans = 1
else:
  ch = (h*w)/2
  ans = (ch//1)+((h*w)%2)
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 or W%2==0:
  ans = int(H*W/2)

else:
  ans = int((H*W+1)/2)

print(ans)

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:
import math as m

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

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

Submission status: Accepted

Solution code:
a = input("").split(" ")
a = [int(aa) for aa in a]
H = a[0]
W = a[1]
if H == 1 or W == 1:
    print("1")
elif H % 2 == 0:
    print(str(int(H/2)*W))
elif W % 2 == 0:
    print(str(int(W/2)*H))
else:
    p = int((H+1)/2)
    q = int((W+1)/2)
    print(str(p*q+(p-1)*(q-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 and W > 1:
  if H*W % 2 == 0:
    s = (H * W) // 2
  elif H*W % 2 != 0:
    s = (H * W + 1) // 2

elif H == 1 or W  == 1:
  s = 1


print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    h, w = map(int, input().split())
    print((h * w + 1) // 2 if min(h, w) > 1 else 1)


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

Submission status: Accepted

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

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:
import math

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

h = x[0]
w = x[1]

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

'''
for i in range(h):
    if i % 2 == 0:
        count += math.ceil(w/2)
    else:
        count += math.floor(w/2)
'''

print(count)

Submission status: Accepted

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

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 == 1:
  print(round(a//2+1))
else:
  print(round(a/2))

Submission status: Accepted

Solution code:
"""Boot-camp-for-Beginners_Easy006_B_Bishop_25-August-2020.py"""

H, W = (map(int, input().split()))
if(H == 1 or W == 1):
    print(1)
else:
    if (H*W) % 2 == 0:
        print(int(H*W/2))
    else:
        print(int(H*W/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:
	print(math.ceil((h * w) / 2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
H, W = [int(x) for x in input().split()]
if(H==1)or(W==1):
  print(1)
  sys.exit()
if(H%2)==0:
  h = -(-H//2)
  print(h*W)
  sys.exit()
elif(W%2)==0:
  w = -(-W//2)
  print(H*w)
  sys.exit()
else:
  print(-(-(H*W)//2))
  sys.exit()

Submission status: Accepted

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

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