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

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
if __name__ == "__main__":
  H, W = list(map(int, input().split()))
  all_count = H * W
  L = [j == "#" for i in range(H) for j in input()]
  blacks = [i for i in range(all_count) if L[i]]
  black_count = len(blacks)
 
  cands_H = [-W, W]
  cands_W = [-1, 1]
  result = 0
  while black_count < all_count:
    next_steps = [black+cand for black in blacks for cand in cands_H]
    next_steps.extend([black-1 for black in blacks if black%W != 0])
    next_steps.extend([black+1 for black in blacks if black%W != W-1])
    next_steps = set(next_steps)
    blacks = [i for i in next_steps if i >= 0 and i < all_count and not L[i]]
    black_count += len(blacks)
    result += 1
    if black_count >= all_count:
      break
    for i in blacks:
      L[i] = True
 
  print(result)

### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy

def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)

if __name__ == "__main__":
  main()
### BUGGY CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
from collections import deque
def run():
    N, M = map(int, sysread().split())
    to = [[] for _ in range(N+1)]
    AB = list(map(int, read().split()))
    A = AB[::2]
    B = AB[1::2]
    for a,b in zip(A,B):
        to[a].append(b)
        to[b].append(a)

    seen = [False] * (N+1)
    queue = deque([])
    seen[1] = True
    queue.append((1, 0))# (node, prev)
    mark = [0] * (N+1)

    while queue:
        current, prev = queue.popleft()
        if not seen[current]:
            seen[current] = True
            mark[current] = prev
        for next in to[current]:
            if not seen[next]:
                queue.append((next, current))

    print('Yes')
    mark = [str(val) for val in mark]
    print('\n'.join(mark[2:]))

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
from collections import deque
def run():
    N, M = map(int, sysread().split())
    to = [[] for _ in range(N+1)]
    AB = list(map(int, read().split()))
    A = AB[::2]
    B = AB[1::2]
    for a,b in zip(A,B):
        to[a].append(b)
        to[b].append(a)

    seen = [False] * (N+1)
    queue = deque([])
    seen[1] = True
    queue.append((1, 0))# (node, prev)
    mark = [0] * (N+1)

    while queue:
        current, prev = queue.popleft()
        for next in to[current]:
            if not seen[next]:
                queue.append((next, current))
                mark[next] = current
                seen[next] = True

    print('Yes')
    mark = [str(val) for val in mark]
    print('\n'.join(mark[2:]))

if __name__ == "__main__":
    run()
### BUGGY CODE ###

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]


V[C[0]][C[1]] = 0
pool = [tuple(C)]

while(pool):
    y, x = pool.pop()
    for dx, dy in [(-1,0),(1,0),(0,-1),(0,1)]:
        if y + dy < 0 or H <= y + dy:
            continue
        if x + dx < 0 or W <= x + dx:
            continue
        if S[y+dy][x+dx] == "#":
            continue
        if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
            V[y+dy][x+dx] = V[y][x]
            pool.append((y+dy, x+dx))
    for dx in [-2,-1,0,1,2]:
        for dy in [-2,-1,0,1,2]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                V[y+dy][x+dx] = V[y][x] + 1
                pool.append((y+dy, x+dx))

print(V[D[0]][D[1]])


### FIXED CODE ###

from collections import deque

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]

V[C[0]][C[1]] = 0

pool = deque()
pool.append(tuple([0, C[0], C[1]]))
while(pool):
    c, y, x = pool.popleft()
    if c != V[y][x]:
        continue
    for dx in [-2, -1, 0, 1, 2]:
        for dy in [-2, -1, 0, 1, 2]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if (dx, dy) in [(-1,0),(1,0),(0,-1),(0,1)]:
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
                    V[y+dy][x+dx] = V[y][x]
                    pool.appendleft((c, y+dy, x+dx))
            elif V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                V[y+dy][x+dx] = V[y][x] + 1
                pool.append((c+1, y+dy, x+dx))
print(V[D[0]][D[1]])
### BUGGY CODE ###

def main():
    # rankを出力、modを使って実装
    def matrix_rank(a, mod=10**9+7):
        n, m = len(a), len(a[0])
        M = [[j for j in i] for i in a]
        rank = min(n, m)
        for i in range(min(n, m)):
            if M[i][i] == 0:
                for j in range(i+1, n):
                    if M[j][i] != 0:
                        for k in range(i, m):
                            M[i][k] = (M[i][k]+M[j][k]) % mod
                        break
                else:
                    rank -= 1
            pinv = pow(M[i][i], mod-2, mod)
            for j in range(m):
                M[i][j] = M[i][j]*pinv % mod
            M2 = M[i]
            for j in range(i+1, n):
                M3 = M[j][i]
                M[j][i] = 0
                for k in range(i+1, m):
                    M[j][k] = (M[j][k]-M3*M2[k]) % mod
        return rank

    t = int(input())
    for _ in range(t):
        n = int(input())
        a = list(map(int, input().split()))
        s = input()
        r = 0
        m = []
        for i in range(n-1, -1, -1):
            ai = a[i]
            b = [[(ai >> j) & 1 for j in range(64)]]
            newr = matrix_rank(m+b)
            if s[i] == "0":
                if newr > r:
                    r += 1
                    m += b
            else:
                if newr > r:
                    print(1)
                    break
        else:
            print(0)


main()

### FIXED CODE ###

def main():
    t = int(input())
    for _ in range(t):
        nn, aa, s, r, mm = int(input()), list(map(int, input().split())), input(), 0, []
        for ii in range(nn-1, -1, -1):
            ai = aa[ii]
            mm += [[(ai >> jj) & 1 for jj in range(64)]]
            n, i, j = r+1, 0, 0
            while i < n and j < 64:
                if mm[i][j] == 1 and mm[n-1][j] == 0:
                    i += 1
                    j += 1
                    continue
                if mm[i][j] == 0:
                    if mm[n-1][j] != 0:
                        for l in range(j, 64):
                            mm[i][l] ^= mm[n-1][l]
                    else:
                        j += 1
                        continue
                M2 = mm[i]
                for k in range(i+1, n):
                    M3 = mm[k][j]
                    mm[k][j] = 0
                    for l in range(j+1, 64):
                        mm[k][l] ^= M3*M2[l]
                i += 1
                j += 1
    
            if s[ii] == "0":
                if i > r:
                    r += 1
                else:
                    mm.pop()
            else:
                mm.pop()
                if i > r:
                    print(1)
                    break
        else:
            print(0)


main()
### BUGGY CODE ###

H, N = map(int, input().split())
ls = []
x = 0
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
  if a>x:
    x = a

L = x+H+1
dp = [10**9]*L
dp[0] = 0
for i in range(L):
  for j in range(N):
    a, b = ls[j]
    if i>=a:
      dp[i] = min(dp[i], dp[i-a]+b)

ans = min(dp[H:])

print(ans)

### FIXED CODE ###

H, N = map(int, input().split())
ls = []
x = 0
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
  if a>x:
    x = a

L = x+H+1
dp = [10**9]*L
dp[0] = 0
for i in range(L):
  for j in range(N):
    a, b = ls[j]
    if i>=a:
      dp[i] = min(dp[i], dp[i-a]+b)

ans = min(dp[H:])

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

S = input()
Q = int(input())

ans = S
flag = 1
for i in range(Q):
    qry = list(input().split())

    if qry[0] == '1':
        if flag:
            flag = 0
        else:
            flag = 1
    
    elif qry[0] == '2':
        if flag:
            if qry[1] == '1':
                ans = qry[2] + ans
            else:
                ans += qry[2]
        else:
            if qry[1] == '1':
                ans += qry[2]
            else:
                ans = qry[2] + ans

if flag:
    print(ans)
else:
    print(ans[::-1])

### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())

flag = 1
for i in range(Q):
    qry = input().split()

    if qry[0] == '1':
        if flag:
            flag = 0
        else:
            flag = 1
    
    elif qry[0] == '2':
        if flag:
            if qry[1] == '1':
                S.appendleft(qry[2])
            else:
                S.append(qry[2])
        else:
            if qry[1] == '1':
                S.append(qry[2])
            else:
                S.appendleft(qry[2])

S = ''.join(S)

if flag:
    print(S)
else:
    print(S[::-1])
### BUGGY CODE ###

from collections import deque

def bfs(G, start):
    label[start] = start
    queue = deque()
    visited = [False] * (len(G))
    queue.append(start)
    while queue:
        target = queue.popleft()
        label[target] = start
        for j in G[target]:
            if visited[j] == False:
                visited[j] = True
                queue.append(j)
    visited = [k for k, x in enumerate(visited) if x ]
    return set(visited)

N, M, K = map(int, input().split())
F_G = [[] for _ in range(N)]
B_G = [[] for _ in range(N)]
label = [-1] * N
# 無向グラフの作成
for _ in range(M):
    a, b = map(int, input().split())
    F_G[a-1].append(b-1)
    F_G[b-1].append(a-1)
for _ in range(K):
    c, d = map(int, input().split())
    B_G[c-1].append(d-1)
    B_G[d-1].append(c-1)

sub = list(range(N))
for i in sub:
    can = list(range(N))
    can.pop(i) # 自分自身を友達候補から削除
    can = set(can)
    can -= set(B_G[i])     # ブロック関係にある人を友達候補から削除
    can -= set(F_G[i])     # 友達関係に既にある人を友達候補から削除
    if label[i] != -1:
        v = [l for l, x in enumerate(label) if x == label[i]]
        v = set(v)
    else:
        v = bfs(F_G, i)    # 友達グラフ上でつながっている友達をsetで取得
    can &= v               # 今の候補と積集合とって完成
    if i != N-1:
        print(len(can), end=" ")
    else:
        print(len(can))

### FIXED CODE ###

N,M,K = map(int,input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]

"""
Union-Find木実装のキモ(計算量削減)
1. Unionの工夫
   マージテク：大きい方を動かさずに小さい方をくっつける
2. Findの工夫
   経路圧縮 : 集合の要素を根に直接つなぎ変える.木をフラットにする.
"""

# Union-Findを用いて連結成分を考える(Union-Find木の実装)
class UnionFind:
    # まずは最初の状態を作る
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0

    # そのノードの根を返す過程で,集合の要素を根に直接つなぎかえる
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]

    # aとbの根が同じ,つまり同じ連結成分内かどうかを返す
    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    # 連結成分同士を効率的に(rankが大きい方を動かさずにrankが小さい方をくっつける)
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

blocks = [[] for _ in range(N)]
for c, d in CD:
    c, d = c-1, d-1
    blocks[c].append(d)
    blocks[d].append(c)

# friendsは友達の数を保持する
friends = [0] * N
uf = UnionFind(N)
for a,b in AB:
    a, b = a-1, b-1
    friends[a] += 1
    friends[b] += 1
    # aとbが同連結成分内であれば何もする必要がない
    if uf.is_same(a, b): continue
    # 異なれば結合
    uf.unite(a, b)

for i in range(N):
    uf.root(i)

from collections import Counter
ctr = Counter()
for i in range(N):
    r = uf.root(i)
    ctr[r] += 1

ans = []
for i in range(N):
    tmp = ctr[uf.root(i)] - friends[i] -1
    for b in blocks[i]:
        if uf.is_same(i, b):
            tmp -= 1
    ans.append(tmp)
print(*ans)
### BUGGY CODE ###

import collections
import math


def trial_division(n):
    l = []
    f = 2
    while n > 1:
        if (n % f == 0):
            l.append(f)
            n /= f
        else:
            f += 1
    return l


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

c = collections.Counter(trial_division(M))
a = 1
for i in c.values():
    a *= combinations_count(i + N - 1, i)

print(a % (10**9 + 7))

### FIXED CODE ###

import collections
from functools import reduce
from operator import mul


def trial_division(n):
    l = []
    f = 2
    while f * f <= n:
        if n % f == 0:
            l.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        l.append(n)
    return l


def combinations_count(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))


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

c = collections.Counter(trial_division(M))
a = 1
for i in c.values():
    a *= combinations_count(i + N - 1, i)

print(a % (10**9 + 7))
### BUGGY CODE ###

N = int(input()) 
A=list(map(int,input().split())) 
i=0 
s=[i for i in range(N)]
sumall=0
for i in range(N):
    s[i]=A.count(i+1)
    sumall=sumall+s[i]
    print(s[i])
    if sumall>=N-1:
        i=i+1
        break
for _ in range(i,N):
    print(0)

### FIXED CODE ###

import collections
n = int(input())
base = map(int,input().split())
c = collections.Counter(base)
for i in range(1,n):
    print(c[i])
print(0)
### BUGGY CODE ###

N = int(input())
s = [int(input()) for _ in range(N)]
ans = 0
for i in range(1<<N):
    total = 0
    for j in range(N):
        if (i>>j)&1:
            total += s[j]
    if total%10 != 0:
        ans = max(ans,total)
print(ans)

### FIXED CODE ###

N = int(input())
s = [int(input()) for _ in range(N)]
t = [x for x in s if x%10 != 0]
total = sum(s)
if total%10 != 0:
    print(total)
else:
    if len(t) == 0:
        print(0)
    else:
        print(total-min(t))
### BUGGY CODE ###

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

for i in range(n):
  kkk = ( 1<<(a[i]-1) ) -1
  if bit&kkk == 0:
    ans += 1
  bit += 1<<(a[i]-1)
  
    
  
print(ans)




### FIXED CODE ###

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

#from bisect import bisect_left,bisect_right
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

num=[0]*30
def f(L,k):
    t=0
    s=len(L)-1
    if L[t]>=k:
        return 0
    if L[s]<k:
        return s+1
    while s-t>1:
        a=(s+t)//2
        if k>L[a]:
            t=a
        else:
            s=a
    return s
for i in range(30):
    t = pow(2,i)
    K=[i%(2*t) for i in A]
    L=[i%(2*t) for i in B]
    L.sort()
    #print(K,L)
    a = 0
    for k in K:
        x = f(L,2*t-k)-f(L,t-k)
        y = f(L,4*t-k)-f(L,3*t-k)
        #print(x,y)
        a =(a+x+y)%2
    num[i]=a
ans =0
s=1
for z in num:
    ans += z*s
    s*=2
print(ans)



### FIXED CODE ###

from bisect import bisect_left,bisect_right
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

num=[0]*30
for i in range(30):
    t = pow(2,i)
    K=sorted(i%(2*t) for i in A)
    L=sorted(i%(2*t) for i in B)
    #L=sort()
    #print(K,L)
    a = 0
    #尺取り法,i*tより小さい整数を数える
    S=[i*t for i in range(1,5)]
    count=[N]*4
    for k in K:
        for j in range(4):
            while L[count[j]-1]+k>=S[j] and count[j]>0:
                count[j]-=1
        a +=count[3]-count[2]+count[1]-count[0]
        #print(count,a)
    num[i]=a%2
ans =0
s=1
for z in num:
    ans += z*s
    s*=2
print(ans)
### BUGGY CODE ###

S=input()
q=int(input())
s=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or int(qv[1])^t==2:
            s.insert(0,qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
ans=''.join(s)
print(ans)

### FIXED CODE ###

S=input()
q=int(input())
s=[]
r=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or int(qv[1])^t==2:
            r.append(qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
    ans=s
    ans.extend(r)
else:
    rr=r.copy()
    r=[]
    for j in range(len(rr)):
        r.append(rr[-1-j])
    ans=r
    ans.extend(s)
answer=''.join(ans)
print(answer)
### BUGGY CODE ###

a, b = map(int, input().split())
ans = 1
for i in range(a , b + 1):
    ans *= i

if ans > 0:
    print("Positive")
elif ans < 0:
    print("Negative")
elif ans == 0:
    print("Zero")

### FIXED CODE ###

a, b = map(int, input().split())
c = b - a
if a <= 0 <= b:
    print("Zero")
 
elif a > 0:
    print("Positive")
 
elif b < 0:
    if c % 2 == 1:
        print("Positive")
    else:
        print("Negative")
### BUGGY CODE ###

N, H = ( int(i) for i in input().split() )
ka = []
kb = []
for i in range(N):
	a, b = ( int(i) for i in input().split() )
	ka.append(a)
	kb.append(b)
	
kb.sort()
kb.reverse()

hp = H
res = 0
for b in kb:
	if b < max(ka):
		continue
	hp = hp - b
	res += 1
	if hp <= 0:
		break
else:
	res += (hp + max(ka) - 1)//max(ka)
	
print(res)
		

### FIXED CODE ###

N, H = ( int(i) for i in input().split() )
ka = []
kb = []
for i in range(N):
	a, b = ( int(i) for i in input().split() )
	ka.append(a)
	kb.append(b)
	
kb.sort()
kb.reverse()
ma = max(ka)

hp = H
res = 0
for b in kb:
	if b < ma:
		continue
	hp = hp - b
	res += 1
	if hp <= 0:
		break
else:
	res += (hp + ma - 1)//ma
	
print(res)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
INF = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        ans += (A[i]^A[j]) % INF
        ans %= INF
print(ans)

### FIXED CODE ###

import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    A = NLI()
    B = [[0]*2 for _ in range(62)]
    for a in A:
        for i in range(62):
            B[i][(a >> i) & 1] += 1
    ans = 0
    for i, b in enumerate(B):
        ans += b[0] * b[1] * pow(2, i, MOD)
    print(ans % MOD)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

### FIXED CODE ###

n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])
### BUGGY CODE ###

from numpy import median
from copy import deepcopy

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

for i in range(n):
    newl = deepcopy(x)
    del newl[i]
    print(int(median(newl)))


### FIXED CODE ###

from numpy import median
from copy import deepcopy

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

sx = sorted(x)
newl = deepcopy(sx)
del newl[0]
maxm = median(newl)
newl = deepcopy(sx)
del newl[-1]
minm = median(newl)

med = median(x)

for i in x:
    if i > med:
        print(int(minm))
    else:
        print(int(maxm))
### BUGGY CODE ###

n = int(input())
l = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    calc = l[:i+1]
    if l[i] == min(calc):
        ans += 1
        
print(ans)
    


### FIXED CODE ###

import numpy as np
n = int(input())
l = np.array([int(i) for i in input().split()])

q = np.minimum.accumulate(l)
ans = np.count_nonzero(l <= q)

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

import numpy as np
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
T = [0, 0] + T + [0]
V = [0] + V + [0]
accT = np.cumsum(T)
INF = 10 ** 9

t2_max = accT[-1] * 2
speeds = np.ones(t2_max + 1) * INF
for t0, t1, v in zip(accT[:-1], accT[1:], V):
    sptmp = np.ones(t2_max + 1) * v
    for t2 in range(0, t0 * 2):
        sptmp[t2] += t0 - t2 * 0.5
    for t2 in range(t1 * 2, t2_max + 1):
        sptmp[t2] += t2 * 0.5 - t1
    speeds = np.minimum(speeds, sptmp)

ans = sum(speeds) / 2

print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
T = [0, 0] + T + [0]
V = [0] + V + [0]
accT = np.cumsum(T)
INF = 10 ** 9

t2_max = accT[-1] * 2
speeds = np.ones(t2_max + 1) * INF
for t0, t1, v in zip(accT[:-1], accT[1:], V):
    sptmp = np.ones(t2_max + 1) * v
    sptmp[:t0 * 2] += np.arange(t0, 0, -0.5)
    sptmp[t1 * 2:] += np.arange(0, accT[-1] - t1 + 0.5, 0.5)
    speeds = np.minimum(speeds, sptmp)

ans = sum(speeds) / 2

print(ans)