Harryxun/stf_run huggingface dataset:
N, X, M = map(int, input().split())

ans = X
x = X

C = [0, x]
Xd = [-1] * (M+1)
Xd[x] = 0
Xl = [x]

for i in range(1, N):
    x = x**2 % M

    if Xd[x] > -1:
        break
    Xd[x] = i
    Xl.append(x)
    ans += x
    C.append(ans)

# print(Xl)
# print(C)
# print(Xd[x], i)
loop_len = i - Xd[x]
# print(loop_len)
if loop_len > 0:
    S = C[i] - C[Xd[x]]
    # print(S)
    loop_num = (N - i) // loop_len
    # print(loop_num)
    ans += loop_num * S
    m = N - loop_num * loop_len - i
    # print(ans)
    # print(m)
    #ans += C[Xd[x]+m] - C[Xd[x]]

# print(S)

print(ans)

### FIXED CODE ###

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

ans = X
x = X

C = [0, x]
Xd = [-1] * (M+1)
Xd[x] = 0
i = 1

for i in range(1, N):
    x = x**2 % M

    if Xd[x] > -1:
        break
    Xd[x] = i
    ans += x
    C.append(ans)

loop_len = i - Xd[x]
if loop_len > 0:
    S = C[i] - C[Xd[x]]
    loop_num = (N - i) // loop_len
    ans += loop_num * S
    m = N - loop_num * loop_len - i
    ans += C[Xd[x]+m] - C[Xd[x]]

print(ans)
t = input()

stack = ''
for i in range(len(t)):
    word = t[i]
    if word == '?':
        next_word = t[i+1] if i < len(t)-1 else None
        if len(stack) <= 0 and next_word == 'P':
            word = 'D'
        elif len(stack) <= 0 and (next_word == 'D' or next_word == '?'):
            word = 'P'
        elif stack[-1] == 'D' and (next_word == '?' or next_word == 'D'):
            word = 'P'
        else:
            word = 'D'

    stack += word
print(stack)


### FIXED CODE ###

t = input()

stack = ''
for i in range(len(t)):
    word = t[i]
    if word == '?':
        next_word = t[i+1] if i < len(t)-1 else None
        if next_word is None:
            word = 'D'
        else:
            if len(stack) <= 0 and next_word == 'P':
                word = 'D'
            elif len(stack) <= 0 and (next_word == 'D' or next_word == '?'):
                word = 'P'
            elif stack[-1] == 'D' and (next_word == '?' or next_word == 'D'):
                word = 'P'
            else:
                word = 'D'

    stack += word
print(stack)
N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x] = y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    union(a-1,b-1,li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1))]
for i in range(N):
    m = root(i,li1)
    mm[m-1] += 1

# print(li1)
# print(mm)
ans = [mm[li1[i]-1]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    # print(str(i)+" ",end="")
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1)+1)]
for i in range(N):
    m = root(i,li1)
    mm[m] += 1

# print(li1)
# print(mm)
ans = [mm[li1[i]]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)
N,K=map(int,input().split())
D=[]
A=set()
for i in range(K):
	D.append(input())
	A.add(int(input()))
S=len(A)
print(N-S)

### FIXED CODE ###

N,K=map(int,input().split())
D=[]
A=set()
for i in range(K):
	D.append(int(input()))
	A=A|set(map(int,input().split()))
length=len(A)
print(N-length)
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

light=1

for i in range(n):
    light=a[light]
    if light = 2:
        print(i)
        break
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input())-1)
 
light=0
 
for i in range(1,n+1):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)
s = list(input())
n = len(s)
k = ['R','U','D']
g = ['L','U','D']

for i in range(n):
    if i % 2 ==0:
       new2 =[s[i] in k]
    else:
        new1 =[s[i] in g]
       
if new2 == [True] and new1 == [True]:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

s = list(input())
n = len(s)
k = ['R','U','D']
g = ['L','U','D']
count =0

for i in range(n):
    if i % 2 ==0:
        if s[i] in k:
            count +=1
    else:
        if s[i] in g:
            count += 1
       
if count == n:
    print("Yes")
else:
    print("No")
A, B = input().strip()
K = (A+B)//2
if (A+B)%2 == 0:
    print (K)
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

A, B = map(int,input().split())
K = (A+B)//2
if (A+B) % 2 == 0:
    print(K)
else:
    print('IMPOSSIBLE')
n = int(raw_input())
data = raw_input().split(" ")

sorted_data = data.sort()

minimum = sorted_data[0]
maximum = sorted_data[-1]

goukei = 0
for i in range(n):
	goukei += i

print("{:} {:} {:}".format(minimum, maximum, goukei))

### FIXED CODE ###

n = int(raw_input())
data = map(int, raw_input().split(" "))

#data = [10, 1, 5, 4, 17]

minimum = data[0]
maximum = data[0]
goukei = 0

for i in data:
	if i < minimum:
		minimum = i

	if i > maximum:
		maximum = i

	goukei += i

print("{:} {:} {:}".format(minimum, maximum, goukei))
# coding: utf-8

i = input()
menseki=int(i[0])*int(i[2])
nagasa=(int(i[0])+int(i[2]))*2
print(menseki,nagasa)

### FIXED CODE ###

# coding: utf-8

a,b = map(int,input().split())

print(a*b,(a+b)*2)
import math
n,k = map(int,input().split())
alist = list(map(int,input().split()))

max_length = max(alist)
cur_length = 0

while(max_length - cur_length > 1):
    next_length = (max_length+cur_length)//2

    test_k = 0
    for i in range(n):
        test_k += math.ceil(alist[i]/next_length)-1

    if test_k <= k:
        max_length = next_length
    else:
        cur_length = next_length
        

if test_k > k:
    print(cur_length+1)
else:
    print(cur_length)


### FIXED CODE ###

import math
n,k = map(int,input().split())
alist = list(map(int,input().split()))

max_length = max(alist)
cur_length = 0

while(max_length - cur_length > 1):
    next_length = (max_length+cur_length)//2

    test_k = 0
    for i in range(n):
        test_k += math.ceil(alist[i]/next_length)-1

    if test_k <= k:
        max_length = next_length
    else:
        cur_length = next_length
        

print(max_length)
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[input()])


### FIXED CODE ###

list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[int(input())-1])
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    else if (x % 2 == 0):
        continue
    else:
        if (pow(2, x - 1, x) == 1):
            count += 1
print(count)
 

### FIXED CODE ###

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    elif (x % 2 == 0):
        continue
    else:
        if (pow(2, x - 1, x) == 1):
            count += 1
print(count)
N = int(input())
A = list(map(int, input().split()))

def gcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    if y == 0:
        return x
    return gcd(y, x % y)

from functools import lru_cache
@lru_cache(maxsize = None)

def L(x):
    if x <= 0:
        return 0
    else:
        return gcd(L(x-1), A[x-1])

def R(x):
    if x >= N - 1:
        return 0
    else:
        return gcd(A[x+1], R(x+1))

for i in range(N-1, -1, -1):
    R(i)

w = 1
for i in range(N):
    w = max(w, gcd(L(i), R(i)))

print(w)


### FIXED CODE ###

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

def gcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    g = x % y
    if g == 0:
        return y
    return gcd(y, g)

R = [0] * N
R[N-1] = w = 0
for i in range(N-2, -1, -1):
    R[i] = w = gcd(w, A[i+1])

L = [0] * N
L[0] = w = 0
for i in range(1, N):
    L[i] = w = gcd(w, A[i-1])

w = 1
for i in range(N):
    w = max(w, gcd(L[i], R[i]))

print(w)
# arr=input().strip().split(' ')
x,n=[int(i) for i in input().strip().split(' ')]
arr=[int(i) for i in input().strip().split(' ')]
# neg,pos=[],[]
# for i in arr:
# 	if x-i >0 :
# 		pos.append(x-i)
# 	else:
# 		neg.append(i-x)
# pos=sorted(pos)
# neg=sorted(neg)
diff=[]
for i in arr:
	diff.append(x-i)
i=-1
j=1
while i in diff:
	i=i-1
while j in diff:
	j=j+1
print(min(x+i,x+j))

### FIXED CODE ###

# arr=input().strip().split(' ')
def aa():
    x,n=[int(i) for i in input().strip().split(' ')]
    if n==0:
        print(x)
        return 
    arr=[int(i) for i in input().strip().split(' ')]
    # neg,pos=[],[]
    # for i in arr:
    # 	if x-i >0 :
    # 		pos.append(x-i)
    # 	else:
    # 		neg.append(i-x)
    # pos=sorted(pos)
    # neg=sorted(neg)
    
    diff=[]
    for i in arr:

        diff.append(x-i)
    i=-1
    j=0
    while i in diff:
        i=i-1
    while j in diff:
        j=j+1
    if abs(i)<abs(j):
        print(x-i)
    else:
        print(x-j)
    # print(x+)
aa()
a,b,c,d = map(int,input(),split())

if abs(a-c) <= d:
    print('Yes')

elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')

else:
    print('No')



### FIXED CODE ###

a,b,c,d = map(int,input().split())

if abs(a-c) <= d:
    print('Yes')

elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')

else:
    print('No')
import math
a, b, h, m = map(int, input().split())
ax = a * math.cos(math.radians((h/12 + 1/12 * m/60) * 360))
ay = a * math.sin(math.radians((h/12 + 1/12 * m/60) * 360))
bx = b * math.cos(math.radians(m/60 * 360))
by = b * math.sin(math.radians(m/60 * 360))
print(math.sqrt((ax-bx)**2 + (ay-by)**2))

### FIXED CODE ###

n = int(input())
n = n % 10
if n in [2, 4, 5, 7, 9]:
  print("hon")
elif n in [0,1,6,8]:
  print("pon")
else:
  print("bon")
X,N = map(int, input().split())
A = list(map(int, input().split()))
Min = 101

for i in range(1,101):
    if i in A:
        continue
    if abs(i-X) < Min:
        ans = i
        Min = abs(i-X)
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3

#!/usr/bin/env python3

X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()

A = list(map(int, input().split()))
Min = 101

cnt = -200
for i in range(1,400):
    #print(cnt)
    if cnt in A:
        cnt += 1
        continue
    if abs(cnt-X) < Min:
        ans = cnt
        Min = abs(cnt-X)
    cnt += 1
print(ans)
n = int(input())
t = []
for i in range(1,int(n**0.5)):
  if n%i==0:
    t.append(max(len(str(int(n/i))),len(str(i))))            
print(min(t))


### FIXED CODE ###

n = int(input())
t = []
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    t.append(max(len(str(int(n/i))),len(str(i))))            
print(min(t))
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])
X, K, D = map(int, input().split())

ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    a = int((X+K*D)/(2*D))
    for i in range(-2,3):
        if a+i <= K and a+i >= 0:
            ans_list.append(abs(X+(K-(a+i))*D - (a+i)*D))
    ans = min(ans_list)
print(ans)

### FIXED CODE ###

X, K, D = map(int, input().split())
ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    a = (X+K*D)//(2*D)
    if a >= K:
        a = K
        ans = abs(X-K*D)
    else:
        ans_1 = abs(X+K*D-2*a*D)
        ans_2 = abs(X+K*D-2*(a+1)*D)
        ans = min(ans_1, ans_2)
print(ans)
import numpy as np

s = input()
s = s[::-1]
n = len(s)
mod = 10**9 + 7

dp = np.array([0 for j in range(13)])
if s[0] == '?':
    for i in range(10):
        dp[i] = 1
else:
    num = int(s[0])
    dp[num] = 1

for i in range(1, n):
    dp_new = np.array([0 for j in range(13)])
    if s[i] == '?':
        for m in range(10):
            num = (m * 10**i) % 13
            dp_rolled = np.roll(dp, num)
            dp_new += dp_rolled
            dp_new %= mod
    else:
        num = (int(s[i]) * 10**i) % 13
        dp_rolled = np.roll(dp, num)
        dp_new += dp_rolled
        dp_new %= mod
    dp = dp_new

print(dp[5])

### FIXED CODE ###

s = input()
s = s[::-1]
n = len(s)
mod = 10**9 + 7

dp = [[0 for j in range(13)] for i in range(n)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    num = int(s[0])
    dp[0][num] = 1

mul = 1
for i in range(1, n):
    mul = (mul*10) % 13
    if s[i] == '?':
        for m in range(10):
            num = (m * mul) % 13
            for j in range(13):
                dp[i][(j+num)%13] = (dp[i][(j+num)%13] + dp[i-1][j]) % mod
    else:
        num = (int(s[i]) * mul) % 13
        for j in range(13):
            dp[i][(j+num)%13] = (dp[i][(j+num)%13] + dp[i-1][j]) % mod

print(dp[n-1][5])
a, b, c = map(int, raw_input().split())
num = [a, b, c]
num.sort
for i in num
   print i,

### FIXED CODE ###

a, b, c = map(int, raw_input().split())
num = [a, b, c]
num.sort()
print num[0], num[1], num[2]
n = input()
a = list(map(int, input().split()))
count = 0
min = a[0]
for i in range(n):
    if min > a[i]:
        min = a[i]
        count += 1
print(count)

### FIXED CODE ###

import bisect
from collections import deque
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
count = deque()
count.append(a[0])
for i in range(1, n):
    
    index = bisect.bisect_left(count, a[i])
    
    if index == 0:
        count.appendleft(a[i])
    else:
        count[index - 1] = a[i]
    #print("{}  {}".format(count, index))
print(len(count))
N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0

for i in N:
    t = raw_input().spilit()
    A.append(t[0],int(t[1]))

while A:
    name, time = A.pop(0)
    if time < q:
        total += time
        B.append(name, time)
       
    else:
        time -= q
        total += q
        A.append(name, time)

print " ".join()

### FIXED CODE ###

N_str, q_str = raw_input().split()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0

for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B)
a, b, c = input().split()
if a < b and b < c:
  print 'No'

if a < c and c < b:
  print 'Yes'

if b < c and c < a:
  print 'Yes'

if b < a and a < c:
  print 'No'
  
if c < a and a < b:
  print 'Yes'
  
if c < b and b < a:
  print 'No'

### FIXED CODE ###

a, b, c = input().split()
if (int(a) < int(c) and int(c) < int(b)) or (int(b) < int(c) and int(c) < int(a)):
  print('Yes')
else:
  print('No')
n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
l = list(map(lambda x: '0' if x in None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) >1:
    print(-1)
else:
    print(msg.join(l))


### FIXED CODE ###

n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
if l[0] is None and len(l) != 1:
    l[0]='1'
l = list(map(lambda x: '0' if x is None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) != 1:
    print(-1)
else:
    print(msg.join(l))
N = int(input())
A = list(map(int,input().split()))

ans = 0
high = 0
for i in range(1,N):
  if A[i-1] > high:
    high = A[i-1]
  if A[i] < hihg:
    ans += high - A[i]
    
print(ans)

### FIXED CODE ###

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

ans = 0
high = 0
for i in range(1,N):
    af = A[i]
    bf = A[i-1]
    if bf > high:
        high = bf
    if high > af:
        ans += high - af

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

if int(H)-sum(A) <=0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if int(H)-sum(A) <=0:
    print("Yes")
else:
    print("No")
from math import gcd
from collections import defaultdict


def cmb(n, r):
    return (fac[n] * pow(fac[r], p - 2, p) * pow(fac[n - r], p - 2, p)) % p


p = 1000000007
fac = [1] * (2 * 10 ** 6 + 1)
for i in range(1, 2 * 10 ** 6 + 1):
    fac[i] = (fac[i - 1] * i) % p


N = int(input())

AB = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    g = gcd(a, b)
    AB[(a // g, b // g)] += 1

bad_pairs_cnt = 0
for a, b in AB:
    bad_pairs_cnt += AB[(a, b)] * (AB.get((-b, a), 0) + AB.get((b, -a), 0))

ans = N
for i in range(2, N + 1):
    b = cmb(N, 2) - bad_pairs_cnt * (N ** (i - 1))
    if b <= 0:
        break
    ans += b
    ans %= p
print(ans)


### FIXED CODE ###

from collections import defaultdict
from math import gcd


MOD = 1000000007
N = int(input())
both_zeros_cnt = 0
bads = defaultdict(lambda: [0, 0])
for _ in range(N):
    A, B = map(int, input().split())
    if A == 0 and B == 0:
        both_zeros_cnt += 1
        continue
    if B < 0 or (B == 0 and A < 0):
        A, B = -A, -B
    g = gcd(A, B)
    A, B = A // g, B // g
    if A > 0:
        bads[(A, B)][0] += 1
    else:
        bads[(B, -A)][1] += 1

ans = 1
for k, l in bads.values():
    ans *= (pow(2, k, MOD) - 1) + (pow(2, l, MOD) - 1) + 1
    ans %= MOD
print((ans + both_zeros_cnt - 1) % MOD)
import sys
input = sys.stdin.buffer.readline

R, C, K = map(int,input().split())
RC = [[0] * (C+1) for _ in range(R+1)]

for _ in range(K):
    r, c, v = map(int,input().split())
    RC[r-1][c-1] = v


dp = [[[0] * (C+1) for i in range(R+1)] for j in range(4)]

dp[1][0][0] = RC[0][0]
for r in range(R):
    for c in range(C):
        for i in range(4):
            dp[i][r][c+1] = max(dp[i][r][c], dp[i][r][c+1])
            if i <= 2:
                dp[i+1][r][c+1] = max(dp[i][r][c] + RC[r][c+1], dp[i+1][r][c+1])
        dp[0][r+1][c] = max(max(dp[:][r][c]), dp[0][r+1][c])
        dp[1][r+1][c] = max(dp[1][r+1][c], dp[0][r+1][c] + RC[r+1][c])
        
print(max(dp[:][R-1][C-1]))
            

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

R, C, K = map(int,input().split())
RC = [[0] * (C+1) for _ in range(R+1)]

for _ in range(K):
    r, c, v = map(int,input().split())
    RC[r-1][c-1] = v


dp = [[[0] * (C+1) for i in range(R+1)] for j in range(4)]

dp[1][0][0] = RC[0][0]
for r in range(R):
    for c in range(C):
        for i in range(4):
            dp[i][r][c+1] = max(dp[i][r][c], dp[i][r][c+1])
            if i <= 2:
                dp[i+1][r][c+1] = max(dp[i][r][c] + RC[r][c+1], dp[i+1][r][c+1])
            dp[0][r+1][c] = max(dp[i][r][c], dp[0][r+1][c])
        dp[1][r+1][c] = max(dp[1][r+1][c], dp[0][r+1][c] + RC[r+1][c])

print(max(dp[0][-2][-2], dp[1][-2][-2], dp[2][-2][-2], dp[3][-2][-2]))
import numpy as np
N, K, Q = list(map(int, input().split()))

vec = np.ones(N)*K

A = []
for _ in range(Q):
    A = int(input())
    vec -= 1
    vec[A-1] += 1

ret = '\n'.join(['Yes' if x > 0 else 'No' for x in vec])
print(ret)

### FIXED CODE ###

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

# vec = [K for _ in range(N)]

vec = [0 for _ in range(N)]

for _ in range(Q):
    A = int(input())
#     for i in range(N):
#         vec[i] -= 1
    vec[A-1] += 1

ret = '\n'.join(['Yes' if K-Q+x > 0 else 'No' for x in vec])
print(ret)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

ls =[s]
while True:
    if ls[-1] % 2 ==0:
        a = ls[-1]/2
    else:
        a = ls[-1]*3 + 1
    if a in ls:
        break
    else:
        ls.append(a)

print(lsn(ls))



### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

ls =[s]
while True:
    if ls[-1] % 2 ==0:
        a = int(ls[-1]/2)
    else:
        a = int(ls[-1]*3 + 1)
    
    if a in ls:
        break
    else:
        ls.append(a)

print(len(ls)+1)
import operator
for e in iter(input,'0'):
    target = [[*map(int,input().split())]for _ in[0]*int(e)]
    s,t = min(target)
    target = {(x - bx, y - by) for x, y in target}
    max_tx = max(map(lambda x:x[0], target))
    b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
    max_sx = max(map(operator.itemgetter(0), b))
    lim_x = max_sx - max_tx
    for x,y in b:
        if x > lim_x:continue
        for u,v in target:
            if (x + u, y + v) not in b:break
        else:
            print(x - bx, y - by)
            break


### FIXED CODE ###

for e in iter(input,'0'):
 a=[[*map(int,input().split())]for _ in[0]*int(e)]
 s,t=min(a)
 b={tuple(map(int,input().split()))for _ in[0]*int(input())}
 m=max(b)[0]-max(a)[0]+s
 for x,y in b:
  if x<=m:
   for u,v in a:
    if(x+u-s,y+v-t)not in b:break
   else:print(x-s,y-t);break
a - int(input())

print(a+a**2+a**3)

### FIXED CODE ###

a = int(input())

print(a+(a**2) + (a**3))
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def roundup(n):
    return int(math.ceil(n /10)) * 10
def get_digit(number):
    return number // 10**0 % 10   
s = 0
m = []
li = [A, B, C, D, E]
for i in range(len(li)):
    if get_digit(li[i]) >= 1:
        m.append(get_digit(li[i]))
f = False
        
for l in range(len(li)):
    if min(m) == get_digit(li[l]) and f == False:
        s += li[l]
        f = True
    else:
        s += roundup(li[l])
print(s)

### FIXED CODE ###

import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def roundup(n):
    return int(math.ceil(n /10)) * 10
def get_digit(number):
    return number % 10   
s = 0
m = []
li = [A, B, C, D, E]
for i in range(len(li)):
    if get_digit(li[i]) >= 1:
        m.append(get_digit(li[i]))
f = False
m.sort()        
for l in range(len(li)):
    if len(m) > 0:
        if m[0] == get_digit(li[l]) and f == False:
            s += li[l]
            f = True
        else:
            s += roundup(li[l])
            # print(roundup(li[l]))
    else:
        s =sum(li)
print(s)