Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque

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

adj_list = [[] for _ in range(n)]

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

distance = [-1] * n
prev = [-1] * n

q = deque()
q.append([0, 0, 0])  #[node, distance, prev]

while len(q) > 0:
    room, d, p = q.popleft()
    #if distance[room] > 0:
    #    continue
    if distance[room] == -1 or distance[room] > d:
        distance[room] = d
        prev[room] = p

    for n_room in adj_list[room]:
        if distance[n_room] > 0:
            continue
        q.append([n_room, d + 1, room])

flag = True
for i in range(n):
    if distance[i] < 0:
        flag = False
        break

if flag is True:
    print("Yes")
    for i in range(1, n):
        print(prev[i] + 1)
else:
    print("No")


### FIXED CODE ###

from collections import deque

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

adj_list = [[] for _ in range(n)]

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

distance = [-1] * n
prev = [-1] * n

q = deque()
q.append([0, 0, 0])  #[room, distance, prev]

while len(q) > 0:
    room, d, p = q.popleft()
    #if distance[room] == -1:
    #    distance[room] = d
    #    prev[room] = p

    for n_room in adj_list[room]:
        if distance[n_room] > 0:
            continue
        q.append([n_room, d + 1, room])
        distance[n_room] = d + 1
        prev[n_room] = room

flag = True
for i in range(n):
    if distance[i] < 0:
        flag = False
        break

if flag is True:
    print("Yes")
    for i in range(1, n):
        print(prev[i] + 1)
else:
    print("No")
### BUGGY CODE ###

N, K = map(int, (input().split()))
h = list(map(int, input().split()))
# print(N, h)

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10 ** 5 + 10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i - j]))

print(dp[N - 1])

### FIXED CODE ###

N, K = map(int, (input().split()))
h = list(map(int, input().split()))
# print(N, h)

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10 ** 5 + 10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i - j]))

print(dp[N - 1])
### BUGGY CODE ###

a=int(input())
for i in range(a):
    if a%(i+1)==0:
        p=a//(i+1)
        if (i+1)>=p:
            break
print(i+p-1)

### FIXED CODE ###

n=int(input())
i=0
s=[]
p=0
for i in range(int(n**0.5)):
    i+=1
    if n%i==0:
        p=1
        s.append(n//i+i-2)
print(min(s))
### BUGGY CODE ###

import sys
A, B, C, X, Y = map(int, sys.stdin.readline().split(" "))
ans = float("inf")
 
for i in range(X + 1):
    for j in range(Y + 1):
        k = max(X - i, Y - j) * 2
        ans = min(ans, A * i + B * j + C * k)
print(ans)

### FIXED CODE ###

import sys
A, B, C, X, Y = map(int, sys.stdin.readline().split(" "))
ans = float("inf")
 
for i in range(max(X, Y) * 2 + 1):
    j = X - i // 2
    if j < 0:
        j = 0
    k = Y - i // 2
    if k < 0:
        k = 0
    ans = min(ans, C * i + A * j + B * k)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

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

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    return min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))

print(cost(n-1))


### FIXED CODE ###

# coding: utf-8
n=int(input())
h=list(map(int,input().split()))
dp=[999999999 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
### BUGGY CODE ###

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

bridges = []
for i in range(m):
    bridges.append([int(x) for x in input().split()])

g = list(range(n+1))
ng = [1 for _ in range(n+1)]
gl = [[i] for i in range(n+1)]
ans = []
unconf = n*(n-1)//2
ans.append(unconf)


for x in reversed(bridges):
    a,b = x
    if g[a] != g[b]:
        tmp = ng[g[a]] * ng[g[b]]
        ng[g[a]] = ng[g[a]]+ng[g[b]]
        gl[g[a]] = gl[g[a]] + gl[g[b]]
        for y in gl[g[b]]:
            g[y] = g[a]
        unconf -= tmp
        ans.append(unconf)
    else:
        ans.append(unconf)


ans.reverse()
ans.pop(0)
for x in ans:
    print(x)

### FIXED CODE ###

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

bridges = []
for i in range(m):
    bridges.append([int(x) for x in input().split()])
'''
g = list(range(n+1))
ng = [1 for _ in range(n+1)]
gl = [[i] for i in range(n+1)]
ans = []
unconf = n*(n-1)//2
ans.append(unconf)


for x in reversed(bridges):
    a,b = x
    if g[a] != g[b]:
        tmp = ng[g[a]] * ng[g[b]]
        ng[g[a]] = ng[g[a]]+ng[g[b]]
        gl[g[a]] = gl[g[a]] + gl[g[b]]
        for y in gl[g[b]]:
            g[y] = g[a]
        unconf -= tmp
        ans.append(unconf)
    else:
        ans.append(unconf)


ans.reverse()
ans.pop(0)
for x in ans:
    print(x)
'''
def root(par, ifpar, a):
    while ifpar[a] != 1:
       a = par[a]
    return a 

def unite(cnt, par, ifpar, npar, depth, ra, rb):
    if depth[ra] >= depth[rb]:
        npar[ra] = npar[ra] + npar[rb]
        par[rb] = ra
        ifpar[rb] = 0
        if depth[ra] == depth[rb]:
            depth[ra] += 1
    else:
        npar[rb] = npar[rb] + npar[ra]
        par[ra] = rb
        ifpar[ra] = 0

par = list(range(n+1))
ifpar = [1 for _ in range(n+1)]
npar = [1 for _ in range(n+1)]
depth = [1 for _ in range(n+1)]

ans = []
unconf = n*(n-1)//2
ans.append(unconf)
cnt = 0

for x in reversed(bridges):
    a,b = x
    ra = root(par, ifpar, a)
    rb = root(par, ifpar, b)
    if ra != rb:
        tmp = npar[ra] * npar[rb]
        unite(cnt, par, ifpar, npar, depth, ra, rb)
        unconf -= tmp
    ans.append(unconf)
    cnt += 1

ans.reverse()
ans.pop(0)
for x in ans:
    print(x)
### BUGGY CODE ###

import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        memo_ls[i][j] = memo_ls[i-1][j] + int(k)

res = 0
for i in range(60):
    res += memo_ls[-1][i] * (n - memo_ls[-1][i]) * 2 ** i
    res %= MOD
print(res)

### FIXED CODE ###

import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
ct = {i : 0 for i in range(60)}
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        if k == "1":
            ct[j] += 1

res = 0
for i in range(60):
    res += ct[i] * (n - ct[i]) * 2 ** i
    res %= MOD
print(res)
### BUGGY CODE ###

from heapq import heappush, heappop
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x : int(x) - 1, input().split())
c = [input().rstrip() for _ in range(H)]
INF = 10**18
dist = [[[(INF, INF)] * 4 for _ in range(W)] for _ in range(H)]
dist[x1][y1] = [(1, 0)] * 4
heap = []
for i in range(4):
    heappush(heap, (dist[x1][y1][i], x1, y1, i))
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
while heap:
    d, x, y, i = heappop(heap)

    if d > dist[x][y][i]:
        continue

    for j in range(4):
        nd = (d[0] + 1, 0)
        if dist[x][y][j] > nd:
            dist[x][y][j] = nd
            heappush(heap, (nd, x, y, j))

    nx = x + dx[i]
    ny = y + dy[i]
    if nx < 0 or H <= nx or ny < 0 or W <= ny or c[nx][ny] == '@':
        continue
    nd = (d[0], d[1] + 1) if d[1] < K else (d[0] + 1, 1)
    if dist[nx][ny][i] > nd:
        dist[nx][ny][i] = nd
        heappush(heap, (nd, nx, ny, i))
ans = min(dist[x2][y2])[0]
print(ans if ans < INF else -1)


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x : int(x) - 1, input().split())
c = [input().rstrip() for _ in range(H)]
INF = 10**18
dist = [[[(INF, INF)] * 4 for _ in range(W)] for _ in range(H)]
dist[x1][y1] = [(1, 0)] * 4
dq = deque()
for i in range(4):
    dq.append((dist[x1][y1][i], x1, y1, i))
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
while dq:
    d, x, y, i = dq.popleft()

    if d > dist[x][y][i]:
        continue

    for j in range(4):
        nd = (d[0] + 1, 0)
        if dist[x][y][j] > nd:
            dist[x][y][j] = nd
            dq.append((nd, x, y, j))

    nx = x + dx[i]
    ny = y + dy[i]
    if nx < 0 or H <= nx or ny < 0 or W <= ny or c[nx][ny] == '@':
        continue
    if d[1] < K:
        nd = (d[0], d[1] + 1)
        if dist[nx][ny][i] > nd:
            dist[nx][ny][i] = nd
            dq.appendleft((nd, nx, ny, i))
    else:
        nd = (d[0] + 1, 1)
        if dist[nx][ny][i] > nd:
            dist[nx][ny][i] = nd
            dq.append((nd, nx, ny, i))
ans = min(dist[x2][y2])[0]
print(ans if ans < INF else -1)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
s = s[::-1]
dp = [[0]*13 for _ in range(n)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for i in range(1,n):
    if s[i] != '?':
        x = (int(s[i])*(10**i)) % 13
        for j in range(13):
            dp[i][(j+x) % 13] += dp[i-1][j]
            dp[i][(j+x) % 13] %= mod
    else:
        for j in range(10):
            x = j*(10**i) % 13
            for k in range(13):
                dp[i][(k+x) % 13] += dp[i-1][k]
                dp[i][(k+x) % 13] %= mod
print(dp[n-1][5])


### FIXED CODE ###

#!/usr/bin/env python3
#ABC135 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

s = list(input())
s = s[::-1]
l = len(s)
#dp[i][j] := 先頭i文字として考えられるもののうち、13で割ったあまりがjであるもの
dp = [[0]*13 for _ in range(l)]
remain = 1
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1,l):
    remain = (remain * 10) % 13
    if s[i] == '?':
        for k in range(10):
            for j in range(13):
                dp[i][(j + remain * k) % 13] += dp[i-1][j]
                dp[i][(j + remain * k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j + remain * int(s[i])) % 13] += dp[i-1][j]
print(dp[-1][5])
### BUGGY CODE ###

while 1:
	r,c,q = map(int,raw_input().split())
	if r == 0: break
	R = [[0,0] for i in range(r)]
	C = [[0,0] for i in range(c)]
	for i in range(1,q+1):
		A,B,order = map(int,raw_input().split())
		if A == 0:
			R[B] = [i,order]
		else:
			C[B] = [i,order]
	ans = 0
	for ri in range(r):
		ans += sum(R[ri][1] if R[ri][0] > C[ci][0] else C[ci][1] for ci in range(c))
	print ans

### FIXED CODE ###

from bisect import *
while 1:
	r,c,q = map(int,raw_input().split())
	if r == 0: break
	R = [[0,0] for i in range(r)]
	C = [[0,0] for i in range(c)]
	for i in range(1,q+1):
		A,B,order = map(int,raw_input().split())
		if A == 0:
			R[B] = [i,order]
		else:
			C[B] = [i,order]
	CC =  [sorted(C[ci][0] for ci in range(c) if C[ci][1] == 1)]
	CC += [sorted(C[ci][0] for ci in range(c) if C[ci][1] == 0)]
	ans = r*sum(C[ci][1] for ci in range(c))
	ans -= sum((-1)**R[ri][1]*bisect(CC[R[ri][1]],R[ri][0]) for ri in range(r))
	print ans
### BUGGY CODE ###

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

links = []

sums = [0] * (n + 1)

for _ in range(n - 1):
  a, b= map(int, input().split())
  heapq.heappush(links, [a,b])

uppers = [[1, x] for x in range(n + 1)]

for l in links:
  # print(l, uppers)
  uppers[l[1]] += uppers[l[0]]
  uppers[l[1]] = list(set(uppers[l[1]]))
  
for _ in range(m):
  p, x = map(int, input().split())
  for i in range(n+1):
    if p in uppers[i]:
      sums[i] += x

print(*sums[1:])
  

### FIXED CODE ###

from collections import defaultdict

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

links = [[] for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]

links[0].append(1)
for _ in range(n - 1):
  a, b= map(int, input().split())
  links[a].append(b)
  links[b].append(a)

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

# print(links)
que = [0,[1]]
checked = [0 for x in range(n+1)]

que = [[-1, [0]]]

while que:
  link = que.pop()
  # print(link)
  par = link[0]
  childs = link[1]

  for child in childs:
    if checked[child] != 1:
      sums[child] = sums[par] + adds[child]
      que.append([child, links[child]])
      checked[child] = 1

  
print(*sums[1:])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

s = input().strip()
dp = tuple([{} for i in range(len(s))])

def f(i, g):
    if i == len(s):
        return 0
    if g in dp[i]:
        return dp[i][g]
    p = i - g
    ans = (-1 if s[i] == 'p' else 0) + f(i + 1, g + 1)
    if p + 1 <= g:
        ans = max(ans, (1 if s[i] == 'g' else 0) + f(i + 1, g))
    dp[i][g] = ans
    return ans


print(f(0, 0))

### FIXED CODE ###

S = input()
N = len(S)
print(N // 2 - sum([int(s == 'p') for s in S]))
### BUGGY CODE ###

import sys

input = sys.stdin.readline
N = int(input())
As = [[]]
for i in range(N):
    As.append(list(map(int, input().split())))

Cs = [0] * (N + 1)
Ks = [False] * (N + 1)
d = 1
ms = 0
msMax = N * (N - 1) // 2
sw = True
tab = set()
wa = [0] * (N + 1)
while sw:
    wac = 0
    c = 0
    e = N + 1
    f = N - 1
    for i in range(1, e):
        if Ks[i] or Cs[i] == f:
            continue
        if i > As[i][Cs[i]]:
            a = As[i][Cs[i]]
            b = i
        else:
            a = i
            b = As[i][Cs[i]]
        if (a, b) in tab:
            ms = ms + 1
            c = c + 1
            if ms == msMax:
                sw = False
                print(d)
                break
            Cs[a] = Cs[a] + 1
            Cs[b] = Cs[b] + 1
            tab.remove((a, b))
            Ks[a] = False
            wa[wac] = b
            wac = wac + 1
        else:
            tab.add((a, b))
            Ks[i] = True
    for i in range(N):
        if wa[i] == 0:
            break
        Ks[wa[i]] = False
        wa[i] = 0
    d = d + 1
    if c == 0:
        print(-1)
        break

### FIXED CODE ###

import sys

input = sys.stdin.readline
N = int(input())
As = [list(map(int, input().split())) + [-1] for _ in range(N)]

import collections

que = collections.deque([i for i in range(N)])
counters = [0] * N
days = [0] * N
while que:
    player = que.popleft()
    opponent = As[player][counters[player]] - 1
    if As[opponent][counters[opponent]] - 1 == player:
        days[player] = max(days[player], days[opponent]) + 1
        days[opponent] = days[player]
        counters[player] += 1
        counters[opponent] += 1
        que.append(player)
        que.append(opponent)
for c in counters:
    if c < N - 1:
        print(-1)
        break
else:
    print(max(days))
### BUGGY CODE ###

import heapq
def SME(start,end):
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    i = L
    while i < N :
        if None not in ANS[i:i+L] :
            i += L
            continue
        if ANS[i] : 
            i += 1
            continue
        else : 
            ANS[i] = min(Whole[i+1-L:i+1])
            i+=1
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.9998
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
	S.append(input())
	S = list(set(S))
print(len(S))

### FIXED CODE ###

N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())

S = list(set(S))
print(len(S))
### BUGGY CODE ###

N = int(input())
l = [i for i in input()]
numR = l.count('R')
cnt = 0

if numR == len(l) or numR == 0:
    print(0)
    exit()

for i in range(N):
    if l[-(i + 1)] == 'R':
        cnt += 1
        l[l.index('W')] = 'R'
        l[-(i + 1)] = 'W'
    if l.index('W') == numR:
        print(cnt)
        break


### FIXED CODE ###

N = int(input())
c = input()

numR = c.count('R')
print(0 if numR == 0 or numR == len(c) else c[:numR].count('W'))
### BUGGY CODE ###

N = int(input())
X = input()

x_num = int(X, 2)

def f(cnt):
    if (cnt > 0):
        pcount = p_count(cnt)
        return f(cnt % pcount) + 1
    else:
        return 0


def p_count(x):
    cnt = 0
    while (x > 0):
        if x % 2 != 0:
            cnt += 1
        x //= 2
    return cnt


for i, x in enumerate(X):
    if (x == '1'):
        #x_num = int(''.join(X), 2)
        print(f(x_num - (2**(N-(i+1)))))
    else:
        #x_num = int(''.join(X), 2)
        print(f(x_num + (2**(N-(i+1)))))

### FIXED CODE ###

#!/usr/bin/env python3
N = int(input())
X = input()

x_num = int(X, 2)
cnt1 = X.count('1')

p_zero = x_num % (cnt1 + 1)
p_one = (x_num % (cnt1 - 1) if cnt1 - 1 > 0 else 1)


def f(cnt):
    if (cnt > 0):
        pcount = p_count(cnt)
        return f(cnt % pcount) + 1
    else:
        return 0


def p_count(x):
    cnt = 0
    while (x > 0):
        if x % 2 != 0:
            cnt += 1
        x //= 2
    return cnt


def f1(x):
    cnt = 0
    while (x > 0):
        x %= bin(x).count('1')
        cnt += 1
    return cnt


for i, x in enumerate(list(X)):
    if (x == '1'):
        #x_num = int(''.join(X), 2)
        if cnt1 - 1 > 0:
            xxx = (p_one - pow(2, (N - (i + 1)), cnt1 - 1)) % (cnt1 - 1)
            xxx += cnt1 - 1 if xxx < 0 else 0
            print(f1(xxx) + 1)
        else:
            print(0)
    else:
        #x_num = int(''.join(X), 2)
        xxx = (p_zero + pow(2, (N - (i + 1)), cnt1 + 1)) % (cnt1 + 1)
        xxx += cnt1 + 1 if xxx < 0 else 0
        print(f1(xxx) + 1)
### BUGGY CODE ###

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

m=max(a)
for i in range(n):
    if a[i]==m:
        a_new=a[:i]+a[i+1:]
        print(max(a_new))
    else:
        print(m)


### FIXED CODE ###

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

a_s=sorted(a)
m1=a_s[-1]
m2=a_s[-2]

for i in range(n):
    if a[i]==m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

import itertools

iCnt = int(input())
v = list(input())

vAns = []
vProduct = []
iOnIndex = 0
for _ in range(iCnt - 1):
    iLen = len(v[-iCnt + iOnIndex + 1:])
    vProduct = itertools.product([0, 1], repeat=iLen)
    for p in vProduct:
        sChk = v[iOnIndex]
        iP_Len = len(p)
        for i in range(iP_Len):
            if p[i] == 1:
                if v[iOnIndex + i + 1] not in sChk:
                    sChk += v[iOnIndex + i + 1]
                else:
                    sChk = "NG"
                    break
        if "NG" not in sChk: vAns.append(sChk)
    iOnIndex += 1
vAns.append(v[iCnt - 1])
print(len(vAns) % (10 ** 9 + 7))

### FIXED CODE ###

from collections import defaultdict

iCnt = int(input())
S = input()
M = 10**9 + 7

vCntDct = defaultdict(int)

for s in S:
    vCntDct[s] += 1

ans = 1
for v in vCntDct.values():
    ans *= (v + 1)
    ans %= M

print(ans - 1)
### BUGGY CODE ###

from itertools import combinations

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

for k in range(1, K+1):
    ans = len(list(combinations(range(R+1), k))) * len(list(combinations(range(K-1), k-1)))
    ans %= mod
    print(int(ans))

### FIXED CODE ###

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

fact = [0] * 2001
inv = [0] * 2001
inv_cal = [0] * 2001

fact[:2] = [1, 1]
inv[1] = 1
inv_cal[:2] = [1, 1]

for i in range(2, 2001):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - (mod // i) * inv[mod % i] % mod
    inv_cal[i] = inv_cal[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (inv_cal[k] * inv_cal[n-k] % mod) % mod

for k in range(1, K+1):
    if R+1 >= k:
        print(comb(R+1, k) * comb(K-1, k-1) % mod)
    else:
        print(0)