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

N,K = map(int,input().split())
S = list(input())
A = [1]
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        A[-1] += 1
    else:
        A.append(1)
J = len(A)
if S == ['0']:
    print(1)
elif (S[0] == '1') & (S[-1] == '1'):
    ANSL = []
    if J <= 2*K+1:
        print(sum(A))
    else:
        for i in range((J+1)//2-K):
            ANS = 0
            for j in range(2*K+1):
                ANS += A[2*i+j]
            ANSL.append(ANS)
        print(max(ANSL))
elif (S[0] == '0') & (S[-1] == '0'):
    if J <= 2*K-1:
        print(sum(A))
    else:
        ANSL = []
        ANSM = 0
        for i in range(2*K):
            ANSM += A[i]
        ANSN = 0
        for i in range(J-2*K,J):
            ANSN += A[i]
        for i in range((J-1)//2-K):
            B = A[2*i+1:2*i+2+2*K]
            ANSL.append(sum(B))
        ANSL.append(ANSM)
        ANSL.append(ANSN)
        print(max(ANSL))
elif (S[0] == '0') & (S[-1] == '1'):
    if J <= 2*K:
        print(sum(A))
    else:
        ANSL = []
        ANSM = 0
        for i in range(2*K):
            ANSM += A[i]
        for i in range(J//2-K):
            B = A[2*i+1:2*i+2*K+2]
            ANSL.append(sum(B))
        ANSL.append(ANSM)
        print(max(ANSL))
else:
    A.reverse()
    if J <= 2*K-1:
        print(sum(A))
    else:
        ANSL = []
        ANSM = 0
        for i in range(2*K):
            ANSM += A[i]
        for i in range(J//2-K):
            B = A[2*i-1:2*i+2*K]
            ANSL.append(sum(B))
        ANSL.append(ANSM)
        print(max(ANSL))

### FIXED CODE ###

N,K = map(int,input().split())
S = list(input())

if len(S) == 1:
    print(1)
elif len(S) == 2:
    print(2)
elif S[0] == '0':
    LA = [0]
    LB = [0]
    for i in range(0,N-1):
        if (S[i] != S[i+1]) & (S[i] == '0'):
            LA.append(i+1)
    for i in range(1,N-1):
        if (S[i] != S[i+1]) & (S[i] == '1'):
            LB.append(i)
    LB.append(N-1)
    ANS = 0
    if K >= len(LB)-1:
        print(N)
    else:
        for i in range(len(LB)-K):
            J = LB[i+K]-LA[i]+1
            if J > ANS:
                ANS = J
        print(ANS)
else:
    LA = [0]
    LB = []
    for i in range(0,N-1):
        if (S[i] != S[i+1]) & (S[i] == '0'):
            LA.append(i+1)
        elif (S[i] != S[i+1]) & (S[i] == '1'):
            LB.append(i)
    LB.append(N-1)
    ANS = 0
    if K >= len(LB)-1:
        print(N)
    else:
        for i in range(len(LB)-K):
            J = LB[i+K]-LA[i]+1
            if J > ANS:
                ANS = J
        print(ANS)
### BUGGY CODE ###

H, W, K = map(int, input().split())

area = [input() for _ in range(H)]
ans = float('inf')
S = []
for w in range(W):
    s = [0, ]
    for h in range(H):
        if area[h][w] == '1':
            s.append(s[-1]+1)
        else:
            s.append(s[-1])
    S.append(s)

for i in range(1 << H-1):
    flag = False
    tmp_ans = 0

    tmp = 0
    flag1 = [False for _ in range(H)]
    flag1[-1] = True
    for j in range(H):
        if i >> j & 1 == 1:
            tmp_ans += 1
            flag1[j] = True
    T = tmp_ans+1
    counter = [0 for _ in range(T)]

    for w in range(W):
        tmp_counter = []
        before = 0
        for k, f in enumerate(flag1):
            if f:
                tmp_counter.append(S[w][k+1] - S[w][before])
                before = k+1
        
        for tmp in tmp_counter:
            if tmp > K:
                flag = True
        if flag:
            tmp_ans = float('inf')
            break

        for k, tmp in enumerate(tmp_counter):
            if counter[k]+tmp > K:
                tmp_ans += 1
                counter = tmp_counter
                break
            else:
                counter[k] += tmp
    ans = min(ans, tmp_ans)

print(ans)


### FIXED CODE ###

H, W, K = map(int, input().split())

area = [input() for _ in range(H)]
ans = float('inf')
S = []
for w in range(W):
    s = [0, ]
    for h in range(H):
        if area[h][w] == '1':
            s.append(s[-1]+1)
        else:
            s.append(s[-1])
    S.append(s)

for i in range(1 << H-1):
    flag = False
    tmp_ans = 0

    tmp = 0
    flag1 = [False for _ in range(H)]
    flag1[-1] = True
    for j in range(H):
        if i >> j & 1 == 1:
            tmp_ans += 1
            flag1[j] = True
    T = tmp_ans+1
    counter = [0 for _ in range(T)]

    for w in range(W):
        tmp_counter = []
        before = 0
        for k, f in enumerate(flag1):
            if f:
                tmp_counter.append(S[w][k+1] - S[w][before])
                before = k+1
        
        for tmp in tmp_counter:
            if tmp > K:
                flag = True
        if flag:
            tmp_ans = float('inf')
            break

        for k, tmp in enumerate(tmp_counter):
            if counter[k]+tmp > K:
                tmp_ans += 1
                counter = tmp_counter
                break
            else:
                counter[k] += tmp
    ans = min(ans, tmp_ans)

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

k, s = list(map(int, input().split()))
k = k+1

count = 0

for x in range(k):
    for y in range(k):
        for z in range(k):
            if s == x + y + z:
                count += 1

print(count)

### FIXED CODE ###

k, s = list(map(int, input().split()))
k = k+1

count = 0
for x in range(k):
    for y in range(k):
        z = s - x - y
        if z >=0 and z < k:
            count += 1

print(count)
### BUGGY CODE ###

import fractions
K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans=fractions.gcd(fractions.gcd(i,j),k)
      sum=sum+ans
      
print(sum)

### FIXED CODE ###

import math

K=int(input())
sum=0


for i in range(1,K+1):
    for j in range(1,K+1):
        a=math.gcd(i,j)
        for k in range(1,K+1):
            b=math.gcd(a, k)
            sum = sum + b

print(sum)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
Query = [tuple(map(int, input().split())) for _ in range(Q)]
from collections import Counter
cntr = Counter(A)
keys = list(cntr.keys())
for b, c in Query:
    cntr[c] += cntr[b]
    cntr[b] = 0
    ans = 0
    for k, v in cntr.items():
        ans += k * v
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
Query = [tuple(map(int, input().split())) for _ in range(Q)]
from collections import Counter
cntr = Counter(A)
ans = sum(A)
for b, c in Query:
    if cntr.get(b) == None:
        print(ans)
        continue
    diff = (c - b) * cntr[b]
    ans += diff
    print(ans)
    cntr[c] += cntr[b]
    cntr[b] = 0
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
# i-indexed
A = [deque() for _ in range(N+1)]
for i in range(1,N+1):
    for j in input().split():
        A[i].append(int(j))

def is_not_empty():
    for x in A:
        if len(x) != 0:
            return True
    return False

answer = 0
while is_not_empty():
    played = []
    append = played.append
    for i in range(1,N+1):
        if i in played:
            continue
        if len(A[i]) == 0:
            continue
        enemy = A[i].popleft()
        ME = A[enemy].popleft()
        if ME == i and not(enemy in played):
            append(ME)
            append(enemy)
        else:
            A[i].appendleft(enemy)
            A[enemy].appendleft(ME)
    if len(played) == 0:
        print(-1)
        exit()
    answer += 1

print(answer)

### FIXED CODE ###

# O(N)
def is_not_empty(A):
    for x in A:
        if x:
            return True
    return False

def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    N = int(input())
    # 1-indexed
    A = [deque() for _ in range(N+1)]
    # O(N^2)
    for i in range(1,N+1):
        for j in input().split():
            A[i].append(int(j))

    # 当日の参加者
    today = set()
    # 初日
    for i in range(1,N+1):
        # 既に参加した人はダメ
        if i in today:
            continue
        enemy = A[i].popleft()
        ME = A[enemy].popleft()
        if ME == i and not(enemy in today):
            today.add(ME)
            today.add(enemy)
        else:
            A[i].appendleft(enemy)
            A[enemy].appendleft(ME)
    # 初日に誰も試合できなかったとき
    if not today:
        print(-1)
        exit()

    # 前日の参加者
    yesterday = today
    # 日数
    answer = 1
    while is_not_empty(A):
        today = set()
        # 前日に試合した人は必ず次の日に試合する
        for i in yesterday:
            if not A[i]:
                continue
            if i in today:
                continue
            enemy = A[i].popleft()
            ME = A[enemy].popleft()
            if ME == i and not(enemy in today):
                today.add(ME)
                today.add(enemy)
            else:
                A[i].appendleft(enemy)
                A[enemy].appendleft(ME)
        if not today:
            print(-1)
            exit()
        answer += 1
        yesterday = today

    print(answer)

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

K,A,B = input().split()
K = int(K)
A = int(A)
B = int(B)
bi = 1

step = K
for num in range(K):
    if(step >= 1):
        if(B-A>1):
            if(step>2):
                if(bi>=A):
                    bi += B-A
                    step -= 1
                else:
                    bi+=1
            else:
                bi+=1
        else:
            bi+=1
        
        step-=1
    else:
        break

print(bi)


### FIXED CODE ###

K,A,B = input().split()
K = int(K)
A = int(A)
B = int(B)
bi = 1

if(B-A<=2):
    bi+=K
else:
    bi=A
    #print(bi)
    K1=K-(A-1)
    #print(K-(A-1))
    bi+=((K1)//2)*(B-A)
    #print(((K1)//2)*(B-A))
    bi+=((K1)%2)
    #print(((K1)%2))
print(bi)
### BUGGY CODE ###

import math
import sys

import numpy as np
from scipy.special import comb

N = int(input())
if N < 2:
    print(0)
    sys.exit()

# Num of arrays consist of 0 and 9 only
# (but subtract a number of 0-only and 9-only arrays)
ans = np.power(2, N) - 2
x = 1
while 2 + x <= N:
    # Fill x sheets by 1~8
    ans += (np.power(2, (N - x)) - 2) * comb(N, x, exact=True) * np.power(8, x)
    x += 1
print(ans % (10 ** 9 + 7))

### FIXED CODE ###

def powmod(x, y, mod):
    res = pow(x, y) % mod
    return res

N = int(input())
mod = pow(10, 9) + 7
# (x + y) mod z = (x mod z + y mod z) mod z
ans = powmod(10, N, mod) - 2 * powmod(9, N, mod) + powmod(8, N, mod)
ans = ans % mod
print(ans)
### BUGGY CODE ###

import collections
import sys
n = int(input())
d = list(map(int, input().split()))


if d[0]!=0:
    print(0)
    sys.exit(0)
    

m=[1]
p=1


for i in range(1,max(d)+1):
    if d.count(i)==0:
        print(0)
        sys.exit(0)
    elif d[i]==0:
        print(0)
        sys.exit(0)
    else:
        tmp = 1
        for j in range(d.count(i)):
            tmp = (tmp * d.count(i-1)%998244353)%998244353
            
        p = (p * tmp)%998244353
    

print(p)

### FIXED CODE ###

import collections
import sys

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

cnt = collections.Counter(d)

if d[0]!=0:
    print(0)
    sys.exit(0)

if cnt[0]!=1:
    print(0)
    sys.exit(0)    
    
p = 1

for i in range(1,max(d)+1):
    if cnt[i] == 0:
        print(0)
        sys.exit(0)  
    else:
        p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353

print(p)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
H,W,M=map(int, input().split())#slow,行数H、列数W、爆弾数M
hcnt=[0]*H#何行目に何個あるか
wcnt=[0]*W#何列目に何個あるか
bomb=[]

for i in range(M):
    bh,bw=map(int,input().split())
    hcnt[bh-1]+=1#行方向
    wcnt[bw-1]+=1#列方向
    bomb.append([bh-1,bw-1])
#hcnt [2,1]
#wcnt[1,1,1]
#bomb[[2,2],[1,1],[1,3]]
hmax = max(set(hcnt))#2
wmax = max(set(wcnt))#1
hmaxindex = [i for i in range(H) if hcnt[i]==hmax]#[0]
wmaxindex = [i for i in range(W) if wcnt[i]==wmax]#[0,1,2]
#crosspoint has not bomb

for i in hmaxindex:
    for j in wmaxindex:
        if bomb.count([i,j])==0:
            print(hmax + wmax)
            sys.exit()
        else:
            continue
#all crosspoint has bomb
print(hmax+wmax-1)

### FIXED CODE ###


import sys
from collections import Counter

H, W, M = map(int, sys.stdin.readline().rstrip().split())#行数H、列数W、爆弾数M
hcnt = [0] * H#何行目に何個あるか
wcnt = [0] * W#何列目に何個あるか
bomb = []

for i in range(M):
    bh,bw=map(int,sys.stdin.readline().rstrip().split())
    hcnt[bh - 1] += 1#行方向
    wcnt[bw - 1] += 1#列方向
    bomb.append((bh - 1,bw - 1))
#hcnt [2,1]
#wcnt[1,1,1]
#bomb[[1,1],[0,0],[0,2]]
hmax = max(hcnt)#2
wmax = max(wcnt)#1

crs = 0#hmax and wmax crosspoint
for (i, j) in bomb:
    if hcnt[i] == hmax and wcnt[j] == wmax:
        crs += 1
#all crosspoint has bomb
if crs == Counter(hcnt)[hmax] * Counter(wcnt)[wmax]:
    print(hmax + wmax - 1)
#more than one crosspoint has no bomb
else:
    print(hmax + wmax)
### BUGGY CODE ###

from collections import deque

n,m=map(int,input().split())
node=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)


seen=[False]*n
depth=[0]*n
todo=deque([])
todo.append(0)
    
    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if not (i in todo):
            depth[i]+=depth[p]+1
            todo.append(i)
    todo.popleft()



#print(depth)

sekai=[]

for i in range(1,n):
    for j in node[i]:
        if depth[j]<depth[i]:
            sekai.append(j+1)
            break

if len(sekai)!=n-1:
    print('No')
else:
    print("Yes")
    for a in sekai:
        print(a)

### FIXED CODE ###

from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break
### BUGGY CODE ###

L, R = map(int, input().split())
R = min(R, L+4038)
ans = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min((i*j) % 2019, ans)
print(ans)


### FIXED CODE ###

L, R = map(int, input().split())
R = min(R, L+4038)
ans = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min((i*j) % 2019, ans)
print(ans)
### BUGGY CODE ###

N = int(input())
mod = 1000000007

ans = 1
for i in range(1,N+1):
  ans *= i
print(ans %mod)

### FIXED CODE ###

N = int(input())
mod = int(1e9)+7

ans = 1
for i in range(1,N+1):
  ans = (ans*i) %mod
print(ans)
### BUGGY CODE ###

n = int(input())
s = 1
t = 0
for i in range(1, n+1):
  s *= i
for i in range(1, s+1):
  if s % i == 0:
    t += 1
print(t % (10 ** 9 + 7))

### FIXED CODE ###

n = int(input())
s = 1
ans = 1
for i in range(1, n+1):
  s *= i
for i in range(2, n+1):
  k = 1
  while s % i == 0:
    s = s // i
    k += 1
  ans *= k
print(ans % (10 ** 9 + 7))
### BUGGY CODE ###

import sys


def get_sliding_minimum_element(nums, k):
    res = []
    queue = []
    for i, v in enumerate(nums):
        if queue and queue[0] <= i - k:
            queue = queue[1:]
        while queue and nums[queue[-1]] > v:
            queue.pop()
        queue.append(i)
        if i + 1 >= k:
            res.append(nums[queue[0]])
    return res


line = sys.stdin.readline()
n, l = map(int, line.split())
arr = list(map(int, input().split()))
res = get_sliding_minimum_element(arr, l)
print(' '.join(map(str, res)))



### FIXED CODE ###

import sys


def get_sliding_minimum_element(nums, k):
    res = []
    queue = []
    for i, v in enumerate(nums):
        if queue and queue[0] <= i - k:
            queue = queue[1:]
        while queue and nums[queue[-1]] > v:
            queue.pop()
        queue.append(i)
        if i + 1 >= k:
            res.append(nums[queue[0]])
    return res


b = [0 for _ in range(1000000)]
deq = [0 for _ in range(1000000)]

line = sys.stdin.readline()
n, l = map(int, line.split())
arr = list(map(int, input().split()))
s = 0
t = 0
for i in range(n):
    while s < t and arr[deq[t - 1]] >= arr[i]:
        t -= 1
    deq[t] = i
    t += 1
    if i - l + 1 >= 0:
        b[i - l + 1] = arr[deq[s]]
        if deq[s] == i - l + 1:
            s += 1

for i in range(n-l+1):
    if i == n - l:
        print(str(b[i]), end='')
    else:
        print(str(b[i]) + " ", end='')
print("\n", end='')
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def bs(f, mi, ma):
    mm = -1
    while ma > mi + eps:
        mm = (ma+mi) / 2.0
        if f(mm):
            mi = mm + eps
        else:
            ma = mm
    if f(mm):
        return mm + eps
    return mm

def main():
    xy = sorted([LI() for _ in range(3)])
    x = list(map(lambda _: _[0] - xy[0][0], xy))
    y = list(map(lambda _: _[1] - xy[0][1], xy))
    a = []
    for i in range(3):
        a.append(((x[i] - x[i-1])**2 + (y[i] - y[i-1])**2) ** 0.5)
    ma = max(a)
    s = abs(x[1]*y[2] - x[2]*y[1]) / 2
    r = 2 * s / sum(a)

    def f(i):
        return (1-i/r) * ma - 2*i > 0


    return bs(f, 0, ma)




print(main())



### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def bs(f, mi, ma):
    mm = -1
    while ma > mi + eps:
        mm = (ma+mi) / 2.0
        if f(mm):
            mi = mm + eps
        else:
            ma = mm
    if f(mm):
        return mm + eps
    return mm

def main():
    xy = sorted([LI() for _ in range(3)])
    x = list(map(lambda _: _[0] - xy[0][0], xy))
    y = list(map(lambda _: _[1] - xy[0][1], xy))
    a = []
    for i in range(3):
        a.append(((x[i] - x[i-1])**2 + (y[i] - y[i-1])**2) ** 0.5)
    ma = max(a)
    s = abs(x[1]*y[2] - x[2]*y[1]) / 2
    r = 2 * s / sum(a)

    def f(i):
        return (1-i/r) * ma - 2*i > 0


    return bs(f, 0, ma)




print(main())
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i]<l[j]+l[k] and l[j]<l[k]+l[i] and l[k]<l[i]+l[j]:
        ans += 1
print(ans)

### FIXED CODE ###

from  bisect import bisect_left

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

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)
### BUGGY CODE ###

def getCalc(AAA, BBB):
    sum = 0
    for i in range(len(AAA)):
        sum += AAA[i] * BBB[i]
    return sum


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

AAA = []
BBB = []

for i in range(10 ** 5 + 1):
    count = A.count(i)
    if (count > 0):
        AAA.append(i)
        BBB.append(count)

total = getCalc(AAA, BBB)

for i in range(Q):
    if (B[i] in AAA):
        index = AAA.index(B[i])

        if(C[i] in AAA):
            Cindex = AAA.index(C[i])
            AAA[index] = C[i]
            BBB[index] += BBB[Cindex]
            AAA.pop(Cindex)
            BBB.pop(Cindex)
        else:
            AAA[index] = C[i]

        total = getCalc(AAA, BBB)

    print(total)


### FIXED CODE ###


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

max_num = max(max(A), max(B), max(C))

NUM = [0] * (max_num + 1)

num_list = []

for a in A:
    NUM[a] += 1

total = sum(A)

for i in range(Q):

    total += (C[i] - B[i]) * NUM[B[i]]
    NUM[B[i]], NUM[C[i]] = 0, NUM[B[i]] + NUM[C[i]]

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


url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    Xs_dic = {i: Xs[i] for i in range(len(Xs))}
    for i in range(len(Xs)):
        tmp = Xs_dic.copy()
        tmp.pop(i)
        tmp = sorted(list(tmp.values()))
        print(tmp[(len(tmp)) // 2])

if __name__ == '__main__':
    main()


### FIXED CODE ###


url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    sort_Xs = sorted(Xs)
    front = len(sort_Xs) // 2 - 1
    rear = len(sort_Xs) // 2
    for X in Xs:
        if sort_Xs[rear] > X:
            print(sort_Xs[rear])
        else:
            print(sort_Xs[front])



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

s = t = input()

ans = 0
flag = True
while flag:
    s = s.replace('01','').replace('10','')
    if len(s) == len(t):
        flag = False
    else:
        ans += len(t) - len(s)
        t = s

print(ans)

### FIXED CODE ###

s = input()
c0 = s.count('0')
c1 = s.count('1')  # len(s)-c0
print(2 * min(c0, c1))
### BUGGY CODE ###

import numpy as np
n,k=map(int, input().split())
a=list(map(int, input().split()))
a2=[0]
for i in a:
    a2.append(a2[-1]+i)
c=dict()
for i in range(n+1):
    for j in range(i,n+1):
        if j>i:
            c[a2[j]-a2[i]]=c.get(a2[j]-a2[i],0)+1
keys=list(c.keys())
keys.sort()
keys2=[bin(i).split('b')[1] for i in keys]
maxb=len(keys2[-1])
keys2=[i.zfill(maxb) for i in keys2]
bin_list=[]
for i in keys2:
    bin_list.append(list(map(int,list(i))))
bin_list=np.array(bin_list)
for i,j in enumerate(keys):
    bin_list[i]=bin_list[i]*c[j]
bin_list
ans=0
l=0
while l<maxb:
    if bin_list[:,l].sum()>=k:
        ans+=2**(maxb-l-1)
        bin_list=bin_list[bin_list[:,l]>0]
    l+=1
print(ans)

### FIXED CODE ###

n,k=map(int, input().split())
a=list(map(int, input().split()))
a2=[0]
for i in a:a2.append(a2[-1]+i)
c=[]
for i in range(0,n+1):
    for j in range(i+1,n+1):c.append(a2[j]-a2[i])

ans=0
for i in range(40,-1,-1):
    n2=2**i
    c2=[i for i in c if i&n2==n2]
    if len(c2)>=k:
        ans+=n2
        c=c2
print(ans)