Harryxun/stf_run huggingface dataset:
def f(x):
    if dp[x] != -1:
        return dp[x]

    t = 0
    for v in V[x]:
        t = max(t, f(v)+1)

    dp[x] = t
    return dp[x]

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

dp = [-1]*(n+1)
V = [[] for _ in range(n+1)]

for i in range(m):
    x, y = map(int, input().split())
    V[x].append(y)

t = 0
for i in range(1, n+1):
    t = max(t, f(i))

print(t)


### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

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

dp = [-1 for _ in range(n)]
V = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    V[x-1].append(y-1)

def f(x):
    if dp[x] != -1:
        return dp[x]

    t = 0
    for v in V[x]:
        t = max(t, f(v)+1)

    dp[x] = t
    return dp[x]

t = 0
for i in range(n):
    t = max(t, f(i))

print(t)
s = input()
q = int(input())

from collections import deque

ss = deque(s)
flg = True

for i in range(q):
  t = input().split()
  if t[0] == '1':
    flg = !flg
  else:
    if t[1] == '2':
        ss.append(t[2]) if flg else ss.appendleft(t[2])
    else:
        ss.append(t[2]) if flg != True else ss.appendleft(t[2])



print("".join(ss)) if flg else print("".join(ss[::-1]))



### FIXED CODE ###

s = input()
q = int(input())

from collections import deque

ss = deque(s)
flg = True

for i in range(q):
  t = input().split()
  if t[0] == '1':
    flg = not flg
  else:
    if t[1] == '2':
        ss.append(t[2]) if flg else ss.appendleft(t[2])
    else:
        ss.append(t[2]) if not flg else ss.appendleft(t[2])

ss = list(ss)

print("".join(ss)) if flg else print("".join(ss[::-1]))
n=int(input())

flag=0
for i in range(1,10):
  if n%i==0:
    flag=1

if flag==1
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())


for i in range(1,10):
      for j in range(1,10):
            if i*j==n:
                  print("Yes")
                  exit()
print("No")
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a , b = map(int,input().split())
print(lcm(a, b))

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)
a , b = map(int,input().split())
print(lcm(a, b))
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
c = a[-1]
for i in range(n):
   p = abs(a[-1]-a[i]*2)
      if c > p:
        c = p   
print(c) 

### FIXED CODE ###

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

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

c = a[-1]
for i in range(n):
    c = min(c, abs(a[-1]-a[i]*2))
print(c)
n=int(input())
nums=[int(x) for x in input().split()]

def findMedian(nums):
    size=len(nums)
    mIndex = (size*(size+1)//2) + 1
    gap=0
    mValue=0
    while mIndex>0 and gap<size:
        start=0
        end=start+gap
        while end<size and mIndex>0:
            mIndex-=1
            mValue=nums[(start+end+1)//2]
            start+=1
            end+=1
        gap+=1
    return mValue

print(findMedian(nums))

### FIXED CODE ###

n,i = map(int, input().split())

def findJ(num):
    return n+1-num;

print(findJ(i))
a,b = map(int,input())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")

### FIXED CODE ###

a,b = map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")
n = int(input())
a = [int(i) for i in input().split()]

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

print(x)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
ans = 0
for i in range(N-1):
    if A[i]>A[i+1]:
        ans += A[i]-A[i+1]
        A[i+1] = A[i]
print(ans)
N = input()
ans = 0
for n in N:
  ans += int(n)
if N % ans == 0:
  print("Yes")
else:s
  print("No")

### FIXED CODE ###

N = int(input())
sn = 0
for s in str(N):
    sn += int(s)
if N % sn == 0:
    print("Yes")
else:
    print("No")
w = input()
print(set(w))
"""for i in set(w):
  print(w)
  if w.count(i)%2 != 0:
    print("No")
    exit()
print("Yes")"""
セットで出てくる文字列を絞って数える

### FIXED CODE ###

s=list(input())
s.sort()
if len(s)%2==1 and s[0]==s[-1]:
  print("No")
  
else:
  ans=0
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      ans+=1
    else:
      if ans%2==0:
        print("No")
        break
      else:
        ans=0
        pass
  else:
    print("Yes")
import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


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

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

dist_list = [abs(X - e) for e in x]

print(gcd_list(dist_list))


### FIXED CODE ###

def gcd(x, y):
    while y != 0:
        temp = y
        y = x % y
        x = temp
    return x


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

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)
a, h = map(int , input().split())
count = 0

while(h < 0){
    h -= a;
    count++
}
print(count)

### FIXED CODE ###

h, a = list(map(int , input().split()))
count = 0
while h > 0:
    h = h - a
    count += 1

print(count)
n = input()
ans = 0
for i in range(1,n+1):
  if len(str(i)) %2:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
  if len(str(i)) %2:
    ans += 1
print(ans)
k,x,y = map(int,input().split())

if x%k>>0 :
    if x<= (x/k+1)*k <=y :
        print('OK')
    else:
        print('NO')

elif x%k ==0:

    print('OK')
    

### FIXED CODE ###

k= int(input())
x,y = map(int,input().split())
if 1<=x<=y<=1000 and 1<=k<=1000:
    pass



    if x%k>>0 :
        if x<= (x//k+1)*k <=y :
            print('OK')
        else:
            print('NG')
    else:
        print('OK')

else:
    print('NG')
a,b,c=map(int,input())
print('Yes' if a+b>=c else 'No')

### FIXED CODE ###

a,b,c=map(int,input().split())
print('Yes' if a+b>=c else 'No')
# 27
n,x = list(map(int, input().split()))
aa = list(map(int, input().split()))
aa.sort()
ans = 0
for a in aa:
    if x<a:
        break
    ans+=1
    x-=ai
else:    #for else文 - breakすると入らないことを利用=ループ完遂した場合の終端処理
    if x>0:
        ans-=1
print(num)

### FIXED CODE ###

# 27
n,x = map(int, input().split())
aa = list(map(int, input().split()))
aa.sort()
ans = 0
for a in aa:
    if x<a:
        break
    ans+=1
    x-=a
else:    #for else文 - breakすると入らないことを利用=ループ完遂した場合の終端処理
    if x>0:
        ans-=1
print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    if A[0] > 0:
        printAllPlus(A)
        sys.exit()
    elif A[N - 1] < 0:
        printAllMinus(A)
        sys.exit()

    i = -1
    for k, n in enumerate(A):
        if n >= 0:
            i = k
            break
    plus = A[i:]
    minus = A[:i]
    print(sum(plus) - sum(minus))
    while len(plus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(m, p)
        minus.append(m - p)
    p0 = plus.pop()
    for m in minus:
        print(p0, m)
        p0 -= m


def printAllPlus(nums):
    ans = sum(nums) - 2 * nums[0]
    print(ans)
    tmp = nums[0]
    for n in nums[1:-1]:
        print(tmp, n)
        tmp -= n
    print(nums[-1], tmp)


def printAllMinus(nums):
    nums.reverse()
    ans = -sum(nums) + 2 * nums[0]
    print(ans)
    tmp = nums[0]
    for n in nums[1:]:
        print(tmp, n)
        tmp -= n


if __name__ == "__main__":
    main()


### FIXED CODE ###

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


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    if A[0] >= 0:
        printAllPlus(A)
    elif A[-1] <= 0:
        printAllMinus(A)
    else:
        printMixed(A)


def printMixed(nums):
    i = -1
    for k, n in enumerate(nums):
        if n >= 0:
            i = k
            break
    plus = nums[i:]
    minus = nums[:i]
    print(sum(plus) - sum(minus))
    while len(plus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(m, p)
        minus.append(m - p)
    p0 = plus.pop()
    for m in minus:
        print(p0, m)
        p0 -= m


def printAllPlus(nums):
    ans = sum(nums) - 2 * nums[0]
    print(ans)
    tmp = nums[0]
    for n in nums[1:-1]:
        print(tmp, n)
        tmp -= n
    print(nums[-1], tmp)


def printAllMinus(nums):
    nums.reverse()
    ans = -sum(nums) + 2 * nums[0]
    print(ans)
    tmp = nums[0]
    for n in nums[1:]:
        print(tmp, n)
        tmp -= n


if __name__ == "__main__":
    main()
S = input()
T = input()
flag = False
for i in range(len(S)):
    if flag:
        break
    if S[i] == T[0]:
        tem = i+1
        f = 1
        for t in range(1,len(T)):
            if T[t] == S[tem]:
                tem += 1
                if tem == len(S):
                    tem = 0
            else:
                break
            if t == len(T)-1:
                flag = True
if flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S = input()
T = input()
flag = False

for i in range(len(S)):
    if flag:
        break
    if S[i] == T[0]:
        tem = i+1
        f = 1
        if tem == len(S):
            tem = 0
        for t in range(1,len(T)):
            if T[t] == S[tem]:
                tem += 1
                if tem == len(S):
                    tem = 0
            else:
                break
            if t == len(T)-1:
                flag = True
if flag:
    print('Yes')
else:
    print('No')
N, M = map(int, input().split())
Grap = {j+1:[] for j in range(N)}
memo = {j+1: -1 for j in range(N)} # 各頂点からの最長経路をメモ. -1で初期化.
ans = 0

for _ in range(M):
  x, y = map(int, input().split())
  Grap[x].append(y)


def dp(v):# 頂点nから始まる最長経路を返す.
  if memo[v] != -1: 
    return memo[v]
  else:
    answ = 0
    for to in Grap[v]:
      answ = max(answ, dp(to)+1)
    memo[v] = answ
    return answ

for n in range(1,N+1):
  ans = max(ans, dp(n))
print(ans)




### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
MEMO = [-1 for _ in range(N+1)]

for _ in range(M):
  x, y = map(int, input().split())
  G[x].append(y)


def dp_LP(v):# 頂点nから始まる最長経路を返す.
  if MEMO[v] != -1:
    return MEMO[v]
  else:
    ans = 0
    for i in G[v]:
      ans = max(ans, dp_LP(i)+1)
    MEMO[v] = ans

    return ans



answer = 0
for n in range(1,N+1):
  answer = max(answer, dp_LP(n))
print(answer)
cardArray = list(map(int,input().split()))

if cardArray[0]== carArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  print("Bob")


### FIXED CODE ###

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

if cardArray[0]== cardArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  if cardArray[1] == 1:
    print("Bob")
  else:
    print("Alice")
n,k=map(int,input().split())
d=[0]*n
a=[]
for i in range(k):
    d[i]=int(input())
    a.extend(list(map(int,input().split())))
a=set(a)
print(n-len(a))

### FIXED CODE ###

n,k=map(int,input().split())
d=[0]*k
a=[]
for i in range(k):
    d[i]=int(input())
    a.extend(list(map(int,input().split())))
a=set(a)
print(n-len(a))
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    ans = 0
    if d[n//2] == d[n//2 + 1]:
        print('0')
        exit()
    ans = d[n//2] - d[n//2 - 1]
    print(ans)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


### FIXED CODE ###

import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    ans = d[n//2] - d[n//2 - 1]
    print(ans)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()
a = []
for line in sys.stdin:
    a.append(line)

for n in a:
    inl=n.split()
    num=int(inl[0])+int(inl[1])
    l=list(str(num))
    time=0
    for i in l:
        time+=1
    print time

### FIXED CODE ###

import sys

a = []
for line in sys.stdin:
    a.append(line)

for n in a:
    inl=n.split()
    num=int(inl[0])+int(inl[1])
    l=list(str(num))
    time=0
    for i in l:
        time+=1
    print time
a,b = map(int, input().split())
if (a*b)%2 == 1:
  print("Odd")
  else:print("Even")
    end

### FIXED CODE ###

a,b = map(int, input().split())
if a*b%2 == 1:
  print('Odd')
else:
  print('Even')
N = int(input())
flag = False
h_list = list(map(int , input().split()))
for i in range(N):
  h_list[i] - 1 > h_list[i-1]:
    flag = True
    break
if flag:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

N = int(input())
max = 0
h_list = list(map(int , input().split()))
for i in h_list:
    if max < i:
        max = i
    elif max - 1 > i:
        print("No")
        exit(0)
print("Yes")
N, M = map(int, input().split())

l = []
A = 0
B = 0
ans = 1
if M > 0:
    A, B = map(int, input().split())
    l.append([A, B])
for i in range(M-1):
    A, B = map(int, input().split())
    hit = None
    for tup in l:
        if A in tup or B in tup:
            if hit != None:
                hit = set(hit+tup+[A, B])
            else:
                hit = set(tup+[A, B])
            l.remove(tup)
    if hit != None:
        l.append(hit)
    else:
        l.append((A, B))

if len(l) > 0:
    ans = 1
for item in (l):
    if ans < len(item):
        ans = len(item)
print(ans)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
uf = UnionFind(N)

ans = 0
for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1, B-1)

for i in range(uf.group_count()):
    if ans < uf.size(i):
        ans = uf.size(i)
print(ans)
N = input()

 answer = ""

 for i in range(1 << 3):
     exp = N[0]
     for j in range(3):
         if i >> j & 1:
             exp += "+"
         else:
             exp += "-"
         exp += N[j + 1]
     if eval(exp) == 7:
         answer = exp
         break

 print(answer + "=7")


### FIXED CODE ###

N = input()

answer = ""

for i in range(1 << 3):
    exp = N[0]
    for j in range(3):
        if i >> j & 1:
            exp += "+"
        else:
            exp += "-"
        exp += N[j + 1]
    if eval(exp) == 7:
        answer = exp
        break

print(answer + "=7")
# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def solve(N, W, w, v):
    dp = [[0] * (W + 1) for __ in range(N + 1)]

    for i in range(N - 1, -1, -1):
        for j in range(W + 1):
            if j < w[i]:
                dp[i][j] = dp[i + 1][j]
            else:
                dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i])
    
    ans = dp[0][W]
    return ans


def main():
    N, W = ILI()
    w, v = [], []
    for __ in range(N):
        x, y = ILI()
        w.append(x)
        v.append(y)
    print(solve(N, W, w, v))


if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def solve(N, W, w_v):
    memo = collections.defaultdict(int)
    memo[0] = 0
    for w, v in w_v:
        for w_memo, v_memo in sorted(list(memo.items()), key=lambda x: -x[0]):
            if w + w_memo > W:
                continue
            if memo[w + w_memo] < v_memo + v:
                memo[w + w_memo] = v_memo + v

    return max(memo.values())


def main():
    N, W = ILI()
    w_v = IAI(N)
    print(solve(N, W, w_v))


if __name__ == "__main__":
    main()
n, k, q = map(int, input().split())
a = list(map(int, input().split()))

ans = 10 ** 10
for i, y in enumerate(a):
    li = []
    l = 0
    cnd = []
    for j, x in enumerate(a + [-1]):
        if i == j:
            continue
        if x < y:
            if l - k + 1 >= 0:
                li.sort()
                cnd += li[:l-k+1]
            li = []
            l = 0
        else:
            li.append(x)
            l += 1

    if len(cnd) >= q - 1:
        cnd.sort()
        sub = cnd[q-2] - y
        ans = min(ans, sub)

print(ans)


### FIXED CODE ###

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

if q == 1:
    print(0)
    exit()

ans = 10 ** 10
for i, y in enumerate(a):
    li = []
    l = 0
    cnd = []
    for j, x in enumerate(a + [-1]):
        if i == j:
            continue
        if x < y:
            if l - k + 1 >= 0:
                li.sort()
                cnd += li[:l-k+1]
            li = []
            l = 0
        else:
            li.append(x)
            l += 1

    if len(cnd) >= q - 1:
        cnd.sort()
        sub = cnd[q-2] - y
        ans = min(ans, sub)

print(ans)
a = input()
s = a.length
print(a[0]+int(s)+a[-1])

### FIXED CODE ###

a = input()
print(a[0]+str(len(a)-2)+a[-1])
import numpy as np
N = int(input())
A_list = list(map(int,input().split()))
neg_num = len([x for x in A_list if x<0])
zero_num = len([x for x in A_list if x==0])
abs_list = [abs(x) for x in A_list]

ans = np.sum(abs_list)
if neg_num%2==0 or zero_num>0:
    ans = ans
elif n%2!=0:
    ans = ans - min(abs_list)
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A_list = list(map(int,input().split()))
neg_num = len([x for x in A_list if x<0])
zero_num = len([x for x in A_list if x==0])
abs_list = [abs(x) for x in A_list]

ans = np.sum(abs_list)
if neg_num%2==0 or zero_num>0:
    ans = ans
elif neg_num%2!=0:
    ans = ans - 2*min([x for x in abs_list if x!=0])
print(ans)
s=input().replace('eraser',"").replace('eraser',"").replace('erase',"")replace('dreamer',"").replace('dream',"")
if s:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

s=input().replace('eraser',"").replace('eraser',"").replace('erase',"").replace('dreamer',"").replace('dream',"")
if s:
    print("NO")
else:
    print("YES")
import sys
input = sys.stdin.readline

def solve():
    INF = float('inf')

    def min2(x, y): return x if x <= y else y

    H, N = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]

    items.sort()

    dp = [INF] * (H+1)
    dp[0] = 0
    for vi, wi in items:
        for j in range(H-vi+1):
            dp[j+vi] = min2(dp[j+vi], dp[j]+wi)
        for j in range(H-vi+1, H+1):
            dp[H] = min2(dp[H], dp[j]+wi)
#        print(dp)

    print(dp[H])


solve()


### FIXED CODE ###

INF = 10**12
maxH = 2 * 10**4 + 10

def solve():
    H, N = map(int, input().split())
    ABs = [tuple(map(int, input().split())) for _ in range(N)]

    dp = [INF] * (maxH+1)
    dp[0] = 0
    for A, B in ABs:
        for h in range(maxH-A+1):
            h2 = h + A
            dp2 = dp[h] + B
            if dp2 < dp[h2]:
                dp[h2] = dp2

    print(min(dp[H:]))


solve()
H, W, K = map(int,input().split())
S = list(list(input())for i in range(H))
cake = [[0]*W for i in range(H)]
ans = [[0]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            cake[i][j] = 1
i = 0
a = 0
queue = []
while i < H:
    if max(cake[i]) == 0:
        ans[i] = ans[i-1]
        i += 1
        continue
    first = cake[i][0] != 1
    for j in range(W):
        if j == 0:
            ans[i][j] = ans[i-1][-1] + 1
        if cake[i][j] == 1:
            if first == True:
                first = False
                ans[i][j] = ans[i][j-1]
            else:
                ans[i][j] = ans[i][j-1]+1
        elif j != 0:
            ans[i][j] = ans[i][j-1]
    i += 1
i = 0
while ans[i][0] != 1:
    ans[i] = ans[i+1]
    i += 1
for i in ans:
    print(*i)

### FIXED CODE ###

H, W, K = map(int,input().split())
S = list(list(input())for i in range(H))
cake = [[0]*W for i in range(H)]

queue = []
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            queue.append([i,j])
            cake[i][j] = -1
for i in range(len(queue)):
    h,w = queue[i]
    U,D,L,R = 0,0,0,0
    while L < w:
        if cake[h][w-L-1]:
            break
        L += 1
    while R+w < W-1:
        if cake[h][w+R+1]:
            break
        R += 1
    while U < h:
        flag = False
        for k in range(w-L,w+R+1):
            if cake[h-U-1][k]:
                flag = True
        if flag:
            break
        U += 1
    while D+h < H-1:
        flag = False
        for k in range(w-L,w+R+1):
            if cake[h+D+1][k] != 0:
                flag = True
                break
        if flag:
            break
        D += 1
    for x in range(h-U,h+D+1):
        for y in range(w-L,w+R+1):
            cake[x][y] = i+1

for i in cake:
    print(*i)
from numba import njit


@njit
def solve(n, k, a):
    dp = [[0] * k for _ in range(n + 1)]
    dp[0][0] = 1
    for i, e in enumerate(a, 1):
        for j in range(k):
            dp[i][j] = dp[i-1][j]

        for j in range(k - e):
            if dp[i-1][j]:
                dp[i][j+e] = 1

    dp2 = [[0] * k for _ in range(n + 1)]
    dp2[0][0] = 1
    for i, e in enumerate(a[::-1], 1):
        for j in range(k):
            dp2[i][j] = dp2[i-1][j]

        for j in range(k - e):
            if dp2[i-1][j]:
                dp2[i][j+e] = 1

    ans = 0
    for i, e in enumerate(a, 1):
        li = [j for j in range(k) if dp[i-1][j]]
        li2 = [j for j in range(k) if dp2[n-i][j]]

        j = len(li2) - 1
        mx = 0
        for e2 in li:
            while j > 0 and e2 + li2[j] >= k:
                j -= 1

            if e2 + li2[j] < k:
                mx = max(mx, e2 + li2[j])

        if mx + e < k:
            ans += 1

    print(ans)


if __name__ == "__main__":
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))
    solve(n, k, a)


### FIXED CODE ###

import numpy as np


def check(x):
    dp = np.zeros(k, np.bool)
    dp[0] = True
    for e in a[:x] + a[x+1:]:
        dp[e:] |= dp[:-e]

    return dp[-a[x]:].any()


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

a.sort()

lb = -1
ub = n
while ub - lb > 1:
    m = (lb + ub) // 2
    if check(m):
        ub = m
    else:
        lb = m

print(ub)
A, B = map(int, input())

B = B-A
for i in range(20):
	if B<=0:
    	print(i+1)
    	break()
    B=B-A+1

### FIXED CODE ###

# coding: utf-8

A,B = map(int, input().split())
for i in range(20):
  if (A-1)*i+1 >= B:
    print(i)
    break