Harryxun/stf_run huggingface dataset:
n, a, b, c = map(int,input().split())
l = [int(input() for i in range(n))]

inf = 10**9

def dfs(cut, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else inf#-30は最初に選んだもの
    ret0 = dfs(cur + 1, a, b, c)#何も使わない
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10#Aに使うために合成するとして
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10#Bに使うために合成するとして
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10#Cに使うために合成するとして
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

### FIXED CODE ###

n, A, B, C = map(int,input().split())
l = [int(input()) for i in range(n)]

inf = 10**9

def dfs(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else inf#-30は最初に選んだもの
    ret0 = dfs(cur + 1, a, b, c)#何も使わない
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10#Aに使うために合成するとして
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10#Bに使うために合成するとして
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10#Cに使うために合成するとして
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))
#!/usr/bin/env python3
import sys
import re


def solve(N: int, S: str):
    result = 0
    for s in set(S):
        regex = re.compile(f"{s}+")
        # print(regex.findall(S))
        result += len(regex.findall(S))
    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import re


def solve(N: int, S: str):
    result = 0
    for s in set(S):
        regex = re.compile(s + "+")
        # print(regex.findall(S))
        result += len(regex.findall(S))
    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == "__main__":
    main()
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
output = "Yes"

for i in range(1, w - 1):
    for k in range(1, h - 1):
        if s[i - 1][k] == "." and s[i + 1][k] == "." and s[i][k - 1] == "." and s[i][k + 1] == ".":
            output = "No"
            break

    else:
        break
    continue

print(output)


### FIXED CODE ###

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = True

for i in range(h):
    for k in range(w):
        if s[i][k] == "#":
            count = True
            d = [[0, 1], [1, 0], [0, -1], [-1, 0]]
            for l in d:
                if 0 <= i + l[0] < h and 0 <= k + l[1] < w:
                    if s[i + l[0]][k + l[1]] == "#":
                        count = False
                        break

            if count:
                ans = False

print("Yes") if ans else print("No")
s=list(input())

ch=[]
for i in range(len(s)):
    if s[i]!='x':
        ch.append(s[i])
for i in range(len(ch)//2):
    if ch[i]!=ch[len(ch)-i-1]:
        print('-1')
        exit()

ans=0
li=0
ri=0
for i in range(len(ch)//2+1):
    x=0
    while s[li]!=ch[i]:
        x += 1
        li += 1
    li += 1
    y=0
    while s[len(s)-1-ri]!=ch[len(ch)-1-i]:
        y += 1
        ri += 1
    ri += 1
    ans += abs(x-y)
print(ans)


### FIXED CODE ###

s=list(input())

ch=[]
for i in range(len(s)):
    if s[i]!='x':
        ch.append(s[i])

if len(ch)==0:
    print(0)
    exit()
for i in range(len(ch)//2):
    if ch[i]!=ch[len(ch)-i-1]:
        print(-1)
        exit()

ans=0
li=0
ri=0
for i in range(len(ch)//2+1):
    x=0
    while s[li]!=ch[i]:
        x += 1
        li += 1
    li += 1
    y=0
    while s[len(s)-1-ri]!=ch[len(ch)-1-i]:
        y += 1
        ri += 1
    ri += 1
    ans += abs(x-y)

print(ans)
n=int(input())
l=list(map(int, input().split()))
l=sorted([x for x in set(l) if l.count(x)<4])
ans=0
x=[]
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,(n-sum((x>l[j]+l[i]) for x in l))):
            if (l[i]<(l[j]+l[k])and l[j]<(l[i]+l[k]) and x.count([l[i],l[j],l[k]])==0):
                x.append([l[i],l[j],l[k]])
                ans+=1

print(ans)


### FIXED CODE ###

a,b = list(map(int, input().split()))

c=a-2*b
if c<0:
    c=0
    
print(c)
n = int(input())

if n != 2:
    if n % 2 == 0:
        n += 1
    while not is_prime(n):
        n += 2
    print(n)
else:
    print(n)

def is_prime(q):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

### FIXED CODE ###

def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

if __name__ == '__main__':
    n = int(input())
    while not is_prime(n):
        n += 1
    print(n)
k=int(input())
s=input()
n=len(s)
for i in range(n):
    z=ord(s[i]+k)
    if z>123:
        z-=27
    s[i]=chr(z)
print(s)

### FIXED CODE ###

k=int(input())
s=input()
n=len(s)
temp=""
for i in range(n):
    z=ord(s[i])+k
    if z>90:
        z-=26
    temp+=chr(z)
print(temp)
import sys
sys.setrecursionlimit(10**6)

N = [int(i) for i in input().split()][0]

balls=[]
for i in range(N):
  balls.append( [int(i) for i in input().split()])

salist=[]
for i in range(1,len(balls),1):
  sax = balls[i][0]-balls[i-1][0]
  say = balls[i][1]-balls[i-1][1]
  if [sax,say] not in salist:
    salist.append([sax,say])

balls.reverse()
costs=[]
for i,sa in enumerate(salist):
  cost=1
  for i in range(0,len(balls)-1,1):
    if balls[i+1][0]!=balls[i][0]-sa[0] and balls[i+1][1]!=balls[i][1]-sa[1]:
      cost+=1
  costs.append(cost)

print(min(costs))

### FIXED CODE ###

N = [int(i) for i in input().split()][0]

balls=[]
for i in range(N):
  balls.append( [int(i) for i in input().split()])

ans=0
for i in range(0,N-1):
  for j in range(i+1,N):
    sax = balls[j][0]-balls[i][0]
    say = balls[j][1]-balls[i][1]
    merge=0
    for k in range(0,N):
      if([balls[k][0]+sax,balls[k][1]+say] in balls):
          merge+=1
    ans=max(ans,merge)
print(N-ans)
s = list(input())
for i in range(len(s)):
  if ls[i] == "9":
    ls[i] = "1"
  elif ls[i] == "1":
    ls[i] = "9":
for i in s:
  print(i,end="")

### FIXED CODE ###

s = list(input())
for i in range(len(s)):
    if s[i] == "9":
        s[i] = "1"
    elif s[i] == "1":
        s[i] = "9"
for i in s:
    print(i,end="")
n = int(input())
table = [int.input() for i in range(n)]
print("{} {} {}".format(min(table),max(table),sum(table)))


### FIXED CODE ###

n = input()
table = list(map(int,input().split()))
print("{} {} {}".format(min(table),max(table),sum(table)))
#!/usr/bin/env python3
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
ans = sum(p[-x:])+sum(q[-y:])
x_pos = -x
y_pos = -y
for i in range(c):
    #したから見ていく
    if min(p[x_pos],q[y_pos]) >= r[i]:
        continue
    elif p[x_pos] > q[y_pos]:
        ans += r[i] - q[y_pos]
        y_pos -= 1
    else:
        ans += r[i] - p[x_pos]
        x_pos -= 1
    if x_pos == -a:
        p.insert(0,10**5)
        x_pos -= 1
    if y_pos == -b:
        q.insert(0,10**5)
        y_pos -=1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
z = p[-x:]
z.extend(q[-y:])
z.extend(r)
z.sort()
#print(z)
print(sum(z[-x-y:]))
N = int(input())
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s] = 0
    C[s] += 1
C = sorted(list(C.items()),key=lambda x:x[0])
C = sorted(C,key=lambda x:x[1],reverse=True)
k = C[0][1]
for i in range(N):
    if C[i][1]==k:
        print(C[i][0])
    else:break


### FIXED CODE ###

N = int(input())
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s] = 0
    C[s] += 1
C = sorted(list(C.items()),key=lambda x:x[0])
C = sorted(C,key=lambda x:x[1],reverse=True)
k = C[0][1]
for i in range(len(C)):
    if C[i][1]==k:
        print(C[i][0])
    else:break
l,r=map(int,input().split())
d=int(input())

l=l//d
r=r//d

print(r- l)


### FIXED CODE ###

l,r,d = map(int,input().split())

if l%d ==0:
  print(r//d - l//d +1)
else:
  print(r//d-l//d)
x=input().split()

a=x[0]
b=x[1]

p=a + b
q=a - b
r=a * b

max=p
if q > max:
    max = q
    if r > max:
        max = r

print(max)

### FIXED CODE ###

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

a=int[0]
b=int[1]

x=a+b
y=a-b
z=a*b

max=x
if y > max:
    max=y
if z > max:
    max=z
print(max)
# coding:utf-8
# Doubly Linked List

class DLL:

    def __init__(self):
        self.array = []

    def insert(self, x):
        self.array = [x] + self.array
    
    def delete(self, x):
        del self.array[self.array.index(x)]

    def deleteFirst(self):
        del self.array[0]

    def deleteLast(self):
        del self.array[len(self.array)-1]


def main():

    dll = DLL()
    n = int(input())
    ans = ""

    for _ in range(n):
        operation = input().split()
        command = operation[0]
        if command in ["insert", "delete"]:
            key = operation[1]
            eval("dll." + command + '(' + key + ')')

        else:
            eval("dll." + command + "()")

    for value in dll.array:
        ans += str(value) + " "

    print(ans.rstrip())

if __name__ == "__main__":
    main()

### FIXED CODE ###

# coding:utf-8
# Doubly Linked List

from collections import deque

def main():

    n = int(input())
    dll = deque()

    for _ in range(n):
        operation = input().split(' ')
        if operation[0] in ["insert", "delete"]:
            key = operation[1]
            if operation[0] == "insert":
                dll.appendleft(key)
            else:
                try:
                    dll.remove(key)
                except:
                    pass

        else:
            if operation[0][6] == 'F':
                dll.popleft()

            else:
                dll.pop()

    print(' '.join(dll))

if __name__ == "__main__":
    main()
n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(1)
#elif b==1:
else:
    print(n//0)
    exit()

### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
import math

dp = [float('inf') for _ in range(110000)]
withdraw = []

N = int(input())

#引き出し可能な金額の配列にする
withdraw.append(1)

for i in range( math.floor(math.log(N,6)) + 1):
    withdraw.append(6**i)

for i in range( math.floor(math.log(N,9)) + 1):
    withdraw.append(9**i)

withdraw = sorted(list(set(withdraw)))

dp[0] = 0

for i in range(N+1):
    for j in withdraw:
        dp[i+j] = min(dp[i+j],dp[i]+1)
        
print(dp[N])


### FIXED CODE ###

import math

dp = [float('inf') for _ in range(200000)]
withdraw = []

N = int(input())

#引き出し可能な金額の配列にする
withdraw.append(1)

for i in range(20):
    if 100000 >= 6**i:
        withdraw.append(6**i)
    if 100000 >= 9**i:
        withdraw.append(9**i)

withdraw = sorted(list(set(withdraw)))

dp[0] = 0

for i in range(N+1):
    for j in withdraw:
        dp[i+j] = min(dp[i+j],dp[i]+1)
        
print(dp[N])
from bisect import bisect_left

N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

def takeClosest(myList, myNumber):
    pos = bisect_left(myList, myNumber)
    if pos == 0:
        return myList[0]
    if pos == len(myList):
        return myList[-1]
    before = myList[pos - 1]
    after = myList[pos]
    if after - myNumber < myNumber - before:
       return after
    else:
       return before

ans = takeClosest(sorteddata, sorteddata[-1] / 2)
print(sorteddata[-1] + ' ' + ans)

### FIXED CODE ###

from bisect import bisect_left

N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

def takeClosest(myList, myNumber):
    pos = bisect_left(myList, myNumber)
    if pos == 0:
        return myList[0]
    if pos == len(myList):
        return myList[-1]
    before = myList[pos - 1]
    after = myList[pos]
    if after - myNumber < myNumber - before:
       return after
    else:
       return before

ans = takeClosest(sorteddata, sorteddata[-1] / 2)
print(str(sorteddata[-1]) + ' ' + str(ans))
S = raw_input()

n_a = S.find('a')
n_b = S.find('b')
n_c = S.find('c')

chksum = n_a + n_b + n_c

if chksum = 0:
	print("yes")
else:
	print("no")

### FIXED CODE ###

S = input()

chksum = 0
 
if ('a' in S):
    chksum+=1
if ('b' in S):
    chksum+=1
if ('c' in S):
    chksum+=1
    
if chksum == 3:
	print("Yes")
else:
	print("No")
from itertools import permutations as per

n,m,r = map(int,input().split())
rlist = list(map(int,input().split()))
ans = 10**9
A = [[10**8]*n for _ in range(n)]
for _ in range(n):
  a,b,c = map(int,input().split())
  A[a-1][b-1] = c
  A[b-1][a-1] = c

for i in range(n-1):
  for j in range(i+1,n):
    for k in range(n):
      newd = A[i][k] + A[k][j]
      if A[i][j] > newd:
        A[i][j] = newd
        A[j][i] = newd
for x in per(rlist):
  cost = 0
  for i in range(r-1):
    cost += A[x[i]-1][x[i+1]-1]
  if cost < ans:
    ans = cost
print(ans)

### FIXED CODE ###

n,m,r = map(int,input().split())
l = list(map(int,input().split()))
g = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(n+1):
  g[i][i] = 0
for _ in range(m):
  a,b,c = map(int,input().split())
  g[a][b] = c
  g[b][a] = c
for k in range(1,n+1):
  for i in range(1,n):
    for j in range(i+1,n+1):
      if g[i][j] >= g[i][k] + g[k][j]:
        g[i][j] = g[i][k] + g[k][j]
        g[j][i] = g[i][j]
g[0] = [0]*(n+1)
def dfs(cur,res,dis,use):
  if res == 0:
    return dis
  ans = 10**10
  for i in range(r):
    if not use[i]:
      use[i] = 1
      ans = min(ans, dfs(l[i],res-1,dis+g[cur][l[i]],use))
      use[i] = 0
  return ans
print(dfs(0,r,0,[0]*r))
n, k = map(int, input().split())
a = list(map(int, input().split()))
tmp = a[0]
tmp0 = tmp
x = 0

for i in range(k-1):
    tmp = a[tmp-1]
    if tmp == tmp0:
        x = i
        break

ans = a[0]
for i in range(k % x):
    ans = a[ans-1]
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = []
x = [0] * n
x.append(0)
v = 1
c = 1
l = 0
while x[v] == 0:
    x[v] = len(s)
    s.append(v)
    v = a[v-1]
c = len(s) - x[v]
l = x[v]


if k < l:
    print(s[k])
else:
    k -= l
    k = k % c
    print(s[l+k])
n,k = map(int,input().split())
s = set()
for i in [0]*n:
  _ = input()
  s|=set(map(int,input().split()))
print(k-len(s))

### FIXED CODE ###

n,k = map(int,input().split())
l=[]
for i in [0]*k:
  d = input()
  l+=list(map(int,input().split()))
print(n-len(set(l)))
from itertools import permutations as p
N=int(input())
l=list(p(range(1,N+1)))

A=tuple(map(int, input().split()))
B=tuple(map(int, input().split()))

fa=True
fb=True
for i in range(len(l)):
  if l[i]==A and fa:
    idx_a=i
    fa=False
  elif l[i]==B and fb:
    idx_b=i
    fb=False
  if (not fa) and (not fb):
    break
print(abs(idx_a-idx_b))
  

### FIXED CODE ###

from itertools import permutations as p
N=int(input())
l=list(p(range(1,N+1)))

A=tuple(map(int, input().split()))
B=tuple(map(int, input().split()))

fa=True
fb=True
for i in range(len(l)):
  if l[i]==A and fa:
    idx_a=i
    fa=False
  if l[i]==B and fb:
    idx_b=i
    fb=False
  if (not fa) and (not fb):
    break
print(abs(idx_a-idx_b))
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
i = 10**(n-1)
if n==1:
    i = 0
while i<10**n:
    for j in range(m):
        if int(str(i)[sc[j][0]-1])==sc[j][1]:
            pass
        else:
            no = True
    if no == False:
        print(i)
        break
    else:
        i+=1
    no = False
else:
    print(-1)



### FIXED CODE ###

n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
i = 10**(n-1)
if n==1:
    i = 0
no = False
while i<10**n:
    for j in range(m):
        if int(str(i)[sc[j][0]-1])==sc[j][1]:
            pass
        else:
            no = True
    if no == False:
        print(i)
        break
    else:
        i+=1
    no = False
else:
    print(-1)
import sys

def solve():
    n, q = map(int, sys.stdin.readline().split())
    uf = UnionFind(n)
    ans = []

    for lp in range(q):
        c, x, y = map(int, sys.stdin.readline().split())

        if c == 0:
            uf.unite(x, y)
        else:
            ans.append(1 if uf.is_same(x, y) else 0)

    print(*ans, sep='\n')


class UnionFind:

    def __init__(self, n):
        self.ds = [i for i in range(n)]
        self.root = [i for i in range(n)]
        # self.rank = [0] * n

    def find_root(self, x):
        if x != self.root[x]:
            self.root[x] = self.find_root(self.root[x])

        return self.root[x]

    def is_same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        p = self.find_root(x)
        q = self.find_root(y)
        self.root[p] = q

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys

def solve():
    n, q = map(int, sys.stdin.readline().split())
    uf = UnionFind(n)
    ans = []
    
    for lp in range(q):
        c, x, y = map(int, sys.stdin.readline().split())

        if c == 0:
            uf.unite(x, y)
        else:
            ans.append(1 if uf.same(x, y) else 0)

    print(*ans, sep='\n')


class UnionFind:

    def __init__(self, n):
        self.ds = [i for i in range(n)]
        self.root = [i for i in range(n)]
        self.rank = [0] * n

    def find_root(self, x):
        if self.root[x] == x:
            return x

        res = self.root[x]

        while res != self.root[res]:
            res = self.root[res]

        return res

    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        p = self.find_root(x)
        q = self.find_root(y)

        if p == q:
            return None

        if self.rank[p] < self.rank[q]:
            self.root[p] = q
        elif self.rank[q] < self.rank[p]:
            self.root[q] = p
        else:
            self.root[q] = p
            self.rank[p] += 1

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()
def slove():
    import sys
    input = sys.stdin.readline
    d = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
    h, w = list(map(int, input().rstrip('\n').split()))
    for i in range(h):
        s = list(map(str, input().rstrip('\n').split()))
        for j in range(w):
            if s[j] == "snuke":
                print(d[j] + str(i+1))
                exit()


if __name__ == '__main__':
    slove()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    d = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    h, w = list(map(int, input().rstrip('\n').split()))
    for i in range(h):
        s = list(map(str, input().rstrip('\n').split()))
        for j in range(w):
            if s[j] == "snuke":
                print(d[j] + str(i+1))
                exit()


if __name__ == '__main__':
    slove()
length = int(input())
a_list = map(int, input().split())

num_list = []
for a in a_list:
    t = a
    num = 0
    while t % 2 == 0:
        num += 1
        t = t / 2
    num_list.append(num)

print(min(num_list))
#こぴぺです。


### FIXED CODE ###

s=str(input())
print(s.count("1"))
N,M=list(map(int, input().split()))
K=N-2*M
  print(max(N+K//3,N))

### FIXED CODE ###

N,M=list(map(int, input().split()))
K=M-2*N
if K>=0:
  print(N+K//4)
else:
  print(min(N, M//2))
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    cnt = 0
    for i in range(N):
        for j in range(N-1, i, -1):
            if j > 0 and A[j-1] > A[j]:
                A[j-1], A[j] = A[j], A[j-1]
                cnt += 1
    print(" ".join(map(str, A)))
    pritn(cnt)


### FIXED CODE ###

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

if __name__ == '__main__':
    flg = True
    cnt = 0
    while flg:
        for i in range(N):
            flg = False
            for j in range(N-1, i, -1):
                if A[j] < A[j-1]:
                    A[j], A[j-1] = A[j-1], A[j]
                    cnt += 1
                    flg = True
    print(" ".join(map(str, A)))
    print(cnt)
N,X,Y=map(int,input().split())

Ans=[]

i=1
while i<=N:
    j=i+1
    while j<=N:
        Ans.append(min(j-i,abs(X-i)+1+abs(j-Y)))
        j=j+1
    i=i+1

k=1
while k<=N-1:
    print(Ans.count(k))
    k=k+1

### FIXED CODE ###

N,X,Y=map(int,input().split())

Ans=[0]*N

i=1
d=0
while i<=N:
    j=i+1
    while j<=N:
        d=(min(j-i,abs(X-i)+1+abs(j-Y)))
        Ans[d]+=1
        j+=1
    i+=1

k=1
while k<=N-1:
    print(Ans[k])
    k+=1
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z)):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)

### FIXED CODE ###

A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)
#参考
#https://atcoder.jp/contests/aising2019/submissions/3995168
import bisect
N,Q=map(int,input().split())
A=list(map(int,input().split()))
Asum=[0]*N
Asum2=[0]*N
total=0
total2=0
for i in range(N):
  total+=A[i]
  Asum[i]=total
  if i>1:
    Asum2[i]=A[i]+Asum2[i-2]
  else:
    Asum2[i]=A[i]

#yで高橋くんと青木くんの取りたいカードが初めて衝突すると考える。
#このようなyは半分より小さい所にはないので初期値を半分のところとする。
#yがNまで来た時は最初から交互に取る

for i in range(Q):
  y=N//2-1
  ans=0
  x=int(input())
  while x>A[y] and y<=N-1:
    y+=1
  while y<=N-1:
    takahashi=N-y
    aoki=y+1-bisect.bisect_left(A,x-(A[y]-x))
    if takahashi>aoki:
      y+=1
    else:
      break;
      #右端からA[y]までは全て高橋くんが取る
  ans+=Asum[N-1]-Asum[y-1]
  #青木くんはyからN-y個取っているので、その下のところから交互に取る
  if y-(N-y)-1<0:
    print(ans)
    continue;
  ans+=Asum2[y-(N-y)-1]
  
  print(ans)

### FIXED CODE ###

#参考
#https://atcoder.jp/contests/aising2019/submissions/3995168

import bisect

N,Q=map(int,input().split())

A=list(map(int,input().split()))
Asum=[0]*N
Asum2=[0]*N
total=0

for i in range(N):
  total+=A[i]
  Asum[i]=total
  if i>1:
    Asum2[i]=A[i]+Asum2[i-2]
  else:
    Asum2[i]=A[i]

X=[] 
for i in range(Q):
  X.append((int(input()),i))
X.sort(key=lambda x :x[0])
  

#yで高橋くんと青木くんの取りたいカードが初めて衝突すると考える。
#このようなyは半分より小さい所にはないので初期値を半分のところとする。
#yがNまで来た時は最初から交互に取る
#Xを小さい順から計算することで、yの値が単調増加になる
y=N//2-1
ans=[0]*Q
for x,i in X:
  while y<=N-1 and x>A[y]:
    y+=1
  while y<=N-1:
    takahashi=N-y
    aoki=y+1-bisect.bisect_left(A,x-(A[y]-x))
    if takahashi>aoki:
      y+=1
    else:
      break
  #右端からA[y]までは全て高橋くんが取る
  ans[i]+=Asum[N-1]-Asum[y-1]
  #青木くんはyからN-y個取っているので、その下のところから交互に取る
  if y-(N-y)-1<0:
    continue
  ans[i]+=Asum2[y-(N-y)-1]

for i in range(Q):
  print(ans[i])
inport math
h,w=map(int,input().split())
print(math.ceil(h*w/2))

### FIXED CODE ###

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