peterverebics/CodeNet_Python_118 huggingface dataset:
l = int(input())
A = input().split(" ")
unique = set(A)
def combination(number):
  if number <= 1: return 0
  else: return int(number * (number - 1) / 2)

def caluculate(string):
  data = memo[string]
  if data <= 1: return(0)
  else: return(data - 1) 
total = 0
memo = {}
for i in unique:
  times = A.count(i)
  memo[i] = times
  total += combination(times)
from collections import Counter
N = int(raw_input())
A = map(int, raw_input().split())

counter = Counter(A)
total = 0

for i in range((len(A))):
    n = counter[i]
    total += n*(n-1)/2

for i in range((len(A))):
    n = counter[A[i]]
    ans = total -(n-1)
    print ans
import collections

def cal(x):
    b=0
    for i in range(e):
        a=d.most_common()[i]
        c=a[1]
        if a[0]==balls[x]:
            c-=1
        b = c*(c-1)//2
    return b

N = int(input())
balls = list(map(int,input().split()))
new_balls =sorted(balls)
d = collections.Counter(new_balls)
e = len([x for x in set(balls) if balls.count(x) > 1])

for j in range(N):
    print(cal(j))
N = int(input())
A = list(map(int, input().split()))

B = [0] * N

for i in range(N):
	B[A[i] - 1] += 1

ans = 0

for i in range(N):
	ans += B[i] * (B[i] - 1) // 2

for i in range(N):
	ans -= B[i] * (B[i] - 1) // 2
	if B[i] >= 1:
		ans += (B[i] - 1) * (B[i] - 2) // 2
	print(ans)
n = int(input())
a = list(map(int, input().split()))

li = [0] * (n+1)
tmp = 0

for i in range(n):
    li[a[i]] += 1
    
for i in range(n):
    hhh = li[i]
    tmp += hhh * (hhh - 1) // 2
    
for i in range(n):
    ans = tmp - li[a[i]] + 1
    print(ans)
def fact(n, end=1):
  if n <= end: return 1
  return n * fact(n-1, end=end)
def comb(a, b):
  if a < b:
    return 0
  return fact(a, end=a-b) / fact(b)
N = int(input())
A = list(map(int, input().split()))
dp = [[0, 0] for i in range(N+1)]
for i in range(N):
  dp[A[i]][0] += 1
x = 0
for i in range(N):
  dp[i][1] = comb(dp[i][0], 2)
  x += dp[i][1]
for i in range(N):
  y = comb(dp[A[i]][0]-1, 2)
  print(int(x - dp[A[i]][1] + y))
n = int(input())
a = list(map(int, input().split()))

b = set(a)

c = {}

for i in b:
    c[i] = a.count(i)

for k in b:
    ans = 0
    for i in b:
        if i != k:
            ans += c[i]*(c[i]-1)//2
        else:
            ans += (c[i]-1)*(c[i]-2)//2
    print(ans)
n = int(input())
b = list(map(int,input().split()))
balls = [0]*(n+1)
for i in range(n):
    balls[b[i]] += 1


su = 0
for i in range(n):
    su += (balls[i]*(balls[i]-1))//2


for i in range(n):
    bb = balls[b[i]]
    print(su - bb+1)
import collections as cl
n = int(input())
A = list(map(int,input().split()))
cn = cl.Counter(A)
sumC = sum([(n-2)*(n-1)/2 for n in cn.values()])
for k in range(n):
  print(sumC - cn[A[k]] +1)
n = int(input())
A = input().split()
if len(set(A)) == 1:
    print((len(A) * len(A) - 1) // 2)
    exit()
elif len(set(A)) == len(A):
    print(len(A))
    exit()
dA = {}
for a in A:
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

kA = {}
for a in dA:
    dA[a] = dA[a] * (dA[a] - 1) // 2
    kA[a] = (dA[a] - 1) * (dA[a] - 2) // 2
for a in A:
    print(sum(dA.values()) - dA[a] + kA[a])
n=int(input())
array=list(map(int,input().split()))
tot=0
x=0
count=[0]*1000000
for c in range(n):
  count[array[c]]+=1
for c in range(n):
  if x<array[c]:
    x=array[c]
    t=count[array[c]]
    tot+=int(t*(t-1)/2)
for i in range(n):
  ans=tot
  l=count[array[i]]
  ans-=int(l*(l-1)/2)
  ans+=int((l-1)*(l-2)/2)
  print(ans)
N = int(input())
A = list(map(int,input().split()))
B = [0]*(N+1)
for a in A:
    B[a]+=1
C = [0]*(N+1)
for i in range(N):
    C[i] = (B[i]-1)*B[i]//2
S = sum(C)
for k in range(N):
    s = A[k]
    ans = S-C[s]
    print(ans+(B[s]-2)*(B[s]-1)//2)
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(n+1)]

for i in a:
  l[i]+=1
cmb1=[0 for i in range(n+1)]
cmb2=[0 for i in range(n+1)]

for i in range(1,n+1):
  cmb1[i]=(l[i]*(l[i]-1))//2
  cmb2[i]=((l[i]-1)*(l[i]-2))//2

kei1=0
for i in range(1,n):
  kei1+=cmb1[i]

for i in range(1,n+1):
  print(kei1-cmb1[a[i-1]]+cmb2[a[i-1]])
N = int(input())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)

for i in A:
    temp = c.copy()
    temp[i] = temp[i]-1
    counter = 0
    for j in c.keys():
        n = temp[j]
        if n >= 2:
            counter += n*(n-1)/2
    print(counter)
n=int(input())
 
A=list(map(int,input().split()))
 
X=[0]*(n+1)
 
for i in range(n):
    X[A[i]]+=1
 
ans=0
 
for i in range(n):
    if X[i]>1:
        ans+=(X[i]*(X[i]-1))//2      
for i in range(n):
    if X[A[i]]==1:
        print(ans)
    elif X[A[i]]>1:
        print(ans-(X[A[i]]-1))
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)

# 先にk番目を抜かない場合を求めておく
ans = 0
for n in c.values():
    ans += n*(n-1)//2

# k番目を抜く場合の差分を加える
for k in range(N):
    m = c[A[k]]
    ans -= m-1  # -m*(m-1)//2 + (m-1)*(m-2)//2
    print(ans)
n = int(input())
li = list(map(int,input().split()))
lia = [0]*n
sum1 = 0
for i in range(n):
    lia[li[i]-1] += 1
for i in range(n):
    if lia[i] >= 2:
        lia[i] -= 1
        sum1 += (lia[i]*(lia[i]+1)//2)
for i in range(n):
    a = lia[li[i]-1]*(lia[li[i]-1]+1)//2
    b = (lia[li[i]-1]-1)*lia[li[i]-1]//2
    if sum1-a+b >= 0:
        print(sum1-a+b)
    else:
        print(0)
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input().rstrip())
As = [int(x) for x in input().rstrip().split()]
print(As)
d = {}
for n in As:
    if n not in d.keys():
        d[n] = 1
    else:
        d[n] += 1
for n in As:
    d[n] -= 1
    ret = 0
    for val in d.values():
        if val > 1:
            ret += combinations_count(val, 2)
    print(ret)
    d[n] += 1
import collections
N=int(input())
A = list(map(int,input().split()))
cn = collections.Counter(A)
print(cn[A[2]])
sumC=sum([n * (n-1)//2 for n in cn.values()])
for k in range(N):
    print(sumC-cn[A[k]]+1)
n = int(input())

a = input().split(" ")
ab = a
for k in range(n):
    count = 0
    if not k == 0:
        ab.insert(k-1, a[k-1])
    ab.pop(k)
    for i in range(n-1):
        for j in range(i):
            if ab[i] == ab[j] and not i == j:
                count = count + 1
    print(count)
import itertools
import math 
def C(n,r): return n*(n-1)/r

n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0)+1

c = 0
cc = {}
for key, val in d.items():
    temp = C(val,2)
    c += temp
    if cc.get(key) is None:
        cc[key] = temp - C(val-1,2)
for i in a:
    print(c - cc[i])
import numpy
N = int(input())
E= list(map(int,input().split()))
ans = [0 for _ in range(N)]
unique = list(numpy.unique(E))
for s in range(len(unique)):
    unique[s] = int(unique[s])
uniqueNum = [0 for _ in range(len(unique))]

for t in range(len(unique)):
    uniqueNum[t] = E.count(unique[t])
uniqueAns = [0 for _ in range(len(unique))]
full =0
for l in range(len(unique)):
    full = full + uniqueNum[l] * (uniqueNum[l]-1)/2
for m in range(len(unique)):
    uniqueAns[m] = full - uniqueNum[m]+1
for k in range(N):
    ans[k] = uniqueAns[unique.index(int(E[k]))]
    print(ans[k])
import collections

n = int(input())
an = tuple(map(str, input().split()))
print(an)

test_list = [[an[i] for i in range(n)] for i in range(n)]
for i in range(n):
    an2=list(an)
    Ans = 0
    an2[i]="0"
    c = collections.Counter(an2)
    c_list = list(c.values())
    
    for j in range(len(c_list)):
        Ans += (c_list[j]-1)*c_list[j]/2
    print(int(Ans))
def main():
  import sys
  input = sys.stdin.readline
  import numpy as np
  from collections import Counter

  N = int(input())
  A = list(map(int,input().split()))
  print(set(A))
  c = Counter(A)

  tmp = np.array(list(c.values()))
  l1= tmp*(tmp-1)//2
  l2= (tmp-1)*((tmp-1)-1)//2
  S = np.sum(l1)

  for a in A:
    r = list(c).index(a)
    sum = S + l2[r] -l1[r]
    print(int(sum))

if __name__ == '__main__':
  main()
n=int(input())
a=list(map(int,input().split()))
def ans(a,x):
  b=0
  c=a[:x]+a[x+1:]
  d=list(set(c))
  for i in range(len(d)):
    b=b+(c.count(d[i])*(c.count(d[i])-1))/2
    return b
for k in range(n):
  print(int(ans(a,k)))
N = int(input())
A = list(map(int, input().split()))

ANSWER = []
for i in range(N):
    A_ = A.copy()
    del A_[i]
    unique_i = list(set(A_))

    answer_i = 0
    for j in unique_i:
        answer_i += (A_.count(j) * (A_.count(j)-1)/2)
    
    ANSWER.append(int(answer_i))
    
print(ANSWER)
import math


def kumiawase(n):
    if n == 0 or n == 1:
        return 0
    return 5 * n + 5


n = int(input())
aL = list(map(int, input().split(" ")))

d = {}

for ai in aL:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

for ai in aL:
    sm = 0
    for dk, di in d.items():
        if dk == ai:
            sm += kumiawase(di - 1)
        else:
            sm += kumiawase(di)
    print(sm)
N = int(input())
num = list(map(int, input().split()))
dict = {}
for i in range(0, N):
    if num[i] in dict:
        dict[num[i]] += 1
    else:
        dict[num[i]] = 1
totalNum = 0
for i in range(0, N):
    if i in dict and dict[i] > 1:
        totalNum += (dict[i] * (dict[i] - 1)) / 2
for i in range(0, N):
    if dict[num[i]] > 1:
        print(int(totalNum - dict[num[i]] + 1))
    else:
        print(0)
N = int(input())
A = list(map(int,input().split()))

ans = [-1] * N

for A_ in range(len(A)):
    K = A[A_]
    for B_ in range(len(A)):
        if K == A[B_]:
            ans[A_] += 1
    print(ans[A_])
def main():
    N = int(input())
    A = [int(v) for v in input().split()]
    C = [0] * (N + 1)

    for i in A:
        C[i] += 1


    b = 0
    print(C)
    for cnt in C:
        b += ((cnt * (cnt - 1)) // 2)

    for i in range(N):
        p = ((C[A[i]] - 1) * (C[A[i]] - 2)) >> 1
        m = (C[A[i]] * (C[A[i]] - 1)) >> 1
        print(b - m + p)


if __name__ == '__main__':
    main()
import itertools

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    all = len(tuple(filter(lambda t: t[0] == t[1], itertools.combinations(A, 2))))
    for x in range(N):
        count = A.count(A[x])
        tmp = tuple(["0" for _ in range(count)])
        result = tuple(filter(lambda t: t[0] == t[1], itertools.combinations(tmp, 2)))
        print(all-len(result))
h,w = map(int, input().split())
squares = h * w
if h == 1 or w == 1:
  print(1)
elif squares % 2 == 0:
  print(int(squares / 2))
else:
  print(int((squares - 1) / 2 + 1))
c = [int(i) for i in input().split()]
a = c[0]
b = c[1]

r = int((a*b)/2)
if a == 1 or b == 1:
    print(1)
elif a%2 == 0 or b%2 == 0:
    print(r)
else:
    print(r+1)
H,W=map(int,input().split())
if min(H,W)==1:
    print(1)
elif W%2==0:
    print(int((W/2)*H))
else:
    if H%2==0:
        print(int(((W-1)/2+1+(W-1)/2)*H/2))
    else:
        print(int(((W-1)/2+1+(W-1)/2)*(H-1)/2+(W-1)/2+1))
h, w =  map(int,input().split())
if h == 1 or w == 1:
    print(1)
    exit()
else:
    print((h * w + 1) // 2)
h,w = map(int, input().split())

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

if h == 1 or w == 1:
    ans = 1
print(ans)
a, b = map(int,input().split(' '))
ans = a*b//2

if (a*b)%2 == 1:
  ans+=1
if a == 1 or b == 1:
    print(1)
else:
    print(ans)
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))
H, W = map(int, input().split())

ans = 0
x = H * W

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

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

if h==1 or w==1:
    print(1);exit()
tmp = (h*w)//2+(h*w)%2
print(tmp)
H,W = list(map(int,input().split()))
 
if H==1 or W==1:
  print(1)
  exit()
 
if (H*W)%2==0:
  ans = H*W//2
else:
  ans = H*W//2 + 1
  
print(ans)
h, w = list(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)
import math 
H, W = map(int, input().split())
if H==1 or W == 1:
    print(1)
else:
  print(math.ceil((H * W) / 2))
h,w=(int(i) for i in input().split())
if(h==1):
  print(1)
elif(w==1):
  print(1)
else:
  if(h%2==0):
    print((h//2)*w)
  else:
    print( (((h//2)+1)*w)-(w//2))
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))
import math
m,n = map(int,input().strip().split())
if n==1 or m==1:
    print("1")
else:
    print(math.ceil((m*n)/2))
import math
H,W = (int(x) for x in input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(math.ceil(H*W/2))
h, w = list(map(int, input().split()))
if h != 1 and w != 1:
    print((h * w + 1) // 2)
else:
    print(1)
H,W = map(int,input().split())
if H == 1 or W == 1:
  print(1)
else:
  print((H*W+1)//2)
H, W = map(int, input().split())
from math import ceil
 
if H == 1 or W == 1:
  print(1)
else:
  print(ceil(H*W/2))
import sys
h, w = list(map(int, input().split()))

if h == 1 or w == 1:
    print(1)
    exit()
tmp = h * w
if (tmp % 2) == 0:
    a = tmp // 2
    print(a)
else:
    a = tmp // 2
    b = a + 1
    print(b)
H, W = map(int, input().split())
 
if H == 1:
  print(1)
elif  W == 1:
  print(1)
else:
  print(-((-H * W)//2))
h, w = map(int, input().split())
if h==1 or w==1:
    print(1)
elif h%2==0 or w%2==0:
    print(int(h*w/2))
else:
    print(int((h*w+1)/2))
import math
h,w = map(int,input().split())
if(h == 1 or w == 1):
    print(1)
else:
    print(math.ceil((h*w)/2))
h,w = map(int,input().split())
ans = (h*w)//2
if h%2 == 1 and w%2 == 1: ans += 1
if h == 1 or w == 1: ans = 1
print(ans)
a,b=map(int,input().split())

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

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

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

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

h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil(h * w / 2))
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W = map(int,input().split(' '))
A = -(-W//2)
if W==1 or H==1:
    print(1)
    exit()
if H%2==0:
    print(W*H//2)
else:
    print(W*(H-1)//2+A)
import sys
input = sys.stdin.readline

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

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

main()
H,W=map(int, input().split())
ans=H*(W//2)
if W&1:
    ans+=(H+1)//2
if H==1 or W==1:
    ans=1
print(ans)
import math
h,w = map(int,input().split())
if h == 1 or w == 1:
  result = 1
elif h % 2 == 0:
  result = math.floor(h / 2 * w)
elif w % 2 ==0:
  result = math.floor((h // 2 + 1)) * math.floor(w//2) + math.floor((h//2)) * math.floor(w//2)
else:
  result = math.floor((h//2 + 1)) * math.floor((w//2 + 1)) +  math.floor((h//2)) * math.floor(w//2)
  
print(result)
h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
else:
  print((h*w+1)//2)
from decimal import Decimal
a,b = list(map(int,input().split()))
if a == 1 or b ==1:
    d =1
elif a*b%2==0 and a >1 and b >1:
    d = a*b/2
else:
    d = (a*b+1)/2
print(Decimal(d))
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)
H,W = map(int,input().split())
if min(H,W)==1:
    print(1)
else:
    print((H*W+1)//2)
# N = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())

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

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

if min(H,W) == 1:
    print(1)
else:
    print(-(-H*W//2))
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
elif h%2!=0 and w%2!=0:
    print(h*w//2+1)
else:
    print(h*w//2)
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
else:
    print((h*w)//2+(h*w)%2)
H, W = map(int, input().split())
if H == 1 or W == 1:
  print(1)
elif H%2 == 0:
  print(H//2 * W)
elif W%2 == 0:
  print((H//2 + 1) * int(W//2) + int(H//2) * int(W//2))
else:
  print(int(H//2 + 1) * int(W//2 + 1) + int(H//2) * int(W//2))
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)
def resolve():
    h, w = map(int, input().split())
    dy = h // 2 if h != 1 else 1
    if h == 1 or w == 1:
        count = 1
    elif h % 2 == 1:
        count = w * dy + (w - (w // 2))
    else:
        count = w * dy

    print(count)


if __name__ == '__main__':
    resolve()
import sys
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    sys.exit()
count_1 = (h+1) // 2
count_2 = h // 2

loop_num = w // 2
add_num = w - (loop_num * 2)
print((count_1+count_2) * loop_num + (count_1 * add_num))
h,w = map(int,input().split())
if h==1 or w==1:
  print(1)
else:
  print((h*w+1)//2)
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)
h,w=map(int,input().split())
if h<2 or w<2:
	print(1)
elif h%2==0 or w%2==0:
	print(int(h*w/2))
else:
	print(int(h*w/2)+1)
from math import ceil
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
	print(ceil(h/2)*ceil(w/2) + int(h/2)*int(w/2))
h,w=map(int,input().split())
masu=h*w
if h==1 or w==1:
  print(1)
elif masu%2==0:
  print(masu//2)
else:
  print((masu//2)+1)
H, W = map(int, input().split())
if H==1 or W ==1:
    print(1)
else:
    print(-(-(H*W)//2))
H,W = map(int, input().split())
if W == 1 or H == 1:
  print(1)
elif H*W%2 == 0:
  print(H*W//2)
else:
  print(H*W//2+1)
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)
H, W = list(map(int, input().split()))
if(min(H, W) == 1):
    print(1)
else:
    print(int(H*W/2) + H*W%2)
import math

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

main()
import math
h,w = map(int,input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil(h*w/2))
h, w = map(int, input().split())
if h == 1 or w == 1:
  print(1)
else:
  if h*w%2 != 0:
    print(h*w//2 + 1)
  else:
    print(h*w//2)
H,W = map(int,input().split())
x = H//2
ans = (H*W+1)//2
if H == 1:
    ans = 1
if W == 1:
    ans = 1
print(ans)
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
    exit()
    
if w%2==0:
    print(w//2*h)
    exit()
if w%2==1:
    if h%2==0:
        print(w*h//2)
    elif h%2==1:
        ans=0
        ans+=w*(int(h/2))
        ans+=w//2+1
        print(ans)
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)
#スペース区切りの整数の入力
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)
def main():
    H, W = map(int, input().split())
    if H == 1 or W == 1:
        print(1)
        return

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
H,W = map(int,input().split())
if(min(H,W) == 1):
    print(1)
    exit()
print((H*W+(H*W)%2)//2)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    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:
        ans = h * (w // 2) + (h // 2) + 1
    print("%d" % ans)


if __name__ == '__main__':
    main()
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)
H,W=[int(i) for i in input().split()]
if H==1 or W==1:
    print(1)
else:
    print(int(H*W/2)+(H*W)%2)
h, w = map(int, input().split())
ans =  h*w // 2
if h == 1 or w == 1:
    print(1)
elif (h*w) % 2 == 0:
    print(ans)
else:
    print(ans + 1)
[H,W] = list(map(int,input().split(' ')))
K = int((H*W+1)*0.5)
if H==1 or W==1:print(1)
else:print(K)
a, b= map(int, input().split())
if a == 1:
    print('1')
elif b == 1:
    print('1')
else:
    if (a*b)%2 == 0:
        print(round((a*b)/2))
    else:
        print(round(((a//2)+(a%2))*b)-(b//2))
(a,b)=[int(x) for x in input().split()]
if a==1 or b==1:
  print(1)
else:
  print((a*b+1)//2)
h, w = map(int, input().split())
 
if h == 1 or w == 1:
	print(1)
    
elif h % 2 == 1 and w % 2 == 1:
	print((h - 1) * w // 2 + (w+1) // 2 )
else:
	print(h*w//2)
import sys
import math
import bisect

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

if __name__ == "__main__":
    main()
import math
h,w = map(int,input().split())
if h%2 == 0:
    print(h//2 * w)
elif h==1 or w == 1:
    print(1)
else:
    tmp1 = math.floor(h/2)
    tmp2 = math.ceil(h/2)
    buf = math.floor(w/2)
    print(tmp2 * (w-buf) + tmp1 * (buf))
h,w = map(int,input().split())

hw = h*w
if(h == 1 or w == 1):
  ans = 1
elif(hw%2==1):
  ans = (int)(hw/2)+1
else:
  ans = (int)(hw/2)
  
print(ans)
def resolve():
    H, W = [int(i) for i in input().split()]
    if min(H, W) == 1:
        print(1)
    elif (H * W) % 2 == 0:
        print(format(H * W // 2, "d"))
    else:
        print(format((H * W // 2) + 1, "d"))


resolve()
H, W = map(int, input().split())
if H==1 or W==1:
    print(1)
else:
    print((H*W+1)//2)
import sys
import math
h, w = map(int, sys.stdin.readline().split())

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

w1=0--W//2
w2=W//2

if H==1 or W==1:
    print(1)
else:
    print(w1*(0--H//2)+w2*(H//2))
#!/usr/bin/env python3

H,W = [int(x) for x in 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 - 1) * W // 2 + (W + 1) //2

print(ans)
import math
H, W = list(map(int, input().split()))

sum = float(H*W)
if sum%2 == 0:
    if H == 1 or W == 1:
        print(1)
    else:
        print(H*W//2)
else:
    if H == 1 or W == 1:
        print(1)
    else:
        print(math.floor(H*W/2)+1)
import math
h, w = [int(w) for w in input().split()]

if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil(h * w / 2))
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

al = H * W

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

print(ans)