peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, x = map(int, input().split())
l = list(map(int, input().split()))

sub = []
for i in range(n):
  sub.append(abs(x - l[i]))

# a,bの最大公約数を求めます。（ユークリッドの互除法）
def gcd(m, n):
  if n == 0:
    return m

  return gcd(n, m % n)

#gcd_複数の値の最大公約数を求める
def gcd_2(a):
  if len(a) == 1:
    return a[0]

  ans = a[0]
  for i in range(1, len(a)):
    ans = gcd(ans, a[i])
  return ans

print(gcd_2(sub))
# Judge status: Wrong Answer
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
  c = list(map(int, input().split()))
  C.append(c[0])
  A.append(c[1:])
ans = sum(C)
for n in range(1 << N):
  p = [0 for j in range(M)]
  q = 0
  for i in range(N):
    t = (n >> i) & 1
    q += t * C[i]
    for j in range(M):
      p[j] += t * A[i][j]
  f = 0
  for j in range(M):
    if p[j] < X:
      f = 1
      break
  if f == 0:
    ans = min(ans, q)
if ans == sum(C):
  print(-1)
else:
  print(ans)
# Judge status: Accepted
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = []
    B = []
    for _ in range(n):
        a,b = map(int, input().split())
        A.append(a)
        B.append(b)
    import numpy as np
    a = np.array(A[::-1], dtype=int)
    ans = 0
    for i, b in enumerate(B[::-1]):
        tmp = (b-a[i]%b)%b
        a[i:] += tmp
        ans += tmp
    print(ans)


        

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))
A = sorted(a, reverse=True)
count = 0
for i in range(N-1):
  flag = False
  for j in range(i+1,N):
    if i != j:
      if A[i] % A[j] == 0:
        flag = True
        break
  if flag == False:
    count += 1
print(count)
# Judge status: Accepted
n, m = map(int, input().split())
ans = 0
if n > 1: ans += n * (n - 1) // 2
if m > 1: ans += m * (m - 1) // 2
print(ans)
# Judge status: Accepted
n=int(input())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
bef=sum(aa)
for i in range(n):
  aa[i] -= bb[i]
  if aa[i] >= 0:
    bb[i]=0
  else:
    bb[i]=0-aa[i]
    aa[i]=0
  aa[i+1] -= bb[i]
  if aa[i+1] >= 0:
    bb[i]=0
  else:
    bb[i]=0-aa[i+1]
    aa[i+1]=0
print(bef-sum(aa))
# Judge status: Accepted
n, m = map(int, input().split())
n -= 1
dat = list(map(int, input().split()))
iseven = True
for i in range(len(dat)):
    if dat[i] %2 == 1:
        iseven = False
if iseven:
    if m == 0:
        print(2**(n+1))
    else:
        print(0)
else:
    if n == 0:
        print(0)
    else:
        print(pow(2, n))
# Judge status: Accepted
from itertools import permutations
N =[i+1 for i in range(int(input()))]
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
index = 0

for n in permutations(N):
    if p==n:
        x = index
    if q ==n:
        y = index

    index += 1

print(abs(x-y))
# Judge status: Wrong Answer
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    check_point_dist = 10 ** 8 * 2
    check_point = 0
    count = 0
    for c, d in cd:
        count += 1
        if check_point_dist > abs(a - c) + abs(b - d):
            check_point = count
            check_point_dist = abs(a - c) + abs(b - d)
    else:
        print(check_point)
# Judge status: Accepted
s = list(input())
sum = 0
for i in range(len(s)):
    if i % 2 != 0:
        if "R" == s[i]:
            sum += 1

    elif i % 2 == 0:
        if "L" == s[i]:
            sum += 1

if sum > 0:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
n,d=map(int,input().split())
x=[0 for i in  range(n)]

for i in range(n):
    x[i]=list(map(int,input().split()))
print(x)
a=0
for i in range(n):
    if x[i][0]**2+x[i][1]**2<=d**2:
        a+=1

print(a)
# Judge status: Wrong Answer
x, y = map(int, input().split())
dif = abs(abs(x) - abs(y))
if x < 0 and y < 0:
    if x < y:
        print(dif)
        exit()
    else:
        print(dif+2)
        exit()
if x >= 0 and y >= 0:
    if x > y:
        print(dif+2)
        exit()
    else:
        print(dif)
        exit()
print(dif+1 if x >= 0 else dif)
# Judge status: Accepted
import numpy as np
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
a=np.array(a)
b=np.array(b)
c=np.array(c)

cnt_a=np.searchsorted(a,b)
cnt_c=n-np.searchsorted(c,b,side='right')
print(np.sum(cnt_a*cnt_c))
# Judge status: Accepted
L,R = map(int,input().split())
if(R-L >= 2019):
    print(0)
else:
    mL = L%2019
    mR = R%2019
    modmin = 2019
    for i in range(mL,mR):
        for j in range(i+1,mR+1):
            modmin = min(modmin,i*j%2019)
    print(modmin)
# Judge status: Wrong Answer
N, M = map(int, input().split())
ans = max((N*2 + M) // 4, min(N, M // 2))
print(ans)
# Judge status: Accepted
N,M,Q=list(map(int,input().split()))
M=[i for i in range(1,M+1)]
import itertools
A=list(itertools.combinations_with_replacement(M, N))
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i]=list(map(int,input().split()))
s=[]
ans=0
for j in range(len(A)):
  for k in range(Q):
    if A[j][b[k]-1]-A[j][a[k]-1]==c[k]:
      ans=ans+d[k]
  s.append(ans)
  ans=0
print(max(s))
# Judge status: Accepted
s=input()
l=['SUN','MON','TUE','WED','THU','FRI','SAT']
for i in range(7):
  if s==l[i]:print(7-i)
# Judge status: Wrong Answer
n = int(input())
l = sorted(list(map(int, input().split())))

if l[-1] < sum(l[:-2]):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math
list = [input() for i in range(5)]
one_min = 9
for i in range(5):
    if one_min >= int(list[i][-1]) > 0:
        one_min = int(list[i][-1])
sum = 0
for i in range(5):
    sum += math.ceil(int(list[i])/10)*10
print(sum - 10 + one_min)
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if A[K+i] > A[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
# https://atcoder.jp/contests/agc009/tasks/agc009_a

n = int(input())

A = []
B = []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
plus = 0
for i in range(n)[::-1]:
    a = A[i] + plus
    b = B[i]
    if a % b != 0:
        multi = a // b + 1
        t = b * multi - a
        ans += t
        plus += t
print(ans)
# Judge status: Accepted
N = int(input())
z =[]
w = []
for i in range(N):
  x,y = map(int, input().split())
  z.append(x+y)
  w.append(x-y)
print(max(max(z)-min(z),max(w)-min(w)))
# Judge status: Accepted
import itertools as it
import numpy as np
import math

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

rosen = list(it.permutations(range(1, N+1)))

isP = 0
isQ = 0

for i in range (0, len(rosen)):
    if list(rosen[i]) == P:
        isP = i+1
    if list(rosen[i]) == Q:
        isQ = i+1

print(abs(isP-isQ))
# Judge status: Wrong Answer
nab = input().split()
n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

ans = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    tp = 1
    for j in range(n, 1, -1):
        if j > i:
            tp *= j
        else:
            tp /= j
    ans += tp
ans = round(ans % (10**9 + 7))
print(ans)
# Judge status: Wrong Answer
S=input()
s=str(S)
for i in range(len(s)):
    s.replace("x",s[i])
# Judge status: Wrong Answer
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    if a[i] == 1:
        start = i
        break
start += 1
r = n - start + 1
l = start
print(r//(k-1) + l//(k-1))
# Judge status: Accepted
# input
stairs, broken = map(int, input().split())
conditions = [1] * (stairs + 1)
for i in range(broken):
  tmp = int(input())
  conditions[tmp] = 0
  
# main
for i in range(2, stairs+1):
  conditions[i] *= (conditions[i-1] + conditions[i-2]) % (10**9+7)

print(conditions[stairs])
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
b=list(set(a))
if len(a)==len(b):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
a = [int(x) for x in input()[::-1]] + [0]
n = len(a)
dp = [[0] * 2 for _ in range(n)]
dp[0][0], dp[0][1] = a[0], 10-a[0]
for i in range(n-1):
    dp[i+1][0] = min(a[i+1]+dp[i][0], a[i+1]+dp[i][1]+1)
    dp[i+1][1] = min(10-a[i+1]+dp[i][0], 10-(a[i+1]+1)+dp[i][1])
print(min(dp[n-1]))
# Judge status: Accepted
n = int(input())
s = input()
w_c=0
e_c=0
ans=n
for i in s:
  if i == 'E':
    e_c+=1
for i in s:
  if i == 'E':
    e_c-=1
  k=w_c+e_c
  if ans > k:
    ans = k
  if i == 'W':
    w_c+=1
print(ans)
# Judge status: Accepted
n , a , b , c , d = map(int,input().split())
s = input()
if s[a:c+1].count("##") != 0 or s[b:d+1].count("##") != 0:
    print("No")
    exit()
if c > d:
    if s[b-2:d+1].count("...") == 0:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
import sys
N = int(input())
array = [ I for I in range(1,10) ]

if not ( 1 <= N <= 100 ): sys.exit()

if N >= 82:
    print('No')
else:
    for J in array:
        if N % J == 0: print('Yes'); sys.exit()
print('No')
# Judge status: Accepted
n = int(input())
ans = 0
i = 2
 
while n>1 and i*i<=n:
  if n % i == 0:
    c = 0
    while n % i == 0:
      n = n / i
      c += 1
    j = 1
    while c>=j:
      ans=ans+1
      c -= j
      j += 1
 
  i = i + 1
      
    
if n > 1:
  ans = 1 + ans
 
print(ans)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))


def calc_total(A):
    total = []
    for x, y in zip(A, A[1:]):
        total.append(x ^ y)
    return total


total = A
while len(total) != 1:
    total = calc_total(total)
total = total[0]
ans = []
for a in A:
    ans.append(total ^ a)
print(*ans)
# Judge status: Wrong Answer
alfa=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
c=input()
print("'"+c+"'"+"の次は'"+alfa[alfa.index(c)+1]+"'です。")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
num=(a[0]+a[-1])//2
ans=0
for i in range(n):
    ans+=(num-a[i])**2
print(ans)
# Judge status: Wrong Answer
c=[]

for i in range(3):
    c.append(list(map(int,input().split())))

a=[0]*3
b=[0]*3
for i in range(3):
    a[i]=sum(c[i][0:3])
    b[i]=sum(c[0:3][i])

if (a[0]-a[1])%3!=0 or (a[1]-a[2])%3!=0 or (a[2]-a[0])%3!=0:
    ans="No"
elif (b[0]-b[1])%3!=0 or (b[1]-b[2])%3!=0 or (b[2]-b[0])%3!=0:
    ans="No"
else:
    ans="Yes"
print(ans)
# Judge status: Accepted
S=input()
s="keyence"
l=len(S)
for i in range(l):
    for j in range(i,l+1):
        if s==S[:i]+S[j:]:
            print("YES")
            break
    else:
        continue
    break
else:
    print("NO")
# Judge status: Accepted
x=int(input())
cnt,i=0,0
while i<x:
    cnt +=1
    i +=cnt
print(cnt)
# Judge status: Wrong Answer
A,B=map(int,input().split())
if B > A:
    A,B = B,A

for i in range(1, int(10**5 / A)):
    if (A * i) % B == 0:
        print(A * i)
        break
# Judge status: Accepted
A,B,C,D=map(int,input().split())
flag=True
while A >0 and C>0:
    C = C-B
    if C<=0:
        print('Yes')
        flag = False
        break
    A = A-D
if flag:
    print('No')
# Judge status: Accepted
from collections import Counter
N = int(input())
S = list(str(input()))
mod = 10**9+7
count = 1
cs = Counter(S)

for key,value in cs.items():
  count *= (value+1)

print((count-1)%mod)
# Judge status: Accepted
n = int(input())
lis = list(map(int, input().split()))
dp = []
for k in range(n+1):
    dp.append(0)

for i in range(2, n+1):
    if i == 2:
        dp[i] = abs(lis[i-1]-lis[i-2])
        #print(i, dp[i])
    else:
        #print(i)
        dp[i] = min(abs(lis[i-1]-lis[i-2])+dp[i-1], abs(lis[i-1]-lis[i-3])+dp[i-2])
        #print(i, dp[i])
print(dp[n])
# Judge status: Accepted
from collections import defaultdict

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

MOD = 998244353

p = defaultdict(int)
for d in D:
    p[d] += 1

if p[0] == 1 and D[0] == 0:
    ans = 1
    for i in range(N + 1):
        ans *= p[i] ** p[i + 1]
        ans %= MOD

    print(ans % MOD)

else:
    print(0)
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

if S[:A].isdigit() and S[-B:].isdigit() and S[A] == '-':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
AA = list(map(int,input().split()))
cnt = 0
for i in range(0,N,2):
  if AA[i]%2==1:
    cnt+=1
print(cnt)
# Judge status: Accepted
N, K = list(map(int, input().split()))

if N%K != 0:
  print("1")
else:
  print("0")
# Judge status: Accepted
N=int(input())
n=N-1
ans=1
for a in range(1,n):
    ans+=n//a
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
d=int(a/0.08)
u=int(b/0.1)
ans=-1
if min(d,u)>12:
    start=min(d,u)-12
else:
    start=0
for i in range(start,max(d,u)+13):
    if (int(i*0.08)==a)and(int(i*0.1)==b):
        ans=i
        break
print(ans)
# Judge status: Accepted
import math
print 2 ** int(math.floor(math.log(int(raw_input()),2)))
# Judge status: Wrong Answer
N = int(input())

def num10to26(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num10to26(num//26-1)+chr(90)
    else:
        return num10to26(num//26)+chr(64+num%26)

print(num10to26(N))
# Judge status: Wrong Answer
k,n = map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  ans=max(ans,abs(a[i]-a[i-1]))
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
a_div_2 = [1 if a[i] % 2 == 0 and a[i] % 4 != 0 else 0 for i in range(n)]
a_div_4 = [1 if a[i] % 4 == 0 else 0 for i in range(n)]
if a_div_2.count(1) // 2 + a_div_4.count(1) >= n // 2: print("Yes")
else: print("No")
# Judge status: Accepted
import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x: x*(-1),A))

heapq.heapify(A)
for i in range(M):
    temp=heapq.heappop(A)
    heapq.heappush(A,temp//2+temp%2)
    
print(-sum(A))
# Judge status: Wrong Answer
import math
N = int(input())

enter = int(math.sqrt(N))
value_array = []
for x in range(7, enter):
  for y in range(7, enter):
    for z in range(7, enter):
      value_array.append(x**2 + y **2 + z ** 2 + x*y + y*z + z*x)

for i in range(1, N+1):
  print(value_array.count(i))
# Judge status: Accepted
s=input()
print(len(s)-abs(s.count('0')-s.count('1')))
# Judge status: Wrong Answer
S = list(input())

fo = int(''.join(S[:2]))
la = int(''.join(S[2:]))

if fo==0 or la==0:
  print("NA")
elif fo <= 12 and la <= 12:
  print("AMBIGUOUS")
elif fo <= 12 and la > 13:
  print("MMYY")
elif fo > 13 and la <= 12:
  print("YYMM")
else:
  print("NA")
# Judge status: Accepted
import sys
import numpy as np
import math
input=sys.stdin.readline


a,b,h,m=map(int,input().split())
t=60*h+m
hun=6*t%360
zi=0.5*t
deg=min(360-abs(zi-hun),abs(zi-hun))
ans=a**2+b**2-2*a*b*math.cos(math.radians(deg))
print(pow(ans,0.5))
# Judge status: Accepted
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    temp=0
    ans=[]
    dame=0
    end=0
    for i in range(1,10**7):
        temp+=i
        if temp>=N:
            dame=temp-N
            end=i
            break
    for j in range(1,end+1):
        if j!=dame:print(j)
#%%submit!
resolve()
# Judge status: Accepted
# coding:utf-8
n = int(input())
s = input()
ans = 0

for i in range(n):
    right = s[:i]
    left = s[i:]
    tmp = len(set(right) & set(left))
    ans = max(tmp, ans)

print(ans)
# Judge status: Accepted
s= input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if max(a,b,c) -min(a,b,c) <= 1:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
l = list(map(int, input().split()))
for i,j in enumerate(l):
  if j == 0:
    print(i+1)
    break
# Judge status: Accepted
a,b = map(int,input().split())
if(a <= b):
  print(str(a) * b)
else:
  print(str(b) * a)
# Judge status: Wrong Answer
N = int(input())
V = sorted(list(map(int,input().split())))

ans = 0

ans += (V[0]+V[1])/2**(len(V)-1)

print(ans)

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

print(ans)
# Judge status: Accepted
def main():
    a,b,c,x,y = map(int, input().split())
    ans = 10**10
    for i in range(max(x, y)+1):
        total = i*2*c + max(0, x-i)*a + max(0, y-i)*b
        ans = min(ans, total)
    print(ans)


    
if __name__ == '__main__':
    main()
# Judge status: Accepted
def abc106b_105():
    n = int(input())
    cnt = 0
    for i in range(1, n + 1):
        if i % 2 == 0: continue
        yaku_cnt = 0
        for j in range(1, i + 1):
            if i % j == 0:
                yaku_cnt += 1
        if yaku_cnt == 8:
            cnt += 1

    print(cnt)


abc106b_105()
# Judge status: Wrong Answer
n,k = map(int,input().split())
h = list(map(int,input().split()))

h = sorted(h,reverse=True)

attack_n = 0

if k >= n:
    pass

else:
    for i in h[n-k-1:]:
        attack_n += i

print(attack_n)
# Judge status: Accepted
S = input()


def f():
    for i in range(len(S)):
        for j in range(len(S)):
            if S[:i] + S[j:] == "keyence":
                print("YES")
                return
    else:
        print("NO")


f()
# Judge status: Wrong Answer

N, K = map(int, input().split())
X = list(map(int, input().split()))

ub = 10 ** 9 + 7
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2

    res = 0
    for v in X:
        res += v // mid

    if res <= K:
        ub = mid
    else:
        lb = mid

if K == 0:
    print(max(X))
else:
    print(ub)
# Judge status: Accepted
def main():
    n, m = map(int,input().split()) 
    startlis = []
    endlis = []

    for i in range(m):
        a, b = map(int, input().split())
        startlis.append(a)
        endlis.append(b)
    
    start = max(startlis)
    end = min(endlis)

    print(max(0,end - start + 1))





    
if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
S = str(input())

w = S.count('.')
b = S.count('#')
cnt = N+1
tmp = w
for i in range(N):
  if S[i] == '.':
    tmp -= 1
  else:
    tmp += 1
  cnt = min(cnt, tmp)
    
ans = min(w, b, cnt)
print(ans)
# Judge status: Wrong Answer
S = list(input())
a=0
b=0
if S[0]=="0":
    for i in S[::2]:
        print(i)
        if i=="1":
            a+=1
    for k in S[1::2]:
        if k=="0":
            a+=1

if S[0]=="1":
    for i in S[::2]:
        if i=="0":
            b+=1
    for k in S[1::2]:
        if k=="1":
            b+=1
print(max(a,b))
# Judge status: Accepted
s = input()
t = input()

s2 = sorted(s)
t2 = sorted(t, reverse=True)

print("Yes" if s2 < t2 else "No")
# Judge status: Accepted
N = int(input())
N_ = str(N)
n = len(N_)

if n == 1:
    print(N)
    exit()

for i in range(1, n):
    if N_[i] != '9':
        break
else:
    ans = int(N_[0]) + 9*(n-1)
    print(ans)
    exit()

ans = int(N_[0])-1 + 9*(n-1)
print(ans)
# Judge status: Wrong Answer
x,y,z = map(int,input().split())
if x/z>=y:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
## A - Cookie Exchanges
A, B, C = map(int, input().split())
if not (A%2 == B%2 == C%2 == 0):
    ans = 0
elif A == B == C:
    ans = -1
else:
    ans = 0
    while A%2 == B%2 == C%2 == 0:
        a = (B+C) // 2
        b = (C+A) // 2
        c = (A+B) // 2
        A = a
        B = b
        C = c
        ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
def num2(num):
    if num<=26:
        return chr(num+96)
    elif num%26==0:
        return num2(num//26-1)+chr(122)
    else:
        return num2(num//26)+chr(96+num%26)
print(num2(n))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
ans = 'Yes' if b-a == c-b else 'No'
print(ans)
# Judge status: Accepted
N = int(input())

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

total1 = 0
total2 = 0

for i in range(N):
    if a[i]>b[i]:
        total1 += a[i]-b[i]
    else:
        total2 += (b[i]-a[i])//2

if total1 <=total2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()
q = int(input())
r, st1, st2 = 0, "", ""
for _ in range(q):
  query = input()
  if query[0] == "1":
    r += 1
  else:
    t, f, c = query.split()
    if (r + int(f)) % 2:
      st1 += c
    else:
      st2 += c

string = "".join(reversed(list(st1))) + s + st2
if r % 2 == 0:
  print(string)
else:
  print("".join(reversed(list(string))))
# Judge status: Accepted
x = int(input())
def level(x):
    if x >= 1800:
        return 1
    elif x>= 1600:
        return 2
    elif x>=1400:
        return 3
    elif x>=1200:
        return 4
    elif x >= 1000:
        return 5
    elif x >= 800:
        return 6
    elif x >= 600:
        return 7
    else:
        return 8
print(level(x))
# Judge status: Accepted
s = int(input())
mod = 1000000007
dp = [0]*(s+1)
dp[0] = 1
for i in range(3,s+1):
    for j in range(i-2):
        dp[i] += dp[j]
        dp[i] %= mod
print(dp[s])
# Judge status: Accepted
N = int(input())
for i in range(1,10):
    for j in range(1,10):
        if i*j == N:
            print("Yes")
            exit()

print("No")
# Judge status: Accepted
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k])
print(max(dp[N]))
# Judge status: Wrong Answer
N = int(input())
li = list(map(int, input().split()))

li.sort()

sum = 0
for i in li[:-2]:
    sum = i + sum

Nmax = li[-1]
if N <= 2 or li[0] < 1:
    print("No")
elif Nmax < sum:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
s = input()
t = input()

if t in s:
  print(N)
  quit()

for i in range(1, N+1):
  if t in (s + t[-i:]):
    print(N+i)
    quit()
# Judge status: Accepted
def assert_(s, t):
    if s != t:
        print("No")
        exit()

def main():
    S = input()
    T = input()

    mapping = {}
    mapping_ = {}
    for i in range(len(S)):
        if S[i] in mapping:
            assert_(mapping[S[i]], T[i])
        if T[i] in mapping_:
            assert_(mapping_[T[i]], S[i])
        mapping[S[i]] = T[i]
        mapping_[T[i]] = S[i]
    print("Yes")

main()
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
for a in A:
  if a%2:
    continue
  if a%3==0 or a%5==0:
    continue
  else:
    print('DENIED')
    break
else:
  print('APPROVED')
# Judge status: Wrong Answer
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


N=input1()
p=input_array()
count=0
for i in p:
	flag=True
	for j in p[:i+1]:
		if i<=j:
			flag=True
		else:
			flag=False
			break
	if flag:
		count+=1
print(count)
# Judge status: Wrong Answer
from math import floor	# 切り下げ
h = int(input())
cnt = 0
def attack(hp):
  if hp == 1:
    global cnt
    cnt += 1
    return
  else:
    hp = floor(hp/2)
    attack(hp)
    attack(hp)

attack(h)
print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ope = 0
for i in range(n):
    if b[i] > a[i]:
        ope+=(b[i]-a[i]+1)//2

if sum(b) - sum(a) < 0:
    print('No')        
elif ope <= sum(b) - sum(a):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
num = 26
arr = []
ans = ""
moji = "abcdefghijklmnopqrstuvwxyz"
flg = False

ar = []
n = n - 1
for i in range(10000):
    arr.append(n % num)
    n = n // num - 1
    if n < 0:
        break

arr.reverse()

ans = ""

for i in arr:
    ans +=moji[i]
print(ans)
# Judge status: Wrong Answer
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(int(input()) for _ in range(n))

    res, A[0] = divmod(A[0], 2)
    for i in range(1, n):
        cnt, A[i] = divmod(A[i], 2)
        res += cnt
        if A[i - 1] and A[i]:
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()