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

N, K = map(int, raw_input().split())
V = map(int, raw_input().split())

score = {}

def Compute(n, D, S):
    D2 = tuple(D)
    S2 = tuple(S)
    if (n, D2, S2) in score:
        return score[(n, D2, S2)]
    if n == 0:
        return sum(S)

    candidate = [Compute(n - 1, D, S)]
    if len(D) > 0:
        candidate.append(Compute(n - 1, D[1:], sorted(S + [D[0]])))
        candidate.append(Compute(n - 1, D[:-1], sorted(S + [D[-1]])))
    for i in range(len(S)):
        candidate.append(Compute(n - 1, D + [S[i]], S[:i] + S[i+1:]))
        candidate.append(Compute(n - 1, [S[i]] + D, S[:i] + S[i+1:]))
    return max(candidate)

print Compute(K, V, [])


### FIXED CODE ###

import bisect

N, K = map(int, raw_input().split())
V = map(int, raw_input().split())

score = -1e100

M = min(N, K)
for A in range(0, M + 1):
    for B in range(0, M - A + 1):
        S = []
        if A > 0:
            S += V[:A]
        if B > 0:
            S += V[-B:]
        S.sort()
        score = max(score, sum(S) - sum(filter(lambda x: x < 0, S)[:max(0, K - A - B)]))

print score
### BUGGY CODE ###

from operator import mul
from functools import reduce

x, y = map(int, input().split())

def combinations_count(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def A(i, j):
    if 0.5*i <= j and j <= 2*i and (i+j)%3==0:
        n, m = (2*j-i)//3, (2*i-j)//3
        return combinations_count(n+m,m)%((10**9)+7)
    else:
        return 0

print(A(x, y))

### FIXED CODE ###

x, y = map(int, input().split())

def combinations_count(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def A(i, j):
    if 0.5*i <= j and j <= 2*i and (i+j)%3==0:
        n, m = (2*j-i)//3, (2*i-j)//3
        return combinations_count(n+m,m)%((10**9)+7)
    else:
        return 0

print(A(x, y))
### BUGGY CODE ###

import sys
N=raw_input()
LN=raw_input().split()

n = int(N)
ln = [int(i) for i in LN]

ln.sort()

r = []
for i in range(n-1, -1, -1):
    a = ln[i]
    for j in range(i-1, -1, -1):
        b = ln[j]
        if a > 2*b:
            break
        for k in range(j-1, -1, -1):
            # always, a > b > c
            c = ln[k]
            if not a < b + c:
                break
            #if not b < c + a:
            #    break
            #if not c < a + b:
            #    continue
            r.append([a,b,c])

print len(r)
sys.stdout.flush()
sys.exit(0)

### FIXED CODE ###

import bisect

N=int(raw_input())
LN=map(int, raw_input().split())

LN.sort()

r = 0
for i in xrange(N-1, 1, -1):
    a = LN[i]
    for j in xrange(i-1, 0, -1):
        b = LN[j]
        if a > 2*b:
            break
        idx = bisect.bisect_left(LN, a-b+1)
        if idx < j:
            r += j - idx

print r
### BUGGY CODE ###

N, M = map(int, input().split())
AB_list = [tuple(map(int, input().split())) for i in range(N)]

sorted_AB_list = sorted(AB_list, key=lambda x:x[0], reverse=False)
sorted_AB_list = sorted(sorted_AB_list, key=lambda x:x[1], reverse=True)

money = 0

# 最終日から逆算
for i in range(M): # 残り日数
  remain_days = i+1
  
  for (A, B) in sorted_AB_list:
    if A <= remain_days:
      money += B
      sorted_AB_list.remove((A, B))
      break
  
print(money)
    
  

### FIXED CODE ###

from heapq import *
n, m = map(int, input().split())
jobs = [tuple(map(int, input().split())) for _ in range(n)]
jobs.sort(reverse=True)
ans = 0
q = []
for i in range(1, m+1):
    while jobs and jobs[-1][0] <= i:
        heappush(q, -jobs.pop(-1)[1])
    if q:
        ans -= heappop(q)
print(ans)
### BUGGY CODE ###

import numpy as np

N = int(input())
A = sorted([int(i) for i in input().split()])

dp = np.array([-1] * (A[-1]+1))
ans = 0
for i in range(N):
    a = A[i]
    if dp[a] != -1:
        continue

    if dp[a] == -1 and A.count(a) == 1:
        ans += 1
        dp[range(a+a, A[-1]+1, a)] = 0

print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
num = set(A)
count = Counter(A)
dp = [True] * (10**6 + 1)

for a in num:
    for n in range(a+a, 10**6+1, a):
        dp[n] = False

ans = 0
for a in num:
    if count[a] == 1 and dp[a] == True:
        ans += 1

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

N=int(input())
num=1
for i in range(1,N+1):
    num*=i
print(num%(10**9+7))

### FIXED CODE ###

import math
print(math.factorial(int(input()))%(10**9+7))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L = {}
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L:
    h.add(i+1,1)
    on.add(i+1)
  if b in L:
    jump[L[b]]=i+1
  L[b] = i+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

p = []
for q in LOO:
  p.append(ans[q])
  
print(*p, sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L = {}
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L:
    h.add(i+1,1)
    on.add(i+1)
  if b in L:
    jump[L[b]]=i+1
  L[b] = i+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

p = []
for q in LOO:
  p.append(ans[q])
  
print(*p, sep="\n")
### BUGGY CODE ###

import sys #追加

n=int(input())
sys.setrecursionlimit(10**6*2)

s=input()
X=int(s,2)

one_cnt=s.count("1")


ans=[]

ans_memo=[0]*(2*(10**5)+2)
#print(ans_memo)
ans_memo[1]=1
ans_memo[2]=1

def DEF(x,cnt):
    global ans_memo
    #print(x,cnt,ans_memo)
    if x==0:
        return 0
    if x<2*(10**5)+1:    
        if ans_memo[x]!=0:
            return ans_memo[x]
        else:
            if x%(str(bin(x)).count("1"))==0:
                ans_memo[x]=1
                return 1
            else:
                tmp=DEF(x%(str(bin(x)).count("1")),cnt+1)+1
                ans_memo[x]=tmp
                return tmp
    else:
        if x%(str(bin(x)).count("1"))==0:
            return 1
        else:
            tmp=DEF(x%(str(bin(x)).count("1")),cnt+1)+1
            return tmp


ans=[]

for i in range(n):
    tmp=2**(n-i-1)
    tmp_num=X
    #1の時
    if tmp&tmp_num:
        tmp_num-=tmp
        if tmp_num==0:
            ans.append(0)
        else:
            tmp_num=tmp_num%(one_cnt-1)
            ans.append(DEF(tmp_num,1)+1)
        
    else:
        tmp_num+=tmp
        #print(bin(tmp_num),n-i-1)
        tmp_num=tmp_num%(one_cnt+1)
        ans.append(DEF(tmp_num,1)+1)

#print(ans_memo)

for item in ans:
    print(item)
            









### FIXED CODE ###

def popcount(x):
    return bin(x).count("1")

n=int(input())
s=input()
X=int(s,2)

one_cnt=popcount(X)

modp=X%(one_cnt+1)
modm=X%(one_cnt-1) if one_cnt-1!=0 else 0

for i in range(n):
    if s[i]=="1":
        if one_cnt-1==0:
            print(0)
            continue
        else:
            num=(modm-pow(2,n-i-1,one_cnt-1))%(one_cnt-1)
    else:
        num=(modp+pow(2,n-i-1,one_cnt+1))%(one_cnt+1)

    #print(i,"num",num)
    cnt=1
    while num!=0:
        num=num%popcount(num)
        cnt+=1
    print(cnt)
### BUGGY CODE ###


def main():
    import sys
    input = sys.stdin.readline
    #n = int(input())
    #l = list(map(int, input().split()))
    '''
    A=[]
    B=[]
    for i in range():
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)'''

    n=int(input())
    s=input().rstrip('\n')
    from collections import Counter
    a=Counter(s)
    #print(a)
    num=a["R"]*a["G"]*a["B"]
    #print(num)
    for i in range(n-2):
        for j in range(1,n):
            if i+2*j<n:
                #print([i,i+j,i+2*j,s[i], s[i+j], s[i+2*j]])
                if set([s[i],s[i+j],s[i+2*j]])==set(["R","G","B"]):
                    num-=1
    print(num)

if __name__ == "__main__":
    main()

### FIXED CODE ###


def main():
    import sys
    input = sys.stdin.readline
    #n = int(input())
    #l = list(map(int, input().split()))
    '''
    A=[]
    B=[]
    for i in range():
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)'''

    n=int(input())
    s=input().rstrip('\n')
    a=0
    b=0
    c=0
    for i in range(n):
        if s[i]=="R":
            a+=1
        elif s[i]=="G":
            b+=1
        elif s[i]=="B":
            c+=1
    num=a*b*c
    #print(num)
    for i in range(n-2):
        for j in range(1,n//2+1):
            if i+2*j<n:
                if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
                    num-=1
    print(num)

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

import fractions
import sys
input=sys.stdin.readline
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
n,m=map(int,input().split())
s=input()
t=input()
if s[0]!=t[0]:
    print(-1)
    exit()
k=lcm(n,m)
ans=[""for i in range(k)]
ans[0]=s[0]
for i in range(1,n):
    ans[i*(k//n)]=s[i]
for i in range(1,m):
    if not ans[i*(k//m)]:
        ans[i*(k//m)]=t[i]
    else:
        if ans[i*(k//m)]!=t[i]:
            print(-1)
            exit()
print(k)

### FIXED CODE ###

from math import gcd
N,M = map(int, input().split())
S = input()
T = input()
G = gcd(N,M)
for i in range (G):
  if S[N//G * i] != T[M//G * i]:
    print(-1)
    exit()
print(N//G * M//G * G)
### BUGGY CODE ###

n = input()


def get_sum(n):
    s = str(n)
    arr = list(map(int, list(s)))
    return sum(arr)

ans = get_sum(n)
i = 1
for i in range(1, 10000):
    m = get_sum(n * i)
    if ans > m:
        ans = m

print(ans)


### FIXED CODE ###

import collections


def ans(n):
    dist = [10 ** 5] * n
    dist[1] = 1
    d = collections.deque()
    d.append(1)
    while not d.count == 0:
        u = d.popleft()
        if u == 0:
            return dist[u]
        if dist[u] < dist[(u * 10) % n]:
            dist[(u * 10) % n] = dist[u]
            d.appendleft((u * 10) % n)
        if dist[u] < dist[(u + 1) % n]:
            dist[(u + 1) % n] = dist[u] + 1
            d.append((u + 1) % n)

n = int(input())
print(ans(n))
### BUGGY CODE ###

N, K = map(int, input().split())
T_list = list(map(int, input().split()))
T_list = [T_list[i]-1 for i in range(N)]
count_list = []

for s_point in range(N):
  point = s_point
  count = 0
  i = 0
  while i < N:
    point = T_list[point]
    if point == s_point:
      count = i+1
      break
    i += 1
  count_list.append(count)

point = 0
while count_list[point] == 0:
  point = T_list[point]
  count += 1

L = (K-count) % count_list[point]

i = 0
while i < L:
  point = T_list[point]
  i += 1

print(point+1)

### FIXED CODE ###

N, K = map(int, input().split())
T_list = list(map(int, input().split()))
T_list = [T_list[i]-1 for i in range(N)]
point = 0
syuuki = 0

if K < N:
  i = 0
  while i < K:
    point = T_list[point]
    i += 1  

else:
  i = 0
  while i < N:
    point = T_list[point]
    if point == 0:
      syuuki = i+1
      break
    i += 1
  second_point = point
  
  if syuuki != 0:
    L = K % syuuki

  else:
    j = 0
    while j < N:
      point = T_list[point]
      if point == second_point:
        syuuki = j+1
        break
      j += 1
    L = (K-i) % syuuki

  k = 0
  while k < L:
    point = T_list[point]
    k += 1
  
print(point+1)
### BUGGY CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
origin = sum(A)
heapq.heapify(A)

for _ in range(M):
    b, c = map(int, input().split())
    for _ in range(b):
        smallest = heapq.heappop(A)
        tmp = c - smallest
        if tmp <= 0:
            heapq.heappush(A, smallest)
            break
        else:
            heapq.heappush(A, c)
            origin += tmp

print(origin)


### FIXED CODE ###

import sys
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
origin = sum(A)
heapq.heapify(A)

BC = [list(map(int, input().split())) for _ in range(M)]
BC = sorted(BC, reverse=True, key=lambda x: x[1])

count = 0

for i in range(M):
    b = BC[i][0]
    c = BC[i][1]
    for _ in range(b):
        smallest = heapq.heappop(A)
        tmp = c - smallest
        if tmp <= 0:
            heapq.heappush(A, smallest)
            break
        else:
            heapq.heappush(A, c)
            origin += tmp
            count += 1
            if count >= N:
                print(origin)
                sys.exit()

print(origin)
### BUGGY CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)
input=sys.stdin.readline


N = int(input())
par = {i:[] for i in range(1, N+1)}

for i in range(2, N+1):
    a = int(input())
    par[a].append(i)

@lru_cache(maxsize=None)
def dfs(s):
    depth = 1
    res = []
    for t in par[s]:
        res.append(dfs(t))
    res.sort(reverse=True)
    for i, j in enumerate(res, start=1):
        depth = max(depth, i+j)
    return depth

print(dfs(1)-1)

### FIXED CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)
input=sys.stdin.readline


N = int(input())
par = {i:[] for i in range(1, N+1)}

for i in range(2, N+1):
    a = int(input())
    par[a].append(i)

@lru_cache(maxsize=None)
def dfs(s):
    depth = 1
    res = []
    for t in par[s]:
        res.append(dfs(t))
    res.sort(reverse=True)
    for i, j in enumerate(res, start=1):
        depth = max(depth, i+j)
    return depth

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

import sys
from itertools import permutations

for line in sys.stdin:
    n, s = map(int, line.split())
    count = 0
    for combi in permutations(range(10), n):
        if sum(x * y for (x, y) in zip(range(1, 10), combi)) == s:
            count += 1
    print(count)

### FIXED CODE ###

import sys


def memoize(f):
    memo = {}

    def main(*args):
        if args in memo:
            return memo[args]
        result = memo[args] = f(*args)
        return result

    return main


def get_num(remains):
    i = 0
    while remains:
        if remains & 1:
            yield i
        i += 1
        remains >>= 1


@memoize
def calc(n, s, remains):
    if n == 1:
        if remains & (1 << s):
            return 1
        else:
            return 0
    if s <= 0:
        return 0

    return sum(calc(n - 1, s - n * m, remains ^ (1 << m)) for m in get_num(remains) if s - n * m >= 0)


for line in sys.stdin:
    n, s = map(int, line.split())
    print(calc(n, s, (1 << 10) - 1))
### BUGGY CODE ###

def main():
    s = input()
    t = list(input())
    N = len(s)

    for tt in t:
        if tt not in s:
            ans = -1
            print(ans)
            exit()

    i = 0
    ans = 0
    r = s * 2
    while t:
        tt = t.pop(0)
        r = r[i::] + s
        for rr in r:
            if tt == rr:
                i = r.index(rr)
                break
        ans += (i + 1)
        i += 1
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from bisect import bisect


def search_alphabet_index(string):
    cs = [[] for i in range(26)]
    for i, s in enumerate(string):
        j = ord(s) - ord("a")
        cs[j].append(i)
    return cs


def main():
    S = input()
    T = input()
    N = len(S)

    cs = search_alphabet_index(S)

    for c in set(T):
        if not cs[ord(c) - ord("a")]:
            ans = -1
            print(ans)
            exit()

    rnd = 0
    k = -1
    for t in T:
        ti = ord(t) - ord("a")
        i = bisect(cs[ti], k)
        if i == len(cs[ti]):
            k = cs[ti][0]
            rnd += 1
        else:
            k = cs[ti][i]
    ans = rnd * N + k + 1
    print(ans)


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

n=int(input())
*a,=map(int,input().split())
sum_a=[]
for i in range(n):
    sum_a.append(sum(a)-sum(a[:i+1]))
b=0
for i in range(n):
    b+=sum_a[i]*a[i]
print(b%(10**9+7))

### FIXED CODE ###

n=int(input())
*a,=map(int,input().split())
s=sum(a)%(10**9+7)
c=0
b=0
for i in range(n):
    b+=a[i]
    amod=a[i]%(10**9+7)
    c+=(s-b)*amod
print(c%(10**9+7))
### BUGGY CODE ###

from collections import deque

N, *A = map(int, open(0).read().split())
V = N * (N - 1) // 2
G = {(i + 1, j + 1): [] for i in range(N) for j in range(i + 1, N)}
deg = {(i + 1, j + 1): 0 for i in range(N) for j in range(i + 1, N)}
for i, a in enumerate(zip(*[iter(A)] * (N - 1)), 1):
    P = [(i, p) if i < p else (p, i) for p in a]
    for j in range(N - 2):
        G[P[j]].append(P[j + 1])
        deg[P[j + 1]] += 1

Q = deque((k, 1) for k, v in deg.items() if v == 0)

ans = 0
cnt = len(Q)
while Q:
    v, ans = Q.popleft()
    for t in G[v]:
        deg[t] -= 1
        if deg[t] == 0:
            Q.append((t, ans + 1))
            cnt += 1

if cnt != V:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import time
start = time.time()

import sys
input = sys.stdin.readline

N = int(input())
A = [[int(i) - 1 for i in input().split()] for _ in range(N)]

cur = [0] * N

max_pairs = N * (N - 1)

pairs = 0
cnt = 1
for _ in range(max_pairs // 2):
    visited = [False] * N
    for i, a in enumerate(A):
        if cur[i] >= N - 1:
            continue
        p = a[cur[i]]
        if A[p][cur[p]] == i:
            # print(cnt, p + 1, A[p][cur[p]] + 1, i + 1)
            visited[i] = True
            visited[a[cur[i]]] = True
            pairs += 1

    # print(pairs)
    if pairs == max_pairs:
        break
    if pairs > max_pairs:
        print(-1)
        quit()

    update = False
    for i, v in enumerate(visited):
        if v:
            cur[i] += 1
            update = True

    if not update:
        print(-1)
        quit()

    if time.time() - start > 1.8:
        print(N * (N - 1) // 2)
        exit()

    cnt += 1

print(cnt)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

visited = []
pos = 0
count = 0

while pos not in visited:
	visited.append(pos)
	pos = a[pos]-1
	count += 1
	if count >= k:
		print(pos+1)
		exit()

loop_start = visited.index(pos)
loop_length = len(visited)-loop_start
pos_t = (k-loop_start) % loop_length + loop_start
print(visited[pos_t]+1)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

visited = []
tf_visited = [0] * n
pos = 0
count = 0

while tf_visited[pos] == 0:
	visited.append(pos)
	tf_visited[pos] = 1
	pos = a[pos]-1
	count += 1
	if count >= k:
		print(pos+1)
		exit()

loop_start = visited.index(pos)
loop_length = len(visited)-loop_start
pos_t = (k-loop_start) % loop_length + loop_start
print(visited[pos_t]+1)
### BUGGY CODE ###

N = int(input())
import numpy as np
#max=int(np.sqrt(N))

for n in range(1,N+1):
    j=0
    max = int(np.sqrt(abs(n-2)))
    #print(max)
    for x in range(1,max):
        for y in range(1, max):
            for z in range(1, max):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > n:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if j==0:
                        max = z+1
                        #print(x, y, z)
                        #print(f'n:{n}')
                        j += 1
                    else:
                        j += 1
    print(j)


### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1

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

#dp[i][j][k]=(i,j)にアイテムをk個以下使って移動するときの最大値
#入力
r,c,k=list(map(int,input().split()))

rck=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(k):
     r_num,c_num,k_num=list(map(int,input().split()))
     rck[r_num][c_num]=k_num

#dpテーブルと初期条件
dp=[[[0 for i in range(4)] for j in range(c+1)] for k in range(r+1)]
#dp
for i in range(1,r+1):
  for j in range(1,c+1):
    for k in range(1,4):
      dp[i][j][k]=max(dp[i-1][j][3]+rck[i][j],dp[i][j-1][k-1]+rck[i][j],dp[i][j-1][k],dp[i][j][k-1])
    #print(dp[i][j])
print(dp[r][c][3])

      
      
      
      
      


  

### FIXED CODE ###

#dp[i][j][k]=(i,j)にアイテムをk個以下使って移動するときの最大値
#入力
r,c,k=list(map(int,input().split()))

rck=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(k):
     r_num,c_num,k_num=list(map(int,input().split()))
     rck[r_num][c_num]=k_num

#dpテーブルと初期条件
dp_0=[[0 for j in range(c+1)] for k in range(r+1)]
dp_1=[[0 for j in range(c+1)] for k in range(r+1)]
dp_2=[[0 for j in range(c+1)] for k in range(r+1)]
dp_3=[[0 for j in range(c+1)] for k in range(r+1)]
#dp
for i in range(1,r+1):
  for j in range(1,c+1):
    dp_1[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_0[i][j-1]+rck[i][j],dp_0[i][j],dp_1[i][j-1])
    dp_2[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_1[i][j-1]+rck[i][j],dp_1[i][j],dp_2[i][j-1])
    dp_3[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_2[i][j-1]+rck[i][j],dp_2[i][j],dp_3[i][j-1])
    
    
    
    
    #dp[i][j][k]=max(dp[i-1][j][3]+rck[i][j],dp[i][j-1][k-1]+rck[i][j],dp[i][j][k-1],dp[i][j-1][k])
    #print(dp[i][j])
print(dp_3[r][c])
### BUGGY CODE ###

import numpy as np

n,k,q=map(int,input().split())
p=np.array([0]+[k]*n)

for _ in range(q):
    p=p-1
    p[int(input())]+=1

for i in range(1,n+1):
    print("Yes" if p[i]>0 else "No")


### FIXED CODE ###

import numpy as np

n,k,q=map(int,input().split())
p=[0]*(n+1)

for _ in range(q):
    p[int(input())]+=1

for i in range(1,n+1):
    print("Yes" if k-(q-p[i])>0 else "No")