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

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
n = int(input())
A = []
ans = 0
nodes = set()
adjacent_list = defaultdict(list)
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in range(1, len(tmp)):
        l, g = min(i, tmp[j] - 1), max(i, tmp[j] - 1 )
        pre_l, pre_g = min(i, pre), max(i, pre) 
        adjacent_list[pre_l * n + pre_g].append(l * n + g)
        nodes.add(pre_l * n + pre_g)
        nodes.add(l * n + g)
        pre = tmp[j] - 1
nodes = list(nodes)
#まず、閉路検
seen = [False for i in range((n + 2) * n)]
visited = [False for i in range((n + 2) * n)]
def check(node):
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if len(adjacent_list[node]) == 0:
        return 1
    if node in finish:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = max(tmp, finish[node])
    return finish[node]
finished = set()
for i in nodes:
    check(i)
finish = defaultdict(int)
for i in nodes:
    dfs_path(i)
print(max(max(finish.values()), 1))

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n = int(input())
A = []
M = [[-1 for _ in range(n)] for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        M[i][j] = cnt
        M[j][i] = cnt
        cnt += 1
ans = 0
nodes = []
adjacent_list = [[] for i in range(n*(n-1)//2)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in tmp[1:]:
        adjacent_list[M[i][pre]].append(M[i][j-1])
        pre = j - 1
#まず、閉路検
seen = defaultdict(lambda: False)
visited = defaultdict(lambda: False)
def check(node):
    if visited[node]:
        return
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if not adjacent_list[node]:
        return 1
    if finish[node]:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = tmp
    return finish[node]
finished = set()
finish = [0 for i in range(n*(n-1)//2)]
for i in range(n*(n-1)//2):
    check(i)
    dfs_path(i)
print(max(max(finish), 1))
### BUGGY CODE ###

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

a.sort(key=lambda x: -x)
i = 0
p = []
while len(a) != 0:
    i = a.pop()
    if i in a:
        a.remove(i)
        while i in a:
            a.remove(i)
        continue
    p.append(i)
    a2 = []
    for ai in a:
        if ai % i != 0:
            a2.append(ai)
    a = a2

print(len(p))

### FIXED CODE ###

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

a.sort()
mx = a[-1]

dp = [True for _ in range(mx)]

cnt = 0
for i, ai in enumerate(a):
    if dp[ai-1]:
        if i >= len(a)-1 or ai != a[i+1]:
            cnt += 1
        for j in range(ai - 1, mx, ai):
            dp[j] = False

print(cnt)
### BUGGY CODE ###

mod=10**9+7
def mul(a,b):
    x,y=a,b
    return (x*y)%mod

H,W,K=map(int,input().split())
mod=10**9+7
ans=0
const=1
for i in range(H+W-1,H+W-K,-1):
    const=(const*i)%mod

inv=pow(H+W-1,mod-2,mod)
for i in range(K):
    #ans+=(K-i)*(((H+W)*const)%mod)+(((K-i)*i*const)%mod)*((inv*2*H*W)%mod)
    #ans%=mod
    temp1=mul(mul(H+W,const),K-i)
    ans=(ans+temp1)%mod
    temp2=mul(inv,mul(2*H*W,mul((K-i)*i,const)))
    ans=(ans+temp2)%mod
ans+=mul(K,mul(H+W,const))
ans%=mod
print(ans)


### FIXED CODE ###

mod=10**9+7
def mul(a,b):
    x,y=a,b
    return (x*y)%mod

H,W,K=map(int,input().split())
mod=10**9+7
ans=0
const=1
for i in range(H+W-1,H+W-K,-1):
    const=(const*i)%mod

inv=pow(H+W-1,mod-2,mod)
temp1=mul(H+W,mul((K*(K+1)//2)%mod,const))
const=mul(const,inv)
u=(K*(K**2-1))//6
u%=mod
temp2=mul(2*H*W,mul(u,const))
ans=(temp1+temp2)%mod
const=mul(const,H+W-1)
ans+=mul(K,mul(H+W,const))
ans%=mod
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
bc.sort(reverse=True, key=lambda x: x[1])

for i in range(min(n, m)):
    a.extend([bc[i][1]]*bc[i][0])

a.sort(reverse=True)
print(sum(a[:n]))


### FIXED CODE ###

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
bc.sort(reverse=True, key=lambda x: x[1])

bcs = []
for b, c in bc:
    if len(bcs) > n: break
    bcs.extend([c]*b)

a.extend(bcs)
a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

# given an array of Heights, jump from 1 to N with at most K sized jump to N
# each jump incurs abs(H[j] - H[i]) cost
# minimize cost of jumps from 1 to N
#
import collections
def frog(H, k):
    K = collections.deque([0] * (k + 1))
    n = len(H)
    for i in range(n):
        cost = 0
        if i > 0:
            maxjump = min(i, k)
            cost = min([abs(H[i] - H[i - j]) + K[len(K) - j] for j in range(1, maxjump + 1)])
        K.append(cost)
        K.popleft()
    return cost

assert frog([40, 10, 20, 70, 80, 10, 20, 70, 80, 60], 4) == 40
assert frog([10, 10], 100) == 0
assert frog([10, 20, 10], 1) == 20

import sys
s = sys.stdin.read()
l1, l2 = s.splitlines()

N, k = map(int, l1.split())
H = [int(x) for x in l2.split()]
ans = frog(H, k)
print(ans)


### FIXED CODE ###

# given an array of Heights, jump from 1 to N with at most K sized jump to N
# each jump incurs abs(H[j] - H[i]) cost
# minimize cost of jumps from 1 to N
#
def frog(H, k):
    if k > len(H):
        k = len(H)
    n = len(H)
    K = [0] * n
    inf = float("inf")
    for i in range(n):
        cost = 0
        if i > 0:
            maxjump = i if i < k else k # min(i, k)
            cost = inf
            hi = H[i]
            # jump source going backwards from i-1 (smallest 1 sized jump) to i - maxjumps
            for j in range(i - 1, i - maxjump - 1, -1):
                jcost = abs(hi - H[j]) + K[j]
                if jcost < cost:
                    cost = jcost
        K[i] = cost
    return cost

assert frog([40, 10, 20, 70, 80, 10, 20, 70, 80, 60], 4) == 40
assert frog([10, 10], 100) == 0
assert frog([10, 20, 10], 1) == 20

if __name__ == "__main__":
    import sys
    s = sys.stdin.read()
    N, k, *H = map(int, s.split())
    ans = frog(H, k)
    print(ans)
### BUGGY CODE ###

from sys import stdin
import fractions
 
 
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
 
res = []
 
for i in range(N):
    if i == 0:
        gcd_num = A[1]
    else:
        gcd_num = A[0]
    for j in range(N):
        if j == i:
            continue
        gcd_num = fractions.gcd(gcd_num, A[j])
    res.append(gcd_num)
        
 
 
print(max(res))

### FIXED CODE ###

from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
# インデックスを直感で使えるように先頭にダミーを入れる
A = [0] + A

"""
L(i) := A_1, A_2, ..., A_i-1 の最大公約数
R(i) := A_i, A_i+1, ..., A_N の最大公約数
Aiを書き換えることにした場合の最大公約数をM_iとすると
M_i = gcd(L(i), R(i+1))

ただし L(0)=0, R(N+1)=0
"""

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+2)]

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


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

M = []

for i in range(1, N+1):
    M_i = fractions.gcd(L[i], R[i+1])
    M.append(M_i) 

print(max(M))
### BUGGY CODE ###

X=int(input())
B=0
while(True):
    A=X+B**5
    A=int(A)
    if A**5-B**5==X :
        print(A,B)
        exit()
    B-=1

### FIXED CODE ###

X=int(input())
B=0
for i in range(-118,120):
    for j in range(-119,119):
        if X==i**5-j**5:
            print(i,j)
            exit()
### BUGGY CODE ###

N, P = map(int, input().split())
S = input()
total = 0
if P == 2:
  for idx, right_value in enumerate(S, 1):
    if int(int(right_value)%2==0):
      total += idx
elif P == 5:
  valid_options = (0, 5)
  for idx, right_value in enumerate(S, 1):
    if int(int(right_value) in valid_options):
      total += idx
else:
  histo_modsuffix = [0]*P
  for i in range(1, N+1):
    histo_modsuffix[int(S[-i:])%P] += 1
  total = 0
  for val in histo_modsuffix:
    total += val*(val-1)//2
  total += histo_modsuffix[0] # when right hand side is at far end
print(total)

### FIXED CODE ###

N, P = map(int, input().split())
S = input()
total = 0
if P == 2:
  for idx, right_value in enumerate(S, 1):
    if int(int(right_value)%2==0):
      total += idx
elif P == 5:
  valid_options = (0, 5)
  for idx, right_value in enumerate(S, 1):
    if int(int(right_value) in valid_options):
      total += idx
else:
  histo_modsuffix = [0]*P
  previous = 0
  for i, val in enumerate(reversed(S)):
    scale = pow(10, i, P)
    new_val = (previous + scale*int(val))%P
    histo_modsuffix[new_val] += 1
    previous = new_val
  for val in histo_modsuffix:
    total += val*(val-1)//2
  total += histo_modsuffix[0] # when right hand side is at far end
print(total)
### BUGGY CODE ###

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

for i in range(N):
    Xc = X.copy()
    del Xc[i]
    Xc.sort()
    print(Xc[(N-1)//2])


### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
Xc = X.copy()
Xc.sort()

Xcmed = Xc[N//2]

for i in range(N):
    if X[i] < Xcmed:
        print(Xc[N // 2])
    else:
        print(Xc[N // 2 - 1])
### BUGGY CODE ###

import sys
def solve():
    N, K = map(int, input().split(" "))
    heights = [int(c) for c in input().split(" ")]
    dp = [sys.maxsize] * N
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K+1):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i-j] + abs(heights[i] - heights[i-j]))
            else:
                break
    print(dp[N-1])
solve() 

### FIXED CODE ###

import sys
def solve():
    N, K = map(int, input().split(" "))
    heights = [int(c) for c in input().split(" ")]
    dp = [sys.maxsize] * N
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K+1):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i-j] + abs(heights[i] - heights[i-j]))
            else:
                break
    print(dp[N-1])
solve()
### BUGGY CODE ###

N,W = map(int,input().split())
dp = [0]*(W+1)
for i in range(N):
    w,v = map(int,input().split())
    for i in range(W,w-1,-1):
        dp[i] = max(dp[i],dp[i-w]+v)
print(dp[-1])

### FIXED CODE ###

N,W = map(int,input().split())
dp = [0]*(W+1)
for i in range(N):
    w,v = map(int,input().split())
    for i in range(W,w-1,-1):
        dp[i] = max(dp[i],dp[i-w]+v)
print(dp[-1])
### BUGGY CODE ###

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=998244353):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer


N, M, K = map(int, input().split())
mod = 998244353
ans = 0
for i in range(K+1):
    ans += pow(M-1, N-1-i, mod) * nCk(N-1, i)
    ans %= mod
ans *= M
print(ans%mod)

### FIXED CODE ###

mod = 998244353
max = (10**5)*2 + 1
facts = [1 for i in range(max)]
invs = [1 for i in range(max)]
 
def inv(x):
    return pow(x,mod-2,mod)
 
for i in range(1,max):
    facts[i] = facts[i-1]*i%mod
    invs[i] = inv(facts[i])
 
def nCk(n,r):
    return facts[n]*invs[r] * invs[n-r] % mod



N, M, K = map(int, input().split())
ans = 0
for i in range(K+1):
    ans += pow(M-1, N-1-i, mod) * nCk(N-1, i)
    ans %= mod
ans *= M
print(ans%mod)
### BUGGY CODE ###

N, P = map(int, input().split())
S = [int(_) for _ in list(input())]
if P == 2 or P == 5:
    ans = 0
    for n in range(N):
        if S[n] % P == 0:
            ans += n + 1
    print(ans)
else:
    S = [(S[n] * 10**(N - n - 1)) % P for n in range(N)]
    S.reverse()
    T = [0]
    for s in S:
        T.append((T[-1] + s) % P)
    lst = {i: 0 for i in range(P)}
    ans = 0
    for t in T:
        ans += lst[t]
        lst[t] += 1
    print(ans)


### FIXED CODE ###

N, P = map(int, input().split())
S = [int(_) for _ in list(input())]
if P == 2 or P == 5:
    ans = 0
    for n in range(N):
        if S[n] % P == 0:
            ans += n + 1
    print(ans)
else:
    S = [(S[n] * pow(10, N - n - 1, P)) % P for n in range(N)]
    S.reverse()
    T = [0]
    for s in S:
        T.append((T[-1] + s) % P)
    lst = {i: 0 for i in range(P)}
    ans = 0
    for t in T:
        ans += lst[t]
        lst[t] += 1
    print(ans)
### BUGGY CODE ###

import sys

def makePuzzle():
    count_Scc = 0
    tmp = sys.stdin.readlines()
    num_s, num_c = tmp[0].split(" ")
    num_s = int(num_s)
    num_c = int(num_c)

    while num_s>=0 and num_c>=0:

        if num_s>=1 and num_c>=2:
            num_s = num_s - 1
            num_c = num_c - 2
            count_Scc = count_Scc + 1
        elif num_c>=4:
            num_c = num_c - 4
            count_Scc = count_Scc + 1
        else:
            break

    return count_Scc

if __name__=="__main__":
    print(makePuzzle())

### FIXED CODE ###

import sys

def makePuzzle():
    count_Scc = 0
    tmp = sys.stdin.readlines()
    num_s, num_c = tmp[0].split(" ")
    num_s = int(num_s)
    num_c = int(num_c)

    if num_c-num_s*2>=0:
        count_Scc = num_s
        num_c = num_c - num_s*2
        count_Scc = count_Scc + num_c//4
    else:
        count_Scc = num_c//2

    return count_Scc

if __name__=="__main__":
    print(makePuzzle())
### BUGGY CODE ###

import math
from itertools import accumulate

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

g = []
gcd = []

for i in range(n):
  r = a[i]
  a.remove(r)
  gcd = accumulate(a, math.gcd)
  g.append(min(gcd))
  a.insert(i, r)

print(max(g))

### FIXED CODE ###

import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[n-2])

if n == 2:
  print(max(a))
else:
  print(max(gcd))
### BUGGY CODE ###

from fractions import gcd

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

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


lcm_ = A[0]
for a in A[1:]:
    lcm_ = lcm(lcm_, a)

ans = 0
for a in A:
    ans = (ans + lcm_ // a) % (10 ** 9 + 7)

print(ans)

### FIXED CODE ###

from fractions import gcd

M = 10 ** 9 + 7

def xgcd(a, b):
    x0, x1 = 1, 0
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
    return x0 % M

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

lcm_ = A[0]
for a in A[1:]:
    lcm_ = lcm_ * a // gcd(lcm_, a)

ans = 0
for a in A:
    m = xgcd(a, M)
    ans = ans + lcm_ * m

print(ans % M)
### BUGGY CODE ###

def main():
  _max = max
  s = input()
  t = input()
  slen = len(s)
  tlen = len(t)
  dp = [[0 for j in range(tlen + 1)] for i in range(slen + 1)]
  for i in range(slen):
    dpi = dp[i]
    dpi1 = dp[i + 1]
    si = s[i]
    for j in range(tlen):
      j1 = j + 1
      if si == t[j]:
        dpi1[j1] = dpi[j] + 1
      else:
        dpi1[j1] = _max(            dpi1[j], dpi[j1])
  result = ''
  i = slen
  j = tlen
  while i > 0 and j > 0:
    if dp[i - 1][j] == dp[i][j]:
      i -= 1
    elif dp[i][j - 1] == dp[i][j]:
      j -= 1
    else:
      result = s[i - 1] + result
      i -= 1
      j -= 1
  print(result)
main()


### FIXED CODE ###

s = input()
t = input()
slen = len(s)
tlen = len(t)
dp = [[0 for j in range(tlen + 1)] for i in range(slen + 1)]
for i in range(slen):
  for j in range(tlen):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
result = ''
i = slen
j = tlen
while i > 0 and j > 0:
  if dp[i - 1][j] == dp[i][j]:
    i -= 1
  elif dp[i][j - 1] == dp[i][j]:
    j -= 1
  else:
    result = s[i - 1] + result
    i -= 1
    j -= 1
print(result)
### BUGGY CODE ###

n = int(input())
ar = [[] for i in range(n)]
for i in range(n-1):
    ipt = list(map(int,input().split()))
    ar[ipt[0]-1].append([ipt[1]-1,ipt[2]])
    ar[ipt[1]-1].append([ipt[0]-1,ipt[2]])

ans = [[] for i in range(n)]
u = 0
ans[u] = 0
queue = [u] #キュー
check = [False]*n #訪問済み
check[u] = True
l = 1
while True:
    if l == 0:
        break
    u = queue.pop(0)
    l -= 1
    for v in ar[u]:
        if not check[v[0]]:
            check[v[0]] = True
            ans[v[0]] = ans[u] + v[1]
            queue.append(v[0])
            l+=1

for i in range(n):
    print(ans[i]%2)

### FIXED CODE ###

n = int(input())
ar = [[] for i in range(n)]
for i in range(n-1):
    ipt = list(map(int,input().split()))
    ar[ipt[0]-1].append((ipt[1]-1,ipt[2]))
    ar[ipt[1]-1].append((ipt[0]-1,ipt[2]))

ans = [-1 for i in range(n)]
u = 0
ans[u] = 0
queue = [u] #キュー
l = 1
while True:
    if l == 0:
        break
    u = queue.pop(0)
    l -= 1
    for v in ar[u]:
        if ans[v[0]] < 0:
            ans[v[0]] = ans[u] + v[1]
            queue.append(v[0])
            l+=1

for i in range(n):
    print(ans[i]%2)
### BUGGY CODE ###

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

def intinp():
    return int(input())

import itertools
from pprint import pprint

N, K = mapint_inp()
l = list(range(N+1))
r = l[::-1]
ans = 0
while(K < N+2):
    mn = sum(l[:K])
    mx = sum(r[:K])
    ans += mx-mn+1
    K+=1

print(ans)

### FIXED CODE ###

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

def intinp():
    return int(input())

N, K = mapint_inp()
MOD = 10**9+7

ans = 0
for i in range(K, N+2):
    mn = i*(i-1) // 2
    mx = i*(2*N-i+1) // 2
    ans += mx - mn + 1

print(ans%MOD)
### BUGGY CODE ###

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

AB = []

for i in range(N) : 
    tmp_AB = [int(i) for i in input().split()]
    AB.append(tmp_AB)
    
P_list = []

for i in range(N) : 
    for j in range(AB[i][1]) : 
        P_list.append(AB[i][0])

P_list_sorted = sorted(P_list)

sum = 0

for i in range(M) : 
    sum += P_list_sorted[i]
    
print(sum)

### FIXED CODE ###

N,M = map(int, input().split())
 
AB = []
 
for i in range(N) : 
    tmp_AB = [int(i) for i in input().split()]
    AB.append(tmp_AB)
    
P = sorted(AB)
 
sum = 0
cnt = 0 # Mに達したら終了

for i in range(len(P)) : 
    for j in range(P[i][1]) : 
        if cnt < M: 
            sum += P[i][0]
            cnt += 1
        else :
            break
        
    if cnt >= M : 
        break
    
print(sum)
### BUGGY CODE ###

N=list(map(int,input().split(" ")))
answer=[input() for i in range(N[2])]	
X=list(map(int,answer))
#print(X)

point=[]
for i in range(N[0]):
	point.append(N[1])

def down(y):
	return y-1

for i in X:
	point=list(map(down,point))
	point[i-1]+=1
#print(point)
for i in range(N[0]):
	if point[i]>0:
		print("Yes")
	else:
		print("No")
 

### FIXED CODE ###

N=list(map(int,input().split(" ")))
ans=[int(input()) for i in range(N[2])]	

point=[N[1]-N[2] for i in range(N[0])]

for i in ans:
	point[i-1]+=1
#print(point)
for i in range(N[0]):
	if point[i]>0:
		print("Yes")
	else:
		print("No")
### BUGGY CODE ###

n = int(input())
s = input()

dp = [[0 if max(i,j) == n else -1 for i in range(n+1)] for j in range(n+1)]

ans = 0
for i in range(n-1, -1, -1):
    for j in range(n-1, i, -1):
        if s[i] == s[j]:dp[i][j] = dp[i+1][j+1] + 1
        else: dp[i][j] = 0
        ans = max(ans, min(dp[i][j], j-i))

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

A = 1234567
MOD = 10000000000000007

def ok(length):
    rolling_hash = 0
    head = pow(A, length, MOD)
    occurence = {}
    for i in range(n):
        rolling_hash = (rolling_hash * A + ord(s[i])) % MOD
        if i - length >= 0:
            rolling_hash = (rolling_hash - head * ord(s[i-length])) % MOD
        if rolling_hash not in occurence:
            occurence[rolling_hash] = []
        occurence[rolling_hash].append(i)

    for key in occurence:
        if occurence[key][-1] - occurence[key][0] >= length:
            return True
    return False

bottom, top = 0, n

while top - bottom > 1:
    mid = (top + bottom) // 2
    if ok(mid):bottom = mid
    else: top = mid

print(bottom)
### BUGGY CODE ###

def resolve():
	n=int(input())
	x=list(map(int,input().split()))
	for i in x:
		s=sorted(x)
		s.remove(i)
		print(s[(n-2)//2])
	
resolve()

### FIXED CODE ###

def resolve():
	n=int(input())
	x=list(map(int,input().split()))
	s=sorted(x)
	m=s[(n-2)//2]
	for i in x:
		ans=s[(n-2)//2+1] if i<=m else m
		print(ans)
	
resolve()
### BUGGY CODE ###

H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for i in range(H)]
ans=H+W-2
for bit in range(2**(H-1)):
    divH=[0]
    for j in range(H-1):
        if(bit>>j&1):
            divH.append(j+1)
    divH.append(H)
    glen=len(divH)-1
    group=[0]*(glen)
    res=glen-1
    go=True
    w=0
    while w<W:
        ok=True
        c=[0]*(glen)
        for g in range(glen):
            cum=0
            for h in range(divH[g],divH[g+1]):
                if cum>K:
                    go=False
                cum+=S[h][w]
            c[g]+=cum
            if cum+group[g]>K:
                ok=False
        if not go:
            break
        if not ok:
            res+=1
            group=[0]*glen
        else:
            for i in range(glen):
                group[i]+=c[i]
            w+=1
    if not go:
        continue
    ans=min(ans,res)
print(ans)

### FIXED CODE ###

H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for i in range(H)]
ans=H+W-2
for bit in range(2**(H-1)):
    divH=[0]
    for j in range(H-1):
        if(bit>>j&1):
            divH.append(j+1)
    divH.append(H)
    glen=len(divH)-1
    group=[0]*(glen)
    res=glen-1
    go=True
    w=0
    while w<W:
        ok=True
        c=[0]*(glen)
        for g in range(glen):
            cum=0
            for h in range(divH[g],divH[g+1]):
                cum+=S[h][w]
            c[g]+=cum
            if cum>K:
                go=False
                break
            if c[g]+group[g]>K:
                ok=False
        if not go:
            break
        if not ok:
            res+=1
            group=[0]*glen
        else:
            for i in range(glen):
                group[i]+=c[i]
            w+=1
    if not go:
        continue
    ans=min(ans,res)
print(ans)
### BUGGY CODE ###

N = int(input())
A = input().split()

result = 1
length = len(A)

for num in range(length):
    result = result * int(A[num])

if result <= 10 ** 18:
    print(result)
else:
    print("-1")

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) #配列を昇順ソートしておく(配列に0がある場合0が先頭に来るので、場合分けの必要がなくなる)
ans=1
for val in arr:
 ans*=val #Pythonは多倍長整数をサポートしているので単に積を求めれば十分
 if ans>10**18:
   print(-1)
   break
else:
 print(ans)
### BUGGY CODE ###

[N, K, Q] = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [K for i in range(N)]
for i in range(Q):
    for j in range(N):
        if j != A[i]-1:
            B[j] -= 1
for i in range (N):
    if B[i] <=0:
        print('No')
    else:
        print('Yes')


### FIXED CODE ###

[N, K, Q] = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [0 for i in range(N)]
for i in range(Q):
    B[A[i]-1] += 1
for i in range(N):
    if K + B[i] - Q > 0:
        print('Yes')
    else:
        print('No')