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

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect


def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    # big value
    INF = int(1e15)
    distance = [[INF] * W for _ in range(H)]

    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                distance[h][w] = 0

    for h in range(H):
        for w in range(W-1):
            distance[h][w + 1] = min(distance[h][w + 1], distance[h][w] + 1)
        for w in range(W - 1, 0, -1):
            distance[h][w - 1] = min(distance[h][w - 1], distance[h][w] + 1)

    for w in range(W):
        for h in range(H-1):
            distance[h + 1][w] = min(distance[h + 1][w], distance[h][w] + 1)
        for h in range(H - 1, 0, -1):
            distance[h - 1][w] = min(distance[h - 1][w], distance[h][w] + 1)

    ans = 0
    # print(distance)
    for h in range(H):
        ans = max(ans, max(distance[h]))

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect


def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]

    checked = [[False] * W for _ in range(H)]
    ans = 0

    que = []
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#' and not checked[h][w]:
                que.append((h, w))
                checked[h][w] = True
    while que:
        next_que = []
        while que:
            h, w = que.pop()
            dx4 = [0, 0, 1, -1]
            dy4 = [1, -1, 0, 0]

            for dx, dy in zip(dx4, dy4):
                next_h = h + dy
                next_w = w + dx
                if 0 <= next_h < H and 0 <= next_w < W and A[next_h][next_w] == '.' and not checked[next_h][next_w]:
                    A[next_h][next_w] = '#'
                    checked[h][w] = True
                    next_que.append((next_h, next_w))
        que = next_que
        if que:
            ans += 1

    print(ans)


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

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

if B > N:
    print(A*N//B)
else:
    L = []
    for x in range(B-1,N):
        L.append(A*x//B-A*(x//B))
    print(max(L))

### FIXED CODE ###

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

if B > N:
    print(A*N//B)
else:
    print(A*(B-1)//B)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans = 1
for i in range(N):
    ans *= A[i]
    if ans >> 10**18:
        break
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans = 1
flg = True
for i in range(N):
    ans *= A[i]
    if A[-1] != 0:
        if ans > 10**18:
            flg = False
            break
    if A[-1] == 0:
        ans = 0
        break
if flg == False:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
index = 0
for i in range(M):
  A.sort(reverse=True)
  A[0] = int(A[0]/2)
print(sum(A))

### FIXED CODE ###

import heapq

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

#全要素に-1かける
for i in range(len(A)):
    A[i] *= -1 

heapq.heapify(A) 
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))
### BUGGY CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    count = 0
    ans = 0
    for i in A:
        for j in A:
            if i % j == 0:
                count += 1
                if count == 2:
                    count = 0
                    break
        if count == 1:
            ans += 1
        count = 0
    print(ans)
    


main()



### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    M = max(A)
    B = [0]*(M+1)
    ans = 0
    A.sort()
    
    for i in A:
        B[i] += 1
    
    for i in A:
        if B[i] == 1:
            ans += 1
        for j in range(i, M+1, i):
            B[j] += 1
    
    print(ans)

main()
### BUGGY CODE ###

N = int(input())
s = []
for i in range(N):
    s.append(sorted(list(input())))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        if (s[i] == s[j]):
            ans += 1
print(int(ans))

### FIXED CODE ###

N = int(input())
s = []
ans = 0
mydict = {}
for i in range(N):
    s = "".join(sorted(list(input())))
    if (s in mydict.keys()):
        ans += mydict[s]
        mydict[s] += 1
    else:
        mydict[s] = 1
print(ans)
### BUGGY CODE ###

#import numpy as np
 
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
dp_max = 10000000000
dp = [dp_max for i in range(H+1)]
#dp = np.full(H+1, dp_max, dtype=int)
dp[0] = 0
 
for i in range(H+1):
  if dp[i] == dp_max:
    continue
 
  for j in range(N):
    ni = min(H, i + A[j])
 
    dp[ni] = min(dp[ni], dp[i] + B[j])
print(dp[H])

### FIXED CODE ###

#import numpy as np
 
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
dp_max = 10000000000
dp = [dp_max for i in range(H+1)]
#dp = np.full(H+1, dp_max, dtype=int)
dp[0] = 0
 
for i in range(H+1):
  if dp[i] == dp_max:
    continue
 
  for j in range(N):
    ni = min(H, i + A[j])
 
    dp[ni] = min(dp[ni], dp[i] + B[j])
print(dp[H])
### BUGGY CODE ###

N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

result = 0
MOD = 10**9+7

for i in range(len(As)-1):
    tmp = As[i] * sum(As[i+1:])
    result += tmp

result %= MOD

print(result)



### FIXED CODE ###

N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

result = 0
MOD = 10**9+7

S = sum(As)

for i in range(len(As)-1):
    S -= As[i]
    tmp = As[i] * S
    result += tmp
    result %= MOD

print(result)
### BUGGY CODE ###

import math
import sys
input = sys.stdin.readline

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

def is_prime(n):
  if n == 1:
    return False
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      return False
  return True

D = []
E = []

for i, x in enumerate(A):
  Flag = True
  
  if i >= 1 and x == D[-1]:
    E.append(x)
    continue

  if i >= 1 and D[0] != 1 and is_prime(x):
    D.append(x)
    continue
    
  for j in D:
    if x%j == 0:
      Flag = False
      if x == j:
        E.append(x)
      break
    
  if Flag:
    D.append(x)

print(len(set(D)-set(E)))

### FIXED CODE ###


import math
from collections import defaultdict

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

D = defaultdict(int)

AM = A[-1]
dp = [True]*(AM)

for x in A:
  if dp[x-1]:
    temp = 2 * x
    while temp <= AM:
      dp[temp-1] = False
      temp += x

for x in A:
  if dp[x-1]:
    D[x] += 1

ans = len([i for i in D if D[i] == 1])

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

N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N):
  if i%2:
    B = [A[i]]+B
  else:
    B = B+[A[i]]
print(*B[::-1] if N%2 else B)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if N%2==0:
  B = [A[i] for i in range(N) if i%2==0]
  C = [A[(N-i-1)] for i in range(N) if (N-i-1)%2==1]
  print(*C+B)
else:
  B = [A[i] for i in range(N) if i%2==1]
  C = [A[(N-i-1)] for i in range(N) if (N-i-1)%2==0]
  print(*C+B)
### BUGGY CODE ###

from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    n=int(input())
    d=readLine_int_list()
    m=int(input())
    t=readLine_int_list()
    f = True
    for i in t:
        if i in d:
            d.pop(d.index(i))
        else:
            f = False
            break
    if f:
        print("YES")
    else:
        print("NO")
if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin, stdout
from collections import defaultdict
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    d = defaultdict(lambda: 0)
    t = defaultdict(lambda: 0)
    
    n=int(input())
    _d=readLine_int_list()
    for i in _d:
        d[i] += 1
        
    m = int(input())
    _t = readLine_int_list()
    
    for i in _t:
        t[i] += 1
    
    ans = "YES"
    for i in t:
        if i in d:
            if t[i] - d[i] > 0:
                ans = "NO"
                break
        else:
            ans = "NO"
            break
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

dp = [10 ** 9] * n
dp[0] = 0

a = min(n, k)
for i in range(n):
    for j in range(1, min(k + 1, n - i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[-1])

### FIXED CODE ###

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

dp = [10 ** 9] * n
dp[0] = 0

for i in range(1, n):
    j = max(0, i - k)
    hi = h[i]
    dp[i] = min(dpj + abs(hi - hj) for dpj, hj in zip(dp[j:i], h[j:i]))

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

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(node_num - 1 + edge_num)]

    parent_node = [0 for i in range(node_num + 1)]
    root_node = [1 for i in range(node_num + 1)]
    root_node[0] = 0
    graph_data = defaultdict(set)

    for i in range(node_num - 1 + edge_num):
        a, b = data[i]
        graph_data[a].add(b)
        root_node[b] = 0

    root = -1
    for i in range(node_num + 1):
        if root_node[i]:
            root = i

    now_set = set()
    next_set = set()
    now_set.add(root)

    while len(now_set):
        for now_node in now_set:
            for next_node in graph_data[now_node]:
                parent_node[next_node] = now_node
                next_set.add(next_node)
        now_set = next_set
        next_set = set()

    for i in range(1, node_num + 1):
        print(parent_node[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(node_num - 1 + edge_num)]

    parent_node = [0 for i in range(node_num + 1)]
    graph_data = defaultdict(set)
    nyuuji = [0 for i in range(node_num + 1)]

    for i in range(node_num - 1 + edge_num):
        a, b = data[i]
        graph_data[a].add(b)
        nyuuji[b] += 1

    root = -1
    for i in range(1, node_num + 1):
        if nyuuji[i] == 0:
            root = i

    now_set = set()
    next_set = set()
    now_set.add(root)

    while len(now_set):
        for now_node in now_set:
            for next_node in graph_data[now_node]:
                nyuuji[next_node] -= 1
                if nyuuji[next_node] == 0:
                    next_set.add(next_node)
                    parent_node[next_node] = now_node

        now_set = next_set
        next_set = set()

    for i in range(1, node_num + 1):
        print(parent_node[i])


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

import sys
sys.setrecursionlimit(10**6)

def dfs(v, d=0):
    seen[v] = True
    dist[v] = d

    for i in graph[v]:
        next_v = i[0]
        l = i[1]
        if seen[next_v] == True:
            continue
        dfs(next_v, d+l)

    return

N = int(input())

graph = [[] for i in range(N + 1)]

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

Q, K = map(int, input().split())

for i in range(Q):
    ans = 0
    x, y = map(int, input().split())

    seen = [False for i in range(N + 1)]
    dist = [0 for i in range(N + 1)]
    dfs(x)
    ans += dist[K]

    seen = [False for i in range(N + 1)]
    dist = [0 for i in range(N + 1)]
    dfs(K)
    ans += dist[y]
    
    print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def dfs(v, d=0):
    seen[v] = True
    dist[v] = d

    for i in graph[v]:
        next_v = i[0]
        l = i[1]
        if seen[next_v] == True:
            continue
        dfs(next_v, d+l)

    return

N = int(input())

graph = [[] for i in range(N + 1)]

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

Q, K = map(int, input().split())

seen = [False for i in range(N + 1)]
dist = [0 for i in range(N + 1)]
dfs(K)

for i in range(Q):
    x, y = map(int, input().split())
    print(dist[x] + dist[y])
### BUGGY CODE ###

#import sys

#input = sys.stdin.readline



def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    l=list(map(int,input().split()))
    count=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for m in range(j+1,n):
                if l[m]<l[i]+l[j] and l[m]>abs(l[i]-l[j]):
                    count+=1
                
    print(count)






if __name__ == "__main__":
    main()

### FIXED CODE ###

#import sys

#input = sys.stdin.readline

import bisect

def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    l=list(map(int,input().split()))
    l=sorted(l)
 #   print(l)
    count=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            a = bisect.bisect_left(l,l[i]+l[j])
#            print(a)
            count+=a-j-1

    print(count)






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

s = input()
n = len(s)

l_sum = [0]
for i in range(n):
    x = (l_sum[-1] + int(s[n-i-1]) * (10 ** i)) % 2019
    l_sum.append(x)

#print(l_sum)
l_sum.sort()
ans = 0
tmp = 0
cnt = 1
for i in range(1, len(l_sum)):
    if l_sum[i] == tmp:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1
        tmp = l_sum[i]

ans += cnt * (cnt - 1) // 2
print(ans)

### FIXED CODE ###

s = list(map(int, input()))
#print(s)
n = len(s)

l_sum = [0]
for i in range(n):
    x = (l_sum[-1] + int(s[n-i-1]) * (pow(10, i, 2019))) % 2019
    l_sum.append(x)

#print(l_sum)
l_sum.sort()
ans = 0
tmp = 0
cnt = 1
for i in range(1, len(l_sum)):
    if l_sum[i] == tmp:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1
        tmp = l_sum[i]

ans += cnt * (cnt - 1) // 2
print(ans)
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
base = ["#" *(w+4)]
base.append("#" * (w+4))
for n in range(h):
    base.append("##" + input() + "##")
base.append("#" * (w+4))
base.append("#" * (w+4))
ans = [[-1] * (w+4) for _ in range(h+4)]
for j in range(w+4):
    for i in range(h+4):
        if base[i][j] == "#":
            ans[i][j] = -2
ch+=1; cw+=1
dh+=1; dw+=1
ans[ch][cw] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]
move2 = [
    [-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], \
    [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], \
    [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], \
    [1, -2], [1, -1], [1, 0], [1, 1], [1, 2], \
    [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]
    ]
q = deque([[ch, cw]])
one_time = deque([])
while len(q) > 0:
    x, y = q.popleft()
    one_time.append([x, y])
    for i, j in move:
        v1, v2 = x+i, y+j
        if ans[v1][v2] == -1:
            ans[v1][v2] = ans[x][y]
            q.append([v1, v2])
    if len(q) == 0:
        while len(one_time) > 0:
            x2, y2 = one_time.popleft()
            for i, j in move2:
                v1, v2 = x2+i, y2+j
                if ans[v1][v2] == -1:
                    ans[v1][v2] = ans[x2][y2] + 1
                    q.append([v1, v2])
print(ans[dh][dw])

### FIXED CODE ###

from collections import deque
 
 
# In[30]:
 
 
def main():
    H,W = map(int, input().split())
    ch,cw = map(int, input().split())
    dh,dw = map(int, input().split())
    s = ["#"*(W+4)]
    s.append("#"*(W+4))
    for i in range(H):
        s.append("##"+input()+"##")
    s.append("#"*(W+4))
    s.append("#"*(W+4))
    
    ans = [[-1]*(W+4) for _ in range(H+4)]
    for i in range(H+4):
        for j in range(W+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ch += 1; cw += 1
    dh += 1; dw += 1
    ans[ch][cw] = 0
    
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    magic = [
        [-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],\
        [-1,-2],[-1,-1],[-1,0],[-1,1],[-1,2],\
        [0,-2],[0,-1],[0,0],[0,1],[0,2],\
        [1,-2],[1,-1],[1,0],[1,1],[1,2],\
        [2,-2],[2,-1],[2,0],[2,1],[2,2]
        ]
    
    mylist = deque([[ch,cw]])
    mylist2 = deque([])
    while len(mylist) > 0:
        x,y = mylist.popleft()
        mylist2.append([x,y])
        for p,q in move:
            v1,v2 = x+p,y+q
            if ans[v1][v2] == -1:
                mylist.append([v1,v2])
                ans[v1][v2] = ans[x][y]
        if len(mylist) == 0:
            while len(mylist2) > 0:
                x2,y2 = mylist2.popleft()
                for v1,v2 in magic:
                    i,j = x2+v1,y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        mylist.append([i,j])
    print(ans[dh][dw])
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = [-float('inf')]
for i in range(1, len(stack) // 2 + 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        if r2 - r1 > candidate[0]:
            candidate.append(r2 - r1)
    for r1, r2 in zip(stack[::1], stack[len(stack) - i::1]):
        if r2 - r1 > candidate[0]:
            candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

### FIXED CODE ###

n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)
### BUGGY CODE ###

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

B = [0]*N

for i in range(N):
    for j in range(N):
        if i <= j:
            B[i] += A[j]*(-1)**(j-i)
        else:
            B[i] += A[j]*(-1)**(i-j+1)
    print(B[i])


### FIXED CODE ###

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

ans = 0
for j in range(N):
    ans += A[j]*(-1)**j

print(ans)

for i in range(1, N):
    ans = 2*A[i-1]-ans
    print(ans)
### BUGGY CODE ###

import numpy as np
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
h,w = map(int,input().split())
a=[[s=='.' for s in list(input())] for _ in range(h)]
mod=10**9+7
dp=np.zeros((h,w),np.int64)
for i in range(h):
      if a[i][0]:
            dp[i,0]=1
      else:
            break
for j in range(w):
      if a[0][j]:
            dp[0,j]=1
      else:
            break
for i in range(1,h):
      for j in range(1,w):
            dp[i,j]=(dp[i-1,j]+dp[i,j-1])%mod if a[i][j] else 0
print(dp[-1][-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
h,w = map(int,input().split())
a=[input() for _ in range(h)]
mod=10**9+7
dp=[[0]*w for _ in range(h)]
dp[0][0]=1
for i in range(h):
      for j in range(w):
            if i+1<h and a[i+1][j]=='.':
                  dp[i+1][j]+=dp[i][j]%mod
            if j+1<w and a[i][j+1]=='.':
                  dp[i][j+1]+=dp[i][j]%mod
print(dp[-1][-1]%mod)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
res = a[0]
for i in range(1, n): res *= a[i]
print(-1) if res > 10**18 else print(res)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
a = sorted(a, reverse=True)
res = a[0]
for ai in a[1:]:
    res *= ai
    if res > 10**18:
        print(-1)
        exit()
print(res)
### BUGGY CODE ###

def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
a = lmiinps()

ans = 0

for i in range(0,n-1):
    for j in range(i+1,n):
        k = ((a[i]%(10**9+7))*(a[j]%(10**9+7)))%(10**9+7)
        ans += k

ans %= (10**9+7)

print(ans)

### FIXED CODE ###

def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
a = lmiinps()

ans = 0
count = 0

for i in range(n):
    count += (a[i]%(10**9+7))

for i in range(n):
    count -= a[i]
    ans += (a[i]%(10**9+7))*count


ans %= (10**9+7)

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

import math
N = int(input())
A = [int(input()) for i in range(N)]
c=0
for i in range(N):
    x=A[i]
    if x < 2: continue
    if x==2 or x==3 or x==5:c+=1
    if x%2==0 or x%3==0 or x%5==0: continue

    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: continue
        prime += step
        step = 6 - step
    c += 1
print(c)

### FIXED CODE ###

def is_prime(x):
    if x==2:
        return 1
    elif x&1==0:
        return 0
    else: return pow(2,x-1,x)==1
N = int(input())
c=0
for i in range(N):
    c+=is_prime(int(input()))
print(c)
### BUGGY CODE ###

from collections import defaultdict

N, K, L = [int(a) for a in input().split(" ")]
P, Q = zip(*[[int(v) for v in input().split(" ")] for i in range(K)])
R, S = zip(*[[int(v) for v in input().split(" ")] for i in range(L)])

def find(tab, a):
    if tab[a] == -1: return a
    tab[a] = find(tab, tab[a])
    return tab[a]

def union(tab, a, b):
    pa, pb = (find(tab, a), find(tab, b))
    if pa!=pb:
        tab[pb] = pa

loads = [-1]*N
rails = [-1]*N
for p, q in zip(P, Q):
    union(loads, p-1, q-1)

for r, s in zip(R, S):
    union(rails, r-1, s-1)

ans = []
for i in range(N):
    ans.append(0)
    for j in range(N):
        if find(loads, i)==find(loads, j) and find(rails, i)==find(rails,j):
            ans[-1]+=1

print(" ".join([str(n) for n in ans]))


### FIXED CODE ###

from collections import defaultdict

N, K, L = [int(a) for a in input().split(" ")]
P, Q = zip(*[[int(v) for v in input().split(" ")] for i in range(K)])
R, S = zip(*[[int(v) for v in input().split(" ")] for i in range(L)])

def find(tab, a):
    if tab[a] == -1: return a
    tab[a] = find(tab, tab[a])
    return tab[a]

def union(tab, a, b):
    pa, pb = (find(tab, a), find(tab, b))
    if pa!=pb:
        tab[pb] = pa

loads = [-1]*N
rails = [-1]*N
both = [-1]*N
for p, q in zip(P, Q):
    union(loads, p-1, q-1)

for r, s in zip(R, S):
    union(rails, r-1, s-1)

dic = defaultdict(lambda: 0)
ans = []
for i in range(N):
    key = (find(loads, i), find(rails, i))
    ans.append(key)
    dic[key] += 1

ans = [dic[key] for key in ans]
print(" ".join([str(cnt) for cnt in ans]))
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
for i in range(n):
    place = l1.index(x[i])
    l1.remove(x[i])
    print(l1[int((n / 2) - 1)])
    l1.insert(place, x[i])

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
median1 = l1[int(n / 2) - 1]
median2 = l1[int(n / 2)]
if median1 == median2:
    for i in range(n):
        print(median1)
else:
    for i in range(n):
        if x[i] <= median1:
            print(median2)
        else:
            print(median1)