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

import collections
import sys
sys.setrecursionlimit(1000000)


# 入力
N = int(input())
A = [int(x) for x in input().split()]

# DPテーブルを初期化
dp = [[[-1 for k in range(310)] for j in range(310)] for i in range(310)]
dp[0][0][0] = 0


c = collections.Counter(A)
# print(c)

for k in range(0, c[3] + 1):
    for j in range(0, c[2]+c[3]-k + 1):
        for i in range(0, c[1]+c[2]+c[3]-j-k + 1):
            if i == j == k == 0:
                continue
            temp = N
            if i != 0:
                temp += i*dp[i - 1][j][k]
            if j != 0:
                temp += j*dp[i + 1][j - 1][k]
            if k != 0:
                temp += k*dp[i][j + 1][k - 1]
            dp[i][j][k] = temp / (i + j + k)


# 答えを得て出力
print(dp[c[1]][c[2]][c[3]])


### FIXED CODE ###

import collections

# 入力
N = int(input())
c = collections.Counter(list(map(int, input().split())))

# DPテーブルを初期化
dp = [[[0.0 for k in range(310)] for j in range(310)] for i in range(310)]


for k in range(0, c[3] + 1):
    for j in range(0, c[2]+c[3]-k + 1):
        for i in range(0, c[1]+c[2]+c[3]-j-k + 1):
            if i == j == k == 0:
                continue
            dp[i][j][k] = (N+i*dp[i - 1][j][k]+j *
                           dp[i + 1][j - 1][k]+k*dp[i][j + 1][k - 1])/(i+j+k)


# 答えを得て出力
print(dp[c[1]][c[2]][c[3]])
### BUGGY CODE ###

n = int(input())
print(sum([i+1 for i in range(n-1)]))

### FIXED CODE ###

n = int(input())

print(int((n-1)*n//2))
### BUGGY CODE ###

import sys
si = sys.stdin.readline


def BFS(g, s):
    d = 0
    dt = dict()
    visited = set()
    visited.add(s)
    Q = [s]

    while len(Q):
        d += 1
        Qs = len(Q)
        for _ in range(Qs):
            Qpop = Q[0]
            Q = Q[1:]
            for node in g[Qpop]:
                if node not in visited:
                    Q.append(node)
                    visited.add(node)
                    dt[node] = d
    return dt


def main():
    l = [int(e) for e in si().split()]
    n, u, v = l[0], l[1], l[2]
    graph = [[] for _ in range(n+1)]
    for _ in range(n-1):
        l = [int(e) for e in si().split()]
        graph[l[0]].append(l[1])
        graph[l[1]].append(l[0])

    udt = BFS(graph, u)
    vdt = BFS(graph, v)
    udt[u], vdt[v] = 0, 0

    vdmax = 0
    for i in range(1, n+1):
        if (vdt[i]-udt[i]) > 0 and vdt[i] > vdmax:
            vdmax = vdt[i]
    print(vdmax-1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

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


def BFS(g, s):
    d = 0
    dt = dict()
    visited = set()
    visited.add(s)
    Q = deque([s])

    while len(Q):
        d += 1
        Qs = len(Q)
        for _ in range(Qs):
            Qpop = Q.popleft()
            for node in g[Qpop]:
                if node not in visited:
                    Q.append(node)
                    visited.add(node)
                    dt[node] = d
    return dt


def main():
    l = [int(e) for e in si().split()]
    n, u, v = l[0], l[1], l[2]
    graph = [[] for _ in range(n+1)]
    for _ in range(n-1):
        l = [int(e) for e in si().split()]
        graph[l[0]].append(l[1])
        graph[l[1]].append(l[0])

    udt = BFS(graph, u)
    vdt = BFS(graph, v)
    udt[u], vdt[v] = 0, 0

    vdmax = 0
    for i in range(1, n+1):
        if (vdt[i]-udt[i]) > 0 and vdt[i] > vdmax:
            vdmax = vdt[i]
    print(vdmax-1)


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

import numpy as np
N = int(input())
A = list(map(int,input().split()))


x = np.array(A)

for i in range(len(x)):
    print (np.argsort(x)[i]+1,"",end="")

### FIXED CODE ###

import numpy as np
N = int(input())

x = np.array(list(map(int,input().split())),dtype=np.int)

print (*np.argsort(x)+1)
### BUGGY CODE ###

S = input()

length = len(S)

cnt = 0
temp = int(S[ : 4])
for x in range(length):
    first = temp
    for i in range(x + 4, length + 1):
        temp %= 2019
        if temp == 0:
            cnt += 1
        #print(temp, cnt)

        if i < length:
            temp = ((temp % 2019) * 10) % 2019
            temp = (temp + int(S[i])) % 2019
        else:
            if x + 4 < length:
                temp = (first - (int(S[x]) * 1000))
                temp = temp * 10 + int(S[x + 4])


print(cnt)



### FIXED CODE ###

S = input()[::-1]

length = len(S)
dp = [0] * (length + 2)

times = 1
for x in range(1, length + 1):
    dp[x] += dp[x - 1]
    dp[x] %= 2019
    dp[x] += int(S[x - 1]) * times
    dp[x] %= 2019
    times *= 10
    times %= 2019


cnt = [0] * 2020
for x in range(length + 1):
    cnt[dp[x]] += 1

ans = 0
for c in cnt:
    ans += (c * (c - 1)//2)

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

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a.sort(reverse=True); b.sort(reverse=True)

def k(a, b, n, m):
    c, s = 0, 1
    if (n * m not in a) or (n * m not in b):
        return 0
    for i in reversed(range(n * m)):
        try:
            x = a.index(i + 1) + 1
            row = 1
        except ValueError:
            row = 0
        try:
            y = b.index(i + 1) + 1
            column = 1
        except ValueError:
            column = 0

        if row * column:
            s *= 1
        elif not row * column and row + column:
            s *= column * x + row * y
        else:
            if x * y - c > 0:
                s *= x * y - c
            else:
                s = 0
                break
        c += 1
        if s > 10 ** 9 + 7:
            s %= 10 ** 9 + 7
    return s

if len(a) != n or len(b) != m:
    print(0)
else:
    print(k(a, b, n, m))


### FIXED CODE ###

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a = set(a); b = set(b)
#print(a, b)

def k(a, b, n, m):
    s = 1
    x, y = 0, 0
    if (n * m not in a) or (n * m not in b):
        return 0
    for i, j in enumerate(reversed(range(n * m))):

        if (j + 1 in a) and (j + 1 in b):
            x += 1; y += 1
            #continue
        elif j + 1 in a:
            y += 1
            s *= x
        elif j + 1 in b:
            x += 1
            s *= y
        else:
            if x * y - i > 0:
                s *= x * y - i
            else:
                s = 0
                break
        if s > 10 ** 9 + 7:
            s %= 10 ** 9 + 7
        #print(i, j + 1, 'x=', x, 'y=', y, 's=', s)
    return s

if len(a) != n or len(b) != m:
    print(0)
else:
    print(k(a, b, n, m))

# TimeLimitExceeded
# indexで一個ずつ見つけていくのは時間がかかるということ。
### BUGGY CODE ###

H, W, D = map(int, input().split())
A = [[int(j) for j in input().split()] for i in range(H)]
B = [(-1, -1) for j in range(H*W)]
for i in range(H):
    for j in range(W):
        B[A[i][j]-1] = (i, j)

C = [-1] * H*W
for i in range(H*W-D):
    fx, fy = B[i+D]
    tx, ty = B[i]
    C[i] = abs(fx-tx)+abs(fy-ty)

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    for i in range(L, R, D):
        ans += C[i-1]
    print(ans)


### FIXED CODE ###

H, W, D = map(int, input().split())
A = [[int(j) for j in input().split()] for i in range(H)]
B = [(-1, -1) for j in range(H*W)]
for i in range(H):
    for j in range(W):
        B[A[i][j]-1] = (i, j)

C = [-1] * H*W
for i in range(H*W-D):
    fx, fy = B[i+D]
    tx, ty = B[i]
    C[i] = abs(fx-tx)+abs(fy-ty)

E = [0] * H*W
for i in range(D):
    S = 0
    for j in range(i, H*W-D, D):
        S += C[j]
        E[j+D] = S
# print(E)

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(E[R-1]-E[L-1])
### BUGGY CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(60):
    N1 = 0
    N1 = sum(( (a >> k) & 1) for a in A )
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))

### FIXED CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

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

import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))

INF = 1001001001

# ---------------------------------------

n, k = inpl()
p = [0] + inpl()
c = [0] + inpl()

ans = - INF

for i in range(1, n + 1):
    loop = 0
    nxt = p[i]
    cost = [0]
    for j in range(1, k + 1):
        loop += c[nxt]
        ans = max(ans, loop)
        nxt = p[nxt]
        cost.append(loop)
        if nxt == p[i]:
            if loop > 0:
                cnt = k % j
                score = loop * (k // j)
                ans = max(ans, score + cost[k % j])
            break

print(ans)


### FIXED CODE ###

import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))

INF = 1001001001

# ---------------------------------------



n, k = inpl()
p = [0] + inpl()
c = [0] + inpl()

ans = - INF

for i in range(1, n + 1):
    cycle_cnt = 0
    cycle_sum = 0
    v = i

    while True:
        v = p[v]
        cycle_cnt += 1
        cycle_sum += c[v]
        if v == i: break
    
    cnt = 0
    path = 0

    while True:
        v = p[v]
        cnt += 1
        path += c[v]

        if cnt > k: break

        num = (k - cnt) // cycle_cnt
        score = path + max(0, cycle_sum) * num
        ans = max(ans, score)

        if v == i: break

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


N = int(input())

total =  0
for i in range(1,N+1):
    a = i * len(make_divisors(i))
    total += a
print(total)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(1,n+1): #各iについて、i*(1～n//iまでの総和)を足し合わせればよい
 k=n//i
 ans+=i*(k*(k+1)//2)
print(ans)
### BUGGY CODE ###

import collections

def calc(zero,one,two,three):
  n=zero+one+two+three
  if (zero,one,two,three) in memo:
    return memo[(zero,one,two,three)]
  ret=0
  if zero!=n:
    ret=1/(1-zero/n)
  if one!=0:
    ret+=(calc(zero+1,one-1,two,three)*one/n)/(1-zero/n)
  if two!=0:
    ret+=(calc(zero,one+1,two-1,three)*two/n)/(1-zero/n)
  if three!=0:
    ret+=(calc(zero,one,two+1,three-1)*three/n)/(1-zero/n)
  memo[(zero,one,two,three)]=ret
  return ret

n=int(input())
arr=list(map(int,input().split()))
memo=collections.defaultdict(int)
cnt=[0,0,0,0]
for val in arr:
  cnt[val]+=1
calc(cnt[0],cnt[1],cnt[2],cnt[3])
print(memo[(cnt[0],cnt[1],cnt[2],cnt[3])])

### FIXED CODE ###

import collections

n=int(input())
arr=list(map(int,input().split()))
dp=[[[0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
cnt=collections.Counter(arr)
for total in range(1,n+1):
  for three in range(total+1):
    for two in range(total-three+1):
      one=total-two-three
      dp[one][two][three]+=n/total
      if one!=0:
        dp[one][two][three]+=dp[one-1][two][three]*one/total
      if two!=0:
        dp[one][two][three]+=dp[one+1][two-1][three]*two/total
      if three!=0:
        dp[one][two][three]+=dp[one][two+1][three-1]*three/total
print(dp[cnt[1]][cnt[2]][cnt[3]])
### BUGGY CODE ###


N=int(input())
s=[list(map(int,input().split())) for i in range(N)]
A=N
c=0
s.sort(key=lambda x: x[0])

Check=[[s[i][0]-s[i][1],s[i][0]+s[i][1]] for i in range(N)]

for j in range(1,N):
    if j == N:
        break
    if Check[j-1][1] > Check[j][0]:
        c=c+1
        Check.remove(Check[j])
        j=j-1
        N=N-1
    
print(A-c)

### FIXED CODE ###

N=int(input())
s=[list(map(int,input().split())) for i in range(N)]
A=N
c=0
s.sort(key=lambda x: x[0])

Check=[[s[i][0]-s[i][1],s[i][0]+s[i][1]] for i in range(N)]
tmp=Check[0][1]
for j in range(1,N):
    if tmp > Check[j][0]:
        c=c+1
        tmp=min(tmp, Check[j][1])
    else:
        tmp=Check[j][1]
    
print(A-c)
### BUGGY CODE ###

N = int(input())
arr = [False]*(N+1)

for i in range(1, N+1):
    num = 0
    sqi = int(float(i)**0.5)
    sec = arr.copy()
    for j in range(1,sqi+1):
        sqj = int(float(i-j**2)**0.5)
        if not(sec[j]):
            #print(sec[j])
            #print("num"+str(j))
            for k in range(1, sqj+1):
                c = float(i-j**2-k**2-j*k)
                if c > 0:
                    c *= -1.0
                    b = float(j) + float(k)
                    d = b**2-4*c
                    if d >=0.0:
                        z = (-b + d**0.5)/2.0
                        if z.is_integer():
                            #print(j,k,z)
                            z = int(z)
                            sec[j]=True
                            sec[k]=True
                            sec[z]=True
                            if j==k and k == z:
                                num += 1
                            elif j == k or k == z or j ==z:
                                num += 3
                            else:
                                num +=6
                            #print(sec)
                            break
                else:
                    break

    print(num)

### FIXED CODE ###

N = int(input())
ans = [0]*(10**4+10)

for i in range(1,10**2+10):
    for j in range(1, 10**2+10):
        for k in range(1, 10**2+10):
            v = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if v < 10**4+10:
                ans[v]+=1

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

import heapq

n,m,s,t=map(int,input().split())
TRAIN=[None]*m

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


YEN=[10**16]*(n+1)#sから国iまで行くときの最小円
SNOOK=[10**16]*(n+1)#国iからtまで行くときの最小スヌーク
YEN[s]=0
SNOOK[t]=0


TRAINMAP=[[] for i in range(n+1)]

for i in range(m):
    TRAINMAP[TRAIN[i][0]]+=[(TRAIN[i][1],TRAIN[i][2],TRAIN[i][3])]
    TRAINMAP[TRAIN[i][1]]+=[(TRAIN[i][0],TRAIN[i][2],TRAIN[i][3])]


checktown=s
checked=set()
alltown=set(list(range(1,n+1)))
checking=[(0,s)]

while checking:

    checktown=heapq.heappop(checking)[1]
    
    for i in TRAINMAP[checktown]:
        if YEN[i[0]]>YEN[checktown]+i[1]:
            YEN[i[0]]=YEN[checktown]+i[1]
            heapq.heappush(checking,(i[1],i[0]))


    checked=checked|{checktown}
    

checktown=t
checked=set()
alltown=set(list(range(1,n+1)))
checking=[(0,t)]

while checking:

    checktown=heapq.heappop(checking)[1]
   
    for i in TRAINMAP[checktown]:
        if SNOOK[i[0]]>SNOOK[checktown]+i[2]:
            SNOOK[i[0]]=SNOOK[checktown]+i[2]
            heapq.heappush(checking,(i[2],i[0]))

    checked=checked|{checktown}
    


MONEY=[None]*(n+1)

for i in range(1,n+1):
    MONEY[i]=YEN[i]+SNOOK[i]


for i in range(1,n+1):
    print(10**15-min(MONEY[i:]))


### FIXED CODE ###

import heapq

n,m,s,t=map(int,input().split())
TRAIN=[None]*m

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


YEN=[10**16]*(n+1)#sから国iまで行くときの最小円
SNOOK=[10**16]*(n+1)#国iからtまで行くときの最小スヌーク
YEN[s]=0
SNOOK[t]=0


TRAINMAP=[[] for i in range(n+1)]

for i in range(m):
    TRAINMAP[TRAIN[i][0]]+=[(TRAIN[i][1],TRAIN[i][2],TRAIN[i][3])]
    TRAINMAP[TRAIN[i][1]]+=[(TRAIN[i][0],TRAIN[i][2],TRAIN[i][3])]



checking=[(0,s)]

while checking:

    cost,checktown=heapq.heappop(checking)
    
    for i in TRAINMAP[checktown]:
        if YEN[i[0]]>cost+i[1]:
            YEN[i[0]]=cost+i[1]
            heapq.heappush(checking,(cost+i[1],i[0]))

checking=[(0,t)]

while checking:

    cost,checktown=heapq.heappop(checking)
   
    for i in TRAINMAP[checktown]:
        if SNOOK[i[0]]>cost+i[2]:
            SNOOK[i[0]]=cost+i[2]
            heapq.heappush(checking,(cost+i[2],i[0]))



MONEY=[10**16]*(n+1)
MONEY[n]=YEN[n]+SNOOK[n]

for i in range(n-1,0,-1):
    if YEN[i]+SNOOK[i]<MONEY[i+1]:
        MONEY[i]=YEN[i]+SNOOK[i]
    else:
        MONEY[i]=MONEY[i+1]


for i in range(1,n+1):
    print(10**15-MONEY[i])
### BUGGY CODE ###

h,w,m=map(int,input().split())
bomb=[list(map(int,input().split())) for _ in range(m)]
a=[0 for i in range(h+1)]
b=[0 for _ in range(w+1)]
for i in range(m):
    a[bomb[i][0]]+=1
    b[bomb[i][1]]+=1
am=max(a)
bm=max(b)
aa=[i for i, x in enumerate(a) if x==am]
bb=[i for i, x in enumerate(b) if x==bm]
if len(aa)*len(bb)>m:
    print(am+bm)
    exit()
for i in aa:
    for j in bb:
        if [i,j] in bomb:
            continue
        else:
            print(am+bm)
            exit()
print(am+bm-1)

### FIXED CODE ###

h,w,m=map(int,input().split())
bomb=[list(map(int,input().split())) for _ in range(m)] #bombの位置
a=[0 for i in range(h+1)] #各行のbombの個数
b=[0 for _ in range(w+1)] #各列のbombの個数
for i in range(m):
    a[bomb[i][0]]+=1
    b[bomb[i][1]]+=1
am=max(a) #１行にあるbombの最大値
bm=max(b) #１列にあるbombの最大値
hmax=[0]*(h+1) #最大値をとるh全部
wmax=[0]*(w+1) #最大値をとるw全部
for i in range(h+1):
    if am==a[i]:
        hmax[i]+=1
for i in range(w+1):
    if bm==b[i]:
        wmax[i]+=1
ans=am+bm #基本解
k=sum(hmax)*sum(wmax)
if k>m: #鳩ノ巣原理
    print(ans)
    exit()
for i in bomb:
    if hmax[i[0]]==1 and wmax[i[1]]==1:
        k-=1
if k==0:
    print(ans-1)
else:
    print(ans)
### BUGGY CODE ###

from pprint import pprint
from collections import deque
h, w = map(int, input().split())

m = deque([])
mv = deque([])
mh = deque([])

for i in range(h):
    mh.append([0] * w)
for i in range(h):
    mv.append([0] * w)

for i in range(h):
    m.append(input())

for i in range(h):
    c = 0
    for j in range(w):
        if m[i][j] == "#":
            mh[i][j] = 0
            for k in range(c):
                mh[i][j - k - 1] = c
            c = 0
        else:
            c += 1
    for k in range(c):
        mh[i][w - 1 - k] = c

for i in range(w):
    c = 0
    for j in range(h):
        if m[j][i] == "#":
            mv[j][i] = 0
            for k in range(c):
                mv[j - k - 1][i] = c
            c = 0
        else:
            c += 1
    for k in range(c):
        mv[h - 1 - k][i] = c

res = 0
for i in range (h):
    for j in range(w):
        res = max(res, mv[i][j] + mh[i][j])
print(res - 1)

### FIXED CODE ###

h, w = map(int, input().split())

m = list()
mv = list()
mh = list()

for i in range(h):
    mh.append([0] * w)
for i in range(h):
    mv.append([0] * w)

for i in range(h):
    m.append(input())

for i in range(h):
    c = 0
    for j in range(w):
        if m[i][j] == "#":
            mh[i][j] = 0
            for k in range(c):
                mh[i][j - k - 1] = c
            c = 0
        else:
            c += 1
    for k in range(c):
        mh[i][w - 1 - k] = c

for i in range(w):
    c = 0
    for j in range(h):
        if m[j][i] == "#":
            mv[j][i] = 0
            for k in range(c):
                mv[j - k - 1][i] = c
            c = 0
        else:
            c += 1
    for k in range(c):
        mv[h - 1 - k][i] = c

res = 0
for i in range (h):
    for j in range(w):
        res = max(res, mv[i][j] + mh[i][j])
print(res - 1)
### BUGGY CODE ###

s = input()
count = 0
for i in range(len(s)):
    if '10' in s:
        s = s.replace('10', '', 1)
        count += 1
    elif '01' in s:
        s = s.replace('01', '', 1)
        count += 1
    else:
        pass

print(count * 2)

### FIXED CODE ###

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

N = int(input())
A = list(map(int,input().split(" ")))
total = 1
Triger = 0
for i in A:
  if total == 0:
    print(0)
    Triger = 1
    break
  else:
    total *= i

if total > 10**18:
  print(-1)
elif Triger == 0:
  print(total)

### FIXED CODE ###

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

for i in A:
  if i == 0:
    total = 0
    break
  elif total > 10**18:
    break
  total = total * i
if total > 10**18:
  print(-1)
else:
  print(total)
### BUGGY CODE ###

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

N = int(input())

lasts = []

before = [int(input())]
lasts.append(before)

for _ in range(N - 1):
    current = int(input())
    if before[0] < current:
        before[0] = current
        continue
    lows = [x for x in lasts if x[0] < current]
    if len(lows) == 0:
        lasts.append([current])
    else:
        lows[0][0] = current

print(len(lasts))


### FIXED CODE ###

# -*- coding: utf-8 -*-
from bisect import bisect_right

N = int(input())

columns = []


for _ in range(N):
    current = -int(input())
    index = bisect_right(columns, current)
    if len(columns) <= index:
        columns.append(current)
    else:
        columns[index] = current

print(len(columns))
### BUGGY CODE ###

import numpy as np

N, K, Q = map(int, input().split())
A = np.array([0]*Q)
N = np.array([K]*N)


for i in range(Q):
  A[i] = int(input())

for i in range(Q):
  N[A[i]-1] += 1
  N -= 1

for i in range (N.size):
  if N[i] <= 0:
    print('No')
  else:
    print('Yes')
    

### FIXED CODE ###

N,K,Q = map(int,input().split())
score = [0]*N

for i in range(Q):
  score[int(input())-1] += 1

for j in score:
  print('Yes' if Q-j < K else 'No')
### BUGGY CODE ###

[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
C = N//L
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        count += 1
        for k in range(L) :
            if j + k not in ANS : ANS[j+k] = i
    if count  > C * 2 : break
        
for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])