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

# -*- coding: utf-8 -*-

import numpy as np

### TESTCASE
test = ""
#test = \
"""
4 6
#..#..
.....#
....#.
#.#...
ans 8
"""

"""
8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#
ans 13
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
####### MAIN

h, w = map(int, input2().split())
s = [["#"] * (w+1)]
s += [list("#" + input2()) for _ in range(h)]

ws = [[0] * (w+1) for _ in range(h+1)]  # Pythonの恐ろしい仕様！
hs = [[0] * (w+1) for _ in range(h+1)]

for hi in range(1, h+1):
    for wi in range(1, w+1):
        if s[hi][wi] == ".":
            ws[hi][wi] = ws[hi][wi-1] + 1
            hs[hi][wi] = hs[hi-1][wi] + 1

for hi in range(1, h+1):
    for wi in range(w-1, 0, -1):
        if ws[hi][wi]:
            ws[hi][wi] = max(ws[hi][wi+1], ws[hi][wi])
            
for wi in range(1, w+1):
    for hi in range(h-1, 0, -1):
        if hs[hi][wi]:
            hs[hi][wi] = max(hs[hi+1][wi], hs[hi][wi])           
            
ws = np.array(ws)
hs = np.array(hs)

print(np.max(ws + hs) - 1)




### FIXED CODE ###

# -*- coding: utf-8 -*-

import numpy as np

### TESTCASE
test = ""
#test = \
"""
4 6
#..#..
.....#
....#.
#.#...
ans 8
"""

"""
8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#
ans 13
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
####### MAIN

h, w = map(int, input2().split())
s = [["#"] * (w+1)]
s += [list("#" + input2()) for _ in range(h)]
s = np.array(s)

hs = np.zeros((h+1, w+1), dtype="int64")
ws = np.zeros((h+1, w+1), dtype="int64")

for hi in range(1, h+1):
    htmp = np.array(s[hi] == ".", dtype="int")
    hs[hi] = hs[hi-1] * htmp + htmp
    
for hj in range(h-1, 0, -1):
    hs[hj] = np.maximum(hs[hj], np.minimum(hs[hj+1], hs[hj] * hs[hj+1]))
    
for wi in range(1, w+1):
    wtmp = np.array(s[:, wi] == ".", dtype="int")
    ws[:, wi] = ws[:, wi-1] * wtmp + wtmp
    
for wj in range(w-1, 0, -1):
    ws[:, wj] = np.maximum(ws[:, wj], 
      np.minimum(ws[:, wj+1], ws[:, wj] * ws[:, wj+1]))
    
print(np.max(ws + hs) - 1)
### BUGGY CODE ###

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

def allequal(s):
    for i in range(n):
        for j in range(n):
            if s[i][j] != s[0][0]:
                return False
    return True

def val(s,k):
    global n
    for i in range(n):
        if i+k >= n:
            ni = i+k-n
        else:
            ni = i+k
        for j in range(n):
            if j-k < 0:
                nj = j-k+n
            else:
                nj = j-k
            if s[i][j] != s[nj][ni]:
                return False
    return True

if allequal(s):
    print(n**2)
else:
    res = 0
    for k in range(0,n):
        if val(s,k):
            res += n
    print(res)

### FIXED CODE ###

n = int(input())
s = []
for _ in range(n):
    s.append(input())
st=list(map(''.join,zip(*s)))

def plusa(s,a):
    ns = []
    for ss in s:
        ns.append(ss[a:]+ss[:a])
    return ns

def plusb(s,b):
    global n
    ns = []
    for i in range(n-b):
        ns.append(s[b+i])
    for i in range(b):
        ns.append(s[i])
    return ns

res = 0
for i in range(n):
    if plusa(st,i) == plusb(s,i):
        res += n

print(res)
### BUGGY CODE ###

#!/usr/bin/env python3

MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w *= 2
print(ans)


### FIXED CODE ###

MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w = w * 2 % MOD
print(ans)
### BUGGY CODE ###

import numpy as np

N,K=map(int,input().split())
p=np.array(list(map(int,input().split())))

def rolling_window(a, window, step_size):
    shape = a.shape[:-1] + (a.shape[-1] - window + 1 - step_size + 1, window)
    strides = a.strides + (a.strides[-1] * step_size,)
    return np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)

print((max(np.sum(rolling_window(p,K,1),axis=1))+K)/2)

### FIXED CODE ###

import numpy as np

N,K=map(int,input().split())
p=np.array(list(map(int,input().split())))

pcm=np.concatenate([np.array([0]),(p+1).cumsum()],0)

print((pcm[K:]-pcm[0:-K]).max() /2)
### BUGGY CODE ###

from collections import defaultdict,deque

H, W = map(int, input().split())
S = list(map(int, input().split()))
G = list(map(int, input().split()))
S[0] -= 1
S[1] -= 1
G[0] -= 1
G[1] -= 1
c = [input() for i in range(H)]
dist = [[-1]*W for _ in range(H)]

for i in range(H):
    for g in range(W):
        if c[i][g] == "#":
            dist[i][g] = -2

checkList = set()
que = deque()
que.append(S)
dist[S[0]][S[1]] = 0

directions = [(0, -1), (0, 1), (1, 0), (-1, 0)]

cost = 0

while True:
    if len(que) == 0:
        cost += 1
        que = set()
        for h, w in checkList:
            for i in [-2, 0, 2]:
                for g in [-2, 0, 2]:
                    nh = h+i
                    nw = w+g
                    if nw < 0 or nw > W-1 or nh < 0 or nh > H-1:
                        continue
                    else:
                        if dist[nh][nw] == -1:
                            que.add((nh, nw))
        que = deque(que)
        checkList = set()
        if len(que) == 0:
            print(-1)
            exit()
    else:
        h, w = que.popleft()
        if h == G[0] and w == G[1]:
            print(cost)
            exit()
        for i in range(4):
            nh = h+directions[i][0]
            nw = w+directions[i][1]
            if nw < 0 or nw > W-1 or nh < 0 or nh > H-1:
                continue
            if dist[nh][nw] == -1:
                que.append((nh, nw))
                dist[nh][nw] = cost
            elif dist[nh][nw] == -2:
                checkList.add((h, w))

### FIXED CODE ###

from collections import defaultdict,deque

H, W = map(int, input().split())
S = list(map(int, input().split()))
G = list(map(int, input().split()))
S[0] -= 1
S[1] -= 1
G[0] -= 1
G[1] -= 1
c = [input() for i in range(H)]
dist = [[-1]*W for _ in range(H)]

for i in range(H):
    for g in range(W):
        if c[i][g] == "#":
            dist[i][g] = -2

checkList = set()
que = deque()
que.append(S)

directions = [(0, -1), (0, 1), (1, 0), (-1, 0)]

cost = 0

while True:
    if len(que) == 0:
        cost += 1
        que = set()
        for h, w in checkList:
            for i in range(-2, 3):
                for g in range(-2, 3):
                    nh = h+i
                    nw = w+g
                    if nw < 0 or nw > W-1 or nh < 0 or nh > H-1:
                        continue
                    else:
                        if dist[nh][nw] == -1:
                            que.add((nh, nw))
        que = deque(que)
        checkList = set()
        if len(que) == 0:
            print(-1)
            exit()
    else:
        h, w = que.popleft()
        dist[h][w] = cost
        if h == G[0] and w == G[1]:
            print(cost)
            exit()
        for i in range(4):
            nh = h+directions[i][0]
            nw = w+directions[i][1]
            if nw < 0 or nw > W-1 or nh < 0 or nh > H-1:
                continue
            if dist[nh][nw] == -1:
                que.append((nh, nw))
                dist[nh][nw] = cost
            elif dist[nh][nw] == -2:
                checkList.add((h, w))
### BUGGY CODE ###


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

L, R = map(int, input().split())

ans = float('inf')
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min(ans, i*j % 2019)

print(ans)

### FIXED CODE ###


l, r = map(int, input().split())

least = 2*(10**9)+1
for i in range(l, r):
    for j in range(i+1, r+1):
        if (i * j % 2019) == 0:
            print(0)
            exit()
        least = min(least, (i * j % 2019))

print(least)
### BUGGY CODE ###

import math
K=int(input())
ans = 0
for i1 in range(1,1+K):
  for i2 in range(1,1+K):
    for i3 in range(1,1+K):
      ans = ans + math.gcd(math.gcd(i1,i2),i3)
print(ans)

### FIXED CODE ###

import math
K=int(input())
total = 0

for a in range(1,K+1):
  for b in range(a+1,K+1):
    for c in range(b+1,K+1):
      total += math.gcd(a, math.gcd(b,c) ) * 6
      
for a in range(1,K+1):
  for b in range(a+1,K+1):
    total += math.gcd(a, b)*6

for a in range(1,K+1):
  total += a

print(total)
### BUGGY CODE ###

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

import numpy as np

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

MOD = 10 ** 9 + 7

U = 6*10**5 + 100
fact = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1]*n%MOD
fact_inv = [1] * (U+1)
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

fact = np.array(fact,dtype=np.int64)
fact_inv = np.array(fact_inv,dtype=np.int64)

U = N - M
comb = fact[U] * fact_inv[:U+1] % MOD * fact_inv[U::-1] % MOD
comb[1::2] *= (-1)

F = np.zeros(N+M+1,dtype=np.int64)
F[M:N+1] = comb

P = np.zeros(R+1,dtype=np.int64)
for a in range(1,R+1):
    n = min(len(F),(R+a)//a)
    P[:a*n:a] += F[:n]

P[M:] -= P.copy()[:-M]
P %= MOD

# (1-x)^{N+1}で割る
Q = fact[N:N+R+1] * fact_inv[:R+1] % MOD * fact_inv[N] % MOD

def f(R):
    total = fact[R+N] * fact_inv[R] % MOD * fact_inv[N] % MOD
    x = (Q[R::-1] * P[:R+1] % MOD).sum() % MOD
    coef = fact[N] * fact_inv[M] % MOD * fact_inv[N-M] % MOD
    return (total - x*coef)%MOD

answer = (f(R) - f(L-1))%MOD
print(answer)

### FIXED CODE ###

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

import numpy as np

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

MOD = 10 ** 9 + 7

U = 6*10**5 + 100
fact = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1]*n%MOD
fact_inv = [1] * (U+1)
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

fact = np.array(fact,dtype=np.int64)
fact_inv = np.array(fact_inv,dtype=np.int64)


U = N - M
comb = fact[U] * fact_inv[:U+1] % MOD * fact_inv[U::-1] % MOD
comb[1::2] *= (-1)

P = np.zeros(R+1,dtype=np.int64)
for i,x in enumerate(comb,M):
    P[::i] += x


P[M:] -= P.copy()[:-M]
P %= MOD

# (1-x)^{N+1}で割る
Q = fact[N:N+R+1] * fact_inv[:R+1] % MOD * fact_inv[N] % MOD

def f(R):
    total = fact[R+N] * fact_inv[R] % MOD * fact_inv[N] % MOD
    x = (Q[R::-1] * P[:R+1] % MOD).sum() % MOD
    coef = fact[N] * fact_inv[M] % MOD * fact_inv[N-M] % MOD
    return (total - x*coef)%MOD

answer = (f(R) - f(L-1))%MOD
print(answer)
### BUGGY CODE ###

# D - Knapsack Queries on a tree

import bisect

n = int(input())

v = [0] * n
w = [0] * n
for i in range(n):
    v[i], w[i] = map(int, input().split())

max_l = 10 ** 5

# dp table (for some amount)
dp = [None] * min(n, 2 ** 16)

# dp[vertex] = list of (weight, value)
dp[0] = [(0, 0), (w[0], v[0])]

for u in range(1, len(dp)):
    parent = (u - 1) // 2
    dp[u] = dp[parent].copy()
    for ww, vv in dp[parent]:
        dp[u].append((ww + w[u], vv + v[u]))
    dp[u].sort()

    # remove unnecessary entries
    tail = 0
    for i in range(1, len(dp[u])):
        if dp[u][i][0] > max_l:
            break
        if dp[u][tail][1] < dp[u][i][1]:
            tail += 1
            dp[u][tail] = dp[u][i]
    del dp[u][tail + 1:]

dpkeys = [[ww for ww, vv in dp[u]] for u in range(len(dp))]

def solve(u, l):
    if u < len(dp):
        x = bisect.bisect_right(dpkeys[u], l) - 1
        return dp[u][x][1]

    parent = (u - 1) // 2
    s = solve(parent, l)
    if l >= w[u]:
        s = max(s, v[u] + solve(parent, l - w[u]))
    return s

q = int(input())
for i in range(q):
    u, l = map(int, input().split())
    print(solve(u - 1, l))


### FIXED CODE ###

# D - Knapsack Queries on a tree

from sys import stdin
import bisect

readline = stdin.readline
bisect_right = bisect.bisect_right

n = int(readline())

v = [0] * n
w = [0] * n
for i in range(n):
    v[i], w[i] = map(int, readline().split())

max_l = 10 ** 5
vshift = 21
mask = (1 << vshift) - 1

# dp table (for some amount)
dp = [None] * min(n, 2 ** 12)

# dp[vertex] = list of (weight, value)
dp[0] = [(0 << vshift) + 0, (w[0] << vshift) + v[0]]

for u in range(1, len(dp)):
    parent = (u - 1) // 2

    ls = dp[parent][:]
    ls.extend(x + (w[u] << vshift) + v[u] for x in dp[parent]
              if (x >> vshift) + w[u] <= max_l)
    ls.sort()

    # remove unnecessary entries
    tail = 0
    for i in range(1, len(ls)):
        if (ls[tail] >> vshift) == (ls[i] >> vshift):
            ls[tail] = ls[i]
        elif (ls[tail] & mask) < (ls[i] & mask):
            tail += 1
            ls[tail] = ls[i]
    del ls[tail + 1:]
    dp[u] = ls

def solve(u, l):
    if u < len(dp):
        x = bisect_right(dp[u], (l << vshift) + mask) - 1
        return dp[u][x] & mask

    parent = (u - 1) // 2
    s = solve(parent, l)
    if l >= w[u]:
        s = max(s, v[u] + solve(parent, l - w[u]))
    return s

q = int(readline())
for i in range(q):
    u, l = map(int, readline().split())
    print(solve(u - 1, l))
### BUGGY CODE ###

def main():
    from collections import deque
    H, W = map(int, input().split())
    grid = [["#"] * (W + 2)] + [list("#" + input() + "#")
                                for i in range(H)] + [["#"]*(W+2)]
    # print(grid)
    stack = deque()
    for h in range(1, H+1):
        for w in range(1, W+1):
            # 黒ならスタックにpush
            if grid[h][w] == "#":
                stack.append([h, w])

    for i in range(h + w + 3):
        tmp = deque()
        while stack:
            h, w = stack.pop()
            for dh, dw in ([0, 1], [0, -1], [1, 0], [-1, 0]):
                if grid[h + dh][w + dw] == ".":
                    grid[h + dh][w + dw] = "#"
                    tmp.append([h + dh, w + dw])
        stack = tmp
        if not stack:
            print(i)
            break


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import deque
    H, W = map(int, input().split())
    grid = [["#"] * (W + 2)] + [list("#" + input() + "#")
                                for i in range(H)] + [["#"]*(W+2)]
    # print(grid)
    stack = deque()
    for h in range(1, H+1):
        for w in range(1, W+1):
            # 黒ならスタックにpush
            if grid[h][w] == "#":
                stack.append([h, w])

    for i in range(h + w + 3):
        tmp = deque()
        while stack:
            h, w = stack.pop()
            for dh, dw in ([0, 1], [0, -1], [1, 0], [-1, 0]):
                if grid[h + dh][w + dw] == ".":
                    grid[h + dh][w + dw] = "#"
                    tmp.append([h + dh, w + dw])
        stack = tmp
        if not stack:
            print(i)
            break


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

n,q=map(int,input().split())
s=input()
for _ in range(q):
    l,r=map(int,input().split())
    print(s[l-1:r].count('AC'))

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
i=0
bb=[]
c=0
while True:
    b=s.find('AC', i)
    if b<0:
        bb.extend([c]*(len(s)-i))
        break
    bb.extend([c]*(b-i+1))
    i=b+1
    c+=1
for _ in range(q):
    l,r=map(int,input().split())
    print(bb[r-1]-bb[l-1])
### BUGGY CODE ###

import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
s = list(map(ord, ns()))
d = dict()
for x in map(ord, list('RGB')):
    d[x] = s.count(x)
tot = sum(map(ord, list('RGB')))
ans = 0
for i in range(n-1):
    for j in range(i):
        if s[i] != s[j]:
            t = tot - s[i] - s[j]
            ans += d[t] - ((2*i - j) < n and t == s[2*i - j])
    d[s[i]] -= 1
print(ans)


### FIXED CODE ###

import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
s = list(map(ord, ns()))
d = dict()
for x in map(ord, list('RGB')):
    d[x] = s.count(x)
tot = sum(map(ord, list('RGB')))
ans = 0
for i in range(n-1):
    for j in range(i):
        if s[i] != s[j]:
            t = tot - s[i] - s[j]
            ans += d[t] - ((2*i - j) < n and t == s[2*i - j])
    d[s[i]] -= 1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

def main(N, A_list):
    val = 0
    mod = (10 ** 9) + 7
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            val += A_list[i] * A_list[j]

    print(val % mod)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

### FIXED CODE ###

# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n, q = [ int(v) for v in input().split() ]
s = input()
ac_list = [ 0 for i in range(n-1) ]
for i in range(n-1):
	if s[i:i+2] == "AC":
		ac_list[i] += 1


for i in range(q):
	l, r = [ int(v) for v in input().split() ]
	print(sum(ac_list[l-1:r-1]))

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
n, q = [ int(v) for v in input().split() ]
s = input()
ac_list = []

for i in range(n-1):
	if s[i:i+2] == "AC":
		ac_list.append(i)


for i in range(q):
	l, r = [ int(v) for v in input().split() ]
	a = (bisect.bisect_left(ac_list, l-1))
	b = (bisect.bisect_right(ac_list, r-2))
	print(b-a)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(sorted([A.count(b) for b in set(A)], reverse=True))
print(sum(B[K:len(B)]))

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = {i:0 for i in set(A)}
for a in A:
    B[a] += 1
print(sum(sorted(B.values())[:-K]))
### BUGGY CODE ###

x = int(input())
a = int(input())
b = int(input())

rest_a = x - a
rest_b = 0
while rest_a >= 0:
  rest_b = rest_a - b
print(rest_b)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())

rest_a = x - a
rest_b = rest_a % b
print(rest_b)
### BUGGY CODE ###

S = input()
Scount = 0
for i in range(len(S)):
    for j in range(1,len(S)):
        if (i+j)<=len(S):
            part_S = S[i:i+j]
            num = int(part_S)
            if num % 2019 == 0:
                Scount += 1
print(Scount)

### FIXED CODE ###

S = input()
from collections import defaultdict
d = defaultdict(int)
before = 0
for i in range(1,len(S)+1):
    now = (int(S[-i])*pow(10,i,2019)+before) % 2019
    d[now] += 1
    before = now
d[0] += 1
ans = 0
for i in d.values():
    ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

import numpy as np

def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans
N = int(input())
A = [input() for i in range(N)]
a = []*N
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
d=[]
for i in c:
    d.append(a.count(i))
count=0
for i in d:
    if i>2:
        count += factorial(i) // (factorial(i - 2) * factorial(2))
    elif i ==2:
        count += 1
print(count)

### FIXED CODE ###

N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)
### BUGGY CODE ###

s = input()
mod = 2019
dic = [0] * mod
dic[0] += 1

tmp = 0
d = 1
for i in reversed(range(len(s))):
    tmp += int(s[i]) * d
    tmp %= mod
    d *= 10
    #d %= mod
    dic[tmp] += 1

ans = [i * (i-1) / 2 for i in dic]
print(int(sum(ans)))

### FIXED CODE ###

s = input()
mod = 2019
dic = [0] * mod
dic[0] += 1

tmp = 0
d = 1
for i in reversed(range(len(s))):
    tmp += int(s[i]) * d
    tmp %= mod
    d *= 10
    d %= mod
    dic[tmp] += 1

ans = [i * (i-1) / 2 for i in dic]
print(int(sum(ans)))
### BUGGY CODE ###

import math
import statistics
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=tuple(Y)
for a in range(N):
    b=Z[a]
    answer=list(Z)
    answer.remove(b)
    print(statistics.median(answer))
    

### FIXED CODE ###

N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=sorted(Y)
a=Z[int(N/2-1)]
b=Z[int(N/2)]
for c in range(N):
    if Y[c]<=a:
        print(b)
    else:
        print(a)
### BUGGY CODE ###

import string
n,k =[int(i) for i in input().split()]
not_use=[int(i) for i in input().split()]
use=[int(i) for i in string.digits if int(i) not in not_use]

def check(n):
    for i in str(n):
        if(int(i) in not_use):
            return False
    return True


x=n-1
while True:
    x+=1
    if(check(x)==True):
        print(x)

### FIXED CODE ###

import string
import sys

N,K=[int(i) for i in input().split()]
D=[int(i) for i in input().split()]
use=[int(i) for i in string.digits if int(i) not in D]

def check(use,x):
    for i in str(x):
        if(int(i) not in use):
            return False
    return x

i=N-1
while True:
    i+=1
    x=check(use,i)
    if(x!=False):
        print(x)
        sys.exit()
### BUGGY CODE ###

import collections
N = int(input())
count = []

for _ in range(N):
    tmp = collections.OrderedDict(sorted(collections.Counter([s for s in input()]).items()))
    count.append("".join(list(tmp.keys())) + "".join(map(str, list(tmp.values()))))
        
ans = 0
for v in collections.Counter(count).values():
    ans += v * (v - 1) // 2

print(ans)

### FIXED CODE ###

import collections
N = int(input())
count = []

for _ in range(N):
    s = "".join(sorted(input()))
    count.append(s)

ans = 0
for v in collections.Counter(count).values():
    ans += v * (v - 1) // 2

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

n = int(input())
numbers = [int(input()) for i in range(n)]

for i in range(n):
    temporary_list = list(numbers)
    temporary_list.pop(i)
    print(max(temporary_list))

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
n = int(input())
data = [int(input()) for k in range(n)]
m1,m2 = sorted(data, reverse=1)[:2]
b = [m2 if x==m1 else m1 for x in data]
print('\n'.join(map(str,b)))
### BUGGY CODE ###

n, k = [int(x) for x in input().split()]

flowers = []

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    flowers.append(tmp)

def aaa(p, l):
    count = 0
    for x in l:
        w, d = x[0], x[1]
        if p - w < 0:
            pass
        else:
            count += (p - w) // d + 1
    return count

flag = True
left, right = 1, 2 * (10 ** 18)
ans = 0

while flag:
    point = (right + left) // 2
    if point == left:
        flag = False
        if aaa(left, flowers) >= k:
            ans = left
        else:
            ans = right
    else:
        if aaa(point, flowers) < k:
            left = point
        else:
            right = point

print(ans)

### FIXED CODE ###

n, k = [int(x) for x in input().split()]

flowers = []

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    flowers.append(tmp)

def aaa(p, l):
    count = 0
    for x in l:
        w, d = x[0], x[1]
        if p - w < 0:
            pass
        else:
            count += (p - w) // d + 1
    return count

flag = True
left, right = 1, 10 ** 19
ans = 0

while flag:
    point = (right + left) // 2
    if point == left:
        flag = False
        if aaa(left, flowers) >= k:
            ans = left
        else:
            ans = right
    else:
        if aaa(point, flowers) < k:
            left = point
        else:
            right = point

print(ans)