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

k,n =map(int,input().split())
mod = 998244353
fact=[1]*4010
for i in range(1,len(fact)):
  fact[i] = fact[i-1]*i%mod
def comb(n,k,p):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=fact[n]
  b=fact[k]
  c=fact[n-k]
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
for i in range(2,2*k+1):
  ans = 0
  if i %2 == 1:
    pp = (i+1)//2
    pm = i - pp
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*2**q
      if n - q<0:
        continue
      r = k-p*2
      if r <0:
        r = 0
      ans += sen* comb(n+r-1,n-q,mod)
    print(ans%mod)
  else:
    pp = i//2 +1
    pm = i//2 -1
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*2**q
      if n - q<0:
        continue
      r = k-p*2-1
      if r <0:
        r = 0
      ans += sen* comb(n+r-1,n-q,mod)
    for q in range(p+1):
      sen = comb(p,q,mod)*2**q
      if n - q-1<0:
        continue
      r = k-p*2-1
      if r <0:
        r = 0
      ans += sen* comb(n+r-2,n-q-1,mod)
    print(ans%mod)

### FIXED CODE ###

k,n =map(int,input().split())
mod = 998244353
fact = [1]*(n+k+1)
rfact = [1]*(n+k+1)
for i in range(n+k):
    fact[i+1] = rr = ((i+1) * fact[i]) % mod
    rfact[i+1] = pow(rr, mod-2, mod)
def comb(N, K,mod):
    return fact[N] * rfact[K] * rfact[N-K] % mod
kota = []
for i in range(2,k+2):
  ans = 0
  if i %2 == 1:
    pp = (i+1)//2
    pm = i - pp
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q<0:
        break
      r = k-p*2
      if r <0:
        r = 0
      if n+r-1 < n-q:
        continue
      ans += sen* comb(n+r-1,n-q,mod)%mod
    kota.append(ans%mod)
  else:
    pp = i//2 +1
    pm = i//2 -1
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q<0:
        break
      r = k-p*2-1
      if r <0:
        r = 0
      if n+r-1 < n-q:
        continue
      ans += sen* comb(n+r-1,n-q,mod)%mod
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q-1<0:
        break
      r = k-p*2-1
      if r <0:
        r = 0
      if n+r-2 < n-q-1:
        continue
      ans += sen* comb(n+r-2,n-q-1,mod)%mod
    kota.append(ans%mod)
for i in kota:
  print(i)
for i in range(len(kota)-2,-1,-1):
  print(kota[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
import sys
n = int(input())
li = list(map(int, input().split()))

count = 0

for i in range(len(li)) :
  for j in range(len(li)) :
    if sum(li[i:i+j+1]) == 0:
      count = count + 1
    if i + j >= len(li) - 1:
      break

print(count)


### FIXED CODE ###

def tri(n):
  return n * (n+1) // 2

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

SA = [0] * (N+1)
for i in range(N):
  SA[i+1] = SA[i] + A[i]
  
SA.sort()

ans = 0
cnt = 0

for i in range(N+1):
  if i == 0:
    now = SA[i]
    continue
  
  if now == SA[i]:
    cnt += 1
    continue
  elif cnt > 0:
    ans += tri(cnt)
    cnt = 0
  else:
    pass
  now = SA[i]

if cnt > 0:
    ans += tri(cnt)
    
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python
import sys

sys.setrecursionlimit(20000)


matrix = []
vec = [[1,0],[-1,0],[0,1],[0,-1]]
visited =[]

def dfs(x,y,fruit):
  visited.append((x,y))
  for v in vec:
    nx = x + v[0]
    ny = y + v[1]
    if not (nx,ny) in visited and nx in xrange(w) and ny in xrange(h):
      if matrix[ny][nx] == fruit:
        dfs(nx,ny,fruit)



while True:
  h,w = map(int,raw_input().rstrip().split(" "))
  if h == 0 and w == 0:
    break
  matrix = []
  visited = []
  ans = 0
  for i in xrange(h):
    s = raw_input().rstrip()
    matrix.append(list(s))
  for i in xrange(h):
    for j in xrange(w):
      if not (j,i) in visited:
        dfs(j,i,matrix[i][j])
        ans+=1
  print ans

### FIXED CODE ###

#!/usr/bin/env python
import sys

sys.setrecursionlimit(20000)

matrix = []
vec = [[1,0],[-1,0],[0,1],[0,-1]]
visited =[]
h = 0
w = 0

def dfs(x,y,fruit):
  #visited.append((x,y))
  visited[y][x] = 1
  for v in vec:
    nx = x + v[0]
    ny = y + v[1]
    if nx in xrange(w) and ny in xrange(h):
      if visited[ny][nx]==0 and matrix[ny][nx] == fruit:
        dfs(nx,ny,fruit)
  return 0


while True:
  h,w = map(int,raw_input().split())
  if h == 0 and w == 0:
    break
#  print h,w
  matrix = []
  visited = []
  ans = 0
  for i in xrange(h):
    s = raw_input().rstrip()
    matrix.append(list(s))
    visited.append([0]*w)
  for i in xrange(h):
    for j in xrange(w):
      #if not (j,i) in visited:
      if visited[i][j] == 0:
        dfs(j,i,matrix[i][j])
        ans+=1
  print ans
### BUGGY CODE ###


d=[0]*13
d[0]=1
mul=1
t=list(input())
t.reverse()
for c in t:
    e=[0]*13
    """
    if c=="?":
        for i in range(10):
            for j in range(13):
                e[(i*mul+j)%13]+=d[j]
                e[(i*mul+j)%13]%=(10**9+7)
    else:
        for j in range(13):
            e[(int(c)*mul+j)%13]+=d[j]
            e[(int(c)*mul+j)%13]%=(10**9+7)
    """
    for i in (range(10) if c=="?" else[int(c)]):
        for j in range(13):
            e[(i*mul+j)%13]+=d[j]
            
    d=[e%(10**9+7)for e in e]
    mul*=10
print(d[5])

### FIXED CODE ###

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
 
s = input()
l = len(s)
MOD = 10**9+7
 
dp = [0]*13
dp[0] = 1
for i in s:
    new = [0]*13
    if i == "?":
        for i in range(10):
            for j in range(13):
                new[(10*j+i)%13] += dp[j]
    else:
        i = int(i)
        for j in range(13):
            new[(i+10*j)%13] += dp[j]
    
    for i in range(13):
        new[i] %= MOD
    dp,new = new,dp
#    print(dp)
 
print(dp[5]%MOD)
### BUGGY CODE ###

def getlist():
	return map(int, input().split())

L = []

H, W = getlist()
for i in range(H):
	S = list(input())
	L.append(S)

ans1 = [[0 for i in range(W)] for j in range(H)]
ans2 = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
	val = 0
	l = []
	for j in range(W):
		if L[i][j] == "#":
			for k in l:
				ans1[i][k] = val
			val = 0
			l = []
		else:
			val += 1
			l.append(j)
	for k in l:
		ans1[i][k] = val

for i in range(W):
	val = 0
	l = []
	for j in range(H):
		if L[j][i] == "#":
			for k in l:
				ans2[k][i] = val
			val = 0
			l = []
		else:
			val += 1
			l.append(j)
	for k in l:
		ans2[k][i] = val


ans = -1
for i in range(H):
	for j in range(W):
		x = ans1[i][j] + ans2[i][j] - 1
		if x > ans:
			ans = x

print(ans)

### FIXED CODE ###

def getlist():
	return map(int, input().split())

L = []

H, W = getlist()
for i in range(H):
	S = list(input())
	L.append(S)

ans1 = [[0 for i in range(W)] for j in range(H)]
ans2 = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
	val = 0
	l = []
	for j in range(W):
		if L[i][j] == "#":
			for k in l:
				ans1[i][k] = val
			val = 0
			l = []
		else:
			val += 1
			l.append(j)
	for k in l:
		ans1[i][k] = val

for i in range(W):
	val = 0
	l = []
	for j in range(H):
		if L[j][i] == "#":
			for k in l:
				ans2[k][i] = val
			val = 0
			l = []
		else:
			val += 1
			l.append(j)
	for k in l:
		ans2[k][i] = val


ans = -1
for i in range(H):
	for j in range(W):
		x = ans1[i][j] + ans2[i][j] - 1
		if x > ans:
			ans = x

print(ans)
### BUGGY CODE ###

import numpy as np

def dp(v, d, c):
    if res[v-1] == 0:
        res[v-1] = c

    if d == 0:
        return None

    if np.all(res > 0):
        return None



    for e in dic.get(v, []):
        dp(e, d-1, c)


N, M = tuple(map(int, input().split(' ')))

dic = {}

for m in range(M):
    a, b = tuple(map(int, input().split(' ')))
    dic[a] = dic.get(a, []) + [b]
    dic[b] = dic.get(b, []) + [a]

Q = int(input())

vdc = []

for q in range(Q):
    vdc.append(tuple(map(int, input().split(' '))))

vdc.reverse()

res = np.zeros(N)

for q in range(Q):
    v, d, c = vdc[q]
    dp(v, d, c)


for i in range(N):
    print(int(res[i]))


### FIXED CODE ###

import numpy as np

def dp(v, d, c):
    if memo[v-1][d]:
        return

    memo[v-1][d] = True
    if d == 0:
        res[v-1] = str(c)
        return

    dp(v, d-1, c)
    for e in dic[v-1]:
        dp(e, d-1, c)


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

dic = [[] for _ in range(N)]
memo = [[False]*11 for _ in range(N)]

for m in range(M):
    a, b = [int(e) for e in input().split(' ')]
    dic[a-1].append(b)
    dic[b-1].append(a)

Q = int(input())


vdc = [[int(e) for e in input().split(' ')] for _ in range(Q)]

res = ['0']*N

[dp(v, d, c) for v, d, c in vdc[::-1]]


print('\n'.join(res))
### BUGGY CODE ###

from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
Ps = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
g = 1
for p in Ps:
    g = lcm(g,p)
ans = 0

print(sum([g // p for p in Ps]) % (10 ** 9 + 7))



### FIXED CODE ###

from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
Ps = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
g = 1
for p in Ps:
    g = lcm(g,p)
ans = 0

print(sum([g // p for p in Ps]) % (10 ** 9 + 7))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
s = 0
mod = 10**9+7
for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        s += a[i]*a[j]
        s%=mod
print(s)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
k = 0
b = [0]*len(a)
ans = 0
for i in range(len(a)-1, 0, -1):
    k += a[i]
    k %= mod
    b[i] = k
for i in range(len(a)-1):
    ans += a[i] * b[i+1]
    ans %= mod

print(ans)
### BUGGY CODE ###

N,K = map(int, input().split())
A = [int(a) for a in input().split()]

n = 40
List = [-1]*n
for i in range(N):
    temp = bin(A[i])
    temp = temp[::-1]
    for j in range(n):
        if j < len(temp)-2:
            if List[j] == -1:
                List[j] = [int(temp[j])]
            else:
                List[j].append(int(temp[j]))
        else:
            if List[j] == -1:
                List[j] = [0]
            else:
                List[j].append(0)

ans_list = [0]*n
for i in range(n):
    if List[n-1-i].count(0)*2 > len(List[n-1-i]):
        ans_list[n-1-i] = 1
        num = 0
        for j in range(n):
            num += ans_list[j]*2**j
        if num > K:
            ans_list[n-1-i] = 0

X = 0
for k in range(n):
    X += ans_list[k]*2**k

ans = 0
for l in range(N):
    ans += (A[l]^X)

print(ans)

### FIXED CODE ###

N,K = map(int, input().split())
A = [int(a) for a in input().split()]

d = 50
L = [0]*d
for i in range(N):
    b = list(bin(A[i]))
    for j in range(2, len(b)):
        if b[j] == "1":
            L[len(b)-j-1] += 1

X0 = [0]*d
X1 = [0]*d
for i in range(d):
    X0[i] = 2**i*L[i]
    X1[i] = 2**i*(N-L[i])
    
ans = 0
    
Kb = list(bin(K))
for i in range(2, len(Kb)):
    if Kb[i] == "0":
        continue
    c = 0
    for j in range(2, len(Kb)):
        if j < i:
            if Kb[j] == "0":
                c += X0[len(Kb)-1-j]
            else:
                c += X1[len(Kb)-1-j]
        elif j == i:
            c += X0[len(Kb)-1-j]
        else:
            c += max(X0[len(Kb)-1-j], X1[len(Kb)-1-j])
    ans = max(ans, c)
    
for i in range(len(Kb)-2, d):
    ans += X0[i]
    
c = 0
for i in range(N):
    c += K^A[i]
    
ans = max(ans, c)
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = [[-1] * (N + 1) for i in range(100)]
A[0] = [0] + list(map(int, input().split()))


# nowから2**i先まで移動したとこ
def double(now, i):
    global A
    if A[i][now] != -1:
        return A[i][now]
    # nowから2**(i-1)移動して、そこからさらに2**(i-1)移動する
    A[i][now] = double(double(now, i - 1), i - 1)
    return A[i][now]


# nowからk移動した場所を求める
def rec(now, k):
    if k == 0:
        return now
    # if k == 1:
    #     return A[now]

    log2k = len(bin(k)) - 3
    return rec(double(now, log2k), k - 2 ** log2k)

print(rec(1, K))


### FIXED CODE ###

n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))

if A[1] == 1:
    print(1)
    exit()

# 訪問順
B = [1]

# 訪問済み
C = [False] * (n + 1)
C[1] = True


while True:
    B.append(A[B[-1]])
    if C[B[-1]]:
        break
    C[B[-1]] = True

# print(B)

s = B.index(B[-1])

# print(B)
# print(len(B))

if k < s:
    print(B[k])
    exit()


B = B[B.index(B[-1]):-1]
print(B[(k - s) % len(B)])
### BUGGY CODE ###

dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if h == eh and w == ew:
        dst[h][w] = d
        break

    if dst[h][w] >= 0 or S[h][w] == '#': continue
    if dst[h][w] == -1 or d < dst[h][w]: dst[h][w] = d

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.appendleft((nh, nw, d))

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.append((nh, nw, d+1))

print(dst[eh][ew])


### FIXED CODE ###

dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if 0 <= h < H and 0 <= w < W and dst[h][w] < 0 and S[h][w] != '#':
        dst[h][w] = d
    else:
        continue
    for i in range(4): dq.appendleft((h + dhw[i][0], w + dhw[i][1], d))
    for i in range(4, 24): dq.append((h + dhw[i][0], w + dhw[i][1], d+1))

print(dst[eh][ew])
### BUGGY CODE ###

from statistics import median
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    b = a.copy()
    b.remove(a[i])
    c = median(b)
    print(c)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = a.copy()
b.sort()
for i in range(n):
    if a[i] < b[n//2]:
        print(b[n//2])
    else:
        print(b[(n//2)-1])
### BUGGY CODE ###

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

ans = 0
for i,n1 in enumerate(l):
    for j,n2 in enumerate(l):
        if i < j:
            a1 = n1 + n2
        else:
            continue
        for k,n3 in enumerate(l):
            if j < k and n3 < a1:
                ans += 1
            else:
                continue
print(ans)


### FIXED CODE ###

import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)-2):
    for j in range(i+1, len(l)-1):
        a1 = l[i] + l[j]
        index = bisect.bisect_left(l, a1)
        if index:
            ans += index - j - 1
print(ans)
### BUGGY CODE ###

from collections import deque
def main():
    S = input()
    s = 0
    S_sum = deque([0])
    for i in range(len(S)):
        S_sum.append(s + int(S[len(S) - i - 1]) * 10**i)
        s += int(S[len(S) - i - 1]) * 10**i

    ans = 0
    for i in range(len(S_sum) - 1):
        for j in range(i + 4, len(S_sum)):
            if ((S_sum[j] - S_sum[i]) // 10**i) % 2019 == 0:
                ans += 1

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

S = input()
mod = 2019
count = [0] * 2019
count[0] = 1
tmp = 0
d = 1

for s in S[::-1]:
    tmp += int(s) * d
    count[tmp % mod] += 1
    d *= 10
    d %= mod

ans = 0

for c in count:
    ans += c * (c - 1) // 2
        
print(ans)
### BUGGY CODE ###

from collections import defaultdict

n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = [p - 1 for p in P]
SB = defaultdict(int)

sumC = sum(C) 

# if sumC > 0:
#   d, k = divmod(k, n)
#   if d > 0:
#     pscore = (d - 1) * sumC
#     k += n 
#   else:
#     pscore = 0
# else:
#   k = min(k, n * 2)
pscore = 0

for p in P: 
  cnt = 0
  score = 0
  mv = - 10 ** 19
  s = p
  while cnt < k:
    score += C[s]
    s = P[s]
    cnt += 1
    mv = max(mv, score)
  
  SB[p] = mv

ans = max(SB.values()) + pscore
print(ans)

### FIXED CODE ###

from collections import defaultdict

n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = [p - 1 for p in P]

# Pの要素の中で循環するモノ同士をまとめる
sep = []
visited = [0] * n
for i in range(n):
  s = i
  box = []
  while visited[s] == 0:
    box.append(s)
    visited[s] = 1
    s = P[s]
  if box != []:
    sep.append(box)

ans = - 10 ** 19
for sp in sep:
  SB = defaultdict(int)
  sumC = sum([C[i] for i in sp]) 
  sn = len(sp)

  if sumC > 0:
    d, mk = divmod(k, sn)
    if d > 0:
      pscore = (d - 1) * sumC
      mk += sn 
    else:
      pscore = 0
  else:
    mk = min(k, sn * 2)
    pscore = 0

  for p in sp: 
    cnt = 0
    score = 0
    mv = - 10 ** 19
    s = p
    while cnt < mk:
      score += C[s]
      s = P[s]
      cnt += 1
      mv = max(mv, score)
    
    SB[p] = mv

  ans = max(ans, max(SB.values()) + pscore)
  
print(ans)
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
cnt=1
for i in range(1,n):
    if p[i]<=min(p[:i]):
        cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
cnt=1
a=p[0]
for i in range(1,n):
    if p[i] <= a:
        a = p[i]
        cnt += 1
print(cnt)
### BUGGY CODE ###

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

import collections
c = collections.Counter(A)

for x in A:
    _ans = 0
    d = c.copy()
    d[x] -= 1
    _ans = sum([j*(j-1)//2 for j in d.values()])
    print(_ans)




### FIXED CODE ###

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

import collections
c = collections.Counter(A)
ans = sum([j*(j-1)//2 for j in c.values()])

for x in A:
    print(ans-(c[x]-1))
### BUGGY CODE ###

N=int(input())
an=list(map(int,input().split()))
l=[]
for i in range(1,N):
    x=sum(an[:i])
    y=sum(an[i:])
    l.append(abs(x-y))
print(min(l))


### FIXED CODE ###

N=int(input())
an=list(map(int,input().split()))
s=sum(an)
b = an[0]

l=[]
a = abs(s-2*b)
for i in range(1,N-1):
    b = b + an[i]
    a=min(a,abs(s-2*b))
print(a)
### BUGGY CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[];B=[]
retu=[[0]*N for _ in range(N)]
flg=[1]*N


for m in range(M):
  array=list(map(int,input().split()))
  A.append(array[0])
  B.append(array[1])

for m in range(M):
  retu[A[m]-1][B[m]-1]=1
  retu[B[m]-1][A[m]-1]=1

for k,n in enumerate(retu):
  for i,j in enumerate(n):
    if j==1:
      if H[k]<=H[i]:
        flg[k] =0

print(sum(flg))
  

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
flg=[1]*N


for m in range(M):
  a,b =map(int,input().split())
  if H[a-1]<H[b-1]:
    flg[a-1]=0
  elif H[a-1]>H[b-1]:
    flg[b-1]=0
  else:
    flg[a-1]=flg[b-1]=0
  
print(flg.count(1))
### BUGGY CODE ###

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

for i in range(len(A)):
    tmp = A.pop(i)
    print(max(A))
    A.insert(i, tmp)


### FIXED CODE ###

from collections import deque
n = int(input())
A = [int(input()) for _ in range(n)]
# ans = []
#
# for _ in range(n):
#     tmp = A.popleft()
#     print(max(A))
#     A.append(tmp)

# 時間がかかるのはソートだけ。
sorted_A = sorted(A, reverse=True)
max_val = sorted_A[0]
second_val = sorted_A[1]

for i in range(n):
    # 索引は速いらしい
    if A[i] != max_val:
        print(max_val)
    else:
        print(second_val)
### BUGGY CODE ###

N,M=map(int,input().split())
a=[int(input()) for i in range(M)]
dp=[0]*(N+1)
dp[0]=1
anlist=[]
inf=10**9+7
if 1 not in a:
  dp[1]=1
else:
  dp[1]=0
for i in range(2,N+1):
  if i in a:
    continue
  else:
    dp[i]=dp[i-1]+dp[i-2]
ans=dp[N]%inf
print(ans)

  

### FIXED CODE ###

N,M=map(int,input().split())
a=[int(input()) for i in range(M)]
a=set(a)
dp=[0]*(N+1)
dp[0]=1
anlist=[]
inf=10**9+7
if 1 not in a:
  dp[1]=1
else:
  dp[1]=0
for i in range(2,N+1):
  if i in a:
    continue
  else:
    dp[i]=dp[i-1]+dp[i-2]
ans=dp[N]%inf
print(ans)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline
X,Y,Z,K = map(int, readline().split())
A = sorted(list(map(int, readline().split())), reverse=True)
B = sorted(list(map(int, readline().split())), reverse=True)
C = sorted(list(map(int, readline().split())), reverse=True)

def f(thres:int)->bool:
    """return (おいしさが thres 以上の組み合わせ) >= K
    """
    global K
    cnt = 0
    for a in range(X):
        for b in range(Y):
            for c in range(Z):
                if A[a]+B[b]+C[c]<thres:
                    break
                cnt += 1
                if cnt >= K:
                    return True
    return False

def binary_search(f, s:int, t:int)->int:
    """f: function(x:int)->bool
    f(s)=False, f(t)=True，f は広義単調増加
    return : [s, t) での f(x)=True なる最小のx
    """
    ok = s-1
    ng = t
    while ng - ok > 1:
        mid = (ok + ng)//2
        if f(mid): ok = mid
        else:      ng = mid
        # print(ng, ok, ok-ng)

    if ok==s-1:
        raise(ValueError("For all x, f(x)=False"))
    return ok

M = A[0]+B[0]+C[0]
m = A[-1]+B[-1]+C[-1]
# print(f(m), f(M))
thres = binary_search(f, m, M+1)-1
# print("thres:",thres)
ans = []
for a in range(X):
    for b in range(Y):
        for c in range(Z):
            if A[a]+B[b]+C[c]<thres:
                break
            ans.append(A[a]+B[b]+C[c])

ans.sort(reverse=True)
print("\n".join(map(str, ans[:K])))


### FIXED CODE ###

import sys
readline = sys.stdin.readline
X,Y,Z,K = map(int, readline().split())
a = sorted(list(map(int, readline().split())), reverse=True)
b = sorted(list(map(int, readline().split())), reverse=True)
c = sorted(list(map(int, readline().split())), reverse=True)

ab = []
for ai in a:
    for bj in b:
        ab.append(ai+bj)
ab.sort(reverse=True)
ab = ab[:K]
cond = []
for abi in ab:
    for cj in c:
        cond.append(abi+cj)
cond = sorted(cond, reverse=True)[:K]
for condi in cond:
    print(condi)