peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
#A
a, b = map(int, input().split())
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
a,b = map(int,input().split())

if a <= 5 :
    print(0)
elif 6 <= a <= 12 :
    print(b//2)
else :
    print(b)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

res = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        res += 1
print(res)
# Judge status: Accepted
def main():
    N, *A = map(int, open(0).read().split())
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    b = A[N // 2]
    print(sum([abs(A[i] - b) for i in range(N)]))
    return


main()
# Judge status: Accepted
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    for a in range(1,B+1):
        _ = (a*A)%B
        if _ == C:
            TF = 'YES'
            break
    else:
        TF = 'NO'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)
# Judge status: Accepted
X = input()

cntS = 0
res = 0
for x in X:
    if x == "S":
        cntS += 1
    elif cntS > 0:
        cntS -= 1
    else:
        res += 1

print(res + cntS)
# Judge status: Wrong Answer
length=int(input())
s=input()
string = ""
if len(s) < length:
    print(s)

else:
    for i in range(0,length):
        string += s[i]
    string +="..."

    print(string)
# Judge status: Accepted
if "9" in input():
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import bisect

N = int(input())
L = sorted([int(n) for n in input().split()])
#print(L)

count = 0
for i in range(N-1):
    for j in range(i+1, N):
        count += bisect.bisect(L[j+1:], L[i]+L[j])

print(count)
# Judge status: Accepted
N,K= map(int,input().split())
p= list(map(int,input().split()))

p.sort()
print(sum(p[:K]))
# Judge status: Accepted
n=int(input())
h=[int(x) for x in input().split()]
a=1
for i in range(n-1):
  if h[i]>h[i+1]:
    h[i+1]+=1
    if h[i]>h[i+1]:
      print("No")
      a=0
      break
if a==1:
  print("Yes")
# Judge status: Accepted
N = input()
N = int(N) //2 + int(N)%2
print(N)
# Judge status: Accepted
import math
n,k=map(int,input().split())
p=0
for i in range(1,n+1):
  if k/i<=1:
    p+=1
  else:
    thrw=math.ceil(math.log2(k/i))
    p+=0.5**thrw
print(p/n)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n = ii()
l = []
for _ in range(n):
    l.append(iil())

l.sort(key=lambda x:x[1])

time = 0

for item in l:
    time += item[0]
    if time <= item[1]:
        continue
    else:
        print('No')
        exit()

print('Yes')
# Judge status: Wrong Answer
def has_duplicates(seq):
    return len(seq) == len(set(seq))

iranai  =input()
l   =   input()
if has_duplicates(l)== "TRUE":
	print("YES")
else:
  	print("NO")
# Judge status: Accepted
N = int(input())
strlist = 'abcdefghij'

def dfs(s, i):
  if len(s) == N:
    print(s)
  else:
    for j in range(i+1):
      t = s + strlist[j]
      if j == i:
        dfs(t, i+1)
      else:
        dfs(t, i)

dfs('', 0)
# Judge status: Accepted
import sys

s = input()
t = input()

s = sorted(s)
t = sorted(t)[::-1]

N = len(s)
M = len(t)

if N < M:
    if s == t[:N]:
        print('Yes')
        sys.exit()
N = min(N, M)
i = 0
while i < N and s[i] == t[i]:
    i += 1
if i < N and s[i] < t[i]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def resolve():
    n = int(input())
    ans = float('inf')
    c = divisor(n)
    for a in c:
        b = n//a
        ans = min(ans,a+b-2)
    print(ans)
resolve()
# Judge status: Wrong Answer
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.sort(reverse=True)
for i in range(0, N, 2):
  if i == N-2 or i == N-1:
    total = total + score[i]
  else:
    total = total + (score[i]-score[i+1])
 
print(total)
# Judge status: Wrong Answer
n=int(input())
s=list(input())
w=[0]*n
for i in range(n):
    if s[i]=="E":
        w[i]=1
from itertools import accumulate    
d=list(accumulate([0]+w))
ans=10**10
cnt=0
for i in range(n):
    cnt=i-d[i]+d[-1]-d[i]
    ans=min(ans,cnt)
print(ans)
# Judge status: Accepted
s=input()
cnt_a=s.count('a')
cnt_b=s.count('b')
cnt_c=s.count('c')
ac=abs(cnt_a-cnt_c)
ab=abs(cnt_a-cnt_b)
bc=abs(cnt_b-cnt_c)
if ab<=1 and ac<=1 and bc<=1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())

ans=0

while b <= a:
  b=b*2
  ans += 1
  
while c <= b:
  c=c*2
  ans += 1

if ans <= k:print("YES")
else:print("NO")
# Judge status: Accepted
import math 
a,b=(int(x) for x in input().split())
if(a%2 != b%2):
    print("IMPOSSIBLE")
else:
    k=int (a+b)/2
    print(math.floor(k))
# Judge status: Accepted
n, x, y= map(int, input().split())

ans = [0] * n

for i in range(1, n + 1):
  for j in range(i + 1, n + 1):
    min_dis = min([
      j - i, 
     abs(j - y) + 1 + abs(x - i),
    ])
    ans[min_dis] += 1

for i in range(1, n):
  print(ans[i])
# Judge status: Accepted
n = int(input())
s = input()
print(''.join(chr((ord(c) - ord('A') + n) % 26 + ord('A')) for c in s))
# Judge status: Accepted
n = int(input())
s = str(input())
rn = s.count("R")
gn = s.count("G")
bn = s.count("B")
 
ct=0
for i in range(n):
  for j in range(i+1,n):
    k = 2*j - i
    if k >= n:
      break
    elif s[i]!=s[j] and s[j]!=s[k]and s[i]!=s[k]:
      ct += 1
 
print(rn*gn*bn-ct)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split( )))
ans = 0
tmp = n+1
for i in range(n):
    if tmp>=a[i]:
        tmp = a[i]
        ans += 1
    tmp = max(a[i],tmp)
print(ans)
# Judge status: Accepted
import math
A, B, H, M = map(int, input().split(' '))
deg = abs(H * 30 + 0.5 * M - 6 * M)
if deg > 180:
    deg = 360 - deg
deg = math.radians(deg)
print(math.sqrt((B - A * math.cos(deg)) ** 2 + (A * math.sin(deg)) ** 2))
# Judge status: Accepted
a,b,c = map(int, input().split())
s = [a,b,c]
print(len(set(s)))
# Judge status: Accepted
n = int(input())
S = [int(input()) for i in range(n)]
S.sort()
x = sum(S)
if x % 10 == 0:
    for i in range(n):
        if S[i] % 10 != 0:
            x -= S[i]
            print(x)
            exit()
    print(0)
else:
    print(x)
# Judge status: Accepted
ab = int("".join(input().split()))**0.5

if ab.is_integer():
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())

x = 800 * n
y = (n // 15) *200

print(x-y)
# Judge status: Accepted
N,a,b=map(int,input().split())

if (b-a)%2==0 :
    print(((b-a)//2))
else:
    print(min(b-1,N-a,int(N-b+(b-a+1)//2),int(a+(b-a-1)//2)))
# Judge status: Accepted
import sys
input=sys.stdin.readline
from itertools import accumulate
def main():
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  k=k if k<50 else 50
  for _ in range(k):
    b=[0]*(n+1)
    for i in range(n):
      ai=a[i]
      l,r=i-ai,i+ai+1
      l=0 if l<0 else l
      r=n if r>n else r
      b[l]+=1
      b[r]-=1
    b=tuple(accumulate(b))[:-1]
    a=b
    if min(set(b))==n:
      break
  print(*a)
if __name__ == '__main__':
  main()
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
ans=0
c=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
    else:
        ans=max(ans,c)
        c=0
ans=max(ans,c)
print(ans)
# Judge status: Accepted
S=input()
S_len=len(S)
count=0
for i in range(int(S_len/2)):
  if S[i]!=S[S_len-i-1]:
    count+=1
print(count)
# Judge status: Accepted
N = int(input())
x = N % 10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]
if x in hon:
    print('hon')
elif x in pon:
    print('pon')
elif x in bon:
    print('bon')
# Judge status: Accepted
def main():
  N,M,*alst=map(int, open(0).read().split())
  alst=set(alst)
  mod=10**9+7
  dp = [0] * (N+1)
  dp[:2] = [1, 1 if 1 not in alst else 0]
  for i in range(2, N+1):
    if i not in alst:
      dp[i] = (dp[i-2] + dp[i-1])%mod
  print(dp[N])
main()
# Judge status: Accepted
X, A, B = map(int, input().split())

print('delicious' if A >= B else ('safe' if (A + X) >= B else 'dangerous'))
# Judge status: Accepted
N, K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
p.sort()
price = 0
for i in range(K):
  price += p[i]
print(price)
# Judge status: Accepted
import sys
input = sys.stdin.readline

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

t = 1

s = 0

if t not in a:
    s = -1
else:
    for x in a:
        if x == t:
            t += 1
        else:
            s += 1

print(s)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a < c < b:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a=list(input())
s=list(input())
ans=sorted(a)
ans1=sorted(s)
if ans<ans1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
s = input()
ans = list()
for ss in s:
  if ss == '0':
    ans.append('0')
  elif ss == '1':
    ans.append('1')
  else:
    if ans:
      ans.pop(-1)

print(''.join(ans))
# Judge status: Accepted
x = int(input())
print(8-((x-400)//200))
# Judge status: Accepted
N = input()

DP_just = 0
DP_plus = 1

for c in N:
    d = int(c)
    last_just = DP_just
    last_plus = DP_plus
    DP_just = min(last_just + d, last_plus + 10 - d)
    d += 1
    DP_plus = min(last_just + d, last_plus + 10 - d)

print(DP_just)
# Judge status: Accepted
A, B, C, X, Y = map(int, input().split())

ans = 10**18
for ab in range(max(X, Y) * 2 + 10):
    a = max(0, X - ab // 2)
    b = max(0, Y - ab // 2)
    ans = min(ans, A * a + B * b + C * ab)
print(ans)
# Judge status: Accepted
n = int(input())
C, S, F = [[0]*n for i in range(3)]
for i in range(1, n):
    c, s, f = map(int, input().split())
    C[i], S[i], F[i] = c, s, f

ans = [0]*(n+1)
for i in range(1, n):
    t = S[i]+C[i]
    for j in range(i+1, n):
        t = S[j]+C[j]+[0, -(-(t-S[j])//F[j])*F[j]][S[j] < t]
    ans[i] = t

print(*(x for x in ans[1:]), sep="\n")
# Judge status: Accepted
n = int(input())
import string
A = [chr(i) for i in range(ord("a"),ord("a")+10)]
B = {}
for i in range(10):
    B[A[i]] = i

def d(s,t,ANS):
    if len(s) == n:
        ANS.append(s)
    else:
        for i in range(t+2):
            d(s + A[i],max(i,t),ANS)
ANS = []

d("",-1,ANS)

ANS.sort()
for i in ANS:
    print(i)
# Judge status: Accepted
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
    min_l = 1000000000
    index = 0
    for j in range(m):
        d = abs(l[i][0] - p[j][0]) + abs(l[i][1] - p[j][1])
        if min_l > d:
            min_l = d
            index = j
    print(index + 1)
# Judge status: Wrong Answer
num = list(input())
n = len(num) - 1
lst = ["-"]*n

for i in range(2**n):
    temp = [0]*(len(num)+n)
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    temp[::2] = num
    temp[1::2] = lst
    wa = eval("".join(temp[:]))
    if wa == 7:
        print("".join(temp[:]) + "=7")
        exit()
# Judge status: Accepted
import numpy as np
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d,e=0,0
for i in range(n):
  c=a[i]-b[i]
  if c>0:
    d+=c
  elif c%2==0:
    e+=-c
  else:
    e+=-c-1
print('Yes' if 2*d<=e else 'No')
# Judge status: Accepted
N,M = map(int,input().split())
H = list(map(int,input().split()))
c = [0] * N
for i in range(M):
    A,B = map(int,input().split())
    if H[A -1] >= H[B -1]:
        c[B - 1] += 1
    if H[B - 1] >= H[A - 1]:
        c[A - 1] += 1
print(c.count(0))
# Judge status: Accepted
arr = input().split()
arr = list(map(int,arr))
s = set(arr)
print(len(s))
# Judge status: Accepted
n = int(input())
w = 1000000007

if(n == 1):
  print(0)
  exit()
if(n == 2):
  print(2)
  exit()
  
ans1 = 1


for i in range(n):
  ans1 = ans1*10%w
  
ans2 = 2

for i in range(n):
  ans2 = ans2*9%w
  
ans3 = 1

for i in range(n):
  ans3 = ans3*8%w

ans = ans1-ans2+ans3
ans %= w
ans += w
ans %= w

print(ans)
# Judge status: Accepted
a, b, c, d = [int(_) for _ in input().split()]
if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n,s=open(0);print("YNeos"[s!=s[:int(n)//2]*2::2])
# Judge status: Accepted
from sys import stdin
input = stdin.buffer.readline

def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]

    dp = [0] * (w + 1)
    for weight, value in wv:
        for i in range(w - weight + 1)[::-1]:
            if dp[i + weight] < dp[i] + value:
                dp[i + weight] = dp[i] + value

    print(dp[w])

main()
# Judge status: Accepted
import numpy as np

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

a = np.array(A)

odd = a[a%2 == 0]

if np.sum((odd%3 != 0)&(odd%5 != 0)) == 0:
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
N = int(input())
print(int((N+1)*N/2))
# Judge status: Accepted
A, B, M = list(map(int,input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = [list(map(int, input().split())) for _ in range(M)]

# no discount
min_val = min(a) + min(b)
# with discount
for ai, bi, ci in m:
    val = a[ai-1] + b[bi-1] - ci
    if min_val > val:
        min_val = val
print(min_val)
# Judge status: Wrong Answer
N,k=map(int,input().split())
A=input()
ans=0
for i in range(0,N-1):
  if A[i]==A[i+1]:
    ans=ans+1
if A[N-2]=='R' and A[N-1]=='R':
  ans=ans-1
print(min(N-1,2*k+ans))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def main():
    S = input()
    if S[-1] == "s":
        print(S + "es")
    else:
        print(S + "s")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
from math import ceil
from fractions import gcd

a, b = map(int, input().split())
c = gcd(a, b)
count = 1
for num in range(2, ceil(c**0.5) + 1):
  if c % num == 0:
    count += 1
    while c % num == 0:
      c = c // num
print(count)
# Judge status: Wrong Answer
count = 0

def check(a,b,c,n):
    if n==0:
        global count
        count += 1
        return
    if n<0:
        return
    if a>0:
        check(a-1,b,c,n-500)
    if b>0:
        check(a,b-1,c,n-100)
    if c>0:
        check(a,b,c-1,n-50)
    return



a = int(input())
b = int(input())
c = int(input())
x = int(input())

check(a,b,c,x)

print(count)
# Judge status: Accepted
l = [[int(i) for i in input().split()] for _ in range(3)]

total1 = 0
total2 = 0


for i in range(3):
    total1 += sum(l[i])
    total2 += l[i][i]
    
if total1 == total2 * 3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
f=lambda:map(int,sys.stdin.readline().split())
h,n=f()
dp=[10**9]*(h+1)
dp[0]=0
for i in range(n):
  a,b=f()
  for j in range(h+1):
    dp[j]=min(dp[j],dp[max(j-a,0)]+b)
print(dp[h])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = []
R = 0
L = sum(A)
for i in range(N):
  B.append(abs(L-R))
  R += A[i]
  L -= A[i]
print(min(B))
# Judge status: Wrong Answer
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one + 1
    right = N - one + 1
    if right < K or left < K:
        print(ceil(N / K))
    else:
        print(ceil(left / K) + ceil(right / K))
# Judge status: Accepted
X=input()
ans = []
for i in X:
    if i=='S':
        ans.append(i)
    elif i=='T' and (not ans or ans[-1] == 'T'):
        ans.append(i)
    else:
        ans.pop()
print(len(ans))
# Judge status: Wrong Answer
k,x = map(int,input().split())
for i in range(x-k+1,x+k):
  print(i,end="")
# Judge status: Accepted
K = int(input())

rnrn = list(range(10))

idx = 0
for idx_base in range(0, K + 1):
    base = rnrn[idx_base]
    for d in (-1, 0, 1):
        digit = base % 10 + d
        if digit < 0 or 9 < digit: continue
        if base == 0: continue
        rnrn.append(10 * base + digit)
        if len(rnrn) >= K + 1: break
    if len(rnrn) >= K + 1: break

# print("#", rnrn)
print(rnrn[K])

# なんでや！阪神関係無いやろ！
# Judge status: Accepted
s,w=input().split()
if(int(s)>int(w)):
    print('safe')
else:
    print('unsafe')
# Judge status: Accepted
n = int(input())
w = []
for _ in range(n):
    ww = list(input())
    w.append(ww)
    
bool = True
for i in range(n-1):
    if w.count(w[i]) == 1:
        if w[i][-1] == w[i+1][0]:
            continue
        else:
            bool = False
            break
    else:
        bool = False
        break
        
print('Yes' if bool else 'No')
# Judge status: Accepted
s=input().split()
print("A"+s[1][0]+"C")
# Judge status: Accepted
import numpy as np
 

A = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for _ in range(n):
  b = int(input())
  A = np.where(A == b, 0, A)
  
x = np.all(A[[0, 1, 2], [0, 1, 2]] == 0)
y = np.all(A[[0, 1, 2], [2, 1, 0]] == 0)
z = np.any(np.sum(A, axis=0) == 0)
w = np.any(np.sum(A, axis=1) == 0)
 
print(['Yes', 'No'][not x and not y and not z and not w])
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

X = 0

if H <= W:
  X = N // W
  if N % W != 0:
    X = X + 1
else :
  X = N // H
  if N % H != 0:
    X = X + 1
  
print(X)
# Judge status: Wrong Answer
from math import floor

def solve(n, A):
    b = floor(sum(a - (i + 1) for i, a in enumerate(A)) / n)
    return sum(abs(a - (b + i + 1)) for i, a in enumerate(A))

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))
# Judge status: Accepted
N = int(input())
ls = []
ans = ('Yes')
for i in range(N):
    ls.append(input())
for i in range(1,N):
    if ls[i] in ls[:i]:
        ans = ('No')
        break
    else:
        if ls[i][0] == ls[i-1][-1]:
            continue
        else:
            ans = ('No')
            break
print(ans)
# Judge status: Wrong Answer
n = int(input())
if n == 1:
  print(1)
elif n%2 == 0:
  print(0.5)
else:
  print(0.6)
# Judge status: Accepted
from collections import *
k=int(input());q=deque(range(1,10));c=0
while c<k:
  t=q.popleft()
  for j in range(max(t%10-1,0),min(t%10+2,10)): q+=[t*10+j]
  c+=1
print(t)
# Judge status: Wrong Answer
n = list(input())
n = [int(i) for i in n]
l =  [0]
s = sum(n)
if s%9 == 0 and l != n:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s = input()
n = len(s)

if s[:(n-1)//2] == ''.join(reversed(s[:(n-1)//2])) and s[((n+3)//2-1):] == ''.join(reversed(s[((n+3)//2-1):])):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
S = input()
if(S=="RRR"):
  print(3)
elif(S=="RRS" or S=="SRR"):
  print(2)
elif(S[0]=="R" or S[1]=="R" or S[2]=="R"):
  print(1)
else:
  print(0)
# Judge status: Accepted
_, *a = map(int, open(0).read().split())
*z, = map(abs, a)
s = sum(z)
print(s if len([i for i in a if i<0])%2==0 or 0 in a else s-min(z)*2)
# Judge status: Accepted
N, x = [int(i) for i in input().split()]

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

if a[0] > x:
    ans+=a[0]-x
    a[0] = x

for i in range(1, N):
    if (a[i-1]+a[i] > x):       
        ans+= (a[i]-(x-a[i-1]))
        a[i] = x-a[i-1]
        
print(int(ans))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

d = {}
for each in a:
  d[each] = d.get(each, 0) + 1
  d[each-1] = d.get(each-1, 0) + 1
  d[each+1] = d.get(each+1, 0) + 1
  
print(max(d.values()))
# Judge status: Wrong Answer
d,t,s=map(int,input().split())
if(d//s<=t):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
x = int(input())

if x:
    print(0)
else:
    print(1)
# Judge status: Accepted
n,k=map(int, input().split())
a=list(map(int, input().split()))
for x in range(k,n):
    if a[x]>a[x-k]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import math
N = int(input())
A = [int(X) for X in input().split()]
Left  = [0]*(N+1)
Right = [0]*(N+1)
GCDLR = [0]*(N+1)
for T in range(0,N):
    Left[T+1] = math.gcd(Left[T],A[T])
    Right[N-T-1] = math.gcd(Right[N-T],A[N-T-1])
    
for T in range(0,N):
    GCDLR[T] = math.gcd(Left[T],Right[T+1])
print(max(GCDLR))
# Judge status: Accepted
n = int(input())
arr = sorted(list(map(int, input().split())))
res = arr[0]
for i in range(1, n):
    res = (res + arr[i]) / 2
print(res)
# Judge status: Wrong Answer
r = int(input())

m = 3.14*r*r
ans = int(m/3.14)
print(ans)
# Judge status: Accepted
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
G = Graph(ab)

for new_v in G[0]:
    if n in G[new_v - 1]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Judge status: Accepted
N=int(input())
ans=1
mod=10**9+7

for i in range(1,N+1):
    ans=ans*i
    ans=ans%mod

print(ans)
# Judge status: Accepted
n = int(input())
for i in range(111, 1000, 111):
    if i >= n:
        print(i)
        break
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
mini = 112345678909
ans = 0
for i in range(n):
    if p[i] < mini:
        ans += 1
        mini = min(mini,p[i])
print(ans)
# Judge status: Wrong Answer
O = list(input())
E = list(input())
for x, y in zip(O, E):
    print(x+y,end="")
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]

res = sum(i for i in a)
ans = 0
base = 1e9 + 7
for i in a:
  res -= i
  ans += (i * res)
  
print(ans % base)
# Judge status: Accepted
N = int(input())

lst = []
m = 0
temp = [[0]]

while temp:
    p = temp.pop()
    if len(p)==N:
        lst.append(p)
    else:
        for i in range(max(p)+2):
            s = p[:]
            s.append(i)
            temp.append(s)

lst.sort()
abc = 'abcdefghij'
for l in lst:
    print(*[abc[i] for i in l], sep='')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i in range(n):
    ans[a[i]-1] = i+1
print(*ans)
# Judge status: Wrong Answer
def main():
    n = int(input())
    A = [0]*n
    B = [0]*n
    for i in range(n):
        a,b = map(int,input().split())
        A[i] = a
        B[i] = b
    A.sort()
    B.sort()
    if n%2 == 0:
        m1 = (A[n//2-1]+A[n//2])//2
        m2 = (B[n//2-1]+B[n//2])//2
        print(2*(m2-m1)+1)
    else:
        print(B[(n+1)//2-1]-A[(n+1)//2-1]+1)    
main()
# Judge status: Wrong Answer
N,M=map(int,input().split())
print((N**2-N)/2 + (M**2-M)/2)
# Judge status: Accepted
l = [int(x) for x in input().split()]
ans = 0
for i in range(l[0],l[1]+1):
    if i % l[2] == 0:
        ans += 1
print(ans)
# Judge status: Accepted
def countcut(A, length):
    ret = 0
    for a in A:
        ret += -(-a//length) - 1
    return ret


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    lo = 1
    hi = int(1e9)
    while lo < hi:
        mid = (lo+hi) // 2
        if countcut(A, mid) <= K:
            hi = mid
        else:
            lo = mid + 1
    print(lo)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N,K,S=map(int,input().split())

if S!=10**9:
    ANS=[10**9 for i in range(N)]
    for i in range(K):
        ANS[i]=S
else:
    ANS=[10**9-1 for i in range(N)]
    for i in range(K):
        ANS[i]=S
print(*ANS)
# Judge status: Wrong Answer
import math
import copy

neko = 0
nuko = 0
s = input()
a = ["0","1"]
for i in range(len(s)-1):
    if s[i] == a[i%2]:
        neko += 1
    if s[i] == a[(i+1)%2]:
        nuko += 1
if neko > nuko:
    neko = nuko
print(neko)
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
value1 = []
value2 = []
for value in c1.values():
    value1.append(value)
for value in c2.values():
    value2.append(value)
value1.sort(),value2.sort()
if value1 == value2:
    print("Yes")
else:
    print("No")