Harryxun/stf_run huggingface dataset:
N, K=map(int, input().split())
red=N-K

def cmb(n, r):
  m=1
  if(n==0 or r==0):
      return 1
  if(n<2*r):
      r=n-r
  for i in range(1,r+1):
      m=m*(n-i+1)/i
    
  return m

n = min(N-K+1,K)
for i in range(1,n+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(int(ret%(1e9+7)))

### FIXED CODE ###

from operator import mul
from functools import reduce


def cmb(n, r):
	if n < r:
		return 0
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF


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

for i in range(1, K + 1):
	print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % INF)
return int(input()**2)

### FIXED CODE ###

print(int(input())**2)
while True:
    x,y = map(int,input().split())
    if H==W==0:
        break;
    for i in range(x):
        print("#"*y)
    print()



### FIXED CODE ###

import sys
import os
 
 
for line in sys.stdin:
    H, W = map(int, line.split())
    if H == 0 and W == 0:
        break
    print(('#' * W + '\n') * H)
import math
n, init = map(int, input().split())
x = list(map(lambda a: abs(int(a)-init), input().split()))
g = x[0]
for i in range(n):
    if g == 1:
        break
    elif x[i] % g != 0:
        g = math.gcd(g,x[i])
print(g)


### FIXED CODE ###

n, init = map(int,input().split())
x = list(map(lambda x: abs(int(x)-init), input().split()))
g = x[0]
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)
for i in range(1,n):
    g = gcd(g,x[i])
print(g)
from fractions import Fraction
def sroap(x1,y1,x2,y2):
	if x2 - x1 == 0:
		return float("inf")
	else:
		return Fraction(y2 - y1,x2 - x1)
		
N = int(input())
for n in range(N):
	Ax,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))
	if sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):
        ????????????print("YES")
	else:
		print("NO")

### FIXED CODE ###

from fractions import Fraction

def sroap(x1,y1,x2,y2):
	if x2 - x1 == 0:
		return float("inf")
	else:
		return Fraction(y2 - y1,x2 - x1)
		
N = int(input())
for n in range(N):
	Ax,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))
	if sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):
		print("YES")
	else:
		print("NO")
import sys

readline = sys.stdin.readline

N = int(readline())

XY = [list(map(int, readline().split())) for i in range(N)]

diff_list = {}

for x1, y1 in XY:
    for x2, y2 in XY:
        if x1 == x2 and y1 == y2:
            continue
        diffx = x2 - x1
        diffy = y2 - y1
        diff = (diffx, diffy)
        if not (diff in diff_list): diff_list[diff] = 0
        diff_list[diff] += 1

m = max(diff_list.values())

ans = N - m

print(ans)

### FIXED CODE ###

import sys

readline = sys.stdin.readline

N = int(readline())

XY = [list(map(int, readline().split())) for i in range(N)]

diff_list = {}

for x1, y1 in XY:
    for x2, y2 in XY:
        if x1 == x2 and y1 == y2:
            continue
        diffx = x2 - x1
        diffy = y2 - y1
        diff = (diffx, diffy)
        if not (diff in diff_list): diff_list[diff] = 0
        diff_list[diff] += 1

values = diff_list.values()
if len(values) > 0:
    m = max(values)
    ans = N - m
else:
    ans = 1

print(ans)
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    ユークリッドの互除法より
    aの逆元 ax = 1 (mod N)を満たすxを返す。
    O(log a)
    """

    def extgcd(a, b):
        """
        Extended Great Common Divisor
        ax + by = gcd(a, b) = dを満たすx, y, dを返す。
        """
        d = fractions.gcd(a, b)
        if b == 0:
            return 1, 0, a
        else:
            q, r = divmod(a, b)
            x, y, d = extgcd(b, r)
            s, t = y, x - q * y
            return s, t, d

    return extgcd(a, N)[0]


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log2(y) // 1 + 1))  # yの２進数表示の桁数
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = []

for i in range(max(a, b)):
    inv_list.append(inv_mod(i + 1, MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)


### FIXED CODE ###

import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    ユークリッドの互除法より
    aの逆元 ax = 1 (mod N)を満たすxを返す。
    O(log a)
    """

    def extgcd(a, b):
        """
        Extended Great Common Divisor
        ax + by = gcd(a, b) = dを満たすx, y, dを返す。
        """
        d = fractions.gcd(a, b)
        if b == 0:
            return 1, 0, a
        else:
            q, r = divmod(a, b)
            x, y, d = extgcd(b, r)
            s, t = y, x - q * y
            return s, t, d

    return extgcd(a, N)[0]


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  # yの２進数表示の桁数
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = []

for i in range(max(a, b)):
    inv_list.append(inv_mod(i + 1, MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)
N,A,B=map(int,input().split())
ballb=[]
ballr=[]
ballb.append('b')
ballb2=ballb*A
ballr.append('r')
ballr2=ballr*B
ball=(ballb2+ballr2)*(10**100)
count=0
for i in range(N):
    if ball[i]=='b':
        count += 1
    else:
        count=count
print(count)

### FIXED CODE ###

N,A,B=map(int,input().split())
a=N//(A+B)*A
c=N%(A+B)
b=min(A,c)
print(a+b)
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(W):
    s = ''
    for j in range(len(a)):
        if i in ls:
            continu
        else:
            s += a[j][i]
    ans.append(s)
print(*ans, sep='\n')

### FIXED CODE ###

H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(len(a)):
    s = ''
    for j in range(W):
        if j in ls:
            continue
        else:
            s += a[i][j]
    ans.append(s)
print(*ans, sep='\n')
import sys
sys.setrecursionlimit(100000000)

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

A = [0]*M

for i in range(M):
    A[i] = int(input())

A.append(N+1)

# DP version
DP = [0]*(N+1)
DP[0] = 1
# １段の階段を登るやり方の数
DP[1] = 1
# 2段の階段を登るやり方の数
DP[2] = 2

for i in range(3,N):
    DP[i] = DP[i-1] + DP[i-2]

def step_comb(L):
    if DP[L]>0:
        return DP[L]
    DP[L] = step_comb(L-1) + step_comb(L-2)
    return DP[L]
    
total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    if NOW == N:
        break
    
print(total_comb % 1000000007 )


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

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

if M == 0:
    A = []
else:
    A = [0]*M
    for i in range(M):
        A[i] = int(input())

A.append(N+1)

# DP version
DP = [0]*(N+1)
DP[0] = 1
# １段の階段を登るやり方の数
DP[1] = 1
# 2段の階段を登るやり方の数
#DP[2] = 2

for i in range(2,N+1):
    DP[i] = DP[i-1] + DP[i-2]

def step_comb(L):
    if DP[L]>0:
        return DP[L]
    DP[L] = step_comb(L-1) + step_comb(L-2)
    return DP[L]
    
total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    if NOW == N:
        break
    
print(total_comb % 1000000007 )
s = input('S')

if s == 'SUN':
    print('7')
if s == 'SAT':
    print('1')
if s == 'FRI':
    print('2')
if s == 'THU':
    print('3')
if s == 'WED':
    print('4')
if s == 'TUE':
    print('5')
if s == 'MON':
    print('6')

### FIXED CODE ###

s = input()

if s == 'SUN':
    print('7')
if s == 'SAT':
    print('1')
if s == 'FRI':
    print('2')
if s == 'THU':
    print('3')
if s == 'WED':
    print('4')
if s == 'TUE':
    print('5')
if s == 'MON':
    print('6')
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q)
print(p-q)

### FIXED CODE ###

import itertools
N = int(input())
LN = []
for i in range(N):
  LN.append(i+1)
LLN=list(itertools.permutations(LN))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
print(abs(LLN.index(tuple(P))-LLN.index(tuple(Q))))
h,n=map(int,inuput().split())
a=list(map(int,input().split()))

if h>sum(a):
    print('No')
else:
    print('Yes')

### FIXED CODE ###

h,n=map(int,input().split())
a=list(map(int,input().split()))

if h>sum(a):
    print('No')
else:
    print('Yes')
n = int(input())
count1 = 0

for i in range(1, n + 1, 2):
    count2 = 0

    for j in range(1, i + 1):
        if i % j == 0:
            count2 += 1

    if count2 == 8:
        count1 += 1

print(count1)

### FIXED CODE ###

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

print((A -1) * (B - 1))
from math import gcd
#input
N = int(input())
A = [int(i) for i in input().split()]
#cluc left and right gcd 
left = [0]*N
right = [0]*N
count = 0
left[0] = A[0]
right[-1] = A[-1]
Ans = []

for i in A[1:]:
    left[count+1] = gcd(left[count],i)
    count += 1

for i in reversed(A[:-1]):
    right[count-1] = gcd(right[count],i)
    count -= 1
# make ans
Ans.append(right[1])
Ans.append(left[-2])
for i in range(N-2):
    Ans.append(gcd(left[i],right[i+2]))
print(max(Ans))

### FIXED CODE ###

from fractions import gcd
#input
N = int(input())
A = [int(i) for i in input().split()]
#cluc left and right gcd 
left = [0]*N
right = [0]*N
count = 0
left[0] = A[0]
right[-1] = A[-1]
Ans = []

for i in A[1:]:
    left[count+1] = gcd(left[count],i)
    count += 1

for i in reversed(A[:-1]):
    right[count-1] = gcd(right[count],i)
    count -= 1
# make ans
Ans.append(right[1])
Ans.append(left[-2])
for i in range(N-2):
    Ans.append(gcd(left[i],right[i+2]))
print(max(Ans))
n=int(input())

def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr


res = list(input())
for _ in range(n-1):
    s = list(input())
    res = intersect_list(res,s)
res.sort()
ans = ''.join(res)
print(*ans, sep='')

### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print(''.join(sorted(s.elements())))
from itertools import combinations
import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)
for ele in range(1,m):
    combi = combinations(range(m),ele)
    for j in combi:
        current_under = np.array([sum(understnding[j,ind]) for ind in range(m)])
        tmp_ans = np.sum(costs[list(j)])
        if np.all(current_under>=x) and tmp_ans < ans:
            ans = tmp_ans
if ans != 10 ** 20:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

from itertools import combinations
import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(1, 2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row))+row
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)
import bisect
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=[]
for i in range(29):
  T=2**i
  B_=list(B)
  A_=list(A)
  t=0
  for j in range(N):
    B_[j]%=2*T
    A_[j]%=2*T
  B_.sort()
  for j in range(N):
    a=A_[j]
    p=bisect.bisect_left(B_,T-a)
    q=bisect.bisect_left(B_,2*T-a)
    r=bisect.bisect_left(B_,3*T-a)
    s=bisect.bisect_left(B_,4*T-a)
    t+=(q-p)+(s-r)
  ans.append(t%2)
a=0
for i in range(29):
  a+=2**i*ans[i]
print(a)


### FIXED CODE ###

N,C=map(int,input().split())
xv=[(0,0)]
xv_=[]
for i in range(N):
    x,v=map(int,input().split())
    xv.append((x,v))
    xv_.append((x,v))
xv_.append((C,0))
xv_.reverse()
r=[0]*(N+1)
r_=[0]*(N+1)
for i in range(N):
    r[i+1]=r[i]-(xv[i+1][0]-xv[i][0])+xv[i+1][1]
    r_[i+1]=max(r_[i],r[i+1]-xv[i+1][0])
l=[0]*(N+1)
l_=[0]*(N+1)
for i in range(N):
    l[i+1]=l[i]-abs(xv_[i+1][0]-xv_[i][0])+xv_[i+1][1]
    l_[i+1]=max(l_[i],l[i+1]-(C-xv_[i+1][0]))
ans=0
for i in range(1,N+1):
    ans=max(r[i]+l_[N-i],ans)
    ans=max(l[i]+r_[N-i],ans)
print(ans)
s=input()
c=0
for i in range(s):
    if i=="1":
        c+=1

print(c)

### FIXED CODE ###

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

if (a*b)%2==1:
    print("Odd");
else:
    print("Even");
n,m = map(int, input().split())
height = list(map(int, input().split()))
roads = [list(map(int, input().split())) for i in range(m)]

bestcount = 0

print(height)
print(roads)

for i in range(n):
    best = 1 # 良い展望台なら1
    for j in range(m):
        if (roads[j][0] == i):
            a = roads[j][0]
            b = roads[j][1]
            if (height[a] <= height[b]):
                best = 0
                break
        if (roads[j][1] == i):
            a = roads[j][1]
            b = roads[j][0]
            if (height[a] <= height[b]):
                best = 0
                break
    if(best == 1):
        bestcount += 1

print(str(bestcount))

### FIXED CODE ###

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

roads = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    roads[x-1].append(y-1)
    roads[y-1].append(x-1)

bestcount = 0

for i in range(n):
    best = 1 # 良い展望台なら1
    for j in roads[i]:
        if (height[j] >= height[i]):
            best = 0
            break
    if(best == 1):
        bestcount += 1

print(str(bestcount))
n=int(input())
if n==1:print("Hello World")
print(int(input())+int(input()))


### FIXED CODE ###

n=int(input())
if n==1:print("Hello World")
else:print(int(input())+int(input()))
n = int(input())

maxv = -2000000000

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

minv = lst[0]

for i in range(n + 1):
   maxv = max([maxv, lst[i] - minv])
   minv = min([minv, lst[i])

print(maxv) 


### FIXED CODE ###

n = int(input())
 
maxv = -2000000000
 
 
minv = int(input())
 
for i in range(1, n):
   cur = int(input())
   maxv = max([maxv, cur - minv])
   minv = min([minv, cur])
 
print(maxv)
from collections import Counter

n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
OVER_RUN = n*k

cnt = [-1] * (2 * 10**5 + 10)
transition = [[-1] * n for _ in range(58)]
transition[0] = [0 for _ in range(1,n+1)]
for i, item in enumerate(a + a):
    if cnt[item] == -1:
        cnt[item] = i
        continue
    if cnt[item] < n:
        transition[1][cnt[item]] = i+1 - cnt[item]
    cnt[item] = i

for i in range(2,58):
    for j in range(n): 
        walk = transition[i-1][j] + transition[i-1][(transition[i-1][j] + j) % n]
        if walk > OVER_RUN:
            transition[i][j] = OVER_RUN
        else:
            transition[i][j] = walk

step = 0
step_mod = 0
while True:
    itr = 57 
    while transition[itr][step_mod] + step >= OVER_RUN:
        itr -= 1
    step += transition[itr][step_mod]
    step_mod = step % n
    if itr == 0:
        break

# Simulation
target = a[step_mod:]
ans = []
cnt = Counter()
for item in target:
    if cnt[item] > 0:
        while True:
            p = ans.pop()
            if p == item:
                break
    else:
        cnt[item] += 1
        ans.append(item)
print(" ".join([str(item) for item in ans]))

### FIXED CODE ###

from collections import Counter

n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
OVER_RUN = n*k

cnt = [-1] * (2 * 10**5 + 10)
transition = [[-1] * n for _ in range(58)]
transition[0] = [0 for _ in range(1,n+1)]
for i, item in enumerate(a + a):
    if cnt[item] == -1:
        cnt[item] = i
        continue
    if cnt[item] < n:
        transition[1][cnt[item]] = i+1 - cnt[item]
    cnt[item] = i

for i in range(2,58):
    for j in range(n): 
        walk = transition[i-1][j] + transition[i-1][(transition[i-1][j] + j) % n]
        if walk > OVER_RUN:
            transition[i][j] = OVER_RUN
        else:
            transition[i][j] = walk

step = 0
step_mod = 0
while True:
    itr = 57 
    while transition[itr][step_mod] + step >= OVER_RUN:
        itr -= 1
    step += transition[itr][step_mod]
    step_mod = step % n
    if itr == 0:
        break

# Simulation
target = a[step_mod:]
ans = []
cnt = Counter()
for item in target:
    if cnt[item] > 0:
        while True:
            p = ans.pop()
            cnt[p] -= 1
            if p == item or not p:
                break
    else:
        cnt[item] += 1
        ans.append(item)
print(" ".join([str(item) for item in ans]))
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(x) for x in input().split())
H = [-1]+list(map(int, input().split()))

#observ_H =[i for i in range(1,N+1)]
observ_H ={}
connction ={i:set() for i in range(1,N+1)}

#つながり
for i in range(1,M+1):
    a,b = (int(x) for x in input().split())
    connction[a].add(b)
    connction[b].add(a)
    
#展望台の高さ、辞書
for i in range(1,N+1):
    observ_H[i] = H[i]
#observ_H.sort(key=lambda x:x[1],reverse=True)
observ_good ={i:"bad"}
hantei="bad"
for num,connect in connction.items():
    hantei ="bad"
    for saki in connect:
        if observ_H[num] > observ_H[saki]:
            hantei ="good"
    if hantei=="good":
        observ_good[num] ="good"
print(len(i))


### FIXED CODE ###

# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(x) for x in input().split())
H = [-1]+list(map(int, input().split()))

#observ_H =[i for i in range(1,N+1)]
observ_H ={}
connection ={i:set() for i in range(1,N+1)}

#つながり
for i in range(1,M+1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
    
#展望台の高さ、辞書
for i in range(1,N+1):
    observ_H[i] = H[i]
#observ_H.sort(key=lambda x:x[1],reverse=True)
observ_good ={}
hantei=1
for num,connect in connection.items():
    hantei =1
    for saki in connect:
        if observ_H[num] > observ_H[saki]:
            hantei *=1
        else:
            hantei=0
    if hantei==1:
        observ_good[num] ="good"
print(len(observ_good))
s,t = map(str,input().split())
s =  ''.join(sorted(s))
t = ''.join(sorted(t))
 
print(s)
print(t)
if s == t:
    print("yes")
else:
    print("no")


### FIXED CODE ###

import math

a,b,c = map(int,input().split())
lst = []
lst.append(a)
lst.append(b)
lst.append(c)
lst.sort()

print(lst[2] - lst[1] + (lst[1] - lst[0]))
N, Q=map(int, input().split())
value=[0]*N
#各ノードの下につくノード
road=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  road[a-1].append(b-1)
  
adds=[0]*N
for i in range(Q):
  p,x=map(int, input().split())
  adds[p-1]+=x
  
#自身のノード番号 足していく
#a: add[なんとか]
def dfs(a,  i):
  value[i]+=a
  L=road[i]
  for l in L:
    dfs(a,l)
for i in range(N):
  dfs(adds[i], i)


for v in value:
  print(v, end=" ")

### FIXED CODE ###

from collections import deque 
N,Q=map(int, input().split())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
X=[0]*N
for i in range(Q):
    p,x=map(int, input().split())
    X[p-1]+=x
que=deque([(0,-1)])
#print(que)
while que:
    now, pre=que.pop()
    for nex in G[now]:
        if nex==pre:
            continue
        else:
            X[nex]+=X[now]
            que.append((nex,now))

print(" ".join(map(str, X)))
k,n=map(int,input().split())
list=list(input().split())
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))

### FIXED CODE ###

k,n=map(int,input().split())
list=list(map(int,input().split()))
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))
n = input()
maxi = 0
mini = 0

for i in range(n):
  tmp = input n
  maxi = max(maxi, tmp)
  mini = min(mini, tmp)

print maxi

### FIXED CODE ###

n = input()
maxi = -1 * 10**9
mini = input()


for i in range(n-1):
  tmp = input()
  maxi = max(maxi, tmp - mini)
  mini = min(mini, tmp)

print maxi
s=input()
k=int(input())
a=[]
a = [s[i:j] for i in range(0,len(s)) for j in range(1,len(s)+1) if i != j]
a=set(a)
a.remove("")
a=sorted(a)
print(a[k-1])


### FIXED CODE ###

s=input()
k=int(input())
a=[s[i:i+j+1] for i in range(len(s)) for j in range(k+1)]
a=set(a)
a=sorted(a)
print(a[k-1])
print(int(input()) * (100 ** int(input()))) 

### FIXED CODE ###

d, n = map(int, input().split())
print(100 ** d * 101 if n == 100 else 100 ** d * n)
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)

if length > 0:
  o_nums = list(input().split())

  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs)) #絶対値が最も小さいもの

  if -(nums[smallest_diff_index]) in diffs:
    print(-(nums[smallest_diff_index]))
  else:
    print(nums[smallest_diff_index])

else:
  print(target)


### FIXED CODE ###

class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  a = target - i
  if a not in nums:
    print(a)
    exit()

  b = target + i
  if b not in nums:
    print(b)
    exit()