Harryxun/stf_run huggingface dataset:
from collections import deque
f = open("/Users/naoki/Documents/Atcoder/input.txt")

H,W = map(int,f.readline().split())
Ss = [str(f.readline()) for _ in range(H)]

yoko = [[0 for _ in range(W)] for _ in range(H)]
tate = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "#" or yoko[i][j] != 0:
            continue
        else:
            paths = [[i,j]]
            temp = 1
            for k in range(j+1, W):
                if Ss[i][k] == ".":
                    temp+=1
                    paths.append([i,k])
                else:
                    break
            for path in paths:
                yoko[path[0]][path[1]] = temp

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "#" or tate[i][j] != 0:
            continue
        else:
            paths = [[i,j]]
            temp = 1
            for k in range(i+1, H):
                if Ss[k][j] == ".":
                    temp+=1
                    paths.append([k,j])
                else:
                    break
            for path in paths:
                tate[path[0]][path[1]] = temp

answer = 0
for i in range(H):
    for j in range(W):
        if answer < tate[i][j]+yoko[i][j]-1:
            answer = tate[i][j]+yoko[i][j]-1
print(answer)

### FIXED CODE ###

from collections import deque

H,W = map(int, input().split())
Ss = [str(input()) for _ in range(H)]

yoko = [[0 for _ in range(W)] for _ in range(H)]
tate = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "#" or yoko[i][j] != 0:
            continue
        else:
            paths = [[i,j]]
            temp = 1
            for k in range(j+1, W):
                if Ss[i][k] == ".":
                    temp+=1
                    paths.append([i,k])
                else:
                    break
            for path in paths:
                yoko[path[0]][path[1]] = temp

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "#" or tate[i][j] != 0:
            continue
        else:
            paths = [[i,j]]
            temp = 1
            for k in range(i+1, H):
                if Ss[k][j] == ".":
                    temp+=1
                    paths.append([k,j])
                else:
                    break
            for path in paths:
                tate[path[0]][path[1]] = temp

answer = 0
for i in range(H):
    for j in range(W):
        if answer < tate[i][j]+yoko[i][j]-1:
            answer = tate[i][j]+yoko[i][j]-1
print(answer)
a = input("enter sth for a: ")
b = input("enter sth for b: ")
c = input("enter sth for c: ")

a1=a
b1 = b
c1= c
a = c1
b = a1
c = b1
print(f"valuse after reverse:{a}")
print(f"valuse after reverse:{b}")
print(f"valuse after reverse:{c}")

### FIXED CODE ###

x,y,z = list(map(int,input().split()))
 
def swap(a,b):
    tmp = a
    a = b
    b = tmp
    return (a,b)
 
x,y = swap(x,y)
x, z = swap(x, z)
print(x,y,z)
n, a, b = list(map(int, input().split()))
roop = n // (a +b)
extra = n - roop*(a+b)
print(extra)
result = a*roop
cycle = [1]*a +  [0]*b
if extra != 0:
  result += sum(cycle[:extra]) 
print(result)

### FIXED CODE ###

n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  result = a*roop
  if extra >= a:
    result += a
  else:
    result += extra
print(result)
N, K = map(int, input().split())

print(N-k+1);

### FIXED CODE ###

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

print(N-K+1);
N,Q=map(int, input().split())
s=input()
S=len(s)
A=[]
for i in range(Q):
  x,y=input().split()
  A.append((x,y))
  
if N==1:
  for x,y in A:
    if s[0]==x:
      print(0)
      exit()
  print(1)
  exit()
  
def L(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    elif s[d]==x and y=='R':
      d+=1
    if d<0:
      return False
  return True

ok,ng=S,-1
mid=(ok+ng)//2
for i in range(70):
  mid=(ok+ng)//2
  if L(mid):
    ok=mid
  else:
    ng=mid
p=ok
if ok==S:
  print(0)
  exit()

def R(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    elif s[d]==x and y=='R':
      d+=1
    if d==S:
      return False
  return True

ok,ng=-1,S
mid=(ok+ng)//2
for i in range(70):
  mid=(ok+ng)//2
  if R(mid):
    ok=mid
  else:
    ng=mid
q=ok
print(q-p+1)

### FIXED CODE ###

N,Q=map(int, input().split())
s=input()
S=len(s)
A=[]
for i in range(Q):
  x,y=input().split()
  A.append((x,y))
  
if N==1:
  for x,y in A:
    if s[0]==x:
      print(0)
      exit()
  print(1)
  exit()
  
def L(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    if s[d]==x and y=='R':
      d+=1
    if d<0:
      return False
    elif d==S:
      d-=1
  return True

ok,ng=S,-1
mid=(ok+ng)//2
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if L(mid):
    ok=mid
  else:
    ng=mid
p=ok
if ok==S:
  print(0)
  exit()

def R(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    if s[d]==x and y=='R':
      d+=1
    if d>=S:
      return False
    elif d<0:
      d+=1
  return True

ok,ng=-1,S
mid=(ok+ng)//2
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if R(mid):
    ok=mid
  else:
    ng=mid
q=ok

print(q-p+1)
A=[]
fp =0
bp =0
cmd = raw_input()
n=int(raw_input())
while n: 
    if cmd[0] == 'i':
        A.append(int(cmd[7:]))
        fp += 1
    elif cmd[6] == ' ':
        try:
            i = A[::-1].index(int(cmd[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif cmd[6] == 'F':
        A.pop()
        fp -=1
    elif cmd[6] == 'L':
        bp +=1
    n -=1
 
for e in A[bp:fp+1][::-1]:
    print int(e),

### FIXED CODE ###


A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()

    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
  n += 1
break

### FIXED CODE ###

n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1
N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[i]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)
x = input().int()

if x<1200:
    print("ABC")
else:
    print("ARC")

### FIXED CODE ###

x = int(input())

if x<1200:
    print("ABC")
else:
    print("ARC")
"""
・あるボールから（p,q）の移動で別のボールに移れるならコストが０、そうでなければ１
　→あるボールの位置(x,y) + (p,q) の位置にボールがあるかどうか、全てのボールについて確認する。なければコスト＋１
・p,qの選び方は、全ボールの間隔を試すと行けそう(N <= 50 なので間に合いそう)

"""



N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            pq.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))


ans = N
for p,q in pq:
    cost = 0
    for x,y in xy:
        if  (x+p, y+q) not in xy:
            cost += 1

    ans = min(ans, cost)

print(cost)

### FIXED CODE ###



N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            pq.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))


ans = N
for p,q in pq:
    cost = 0
    for x,y in xy:
        if  (x+p, y+q) not in xy:
            cost += 1

    ans = min(ans, cost)

print(ans)
s = str(input())
if s == 'ABC':
  print('ARC)
else:
  print('ABC')

### FIXED CODE ###

s = str(input())
if s == 'ABC':
  print('ARC')
else:
  print('ABC')
import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].append(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

n,m,k=map(int,input().split())

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append([])
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(set(unii)&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)


### FIXED CODE ###

n=int(input())
print((n+1)//2)
N = int(input())
counter = 0
for i in range(N):
	l,n = map(int,input().split())
 	counter += (n-l+1)
print(counter)

### FIXED CODE ###

N = int(input())
counter = 0
for i in range(N):
 l,n = map(int,input().split())
 counter += (n-l+1)
print(counter)
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K)/N
    for k in range(1, K):
        r = math.ceil(math.log2(K / k))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log2(K / k))
        pro += 0.5**r / N
    print(pro)



### FIXED CODE ###

import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

N,M = map(int, sys.stdin.readline().rstrip().split(" "))
Lmax, Rmin = 0, N
for _ in range(M):
    L, R = map(int, sys.stdin.readline().rstrip().split(" "))
    Lmax = max(L, Lmax)
    Rmin = min(R, Rmin)
assert Rmin >= Lmax
print(Rmin - Lmax + 1)
exit(0)

### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

N, M = map(int, sys.stdin.readline().rstrip().split(" "))
Lmax, Rmin = 0, N
for _ in range(M):
    L, R = map(int, sys.stdin.readline().rstrip().split(" "))
    Lmax = max(L, Lmax)
    Rmin = min(R, Rmin)
if Rmin >= Lmax:
    print(Rmin - Lmax + 1)
else:
    print(0)
exit(0)
n,m,k=map(int,input().split())
friend=[0]*n
stock=[[] for i in range(n)]
ter=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    stock[a-1].append(b-1)
    stock[b-1].append(a-1)
    friend[a-1]+=1
    friend[b-1]+=1
def dfs(i,k):
    size[k]+=1
    for next_i in stock[i]:
        if ter[next_i]==0:
            ter[next_i]=k
            dfs(next_i,k)
total=0
size=[0]*(n+1)
for i in range(n):
    if ter[i]==0:
        total+=1
        ter[i]=total
        dfs(i,total)
ans=[0]*n
for i in range(n):
    ans[i]=size[ter[i]]-friend[i]-1
for i in range(k):
    c,d=map(int,input().split())
    if ter[c-1]==ter[d-1]:
        ans[c-1]-=1
        ans[d-1]-=1
for i in range(n-1):
    print(ans[i],end=" ")
print(ans[n-1])


### FIXED CODE ###

class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parent=[i for i in range(n)]
        self.rank=[1]*n#木の高さ
        self.size=[1]*n#size[i]はiを根とするグループのサイズ

    def find(self,x):#ｘの根（親）を返す
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.find(self.parent[x])#経路圧縮
            return self.parent[x]

    def unite(self,x,y):#ｘ、ｙの集合の統合
        x=self.find(x)
        y=self.find(y)
        if x!=y:
            if self.rank[x]<self.rank[y]:#ランクの比較
                self.parent[x]=y
                self.size[y]+=self.size[x]
            else:
                self.parent[y]=x
                self.size[x]+=self.size[y]
                if self.rank[x]==self.rank[y]:
                    self.rank[x]+=1
    def group_size(self,x):#ｘが属する集合の大きさ
        return self.size[self.find(x)]
    def is_same(self,x,y):#ｘ、ｙが同じ集合に属するかを判定する
        return self.find(x)==self.find(y)

n,m,k=map(int,input().split())

uf=UnionFind(n)
ans = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    uf.unite(a-1,b-1)
    ans[a - 1] -= 1
    ans[b - 1] -= 1
for i in range(k):
    c, d = map(int, input().split())
    if uf.is_same(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1

for i in range(n):
    ans[i]+=uf.group_size(i)-1
    print(ans[i])
import statistics
import math

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

B = []
C = []
D = []
E = []
ureshimi = []
k = 0
l = 0

sumA = sum(A)
sumBC = sum(A[0:2])
sumDE = sum(A) - sumBC

s = 0
mannnaka = 0

for i in range(N-2):
    s += A[i]
    if i == N - 3:
        mannnaka = N - 3
    elif s + A[i + 1] > sumA / 2:
        mannnaka = i
        break



saisho = max(0, mannnaka - 7)
saigo = min(N - 3, mannnaka + 5)

sumBC = sum(A[0:saisho + 2])
sumDE = sum(A) - sumBC


for i in range(saisho, saigo):
    BC = A[0 : i + 2]
    s = sum(A[0 : k])
    for j in range(k, i + 2):
        s += BC[j]
        if j == i + 1:
            k = j 
            B = BC[0 : j ]
            C = BC[j  : N - i]
            break
        elif s + BC[j + 1] > sumBC / 2:
            k = j
            if BC[j + 1] / 2 >= sumBC / 2 - s:
                B = BC[0 : j + 1]
                C = BC[j + 1 : i + 2]
            else:
                B = BC[0 : j + 2]
                C = BC[j + 2 : i + 2]
            break
    sumBC += A[i + 2]
    DE = A[i + 2 : N + 1]
    s = sum(DE[0:l - i + 1 ])
    for j in range(l - i + 1 , N - i - 2):
        if j == N - i - 2:
            l = j + i 
            D = DE[0 : j ]
            E = DE[j  : N - i]
            break
        elif s + DE[j ] > sumDE / 2:
            l = j + i
            if DE[j ] / 2 >= sumDE / 2 - s:
                D = DE[0 : j ]
                E = DE[j : N - i]
            else:
                D = DE[0 : j + 1]
                E = DE[j + 1 : N - i]
            break
        s += DE[j]
    sumDE -= A[i + 2]

    ureshimi.append(max(sum(B), sum(C), sum(D), sum(E)) - min(sum(B), sum(C), sum(D), sum(E)))



print(min(ureshimi))

### FIXED CODE ###

import statistics
import math

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


ureshimi = []
k = 0
l = 2

B = 0
C = 0
D = 0
E = 0

sumBC = sum(A[0:2])
sumDE = sum(A) - sumBC

for i in range(2, N - 1):
    for j in range(k, i):
        if j == i - 1:
            k = j
            C = sumBC - B
            break
        elif B + A[j] >= sumBC / 2:
            if sumBC / 2 - B  > A[j] / 2:
                B += A[j]
                k = j + 1
                C = sumBC - B
                break
            else:
                k = j
                C = sumBC - B
                break
        B += A[j]
    for j in range(l, N):
        if j == N - 1:
            l = j
            E = sumDE - D
            break
        elif D + A[j] >= sumDE / 2:
            if sumDE / 2 - D > A[j] / 2:
                D += A[j]
                l = j + 1
                E = sumDE - D
                break
            else:
                l = j
                E = sumDE - D
                break
        D += A[j]
    ureshimi.append(max([B, C, D, E]) - min([B, C, D, E]))
    sumBC += A[i]
    sumDE -= A[i]
    D -= A[i]
        

print(min(ureshimi))
H, W = [int(i) for i in input().split(" ")]
S = []
for i in range(H):
  S.append(input())
  
import numpy as np

r_lens = []
for s in S:
  counts = [len(block) for block in s.split("#")]
  
  r_len = []
  for c in counts:
    r_len+=[c]*c
    r_len+=[0]
  r_lens.append(r_len)
r_lens = np.array(r_lens)

S2 = [""]*W
for h in range(H):
  for w in range(W):
    S2[w] += S[h][w]
    
c_lens = []
for s in S2:
  counts = [len(block) for block in s.split("#")]
  
  c_len = []
  for c in counts:
    c_len+=[c]*c
    c_len+=[0]
  c_lens.append(c_len)
c_lens = np.array(c_lens)

print((r_lens+c_lens+1).max())

### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)
from collections import deque
import math
mod = 10**9+7
N,K = map(int,input().split())

#KPxの計算用。一回だけ使う
def Perm(n,r):#aPb
    return math.factorial(n) // math.factorial(n - r)

#K-2Pxの計算のメモ化
K_2perm =[1,K-2]
pres = K-2
for i in range(2,K-1):
    pres = (pres*(K-1-i))%mod
    K_2perm.append(pres)

child = [[] for i in range(N)]
for hoge in range(N-1):
    a,b = [int(i)-1 for i in input().split()]#点を0-indexedになおす
    child[a].append(b)
    child[b].append(a)


ans = Perm(K,len(child[0])+1)%mod
#DFSしながら塗る
went = [False] * N
queue = deque()
queue.append(0)
went[0] = True
while queue:
    cur = queue.pop()
    for togo in child[cur]:
        if not went[togo]:
            went[togo] = True
            queue.append(togo)
            print(len(child[togo]))
            ans *= K_2perm[len(child[togo])-1]
            ans %= mod
print(ans)



### FIXED CODE ###

from collections import deque
import math
import sys
mod = 10**9+7
N,K = map(int,input().split())

#k
Kperm =[1,K]
pre = K
for i in range(2,K+1):
    pre = (pre*(K+1-i))%mod
    Kperm.append(pre)


#K-2Pxの計算のメモ化
K_2perm =[1,K-2]
pres = K-2
for i in range(2,K-1):
    pres = (pres*(K-1-i))%mod
    K_2perm.append(pres)

child = [[] for i in range(N)]
for hoge in range(N-1):
    a,b = [int(i)-1 for i in input().split()]#点を0-indexedになおす
    child[a].append(b)
    child[b].append(a)

if len(child[0])>=K:
    print(0);sys.exit()
ans = Kperm[len(child[0])+1]
#DFSしながら塗る
went = [False] * N
queue = deque()
queue.append(0)
went[0] = True
while queue:
    cur = queue.pop()
    if cur!=0 and len(child[cur])>=K:
        print(0)
        sys.exit()
    if cur!=0:
        ans *= K_2perm[len(child[cur])-1]
        ans %= mod
    for togo in child[cur]:
        if not went[togo]:
            went[togo] = True
            queue.append(togo)
print(ans)
from math import degrees,atan 
a,b,x=map(int,input().split())
print(math.degrees(math.atan(a*b*b/2*x)) if x <=a*a*b/2 else math.degrees(math.atan(2*b/a-2*x/a*a*a)))

### FIXED CODE ###

from math import degrees,atan 
a,b,x=map(int,input().split())
print(degrees(atan((a*b*b)/(2*x))) if x <=a*a*b/2 else degrees(atan((2*b)/a-(2*x)/(a*a*a))))
K, X = map(int, input().split())
if 500*K >= X:
  print("Yes")
else;
  print("No")

### FIXED CODE ###

K, X = map(int, input().split())
if 500*K >= X:
  print("Yes")
else:
  print("No")
a,b = map(int,input())

if a >= 2*b:
    print(a-2*b)
else:
    print("0")


### FIXED CODE ###

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

if a >= 2*b:
    print(a-2*b)
else:
    print("0")
N,Q=map(int,input().split())
S=input()
l,r=[],[]
for i in range(Q):
    l0,r0=map(int,input().split())
    l.append(l0)
    r.append(r0)
c={}
for i in range(Q):
    for i in range(l[i]-1,r[i]-1):
        if (S[i]=='A') and (S[i+1]=='C'):
            c[i]=1
    d=int(c.count(1))
    print(d)

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
t=[0]*N
for i in range(N-1):
    t[i+1]=t[i]+(1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
a=int(input())
b=int(input())
c=a+b

if c<10:
  print(c)
else:
  print('error')

### FIXED CODE ###

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

if a+b<10:
  print(a+b)
else:
  print("error")
L_yoko = []
for i in range(3):
     x = list(map(int,input().split()))
     L_yoko.append(x)

ans = []
for i in range(9):
     x = int(input())
     ans.append(x)


L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

a = int(0)
for z in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break


if a == 1:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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


L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

n = int(input())
ans = [int(input()) for _ in range(n)]

a = int(0)
for z in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break


if a == 0:
    print("No")
else:
    print("Yes")
s = input()
ans = []
for c in s:
    if c == "0":
        ans.append("0")
    if c == "1":
        ans.append("1")
    if c == "B":
        ans.pop(-1)
print("".join(ans))


### FIXED CODE ###

s = list(input())
ans = []
for char in s:
    if char == "B":
        if ans:
            ans.pop(-1)
        else:
            pass
    else:
        ans.append(char)

print("".join(ans))
A = list(map(int, input().sprit()))
ans = sorted(A)
if ans == [5,5,7]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

A=list(map(int,input().split()))
ans=sorted(A)
if ans==[5,5,7]:
  print('YES')
else:
  print('NO')
K=input("K=")
A=input("A=")
B=input("B=")

f="NG"
for i in range(int(A),int(B)):
    c=i%int(K)
    if c==0:
        f="OK"
print(f)


### FIXED CODE ###

K=input()
A, B=input().split()


f="NG"
for i in range(int(A),int(B)+1):
    c=i%int(K)
    if c==0:
        f="OK"
print(f)
N, K = map(int, input().split())

while N-K >= 0:
	num1 = N-K
	N = N-K
    
num2 = abs(num1-K)
if num1 < num2:
  print(num1)
else:
  print(num2)

### FIXED CODE ###

N, K=map(int, input().split())
min=min(N%K, abs((N%K)-K))
print(min)
a,b,c=input().split()
if b=="+":
  print(a+b)
else:print(a-b)

### FIXED CODE ###

a,b,c=input().split()
a=int(a)
c=int(c)
if b=="+":
  print(a+c)
else:print(a-c)
import.math
A, B, C, D = map(int, input().split())
sita = A*30+B*6
sitas = 0
if sita > 180:
  sitas = 360 - sita
elif -180<= sita < 0:
  sitas = sita * -1
elif sita < -180:
  sitas = sita + 360
else:
  sitas = sita
print(math.sqrt(C**2+D**2-2*C*D*(math.cos(sitas))))

### FIXED CODE ###

def resolve():
    import math
    A, B, H, M = map(int, input().split())
    sita = abs(H*30+M*0.5-M*6)
    if sita > 180:
        sita = 360 - sita
    print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(sita))))
resolve()
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    if a == b:
        continue
    sbn_ = abs(m//2-a)
    if sbn_ < sbn :
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])


### FIXED CODE ###

n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)