Harryxun/stf_run huggingface dataset:
import sys
input=sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
A.sort()
Devide_N=10**9+7
Rem_2_32_DN=(2**32)%Devide_N

if N%2==1:
  if A[0]!=0 or A[1]==0:
    print(0)

  else:
    del A[0]
    for ch_n in range(1,(N-1)//2+1):
      if A[0]!=ch_n*2 or A[1]!=ch_n*2:
        break
      else:
        del A[0:2]
    else:
      exp=(N-1)//2
      
      exp_quotient_32=exp//32
      exp_rem_32=exp%32
      Rem_ans_Devide_N=1
      for _ in range(exp_quotient_32):
        Rem_ans_Devide_N=(Rem_ans_Devide_N*Rem_2_32_DN)%Devide_N
        
      print((Rem_ans_Devide_N*2**(exp_rem_32))%Devide_N)
      sys.exit()
    print(0)
else:
  for ch_n in range(1,N//2+1):
    if A[0]!=ch_n*2-1 or A[1]!=ch_n*2-1:
      break
    else:
      del A[0:2]
  else:
    exp=N//2
    
    exp_quotient_32=exp//32
    exp_rem_32=exp%32
    Rem_ans_Devide_N=1
    for _ in range(exp_quotient_32):
      Rem_ans_Devide_N=(Rem_ans_Devide_N*Rem_2_32_DN)%Devide_N
      
    print((Rem_ans_Devide_N*2**(exp_rem_32))%Devide_N)
    sys.exit()
  print(0)




### FIXED CODE ###

import sys
input=sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
A.sort()
Devide_N=10**9+7
Rem_2_32_DN=(2**32)%Devide_N

if N%2==1:
  if (A[0]!=0 or A[1]==0 if N>2 else A[0]!=0):
    print(0)

  else:
    del A[0]
    for ch_n in range(1,(N-1)//2+1):
      if A[0]!=ch_n*2 or A[1]!=ch_n*2:
        break
      else:
        del A[0:2]
    else:
      exp=(N-1)//2
      
      exp_quotient_32=exp//32
      exp_rem_32=exp%32
      Rem_ans_Devide_N=1
      for _ in range(exp_quotient_32):
        Rem_ans_Devide_N=(Rem_ans_Devide_N*Rem_2_32_DN)%Devide_N
        
      print((Rem_ans_Devide_N*2**(exp_rem_32))%Devide_N)
      sys.exit()
    print(0)

else:
  for ch_n in range(1,N//2+1):
    if A[0]!=ch_n*2-1 or A[1]!=ch_n*2-1:
      break
    else:
      del A[0:2]
  else:
    exp=N//2
    
    exp_quotient_32=exp//32
    exp_rem_32=exp%32
    Rem_ans_Devide_N=1
    for _ in range(exp_quotient_32):
      Rem_ans_Devide_N=(Rem_ans_Devide_N*Rem_2_32_DN)%Devide_N
      
    print((Rem_ans_Devide_N*2**(exp_rem_32))%Devide_N)
    sys.exit()
  print(0)
# -*- coding: utf-8 -*-
n=int(input())
n.replace("1","9")and("9","1")

### FIXED CODE ###

# -*- coding utf-8 -*-
n = str(input())
S = n.replace("1","8")
T = S.replace("9","1")
U = T.replace("8","9")
print(U)
N,K = map(int,input().split())
import math
ans = 0.
for c in range(1,N+1):
    if c >= K:
        req = 0
    else:
        req = int(math.log2(K/c)) + 1
    ans += (1/N)*((1/2)**req)
print(ans)
    


### FIXED CODE ###

N,K = map(int,input().split())
import math
ans = 0.
for c in range(1,N+1):
    if c >= K:
        req = 0
    else:
        req = math.log2(K/c)
        if req != int(req):
            req = int(req) + 1
        else:
            req = int(req)
    ans += (1/N)*((1/2)**req)
print(ans)
import math
#引数にリストを入れるとその最小公倍数が返ってくる
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n=int(input())
A=list(map(int,input().split()))

k=1
for i in A:
  k=lcm(k,i)

def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(k-1))

### FIXED CODE ###

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

m =1
for i in range(len(mods)):
  m *= mods[i]

sums = 0
for i in range(len(mods)):
  sums += (m-1) %mods[i]

print(sums)
import sys
sys.setrecursionlimit(10**6)
from collections import deque
from itertools import chain

def bfs(maze,visited,gy,gx):
    que = deque([[0,0]])
    visited[0][0] = 0
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            ny,nx = y+j,x+k
            if 0 <= ny < w and 0 <= nx < h:
                if maze[ny][nx] == "." and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[y][x] + 1
                    que.append([ny,nx])

h,w = map(int,input().split())
maze = [input() for _ in range(h)]
visited = [[-1]*(w) for _ in range(h)]
sr = bfs(maze,visited,h-1,w-1)

num_dot = list(chain.from_iterable(maze))
num_dot = num_dot.count('.')

if sr == -1 or num_dot < sr:
    print(-1)
else:
    print(num_dot - sr - 1)

### FIXED CODE ###

from collections import deque

def bfs(maze,visited,sy,sx,gy,gx):
    Step = ([1,0],[0,1],[-1,0],[0,-1])
    
    que = deque([[sx,sy]])
    visited[sx][sy] = 1
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in Step:
            ny,nx = y+j , x+k
            if 0 <= ny <= gy and 0 <= nx <= gx:
                if maze[ny][nx] == '.' and visited[ny][nx] == INF:
                    visited[ny][nx] = visited[y][x] + 1
                    que.append([ny,nx])


h,w = map(int,input().split())
maze = [input().strip() for _ in range(h)]

cntSharp = 0
for i in range(h):
    cntSharp += maze[i].count('.')

INF = 10**5
visited = [[INF]*w for _ in range(h)]

sx,sy = 0,0
gy,gx = h-1,w-1

minStep = bfs(maze,visited,sy,sx,gy,gx)
print(cntSharp - minStep if visited[gy][gx] != INF else -1)
s = list(map(int, input()))
if list(sorted(s)) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")  

### FIXED CODE ###

s = list(map(int, input().split()))
if sorted(s) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")
N,K = map(int,input().split())

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


A = []
for i in range(N):
    A.append(tmp[i]-1)

check = set([0])

now = 0

jun = [0]
for i in range(N):
    if A[now] not in check:
        check.add(A[now])
        jun.append(A[now])
        now = A[now]
    else:
        break
#print(jun.index(A[now]))
#print(jun)
print(jun[(K-jun.index(A[now])+1)%(len(jun)-jun.index(A[now])+1)]+1)



### FIXED CODE ###

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

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

reached = []

check = [0]*(N+1)
now = 1


for _ in range(N):
    check[now]+=1
    if check[now] == 1 :
        reached.append(now)
        now = A[now-1]

    if check[now] > 1:
        break

#print(reached)

for i in range(len(reached)):
    if reached[i]== now:
        cnt = i
        break


roop = len(reached)- cnt
init = len(reached) 

if K < init:
    print(reached[K])
else:
    print(reached[(K-init)%roop+cnt])
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
count=Counter(s[0])
for i in range(n):
    count &=s[i]

ans=""
for i in sorted(count.keys()):
    ans +=i*count[i]
print(ans)

### FIXED CODE ###

from collections import Counter
n=int(input())
s=[input() for i in range(n)]
count=Counter(s[0])
for i in range(n):
    count &=Counter(s[i])

ans=""
for i in sorted(count.keys()):
    ans +=i*count[i]
print(ans)
n = input()
A = input().split(' ').sort()
q = input()
M = input().split(' ')

for m in M:
    print_yn(search(0, m))
    
def search(sum_base, m):
    if sum_base == m:
        return true
    result = false
    for a in A:
        if sum_base + a <= m:
            r_branch = search(sum_base + a, m)
            result = result || r_branch
    return result

def print_yn(result):
    if result:
        print('yes')
    else:
        print('no')
    return

### FIXED CODE ###

n = input()
A = input().split(' ')
A.sort()
A.reverse()
q = input()
M = input().split(' ')

A = list(map(int,A))
M = list(map(int,M))
A.sort()

A_sum = [0]
for a in A:
    A_sum.append(a+A_sum[-1])
A_sum.pop(0)

A.reverse()
A_sum.reverse()


#memo = [True]*(len(A))

def search(base, m, n):
    if base == m:
        return True
    if len(A)-1 < n or m - base > A_sum[n]:
        return False
    result = False
    for i in range(len(A)-1,n-1,-1):
        if base + A[i] <= m: # and memo[i]:
#           memo[i] = False
#           print(str(A[i]) + ',' + str(base+A[i]) + ',')
            if search(base+A[i], m, i+1):
                return True
#           memo[i] = True
    return result

def print_yn(result):
    if result:
        print('yes')
    else:
        print('no')

for m in M:
#   print(str(m)+':')
    print_yn(search(0,m,0))
n = input()
  
A = map(int, raw_input().split())
   
q = input()
   
M = map(int, raw_input().split())
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A)
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

### FIXED CODE ###

n = input()

A = map(int, raw_input().split())
   
q = input()
   
M = map(int, raw_input().split())
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"
a,b,c,d=map(int,input().split())

if abs(a,c)<=d or (abs(a-b)<=d and abs(b-c) <=d):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")
n = int(input())
A = list(map(int,input().split()))
A.sort()

l = [0]*(2*10**5+1)

for i in A:
    for j in range(0,10**5,i):
        l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)

### FIXED CODE ###

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

l = [0]*(10**6+1)

for i in A:
    if l[i] <= 1:
        for j in range(0,10**6+1,i):
            l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)
import numpy　as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

### FIXED CODE ###

import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
n = N//2
if N%2 != 0:
    ar1,ar2 = [],[]
    ans1,ans2 = 0,0

    for i in range(n):
        ar1.append(A[-1-i])
        ar1.append(A[i])
        
    for i in range(1,len(ar1)):
        ans1 += abs(ar1[i]-ar1[i-1])
    ans1 += max(abs(ar1[0]-A[n]), abs(ar1[-1]-A[n]))
    for i in range(n):
        ar2.append(A[-1-i])
        ar2.append(A[i])
        
    for i in range(1,len(ar1)):
        ans2 += abs(ar2[i]-ar2[i-1])
    ans2 += max(abs(ar2[0]-A[n]), abs(ar2[-1]-A[n]))
    ans = max(ans1,ans2)
else:
    ar = []
    ans = 0
    for i in range(n-1):
        ar.append(A[-1-i])
        ar.append(A[i])
    for i in range(1,len(ar)):
        ans += abs(ar[i]-ar[i-1])
    ans += max(abs(ar[0]-A[n])+abs(ar[-1]-A[n+1]), abs(ar[-1]-A[n])+abs(ar[0]-A[n+1]))
        
    
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
n = N//2
if N%2 != 0:
    ans1,ans2,ans = 0,0,0
    ar1,ar2 = A[:n],A[n+1:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    ar.append(A[n])
    for i in range(N-1):
        ans1 += abs(ar[i]-ar[i+1])
    ar = [A[n]]+ar[:-1]
    for i in range(N-1):
        ans2 += abs(ar[i]-ar[i+1])
    ans = max(ans1,ans2)
else:
    ans = 0
    ar1,ar2 = A[:n],A[n:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    for i in range(N-1):
        ans += abs(ar[i]-ar[i+1])
 
print(ans)
import math

a,b,x = map(int,input().split())
c = 2*x/(a*b)

if c <= a:
    ans = 90 - math.degrees(math.atan(c/b))
    
else:
    d = 2*(a**2 * b - x)/a**2
    
    ans = 90 - math.degrees(math.atan(a/d))
    
print(ans)

### FIXED CODE ###

import math

a,b,x = map(int,input().split())
c = 2*x/(a*b)

if c <= a:
    ans = 90 - math.degrees(math.atan(c/b))
    
else:
    d = 2*(a**2 * b - x)/a**2
    
    if d == 0:
        ans = 0
    else:
        ans = 90 - math.degrees(math.atan(a/d))
    
print(ans)
hoge = input().split()
i = 0
while i < range(len(hoge)):
  if i%2==0 and hoge[i] == ('R' or 'D' or 'U'):
    pass
  elif i%2==1 and hoge[i] == ('L' or 'D' or 'U'):
    pass
  else:
    break
  i+=1
if i == len(hoge):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import re
hoge = list(input())
i = 0
while i < len(hoge):
    if i%2==0 and re.findall(r'[RDU]',hoge[i]):
        pass
    elif i%2==1 and re.findall(r'[LDU]',hoge[i]):
        pass
    else:
        break
    i+=1
if i == len(hoge):
  print('Yes')
else:
  print('No')
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
  if a[i]+1==a[i+1]:
    ans+=c[i]
print(ans)

### FIXED CODE ###

n=int(input())
print(n**3)
n, a, b, k = map(int, input().split())

M = 998244353
fact_n = [0 for m in range(n+1)]
fact_inv = [0 for m in range(n+1)]


def combination(n, r):
    if n == 0 and r == 0:
        return 1
    elif n < r or n < 0:
        return 0

    c = fact_inv[r] * fact_inv[n-r] % M
    return fact_n[n] * c % M


def main():
    fact_n[0] = fact_inv[0] = 1
    for i in range(1, n+1):
        fact_n[i] = fact_n[i-1] * i % M
        fact_inv[i] = fact_inv[i-1] * pow(i, M-2, M) % M

    com = 0
    for i in range(n):
        if (k-a*i) % b == 0:
            j = (k-a*i) // b
            com += combination(n, i) * combination(n, j) % M

    print(com)


if __name__ == '__main__':
    main()


### FIXED CODE ###

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

M = 998244353
fact_n = [0 for m in range(n+1)]
fact_inv = [0 for m in range(n+1)]


def mod_pow(a, n):
    x = 1
    while n > 0:
        if n & 1:
            x = x * a % M

        a = a * a % M
        n >>= 1

    return x


def combination(n, r):
    if n == 0 and r == 0:
        return 1
    elif n < r or n < 0:
        return 0

    return fact_n[n] * fact_inv[r] * fact_inv[n-r] % M


def main():
    fact_n[0] = fact_inv[0] = 1
    for i in range(1, n+1):
        fact_n[i] = fact_n[i-1] * i % M

    fact_inv[n] = pow(fact_n[n], M-2, M)
    for i in range(n-1, 0, -1):
        fact_inv[i] = fact_inv[i+1] * (i+1) % M

    com = 0
    for i in range(n+1):
        if (k-a*i) % b == 0 and k - a * i >= 0:
            j = (k-a*i) // b
            com += combination(n, i) * combination(n, j) % M

    print(com % M)


if __name__ == '__main__':
    main()
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

S = v()
T = v()
len_s = len(S)
len_t = len(T)
check = False
ans = []

if len_s<len_t:
    print("UNRESTORABLE")
    sys.exit()

for i in range(len_s):
    if S[i] == "?":
        cnt += 1
        if cnt >= len_t:
            aaa = S.replace("?","a")
            ans.append(aaa[:i-len_t+1]+T+aaa[i+1:])
    elif S[i] in T:
        cnt = 0
        place = T.index(S[i])
        a = i
        for j in range(a-place,len_t+a-place):
            if T[j-(a-place)] == S[j] or S[j] == "?":
                check = True
            else:
                check = False
                continue
        if check:
            aaa = S.replace("?","a")
            ans.append(aaa[:i-place]+T+aaa[i+len_t:])
    else:
        cnt = 0

if len(ans)>0:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")
        


### FIXED CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

S = v()
T = v()
len_s = len(S)
len_t = len(T)
check = False
ans = []

if len_s<len_t:
    print("UNRESTORABLE")
    sys.exit()

for i in range(len_s):
    if S[i] == "?":
        cnt += 1
        if cnt >= len_t:
            aaa = S.replace("?","a")
            ans.append(aaa[:i-len_t+1]+T+aaa[i+1:])
    elif S[i] in T:
        cnt = 0
        place = T.index(S[i])
        if len_s<len_t+i-place:
            break
        for j in range(i-place,len_t+i-place):
            if T[j-(i-place)] == S[j] or S[j] == "?":
                check = True
            else:
                check = False
                break
        if check:
            aaa = S.replace("?","a")
            ans.append(aaa[:i-place]+T+aaa[len_t+i-place:])
    else:
        cnt = 0

if len(ans)>0:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")
N, M = map(int, input().split())
ss = {}

for i in range(M):
    p, y = map(int, input().split())
    if not (p-1) in ss:
        ss[p-1] = []
    ss[p-1].append((i, y))

ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = f"{ps}{ds}"

for l in ls:
    print(l)


### FIXED CODE ###

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

for i in range(M):
    p, y = map(int, input().split())
    ss[p-1].append((i, y))

ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = ps+ds

for l in ls:
    print(l)
import math,sys
for e in sys.stdin:print(int(float(input())**2/98+2))


### FIXED CODE ###

import sys
for e in sys.stdin:print(int(float(e)**2/98+2))
def c(n, p, vis, k, f, g):
    if vis[n]:
        return
    vis[n] = True
    w = f[n] + p
    k[n] = w
    ch = g[n]
    for x in ch:
        c(x, w, vis, k, f, g)


def main():
    n, q = map(int, input().split())
    g = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v = map(int, input().split())
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for _ in range(q):
        p, x = map(int, input().split())
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]
    c(1, 0, vis, k, f, g)
    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def c(i, p, f, g, k, vis):
    if vis[i]:
        return
    vis[i] = True
    w = f[i] + p
    k[i] = w
    ch = g[i]
    for x in ch:
        c(x, w, f, g, k, vis)


def main():
    import sys
    sys.setrecursionlimit(300000)
    n, q, *abpx = map(int, sys.stdin.read().split())

    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    c(1, 0, f, g, k, vis)
    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()
import math
x1, y1, x2, y2 = [int(x) for x in input().split(" ")]

print( math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2))

### FIXED CODE ###

import math
x1, y1, x2, y2 = map(float, input().split())

d = math.sqrt(((x2 - x1) ** 2 + (y2 - y1) ** 2))
print(d)
n = int(raw_input())
a = int(raw_input())
b = int(raw_input())
if n == 1:
	print 'Hello World'
elif n == 2:
	print a + b

### FIXED CODE ###

n = int(raw_input())
if n == 1: print 'Hello World'
elif n == 2: print int(raw_input())+int(raw_input())
x, n = map(int, input().split())
p = list(map(int, input().split()))

def main():
    if n == 0:
        print(x)
        return

    ans_l = list(range(1, 100))

    diff_l = list(set(p) ^ set(ans_l))
    diff_l.sort()

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

main()

### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))

def main():
    if n == 0:
        print(x)
        return

    ans_l = list(range(-100, 201))

    diff_l = list(set(p) ^ set(ans_l))
    diff_l.sort()

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

main()
# -*- coding: utf-8 -*-
a = int(input())
c = [int(input()) for i in range(a)]

#最大値のindexを探し、最大値が複数あるか確認
all_max = max(c)
first_max_id = c.index(all_max)

c_dash = sorted(c,reversed=True)
second_max_value = c_dash[1]
for i,v in enumerate(c):
    if i != first_max_id:
        pr_val = all_max
    else:
        if all_max == second_max_value:
            pr_val = all_max
        else:
            pr_val = second_max_value
    print(pr_val)

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = int(input())
c = [int(input()) for i in range(a)]

#最大値のindexを探し、最大値が複数あるか確認
all_max = max(c)
first_max_id = c.index(all_max)

c_dash = sorted(c,reverse=True)
second_max_value = c_dash[1]
for i,v in enumerate(c):
    if i != first_max_id:
        pr_val = all_max
    else:
        if all_max == second_max_value:
            pr_val = all_max
        else:
            pr_val = second_max_value
    print(pr_val)
n, k = [int(i) for i in input().split()]

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0: tmp -= 1
    n = tmp
    
while tmp >= n:
    tmp = n
    n = abs(n - k)
    if tmp < n:
        break
print(tmp)

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))
def coloring2(color,p):
    global K
    dcolor = 1
    for c in Data[p]:
        if dcolor == color:
            dcolor += 1
        s = str(p)+'_'+str(c)
        Edge[s] = dcolor 
        coloring2(dcolor,c)
        dcolor += 1
    K = max(K,dcolor-1)

N = int(input())
Data = [ [] for _ in range(N+1) ]
Edge = {} 
Edge2 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    Data[a].append(b)
    s = str(a)+'_'+str(b)
    Edge[s] = 0
    Edge2.append([a,b])
print(Data)

K = 0
coloring2(0,Edge2[0][0])
print(K)
for [a,b] in Edge2:
    s = str(a)+'_'+str(b)
    print(Edge[s])

### FIXED CODE ###

import sys
def coloring2(color,p):
    global K
    dcolor = 1
    for c in Data[p]:
        if dcolor == color:
            dcolor += 1
        s = str(p)+'_'+str(c)
        Edge[s] = dcolor 
        coloring2(dcolor,c)
        dcolor += 1
    K = max(K,dcolor-1)

sys.setrecursionlimit(10 ** 9)
N = int(input())
Data = [ [] for _ in range(N+1) ]
Edge = {} 
Edge2 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    Data[a].append(b)
    s = str(a)+'_'+str(b)
    Edge[s] = 0
    Edge2.append([a,b])

K = 0
coloring2(0,1)
print(K)
for [a,b] in Edge2:
    s = str(a)+'_'+str(b)
    print(Edge[s])
nums = []
val = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			val.remove(max(val))
		for s in ans:
			print s
		break

### FIXED CODE ###

nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s
		break