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

N, M = map(int, input().split())
Alist = list(map(int, input().split()))
for i in range(M):
    Alist = sorted(Alist)
    Bi, Ci = map(int, input().split())
    Alist = [max(Ci, j) for j in Alist[:Bi]]+Alist[Bi:]
print(sum(Alist))

### FIXED CODE ###

N, M = map(int, input().split())
Alist = list(map(int, input().split()))
numlist = [[1,i] for i in Alist]
BC = [list(map(int, input().split())) for i in range(M)]
numlist += BC
numlist = sorted(numlist, key=lambda x:x[1], reverse=True)
ret = 0
for pair in numlist:
    if N <= 0:
        break
    if N >= pair[0]:
        ret += pair[0]*pair[1]
        N = N - pair[0]
    else:
        ret += N*pair[1]
        break
print(ret)
### BUGGY CODE ###

N,M = map(int,input().split())
edge_from = [set() for _ in range(N+1)]
edge_to = [set() for _ in range(N+1)]
ans = [-1]*(N+1)
child = set()
parent = set()
for _  in range(N-1+M):
    go,to = map(int,input().split())
    edge_from[go].add(to)
    edge_to[to].add(go)
    child.add(to)
for i in range(1,N+1):
    if i not in child:
        parent.add(i)
        par = i
        break
from collections import deque
stack = deque()
stack.append(par)
distance = [-1]*(N+1)
distance[par] = 0
while stack:
    v = stack.popleft()
    if v != par:
        for i in edge_to[v]:
            if i not in parent: continue
    for u in edge_from[v]:
        distance[u] = max(distance[v] + 1,distance[u])
        stack.append(u)
dis = [set() for _ in range(max(distance)+1)]
for i in range(1,N+1):
    dis[distance[i]].add(i)
for i in range(1,N+1):
    if i == par :
        ans[i] = 0
    else:
        for j in dis[distance[i]-1]:
            if j in edge_to[i]:
                ans[i] = j
                break
for i in range(1,N+1):
    print(ans[i])           

### FIXED CODE ###

from collections import defaultdict, deque
import heapq
v, n = map(int, input().split())
es = [[int(x) for x in input().split()] for _ in range(v+n-1)]

outs = defaultdict(list)
ins = defaultdict(int)
edge_from = [[] for _ in range(v+1)]
edge_to = [[] for _ in range(v+1)]
ans = [-1]*(v+1)
for v1, v2 in es:
    edge_from[v1].append(v2)
    edge_to[v2].append(v1)
    outs[v1].append(v2)
    ins[v2] += 1

q = deque(v1 for v1 in range(v) if ins[v1] == 0)
res = []
while q:
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append(v2)
rev = [0]*(v+1)
for i in range(1,v+1):
    rev[res[i]] = i
redge_to = [[] for _ in range(v+1)]
for i in range(1,v+1):
    for j in edge_to[i]:
        ri = rev[i]
        rj = rev[j]
        heapq.heappush(redge_to[ri],-rj)
for ri in range(1,v+1):
    if redge_to[ri]:
        rj = redge_to[ri][0]
        i = res[ri]
        j = res[-rj]
        ans[i] = j
    else:
        i =res[ri]
        ans[i] = 0
for i in ans[1:]:
    print(i)
### BUGGY CODE ###



import sys
import math

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

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

a=list(map(int, input().split()))
##まずソート
a.sort()

dist = []
##次のターゲットとの距離を出す
for i in range(m-1):
    dist.append((a[i+1]-a[i]))

##最後のターゲットは右隣がないので大きな値
dist.append(1000000)

dist.sort()
score = 0
##隣との距離が小さい順に駒に回らせる
while len(dist) > n :
    score += dist[0]
    dist = dist[1:]

print(score)




### FIXED CODE ###



import sys
import math

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

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

a=list(map(int, input().split()))
##まずソート
a.sort()

dist = [None] * m
##次のターゲットとの距離を出す
for i in range(m-1):
    dist[i] = (a[i+1]-a[i])

##最後のターゲットは右隣がないので大きな値
dist[m-1] = 1000000

dist.sort()
score = 0
##隣との距離が小さい順に駒に回らせる
for i in range(m-n):
    score += dist[i]

print(score)
### BUGGY CODE ###

import math
n = int(input())

for N in range(1,n+1):
    result = 0
    for x in range(1,int(math.sqrt(N))+1):
        for y in range(1, int(math.sqrt(N-x**2))+1):
            if N-x**2-y**2-x*y < 0:
                break
            else:
                for z in range(1, int(math.sqrt(N-x**2-y**2-x*y))+1):
                    if x**2 + y**2 + z**2 + x*y + y*z + z*x == N:
                        result += 1
                    elif x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
                        break
    print(result)

### FIXED CODE ###

import math
n = int(input())
mylist = [int(math.sqrt(i)) for i in range(1,n+1)]
mylist = [0]+mylist

def main():
    for N in range(1,n+1):
        result = 0
        for x in range(1,mylist[N//3]+1):
            tempx = x**2
            for y in range(x, mylist[(N-x**2)//2]+1):
                tempy = y**2
                tempxy = x*y
                tempxandy = (x+y)/2
                tempnum = N-tempx-tempy-tempxy+tempxandy**2
                if tempnum <= 0:
                    break
                else:
                    if math.sqrt(tempnum)*2 == int(math.sqrt(tempnum)*2):
                        z = math.sqrt(tempnum)-tempxandy
                        #print(x,y,z,N)
                        if z < y:
                            break
                        elif x != y and y != z:
                            result += 6
                        elif x == y and y == z:
                            result += 1
                        else:
                            result += 3
        print(result)
main()
### BUGGY CODE ###

s = int(input())
count = 1
while True:
  dic = {s:1}
  if s % 2 == 0:
    s //= 2
  else:
    s = 3 * s + 1
  count += 1
  if s in dic.keys():
    dic[s] += 1
    print(count)
    break
  else:
    dic[s] = 1
    

### FIXED CODE ###

s = int(input())
dic = {s:1}
count = 1
while True:
  if s % 2 == 0:
    s //= 2
  else:
    s = 3 * s + 1
  count += 1
  if s in dic.keys():
    dic[s] += 1
    print(count)
    break
  else:
    dic[s] = 1
### BUGGY CODE ###

# coding: utf-8

n, q = map(int, input().split())
s = input()
lst = []
for i in range(q):
    l = list(map(int, input().split()))
    lst.append(l)

count_list = []
for i in range(q):
    f,e = lst[i][0]-1,lst[i][1]
    st = s[f:e]
    count_list.append(st.count('AC'))

for i in count_list:
    print(i) 



### FIXED CODE ###

# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for i in range(q):
    l,r = (map(int, input().split()))
    ans = t[r-1] - t[l-1]
    print(ans)
### BUGGY CODE ###

import numpy as np


N,M=map(int,input().split())
# A=np.array(list(map(int,input().split())))
A=np.array(list(map(int,input().split())),dtype=np.int64)
A=np.sort(A)

EXC=[]

for i in range(M):
    exc=list(map(int,input().split()))
    EXC.append(exc)
excArry=np.array(EXC,dtype=np.int64)

col_num=1
Arr=excArry[np.argsort(excArry[:,col_num])[::-1]]
# print(A)
# print(Arr)

point=0


for j in range (M):
    change_Num=Arr[j][1]
    count=np.count_nonzero(A<change_Num)
    if count > 0:
        m=min(count,Arr[j][0])
        A[point:point+m]=change_Num
        point+=m
        # A=np.sort(A)
    else:
        break

print(np.sum(A))
    
#     for j in range (B):
#         count=np.count_nonzero(A<C)
#         if count>0:
#             m=min(B,count)
#             A[:m]=C
#         else:
#             continue
    
#     A=np.sort(A)

# print(np.sum(A))

### FIXED CODE ###

import numpy as np


N,M=map(int,input().split())
# A=np.array(list(map(int,input().split())))
A=np.array(list(map(int,input().split())),dtype=np.int32)
A=np.sort(A)

EXC=[]

for i in range(M):
    exc=list(map(int,input().split()))
    EXC.append(exc)
excArry=np.array(EXC,dtype=np.int32)

col_num=1
Arr=excArry[np.argsort(excArry[:,col_num])[::-1]]
# print(A)
# print(Arr)

point=0


for j in range (M):
    change_Num=Arr[j][1]
    count=np.count_nonzero(A<change_Num)
    if count > 0:
        m=min(count,Arr[j][0])
        A[point:point+m]=change_Num
        point+=m
        # A=np.sort(A)
    else:
        break

print(np.sum(A))
    
#     for j in range (B):
#         count=np.count_nonzero(A<C)
#         if count>0:
#             m=min(B,count)
#             A[:m]=C
#         else:
#             continue
    
#     A=np.sort(A)

# print(np.sum(A))
### BUGGY CODE ###

import itertools
import numpy
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = list(map(lambda x: x - 1, r))
d = numpy.array([[10 ** 10] * N for _ in range(N)])

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c

for i in range(N):
    d[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 10 ** 10

for i in itertools.permutations(r):
    dist = 0
    for j in range(R - 1):
        dist += d[i[j]][i[j + 1]]
    ans = min(ans, dist)

print(ans)


### FIXED CODE ###

import itertools
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = list(map(lambda x: x - 1, r))
d = [[10 ** 10] * N for _ in range(N)]

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c

for i in range(N):
    d[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 10 ** 10

for i in itertools.permutations(r):
    dist = 0
    for j in range(R - 1):
        dist += d[i[j]][i[j + 1]]
    ans = min(ans, dist)

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

#!/usr/bin/env python3
import sys
from heapq import heapify, heappush, heappop


def solve(N: int, A: "List[int]", B: "List[int]"):

    lh = [[-b, i] for i, b in enumerate(B)]
    heapify(lh)

    count = 0
    while len(lh) > 0:
        b, i = heappop(lh)
        a, b = A[i], B[i]
        c = B[i-1]+B[(i+1) % N]
        if b > a and b >= c:
            d, m = divmod(b-a, c)
            if d == 0:
                break
            count += d
            B[i] = a+m
            if m != 0:
                heappush(lh, [-B[i], i])

    if A != B:
        count = -1

    print(count)
    return


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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# import heapq


def solve(N: int, A: "List[int]", B: "List[int]"):

    count = 0
    flag = True
    while flag:
        flag = False
        for i in range(N):
            a, b, c = B[i-1], B[i], B[(i+1) % N]
            if b > A[i] and b > a+c:
                d, m = divmod(b-A[i], a+c)
                if m == 0:
                    B[i] = A[i]
                    count += d
                else:
                    d, m = divmod(b, a+c)
                    count += d
                    B[i] = m
                flag = True
    # print(*A)
    # print(*B)
    if A != B:
        count = -1

    print(count)
    return


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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)


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

import sys
import fractions
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt=0
for i in range(n):
    cnt+=ans//a[i]
    cnt%=mod
print(cnt)


### FIXED CODE ###

import sys
from collections import deque
import heapq
import math
import bisect
from itertools import permutations
from itertools import accumulate
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

dic={}
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# print(factorization(12))
for i in range(n):
    tmp=factorization(a[i])
    for j in range(len(tmp)):
        if not tmp[j][0] in dic:
            dic[tmp[j][0]]=tmp[j][1]
        else:
            dic[tmp[j][0]]=max(dic[tmp[j][0]],tmp[j][1])
l=1
for i in dic.keys():
    l*=i**dic[i]
    l%=mod
# print(l)
ans=0
for i in range(n):
    ans+=l*pow(a[i],mod-2,mod)
    ans%=mod
print(ans)
### BUGGY CODE ###

import itertools
N = int(input())
a = list(map(int,input().split()))
ruiseki = list(itertools.accumulate(a))
b = sum(a)
ans = 10**100
for i in range(N-1):
    ans = min(ans,abs(sum(a[:i+1])*2-b))
print(ans)

### FIXED CODE ###

import itertools
N = int(input())
a = list(map(int,input().split()))
ruiseki = list(itertools.accumulate(a))
b = sum(a)
ans = 10**100
for i in range(N-1):
    ans = min(ans,abs(ruiseki[i]*2-b))
print(ans)
### BUGGY CODE ###

n, k, q = map(int, input().split())
#print(n,k,q)
l = [k-q] * n
#print(l)
katen = []
for i in range(q):
    katen.append(int(input()))
#print(katen)
for j in katen:
    x = l.pop(j-1)
    l.insert(j-1, x+1)
#print(l)

for y in l:
    if y > 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

n, k, q = map(int, input().split())
#print(n,k,q)
l = [0] * n
#print(l)
katen = []
my_append = katen.append
for i in range(q):
    my_append(int(input()))
#print(katen)

    
for j in katen:
    l[j-1] += 1 

    
#print(l)

for y in range(n):
    if l[y] > q-k:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n, k = [int(e) for e in input().split()]
h = [int(e) for e in input().split()]
cost = [0] * n
for i in range(1, n):
  cost[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
print(cost[n - 1])

### FIXED CODE ###

def main():
  n, k = [int(e) for e in input().split()]
  h = [int(e) for e in input().split()]
  cost = [0] * n
  for i in range(1, n):
    cost[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
  print(cost[n - 1])
main()
### BUGGY CODE ###

def cc(c):
    if c<2:return 0
    return int(c*(c-1)/2)

n=int(input())
a=[int(A) for A in input().split()]

cnt=0
for elem in set(a):
    cnt+=cc(a.count(elem))

for k in a:
    print(cnt-(a.count(k)-1))


### FIXED CODE ###

from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]

cnt=Counter(a)
s=sum([c*(c-1)//2 for c in cnt.values()])

for k in a:
    print(s-(cnt[k]-1))
### BUGGY CODE ###

S = input()
if len(S) < 4:
    print(0)
    exit(0)

U = set([0])
s = int(S[-1])
U.add(s)
ans = 0
for k in range(len(S)-2,-1,-1):
    s = int(S[k])*(10**(len(S)-k-1)) + s
    s %= 2019
    if s in U:
        ans += 1
    else:
        U.add(s)
print(ans)


### FIXED CODE ###

S = input()
if len(S) < 4:
    print(0)
    exit(0)
dp = [0]*2019
dp[0] = 1
s = int(S[-1])
dp[s] = 1
ans = 0
for k in range(len(S)-2,-1,-1):
    s = int(S[k])*(pow(10,len(S)-k-1,2019)) + s
    s %= 2019
    dp[s] += 1
for e in dp:
    ans += e*(e-1)//2
print(ans)
### BUGGY CODE ###

X = int(input())

ans = []
for i in range(1000):
    for j in range(1000):
        if i**j > X:
            continue
        ans.append(i**j)
print(max(ans))


### FIXED CODE ###

X = int(input())

ans = []
for i in range(1, 1000):
    for j in range(2, 11):
        if i**j > X:
            continue
        ans.append(i**j)
print(max(ans))
### BUGGY CODE ###

import copy,time

n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kitai = 0

for x in range(int(n) - (int(k)-1)):
    kazu = []
    kazu = m[x:x+int(k)]
    if ans < sum(kazu):
        ans = sum(kazu)
        kai = copy.deepcopy(kazu)

for j in range(int(k)):
    kitai += (kai[j]+1) /2

print(kitai)

### FIXED CODE ###

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

m = [(e + 1) / 2 for e in p]

t = sum(m[0:K])
result = t
for i in range(N - K):
    t -= m[i]
    t += m[i + K]
    if t > result:
        result = t
print(result)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

def main():
    ans = 0
    mod = (10**9)+7
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1):
        for j in range(i+1, n):
            ans += a[i]*a[j]
    print(ans%mod)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    ans = 0
    mod = (10**9)+7
    n = int(input())
    a = list(map(int, input().split()))
    suma = sum(a)
    for i in range(n-1):
        suma -= a[i]
        ans += a[i]*suma
    print(ans%mod)

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

def green_bin(n,s):
    count = 0

    x = [sorted(i) for i in s]
    _x = sorted(x)

    for i in range(n-1):
        for j in range(i+1,n):
            if _x[i] == _x[j]:
                count += 1
            else:
                break

    return count
if __name__ == '__main__':
    n = int(input())
    s = [ input() for i in range(n)]

    print(green_bin(n,s))

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(raw_input())
d = {}
ans = 0
for i in range(n):
    si = ''.join(sorted(raw_input()))
    if si in d:
        ans += d[si]
        d[si] += 1
    else:
        d[si] = 1
print(ans)
### BUGGY CODE ###

n=str(input())
ans=0
for i in range(0,len(n)-1):
  for j in range(i+1,len(n)+1):
    now=n[i:j]
    now=int(now)
    if now%2019==0:
      ans+=1
print(ans)

### FIXED CODE ###

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

N,K = map(int,input().split()) #K = super attack!!
Monsters = [_ for _ in map(int,input().split())]
res = 0
#一番体力の多いモンスターから、Kで殺していく。あとは一足すだけ。
Monsters.sort(reverse = True) #多い順
for i in range(K):
    if Monsters != []:
        Monsters.remove(Monsters[0])
res += sum(Monsters)
print(res)

### FIXED CODE ###

N,K = map(int,input().split()) #K = super attack!!
Monsters = [_ for _ in map(int,input().split())]
res = 0
#一番体力の多いモンスターから、Kで殺していく。あとは一足すだけ。
Monsters.sort(reverse = True) #多い順
res += sum(Monsters[K:N+1])
print(res)
### BUGGY CODE ###

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

### FIXED CODE ###

from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
res = 0
for i in range(n):
    for j in range(i+1,n):
        ab = l[i] + l[j]
        c_index = bisect_left(l, ab)
        res += c_index - j - 1
print(res)
### BUGGY CODE ###

N = int(input())
mul = [0] * (N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        mul[j] += 1
ans = 0
for i in range(1, N+1):
    ans += i * mul[i]
print(ans)

### FIXED CODE ###

N = int(input())
mul = [0] * (N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        mul[j] += 1
ans = 0
for i in range(1, N+1):
    ans += i * mul[i]
print(ans)
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

for _ in range(n):
    val = a.pop(0)
    print(max(a))
    a.append(val)


### FIXED CODE ###

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

desc = sorted(list(set(a)), reverse=True)
max = desc[0]
large_2 = desc[1] if len(desc) > 1 else 0

if a.count(max) == 1:
    for val in a:
        if val == max:
            print(large_2)
        else:
            print(max)
else:
    for _ in range(n):
        print(max)
### BUGGY CODE ###

#import numpy as np

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

for i in range(n):
    for j in range(n-1):
        A[i][j] -= 1

#print(A)

S = [0 for i in range(n)]
F = [[0 for i in range(n)] for j in range(2*n*n)]

n1n = n*(n-1)

d = 0
for ii in range(n*n*2):
    co = 0
    i = 0
    ga = 0
    while co < n:
        if F[ii][i] == 0 and S[i] <= n-2:
            aite = A[i][S[i]]
            #print(S)
            #print("aite",aite)
            if aite < n and A[aite][S[aite]] == i and F[ii][aite] == 0:
                #print("g", i, aite)
                S[i] += 1
                S[aite] += 1
                F[ii][i] = 1
                F[ii][aite] = 1
                co = 0
                ga += 1
        i = (i-1) % n
        co += 1
    d += 1
    #print("d", d)
    if ga == 0:
        if sum(S) == n1n:
            print(d-1)
        else:
            print(-1)
        break



### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(n-1):
        A[i][j] -= 1

AA = [[j for j in i] for i in A]

ID = [[-1] * n for i in range(n)]
id_ = 0
for i in range(n):
    for j in range(i+1,n):
        ID[i][j] = id_
        ID[j][i] = id_
        id_ += 1

for i in range(n):
    for j in range(n-1):
        A[i][j] = ID[i][A[i][j]]

M = [[] for i in range(id_)]
IN = [0] * id_
for i in range(n):
    for j in range(n-2):
        M[A[i][j]].append(A[i][j+1])
        IN[A[i][j+1]] +=1
# print(A)
# print(M)

# 以下、トポロジカルソート

S = []
s = 0

for i in range(id_):
    if IN[i] == 0:
        S.append(i)

while s < len(S):
    for x in M[S[s]]:
        IN[x] -= 1
        # print(x,IN)
        if IN[x] == 0:
            S.append(x)
    s += 1

# print(S)

if len(S) < id_:
    print(-1)
else:
    T = [1] * id_
    for i in range(id_):
        for j in M[S[i]]:
            T[j] = max(T[j], T[S[i]] + 1)
    print(max(T))


# 以下、閉路検出(今は削除)

# V = [0] * id_
# S = [0]
# V[0] = 1

# import sys

# def visit(x):
#     if V[x] == 1:
#         print(-1)
#         sys.exit()
#     elif V[x] == 0:
#         V[x] = 1
#         for i in M[x]:
#             visit(i)
#         V[x] = 2

# for i in range(id_):
#     if V[i] == 0:
#         visit(i)
# print("heironasi")

# 閉路検出ここまで
### BUGGY CODE ###

r, c, k = map(int, input().split())

dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)]
bord = [[0]*(c+1) for _i in range(r)]

for _i in range(k):
    _r, _c, _v = map(int, input().split())
    bord[_r-1][_c-1] = _v
            
for i in range(r):
    for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        )
        for x in range(2, 4):
            dp[1][j][x] = max(
                dp[1][j-1][x],
                dp[1][j-1][x-1]+bord[i][j],             
            )
        dp[0] = dp[1][::]

print(max(dp[1][c-1]))

### FIXED CODE ###

r, c, k = map(int, input().split())

dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)]
bord = [[0]*(c+1) for _i in range(r)]

for _i in range(k):
    _r, _c, _v = map(int, input().split())
    bord[_r-1][_c-1] = _v
            
for i in range(r):
    for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        )

        dp[1][j][2] = max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        )
        dp[1][j][3] = max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        )

    dp[0] = dp[1][::]

print(max(dp[1][c-1]))
### BUGGY CODE ###

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

### FIXED CODE ###

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