Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
ab = [tuple(map(int,input().split())) for i in range(m)]
es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append(b)

dp = [-1]*n

def rec(start):
    if dp[start] != -1:
        return dp[start]
    ans = 0
    for next_node in es[start]:
        ans = max(ans, rec(next_node)+1 )
    dp[start] = ans

    return dp[start]

ans = 0
for i in range(n):
    ans = max(ans, rec(i))

print(ans)


### FIXED CODE ###

import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
N, M = [int(_) for _ in input().split()]

# 隣接関係は隣接リストで管理する
lst_edge = [[] for _ in range(N)]

for _ in range(M):
  x, y = map(int, input().split()) 
  # 最初のindexをゼロにする
  lst_edge[x-1].append(y-1)
        
# dp[v] := ノードvを始点とした時の有向パスの長さの最大値
# -1 未訪問で初期化。
dp = [-1] * N

# メモ化再帰
def rec(v):
  # 既に更新済み
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v]
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1)
  dp[v] = ans
  return dp[v]
    
# 全ての点に対して更新する
ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)
w,h,x,y,r=map(int,input().split())

a=x-r
ap=x+r

b=y-r
bp=y+r
if a<0 or ap>w or b<0 or bp>h :
	print(“Yes”)
else :
	print(“No”)


### FIXED CODE ###

w,h,x,y,r=map(int,input().split())

a=x-r
ap=x+r

b=y-r
bp=y+r
if a<0 or ap>w or b<0 or bp>h:
	print('No')
else:
	print('Yes')
N = int(input())

list = [int(c)+10*int(c)+100*int(c) for c in str(N)]
list.sort()

x = 0
for i in range(N):
    if list[i] < N:
        continue
    else:
        x = list[i]
print(x)

### FIXED CODE ###

N = str(input())

list = [111*int(c) for c in '123456789']
list.sort()

x = 0
for number in list:
    if number < int(N):
        continue
    else:
        x = number
        break
print(x)
def NotsoDiverse(n , k , al):

    lis = [0]*n

    for i in range(n):
        lis[al[i]] += 1

    lis.sort(reverse=True)

    ans = sum(lis[k:])
    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(NotsoDiverse(n , k , al))

if __name__ == '__main__':
    main()


### FIXED CODE ###

def NotsoDiverse(n , k , al):

    lis = [0]*(n + 1)

    for i in range(n):
        lis[al[i]] += 1

    lis.sort(reverse=True)

    ans = sum(lis[k:])
    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(NotsoDiverse(n , k , al))

if __name__ == '__main__':
    main()
N = int(input())
L_i2 = 2
L_i1 = 1
for n in range(N-1):
  L_i = L_i1 + L_i2
  L_i2 = L_i1
  L_i1 = L_i
print(L_i)

### FIXED CODE ###

N = int(input())
L_i2 = 2
L_i1 = 1
if N == 0:
  L_i = L_i2
elif N == 1:
  L_i = L_i1
else:
  for n in range(N-1):
    L_i = L_i1 + L_i2
    L_i2 = L_i1
    L_i1 = L_i
print(L_i)
import sys
from io import StringIO
import unittest

a = input().rstrip().split(" ")

H = int(a[0])  # 行
W = int(a[1])  # 列
K = int(a[2])  # 操作後に残る黒いマスの数

m = []
for i in range(H):
    n = list(input())
    m.append(n)

# print(m)
ans = 0

for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskL >> j & 1) == 0 and m[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 3 2
..#
###"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3 4
..#
###"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2 2 3
##
##"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6 6 8
..##..
.#..#.
#....#
######
#....#
#....#"""
        output = """208"""
        self.assertIO(input, output)


if __name__ == "__main__":
    unittest.main()


### FIXED CODE ###

a = input().rstrip().split(" ")
 
H = int(a[0])   #行
W = int(a[1])   #列
K = int(a[2])   #操作後に残る黒いマスの数
 
m = []
for i in range(H):
    n = list(input())
    m.append(n)
 
#print(m)
ans = 0
 
#2進数のyes/no(赤く塗るか否か)列を作る
for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskC >> j & 1) == 0 and m[i][j] == "#":
                    black += 1
    
        if black == K:
            ans += 1
 
print(ans)
L,R = map(int,input().split())
ans = 100000000
for i in range(L,R + 1):
    for j in range(i + 1,R + 1):
        if i*j % 2019 < ans:
            ans = i*j % 2019
            if ans == 0:
                print(ans)
                sys.exit
print(ans)

### FIXED CODE ###

L,R = map(int,input().split())
ans = 100000000
for i in range(L,R + 1):
    if ans == 0:
        break
    for j in range(i + 1,R + 1):
        if i*j % 2019 < ans:
            ans = i*j % 2019
            if ans == 0:
                break
print(ans)
temp=input().split()
A=int(temp[0])
B=int(temp[1])
C=int(temp[2])
D=int(temp[3])

for i in range(A, B+1):
  if i%C==0 and i%D==0:
    counter+=1
    
print(counter)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

temp=input().split()
A=int(temp[0])
B=int(temp[1])
C=int(temp[2])
D=int(temp[3])

x=B//C-(A-1)//C
y=B//D-(A-1)//D
s=lcm(C, D)
z=B//s-(A-1)//s

print(int(B-A+1-x-y+z))
N, M = map(int, input().split())
X = [-1] * N#[-1,-1,-1.....]
for i in range(M):
    s, c = map(str, input().split())
    if s == 1 and N > 1 and c==0:
        print(-1)
        exit()#プログラム終了 １桁目が0で２桁以上あるため-1
    if X[s-1] < 0:#もしリストにまだ数字が入っていなかったらCを代入
        X[s-1] = c
    
    #もしすでにリストに数字が入っている場合は-1を出力する
    elif X[s-1] != c:
        print(-1)
        exit()
#このfor文でリストが完成する

if X[0] < 0 :#もし1桁目の数字が指定されていないなら
    X[0] = 1 if N>1 else 0#もし2桁以上ならならX[0]=1、違うならX[0]=0 
print("".join([str(x) if x >= 0 else "0" for x in X]))
#リストを文字列に変換する。もし指定されていない桁の数字があるなら0を代入する

### FIXED CODE ###

N, M = map(int, input().split())
X = [-1] * N#[-1,-1,-1.....]
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and N > 1 and c==0:
        print(-1)
        exit()#プログラム終了 １桁目が0で２桁以上あるため-1

#もしリストにまだ数字が入っていなかったらCを代入
    if X[s-1] < 0:
        X[s-1] = c
    
#もしすでにリストに数字が入っている場合は-1を出力する
    elif X[s-1] != c:
        print(-1)
        exit()
#このfor文でリストが完成する

if X[0] < 0 :#もし1桁目の数字が指定されていないなら
    X[0] = 1 if N>1 else 0#もし2桁以上ならならX[0]=1、違うならX[0]=0 
print("".join([str(x) if x >= 0 else "0" for x in X]))
#リストを文字列に変換する。もし指定されていない桁の数字があるなら0を代入する
N = int(input())
list = list(map(int,input().split()))

ans = 0
for i in range(N-2):
  if list[i+1] > List[i] and list[i-1] < List[i]:
    ans+=1
  if list[i+1] < List[i] and list[i-1] > List[i]:
     ans+=1

print(ans)

### FIXED CODE ###

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

ans=0

for i in range(N-2):
  if L[i] < L[i+1] and  L[i+1] < L[i+2]:
    ans +=1 
  if L[i] > L[i+1] and  L[i+1] > L[i+2]:
    ans +=1 
  else:
    pass

print(ans)
s = int(input()) 
 
if 400 < s < 500:
  print("8")
elif  600 < s <799:
  print("7")
elif  800 < s <999:
  print("6")
elif  1000 < s <1199:
  print("5")
elif  1200 < s <1399:
  print("4")
elif  1400 < s <1599:
  print("3")
elif  1600 < s <1799:
  print("2")
else  1800 < s <1999:
  print("1")

### FIXED CODE ###

s = int(input()) 
 
if 400 <= s <= 599:
  print("8")
elif  600 <= s <=799:
        print("7")
elif  800 <= s <=999:
        print("6")
elif  1000 <= s <=1199:
        print("5")
elif  1200 <= s <=1399:
        print("4")
elif  1400 <= s <=1599:
        print("3")
elif  1600 <= s <=1799:
        print("2")
elif  1800 <= s <=1999:
        print("1")
n=int(input())
t=[int(input()) for i in range(n) ]
import math
from functools import reduce
def lcm_sorce(x,y):
    return (x*y)//math.gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))

### FIXED CODE ###

from fractions import gcd
from functools import reduce
n=int(input())
t=[int(input()) for i in range(n) ]
def lcm_sorce(x,y):
    return (x*y)//gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

print(comb(n, 2) + comb(m, 2))

### FIXED CODE ###

import math
import sys

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if n == 1 and m == 1:
  print('0')
  sys.exit()
  
if n <= 1:
  print(comb(m, 2))
  sys.exit()
  
if m <=1:
  print(comb(n, 2))
  sys.exit()

print(comb(n, 2) + comb(m, 2))
isExist = [False]*2001 
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
for i in A:
	for j in range( 2000-i, 0, -1 ):
		if isExist[j]:
			isExist[ i+j ] = True
	isExist[i] = True
 
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )

### FIXED CODE ###

def solve( p, t ):
	global isExist, n, A
	isExist[ t ] = True
	if p < n:
		solve( p+1, t-A[p] )
		solve( p+1, t )
	else:
		return

isExist = [False]*2001 
n = int( input() )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )
import sys
import os
f = open('../../input.txt', 'r')
sys.stdin = f

n,k = map(int, input().split())
mod = 10**9 + 7

ans = 0
lim = 2*(10**5) + 5
mothers = [1] * lim
mothers_inv = [1] * lim
for i in range(1, lim):
    mothers[i] = mothers[i-1] * i % mod
    mothers_inv[i] = pow(mothers[i], mod-2, mod)


def calc(n,k):
    child = mothers[n] * mothers_inv[n-k] % mod
    mother_inv = mothers_inv[k]
    return((child * mother_inv)%mod)

def calc2(n,k):
    child = 1
    for i in range(n, n-k, -1):
        child = child * i % mod
    mother_inv = mothers_inv[k]
    return((child * mother_inv)%mod)

if( n <= k+1):
    ans = calc2(2*n-1, n-1)
    print(ans)
    exit()

ans = calc2(2*n-1, n-1)

for i in range(1,n-k):
    if(i ==1):
        c1 = 1
    else:
        c1 = calc(n-1, i-1)

    c2 = calc(n, i)
    ans = (ans - c1 * c2)%mod


print(ans)


### FIXED CODE ###

n,k = map(int, input().split())
mod = 10**9 + 7

ans = 0
lim = 2*(10**5) + 5
mothers = [1] * lim
mothers_inv = [1] * lim
for i in range(1, lim):
    mothers[i] = mothers[i-1] * i % mod
    mothers_inv[i] = pow(mothers[i], mod-2, mod)


def calc(n,k):
    child = mothers[n] * mothers_inv[n-k] % mod
    mother_inv = mothers_inv[k]
    return((child * mother_inv)%mod)

def calc2(n,k):
    child = 1
    for i in range(n, n-k, -1):
        child = child * i % mod
    mother_inv = mothers_inv[k]
    return((child * mother_inv)%mod)

if( n <= k+1):
    ans = calc2(2*n-1, n-1)
    print(ans)
    exit()

ans = calc2(2*n-1, n-1)

for i in range(1,n-k):
    if(i ==1):
        c1 = 1
    else:
        c1 = calc(n-1, i-1)

    c2 = calc(n, i)
    ans = (ans - c1 * c2)%mod


print(ans)
import math

A, B, H, M = map(int, input().split())

deg_long = M * 6
deg_short = 30 * H + M / 2

if abs(deg_long - deg_short) > 180:
    rad = math.radians(360 - abs(deg_long - deg_short))
else:
    math.radians(abs(deg_long - deg_short))

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)))

### FIXED CODE ###

import math

A, B, H, M = map(int, input().split())

rad = 0
deg_long = M * 6
deg_short = 30 * H + M / 2

if abs(deg_long - deg_short) > 180:
    rad = math.radians(360 - abs(deg_long - deg_short))
else:
    rad = math.radians(abs(deg_long - deg_short))

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)))
n = int(input())
d = list(map(int, input().split()))

sd = sorted(d)

if n %2 != 0:
  print(0)

else:

  print(sd[n/2] - sd[n/2-1])

### FIXED CODE ###

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

sd = sorted(d)

if n %2 != 0:
  print(0)

else:

  print(sd[int(n/2)] - sd[int(n/2-1)])
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
 
x.sort(reverse=True)
y.sort()


flag=0
for i in range(X+1,Y+1):
  if x[0]<=i and y[0]>i:
    flag=1
    break
  

  else:
    flag=0
    
if flag=1:
  print('No War')
  
else:
  print('War')


### FIXED CODE ###

n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
 
x.sort(reverse=True)
y.sort()
 
 
flag=0
for i in range(X+1,Y+1):
  if x[0]<i and y[0]>=i:
    flag=1
    break
  
 
  else:
    flag=0
    
if flag==1:
  print('No War')
  
else:
  print('War')
S=input()
T=input()
 
a=1
if len(T)==len(S)+1:
    for i in range(len(S)):
        if S[i]==T[i]:
            a=1
            if a==0:
                break
        
        else:
            a=0
            print('No')
            break
else:
    print('No')
S=input()
T=input()

a=1
if len(T)==len(S)+1:
    for i in range(len(S)):
        if S[i]==T[i]:
            a=1
            if a==0:
                break
        
        else:
            a=0
            print('No')
            break
else:
    print('No')
if a==1:
  print('Yes')

### FIXED CODE ###

S=input()
T=input()

a=1
if len(T)==len(S)+1:
    for i in range(len(S)):
        if S[i]==T[i]:
            a=1
            if a==0:
                break
        
        else:
            a=0
            print('No')
            break
else:
    print('No')
if a==1:
    print('Yes')
x = (input())
for ans in x:
    if ans < 1200:
        print("ABC")
    else:
        print("ARC")

### FIXED CODE ###

x = int(input())
if x < 1200:
    print("ABC")
else:
    print("ARC")
n,limit=[int(i) for i in input().split()]
baitolist=[[int(i) for i in input().split()] for j in range(n)]
baitodict={}
for i in range(1,limit+1):
    baitodict[str(i)]=[]
for baito in baitolist:
    if int(day)<=limit:
        day=str(baito[0])
        money=baito[1]
        baitodict[day].append(money)
        baitodict[day].sort()
# print(baitodict)

sumnum=0
for i in range(1,limit+1):
    maxindex=""
    maxmoney=0
    for j in range(1,i+1):
        if baitodict[str(j)]!=[]:
            a=baitodict[str(j)][-1]
            if maxmoney<a:
                maxmoney=a
                maxindex=str(j)
    if maxindex!="":
        baitodict[maxindex].pop()
    sumnum+=maxmoney
#     print(sumnum)
print(sumnum)            

### FIXED CODE ###

class Work:
    count=0
    def __init__(self,payday,money):
        Work.count+=1
        self.count=Work.count
        self.payday=payday
        self.money=money
 #moneyが大きい方、同じなら早くもらえる方、それも同じなら最初に書いてある方が強い方
    def __ft__(self,other):
        if self.money>other.money:
            return True
        if self.money==other.money:
            if self.payday<other.payday:
                return True
            if self.payday==other.payday:
                if self.count<other.count:
                    return True
        return False

    def __gt__(self,other):
        if self.money<other.money:
            return True
        if self.money==other.money:
            if self.payday>other.payday:
                return True
            if self.payday==other.payday:
                if self.count>other.count:
                    return True
        return False

#バイトの数、いつまでに稼ぐのか 
n,limit=[int(i) for i in input().split()]

#バイトのリストを作り、クラスを入れる O(n)
baitolist=[]
for i in range(n):
    payday,money=[int(i) for i in input().split()]
    work=Work(payday,money)
    baitolist.append(work)

#日数でランク付け　O(n)
summoney=0    
rank=[[] for i in range(limit+1)]
for baito in baitolist:
    if baito.payday<=limit:
        rank[baito.payday].append(baito)

        
import heapq
accessible=[]
count=1


for i in range(limit):
    for baito in rank[count]:
        heapq.heappush(accessible,baito)
    if accessible!=[]:
        dowork=heapq.heappop(accessible)
        summoney+=dowork.money
    count+=1
    
    
print(summoney)
n, m = [int(item) for item in input().split()]
count = [0] * n
for i in range(n):
    a, b = [int(item) for item in input().split()]
    count[a-1] += 1
    count[b-1] += 1
for item in count:
    print(item)

### FIXED CODE ###

n, m = [int(item) for item in input().split()]
count = [0] * n
for i in range(m):
    a, b = [int(item) for item in input().split()]
    count[a-1] += 1
    count[b-1] += 1
for item in count:
    print(item)
n = int(input())
a = input()
b = input()

for i in range(n):
  if i == 1:
    if a == b:
      print(n)
      exit()
  if a[i:] == b[:-i]:
    print(n+i)
    exit()
print(n*2)

### FIXED CODE ###

n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
now = t[0]
people = 1
ans = 1
for i in t[1:]:
  if i - now > k or people >= c:
    now = i
    people = 1
    ans += 1
  else:
    people += 1
print(ans)
s = map(int, list(raw_input())) #入力した時にリストでSを配列
print sum(s) #s[0]~s[N]までの合計を出す

### FIXED CODE ###

# -*- coding: utf-8 -*-
s = map(int, list(raw_input())) #入力した時にリストでSを配列
print sum(s) #s[0]~s[N]までの合計を出す
n=int(input())
s=input()
from collections import Counter
l=Counter()
for i,c in enumerate(list(s)):
    if not l[c]:
        l[c]=[]
    l[c].append(i)

for j in l:
    l[j].append(10**18)
q=int(input())
import bisect
for i in range(q):
    a,b,c=input().split()
    if a=="1":
        b=int(b)-1
        idx=bisect.bisect_left(l[s[b]],b)
        del l[s[b]][idx]
        if not l[c]:
            l[c]=[]
        idx=bisect.bisect_left(l[c],b)
        l[c].insert(idx,b)
        l[c].append(10**18)
    else:
        ans=0
        left,right=int(b)-1,int(c)-1
        for j in l:
            p=bisect.bisect_left(l[j],left)
            q=bisect.bisect_left(l[j],right)
            if p!=q:
                ans+=1
            else:
                if l[j]!=[]:
                    if left<=l[j][p]<=right:
                        ans+=1
        print(ans)

### FIXED CODE ###

n=int(input())+1
data=[0]*n*2
def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2
def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:]))
s=input()
for i,c in enumerate(s,n):
    data[i]=1<<(ord(c)-97)
for i in range(n-1,0,-1):
    data[i]=data[2*i]|data[2*i+1]
for _ in range(int(input())):
    q,a,b=input().split()
    if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97))
def main():
    N, M = map(int, input().split())
    a = {int(input()): 1 for _ in range(M)}
    dp = [0] * (N + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1

    for i in range(2, N + 1):
        for k in [-2, -1]:
            if a[i + k]:
                dp[i] = 0
            else:
                dp[i] += dp[i+k]
        dp[i] %= 1000000007

    print(dp[N])

main()


### FIXED CODE ###

N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, N + 1):
    for k in [-2, -1]:
        if i + k not in a:
            dp[i] += dp[i+k]

print(dp[N] % 1000000007)
a = input()
b = input()
count = 0
for i in renge(3)
	if a[i] == b[i]:
    	count += 1
print(count)

### FIXED CODE ###

a = str(input())
b = str(input())
count = 0
for i in range(3):
	if a[i] == b[i]:
		count += 1
        
print(count)
A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   l=[chr(ord('a') + i) for i in range(26)]
   A=A[::-1]
   for i in range(1,26):
      if A[i-1] < A[i]:
         pass
      else:
         if A[i-1] == "z":
            S=l[-1*i:]
            S.sort()
            A=A[::-1]
            print(A[:-1*i-1]+S[0])
            exit()
         else:
            A[i-1],A[i]=A[i],A[i-1]
            print(A[::-1])
            exit()

### FIXED CODE ###

A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   for i in reversed(range(25)):
      for j in reversed(range(i+1,26)):
         if A[i] < A[j]:
            print(A[:i]+A[j])
            exit()
   else:
      print(-1)
# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

for row in range(N):
    row_value = values[row]
    if row_value != max_value:
        max_value = max(value_count_map.keys())
        print(max_value)
    elif value_count_map[row_value] != 1:
        max_value = max(value_count_map.keys())
        print(max_value)
    else:
        # if row value is a unique max value
        value_count = value_count_map.pop(row_value)
        max_value = max(value_count_map.keys())
        print(max_value)
        value_count_map[row_value] = value_count


### FIXED CODE ###

# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

max_value = max(value_count_map.keys())
value_count = value_count_map.pop(max_value)
if value_count == 1:
    next_max_value = max(value_count_map.keys())
for row in range(N):
    if value_count > 1:
        print(max_value)
    elif values[row] == max_value:
        print(next_max_value)
    else:
        print(max_value)
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

### FIXED CODE ###

import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)