Harryxun/stf_run huggingface dataset:
import queue

def proceess(start_x,start_y):
    #insland = []
    #insland.append([start_x,start_y])
    new_island = queue.Queue()
    map[start_x][start_y] = 0
    new_island.put([start_x,start_y])
    while True:
        ob = new_island.get()
        x = ob[0]
        y = ob[1]
        #print("x : " + str(x) + ", y : " + str(y))

        for i in [-1,0,1]:
            for j in [-1,0,1]:
                nx = x + i
                ny = y + j

                if nx >= 0 and ny >= 0 and nx < w and ny < h:
                    #print(map[nx][ny])
                    if map[nx][ny] == 1:
                        #insland.append([nx,ny])
                        #print("nx : " + str(nx) + ", ny : " + str(ny))
                        new_island.put([nx,ny])
                        map[nx][ny] = 0

        if new_island.empty():
            break

while True:
    map = []

    tmp = input().split(" ")
    w = int(tmp[0])
    h = int(tmp[1])

    if w == 1 and h == 1:
        break


    for j in range(h):
        nova = []
        arm = input()
        for k in arm.split(" "):
            #k.rstrip('\n')
            nova.append(int(k))
        map.append(nova)

    #print(map)

    count = 0
    for i in range(w):
        for j in range(h):
            if map[i][j] == 1:
                #print("i : " + str(i) + ", j : " + str(j))
                proceess(i,j)
                count += 1

    print(count)



### FIXED CODE ###

import copy

move = ((1, 0), (0, 1), (0, -1), (-1, 0), (1, 1), (-1, -1), (-1, 1), (1, -1))


def dfs(start):
    field[start[1]][start[0]] = '0'
    CP = [start]
    while CP:
        NP = []
        for cp in CP:
            for m in move:
                n_p = (cp[0]+m[0], cp[1]+m[1])
                if not(n_p[0] < 0 or n_p[1] < 0 or n_p[1] >= h or n_p[0] >= w) and field[n_p[1]][n_p[0]] == '1':
                    field[n_p[1]][n_p[0]] = '0'
                    NP.append(n_p)
        CP = NP


while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    field = [list(input().split()) for _ in range(h)]
    count = 0
    for y in range(h):
        for x in range(w):
            if field[y][x] == '1':
                dfs((x, y))
                count += 1
    print(count)
while(True):
  n=int(input())
  mns=list(map(int,input().split()))
  hrs=list(map(int,input().split()))
  mk=0
  for i in range(n):
    if(hrs[i]>=mns[i]+mns[i+1]):
      mk+=mns[i]+mns[i+1]
      mns[i]=0
      mns[i+1]=0
    else:
      if(hrs[i]<=mns[i]):
        mk+=hrs[i]
      else:
        mk+=hrs[i]
        mns[i+1]-=(hrs[i]-mns[i])
  print(mk)


### FIXED CODE ###


n=int(input())
mns=list(map(int,input().split()))
hrs=list(map(int,input().split()))
mk=0
for i in range(n):
  if(hrs[i]>=mns[i]+mns[i+1]):
    mk+=mns[i]+mns[i+1]
    mns[i]=0
    mns[i+1]=0
  else:
    if(hrs[i]<=mns[i]):
      mk+=hrs[i]
    else:
      mk+=hrs[i]
      mns[i+1]-=(hrs[i]-mns[i])
print(mk)
a = 0
n = int(N)
for i in range(1,n+1):
    if i % 5 != 0 and i % 3 != 0:
        a = a + i
    else:
        continue
print(a)

### FIXED CODE ###

a = 0
N = input()
n = int(N)
for i in range(1,n+1):
    if i % 5 != 0 and i % 3 != 0:
        a = a + i
    else:
        continue
print(a)
import math

a,b = map(int,input().split())
n = math.gcd(a,b)
count = [1]
while n % 2 == 0:
    count += [2]
    n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
    while n % i == 0:
        count+=[i]
        n = n / i

if n > 2:
    count+=[n]
c = 1
count = sorted(count)
for i in range(1,len(count)):
    if count[i-1] != count[i]:
        c+=1
print(c)


### FIXED CODE ###

import math
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
  
a,b = map(int,input().split())
n = gcd(a,b)
count = [1]
while (n % 2 == 0):
    count += [2]
    n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
    while (n % i == 0):
        count+=[i]
        n = n / i

if n > 2:
    count+=[n]
c = 1
count = sorted(count)
for i in range(1,len(count)):
    if (count[i-1] != count[i]):
        c+=1
print(c)
import copy

class MyClass():

    maxSum = 0

    def do(self, baseList, _temochi, leftIndex, rightIndex, nokoriSousaCount):
        if nokoriSousaCount < 0:
            return

        sum = 0
        for each in _temochi:
            sum += each

        if self.maxSum < sum:
            self.maxSum = sum

        if leftIndex <= rightIndex:
            temochi = copy.copy(_temochi)
            temochi.append(baseList[leftIndex])
            self.do(baseList, temochi, leftIndex + 1, rightIndex, nokoriSousaCount - 1)

            temochi = copy.copy(_temochi)
            temochi.append(baseList[rightIndex])
            self.do(baseList, temochi, leftIndex, rightIndex - 1, nokoriSousaCount - 1)
            
        self.removeMin(_temochi, leftIndex, rightIndex, nokoriSousaCount - 1)

    def removeMin(self, _temochi, leftIndex, rightIndex, nokoriSousaCount):
        if len(_temochi) > 0 and nokoriSousaCount > 0:
            minNum = min(_temochi)
            if minNum < 0:
                temochi = copy.copy(_temochi)
                temochi.remove(minNum)
                self.do(baseList, temochi, leftIndex, rightIndex, nokoriSousaCount)


count, opeCount = map(int, input().split())
baseList = list(map(int, input().split()))

doClass = MyClass()
doClass.do(baseList, [], 0, count - 1, opeCount)

print(doClass.maxSum)




### FIXED CODE ###

apple, frag = map(int, input().split())
         
pie = ((apple*3) + frag) / 2
         
print(int(pie))
a,b,c,x = map(int,input().split())
count = 0

for a in range(a+1):
    for b in range(b+1):
        for c in range(c+1):
            if (500*a + 100*b + 50*c) == x:
                count += 1

print(count)


### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)
a,b,x=map(int,input().split())
import math

if x == a**2*b/2:
  print(math.degrees(math.atan(a/b)))
elif x < a**2*b/2:
  print(math.degrees(math.atan(2*x/a/b/b)))
else:
  print(math.degrees(math.atan((a*a*b-x)**(-1)*a**3/2)))


### FIXED CODE ###

a,b,x=map(int,input().split())
import math
 
if x == a**2*b/2:
  print(float(90)-math.degrees(math.atan(a/b)))
elif x == a*a*b:
  print(0)
elif x < a**2*b/2:
  print(float(90)-math.degrees(math.atan(2*x/a/b/b)))
else:
  print(float(90)-math.degrees(math.atan((a*a*b-x)**(-1)*a**3/2)))
a,b=input().split()
if a == H:
    if b == H:
        print("H")
    else:
        print("D")
if a == D:
    if b == H:
        print("D")
    else:
        print("H")

### FIXED CODE ###

a,b=input().split()
if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
if a == "D":
    if b == "H":
        print("D")
    else:
        print("H")
N, X, M = map(int, input().split())
table = [0]*(M+1)

pre = X
table[pre] = 1
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        fir = table[A]
        sec = cnt
        break
    
ans = 0
for i in range(fir + (N-fir)%(sec-fir)):
    ans += seq[i]
mul = (N-fir)//(sec-fir)
for i in range(fir, sec):
    ans += seq[i]*mul

print(ans)

### FIXED CODE ###

N, X, M = map(int, input().split())
table = [0]*(M+1)

pre = X
table[pre] = 0
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        f = table[A]
        s = cnt
        break
    
ans = 0
for i in range(f + (N-f)%(s-f)):
    ans += seq[i]
m = (N-f)//(s-f)
for i in range(f, s):
    ans += seq[i]*m

print(ans)
N = int(input())
S = str(input())

total = []

def yugo(st,x):
	if len(st) == x + 1:
		return st[x]
	if st[x] == st[x + 1]:
		return yugo(st,x+1)
	else:
		return st[x] +  yugo(st,x+1)
	

print(int(len(yugo(S,0))))


### FIXED CODE ###

N = int(input())
S = input()

total = []
Y = 0

for i in range(N):
	if i == N-1:
		Y = Y + 1
		break
	if S[i] == S[i+1]:
		continue
	else:
		Y = Y + 1
		
print(Y)
#166d
x = int(input())
for i in range(-118,119):
    for j in range(-118,119):
        print(i,j)
        if i**5-j**5==x:
            a = i
            b = j
            break
        
print(a,b)

### FIXED CODE ###

#166d
x = int(input())
for i in range(-120,120):
    for j in range(-120,120):
        if i**5-j**5==x:
            a = i
            b = j
            break
        
print(a,b)
x = input()
 print (int(x)**3)

### FIXED CODE ###

x = input()
ans = x**3
print ans
n = int(input())
numbers = list(map(int, input().split()))


def destroy(ns):
    if len(ns) == 0:
        return None
    satisfies = True
    for i, s in enumerate(ns):
        if i + 1 != s:
            satisfies = False
            break
    if satisfies:
        return 0
    min_breaks = None
    if ns[0] != 1:
        ans = destroy(ns[1:])
        if ans is None:
            return None
        return 1 + ans
    for i in range(len(ns) - 1):
        breaks = destroy(ns[:i] + ns[i+1:])
        if breaks is None:
            continue
        breaks += 1
        if min_breaks is None:
            min_breaks = breaks
            continue
        if breaks < min_breaks:
            min_breaks = breaks
    return min_breaks

ans = destroy(numbers)
print(-1 if ans is None else ans)

### FIXED CODE ###

import sys

n = int(input())
numbers = list(map(int, sys.stdin.readline().split()))

if 1 not in numbers:
    print(-1)
    sys.exit(0)

breaks = 0
current = 1
for i in range(n):
    if numbers[i] == current:
        current += 1
    else:
        breaks += 1
print(breaks)
import math
import itertools

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

def l2(z1, z2):
  return math1.sqrt(pow(z1[0] - z2[0], 2) + pow(z1[1] - z2[1], 2))


dist = 0
z_fr = []
z_to = []
for seq in itertools.permutations(l, n):
  for z in seq:
    z_fr = z_to
    z_to = z
    if len(z_fr):
      continue
    dist += l2(z_fr, z_to)

print(dist/math.factorial(n))

### FIXED CODE ###

import math
import itertools

def l2(z1, z2):
  return math.sqrt(pow(z1[0] - z2[0], 2) + pow(z1[1] - z2[1], 2))

n = int(input())
l = [list(map(int, input().split(' '))) for _ in range(n)]
seq_list = itertools.permutations(l, n)

dist = 0
for seq in seq_list:
  z_fr = []
  z_to = []
  
  for z in seq:
    z_fr = z_to
    z_to = z
    if len(z_fr)==0:
      continue
    dist += l2(z_fr, z_to)

print(dist/math.factorial(n))
N = int(input())
mod = 10**9+7
import math
NN = math.factorial(N+7)
U = (NN*(N+8)*(N+9))/362880
A = (NN*(N+8))/40320
C = NN/5040
S = int((U-2*A+C)%mod)
print(S)


### FIXED CODE ###

N = int(input())
mod = 10**9+7
S = 10**N-2*(9**N)+8**N
print(S%mod)
xyz = input().split()
x,y,z = int(xyz=[0]), int(xyz[1]),int(xyz[2])
print(x)

a = x + y
b = y + z
c = z + x
ptint(min([x,y,z])

### FIXED CODE ###

x,y,z = (int(x) for x in input().split())

a = x + y
b = y + z
c = z + x

print(min([a, b, c]))
N = int(input())
A = [int(a) for a in input().split()]

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

B=[]
for k in dic:
  if dic[k]>=2:
    B.append(k)

B.sort()
if B>=2:
  print(B[-1]*B[-2])
else:
  print(0)

### FIXED CODE ###

N=int(input())
A = [int(a) for a in input().split()]

d = {}
for a in A:
  d[a] = d.get(a,0) + 1
B = [0,0]
for k in d:
  if d[k] >= 4:
    B.append(k)
    B.append(k)
  elif d[k] >=2:
    B.append(k)
B.sort()
print(B[-1]*B[-2])
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

data = {}

a_set = set(A)

def my_sum(d):
    retval = 0

    for i in d.keys():
        retval += d[i] * i
    return retval

for i in a_set:
    data[i] = A.count(i)
 
for i in range(Q):
    B, C = map(int, input().split())
 
    if C in data.keys():
        data[C] = data[C] + data[B]
    else:
        data[C] = data[B]
    del data[B]
 
    print(my_sum(data))

### FIXED CODE ###

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

data = [0] * 100001

def my_sum(d):
    retval = 0

    for i in range(len(d)):
        if d[i] == 0:
            continue
        retval += d[i] * i
    return retval

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

sum_val = my_sum(data)

for i in range(Q):
    B, C = map(int,input().split())

    sum_val = sum_val - (data[B] * B) + (data[B] * C)

    data[C] += data[B]
    data[B] = 0

    print(sum_val)
inp = list(map(int, input().strip().split(' ')))

a = inp[0]
b = inp[1]

r = b * 2 + 1
m = math.ceil(a / r)
print(m)


### FIXED CODE ###

import math

inp = list(map(int, input().strip().split(' ')))

a = inp[0]
b = inp[1]

r = b * 2 + 1
m = math.ceil(a / r)
print(m)
import sys
import numpy as np

a = np.array([sys.stdin.readline().split() for _ in range(3)], dtype=np.int64)
n = int(sys.stdin.readline().rstrip())
b = np.array(sys.stdin.read().split(), dtype=np.int64)
def main():
    c = np.isin(a, b)
    bl1 = np.any(np.all(c, axis=1))
    bl2 = np.any(np.all(c, axis=0))
    bl3 = np.all(np.diagonal(c))
    bl4 = np.all(np.diagonal(np.fliplr(c)))
    bl = bl1 | bl2 | bl3 | bl4
    print('Yes' if bl else 'No')

if __name__ ==  '__main__':
    main()

### FIXED CODE ###

import sys

a = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
n, *b = map(int, sys.stdin.read().split())
b = set(b)

def main():
    res = [[False] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                res[i][j] = True
    
    for i in range(3):
        for j in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for j in range(3):
        for i in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for i, j in zip(range(3), range(3)):
        if not res[i][j]:
            break
    else:
        return 'Yes'
    
    for i, j in zip(range(3), range(2, -1, -1)):
        if not res[i][j]:
            break
    else:
        return 'Yes'
    
    return 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)
n = int(input())
c = list(input())
flag = False
ans = 0
for i in range(n-1):
    if c[i] == "W" and c[i+1] == "R":
        flag = True
        break
if not flag:
    print(0)
    exit()
for i in range(n//2):
    if c[i] == "R" and c[n-i-1] == "W":
        continue
    else:
        if c[i] == "W" and c[n-i-1] == "R":
            c[i] = "R"
            c[n-i-1] = "W"
            ans += 1
        elif c[i] == "W" and c[n-i-1] == "W":
            for j in range(n-i,i+1,-1):
                if c[j] == "R":
                    c[i] = "R"
                    c[j] = "W"
                    break
            ans += 1
        elif c[i] == "R" and c[n-i-1] == "R":
            for j in range(i+1, n-i-1):
                if c[j] == "W":
                    c[n-i-1] = "W"
                    c[j] = "R"  
                    break
            ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
c = list(input())
print(len([i for i, j in zip(sorted(c), c) if i != j])//2)
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    x=l[i]
    dp[i]=min((dp[j]+abs(x-l[j])) for j in range(max(0,i-k),i))
print(dp[-1])

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
dp=[0 for i in range(n)]
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
#print(l,dp)
print(dp[-1])
import numpy as np
import math
n,d=[int(i) for i in inpput().split()]
x=[]
for _ in range(n):
  x.append(np.array([int(i) for i in input().split()]))
def dis(x,y):
  return int(np.sum((x-y)**2))
def iss(x):
  a=round(math.sqrt(x))
  return a**2==x
k=0
for i in range(n):
  for j in range(i+1,n):
    if iss(dis(x[i],x[j])):
      k+=1
print(k)

### FIXED CODE ###

import numpy as np
import math
n,d=[int(i) for i in input().split()]
x=[]
for _ in range(n):
  x.append(np.array([int(i) for i in input().split()]))
def dis(x,y):
  return int(np.sum((x-y)**2))
def iss(x):
  a=round(math.sqrt(x))
  return a**2==x
k=0
for i in range(n):
  for j in range(i+1,n):
    if iss(dis(x[i],x[j])):
      k+=1
print(k)
import math

X =input()

if X == 1:
    output = 1
    print(output)
else:
    mylist = [1]
    biggest = int(math.sqrt(X))
    for i in range(2,biggest):
        bekijo = i
        while bekijo <= X:
            bekijo = bekijo * i
        mylist[i] = bekijo
        #print(mylist[i])
    print(max(mylist))

### FIXED CODE ###

import math

x =input()
X = int(x)

if X == 1:
    output = 1
    print(output)
else:
    mylist = []
    for i in range(2,X+1):
        bekijo = i
        count = 0
        while bekijo <= X:
            bekijo = bekijo * i
            count = count +1
        if count > 1:
            mylist.append(int(bekijo/i))
    print(max(mylist))
N=int(input())
SP=[]
for i in range(N):
  S,P=input()
  SP.append([S,int(P),i+1])
  
l=sorted(SP,key = lamda SP : (SP[0],-SP[1]))

for i in l:
  print(SP[2])

### FIXED CODE ###

N=int(input())
SP=[]
for i in range(N):
  S,P=input().split()
  SP.append([S,int(P),i+1])
  
l=sorted(SP,key = lambda SP : (SP[0],-SP[1]))

for i in l:
  print(i[2])
S=input()
if S[3]=S[4] or S[1]=S[2] or S[2]=S[3]:
  print("Bad")
  else: print("Good")


### FIXED CODE ###

S = input()

if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
   print("Bad")
else:
    print("Good")
x,y = map(int,inpu().split())
print(x+int(y/2))

### FIXED CODE ###

x,y = map(int,input().split())
print(x+int(y/2))
print(sum([int(x[i]) for i in range(len(x))]))



### FIXED CODE ###

while True:
    x = input()
    if x == '0':
        break
    print(sum([int(x[i]) for i in range(len(x))]))
n,h =map(int,input().split())
a,b = [0]*n,[0]*n
c = h//max(a) + 1
if sum(b) >= h:
    c0 = 0
    d = 0
    e = reversed(sorted(b))
    while d < h:
        d += e[i] 
        c0 += 1
        i += 1
    c = min(c,c0)
print(c)

### FIXED CODE ###

n,h =map(int,input().split())
a,b = [0]*n,[0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split())
A = max(a)
s = list()
for i in range(n):
    if b[i] > A:
        s.append(b[i])
s.sort()
s.reverse()
c = sum(s)
if c < h:
    print(len(s) + (h-c)//A + [1,0][(h-c)%A==0])
else:
    S = 0
    for i in range(len(s)):
        S += s[i]
        if S >= h:
            print(i+1)
            break
N=int(input())
X=input()
xx=int(X)
xxx=str(xx)
sa=N-len(xxx)
X_len=len(X)
a=0
for i in range(sa,N):
    a=int(X[i])*(2**(N-i-1))+a





fx=[-1]*(2*(10**5))
for i in range(X_len):
    ans=0
    if(X[i]=='0'):
        b=a+2**(X_len-i-1)
    else:
        b=a-2**(X_len-i-1)

    while(b!=0):

        fx=b%str(format(b,'b')).count('1')
        ans=ans+1
        b=fx

    print(ans)


### FIXED CODE ###

N=int(input())

a=[0]*N
a=list(map(int,input().split()))
ans=0
for i in range(1,N+5,2):
    if(N<i):
        break
    if(a[i-1]%2==1):
        ans=ans+1
print(ans)
x = input()
flag = 0

for i in (0,4):
    if x[i] == x[i+1]:
        flag += 1
    else :
        flag += 0

if flag == 0:
    print("Good")
else :
    print("Bad")

### FIXED CODE ###

x = input()
flag = 0

for i in range(0,3):
    if x[i] == x[i+1]:
        flag += 1
    else :
        flag += 0

if flag == 0:
    print("Good")
else :
    print("Bad")
from operator import mul
from functools import reduce
def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(0,B):
    ans = (nCr((R+1),i+1) * nCr((B-1),i))%mod
    print(ans)


### FIXED CODE ###

import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)
N = int(input())
import numpy as np
L = np.array(input().split(),np.int16)

L.sort(reverse=True)
counter = 0

for index1,c in enumerate(L):
    index2 = index1+1
    if index2>N-1:
      break
    b = L[index2]
    while b>=c/2:
        
        index3 = index2+1
        if index3>N-1:
            break
        a = L[index3]
        
        while a+b>c:
            counter += 1
            index3+=1
            if index3>N-1:
                break
            a = L[index3]

        index2+=1
        if index2>N-1:
            break
        b = L[index2]


print(counter)

### FIXED CODE ###

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

L.sort(reverse=True)
counter = 0
import bisect

for index1,c in enumerate(L):
    for index2,b in enumerate(L[index1+1:],start=index1+1):
        left = 0 ; right = N
        oppai = c-b
        while left+1<right:
            mid = (left+right)//2
            if L[mid]>oppai:
                left = mid
            else :
                right=mid
        
        index3 = left
        
        if index3>index2:

            counter += index3-index2
print(counter)
import sys
import math

# 入力
a, b, c = map(int, input().split())
# 計算
if a < (b + 2*c):
    print("a >= b + 2*cとなるようにしてください")
    sys.exit()
elif a == (b + 2*c):
    print("1")
else:
    max = math.floor((a + c) / (b + 2*c))
    print(max)

### FIXED CODE ###

X, Y = input().split()

if int(X, 16) > int(Y, 16):
    print(">")
elif int(X, 16) < int(Y, 16):
    print("<")
else:
    print("=")
s = list(input())
for i in range(3):
  if(s[i] == s[i+1]):
  	print('Bad')
 	exit()
else:
  print('Good')


### FIXED CODE ###

S = list(input())
for i in range(3):
    if(S[i]==S[i+1]):
        print('Bad')
        exit()
else:
    print('Good')
a = input()
b = int(a)
c = list(a)
if a.count("9") != len(a):
    t = int(a[0]) -1
print(t+(len(a)-1)*9)

### FIXED CODE ###

a = input()
b = int(a)
c = list(a)
t = int(a[0])
r = t+(len(a)-1)*9
#print(t,a.count("9"))
if t != 9  and a.count("9") == len(a)-1:
    r = t+(len(a)-1)*9
elif a.count("9") != len(a):
    t -= 1
    r = t+(len(a)-1)*9
if b<9:
    r = b
elif b == 9:
    r = 9
    
print(r)
'''
thinking
comb(n, r)
'''
import numpy as np
import itertools

def get_nearest_val(l, n, side='left'):
    l = sorted(l)
    i = np.searchsorted(l, n, side=side)
    return l[i]

# c = list(itertools.combinations(s,3))

def comb(n, r):
    if n < 0 or r < 0 or n < r: return 0
    elif n == 0 or r == 0: return 1
    return comb(n-1, r-1) + comb(n-1, r)


# def get_nearest_val(l, n):
#     i = np.abs(np.asarray(l) - n).argmin()
#     return l[i]

n = int(input())
A = list(map(int, input().split(' ')))

# n = 5
# A = [6, 9, 4, 2, 11]

max_n = max(A)

key_r = (max_n + 1) / 2

left_r = get_nearest_val(A, key_r, side='left')
right_r = get_nearest_val(A, key_r, side='right')

left_comb = comb(max_n, left_r)
right_comb = comb(max_n, right_r)

# left_comb = len(list(itertools.combinations(A, left_r)))
# right_comb = len(list(itertools.combinations(A, right_r)))

if left_comb >= right_comb:
    print(str(max_n) + ' ' + str(left_r))
else:
    print(str(max_n) + ' ' + str(right_r))

### FIXED CODE ###


import numpy as np
import math

def get_nearest_val(l, n):
    i = np.abs(np.asarray(l) - n).argmin()
    return l[i]

n = int(input())
A = list(map(int, input().split(' ')))

max_n = max(A)
A = sorted(A)
max_n = A[-1]
# A = A.pop
A.pop(-1)
key_r = (max_n + 1) / 2
# key_r = int((max_n + 1) / 2)
# print(key_r)

# left_r = get_nearest_val(A, key_r, side='left')
# # print(left_r)
# right_r = get_nearest_val(A, key_r, side='right')
# # print(right_r)

# left_comb = comb(max_n, left_r)
# # print(left_comb)
# right_comb = comb(max_n, right_r)
# # print(right_comb)

# if left_comb >= right_comb:
#     print(str(max_n) + ' ' + str(left_r))
# else:
#     print(str(max_n) + ' ' + str(right_r))

r = get_nearest_val(A, key_r)
# r = get_nearest_val(A[:len(A)-1], key_r)
print(str(max_n) + ' ' + str(r))