Harryxun/stf_run huggingface dataset:
n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[]
  y=[]
  for j in range(a):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(1):
  l=[1]*n
  for j in range(i,n-i):
    #if l[j]==0:continue
    #for k in range(A[j]):
      #b=X[j][k]
      #l[b] *= Y[j][k]

if c < l.count(1):
  c=l.count(1) 
  
        
  
print(c)  
   

### FIXED CODE ###

n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[0]*a
  y=[0]*a
  for j in range(a):
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
s=0
for i in range(2**n):
  c=0
  d=0
  B=[0]*n
  for j in range(n):
    if((i >> j) & 1):
      c=c+1
      B[j]=1
  for k in range(n):
    if B[k]==1:
      for j in range(A[k]):
        if Y[k][j]!=B[X[k][j]-1]:
          d=-1
          break
    if d<0:
      break
  if s<c and d==0:
    s=c
      
      
print(s)
N, M = map(int, input().split())
l = list(map(int, input().split()))  

S = sum(l)

lr = [i for i in l if i >= S/4M]

if len(lr) >= M:
  	print("Yes")
else:
  	print("No")

### FIXED CODE ###

N, M = map(int, input().split())
l = list(map(int, input().split()))  
 
S = sum(l)
X = 4*M
 
lr = [i for i in l if i >= S/X]
 
if len(lr) >= M:
  	print("Yes")
else:
  	print("No")
if S = 'ABC':
  return 'ARC'
else:
  return 'ABC'

### FIXED CODE ###

S = str(input())
if S == 'ABC':
  print('ARC')
else:
  print('ABC')
import sys
import numpy as np

N, M = [int(_) for _ in input().split()]
S, C = np.array([[int(_) for _ in input().split()] for i in range(M)]).T

ans = [-1] * N

for i in range(M):
    j = int(S[i]) - 1
    if ans[j] == -1 or ans[j] == C[i]:
        ans[j] = C[i]
    else:
        print("-1")
        sys.exit()

if ans[0] == -1:
    ans[0] = 1

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

s = "".join(map(str, ans))

if int(s) == 0:
    print("-1")
else:
    print(s)


### FIXED CODE ###

import sys
import numpy as np

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

if M == 0:
    if N == 1:
        print("0")
    else:
        ans = [0] * N
        ans[0] = 1
        print("".join(map(str, ans)))
    sys.exit()

S, C = np.array([[int(_) for _ in input().split()] for i in range(M)]).T

ans = [-1] * N

for i in range(M):
    j = int(S[i]) - 1
    if ans[j] == -1 or ans[j] == C[i]:
        ans[j] = C[i]
    else:
        print("-1")
        sys.exit()

if N >= 2 and ans[0] == 0:
    print("-1")
    sys.exit()

if N >= 2 and ans[0] == -1:
    ans[0] = 1

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

s = "".join(map(str, ans))
print(s)
w,h,x,y=map(int,input().split())
print(w*h/2,int(w/x==h/y==2))

### FIXED CODE ###

w,h,x,y=map(int,input().split())
if (x,y)==(w/2,h/2):
  frag=1
else:frag=0
print(w*h/2,frag)
a,b=map(int,input().split())
print(6-a-b)

### FIXED CODE ###

a=int(input())
b=int(input())
c=6-a-b
print(c)
def base10to(n, b):
　  if (int(n/b)):
　　    return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
N, K=map(int, input().split())
x = base10to(N,K)
print(len(x))

### FIXED CODE ###

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    else: 
        return str(n%b)
N, K=map(int, input().split())
x = base10to(N,K)
print(len(x))
n=int(ibput())

r=0

for i in range(1,n+1)
	if len(str(i))%2==1:
    	r+=1
print(r)

### FIXED CODE ###

n=int(input())
 
r=0
 
for i in range(1,n+1):
	if len(str(i))%2==1:
		r+=1
print(r)
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
count = 1
for i in L
  D += i
  if X < D:
    break
  count += 1
print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
count = 1
for i in L:
  D += i
  if X < D:
    break
  count += 1
print(count)
import numpy as np
MOD = 10**9+7
N, M = map(int, input().split())
s = np.array(input().split(), dtype=np.int32)
t = np.array(input().split(), dtype=np.int32)

dp = np.zeros((N+1,M+1), dtype=np.int64)
dp[0] = 1

for i in range(N):
  same = (s[i]==t)
  dp[i+1,1:][same] = dp[i,:-1][same]
  dp[i+1] = (dp[i+1].cumsum()+dp[i])%MOD

print(dp[-1,-1])

### FIXED CODE ###

N, M = map(int, input().split())
s = [int(c) for c in input().split()]
t = [int(c) for c in input().split()]
MOD = 10**9+7

dp = [[0]*(M+1) for i in range(N+1)]
dp_cum = [[0]*(M+1) for i in range(N+1)]

dp[0][0] = 1
for i in range(N+1):
  dp_cum[i][0] = 1
for j in range(M+1):
  dp_cum[0][j] = 1
  
for i in range(N):
  for j in range(M):
    if s[i]!=t[j]:
      dp[i+1][j+1] = 0
    else:
      dp[i+1][j+1] = dp_cum[i][j]
    dp_cum[i+1][j+1] = dp_cum[i][j+1] + dp_cum[i+1][j] - dp_cum[i][j] + dp[i+1][j+1]
    dp_cum[i+1][j+1] %= MOD

print(dp_cum[-1][-1])
m,k=map(int,input().split())

if k==0:
    x=[[i]*2 for i in range(2**m)]
    for i in x:
        print(*i,end=" ")
elif m==1:
    print(-1)
elif 2**m<=k:
    print(-1)
else:
    s=set()
    for i in range(m):
        s.add(i)
    a=sorted(s-set(k))
    b=a+[k]+a[::-1]+[k]
    print(*b)

### FIXED CODE ###

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

if k==0:
    x=[[i]*2 for i in range(2**m)]
    for i in x:
        print(*i,end=" ")
elif m==1:
    print(-1)
elif 2**m<=k:
    print(-1)
else:
    for i in reversed(range(2**m)):
        if i!=k:
            print(i,end=" ")
    print(k,end=" ")
    for i in range(2**m):
        if i!=k:
            print(i,end=" ")
    print(k)
N = int(input())
base = ""
d = 0
while N != 0:
    if N%2 == 0:
        base += "0"
        N = N//2
    else:
        base += "1"
        if d%2 == 0:
            N = (N-1)//2
        else:
            N = (N+1)//2
    d += 1
print(int(base[::-1]))

### FIXED CODE ###

N = int(input())
base = ""
d = 0
if N == 0:
    print(0)
else:
    while N != 0:
        if N%2 == 0:
            base += "0"
            N = N//2
        else:
            base += "1"
            if d%2 == 0:
                N = (N-1)//2
            else:
                N = (N+1)//2
        d += 1
    print(int(base[::-1]))
from math import gcd

N, A, B, K = map(int, input().split())
if K == 0:
    print(1)
    exit()
c = gcd(A, B)
if K % c != 0:
    print(0)
    exit()
A //= c; B //= c; K //= c
mod = 998244353

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod


ans = 0
for x in range(N+1):
    if (K - A * x) % B != 0:
        continue
    y = (K - A * x) // B
    tmp = 0
    for g in range(max(0, x + y - N), min(x, y, N)+1):
        r = x - g
        b = y - g
        if r < 0 or b < 0:
            break
        tmp = (tmp + fact_inv[r] * fact_inv[b] * fact_inv[g] * fact_inv[N - r - g - b]) % mod
    ans = (ans + tmp) % mod
ans = ans * fact[N] % mod
print(ans)

### FIXED CODE ###

from fractions import gcd

N, A, B, K = map(int, input().split())
if K == 0:
    print(1)
    exit()
c = gcd(A, B)
if K % c != 0:
    print(0)
    exit()
A //= c; B //= c; K //= c
mod = 998244353

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

ans = 0
for x in range(N+1):
    y, r = divmod(K - A * x, B)
    if r != 0:
        continue
    if 0 <= y <= N:
        ans = (ans + comb(N, x) * comb(N, y)) % mod
print(ans)
import sys
sys.setrecursionlimit(5000)
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
 
def search(s,k, lis_p, lis_c, lis):
    if len(lis) >= k:
        return lis
    s = lis_p[s - 1]
    lis.append(lis_c[s - 1])
    return search(s, k, lis_p, lis_c, lis)
 
ans = -10**10
for i in range(n):
    l = search(i+1, k, p, c, [])
    d = max([sum(l[:j+1]) for j in range(len(l))])
    if d> ans:
        ans = d
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
    P[i] -= 1
C = list(map(int, input().split()))
 
ans = -(10 ** 18)
 
for si in range(N):
    x = si
    loop = []
    total = 0
    while 1:
        x = P[x]
        loop.append(C[x])
        total += C[x]
        if x == si:
            break
    T = len(loop)  # 周期の大きさ
    tmp = 0
    for i in range(T):
        tmp += loop[i]
        if K < i + 1:
            break
        now = tmp
        if total > 0:  # loopの和が正ならloopを回した方がお得
            loop_times = (K - (i + 1)) // T  # 何周できるか
            now += total * loop_times
        ans = max(ans, now)
 
print(ans)
from functools import reduce; from operator import add; print((lambda T, L: T + reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)))(int(input().split()[1]), list(map(int, input().split()))))


### FIXED CODE ###

from functools import reduce; from operator import add; print((lambda T, L: (reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)) + T) if len(L) > 1 else T)(int(input().split()[1]), list(map(int, input().split()))))
def get_min_p(offset, length, k, arr):
  if k == 2:
    min_diff = 100
    p = 0
    for i in range(1, length):
      a = sum(arr[offset:offset + i])
      b = sum(arr[offset + i:])
      if abs(a - b) < min_diff:
        min_diff = abs(a - b)
        p = max(a, b)
      #print("arr:{}, i:{}, p:{}".format(
      #  arr[offset:offset + length], i, p))
    return p
  else:
    p = [100] * (len(arr) - k + 2)
    for i in range(1, len(arr) - k + 2):
      #print("p:{}, i:{}".format(p, i))
      a = get_min_p(offset + i, length - i, k - 1, arr)
      b = sum(arr[:offset + i])
      p[i] = max(a, b)
    return min(p)

n, k = map(int, input().split())
a = [int(input()) for i in range(n)]

print(get_min_p(0, n, k, a))

### FIXED CODE ###

def check(p, k, arr):
  subtotal = 0
  num_of_tracks = 1
  for a in arr:
    subtotal += a
    if subtotal > p:
      num_of_tracks += 1
      if num_of_tracks > k: return False
      subtotal = a
  return True

n, k = map(int, input().split())
arr = [int(input()) for i in range(n)]

min_p = max(arr)
max_p = sum(arr)
while min_p < max_p:
  mid_p = (min_p + max_p) // 2
  if check(mid_p, k, arr):
    max_p = mid_p
  else:
    min_p = mid_p + 1

print(min_p)
hp, _ = map(int, input().split(" "))
s = sum(map(int, input().split(" ")))
print((hp - s) <= 0)


### FIXED CODE ###

H, A = map(int, input().split(" "))
print(H//A + (1 if H%A != 0 else 0))
from operator import itemgetter
import bisect


h, w, n = map(int, input().split())
info = [tuple(map(int, input().split())) for i in range(n)]

memo = set()
for i, j in info:
    memo.add(i*10**6 + j)

pos = [[] for _ in range(w + 1)]
info = sorted(info, key = itemgetter(1))
for i, j in info:
    pos[j].append(i)

ans = 10**9
pos_i, pos_j = 1, 1
while True:
    if (pos_i + 1)*10**6 + pos_j in memo:
        break
    if pos_i == h:
        ans = min(ans, h)
        break
    pos_i += 1

    if pos_i*10**6 + pos_j + 1 in memo:
        continue
    else:
        pos_j += 1
    ind = bisect.bisect_right(pos[pos_j], pos_i)
    try:
        ans = min(pos[pos_j][ind] - 1, ans)
    except:
        pass
print(ans)

### FIXED CODE ###

from operator import itemgetter
import bisect


h, w, n = map(int, input().split())
info = [tuple(map(int, input().split())) for i in range(n)]

memo = set()
for i, j in info:
    memo.add(i * 10**6 + j)

pos = [[] for _ in range(w + 1)]
info = sorted(info, key = itemgetter(0))
for i, j in info:
    pos[j].append(i)

ans = 10**18
pos_i, pos_j = 1, 1
ind = bisect.bisect_right(pos[pos_j], pos_i)
try:
    ans = min(pos[pos_j][ind] - 1, ans)
except:
    pass

while True:
    if (pos_i + 1) * 10**6 + pos_j in memo or pos_i == h:
        ans = min(ans, pos_i)
        break
    pos_i += 1

    if pos_i * 10**6 + (pos_j + 1) in memo or pos_j == w:
        continue
    else:
        pos_j += 1
    ind = bisect.bisect_right(pos[pos_j], pos_i)
    try:
        ans = min(pos[pos_j][ind] - 1, ans)
    except:
        pass
print(ans)
import collections
 
def main():
    n = input()
    a = map(int, raw_input().split())
    odd = [a[2 * i] for i in range(n/2)]
    even = [a[2*i + 1] for i in range(n/2)]
    codd = collections.Counter(odd)
    ceven = collections.Counter(even)
    coddmostitem = codd.most_common()[0][0]
    coddmosttimes = codd.most_common()[0][1]
    cevenmostitem = ceven.most_common()[0][0]
    cevenmosttimes = ceven.most_common()[0][1]
    if coddmostitem == cevenmostitem:
        if coddmosttimes >= cevenmosttimes:
            if len(ceven) == 1:
                cevennoreplace = 0
            else:
                cevennoreplace = ceven.most_common()[1][1]
            coddnoreplace = codd.most_common()[0][1]
        if coddmosttimes < cevenmosttimes:
            if len(codd) == 1:
                coddnoreplace = 0
            else:
                coddnoreplace = codd.most_common()[1][1]
            cevennoreplace = ceven.most_common()[0][1]
    else:
        coddnoreplace = codd.most_common()[0][1]
        cevennoreplace = ceven.most_common()[0][1]
    coddreplace = n/2 - coddnoreplace
    cevenreplace = n/2 - cevennoreplace
    print(coddreplace+cevenreplace)
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    string = raw_input()
    A = string[0]
    B = string[1]
    C = string[2]
    if A == '1':
        A = '9'
    else:
        A = '1'
    if B == '1':
        B = '9'
    else:
        B = '1'
    if C == '1':
        C = '9'
    else:
        C = '1'        
    print(A+B+C)



if __name__ == '__main__':
    main()
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "S = input()\n",
    "if S ==\"AAA\" or S ==\"BBB\":\n",
    "    print(\"No\")\n",
    "else:\n",
    "    print(\"Yes\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}


### FIXED CODE ###

S = input()
if S =="AAA" or S =="BBB":
    print("No")
else:
    print("Yes")
import math

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()

s = reversed(input())

ai = 0
si = [0]*len(s)

p = 2019

for i, j in enumerate(s):
	ai = (int(j)*pow(10,i,p))%p
	si[i] = (si[i-1]+ai)%p
countarr = [0]*2019
for i in si:
	countarr[i]+=1

res = countarr[0]
for i in range(p):
	c = countarr[i]
	res += c*(c-1)//2

print(res)

### FIXED CODE ###

import math

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()

s = reversed(input())

ai = 0
si = 0

p = 2019
countarr = [0]*2019

for i, j in enumerate(s):
	ai = (int(j)*pow(10,i,p))%p
	si = (si+ai)%p
	countarr[si]+=1

res = countarr[0]
for i in range(p):
	c = countarr[i]
	res += c*(c-1)//2

print(res)
s = input()
n = len(s)

dp = [[0 for i in range(n)] for j in range(13)]

if s[0] == '?':
    for i in range(10):
        dp[i][0] = 1
else:
    dp[s][0] = 1

mod_change_table = [(i * 10)%13 for i in range(13)]

for x in range(1, len(s)):
    for y in range(13):
        if s[x] == '?':
            for j in range(10):
                dp[(mod_change_table[y]+j)%13][x] += dp[y][x-1]
        else:
            dp[(mod_change_table[y]+int(s[x]))%13][x] += dp[y][x-1]
            
print(dp[5][n-1])

### FIXED CODE ###

M=10**9+7
r=[[(j-k)*9%13for j in range(10)]for k in range(13)]
d=[1]+[0]*12
for c in input():
  d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])
# -*- coding: utf-8 -*-
import math
from functools import reduce


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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)

max_gcd = 0

for i in range(len(As)):
    others = [As[j] for j in range(len(As)) if j != i]
    max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import fractions

N = int(input().rstrip())
A = [0] + list(map(int, input().rstrip().split())) + [0]

L = [0] * (N + 2)
R = [0] * (N + 2)

for i in range(0, N):
    L[i + 1] = fractions.gcd(L[i], A[i + 1])

for i in range(N, 0, -1):
    R[i] = fractions.gcd(R[i + 1], A[i])

print(max(fractions.gcd(L[i], R[i + 2]) for i in range(0, N)))
N,K,Q = map(int,input().split())
K=K-Q

a=[]
for i in range(Q):
  a.append(int(input()))
cnt=[K-Q]*N
for i in range(1,N+1):
  a.count(i) += cnt[i-1]
  if cnt[i] > 0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

# coding: utf-8
# Your code here!

N, K, Q = map(int,input().split())
L = [0]*N
for i in range(Q):
    a = int(input())
    L[a-1] += 1

for i in range(N):
    if Q - L[i] < K:
        print('Yes')
    else:
        print('No')
x = int(input)

if x%2 == 0:
  print(x)
else:
  print(x*2)

### FIXED CODE ###

x = int(input())
 
if x%2 == 0:
  print(x)
else:
  print(x*2)
S=raw_input()
h=S/3600
r=S%3600/60
s=S%3600%60
print h:r:s

### FIXED CODE ###

S=input()
h=S/3600
r=S%3600/60
s=S-h*3600-r*60
print str(h)+':'+str(r)+':'+str(s)
N, M = list(map(int,input().split()))

def divisor(n):
    if n == 1:
        return 1
    
    ans = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans.append(i)
            if n % n//i == 0:
                ans.append(n//i)

    ans.sort()
    return ans

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)


### FIXED CODE ###

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

def divisor(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if n % n//i == 0:
                res.append(n//i)

    res.sort()
    return res

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)
import sys
input = sys.stdin.readline
import math
import copy
N, K = map(int, input().split())

mod = 10**9+7

Keys = set()
for n in range(1, int(math.sqrt(N))+2):
    Keys.add(n)
    Keys.add(N//n)

L = sorted(list(Keys))
Counts = {1: 1}
for i in range(len(L)-1):
    Counts[L[i+1]] = L[i+1]-L[i]

dp = copy.copy(Counts)
for _ in range(K-1):
    sdp = {}
    c = 0
    for l in L:
        c = (c + dp[l]) % mod
        sdp[l] = c

    for l in L:
        r = N//l
        dp[l] = sdp[r] * Counts[l] % mod

ans = 0
for v in dp.values():
    ans = (ans + v) % mod
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
mod = 10**9+7

n = 1
A = []
while True:
    A.append(N//n)
    if N//(n+1) < n+1: break
    n += 1
A.append(n)

L = 2*n
dp = [[0]*L for _ in range(K)]
for l in range(n):
    dp[0][l] = 1

i = 0
for l in reversed(range(n, L)):
    dp[0][l] = A[i] - A[i+1]
    i += 1

for k in range(1, K):
    s = 0
    for l in reversed(range(L)):
        s = (s+dp[k-1][L-l-1]) % mod
        dp[k][l] = s * dp[0][l] % mod

ans = 0
for l in range(L):
    ans = (ans + dp[K-1][l]) % mod

print(ans)
n = int(input())
strs = [int(x) for x in str(n)]
kijyun = [9]*(len(strs)-1)
if strs[1:] == kijyun:
    print((n-1)*9+strs[1])
else:
    print((n-1)*9+strs[1]-1)

### FIXED CODE ###

n = int(input())
strs = [int(x) for x in str(n)]
kijyun = [9]*(len(strs)-1)
if strs[1:] == kijyun:
    print((len(strs)-1)*9+strs[0])
else:
    print((len(strs)-1)*9+strs[0]-1)
atcoderbeginnercontest
atcoderregularcontest

### FIXED CODE ###

from itertools import zip_longest

O = input()
E = input()

for o, e in zip_longest(O, E, fillvalue=""):
    print(o + e, end="")
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = []
if n == 0:
  print(x)
else:
  for i in range(n-2):
    if x-i not in p:
      ans.append(-i)
      break
    elif x+i not in p:
      ans.append(i)
      break
  print(x+min(ans))

### FIXED CODE ###

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

if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  for j in range(0, int(n/2)+ 2):
    #print(j)
    if x-j not in p:
      print(x-j)
      break
    else:
      if x+j not in p:
        print(x+j)
        break
# sys.stdin.readline()
import sys
import math
input = sys.stdin.readline

bcd = input()
efg = input()
if b == g and c == f and d == e:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

### FIXED CODE ###

# sys.stdin.readline()
import sys
import math
input = sys.stdin.readline

a = input()
b = input()
if (a[0] in b[2]) and (a[1] in b[1]) and (a[2] in b[0]):
    ans = 'YES'
else:
    ans = 'NO'
print(ans)
a,b=map(int,input.split())
print(max(2a-1,2b-1,a+b))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(2*a-1,2*b-1,a+b))
n = input()
N = int(n)

a = int((n[-3:]))

y = 0
if a >= 753:
    x = 6
elif a >= 735:
    x = 5
elif a >= 573:
    x = 4
elif a >= 537:
    x = 3
elif a >= 375:
    x = 2
elif a >= 357:
    x = 1
elif a < 356:
    x =0

for i in range(0, len(n)-3):
    if int(n[i]) == 0:
        y = y
    elif int(n[i]) >=7:
        y += (len(n) - i) * 3 - 9
    elif int(n[i]) >=5:
        y += (len(n) - i) * 3 - 10
    elif int(n[i]) >= 3:
        y += (len(n) - i) * 3 - 11
    elif int(n[i]) == 2 or 1:
        y += (len(n) - i) * 3 - 12

print(x + y)


### FIXED CODE ###

def listup(number, n):

    if number > 10 ** 9:
        return
    else:
        number = 10 * number + n
        if "7" in str(number):
            if "5" in str(number):
                if "3" in str(number):
                    list753.append(number)
        listup(number, 3)
        listup(number, 5)
        listup(number, 7)

list753 = []
ans = 0
N = int(input())
listup(0, 0)
for i in range(len(list753)):
    if N - list753[i] >= 0:
        ans += 1

print(ans)
n=int(input())
l=list(map(int,input().split()))
l.sort()
print(l[1]-l[0]+l[2]-l[1])

### FIXED CODE ###


l=list(map(int,input().split()))
l.sort()
print(l[1]-l[0]+l[2]-l[1])
N, K = map(int, input().split())

A = [i for i in map(int, input().split())]
# print(N, K)
# print(A)
loop = [0]  # startは0→町1
now = 0  # now+1が町
for i in range(N)
  now = A[now] - 1
   if now in loop:
        loop.append(now)

        break
    else:
        loop.append(now)

befo = loop.index(now)+1
new_loop = loop[(befo):]

# print([i+1 for i in loop])
print(new_loop[(K-befo) % (len(new_loop))]+1)


### FIXED CODE ###

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

A = [i-1 for i in map(int, input().split())]

used = [False] * N
loop = [0]  # startは0→町1
now = 0  # now+1が町
while not used[A[now]]:
    used[A[now]] = True
    loop.append(A[now])
    now = A[now]

ind = loop.index(A[now])
# new_loop = loop[(befo):]
if K < ind:
    print(loop[K]+1)
else:
    K -= ind
    K %= len(loop)-ind

    print(loop[ind+K]+1)

# print([i+1 for i in loop])
# print(new_loop[(K-befo) % (len(new_loop))]+1)
n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    a = (y2-y1)/(x2-x1)
    c = (y4-y3)/(x4-x3)
    if a == c:
        print "YES"
    else:
        print "NO"

### FIXED CODE ###

n = int(raw_input())

for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3)) < 1e-10:
        print "YES"
    else:
        print "NO"
[print(I) for I in sorted([int(input()) for i in range(10)])[2::-1]]

### FIXED CODE ###

a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[:3]
print(a[0])
print(a[1])
print(a[2])