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

H,W=[int(s) for s in input().split()]
inls=[[int(s) for s in input().split()] for _ in range(H)]
for i in range(H):
  x=[int(s) for s in input().split()]
  for j in range(W):
    inls[i][j]-=x[j]
dp=[[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(abs(inls[0][0]))
for i in range(H):
  for j in range(W):
    for e in dp[i-1][j]:
      dp[i][j].add(abs(e+inls[i][j]))
      dp[i][j].add(abs(e-inls[i][j]))
    for e in dp[i][j-1]:
      dp[i][j].add(abs(e+inls[i][j]))
      dp[i][j].add(abs(e-inls[i][j]))
print(min(dp[H-1][W-1]))


### FIXED CODE ###

import time
start = time.time()
H,W=[int(s) for s in input().split()]
inls=[[int(s) for s in input().split()] for _ in range(H)]
for i in range(H):
  x=[int(s) for s in input().split()]
  for j in range(W):
    inls[i][j]=abs(inls[i][j]-x[j])
dp=[[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(inls[0][0])
for i in range(H):
  for j in range(W):
    x=80*(H+W-i-j)
    for e in dp[i-1][j]:
      if e+inls[i][j]<x:
        dp[i][j].add(e+inls[i][j])
      dp[i][j].add(abs(e-inls[i][j]))
    for e in dp[i][j-1]:
      if e+inls[i][j]<x:
        dp[i][j].add(e+inls[i][j])
      dp[i][j].add(abs(e-inls[i][j]))
  if time.time() - start>1.7:
    dp[H-1][W-1].add(0)
    break
print(min(dp[H-1][W-1]))
### BUGGY CODE ###

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

root = [1]

break_flag = 0
for n in range(K):
  new = A_list[ int(root[n])-1 ]
  if new not in root:
    root.append(new)
  else:
    ind = root.index(new)
    break
else:
  print(new)
  break_flag = 1
    
if break_flag == 0:  
	pre = len(root[:ind])
	roop = len(root)-pre

	print(root[ind:][(K-pre)%roop])

### FIXED CODE ###

def main():
  N, K = map(int, input().split())
  A_list = input().split()

  root = [1]

  record = [-1]*N
  break_flag = 0
  for n in range(K):
    new = int(A_list[ int(root[n])-1 ])
    if record[new-1] <0:
      record[new-1]=1
      root.append(new)
    else:
      ind = root.index(new)
      break
  else:
    print(new)
    break_flag = 1
    
  if break_flag == 0:  
	  pre = len(root[:ind])
	  roop = len(root)-pre

	  print(root[ind:][(K-pre)%roop])
   
if __name__ == '__main__':
  main()
### BUGGY CODE ###

n,w=map(int,input().split())
dp=[[0 for i in range(w+1)] for j in range(n+1)]
c,p=map(int,input().split())
dp[1][c]=p
for i in range(2,n+1):
  c,p=map(int,input().split())
  for j in range(w-1,0,-1):
    if j+c<=w and dp[i-1][j] != 0:
      dp[i][j+c]=max(dp[i-1][j+c],dp[i-1][j]+p)
    if dp[i-1][j] != 0:
      dp[i][j]=dp[i-1][j]
  dp[i][c]=max(dp[i-1][c],p)
print(max([dp[n][i] for i in range(w+1)]))

### FIXED CODE ###

import sys
input=sys.stdin.readline
 
n,w=map(int,input().split())
dp=[0]*(w+1)
 
def ans(n,w):
  for _ in range(n):
    c,p=map(int,input().split())
    for j in range(w,c-1,-1):
      tmp=dp[j-c]+p
      if dp[j]<tmp:
        dp[j]=tmp
  return max(dp)
print(ans(n,w))
### BUGGY CODE ###

r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

# 求めるものは
# sum[i,r1,r2]sum[j,c1,c2] f(i, j) ・・・ (1)
# g(x, y) = sum[i,0,x]sum[j,0,y](i+j)choose(i) とすると
# (1) = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
# と変形できる
# ここでsum[j,0,y](i+j)choose(i) = (i+y+1)choose(i+1)と変形できる
# これ解けた人って上記の変形を知識として知っていたんですか？その場で算出したんですか？後者ならすごすぎる・・・。
# 詳細はけんちょんさんのブログが凄くわかりやすいです
# よってg(x, y) = sum[i,0,x](i+y+1)choose(i+1)と変形できる

fac = [1]
inv = [1]
for i in range(1, r2 + c2 + 10) :
  fac.append(fac[-1] * i % mod)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

def g(x, y) :
  s = 0
  for i in range(x + 1) :
    s += comb(i + y + 1, i + 1)
  return s

ret = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
ret %= mod

print(ret)

### FIXED CODE ###

r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

fac = [1]
inv = [1]
for i in range(1, r2 + c2 + 10) :
  fac.append(fac[-1] * i % mod)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

def g(x, y) :
  return comb(x + y, y)

ret = g(r2+1, c2+1) - g(r2+1, c1) - g(r1, c2+1) + g(r1, c1)
ret %= mod

print(ret)
### BUGGY CODE ###

import time
n = int(input())
sTime = time.time()

def sum_digit(n):
    s = 0
    while n>0:
        s += n%10
        n //= 10
    return s


mi = n
t = 0
for i in range(1, 10**n):
    mi = min(mi, sum_digit(n*i))
    t = time.time() - sTime
    if t > 2.7:
        break
        
print(mi)

### FIXED CODE ###

n = int(input())

while n % 2 == 0:
    n //= 2
while n % 5 == 0:
    n //= 5
if n == 1:
    print(1)
else:
    X = [n for i in range(n)]
    
    j = 1
    s = 1
    post = []
    m = 0
    while True:
        s *= 10
        s %= n
        post.append(s)
        X[s] = min(j, X[s])
        m += 1
        if s == 1:
            break
    ans = 0
    while True:
        if ans > 0:
            break
        pre = post
        post = []
        j += 1
        for p in pre:
            pp = (p + 1) % n
            if pp == 0:
                X[0] = j
                ans = j
                break
            if X[pp] == n:
                for i in range(m):
                    post.append(pp)
                    X[pp] = j
                    pp *= 10
                    pp %= n
    print(ans)
### BUGGY CODE ###

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

A = [[A[i],i] for i in range(N)]
A.sort()

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

ans = 0
for i in range(N+1):
    for j in range(N+1):
        if i+j>N:
            continue
        if i+j==0:
            continue
        a,k = A[-i-j]
        if i==0:
            dp[i][j] = dp[i][j-1]+a*(N-j-k)
        elif j==0:
            dp[i][j] = dp[i-1][j]+a*(k-i+1)
        else:
            dp[i][j] = max(dp[i-1][j]+a*(k-i+1),dp[i][j-1]+a*(N-j-k))
        ans = max(ans,dp[i][j])
print(ans)

### FIXED CODE ###

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

A = [[A[i],i] for i in range(N)]
A.sort()

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

ans = 0
for i in range(N+1):
    for j in range(N+1):
        if i+j>N:
            continue
        if i+j==0:
            continue
        a,k = A[-i-j]
        if i==0:
            dp[i][j] = dp[i][j-1]+a*(N-j-k)
        elif j==0:
            dp[i][j] = dp[i-1][j]+a*(k-i+1)
        else:
            dp[i][j] = max(dp[i-1][j]+a*(k-i+1),dp[i][j-1]+a*(N-j-k))
        ans = max(ans,dp[i][j])
print(ans)
### BUGGY CODE ###

import math

def comb(n, k, m):
  nf  = math.factorial(n)   % m
  kf  = math.factorial(k)   % m
  nkf = math.factorial(n-k) % m
  return nf * pow_mod(kf*nkf%m, m-2, m) % m

def pow_mod(a, b, m):
  if b == 0:
    return 1
  elif b%2 == 0:
    return pow_mod(a, b//2, m) ** 2 % m 
  else:
    return pow_mod(a, b-1, m) * a % m

tmp = list(map(int, input().split()))
x = tmp[0]
y = tmp[1]

ans = 0
mod = 10**9 + 7

if (x + y) % 3 != 0:
  ans = 0
else:
  n = (x + y) // 3
  if min(x, y) < n:
    ans = 0
  elif min(x,y) == n:
    ans = 1
  else:
    r = min(x, y) - n
    ans = comb(n, r, mod)

print(ans)

### FIXED CODE ###

import math

def comb(n, k, m):
  f = [1] * (n+1)
  for i in range(1, n+1):
    f[i] = f[i-1] * i % m
  return f[n] * pow_mod(f[k]*f[n-k]%m, m-2, m) % m

def pow_mod(a, b, m):
  if b == 0:
    return 1
  elif b%2 == 0:
    d = pow_mod(a, b//2, m) % m
    return d * d % m 
  else:
    d = pow_mod(a, (b-1)//2, m)
    return  d * d * a % m

tmp = list(map(int, input().split()))
x = tmp[0]
y = tmp[1]

ans = 0
mod = 10**9 + 7

if (x + y) % 3 != 0:
  ans = 0
else:
  n = (x + y) // 3
  if min(x, y) < n:
    ans = 0
  elif min(x,y) == n:
    ans = 1
  else:
    r = min(x, y) - n
    ans = comb(n, r, mod)

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

import sys
import math
from bisect import bisect_left as bl
import numpy as np

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)

    bi.sort()
    tmp=0
    for j in range(N):
        x=a[j]%(2*T)
        tmp+= -bl(bi,T-x)+bl(bi,2*T-x)-bl(bi,3*T-x)+bl(bi,4*T-x)
    ans+=(tmp%2)*T

print(ans)

### FIXED CODE ###

import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)
    bi.sort()

    tmp=0
    left1 = bl(bi, T - ai)
    right1 = bl(bi, 2*T - ai)
    left2 = bl(bi, 3*T - ai)
    right2 = bl(bi, 4*T - ai)    
    if np.sum(-left1 + right1 -left2 +right2) % 2: ans+=T

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

# L 以下の数のうち最大の2のべき数をtとする。t = 2 ** k とする。
# k は len(L)-1だね。

# a+bがt未満： 3 ** k 通り
# a+bがt以上L以下： いろいろ複雑！

L = input()
lenL = len(L) 
ans = 3 ** (lenL - 1)
mod = 10 ** 9 + 7

num_one_leftside = 1
for i in range(1, lenL):
	if L[i] == '1':
		ans += 2 ** num_one_leftside * 3 ** (lenL - i - 1)
		ans %= mod

#		print (num_one_leftside ,  (lenL - i - 1))
		num_one_leftside += 1

ans += 2 ** num_one_leftside 
ans %= mod

print(ans)

### FIXED CODE ###

# L 以下の数のうち最大の2のべき数をtとする。t = 2 ** k とする。
# k は len(L)-1だね。

# a+bがt未満： 3 ** k 通り
# a+bがt以上L以下： いろいろ複雑！

L = input()
lenL = len(L) 
ans = 3 ** (lenL - 1)
mod = 10 ** 9 + 7

pow_2 = [1] * (lenL+1)
pow_3 = [1] * (lenL+1)

for i in range(1, lenL+1):
	pow_2[i] = pow_2[i-1] * 2 % mod
	pow_3[i] = pow_3[i-1] * 3 % mod

num_one_leftside = 1
for i in range(1, lenL):
	if L[i] == '1':
		ans += pow_2[num_one_leftside] * pow_3[lenL - i - 1]
		ans %= mod

#		print (num_one_leftside ,  (lenL - i - 1))
		num_one_leftside += 1

ans += pow_2[num_one_leftside]
ans %= mod

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

import sys
input=sys.stdin.readline

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

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

tk=UnionFind(n)

kk=[[False] * n for _ in range(n)]

for _ in range(m):
    a,b=map(int, input().split())
    kk[a-1][b-1]=True
    kk[b-1][a-1]=True
    tk.union(a-1, b-1)

for _ in range(k):
    c,d=map(int, input().split())
    kk[c-1][d-1]=True
    kk[d-1][c-1]=True

for i in range(n):
    ans=-1
    for j in range(n):
        if not kk[i][j] and tk.is_same(i, j):
            ans+=1
    print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

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

tk=UnionFind(n)

stk=[0 for _ in range(n)]
blk=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int, input().split())
    stk[a-1]+=1
    stk[b-1]+=1
    tk.union(a-1, b-1)

for _ in range(k):
    c,d=map(int, input().split())
    blk[c-1].append(d-1)
    blk[d-1].append(c-1)

for i in range(n):
    ans=tk.get_size(i)-1-stk[i]
    for j in blk[i]:
        if tk.is_same(i, j):
            ans-=1
    print(ans)
### BUGGY CODE ###

from collections import Counter, defaultdict

n = int(input())
sss = [input() for _ in range(n)]
d = defaultdict(int)
for s in sss:
    cnt = Counter(s)
    flag = 0
    for c in cnt:
        k = ord(c) - 97
        flag |= 1 << (k * 20)
    d[''] += flag
    for i in range(len(s) - 1, 0, -1):
        c = s[i]
        cnt[c] -= 1
        if cnt[c] == 0:
            flag ^= 1 << ((ord(c) - 97) * 20)
        d[s[i:]] += flag

ans = 0
mask = (1 << 20) - 1
for s in sss:
    flag = d[s[1:]]
    bs = ((ord(s[0]) - 97) * 20)
    cnt = (flag >> bs) & mask
    ans += cnt - 1

print(ans)


### FIXED CODE ###

from collections import Counter

n = int(input())
sss = [input() for _ in range(n)]
d = {s[1:]: 0 for s in sss}
flags = [1 << (i * 18) for i in range(26)]

trie_chr = [-1]
trie_children = [{}]
trie_counter = [0]
trie_fin = [0]
s_fin_node = []
l = 1

for s in sss:
    node = 0
    trie_counter[node] += 1
    for i in range(len(s) - 1, 0, -1):
        c = ord(s[i]) - 97
        if c in trie_children[node]:
            node = trie_children[node][c]
            trie_counter[node] += 1
        else:
            trie_chr.append(c)
            trie_children.append({})
            trie_fin.append(0)
            trie_children[node][c] = l
            trie_counter.append(1)
            node = l
            l += 1
    trie_fin[node] += 1
    s_fin_node.append(node)

trie_flags = [0] * l

for s in sss:
    cnt = Counter(s)
    flag = 0
    for c in cnt:
        flag |= flags[ord(c) - 97]
    node = 0
    if len(s) > 1 and trie_fin[node] > 0:
        trie_flags[node] += flag

    for i in range(len(s) - 1, 1, -1):
        c = s[i]
        k = ord(c) - 97
        cnt[c] -= 1
        if cnt[c] == 0:
            flag ^= flags[k]

        node = trie_children[node][k]
        # print(s, i, node, trie_counter[node])
        if trie_counter[node] == 1:
            break
        if trie_fin[node] > 0:
            trie_flags[node] += flag
            # print('add', s, i)

# print([chr(c) if c >= 0 else -1 for c in trie_chr])
# print(trie_counter)
# print(trie_fin)
# print(trie_flags)
# print(s_fin_node)

ans = 0
mask = (1 << 18) - 1
for i, s in enumerate(sss):
    cnt = (trie_flags[s_fin_node[i]] >> ((ord(s[0]) - 97) * 18)) & mask
    ans += cnt

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

N = int(input())
word_count = {}
for n in range(N):
  s = input()
  if s in word_count:
    word_count[s] += 1
  else:
    word_count[s] = 1
max_word_list = [kv[0] for kv in word_count.items() if kv[1] == max(word_count.values())]
# 辞書順にソートして出力
max_word_list = sorted(max_word_list)
for word in max_word_list:
  print(word)


### FIXED CODE ###

from collections import Counter
N = int(input())
l=[input() for i in range(N)]
count=Counter(l).most_common()
d = []
most = count[0][1]
for si,c in count:
  if c==most:
    d.append(si)
d.sort()
for i in d:
  print(i)



# # O(N)
# max_word_list = [kv[0] for kv in word_count.items() if kv[1] == max(word_count.values())]

# # 辞書順にソートして出力
# max_word_list = sorted(max_word_list)
# for word in max_word_list:
#   print(word)
### BUGGY CODE ###

import heapq
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
road_map = []
for i in range(h):
    road = input()
    road_map.append(road)
queue = []
heapq.heappush(queue,[0,ch-1,cw-1])
used_map = [[-1]*w for _ in range(h)]

layer_set = set()
layer_set.add((ch-1,cw-1))
loop = 0
while used_map[dh-1][dw-1] == -1 and queue != []:
    #move walk
    while queue != []:
        dot = heapq.heappop(queue)
        if dot[1] < 0 or dot[2] < 0 or dot[1] >= h or dot[2] >= w:
            continue
        if used_map[dot[1]][dot[2]] > -1 and used_map[dot[1]][dot[2]] <= dot[0]:
            continue
        if road_map[dot[1]][dot[2]] == "#":
            continue
        used_map[dot[1]][dot[2]] = dot[0]
        layer_set.add((dot[1],dot[2]))

        if not (dot[2] - 1 < 0):
            heapq.heappush(queue,[dot[0],dot[1],dot[2]-1])
        if not (dot[2] + 1 >= w):
            heapq.heappush(queue,[dot[0],dot[1],dot[2]+1])
        if not (dot[1]+1 >= h):
            heapq.heappush(queue,[dot[0],dot[1]+1,dot[2]])
        if not (dot[1]-1 < 0):
            heapq.heappush(queue,[dot[0],dot[1]-1,dot[2]])

    temp = []
    for s in layer_set:
        for x in range(-2,3,1):
            for y in range(-2,3,1):
                if not(s[0]+ x < 0 or s[1]+y < 0 or s[0]+x >= h or s[1]+y >= w):
                    if used_map[s[0]+x][s[1]+y] == -1 and road_map[s[0]+x][s[1]+y] == ".":
                        temp = [s[0]+x,s[1]+y]
                if temp != []:
                    break
            if temp != []:
                break
        if temp != []:
            break 
    if temp != []:
        heapq.heappush(queue,[loop+1,temp[0],temp[1]])
    loop+=1
    
print(used_map[dh-1][dw-1])

### FIXED CODE ###

#shotoyooさんのコードをお借りしてテスト

import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
      

h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
ss = np.array([[c=="#" for c in input()] for _ in range(h)])

print(main(ss,ch,cw,dh,dw))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from copy import deepcopy
from operator import add
from itertools import accumulate

N, K = inpl()
A = sorted(inpl())
S = list(accumulate(A, add))
A = A[::-1]
DP = [False for _ in range(K)]
DP[0] = 1
OK = [False for _ in range(N)]

for i, a in enumerate(A):
    DP0 = deepcopy(DP)
    if a >= K:
        OK[i] = True
        continue
    for j, d in enumerate(DP0[-S[::-1][i]:], max(0, K-S[::-1][i])):
        if d:
            if j + a >= K:
                OK[i] = True
                break
            else:
                DP[j+a] = True

if sum(OK) == 0:
    print(N)
else:
    print(OK[::-1].index(True))

### FIXED CODE ###

# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
 
N, K = inpl()
A = sorted(inpl())
S = []
s = 0
for a in A:
    s += a
    S.append(s)

A = A[::-1]
DP = [True]+[False for _ in range(K-1)]

OK = [False for _ in range(N)]
 
for i, a in enumerate(A):
    DP1 = [False] * K
    if a >= K:
        OK[i] = True
        continue
    for j, d in enumerate(DP[-S[::-1][i]:], max(0, K-S[::-1][i])):
        if d:
            DP1[j] = True
            if j + a >= K:
                OK[i] = True
                break
            else:
                DP1[j+a] = True
    DP = DP1 
if sum(OK) == 0:
    print(N)
else:
    print(OK[::-1].index(True))
### BUGGY CODE ###

import numpy as np
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())))
B=np.zeros(N+1)
if K>41:
  A=np.ones(N)*N
else:
  for k in range(K):
    for i in range(N):
      B[max(0,i-int(A[i]))] +=1
      B[min(N,i+int(A[i])+1)] -=1
    A=np.cumsum(B)[:N]
    B=np.zeros(N+1)

for i in A:
  print(int(i))

### FIXED CODE ###

import numpy as np
from numba import jit
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())),dtype=np.int64)
@jit
def loop(a,k):
  if k>41:
    ans=np.ones(N,dtype=np.int64)*N
  else:
    ans=a
    for j in range(k):
      B=np.zeros(N+1,dtype=np.int64)
      for i in range(N):
        B[max(0,i-int(ans[i]))] +=1
        B[min(N,i+int(ans[i])+1)] -=1
      ans=np.cumsum(B)[:N]
  return ans

for i in loop(A,K):
  print(i)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  l = list(input())
  l.sort()
  ar.append("".join(l))


count = 0
for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)



### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())

# スペース区切りの整数の入力
ar = []
for i in range(N):
  l = list(input())
  l.sort()
  ar.append("".join(l).__hash__())

# 数を数える
list = {}
for i in ar:
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
  
count = 0
for i in list.values():
  n = i - 1
  count = count + int(((n * (n + 1)) / 2))

print(count)
### BUGGY CODE ###

N,K,Q=list(map(int,input().split()))
a=[K for _ in range(N)]
b=[0 for _ in range(Q)]
for i in range(Q):
    b[i]=int(input())

for i in range(Q):
    for j in range(N):
        if (b[i]-1)!=j:
            a[j]-=1

for i in range(N):
    if a[i]<=0:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

n, k, q = map(int, input().split())
L = [k for i in range(n)]
a = [int(input()) for i in range(q)]

for i in a:
    L[i-1] = L[i-1] + 1

for i in range(len(L)):
    if q  < L[i]:
        print("Yes")
    else:
        print("No")