Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [a[i] for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] > 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k, len(plus))):
    min_ = min(2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  print(min_)
else:
  for i in range(min(k, len(minus))):
    min_ = min(2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  print(min_)  
  


### FIXED CODE ###

n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)
import math
from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if max(n, m) % min(n, m) == 0:
    print(-1)
else:
    print(lcm(n, m))

### FIXED CODE ###

import fractions
import sys
from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


g = fractions.gcd(n, m)
for i in range(g):
    if s[n // g * i] != t[m // g * i]:
        print(-1)
        sys.exit()
print(lcm(n, m))
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
def list_count(my_list):
    dic={} #辞書型の宣言
    for num in my_list:
        if num in dic: #もしnumがkeyとして辞書にあれば
            dic[num]+=1 #valueに+1
        else: #なければ
            dic[num]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic
import sys
input = sys.stdin.readline
n=int(input())
s=list(input())
for i in range(n):
    s[i]=int(s[i])
l=[0]*1000
a=list(list_count(s).values())
#print(a)
n=len(a)
m=3
dp=[[0 for i in range(n+1)] for j in range(m+1)]

#メイン
#dp[i+1][j]:=i番目までの品物からj個選ぶ組み合わせの総数

for i in range(n+1):
    dp[i][0]=1
for i in range(n):
    for j in range(1,m+1):
        if j-1-a[i]>=0:
            dp[i+1][j]=(dp[i+1][j-1]+dp[i][j]-dp[i][j-1-a[i]])
        else:
            dp[i+1][j]=(dp[i+1][j-1]+dp[i][j])

#出力
print(dp[n][m])




### FIXED CODE ###

def search(a):
    x=0
    a="".join(["0"*(3-len(a)),a])
    for i in range(n):
        if a[x]==s[i]:
            x+=1
            if x==3:
                return True
    return False
n=int(input())
s=input()
ans=0
k=[False]*1000
for i in range(1000):
    k[i]=search(str(i))
for i in k:
    if i:
        ans+=1
print(ans)
class TrieNode:
    def __init__(self, char):
        self.char = char
        self.nextnode = dict()
        self.is_indict = False


class Trie:
    def __init__(self, charset):
        self.charset = charset
        self.root = TrieNode('')

    def add(self, a_str):
        node = self.root
        for i, char in enumerate(a_str):
            if char not in node.nextnode:
                node.nextnode[char] = TrieNode(char)
            node = node.nextnode[char]
            if i == len(a_str) - 1:
                node.is_indict = True

    def dfs(self, node, dep):
        ret, cnt = 0, 0
        for s in '01':
            if s not in node.nextnode:
                cnt += 1
            else:
                ret ^= self.dfs(node.nextnode[s], dep + 1)
        dep += 1
        if cnt % 2:
            power2 = 0
            while dep > 0 and dep % 2 == 0:
                power2 += 1
                dep //= 2
            ret ^= 2 ** power2
        return ret

    def debug_output(self, node, now):
        print(node.char, list(node.nextnode.items()), node.is_indict, now)
        if node.is_indict:
            print(now)
        for n in node.nextnode.values():
            self.debug_output(n, now + n.char)

N, L = map(int, input().split())
T = Trie('01')
for _ in range(N):
    T.add(input())
# T.debug_output(T.root, '')
print("Alice" if T.dfs(T.root, 0) else "Bob")


### FIXED CODE ###

import sys
sys.setrecursionlimit(2 * 10 ** 5)


class TrieNode:
    def __init__(self, char):
        self.char = char
        self.nextnode = dict()
        self.is_indict = False


class Trie:
    def __init__(self, charset):
        self.charset = charset
        self.root = TrieNode('')

    def add(self, a_str):
        node = self.root
        for i, char in enumerate(a_str):
            if char not in node.nextnode:
                node.nextnode[char] = TrieNode(char)
            node = node.nextnode[char]
            if i == len(a_str) - 1:
                node.is_indict = True

    def dfs(self, node, dep):
        ret, cnt = 0, 0
        if node.is_indict:
            return 0
        for s in '01':
            if s not in node.nextnode:
                cnt += 1
            else:
                ret ^= self.dfs(node.nextnode[s], dep + 1)
        height = L - dep
        if cnt % 2:
            power2 = 0
            while height > 0 and height % 2 == 0:
                power2 += 1
                height //= 2
            ret ^= 2 ** power2
        return ret

    def debug_output(self, node, now):
        print(node.char, list(node.nextnode.items()), node.is_indict, now)
        if node.is_indict:
            print(now)
        for n in node.nextnode.values():
            self.debug_output(n, now + n.char)

N, L = map(int, input().split())
T = Trie('01')
for _ in range(N):
    T.add(input())
# T.debug_output(T.root, '')
print("Alice" if T.dfs(T.root, 0) else "Bob")
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter[R] 

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter[R]

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter.get(R, 0)

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()
a = [int(input())]

for i in range(100000):
  if a[i] % 2 == 0:
    a.append(a[i]//2)
    else:
      a.append(3*a[i] + 1)
    
    if a[i+1] in a[:i]
      print(i+2)
      break
      

### FIXED CODE ###

a = [int(input())]

for i in range(100000):
  if a[i] % 2 == 0:
    a.append(a[i]//2)
  else:
    a.append(3*a[i] + 1)
    
  if a[i+1] in a[:i]:
    print(i+2)
    break
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())

n = make_divisors(N)

cnt = 999999999999
for i in range(0,len(n),2):
    t = n[i]-1 + n[i+1]-1
    if cnt > t:
        cnt = t
print(cnt)



### FIXED CODE ###

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))
    table = list(table)
    table.sort()
    return table

N = int(input())

#for N in range(1000000000000):
n = []
n = divisor(N)
#print(n)

cnt = 999999999999999
for i in range(0,len(n)//2,1):
    t = int(n[i])-1 + int(n[len(n)-i-1])-1
    if cnt > t:
        cnt = t
print(cnt)
import heapq
#N,K = map(int, input().split())
#*V, = map(int, input().split())
N, K = 6, 4
V = [-10, 8, 2, 1, 2, 6]
motimono = []
ans = []

if K >= N: # 操作回数のほうが大きいなら、全部取り出してから何個戻すかを考える
    K -= N
    heapq.heapify(V)
    ans.append(sum(V))
    for i in range(K):
        if len(V)>0:
            heapq.heappop(V)
        ans.append(sum(V))
    print(max(ans))

else:
    V *= 2 # 前後からの取り出しを楽にするためにこうしておく
    #print(V)
    for j in range(1,K+1): # 取り出す個数
        for i in range(N-j, N+1): # 何番目から取り出すか
            motimono = V[i:i+j]
            #print(str(j), str(i), motimono)
            ans.append(sum(motimono))
            #print(ans)
            heapify(motimono)
            for i in range(K-j): # 戻す個数
                if len(motimono)>0:
                    heappop(motimono)
                ans.append(sum(motimono))
    print(max(ans))

### FIXED CODE ###

import heapq
N,K = map(int, input().split())
*V, = map(int, input().split())
#N, K = 6, 4
#V = [-10, 8, 2, 1, 2, 6]
motimono = []
ans = []

if K >= N: # 操作回数のほうが大きいなら、全部取り出してから何個戻すかを考える
    K -= N
    heapq.heapify(V)
    ans.append(sum(V))
    for i in range(K):
        if len(V)>0:
            heapq.heappop(V)
        ans.append(sum(V))
    print(max(ans))

else:
    V *= 2 # 前後からの取り出しを楽にするためにこうしておく
    #print(V)
    for j in range(1,K+1): # 取り出す個数
        for i in range(N-j, N+1): # 何番目から取り出すか
            motimono = V[i:i+j]
            #print(str(j), str(i), motimono)
            ans.append(sum(motimono))
            #print(ans)
            heapq.heapify(motimono)
            for i in range(K-j): # 戻す個数
                if len(motimono)>0:
                    heapq.heappop(motimono)
                ans.append(sum(motimono))
    print(max(ans))
import math
a,b,x = map(int,input().split())
 
maxint = 10**9
 
def dn(p):
    plist = list(str(p))
    return len(plist) #nの桁数d(n)が帰る

def nibuntansaku(l,u):
    c = (l+u)//2 #切り捨て
    if c <= (x-b*dn(c))/a: #条件を満たす(つまり、)
        return c,u
    else:
        return l,c





#上限(大きい)
n_upper = math.ceil((x-b*1)/a)
#下限(小さい)
n_lower = math.floor((x-b*10)/a)


if n_upper < 1 : #最小条件ですでに1未満の場合は0を出力
    print(0)
    exit()

while True:
    if abs(n_upper-n_lower) <= 1:
        break 
    n_lower,n_upper = nibuntansaku(n_lower,n_upper)

if n_upper+1 <= (x-b*dn(n_upper+1))/a:
    ans = n_upper+1

elif n_upper <= (x-b*dn(n_upper))/a:
    ans = n_upper
else:
    ans = n_lower

print(min(ans,maxint))

### FIXED CODE ###

s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1)
# coding: utf-8

N = input()
A = input()

N = int(N)
A = int(A)

flag = 0

if N % 500 == 0:
    print('YES')
    flag = 1
else:
    for i in range(10000 // 500):
        sum_ = 500 * i

        if sum_ > N:
            x = i - 1
            break

for i in range(A):
    y = 500 * x + i

    if N == y:
        print('YES')
        flag = 1

if flag == 0:
    print('NO')


### FIXED CODE ###

# coding: utf-8

N = input()
A = input()

N = int(N)
A = int(A)

if N % 500 <= A:
    print("Yes")
else:
    print("No")
S = input()
T = input()

N, M = len(S), len(T)

# N>=Mのとき
for i in range(max(0,N-M), -1, -1):
    # 今着目しているSの部分
    now = S[i:i+M]

    # nowにTを入れられるかチェック
    for j in range(M):
        if now[j] == '?' or now[j] == T[j]:
            continue
        else:
            break
    else:
        # 入れられるならその部分をTに置換
        S = S[0:i] + T + S[i+M:N]
        # 残った?をaに置換
        S = S.replace('?', 'a')
        print(S)
        break
else:
    # どこにもTを入れられなかったら
    print('UNRESTORABLE')


### FIXED CODE ###

S = input()
T = input()

N, M = len(S), len(T)

if N < M:
    print('UNRESTORABLE')
else:
    for i in range(max(0,N-M), -1, -1):
        # 今着目しているSの部分
        # 後ろから探査
        now = S[i:i+M]

        # nowにTを入れられるかチェック
        for j in range(M):
            if now[j] == '?' or now[j] == T[j]:
                continue
            else:
                break
        else:
            # 入れられるならその部分をTに置換
            S = S[0:i] + T + S[i+M:N]
            # 残った?をaに置換
            S = S.replace('?', 'a')
            print(S)
            break
    else:
        # どこにもTを入れられなかったら
        print('UNRESTORABLE')
n=int(input())
l=[0,0,0]
ans=1
mod=10**9+7
for i in list(map(int,input().split())):
    ans=ans*l.count(i)%mod
    l[l.index(i)]+=1
print(ans)

### FIXED CODE ###

def f():
    n=int(input())
    l=[0,0,0]
    ans=1
    mod=10**9+7
    for i in list(map(int,input().split())):
        if i not in l:print(0);exit()
        ans=ans*l.count(i)%mod
        l[l.index(i)]+=1
    print(ans)
if __name__ == "__main__":f()
N = input()
n = [int(N[:1]), int(N[1:])]
a = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']
if a[0] > 12:
  if a[1] == 0:
    print(a[3])
  else:
    print(a[0])
elif a[1] > 12:
  if a[0 == 0:
    print(a[3])
  else:
    print(a[1])
else:
  print(a[2])

### FIXED CODE ###

N = input()
n = [int(N[:2]), int(N[2:])]
a = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']
if n[0] > 12 or n[0] == 0:
  del a[1]
  del a[1]
  if n[1] > 12 or n[1] == 0:
    del a[0]
elif n[1] > 12 or n[1] == 0:
  del a[0]
  del a[1]
else:
  a = [a[2]]
print(a[0])
#52b
n = int(input())
s = input()
ans = [0]

for i in s:
    if s[i]=='I':
        ans.append(ans[-1]+1)
    else:
        ans.append(ans[-1]-1)

print(max(ans))


### FIXED CODE ###

#52b
n = int(input())
s = input()
ans = [0]

for i in s:
    if i=='I':
        ans.append(ans[-1]+1)
    else:
        ans.append(ans[-1]-1)
#print(ans)

print(max(ans))
userData = input()

userDatas = input()

if userData == useDatas[0:-1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

userData = input()

userDatas = input()

if userData == userDatas[0:-1]:
  print("Yes")
else:
  print("No")
import math

X = int(input())

for i in range(1001):
    if ((X + i ** 5) ** 0.2).is_integer():
        print(int((X + i ** 5) ** 0.2), i)
        exit()

for j in range(1, 1001):
    if ((X - j ** 5) ** 0.2).is_integer():
        print(int((X - j ** 5) ** 0.2), -j)
        exit()


### FIXED CODE ###

import math

X = int(input())

for i in range(1001):
    f = round((X + i ** 5) ** 0.2)
    if f ** 5 - i ** 5 == X:
        print(int((X + i ** 5) ** 0.2), i)
        exit()

for i in range(1, 1001):
    f = round(abs(X - i ** 5) ** 0.2)
    if X - i ** 5 > 0:
        if f ** 5 - (-i) ** 5 == X:
            print(f, -i)
            exit()
    else:
        if (-f) ** 5 - (-i) ** 5 == X:
            print(-f, -i)
            exit()
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)

A, B, C, D = map(int, input().split())

b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)

print((B-A+1) -(b_num - a_num))

### FIXED CODE ###

num = input()
l = [i for i in num]
count = 0
for k in range(0,len(l)-1):
    if l[k] == l[k+1]:
        count+=1
if count > 0:
    print("Bad")
else:
    print("Good")
from collections import deque

n = int(input())
dq = deque()

for _ in range(n):
    command = input().split()
    if command[0] == 'delete':
        dq.remove(int(command[1]))
    elif command[0] == 'insert':
        dq.appendleft(int(command[1]))
    elif command[0] == 'deleteFirst':
        dq.popleft()
    else:
        dq.pop()

print(*list(dq))

### FIXED CODE ###

from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))
def solve():
    S = input()
    K = int(input())
    a = min(list(S))
    lis = set()
    if len(S)>=5:
        for i,s in enumerate(S):
            if s==a:
                for j in range(1,K+1):
                    lis.add(S[i:min(len(S),i+j)])
    else:
        for i in range(len(S)):
            for j in range(i+1,len(S)+1):
                lis.add(S[i:j])
    ans = sorted(list(lis))[K-1]
    return ans
print(solve())

### FIXED CODE ###

def solve():
    S = input()
    K = int(input())
    strlist = sorted(list(S))
    lis = set()
    p = 0
    while len(list(lis))<K:
        a = strlist[p]
        if len(S)>=5:
            for i,s in enumerate(S):
                if s==a:
                    for j in range(i+1,min(len(S)+1,i+K+1)):
                        lis.add(S[i:j])
        else:
            for i in range(len(S)):
                for j in range(i+1,len(S)+1):
                    lis.add(S[i:j])
        p += 1
    ans = sorted(list(lis))[K-1]
    return ans
print(solve())
A, B, C = map(int, input().split())
print(max(C-(A-B)), 0)

### FIXED CODE ###

A, B, C = map(int, input().split())
print(max(C-(A-B), 0))
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=abs(x[i][d]-x[j][d])**2
    tmp=tmp**0.5
    if tmp==int(tmp):1
      ans+=1
print(ans)

### FIXED CODE ###

N, D = map(int, input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    tmp = 0
    for k in range(D):
      tmp += abs(X[i][k]-X[j][k])**2
    tmp = tmp**0.5
    if tmp == int(tmp):
      ans += 1
print(ans)
mod = 1e9 + 7;

def gcd(a, b):
  if a < b:
    a ^= b
    b ^= a
    a ^= b
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

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

l = A[0]
for i in range(1, N):
  l = l * A[i] // gcd(l, A[i])

sum = 0
for i in A:
  sum += l / i
  sum %= mod

print(int(sum))

### FIXED CODE ###

import fractions

mod = 10**9 + 7;

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

l = 1
for i in A:
  l = l * i // fractions.gcd(l, i)

sum = 0
for i in A:
  sum += l // i

print(sum % mod)
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

s=input()+"T"
N=len(s)
x,y=MI()

F=[[],[]]

temp=0
bit=0
for i in range(N):
    if s[i]=="F":
        temp+=1
    else:
        if temp!=0:
            F[bit].append(temp)
        bit=(bit+1)%2
        temp=0
        
        
Nx=len(F[0])
Ny=len(F[1])

        
#i番目の文字で，位置x [-N~N]につけるかどうか
dpx=[[False]*(2*N+1) for _ in range(Nx+1)]
dpy=[[False]*(2*N+1) for _ in range(Ny+1)]

dpx[0][N]=True
dpy[0][N]=True

if Nx>=1:
    dpx[1][N]=False
    dpx[1][N+F[0][0]]=True
    if s[0]=="T":
        dpx[1][N-F[0][0]]=True

MA=F[0][0]+1

for i in range(1,Nx):
    MA+=F[0][i]
    a=min(N-MA,0)
    b=max(N+MA+1,2*N+1)
    for j in range(a,b):
        if dpx[i][j]:
            jj=j+F[0][i]
            jjj=j-F[0][i]
            dpx[i+1][jj]=True
            dpx[i+1][jjj]=True
                
if Ny>=1:   
    MA=F[1][0]+1

for i in range(Ny):
    MA+=F[1][i]
    a=min(N-MA,0)
    b=max(N+MA+1,2*N+1)
    for j in range(a,b):
        if dpy[i][j]:
            jj=j+F[1][i]
            jjj=j-F[1][i]
            dpy[i+1][jj]=True
            dpy[i+1][jjj]=True

if dpx[-1][N+x] and dpy[-1][N+y]:
    print("Yes")
else:
    print("No")





### FIXED CODE ###

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

s=input()+"T"
N=len(s)
x,y=MI()

F=[[],[]]

temp=0
bit=0
for i in range(N):
    if s[i]=="F":
        temp+=1
    else:
        if temp!=0:
            F[bit].append(temp)
        bit=(bit+1)%2
        temp=0
        
XY=[set([0]), set([0])]
    
for bit in range(2):
    for i in range(len(F[bit])):
        temp=set([])
        a=F[bit][i]
        b=-a
        if bit==0 and i==0 and s[0]=="F":
            b=a
        for j in range(len(XY[bit])):
            aaa=XY[bit].pop()
            temp.add(aaa+a)
            temp.add(aaa+b)
        XY[bit]=temp
        
if (x in XY[0] ) and (y in XY[1] ):
    print("Yes")
else:
    print("No")
#import bisect
def desc_bin(a, x, lo=0, hi=None):
    """Insert item x in list a, and keep it reverse-sorted assuming a
    is reverse-sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return lo
N=int(input())
ans=[]
for _ in range(N):
    num=int(input())
    
    index=desc_bin(ans,num)
    if index==len(ans):
        ans.append(num)
    else:
        ans[index]=num
    print(ans)
print(len(ans))

### FIXED CODE ###

#import bisect
def desc_bin(a, x, lo=0, hi=None):
    """Insert item x in list a, and keep it reverse-sorted assuming a
    is reverse-sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return lo
N=int(input())
ans=[]
for _ in range(N):
    num=int(input())
    
    index=desc_bin(ans,num)
    if index==len(ans):
        ans.append(num)
    else:
        ans[index]=num
    #print(ans)
print(len(ans))
weathers = ['Sunny', 'Cloudy', 'Rainy' ]
s = str(input())
t = weathers.index(s)
print(weathers[t+1])


### FIXED CODE ###

weathers = ['Sunny', 'Cloudy', 'Rainy' ]
s = str(input())
t = weathers.index(s)
print(weathers[t-2])
cache = {0: 1, 1: 1, 2: 2}
combo_cache = {}


def permutuation(n):
    if n in cache:
        return cache[n]

    ret = n
    for i in range(n-1, 0, -1):
        if i in cache:
            ret *= cache[i]
            cache[n] = ret
            return ret

        ret *= i
    return ret


def combo(n, r):
    key = str(n) + "-" + str(r)
    if key in combo_cache:
        return combo_cache[key]

    x = permutuation(n)
    y = permutuation(n-r)
    z = permutuation(r)
    combo_cache[key] = int(x // (y * z))
    return combo_cache[key]


count = int(input())
li = list(map(int, input().split()))
#
# data = open("input.txt", "r")
# l = data.read()
# li = list(map(int, l.split(" ")))


sli = sorted(li)

pair_a = 0
pair_b = 0
current_max = 0

for i in range(len(sli) - 2,len(sli)):
    for j in range(0, i):
        val = combo(sli[i], sli[j])
        # print(str(sli[i]) + ", " + str(sli[j]) + ", " + str(val))
        if val > current_max:
            current_max = val
            pair_a = sli[i]
            pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))

cache = {0: 1, 1: 1, 2: 2}
combo_cache = {}


def permutuation(n):
    if n in cache:
        return cache[n]

    ret = n
    for i in range(n-1, 0, -1):
        if i in cache:
            ret *= cache[i]
            cache[n] = ret
            return ret

        ret *= i
    return ret


def combo(n, r):
    key = str(n) + "-" + str(r)
    if key in combo_cache:
        return combo_cache[key]

    x = permutuation(n)
    y = permutuation(n-r)
    z = permutuation(r)
    combo_cache[key] = int(x // (y * z))
    return combo_cache[key]


count = int(input())
li = list(map(int, input().split()))
#
# data = open("input.txt", "r")
# l = data.read()
# li = list(map(int, l.split(" ")))


sli = sorted(li)

pair_a = 0
pair_b = 0
current_max = 0

for i in range(len(sli) - 2,len(sli)):
    for j in range(0, i):
        val = combo(sli[i], sli[j])
        # print(str(sli[i]) + ", " + str(sli[j]) + ", " + str(val))
        if val > current_max:
            current_max = val
            pair_a = sli[i]
            pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))


### FIXED CODE ###

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

sli = sorted(li)

pair_a = sli[len(sli) - 1]
pair_b = 0
current_max = 0

i = sli[len(sli) - 1]

diff = 10**9
for j in range(0, len(sli) - 1):
    h = pair_a / 2
    if abs(h - sli[j]) < diff:
        diff = abs(h - sli[j])
        pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))