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

N, W = map(int, input().split())
K = []
for _ in range(N):
    K.append(list(map(int, input().split())))
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for w in range(W+1):
        wi, vi = K[i]
        if wi<=w:
            dp[i+1][w] = max(dp[i][w-wi]+vi, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[-1][-1])

### FIXED CODE ###

N, W = map(int, input().split())
K = [[] for i in range(N)]
for i in range(N):
    K[i] = list(map(int, input().split()))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
    w, v = K[i-1]
    for sum_w in range(W+1):
        if sum_w-w>=0:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w]+v)
        else:
            dp[i][sum_w] = dp[i-1][sum_w]
print(dp[-1][-1])
### BUGGY CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

c = 1
for i in range(K):
    c *= A[i]

for i in range(K, N):
    if c < c//A[i-K]*A[i]:
        print('Yes')
    else:
        print('No')
    c = c//A[i-K]*A[i]


### FIXED CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    count=0
    mi=P[0]
    for i in range(1,N+1):
        ans=P[:i]
        if i==1:
            count+=1
            #print(i)
        else:
            if min(mi,ans[-1])==ans[-1]:
                count+=1
                mi=ans[-1]
                #print(i)
    print(count)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    count=0
    mi=P[0]
    for i in range(1,N+1):
        if i==1:
            count+=1
            #print(i)
        else:
            if min(mi,P[i-1])==P[i-1]:
                count+=1
                mi=P[i-1]
                #print(i)
    print(count)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

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

s = input()

cnt = 0

while '01' in s or '10' in s:
    if '01' in s:
        s = s.replace('01','', 1)
        cnt += 1
        continue
    if '10' in s:
        s = s.replace('10','', 1)
        cnt += 1
        continue

print(cnt*2)


### FIXED CODE ###

s = input()
leng = len(s)
zero = s.count('0')
one = s.count('1')
print(2*min(zero, one))
### BUGGY CODE ###

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

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

for i in range(N-1):
    for j in range(i+1,N):
        dist = min( j-i , abs(X-1-i)+1+abs(Y-1-j) , abs(Y-1-i)+1+abs(X-1-j) )
        k[dist-1] += 1

print('\n'.join(map(str,k)))


### FIXED CODE ###

from collections import defaultdict
N,X,Y = map(int,input().split())

k = defaultdict(lambda: 0)

for i in range(N-1):
    for j in range(i+1,N):
        dist = min( j-i , abs(X-1-i)+1+abs(Y-1-j) , abs(Y-1-i)+1+abs(X-1-j) )
        k[dist] += 1

for i in range(1,N):
    print(k[i])
### BUGGY CODE ###


from collections import deque
def resolve():
    drc4 = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + drc4]

    H, W = map(int, input().split())
    sy, sx = map(lambda x: int(x) - 1, input().split())
    gy, gx = map(lambda x: int(x) - 1, input().split())
    G = [input() for _ in range(H)]

    INF = 10 ** 7
    ans = [[INF] * W for _ in range(H)]

    q = deque()
    q.append((sy, sx, 0))
    ans[sy][sx] = 0

    while q:
        sy, sx, cost = q.popleft()
        for dy, dx in drc4:
            ny, nx = dy + sy, dx + sx
            if 0 <= ny < H and 0 <= nx < W and G[ny][nx] == "." and ans[ny][nx] > cost:
                ans[ny][nx] = cost
                q.append((ny, nx, cost))

        for dy8, dx8 in warp:
            ny8, nx8 = dy8 + sy, dx8 + sx
            if 0 <= ny8 < H and 0 <= nx8 < W and G[ny8][nx8] == "." and ans[ny8][nx8] > cost + 1:
                ans[ny8][nx8] = cost + 1
                q.append((ny8, nx8, cost + 1))

    res = ans[gy][gx] if ans[gy][gx] < INF else -1
    print(res)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###


from collections import deque
def resolve():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]

    INF = 10 ** 12
    path = [[INF] * W for _ in range(H)]

    q = deque()
    path[Ch][Cw] = 0
    q.append((Ch, Cw, 0))

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s))
        for dx, dy in warp:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s + 1))

    ans = path[Dh][Dw] if path[Dh][Dw] < INF else -1
    print(ans)


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

from fractions import gcd

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

S = input()
T = input()

L = N * M // gcd(N, M)

X = ['.' for _ in range(L)]

for i in range(N):
    p = i * L // N
    X[p] = S[i]

for i in range(M):
    p = i * L // M
    if X[p] != '.' and X[p] != T[i]:
        print(-1)
        exit()

print(L)


### FIXED CODE ###

from fractions import gcd

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

S = input()
T = input()

G = gcd(N, M)

n = N // G
m = M // G

L = N * M // G

for i in range(0, G):
    a = i * n
    b = i * m

    if S[a] != T[b]:
        print(-1)
        exit()

print(L)
### BUGGY CODE ###


def check1(a):
  sum = 0
  for i in range(len(a)):
    if(i % 2 == 0):
      sum += a[i]
      if(a[i] >= 0 or sum >= 0):
        return (i, -1)
    else:
      sum += a[i]
      if(a[i] <= 0 or sum <= 0):
        return (i, 1)
  return True

def check2(a):
  sum = 0
  for i in range(len(a)):
    if(i % 2 == 0):
      sum += a[i]
      if(a[i] <= 0 or sum <= 0):
        return (i, 1)
    else:
      sum += a[i]
      if(a[i] >= 0 or sum >= 0):
        return (i, -1)
  return True



n = input()
b = input().split()
a = [int(b[i]) for i in range(len(b))]
a2 = list(a)

ans1 = 0
ans2 = 0

while(True):
  c = check1(a)
  if(c == True):
    break

  a[c[0]] += c[1]
  ans1 += 1


while(True):
  c = check2(a2)
  if(check2(a2) == True):
    break
  a2[c[0]] += c[1]
  ans2 += 1


print(ans1) if(ans1<ans2) else print(ans2)

### FIXED CODE ###


def check1(a):
  sum = 0
  ans = 0
  for i in range(len(a)):
    if(i % 2 == 0):
      sum += a[i]
      if(sum >= 0):
        a[i] -= abs(sum)+1
        ans += abs(sum)+1
        sum -= abs(sum)+1
    else:
      sum += a[i]
      if(sum <= 0):
        a[i] += abs(sum)+1
        ans += abs(sum)+1
        sum += abs(sum)+1
  return ans

def check2(a):
  sum = 0
  ans = 0
  for i in range(len(a)):
    if(i % 2 == 0):
      sum += a[i]
      if(sum <= 0):
        a[i] += abs(sum)+1
        ans += abs(sum)+1
        sum += abs(sum)+1
    else:
      sum += a[i]
      if(sum >= 0):
        a[i] -= abs(sum)+1
        ans += abs(sum)+1
        sum -= abs(sum)+1
  return ans



n = input()
b = input().split()
a = [int(b[i]) for i in range(len(b))]
a2 = list(a)

ans1 = check1(a)
ans2 = check2(a2)


print(ans1) if(ans1<ans2) else print(ans2)
### BUGGY CODE ###

from collections import Counter

def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
A=list(map(int,input().split()))
C=Counter(A)
ans=0
L=[0]*N
for i in range(N):
    L[A[i]-1]+=1
for i in range(len(C)):
    ans+=Comb(C.most_common()[i][1],2)
for i in range(N):
    pri=ans
    pri=ans-Comb(L[A[i]-1],2)+Comb(L[A[i]-1]-1,2)
    print(pri)

### FIXED CODE ###

from collections import Counter

def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
A=list(map(int,input().split()))
C=Counter()
C.update(A)
ans=0
L=[0]*N
for i in range(N):
    L[A[i]-1]+=1
Most=C.most_common()
#print(Most)
for i in range(len(C)):
    ans+=Comb(Most[i][1],2)
for i in range(N):
    pri=ans
    pri=ans-L[A[i]-1]+1
    print(pri)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**7)

n=int(input())
L=list(map(int,input().split()))
A = L.count(1)
B = L.count(2)
C = L.count(3)
ABC = A + B + C
dp=[[[-0.1] * (n+1) for i in range(n+1)] for i in range(n+1)]

def rec (a,b,c):
  if not (a >= 0 and b >= 0 and c >= 0):
    return 0
  if a == b == c == 0:
    return 0
  if dp[a][b][c] >= 0.0:
    return dp[a][b][c]
  result = n
  result += rec(a-1,b,c) * a
  result += rec(a+1,b-1,c) * b
  result += rec(a,b+1,c-1) * c
  dp[a][b][c] = result / (a+b+c)
  return dp[a][b][c]

print(rec(A,B,C))

### FIXED CODE ###

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

S = [0] * 3
for a in A:
  S[a-1] += 1
I, J, K = S

dp = [[[0.0] * (N+1) for j in range(N+1)] for i in range(N+1)]

for k in range(S[2] + 1):
  for j in range(S[1] + S[2] - k + 1):
    for i in range(S[0] + S[1] + S[2] - j - k + 1):
      if i == j == k == 0: continue
      dp[i][j][k] = (i * (dp[i-1][j][k] if i > 0 else 0) + j * (dp[i+1][j-1][k] if j > 0 else 0) + k * (dp[i][j+1][k-1] if k > 0 else 0) + N) / (i + j + k)

print(dp[I][J][K])
### BUGGY CODE ###

N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
  S[l] = ''.join(S[l]) 

S.sort()
for k in range(N):
  S[k] = list(S[k])
ans = 0

for j in range(N-1):
  for m in range(j+1,N):
    p = 0
    q = 1
    while p < 10:
      if S[j][p] == S[m][p]:
        p += 1
      else:
        q = 0
        break
    ans += q

print(ans)


### FIXED CODE ###

from operator import itemgetter
N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
  S[l] = ''.join(S[l]) 

S.sort()

X = []
p = 1

for j in range(N-1):
  if S[j] == S[j+1]:
    p +=1
  else:
    X.append(p)
    p = 1
X.append(p)


def comb(n):
  if n == 2: return 1
  else:
    return int(n*(n-1)/2)

ans = 0

for k in range(len(X)):
  ans += comb(X[k])

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

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

answer = [0] * len(S)
b_list = []
for idx, moji in enumerate(S):
    if moji == "a" and sum(answer) < A + B:
        answer[idx] = 1
        print("Yes")
        continue
    elif moji == "b":
        b_list.append(1)
        if sum(answer) < A + B and sum(b_list) <= B:
            answer[idx] = 1
            print("Yes")
            continue
    print("No")


### FIXED CODE ###

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

answer = 0
b_list = 0
for idx, moji in enumerate(S):
    if moji == "a" and answer < A + B:
        answer += 1
        print("Yes")
        continue
    elif moji == "b":
        b_list += 1
        if answer < A + B and b_list <= B:
            answer += 1
            print("Yes")
            continue
    print("No")
### BUGGY CODE ###

n = int(input())
towns = []  # coordinates, populations of towns

for _ in range(n):
    x, y, p = map(int, input().split())
    towns.append((x, y, p))

INF = 10 ** 18
ans = [INF] * (n + 1)

for bit in range(1 << n):
    k = bin(bit).count('1')
    i = 0
    t = bit
    selected = []
    while t:
        if t & 1:
            selected.append(i)
        t >>= 1
        i += 1

    for bit2 in range(1 << k):
        i = 0
        t = bit2
        road = [set(), set()]
        for _ in range(k):
            road[t & 1].add(towns[selected[i]][t & 1])
            t >>= 1
            i += 1
        cost = 0
        for x, y, p in towns:
            town_dist = min(abs(x), abs(y))
            for rx in road[0]:
                town_dist = min(town_dist, abs(rx - x))
            for ry in road[1]:
                town_dist = min(town_dist, abs(ry - y))
            cost += town_dist * p
        kk = len(selected)
        ans[kk] = min(ans[kk], cost)

print('\n'.join(map(str, ans)))


### FIXED CODE ###

import os
import sys

import numpy as np


def solve(inp):
    n = inp[0]
    xxx = inp[1::3]
    yyy = inp[2::3]
    ppp = inp[3::3]

    ans = np.full(n + 1, 10 ** 18, dtype=np.int64)

    default_dist = np.zeros(n, dtype=np.int64)
    for i in range(n):
        default_dist[i] = min(abs(xxx[i]), abs(yyy[i]))

    for bit in range(1 << n):
        k = (bit & 0x5555) + (bit >> 1 & 0x5555)
        k = (k & 0x3333) + (k >> 2 & 0x3333)
        k = (k & 0x0f0f) + (k >> 4 & 0x0f0f)
        k = (k & 0x00ff) + (k >> 8 & 0x00ff)

        i = 0
        cur = 0
        t = bit
        selected = np.zeros(k, dtype=np.int64)
        is_selected = np.zeros(n, dtype=np.int8)
        while t:
            if t & 1:
                selected[cur] = i
                is_selected[i] = 1
                cur += 1
            t >>= 1
            i += 1

        for bit2 in range(1 << k):
            cost = 0
            for i in range(n):
                if is_selected[i]:
                    continue
                town_dist = default_dist[i]
                t = bit2
                for j in range(k):
                    if t & 1:
                        town_dist = min(town_dist, abs(yyy[selected[j]] - yyy[i]))
                    else:
                        town_dist = min(town_dist, abs(xxx[selected[j]] - xxx[i]))
                    t >>= 1
                cost += town_dist * ppp[i]
            kk = len(selected)
            ans[kk] = min(ans[kk], cost)

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))
### BUGGY CODE ###

import math

N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()
#print("initial A B")
#print(A)
#print(B)
cnt=0
for i in range(N):
    tmp=math.ceil(A[i]/B[i])*B[i]-A[i]
    for j in range(i,N):
        A[j]+=tmp
    cnt+=tmp
    #print("tmp,cnt,A",tmp,cnt,A)
print(cnt)

### FIXED CODE ###

import math

N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()
cnt=0
for i in range(N):
    A[i]+=cnt
    tmp=math.ceil(A[i]/B[i])*B[i]-A[i]
    cnt+=tmp
print(cnt)
### BUGGY CODE ###

K=int(input())
import math
p=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      p+=math.gcd(i,math.gcd(j,k))
print(p)

### FIXED CODE ###

K=int(input())
import math
def f(x):
  if x==1:
    return 1
  elif x==2:
    return 9
  else:
    m=0
    for j in range(1,x):
      m+=math.gcd(j,x)*6
    for i in range(1,x-1):
      for k in range(i+1,x):
        m+=math.gcd(x,math.gcd(i,k))*6
    return m+x+f(x-1)
print(f(K))
### BUGGY CODE ###

input()
S = [i for i in input()]
flag = True
while flag:
  flag = False
  for i in range(0,len(S)-1):
    if S[i] == S[i+1]:
      del S[i]
      flag = True
      break
print(len(S))

### FIXED CODE ###

input()
S = [i for i in input()]
point = 0
del_list = list()
for i in range(point,len(S)-1):
  if S[i] == S[i+1]:
    del_list.append(i)
for i,j in enumerate(del_list,0):
  del S[j-i]
      
print(len(S))
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
cnt = N
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    if A[i] % A[j] == 0:
      cnt -= 1
      break
print(cnt)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
m = A[-1]
B = [0] * m
for a in A:
  B[a - 1] += 1
  if B[a - 1] == 1:
    for j in range(a * 2, m + 1, a):
      B[j - 1] = 2
print(B.count(1))
### BUGGY CODE ###

from sys import stdin
n, m = map(int, stdin.readline().split())
ans = set(range(1, n+1))
for i in range(m):
    l, r = map(int, stdin.readline().split())
    ans = ans & set(range(l, r+1))
print(len(ans))

### FIXED CODE ###

from sys import stdin
n, m = map(int, stdin.readline().split())
mn = 1
mx = n

for i in range(m):
    l, r = map(int, stdin.readline().split())
    mn = max(mn, l)
    mx = min(mx, r)
print(max(0, mx-mn+1))
### BUGGY CODE ###

S,W=map(int,input().split())
while 1<=S<=100:
  while 1<=W<=100:
    if S>W:
      print('safe')
    else:
      print('unsafe')

### FIXED CODE ###

S,W=map(int,input().split())

if S>W:
  print('safe')
else:
  print('unsafe')
### BUGGY CODE ###

n =int(input())
a=list(map(int, input().split()))
m=0
s=[]
for i in range(len(a)):
    m+=a[i]
    if len(s)!=0:
        mins=min(s)
    s.append(abs(sum(a)-m*2))
    if len(s)!=1 and mins<s[i]:
        break
print(min(s))

### FIXED CODE ###

n =int(input())
a=list(map(int, input().split()))
m=0
s=[]
suma=sum(a)
for i in range(len(a)):
    m+=a[i]
    s.append(abs(suma-m*2))
print(min(s))
### BUGGY CODE ###

s=input()
n=0
ans=0
A=[0]*2019
A[0]=1
for i in range(len(s)):
  n=(n+int(s[-1-i])*(10**i)%2019)%2019
  #print(i,n)
  A[n]+=1
for i in A:
  ans+=i*(i-1)//2
print(ans)

### FIXED CODE ###

s=input()
n=0
ans=0
A=[0]*2019
A[0]=1
for i,j in enumerate(reversed(s)):
  n=(n+int(j)*pow(10,i,2019))%2019
  #print(i,n)
  A[n]+=1
for i in A:
  ans+=i*(i-1)//2
print(ans)
### BUGGY CODE ###

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

mod = 2019
ans = 10000
a = [i%mod for i in range(l,r+1)]


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			break
			
print(ans)


### FIXED CODE ###

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

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

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

n, m = map(int, input().split())
ab = [list(map(int, list(input().split()))) for i in range(m)]

ab.sort(key = lambda x: x[1])
bridge = [False] * n
ans = 0
for i in range(m):
    sub = bridge[ab[i][0] : ab[i][1]]
    if True in sub:
        continue
    else:
        bridge[ab[i][1] - 1] = True
        ans += 1

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
ab = [list(map(int, list(input().split()))) for i in range(m)]

ab.sort(key=lambda x: x[1])
sub = -1
ans = 0
for i in range(m):
    if ab[i][0] <= sub and ab[i][1] > sub:
        continue
    else:
        ans += 1
        sub = ab[i][1] - 1

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

import copy

n = int(input())
x = [int(i) for i in input().split()]
sortedx = copy.copy(x)
sortedx.sort()

m = {}

for i in x:
    if i in m:
        print(m[i])
    else:
        cnt = 0
        flag = False
        for j in range(n):
            if i == sortedx[j] and not flag:
                flag = True
            elif cnt == (n/2)-1:
                print(sortedx[j])
                m[i] = sortedx[j]
                break
            else:
                cnt += 1      


### FIXED CODE ###

import copy

n = int(input())
x = [int(i) for i in input().split()]
sortedx = copy.copy(x)
sortedx.sort()

m = sortedx[int((n+1)/2)]

for i in x:
    if i < m:
        print(sortedx[int(n/2)])
    else:
        print(sortedx[int(n/2-1)])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n=int(input())  #数値入力 「N」だけの入力のとき
a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
f = 0
for i in range(0,n):
    if a[i] in a[i+1:]:
        print("NO")
        f = 1
        break
if f ==0:
    print("YES")

### FIXED CODE ###

# -*- coding: utf-8 -*-
n=int(input())  #数値入力 「N」だけの入力のとき
a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
f = 0
if len(a) != len(set(a)):
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

n=int(input())
line=str(input())
line=line.replace('E','0')
line=line.replace('W','1')
line=list(map(int,line))
v=n
for i in range(n):
  a1=line[0:i]
  a2=line[i+1:n]
  q=a1.count(1)+a2.count(0)
  if q<v:
    v=q
print(v)


### FIXED CODE ###

n=int(input())
s=input()
e=s.count('E')
w=0
ans=e+w
p=0
for i in s:
  if p==1:
    w+=1
    p=0
  if i=='E':
    e-=1
  else:
    p=1
  ans=min(ans,e+w)
print(ans)
### BUGGY CODE ###

def main():
    s=input()
    q=int(input())
    queryy=[]

    for i in range(q):
        queryy.append(tuple(input().split()))
    check=-1
    for query in queryy:
    #   print(query)
        if query[0]=="1":
            check*=-1
        else:
            if query[1]=="1":
                if check==-1:
                    s=str(query[2])+s
                else:
                    s+=str(query[2])
                    
            else:
                if check==-1:
                    s+=str(query[2])
                else:
                    s=str(query[2])+s
    if check==1:
        print(s[::-1]) 
    else:
        print(s)

if __name__=="__main__":
    main()      

### FIXED CODE ###

def main():
    s=input()
    q=int(input())
    queryy=[]
    sent="a"
    back="a"
    for i in range(q):
        queryy.append(tuple(input().split()))
    check=-1
    for query in queryy:
    #   print(query)
        if query[0]=="1":
            check*=-1
        else:
            if query[1]=="1":
                if check==-1:
                    sent+=str(query[2])
                   # s=str(query[2])+s
                else:
                    back+=str(query[2])
                   # s+=str(query[2])
                    
            else:
                if check==-1:
                    back+=str(query[2])
                    #s+=str(query[2])
                else:
                    sent+=str(query[2])
                    #s=str(query[2])+s
   # print(type(sent))
    #if sent[0]=="1":
     #   sent=sent[1:]
    sent=sent[1:]
    sent=sent[::-1]   
    back=back[1:]

    if check==1:
        s=sent+s+back        
        print(s[::-1]) 
    else:
        s=sent+s+back
        print(s)

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

def main():
  
  n, k, q = map(int, input().split())
  a = [ int(input()) for i in range(q) ]
  a_count = a.count

  for i in range(1,n+1):
    x = a_count(i)
    if k-q+x > 0:
      print('Yes')
    else:
      print('No')


if __name__ == '__main__':
  main()


### FIXED CODE ###

n, k, q = map(int, input().split())
a = [ int(input()) for i in range(q) ]
score = [k-q]*n
for i in a:
    score[i-1] += 1
for i in score:
    print('Yes' if i > 0 else 'No')