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

import sys
def input():
    return sys.stdin.readline()[:-1]
h,w,k=map(int,input().split())
s = []
for i in range(h):
    str=input()
    tmp=[]
    for j in range(w):
        if str[j]=="0":
            tmp.append(0)
        else:
            tmp.append(1)
    s.append(tmp)


tdiv=2**(h-1)
import numpy as np
s = np.array(s)
ans = 100100100
for i in range(tdiv):
    lis=[]
    tmp=np.zeros(w)
    tmp+=s[0,:]
    cnt = 0
    #print(tmp)
    for j in range(h-1):
        if (i>>j&1):
            tmp+=s[j+1,:]
        else:
            lis.append(tmp)
            tmp=np.zeros(w)
            tmp+=s[j+1,:]
            cnt+=1
    lis.append(tmp)
    lis = np.array(lis)
    clis=np.zeros(cnt+1)
    #print(lis,cnt)
    for ind in range(w):
        if lis[:,ind].max()>k:
            cnt=10010010
            break
        clis+=lis[:,ind]
        if clis.max()>k:
            clis=lis[:,ind]
            cnt+=1
    #print(cnt)
    ans = min(ans,cnt)
print(ans)


### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
h,w,k=map(int,input().split())
s = []
for i in range(h):
    str=input()
    tmp=[]
    for j in range(w):
        if str[j]=="0":
            tmp.append(0)
        else:
            tmp.append(1)
    s.append(tmp)

tdiv=2**(h-1)
#import numpy as np
#s = np.array(s)
ans = 100100100
for i in range(tdiv):
    lis=[]
    #tmp=np.zeros(w)
    #tmp+=s[0,:]
    tmp=[s[0][ii] for ii in range(w)]
    cnt = 0
    #print(tmp)
    for j in range(h-1):
        if (i>>j&1):
            #tmp+=s[j+1,:]
            tmp=[tmp[ii]+s[j+1][ii] for ii in range(w)]
        else:
            lis.append(tmp)
            #tmp=np.zeros(w)
            #tmp+=s[j+1,:]
            tmp=[s[j+1][ii] for ii in range(w)]
            cnt+=1
    lis.append(tmp)
    #lis = np.array(lis)
    #clis=np.zeros(cnt+1)
    clis=[0 for ii in range(cnt+1)]
    #print(lis,cnt)
    tmpcnt=cnt
    for ind in range(w):
        #if any(d>k for d in lis[:,ind]):
        #if lis[:,ind].max()>k:
        if max([lis[ii][ind] for ii in range(tmpcnt+1)])>k:
            cnt=10010010
            break
        clis=[lis[ii][ind]+clis[ii] for ii in range(tmpcnt+1)]
        #if clis.max()>k:
        if max(clis)>k:
            clis=[lis[ii][ind] for ii in range(tmpcnt+1)]
            cnt+=1
    #print(cnt)
    ans = min(ans,cnt)
print(ans)
### BUGGY CODE ###

from collections import deque

A, B, K = input().split()

A = int(A)
B = int(B)
K = int(K)

value = deque()
s = [i for i in range(A, B+1)]

value.extend(s[0:K])
value.extend(s[len(s)-K:len(s)])

num = list(set(value))
num.sort()
for i in range(len(num)):
    print(num[i])

### FIXED CODE ###

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

value = []

if B - A < K or B <= K:
    value.extend([i for i in range(A, B+1)])
    
else:
    value.extend([i for i in range(A, A+K)])
    value.extend([i for i in range(B-K+1, B+1)])    

num = list(set(value))
num.sort()

for i in range(len(num)):
    print(num[i])
### BUGGY CODE ###

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

mat=[]
for i in range(H):
  array=[x=='.' for x in input()]
  mat.append(array)
#print(mat)

#convert mat to graph
#(i0,j0)->(i1,j1,dist)
graph={}
if mat[0][0]:
  graph[(0,0)]=[(1,1,0)]
else:
  graph[(0,0)]=[(1,1,1)]
  
for i in range(H):
  for j in range(W):
    graph[(i+1,j+1)]=[]
    if mat[i][j]:
      if i<H-1:
        if mat[i+1][j]:
          graph[(i+1,j+1)].append((i+2,j+1,0))
        else:
          graph[(i+1,j+1)].append((i+2,j+1,1))
      if j<W-1:
        if mat[i][j+1]:
          graph[(i+1,j+1)].append((i+1,j+2,0))
        else:
          graph[(i+1,j+1)].append((i+1,j+2,1))
    else:
      if i<H-1:
        graph[(i+1,j+1)].append((i+2,j+1,0))
      if j<W-1:
        graph[(i+1,j+1)].append((i+1,j+2,0))
#print(graph)

# init used,queue,dist
used={}
dist={}
queue=set()
used[(0,0)]=False
dist[(0,0)]=0
queue.add((0,0))
for i in range(1,H+1):
  for j in range(1,W+1):
    used[(i,j)]=False
    dist[(i,j)]=10**9
    queue.add((i,j))
#print(queue)

#dkjstra
while(True):
  d=10**9
  min_q=None
  for q in queue:
    if not used[q] and dist[q]<d:
      min_q=q
      d=dist[q]
      
  #print(min_q,d)
  if min_q==None:
    break
    
  used[min_q]=True
  candlist=graph[min_q]
  for cand in candlist:
    xx,yy,dd=cand
    dist[(xx,yy)]=min(dist[(xx,yy)],dist[min_q]+dd)
  
print(dist[(H,W)])

### FIXED CODE ###

import heapq

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

mat=[]
for i in range(H):
  array=[x=='.' for x in input()]
  mat.append(array)
#print(mat)

#convert mat to graph
#(i0,j0)->(i1,j1,dist)
graph={}
if mat[0][0]:
  graph[(0,0)]=[(1,1,0)]
else:
  graph[(0,0)]=[(1,1,1)]
  
for i in range(H):
  for j in range(W):
    graph[(i+1,j+1)]=[]
    if mat[i][j]:
      if i<H-1:
        if mat[i+1][j]:
          graph[(i+1,j+1)].append((i+2,j+1,0))
        else:
          graph[(i+1,j+1)].append((i+2,j+1,1))
      if j<W-1:
        if mat[i][j+1]:
          graph[(i+1,j+1)].append((i+1,j+2,0))
        else:
          graph[(i+1,j+1)].append((i+1,j+2,1))
    else:
      if i<H-1:
        graph[(i+1,j+1)].append((i+2,j+1,0))
      if j<W-1:
        graph[(i+1,j+1)].append((i+1,j+2,0))
#print(graph)

# init used,queue,dist
dist={}
hq=[]
dist[(0,0)]=0
heapq.heappush(hq,(0,0,0))
for i in range(1,H+1):
  for j in range(1,W+1):
    dist[(i,j)]=10**9
    heapq.heappush(hq,(i+j,i,j))
#print(queue)

#dkjstra
while(True):
  if len(hq)==0:
    break

  ij,ii,jj=heapq.heappop(hq)
  
  candlist=graph[(ii,jj)]
  for cand in candlist:
    xx,yy,dd=cand
    dist[(xx,yy)]=min(dist[(xx,yy)],dist[(ii,jj)]+dd)
  
print(dist[(H,W)])
### BUGGY CODE ###

N,M,L = map(int,input().split())
INF = (500, 10**9)
dist = [[INF for i in range(N)] for j in range(N)]
edge = [[] for i in range(N)]
for i in range(M):
	A,B,C = map(int,input().split())
	if C <= L:
		edge[A-1].append((B-1, C))
		edge[B-1].append((A-1, C))

import heapq as hq
for i in range(N):
	searched = [False for j in range(N)]
	search = [((0,0), i)]
	hq.heapify(search)
	while len(search) > 0:
		s = hq.heappop(search)
		d = s[0]
		n = s[1]
		if searched[n]:
			continue
		searched[n] = True
		dist[i][n] = d
		for e in edge[n]:
			n2 = e[0]
			d2 = e[1]
			if searched[n2]:
				continue
			if d[1] + d2 > L:
				new_d = (d[0] + 1, d2)
			else:
				new_d = (d[0], d[1] + d2)
			hq.heappush(search, (new_d, n2))

Q = int(input())
for q in range(Q):
	s,t = map(int,input().split())
	print(dist[s-1][t-1][0] if dist[s-1][t-1] != INF else -1)


### FIXED CODE ###

N,M,L = map(int,input().split())
INF = (500, 10**9)
dist = [[INF if i != j else (0,0) for i in range(N)] for j in range(N)]
edge = [[] for i in range(N)]
for i in range(M):
	A,B,C = map(int,input().split())
	if C <= L:
		edge[A-1].append((B-1, C))
		edge[B-1].append((A-1, C))

import heapq as hq
for i in range(N):
	searched = [False for j in range(N)]
	n = i
	while n != None:
		searched[n] = True
		for e in edge[n]:
			if searched[e[0]]:
				continue
			d = dist[i][n]
			n2, d2 = e[0], e[1]
			if d[1] + d2 > L:
				new_d = (d[0] + 1, d2)
			else:
				new_d = (d[0], d[1] + d2)
			dist[i][n2] = min(dist[i][n2], new_d)
		n = None
		m = INF
		for j in range(N):
			if not searched[j] and dist[i][j] < m:
				n = j
				m = dist[i][j]


Q = int(input())
for q in range(Q):
	s,t = map(int,input().split())
	print(dist[s-1][t-1][0] if dist[s-1][t-1] != INF else -1)
### BUGGY CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
c=[0 for i in range(n)]
b=sum(a)

for i in range(n):
 if i: c[i]+=c[i-1]
 c[i]+=a[i]
f=float("inf")
import bisect
e=[]
b=a[0]
d=c[n-1]-c[0]
for i in range(1,n-2):
 b+=a[i]
 d-=a[i]
 x=bisect.bisect_left(c[:i+1],b/2)
 
 if abs(c[i]-2*c[x])>abs(c[i]-2*c[x-1]) and x>0:
   e.append(c[i]-c[x-1])
   e.append(c[x-1])
 else:
   e.append(c[i]-c[x])
   e.append(c[x])
 y=bisect.bisect_left(c[i+1:],d/2+c[i])+i+1
 if abs(c[n-1]-c[y]-(c[y]-c[i]))>abs(c[n-1]-c[y-1]-(c[y-1]-c[i])) and y>0:
   e.append(c[n-1]-c[y-1])
   e.append(c[y-1]-c[i])
 else:
   e.append(c[n-1]-c[y])
   e.append(c[y]-c[i])

 f=min(f,max(e)-min(e))
 e=[]
print(f)

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
c=[0 for i in range(n)]


for i in range(n):
 if i: c[i]+=c[i-1]
 c[i]+=a[i]

l=0
r=2
f=float("inf")
for i in range(1,n-1):
 while abs(c[l]-(c[i]-c[l]))>abs(c[l+1]-(c[i]-c[l+1])):
   l+=1
 while abs(c[r]-c[i]-(c[n-1]-c[r]))>abs(c[r+1]-c[i]-(c[n-1]-c[r+1])):
   r+=1
 e=[c[l],c[i]-c[l],c[r]-c[i],c[n-1]-c[r]]
 f=min(f,max(e)-min(e))
print(f)
### BUGGY CODE ###

s = input()
q = int(input())
query = [list(map(str, input().split())) for _ in range(q)]


for i in query:
    if i[0] == "1":
        s =  s[::-1]
    elif i[1] == "1":
        s = i[2] + s
    else:
        s += i[2]

print(s)

### FIXED CODE ###

from collections import deque
s = deque(input())
q = int(input())
query = [list(map(str, input().split())) for _ in range(q)]

order = True
for i in query:
    if i[0] == "1":
        order = not order
    elif i[1] == "1":
        if order:
            s.appendleft(i[2])
        else:
            s.append(i[2])
    else:
        if order:
            s.append(i[2])
        else:
            s.appendleft(i[2])

if not order:
    s.reverse()
print("".join(s))
### BUGGY CODE ###

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

l = []

for i in range(A, B+1, 1):
    l.append(i)


for i in range(len(l)):
    if i <= (K-1) or i >= (len(l)-K):
        print(l[i])

### FIXED CODE ###

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

l       = range(A, B+1)

s       = sorted(set(l[:K])|set(l[-K:]))

for i in s:
    print(i)
### BUGGY CODE ###

n, k = map(int, input().split())
s = input()
ss = []

cnt = 0

if s[0] == '0': ss.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]: j += 1
    ss.append(j-i)
    i = j
if s[-1] == '0': ss.append(0)

#print(ss)
ans = 0
i = 0
while i < n:
    #print(ans, i, sum(ss[i:i+2*k+1]))
    #if i+2*k+1 > n:
    #    break
    ans = max(ans, sum(ss[i:i+2*k+1]))

    i += 2

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
ss = []

cnt = 0

if s[0] == '0': ss.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]: j += 1
    ss.append(j-i)
    i = j
if s[-1] == '0': ss.append(0)

right = 2*k+1
left = 0
val = sum(ss[:right])
ans = val

#print(ss)
while right < len(ss):
    for i in [1, 2]:
        #print('for', ss[left], ss[right])
        val += ss[right]
        val -= ss[left]
        left += 1
        right += 1
    #print(left, right, val)
    ans = max(ans, val)
    
print(ans)
### BUGGY CODE ###

X=raw_input()
while 1:
    if 'ST' in X:
       X=X.replace('ST','')
    else:
        break
print len(X)

### FIXED CODE ###

X=raw_input()
l=[0,0]
for i in X:
    if i=='S':
        l[0]+=1
    elif i=='T' and l[0]>0:
        l[0]-=1
    else:
        l[1]+=1
print sum(l)
### BUGGY CODE ###

n = int(input())
line = list(input())
count_list = []
for i in range(len(line)):
    count = line[:i].count('W') + line[i + 1:].count('E')
    count_list.append(count)
print(min(count_list))


### FIXED CODE ###

n = int(input())
line = list(input())
cum_sum_w = [0]
cum_sum_e = [0]
count_w = 0
count_e = 0
for i in range(n):
    if line[i] == 'W':
        count_w += 1
    else:
        count_e += 1
    cum_sum_w.append(count_w)
    cum_sum_e.append(count_e)
count_list = []
for i in range(1, n + 1):
    count = 0
    count += cum_sum_w[i - 1]
    count += cum_sum_e[n] - cum_sum_e[i]
    count_list.append(count)
print(min(count_list))
### BUGGY CODE ###

from collections import defaultdict
n,s=map(int,input().split())
k=defaultdict(int)
k[0]=0
d=0
for i in range(n):
    w,v=map(int,input().split())
    c=list(k)
    for i in range(len(c)-1,-1,-1):
        if c[i]+w<=s:
            if k[c[i]+w]!=0:
                k[c[i]+w]=max(k[c[i]+w],k[c[i]]+v)
            else:
                k[c[i]+w]=k[c[i]]+v
            d=max(d,k[c[i]+w])
print(d)              

### FIXED CODE ###

import numpy as np
n,a=map(int,input().split())
s=np.full(n*1000+1,a+1)
s[0]=0
for i in range(n):
    w,v=map(int,input().split())
    s[v:]=np.minimum(s[v:],s[:-v]+w)
print(np.max(np.where(s<=a)))
### BUGGY CODE ###

import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(); b.sort(); c.sort()
ins_c = [0]*n
ins_b = [0]*n
for i in range(n) :
    ins_c[i] = bisect.bisect_right(c, b[i])
    ins_b[i] = bisect.bisect_right(b, a[i])
ans = 0
for i in range(n) :
    for j in range(ins_b[i], n) :
        ans += n - ins_c[j]

print(ans)

### FIXED CODE ###

import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(); b.sort(); c.sort()
dp = [0]*(n+1)
for i in range(n-1, -1, -1) :
    ins_c = bisect.bisect_right(c, b[i])
    dp[i] = dp[i+1] + (n-ins_c)
ans = 0
for i in range(n) :
    ins_b = bisect.bisect_right(b, a[i])
    ans += dp[ins_b]

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

import numpy as np
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()

for i in a:
    ans = ans*i
    if ans > 1000000000000000000:
        ans = -1
        exit
    elif ans == 0:
        exit

print(ans)

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.readline
 
n = int(input())
a = list(map(int,input().split()))
ans = 1

for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
        break
 
if 0 in a:
    ans = 0

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

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

dp = [0 for i in range(N)]

if N <= K :
    ans = abs(L[0] - L[-1])
else :
    for i in range(1,K+1) :
        dp[i] = abs(L[0] - L[i])
    for i in range(K+1,N) :
        cost = float("inf")
        for j in range(i-K,i) :
            calc = dp[j] + abs(L[j] - L[i])
            if cost > calc :
                cost = calc
        dp[i] = cost
    ans = dp[N-1]
print(ans)


### FIXED CODE ###

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

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

dp = [0 for i in range(N)]
if N >= K :    
    for i in range(1,K+1) :
        dp[i] = abs(L[i]-L[0])
    for i in range(K+1,len(dp)) :
        state = float("inf")
        for j in range(i-K,i) :
            calc = abs(L[i]-L[j]) + dp[j]
            if state > calc :
                state = calc
        dp[i] = state
    print(dp[N-1])
else :
    print(abs(min(L[1:])-L[0]))
### BUGGY CODE ###

#素因数分解して列挙する関数、約数列挙ではない！
from collections import Counter
from math import log2

def factorize(n):
  if n==1:
    return 1
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  c = Counter(fct)
  ans = 1
  for v in c.values():
    ans *= v+1
  return ans
def solve():
  ans = 0
  N = int(input())
  for i in range(1,N+1,2):
    f = factorize(i)
    m = int(log2(N//i))
    ans += i*f*(m*pow(2,m+1)+1)
  return ans
print(solve())

### FIXED CODE ###

def solve():
    ans = 0
    N = int(input())
    for i in range(1,N+1):
        for j in range(1,N//i+1):
            ans += i*j
    return ans
print(solve())
### BUGGY CODE ###

N = int(input())
S = input()
i = 0
while i != len(S) - 1:
    if S[i] == S[i+1]:
        S = S[:i+1] + S[i+2:]
        i = 0
        continue
    i = i + 1 
print(len(S))

### FIXED CODE ###

N = int(input())
S = input()
i = 0
while i != len(S) - 1:
    if S[i] == S[i+1]:
        S = S[:i] + S[i+1:]
        continue
    i = i + 1 
print(len(S))
### BUGGY CODE ###

H,W,N = [int(input()) for i in range(3)]
o = 1
a = o * W
b = o * H
while a or b > N:
  if H < W and a < N:
      o += 1
  elif W < H and b > N:
      o += 1
print(o)    
    
    
    





	

  
  
  



### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
### BUGGY CODE ###

class UF_weighed:
    def __init__(self, n):
        self.n = n
        self.par = list(range(n+1))
        self.rank = [0]*(n+1)
        self.size = [1]*(n+1)
        self.diff_w = [0]*(n+1)

    def find(self, x):
        if self.par[x] == x: return x
        p = self.find(self.par[x])
        self.diff_w[x] += self.diff_w[self.par[x]]
        self.par[x] = p
        return self.par[x]

    def weight(self, x):
        self.find(x)
        return self.diff_w[x]

    def diff(self, x, y):
        if not self.same(x, y): return None
        return self.weight(y) - self.weight(x)

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def merge(self, x, y, w):
        w += self.weight(x) - self.weight(y)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.rank[x] < self.rank[y]:
            x, y, w = y, x, -w
        self.par[y] = x
        self.size[x] += self.size[y]
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.diff_w[y] = w
        return True
      
def main():
  n,m = map(int, input().split())
  uf = UF_weighed(n+1)
  q = [map(int, input().split()) for _ in range(m)]
  for a, b, c in q:
    if uf.same(a, b) and uf.diff(a, b) != c:
      return 'No'
    uf.merge(a, b, c)
  return 'Yes'

if __name__ == '__main__':
  print(main())

### FIXED CODE ###

n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  q = [(v,p)]
  while q:
    cv,cp = q.pop()
    if pos[cv] != None:
      continue
    pos[cv] = cp
    for i,d in l[cv]:
      if pos[i] == None:
        q.append((i,cp+d))
  return

for i in range(1,n+1):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")
### BUGGY CODE ###

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

result = 0
MOD = 10**9+7

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

print(result)



### FIXED CODE ###

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

result = 0
MOD = 10**9+7

S = sum(As)

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

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

# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if not s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和
answer = 0
for i,j in ans.items():
    answer += j*(j-1)//2
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)
### BUGGY CODE ###

import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n, k, q = map(int, input().split())

    winners = []
    for w in range(q):
        winners.append(int(input()))

    score = [k] * n

    for w in winners:
        winner = w - 1

        for i in range(len(score)):
            score[i] -= 1

        score[winner] += 1

    for s in score:
        if s > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n, k, q = map(int, input().split())

    winners = []
    for w in range(q):
        winners.append(int(input()))

    score = [k - q] * n

    for w in winners:
        winner = w - 1

        score[winner] += 1

    for s in score:
        if s > 0:
            print('Yes')
        else:
            print('No')


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

N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]
L = []
for i in range(N-2):
    if S[i:i+2] == 'AC':
        L.append(i)
for l,r in lr:
    ans = 0
    for a in L:
        if l-1<=a<r-1:
            ans += 1
    print(ans)

### FIXED CODE ###

import bisect

N,Q = map(int,input().split())
S = input()
L = []
for i in range(N):
    if S[i:i+2] == 'AC':
        L.append(i)
for i in range(Q):
    l,r = map(int,input().split())
    a = bisect.bisect_left(L,l-1)
    b = bisect.bisect_right(L,r-2)
    print(b-a)
### BUGGY CODE ###

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

for a in range(0, n+1):
    for b in range(0, n-a+1):
        for c in range(0, n-(a+b)+1):

            if (10000*a + 5000*b + 1000*c) == y and (a+b+c) == n:
                print(a, b, c)
                exit()

a = -1
b = -1
c = -1
print(a, b, c)
               

### FIXED CODE ###

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

for a in range(0, n+1):
    for b in range(0, n-a+1):
        c = n-(a+b)
        if (10000*a + 5000*b + 1000*c) == y:
            print(a, b, c)
            exit()

print(-1, -1, -1)
### BUGGY CODE ###

N = int(input())
a_list = [int(input()) for _ in range(N)]

from heapq import *
from bisect import *

que = []

ans = 0
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        ans += 1
    else:
        idx = bisect_right(que, a-1)
        if idx == 0:
            insort_left(que, a)
            ans += 1
        else:
            b = que[idx-1]
            #if a != b:
            que[idx-1] = a
            #idx2 = bisect_right(que, a-1)

    # print(que, ans)
print(ans)


### FIXED CODE ###

import sys
from bisect import bisect_right, insort_left
from collections import deque
N = int(sys.stdin.readline())
a_list = [int(sys.stdin.readline()) for _ in range(N)]


que = []
que = deque(que)

ans = 0
min_num = float("inf")
for i, a in enumerate(a_list):
    if i == 0:
        que.append(a)
        min_num = a
        ans += 1
    else:
        idx = bisect_right(que, a-1)

        if idx == 0:
            que.appendleft(a)
            ans += 1
            min_num = a
        else:
            idx = bisect_right(que, a-1)
            que[idx-1] = a
            if idx -1 == 0:
                min_num = a
    #print(que, min_num)
print(ans)
### BUGGY CODE ###

def ev(d0, d1, d2, d3):
    if d0 == n:
        return 0
    if memo[d1][d2][d3] != -1:
        return memo[d1][d2][d3]
    re = 1
    if d1 > 0:
        re += ev(d0 + 1, d1 - 1, d2, d3) * d1 / n
    if d2 > 0:
        re += ev(d0, d1 + 1, d2 - 1, d3) * d2 / n
    if d3 > 0:
        re += ev(d0, d1, d2 + 1, d3 - 1) * d3 / n
    re *= n / (n - d0)
    memo[d1][d2][d3] = re
    return re


n = int(input())
a = list(map(int, input().split()))
ds = [0] + [a.count(i) for i in range(1, 4)]
memo = [[[-1] * (ds[3] + 1) for i in range(ds[2] + ds[3] + 1)] for ii in range(n + 1)]
print(ev(0, ds[1], ds[2], ds[3]))


### FIXED CODE ###

import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    cnt_aa = Counter(aa)
    nc3 = cnt_aa[3]
    nc2 = cnt_aa[2]
    nc1 = cnt_aa[1]
    dp = [[[0] * (n + 1) for _ in range(nc3 + nc2 + 1)] for _ in range(nc3 + 1)]
    for c3 in range(nc3 + 1):
        for c2 in range(nc2 + nc3 - c3 + 1):
            if c3 + c2 > n: break
            for c1 in range(n + 1):
                s = c1 + c2 + c3
                if s > n: break
                if c1 > 0: dp[c3][c2][c1] += (dp[c3][c2][c1 - 1] + n / s) * c1 / s
                if c2 > 0: dp[c3][c2][c1] += (dp[c3][c2 - 1][c1 + 1] + n / s) * c2 / s
                if c3 > 0: dp[c3][c2][c1] += (dp[c3 - 1][c2 + 1][c1] + n / s) * c3 / s
    print(dp[nc3][nc2][nc1])

main()