peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
s = list(input())
a = s[0]
cou = 1
i = 1
while i!=len(s) and i!=len(s)-1:
  if s[i]!=a:
    cou += 1
    a = s[i]
    i += 1
  #  print(0,a,cou,i)
  else:
    a = "".join(s[i:i+2])
    cou += 1
    i += 2
  #  print(10,a,cou,i)
#print(a,cou,i)
if a==s[-1] and len(a)==1:
  print(cou)
elif a=="".join(s[-2:]) and len(a)==2 and i==len(s)-2:
  print(cou)
else:
  print(cou+1)
# Judge status: Accepted
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
m1 = Y[N//2-1]
m2 = Y[N//2]

for x in X:
  if x<m2:
    print(m2)
  else:
    print(m1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

l=[0]*(n+1)
for i in a:
    l[i]+=1

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

for i in a:
    print(ans-l[i]*(l[i]-1)//2+(l[i]-1)*(l[i]-2)//2)
# Judge status: Wrong Answer
s = input()
s = s.replace("eraser", "")
s = s.replace("dreamer", "")
s = s.replace("erase", "")
s = s.replace("dream", "")
if len(s) == 0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
S,T=input().split()
A,B=map(int,input().split())
U=input()
print(S, T)
if(U==S):
    print(A-1, B)
else:
    print(A, B-1)
# Judge status: Wrong Answer
def main():
    tmp = int(input())
    if tmp >= 35:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
for i in range(1,10):
  if n % i == 0 and 1<= n/i <= 9:
    print("Yes")
    break
else:
  print("No")
# Judge status: Wrong Answer
from functools import lru_cache
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split(' '))))
i = np.arange(1, N + 1)

left = -2 * (10 ** 9)
right = 2 * (10 ** 9)


@lru_cache(maxsize=None)
def cost(b):
    return np.sum(np.abs(A - (i + b)))


while True:
    mid = (left + right) // 2
    c_left = cost(left)
    c_right = cost(right)
    if left == mid or right == mid:
        print(min(c_left, c_right))
        break
    elif c_left < c_right:
        right = mid
    else:
        left = mid
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
start = a[0]
for i in range(1, n):
    start = start ^ a[i]
ans = []
for i in range(n):
    ans_i = start ^ a[i]
    ans.append(str(ans_i))
print(' '.join(ans))
# Judge status: Wrong Answer
n = int(input())
a = [int(x) - 1 for x in input().split()]

target, point = 0, 0
ans = 0
for i in range(n):
    if a[i] == target:
        ans += i - point
        point = i + 1
        target += 1

if target == 0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
N,M = map(int, input().split())
P = [list(map(int, input().split())) for m in range(M)]
C = (N+1)*[0]
D = {}

for p,y in sorted(P,key=lambda x: x[1]):
  C[p]+= 1
  D[y]="%06d%06d" % (p,C[p])

for p,y in P:
  print(D[y])
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

k = int(input())

for i in range(k):
    if a < b and b < c:
        print("Yes")
        exit()

    elif a > b:
        b *= 2

    elif b > c:
        c *= 2

if a < b and b < c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
ans = sorted(p_list)[:k]
print(sum(ans))
# Judge status: Wrong Answer
s=input()
n=len(s)
a=[ord(i)-ord('a') for i in s]
k=int(input())
for i in range(n):
    if a[i]+k>=26 and a[i]>0:
        k-=26-a[i]
        a[i]=0
k%=26
print(a)
a[-1]+=k
a=[chr(i + ord('a')) for i in a]
print(*a,sep="")
# Judge status: Accepted
n = int(input())
print(n*800 - (n//15)*200)
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())

ans = float('inf')
for i in range(0, 2 * max(x, y)+1, 2):
    if min((x - (i // 2)), (y - (i // 2))) < 0:
        break
    #合計費用
    total = a * (x - (i // 2)) + b *(y - (i // 2)) + c * i
    ans = min(ans, total)
print(ans)
# Judge status: Accepted
N,T=map(int, input().split())
c_list=[]

for i in range(N):
    c,t=map(int, input().split())
    if t<=T:
        c_list.append(c)

if c_list==[]:
    print("TLE")
    
else:
    print(min(c_list))
# Judge status: Accepted
d = int(input())

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

for i in range(d):
    ls = list(map(int, input().split()))
    print(ls.index(max(ls))+1)
# Judge status: Accepted
a,b=map(int,input().split())
print(a+b//2)
# Judge status: Accepted
a = list(map(int, input().split()))

if a[0] % 2 == 1 or a[1] % 2 == 1 or a[2] % 2 == 1:
    print(0)
    exit()

cnt = 0
for _ in range(1000):
    for i in a:
        if i % 2 == 1:
            print(cnt)
            exit()
    a[0], a[1], a[2] = a[1] // 2 + a[2] // 2, a[0] // 2 + a[2] // 2, a[0] // 2 + a[1] // 2
    cnt += 1
else:
    print(-1)
# Judge status: Wrong Answer
import numpy as np
N=int(input())
alist=list(map(int, input().split()))

alist.sort()
#print(alist)
if alist.count(alist[0])==1:
    ans=1
else:
    ans=0
for i in range(1,N):
    a=alist[i]
    aaa=[a]*(i)
    x=np.array(aaa)
    y=np.array(alist[0:i])
    amari=x%y
    #print(x)
    #print(y)
    #print(amari)
    if list(amari).count(0)==0:
        ans+=1
print(ans)
# Judge status: Accepted
N = int(input())
Num = int(N/2)
perseNum = N%2
if perseNum != 0:
    print(Num+perseNum)
else:
    print(Num)
# Judge status: Wrong Answer
if __name__ == '__main__':
    a = int(input())
    max =0
    maxcount=0

    for i in range(1,a+1):
        s2 = i
        count =0
        while s2 >=2:
            if s2 %2 == 0:
                count+=1
                s2 = s2//2

            else:
                break
            if maxcount < count:
                max = i
                maxcount = count

    print(max)
# Judge status: Accepted
a,b,x = map(int,input().split())
if b >= x - a >= 0:
	print('YES')
else:
	print('NO')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]
 
numList = {}
sum = 0

for n in range(N):
  if A[n] not in numList:
    numList[A[n]] = 0
  numList[A[n]] += 1
  sum += A[n]

for q in range(Q):
  if S[q][0] in numList:
    if S[q][1] not in numList:
      numList[S[q][1]] = 0
    sum += (S[q][1] - S[q][0]) * numList[S[q][0]]
    numList[S[q][1]] += numList[S[q][0]]
    numList[S[q][0]] = 0
  print(sum)
# Judge status: Wrong Answer
N, M = map(int, input().split())
a = []
b = []
for i in range(N):
    a.append(input())
c = 0
for i in range(M):
    b.append(input())
for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if a[i+k][j:j+M] == b[k]:
                c += 1
        if c == M:
            print("Yes")
            break
print("No")
# Judge status: Wrong Answer
s = (input())
sa = s.find("a")
sz = int(s.rfind("z"))
print(sz-sa+1)
# Judge status: Accepted
s = int(input())
mod = 10**9 + 7

dp = [0]*(s+1)
dp[0] = 1

x = 0
for i in range(1,s+1):
    for j in range(0,(i-3)+1):
        dp[i] += dp[j]
        dp[i] %= mod
    
print(dp[s])
# Judge status: Accepted
N = input()
l = list()

for a in N:
    l.append(a)

if (l[0] == l[1] and l[1] == l[2]) or l[1] == l[2] and l[2] == l[3]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
number = int(input())

for i in range(1, 1000000 + 1):
    Total = []

    if (i % 3 == 0) and (i % 5 ==0):
        print('FizzBuzz')
    elif i % 3 == 0:
        print('Fizz')
    elif i % 5 == 0:
        print('Buzz')
    else:
        print(str(i))

        print(sum(Total))
# Judge status: Accepted
n = int(input())
s = input()

lie = [0] * (n+1)
liw = [0] * (n+1)
ans = 10**10

for i in range(n):
    if s[i] == 'E':
        lie[i+1] = lie[i] + 1
        liw[i+1] = liw[i]
    else:
        lie[i+1] = lie[i]
        liw[i+1] = liw[i] + 1

for i in range(n):
    cnte = lie[-1] - lie[i+1]
    cntw = liw[i]
    ans = min(ans, cnte + cntw)

print(ans)
# Judge status: Accepted
a, b, c = map(int,input().split())
ans = False
if a == b + c or b == a + c or c == a + b:
    ans = True
if ans:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import itertools

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

m=sum(A)

if(m%10==0):
    A=sorted(A)
    for a in A:
        if a%10!=0:
            print(m-a)
            exit()

else:
    print(m)
# Judge status: Wrong Answer
N,K= map(int,input().split())
 
A = list(map(int,input().split()))
 
B = [1001 for i in range(K)]
 
for x in A:
    
  for i in range(K):
    if x < B[i]:
      B[i] = x
      break
 
S = 0
for y in B:
  S += y
print(S)
# Judge status: Accepted
a,b=map(int,input().split())
if abs(a+b)%2==0:
  print(int(abs(a+b)/2))
else:
  print("IMPOSSIBLE")
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

if K == 1:
    print(N - 1)
elif N == K:
    print(1)
else:
    if (N - K) % (K - 1) != 0:
        print((N - K) // (K - 1) + 1)
    else:
        print((N - K) // (K - 1))
# Judge status: Wrong Answer
n = int(input())

l = [int(input()) for i in range(n)]
#print(l)

if sum(l) % 10 != 0:
  print(sum(l))

else:
  l2 = sorted(l)
  print(sum(l)-l2[0])
# Judge status: Wrong Answer
a,b,c,d = list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d) + '=7')
# Judge status: Accepted
n, k, q = map(int, input().split())
ans_cnt = []

for i in range(n): ans_cnt.append(0)

for i in range(q):
    answer = int(input())
    ans_cnt[answer-1] += 1

for i in range(n):
    had_point = k - (q-ans_cnt[i])
    if had_point > 0: print('Yes')
    else: print('No')
# Judge status: Accepted
A, B, C, D = map(int, input().split())
while A > 0 or C > 0:
  C -= B
  if C <= 0:
    print("Yes")
    break
  A -= D
  if A <= 0:
    print("No")
    break
# Judge status: Accepted
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for i in range(M)]

ans = [[0,0]]*(M)

prefectures = [[] for i in range(0,N+1,1)]
for i in range(M):
    prefectures[PY[i][0]].append([PY[i][1],i])
for i in range(N+1):
    prefectures[i].sort()
for i in range(N+1):
    for j in range(len(prefectures[i])):
        ans[prefectures[i][j][1]]=[i,j+1]

for i in range(M):
    ans[i][0] = str(ans[i][0]).zfill(6)
    ans[i][1] = str(ans[i][1]).zfill(6)
    print("".join(ans[i]))
# Judge status: Accepted
N = int(input())
S = list(input())
L = 0
R = S.count('E')
ans = L + R
for i in range(0, N):
    if S[i] == 'E':
        R -= 1
        R = max(0, R)
        ans = min(ans, L+R)
    else:
        L += 1
print(ans)
# Judge status: Accepted
S = input()
ret = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        f = True
        for k in S[i:j + 1]:
            if k not in ("ACGT"):
                f = False
                break
        if f:
            ret = max(ret, (j + 1) - i)
print(ret)
# Judge status: Accepted
K, A, B = map(int, input().split())
rem = K-(A-1)

if rem>0:
    if rem%2==0:
        print(max(K+1, A+(B-A)*(rem//2)))
    else:
        print(max(K+1, A+(B-A)*(rem//2)+1))
else:
    print(K+1)
# Judge status: Wrong Answer
n=int(input())
*p,=map(int,input().split())
c=0
for i in range(n-1):
    c+=sorted(p[i:i+3])[1]==p[i+1]
print(c)
# Judge status: Accepted
A, B, K = [int(n) for n in input().split()]
x = []
for i in range(1, min(A, B)+1):
    if A%i == 0 and B%i ==0:
        x.insert(0, i)
print(x[K-1])
# Judge status: Accepted
a,b,k = list(map(int,input().split(' ')))
"""takahashi has a
   aoki has b
   loop k

for _ in range(k):
  if a >= 1:
    a -= 1
  elif b >= 1:
    b -= 1
  elif a == 0 and b == 0:
    break
"""
if a <= k:
  k -= a
  a = 0
else:
  a -= k
  k = 0

#print('a,k',a,k)  

if b <= k:
  k -= b
  b = 0
else: 
  b -=k
  k = 0

#print('b,k',b,k)  
  
print(a,b)
# Judge status: Wrong Answer
x=input()

if x==0:
  print(1)
elif x==1:
  print(0)
# Judge status: Wrong Answer
n,m = map(int,input().split())
c = [False for i in range(200000)]
d = [False for i in range(200000)]
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        c[b] == True
    if b == n:
        d[a] = True
for i in range(n):
    if c[i] and d[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()
if s == t: print(n)
else:
    ans = n * 2
    for i in range(n):
        if s[-(i+1)] == t[i]: ans -= 1
        else: break
    print(ans)
# Judge status: Accepted
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    N = read()
    print("ABC" if N[1]=="R" else "ARC")
 
if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
def computeGCD(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n=int(input())
a=list(map(int,input().split()))
ans=computeGCD(a[0],a[1])
for i in range(2,n):
  ans=computeGCD(ans,a[i])
print(ans)
# Judge status: Wrong Answer
L=int(input())
ans=0
tmp=0
d=1
for i in range(L*d):
  for j in range(L*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)
# Judge status: Wrong Answer
n=int(input())
color_list=[[] for _ in range(n+1)]
color_list[1].append(int(input()))
max_color=1
for i in range(n-1):
  a=int(input())
  max_index=0
  max_number=0
  for j in range(1,max_color+1):
    if color_list[j][-1]<a:
      if color_list[j][-1]>max_index:
        max_index=j
        max_number=color_list[j][-1]
  if max_index==0:
    max_color+=1
    color_list[max_color].append(a)
  else:
    color_list[max_index].append(max_number)
print(max_color)
# Judge status: Accepted
# coding: utf-8

class Proc:
    def __init__(self):
        self.x = int(input().rstrip())

    def get_ans(self):
        if self.x <= 0:
            return 0
        if self.x <= 6:
            return 1
        if self.x <= 11:
            return 2
        ans = int(self.x / 11) * 2
        self.x = self.x % 11
        ans += self.get_ans()
        return ans


print(Proc().get_ans())
# Judge status: Wrong Answer
S = input()
K = int(input())
ans = 0
if S[0] == "1":
  if K == 1:
    print(1)
  else:
    if len(S) == 1:
      print(1)
    else:
      print(S[1])
else:
  print(S[0])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ac = set(a)

if len(ac) == len(a):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import radians,cos

def main():
    a,b,H,M = map(int,input().split())
    H *= 30
    H += M/2
    M *= 6
    x = min(360-abs(H - M),abs(H-M))
    x = radians(x)
    ans = a*a + b*b - 2*a*b*cos(x)
    print(ans**0.5)
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n, k = map(int, input().split())
r, s, p = tuple(map(int, input().split()))
t = input()

point = {"r":p, "s":r, "p":s}

log = [0 for _ in range(k)] 
ans = 0

for i, play in enumerate(t):

    if point[play] == log[i % k]:
        log[i % k] = 0
        continue
    log[i % k] = point[play]
    ans += point[play]
print(ans)
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
l = [[] for _ in range(m)]
 
for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        l[a-1].append(b)

a = []
ans = 0

for i in range(m):
    for j in l[i]:
        heapq.heappush(a, (-1) * j)
    if a:
        ans += heapq.heappop(a) * (-1)
        
print(ans)
# Judge status: Accepted
# coding: utf-8
from itertools import permutations
N = int(input())
P = list(map(str, input().split()))
Q = list(map(str, input().split()))

l = list(permutations(P))
l.sort()
ll = []
for i in range(len(l)):
    a = list(map(str, l[i]))
    ll.append("".join(a))
p_idx = ll.index("".join(P))
q_idx = ll.index("".join(Q))
print(abs(p_idx - q_idx))
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int,input().split()))
    B = [A[i-1] - i for i in range(1,N+1)]
    B.sort()
    b = B[N // 2] if N%2 == 1 else round((B[N // 2 - 1] + B[N // 2]) / 2)
    print(sum([abs(bb -b) for bb in B]))
    return

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
s = {1}

for i in range(1, 10):
    for k in range(1, 10):
        s.add(i * k)

if n in s:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
INF=float('inf')

cmin0,cmax0=INF,-INF
cmin1,cmax1=INF,-INF
for _ in range(n):
  x,y=map(int,input().split())
  cx,cy=x-y,x+y
  cmin0=min(cmin0,cx)
  cmax0=max(cmax0,cx)
  cmin1=min(cmin1,cy)
  cmax1=max(cmax1,cy)
  
ans=max(cmax0-cmin0,cmax1-cmin1)
print(ans)
# Judge status: Accepted
n = int(input())
rests = {}

for i in range(n):
  s,p = input().split()
  p = int(p)
  if s in rests:
    rests[s].append((i+1,p))
  else:
    rests[s] = [(i+1,p)]

for s in sorted(list(rests)):
  rest = rests[s]
  rest.sort(key = lambda x:x[1], reverse = True)
  for i,p in rest:
    print(i)
# Judge status: Accepted
#葉の総和-1=分岐の数

n=int(input())
a=list(map(int,input().split()))
s=sum(a)-1
ans,x=0,1

for i in range(n):
  if a[i]>x-1:
    print(-1)
    exit()
  ans+=x
  x-=a[i]
  if i<n-1 and x<=0:
    print(-1)
    exit()
  if s>=0:
    if s>=x:
      s-=x
      x=x*2
    else:
      x=(x-s)+s*2
      s=0
if x!=a[-1] or x<=0:
  print(-1)
  exit()
ans+=x
print(ans)
# Judge status: Accepted
import math
H,A = map(int, input().split())
print(math.ceil(H/A))
# Judge status: Wrong Answer
a, b = map(int, input().split())
c = 0
while a <= b:
    if str(a)[:2] == str(a)[3:]:
        c += 1
    a += 1
print(c)
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())
 
dx = abs(tx - sx)
dy = abs(ty - sy)

s = ["L"]+["U"]*(dy+1)+["R"]*(dx+1)+["D"] + ["R"]+["D"]*(dy+1)+["L"]*(dx+1)+["U"] + ["U"]*dy+["R"]*dx + ["D"]*dy+["L"]*dx
print("".join(s))
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(b/2+a)
# Judge status: Accepted
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    X = [int(c) for c in input().split()]

    def fullsearch():
        for i in range(N-K+1):
            l = X[i]
            r = X[i+K-1]
            distance = abs(r - l)
            yield distance + abs(r)
            yield distance + abs(l)

    print(min(fullsearch()))

main()
# Judge status: Accepted
n, a = [int(input()) for _ in range(2)]
print('Yes' if n%500<=a else 'No')
# Judge status: Accepted
n,m=map(int,input().split())
ans=[False]*n
ans[0]=True
co=[1]*n
for i in range(m):
  x,y=map(int,input().split())
  ans[y-1]|=ans[x-1]
  co[x-1]-=1
  co[y-1]+=1
  if co[x-1]==0:ans[x-1]=False
print(ans.count(True))
# Judge status: Accepted
def main():
    # import sys
    # readline = sys.stdin.buffer.readline
    # readlines = sys.stdin.buffer.readlines
    N, M = map(int, input().split())
    cnt = 0

    if N >= M // 2:
        cnt = M // 2
    else:
        cnt += N
        M -= 2 * N
        cnt += M // 4
    
    print(cnt)


if __name__ == "__main__":
    main()
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if abs(A-B) <= (V-W) * T:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from decimal import *

a, b = map(Decimal, input().split())

c = int(a * b)
print(c)
# Judge status: Accepted
N,K = map(int,input().split())
h = list(map(int,input().split()))

cost = [0]
for i in range(2,N+1):
    cost.append( min([cost[j] + abs(h[i-1]-h[j]) for j in range(max(0,i-K-1), i-1)]) )
print(cost[-1])
# Judge status: Wrong Answer
k = int(input())

def gcd(a,b,c):
  s = [a,b,c]
  s.sort()
  a,b,c = s
  for n in range(1,a+1):
    if a % n == 0 and b % n == 0 and c % n == 0:
      yakusu = n
  return n

total = 0
for x in range(1,k+1):
  for y in range(1,k+1):
    for z in range(1,k+1):
      total += gcd(x,y,z)
      
print(total)
# Judge status: Wrong Answer
n,m  = map(int, input().split())

l = 1
r = n
cnt = 0
while cnt < m:
    print(l,r)
    
    l += 1
    r -= 1
    cnt += 1
# Judge status: Accepted
s = list(input())

if s[0]!="A":
    print("WA")
    exit()
else:
    del s[0]
cnt=0
for i in range (1,len(s)-1):
    if s[i]=="C":
        cnt+=1
    
if cnt==1:
    del s[s.index("C")]
else:
    print("WA")
    exit()

for i in range(len(s)):
    if s[i].islower()==True:
        continue
    else:
        print("WA")
        exit()

print("AC")
# Judge status: Wrong Answer
K,X =map(int,input().split())
l = []
for i in range(X-K+1,X+K):
  l.append(str(i))
##print(l)
print(",".join(l))
# Judge status: Wrong Answer
import bisect
N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort(key=lambda x: (-x[1], x[0]))

days = [i for i in range(1, M+1)]
ans = 0
for a, b in X:
    if len(days) == 0:
        break
    if days[-1] < a:
        continue
    left = bisect.bisect_right(days, a)
    if left > 0:
        days.pop(left-1)
    elif left == 0 and days[0] >= a:
        days.pop(0)
    else:
        continue
    ans += b
print(ans)
# Judge status: Wrong Answer
n, q = map(int, input().split())
s = input()
lst = [0] * (n + 1)
reach = False
for i in range(n):
  if s[i] == 'A':
    reach = True
    lst[i + 1] = lst[i]
  else:
    if reach and s[i] == 'C':
      lst[i + 1] = lst[i] + 1
    else:
      lst[i + 1] = lst[i]
lst.pop(0)
#print(lst)
for i in range(q):
  l, r = map(int, input().split())
  print(lst[r - 1] - lst[l - 1])
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

menu = [a, b, c, d, e]

mintime = 9
minindex = 4
for i, m in enumerate(menu):
    if m % 10 == 0:
        continue

    if m % 10 < mintime:
        minindex = i
        mintime = m % 10

ans = menu[minindex]
for i, m in enumerate(menu):
    if i == minindex:
        continue
    if m % 10 != 0:
        m += 10 - m % 10
    ans += m

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
a, b = map(int, input().split())

x = ""
y = ""

for _ in range(b) :
  x += str(a)
for _ in range(a) :
  y += str(b)

if int(x) >= int(y) :
  print (int(x))
else :
  print (int(y))
# Judge status: Accepted
N, K = input().split()

sunuke = []
for n in range(int(N)):
  sunuke.append([])
for k in range(int(K)):
  people = input()
  no = input().split()
  for i in no:
    sunuke[int(i)-1].append(int(K))
target = []
for i in range(int(N)):
  if len(sunuke[i]) == 0:
    target.append(i)
print(len(target))
# Judge status: Accepted
n = int(input())
a = [0]*n

for i in range(n):
    a[i] = int(input())
ans = 0
for i in range(n-1):
    if a[i] >= 2:
        ans += a[i]//2
        a[i] = a[i]%2
    if a[i] == 1 and a[i+1] >= 1:
        ans += 1
        a[i] -= 1
        a[i+1] -= 1
print(ans+a[-1]//2)
# Judge status: Accepted
import math

a, b, h, m = map(int, input().split())

a_angle = h * 30 + m / 2
b_angle = m * 6
cos_x = math.cos(math.radians(a_angle-b_angle))
d = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_x)
print(d)
# Judge status: Accepted
from itertools import permutations, combinations
import math

def factorial(num):
    if num <= 1:
        return 1
    return num * factorial(num - 1)

n = int(input())
xy =[list(map(int, input().split())) for _ in range(n)]
ans = 0
for i, j in combinations(range(n), 2):
    l = math.sqrt((xy[i][0] -xy[j][0]) ** 2 + (xy[i][1] -xy[j][1]) ** 2)
    ans += 2 * factorial(n - 2) * (n - 1) * l
print(ans / factorial(n))
# Judge status: Wrong Answer
n = int(input())

max1 = -100
min1 = 10 ** 10
max0 = -100
min0 = 10 ** 10

for i in range(n):
    x,y = list(map(int,input().split()))
    k0 = x - y
    k1 = x + y
    if k0 > max0:
        max0 = k0
    if k0 < min0:
        min0 = k0
    if k1 > max1:
        max1 = k1
    if k1 < min1:
        min1 = k1


ans = int(max(max1-min1,max0-min0))

print(ans)
# Judge status: Wrong Answer
a, b, c = map(int,input().split())
print("Yes" if b-a == c-b else "No")
# Judge status: Accepted
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    ans = [str((m := A.pop())), ]
    m /= 2
    A = [(a, abs(a - m)) for a in A]
    A.sort(key = lambda x: x[1])
    ans.append(str(A[0][0]))
    print(' '.join(ans))

if __name__ == '__main__':
    main()