CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
D = list(map(int, input().split()))
M = int(eval(input()))
T = list(map(int, input().split()))

dicD = {}
dicT = {}

for d in D:
    if d not in dicD:
        dicD[d] = 0
    dicD[d] += 1

for t in T:
    if t not in dicT:
        dicT[t] = 0
    dicT[t] += 1

for t in dicT:
    if t not in dicD:
        print("NO")
        break
    elif dicT[t] > dicD[t]:
        print("NO")
        break
else:
    print("YES")

# Optimized solution
N = int(eval(input()))
D = list(map(int, input().split()))
M = int(eval(input()))
T = list(map(int, input().split()))

dicD = {}
dicT = {}

for d in D:
    if d not in dicD:
        dicD[d] = 0
    dicD[d] += 1

for t in T:
    if t not in dicT:
        dicT[t] = 0
    dicT[t] += 1

for t in dicT:
    if (t not in dicD) or (dicT[t] > dicD[t]):
        print("NO")
        break
else:
    print("YES")
# Original solution
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
from functools import reduce
def s(): return eval(input())
def k(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def X(): return list(eval(input()))
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
D = l()
M = k()
T = l()

for i in T:
    if i in D:
        D.remove(i)
    else:
        print("NO")
        sys.exit()

print("YES")


# Optimized solution
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
from functools import reduce
def s(): return eval(input())
def k(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def X(): return list(eval(input()))
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
D = l()
M = k()
T = l()

d = Counter(D)
t = Counter(T)

for i in t:
    if t[i] > d[i]:
        print("NO")
        sys.exit()

print("YES")
# Original solution
import sys
from collections import Counter

N = int(eval(input()))
s1 = list(map(int,input().split()))
M = int(eval(input()))
s2 = list(map(int,input().split()))

c1 = Counter(s1)
c2 = Counter(s2)

for k,v in list(c2.items()):
    if k in c1:
        if v > c1[k]:
            print('NO')
            sys.exit()
    else:
        print('NO')
        sys.exit()
print('YES')


# Optimized solution
from collections import Counter
N = int(eval(input()))
D = list(map(int,input().split()))
M = int(eval(input()))
T = list(map(int,input().split()))

c1 = Counter(D)
c2 = Counter(T)

for k,v in list(c2.items()):
    if c1[k] < v:
        print('NO')
        exit()
print('YES')
# Original solution
n = int(eval(input()))
d = sorted(list(map(int, input().split())))
m = int(eval(input()))
t = sorted(list(map(int, input().split())))

for i in t:
  if i in d:
    d.remove(i)
  else:
    print("NO")
    exit()

print("YES")

# Optimized solution
n = int(eval(input()))

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(eval(input()))

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")
# Original solution
n = int(eval(input()))

x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1

m = int(eval(input()))

y = dict()
for i in input().split():
    y[i] = y.get(i, 0) + 1

for i, j in list(y.items()):
    if x.get(i, 0) < j:
        print("NO")
        exit()
print("YES")

# Optimized solution
n = int(eval(input()))

x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1

m = int(eval(input()))

for i in input().split():
    if i not in x or x[i] == 0:
        print("NO")
        exit()
    else:
        x[i] -= 1
print("YES")
# Original solution
from collections import Counter
n = int(eval(input()))
D = Counter(input().split())
m = int(eval(input()))
for i, j in list(Counter(input().split()).items()):
    if i not in D or D[i] < j:
        print("NO")
        exit()
print("YES")

# Optimized solution
from collections import Counter

eval(input())
d = Counter(input().split())
eval(input())
t = Counter(input().split())

if all(ti in d and d[ti] >= tc for ti, tc in list(t.items())):
    print("YES")
else:
    print("NO")
# Original solution
import collections


N=int(eval(input()))
D=list(map(int,input().split()))
M=int(eval(input()))
T=list(map(int,input().split()))

TS=collections.Counter(T)

for i,k in list(TS.items()):
    if k > D.count(i):
        print('NO')
        exit()

print('YES')


# Optimized solution
import collections

N=int(eval(input()))
D=list(map(int,input().split()))
M=int(eval(input()))
T=list(map(int,input().split()))

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in list(TS.items()):

    if k > DS[i]:
        print('NO')
        exit()

print('YES')
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
m = int(eval(input()))
t = list(map(int, input().split()))
d.sort()
t.sort()

a = 0
cnt = 0
last = t[-1]
for i in range(n):
    for j in range(a, m):
        if d[i] == t[j]:
            cnt += 1
            a = j+1
            break
        elif d[i] > last:
            break
        
if cnt == m:
    print("YES")
else:
    print("NO")

# Optimized solution
n = int(eval(input()))
d = list(map(int, input().split()))
m = int(eval(input()))
t = list(map(int, input().split()))
d.sort()
t.sort()

a = 0
b = 0
cnt = 0
last = t[-1]
for i in range(a, n):
    for j in range(b, m):
        if d[i] == t[j]:
            cnt += 1
            b = j+1
            break
        elif d[i] < t[j]:
            break

if cnt == m:
    print("YES")
else:
    print("NO")
# Original solution
from collections import Counter
N = int(eval(input()))
D = list(map(int, input().split()))
M = int(eval(input()))
T = list(map(int, input().split()))

count_T = Counter(T)

for num, cnt in count_T.most_common():
    if D.count(num) < cnt:
        print("NO")
        break
        
else:
    print("YES")

# Optimized solution
N = int(eval(input()))
D = list(map(int, input().split()))
M = int(eval(input()))
T = list(map(int, input().split()))

D = sorted(D)
T = sorted(T)


i = len(D)-1
j = len(T)-1

flag = True
while(0<=i and 0<=j):
    if D[i] > T[j]:
        i -= 1
    elif D[i] == T[j]:
        i -= 1
        j -= 1
    else:
        flag = False
        break
        
if flag == False or (i<=-1 and j>-1):
    print("NO")
else:
    print("YES")
# Original solution
from collections import Counter

N = int(eval(input()))
D = Counter(list(map(int, input().split())))
M = int(eval(input()))
T = Counter(list(map(int, input().split())))

# print('D, T', D, T)

for key, value in list(T.items()):
    if D.get(key) is None:
        print('NO')
        exit()
    if D.get(key) < value:
        print('NO')
        exit()
print('YES')


# Optimized solution
import sys
from collections import Counter
input = sys.stdin.buffer.readline
N = int(eval(input()))
D = list(map(int, input().split()))
D = Counter(D)
M = int(eval(input()))
T = list(map(int, input().split()))
T = Counter(T)

# print('D, T', D, T)
for key, value in zip(list(T.keys()), list(T.values())):
    if D.get(key, 0) < value:
        print('NO')
        exit()
print('YES')
# Original solution
from collections import Counter
n = int(eval(input()))
D = list(map(int,input().split()))
D = Counter(D)
m = int(eval(input()))
T = list(map(int,input().split()))
T = Counter(T)
#print(D)
#print(T)
for key in T:
    if D[key] < T[key]:
        print('NO')
        exit()

print('YES')

# Optimized solution
n = int(eval(input()))
d = list(map(int,input().split()))
d.sort()
m = int(eval(input()))
t = list(map(int,input().split()))
t.sort()
now = 0
for x in t:
    if now == n:
        print("NO")
        exit()
    while d[now] != x:
        now += 1
        if now == n:
            print("NO")
            exit()
    now += 1

print("YES")
# Original solution
n = int(eval(input()))
d = list(map(int,input().split()))
cnt = {}
for i in d:
  if i not in cnt:
    cnt[i] = d.count(i)
m = int(eval(input()))
t = list(map(int,input().split()))
flag = True
for i in t:
  if i in cnt:
    if cnt[i]>0:
      cnt[i] -= 1
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")

# Optimized solution
n = int(eval(input()))
d = list(map(int,input().split()))
cnt = {}
for i in d:
  if i not in cnt:
    cnt[i] = 1
  else:
    cnt[i] += 1
m = int(eval(input()))
t = list(map(int,input().split()))
flag = True
for i in t:
  if i in cnt:
    if cnt[i]>0:
      cnt[i] -= 1
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")
# Original solution
from collections import Counter

N = int(eval(input()))
D = list(map(int, input().split()))
M = int(eval(input()))
T = list(map(int, input().split()))

d = Counter(D)
t = Counter(T)
for key, value in list(t.items()):
    if d.get(key, 0) < value:
        print('NO')
        exit()
else:
    print('YES')

# Optimized solution
from collections import Counter


def main():
    N = int(eval(input()))
    D = input().split()
    M = int(eval(input()))
    T = input().split()

    d = Counter(D)
    t = Counter(T)
    for key, value in list(t.items()):
        if d.get(key, 0) < value:
            print('NO')
            exit()
    else:
        print('YES')


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter

N=int(eval(input()))
D=Counter((list(map(int,input().split()))))
M=int(eval(input()))
T=Counter((list(map(int,input().split()))))

for i in range(len(D)):
    x=sorted([i for i in list(D.items())])

for j in range(len(T)):
    y=sorted([j for j in list(T.items())])

if N<M or len(x)<len(y):
    print("NO")
else:
    cnt=0
    for i in range(len(x)):
        for j in range(len(y)):
            if x[i][0]==y[j][0] and x[i][1]>=y[j][1]:
                cnt+=1
    print(("YES" if cnt==len(y) else "NO"))

# Optimized solution
from collections import Counter

N=int(eval(input()))
D=Counter((list(map(int,input().split()))))
M=int(eval(input()))
T=Counter((list(map(int,input().split()))))

for difficult,count in list(T.items()):
    if difficult in D and D[difficult]>=count:
        pass
    else:
        print("NO")
        exit()
print("YES")
# Original solution
from collections import Counter

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

Count = Counter(D)

for t in T:
    if not Count[t]:
        print("NO")
        exit()
    else:
        Count[t] -= 1
print("YES")

# Optimized solution
from collections import Counter

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

C = Counter(D)

for t in T:
    if C[t]:
        C[t] -= 1
    else:
        print("NO")
        exit()
print("YES")
# Original solution
import bisect
N = int(eval(input()))
D = list(map(int, input().split()))
D.sort()
M = int(eval(input()))
T = list(map(int, input().split()))
for i in range(M):
    t = T[i]
    for j in range(N):
        idx = min(bisect.bisect_left(D, t), len(D) - 1)
        d = D[idx]
        if t == d:
            D.pop(idx)
            break
    else:
        print('NO')
        exit()
print('YES')


# Optimized solution
import bisect
N = int(eval(input()))
D = list(map(int, input().split()))
D.sort()
M = int(eval(input()))
T = list(map(int, input().split()))
for i in range(M):
    t = T[i]
    idx = min(bisect.bisect_left(D, t), len(D) - 1)
    d = D[idx]
    if t == d:
        D.pop(idx)
    else:
        print('NO')
        exit()
print('YES')
# Original solution
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
li = []
for key, value in groupby(t):
    li.append((key,len(list(value))))
for i in li:
    if d.count(i[0]) < i[1]:
        print("NO")
        exit()
print("YES")

# Optimized solution
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
now = 0
for i in d:
    if i == t[now]:
        now += 1
    if now == m:
        print("YES")
        exit()
else:
    print("NO")
# Original solution
N=int(eval(input()))
D=[int(i) for i in input().split()]
M=int(eval(input()))
T=[int(i) for i in input().split()]
x=0
for i in range(M):
    if T[i] in D:
        D.remove(T[i])
    else:
        x+=1
if x==0:
    print("YES")
else:
    print("NO")

# Optimized solution
n = int(eval(input()))
*D, = list(map(int, input().split()))
m = int(eval(input()))
*T, = list(map(int, input().split()))
D.sort()
T.sort()
j = 0
for i in range(n):
    if j == m:
        break
    if D[i] == T[j]:
        j += 1
if j == m:
    print('YES')
else:
    print('NO')
# Original solution
import sys
input = sys.stdin.readline

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
dp1 = [[0]*K for _ in range(N+1)]
dp1[0][0] = 1

for i in range(N):
    for j in range(K):
        dp1[i+1][j] += dp1[i][j]
        
        if j+a[i]<K:
            dp1[i+1][j+a[i]] += dp1[i][j]

dp2 = [[0]*K for _ in range(N+1)]
dp2[0][0] = 1

for i in range(N):
    for j in range(K):
        dp2[i+1][j] += dp2[i][j]
        
        if j+a[N-i-1]<K:
            dp2[i+1][j+a[N-i-1]] += dp2[i][j]

for i in range(N):
    for j in range(1, K):
        dp2[i][j] += dp2[i][j-1]

ans = N

for i in range(N):
    for j in range(K):
        if dp1[i][j]>0:
            l = max(0, K-a[i]-j)
            h = K-1-j
            
            if l==0:
                if dp2[N-i-1][h]>0:
                    ans -= 1
                    break
            else:
                if dp2[N-i-1][h]-dp2[N-i-1][l-1]>0:
                    ans -= 1
                    break

print(ans)

# Optimized solution
import sys
input = sys.stdin.readline

def judge(x):
    dp = [[False]*K for _ in range(N)]
    dp[0][0] = True
    
    for i in range(N-1):
        for j in range(K):
            dp[i+1][j] |= dp[i][j]
            
            if j+a[i+(1 if i>=x else 0)]<K:
                dp[i+1][j+a[i+(1 if i>=x else 0)]] |= dp[i][j]
    
    for i in range(max(K-a[x], 0), K):
        if dp[N-1][i]:
            return False
    
    return True
    
def binary_search():
    l, r = 0, N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            l = m+1
        else:
            r = m-1
    
    return r

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
print((binary_search()+1))
# Original solution
n, k = [int(item) for item in input().split()]
a = sorted([int(item) for item in input().split()], reverse=True)
max_k = min(sum(a), 5000)

def check_needed(index):
    memo = [[0] * (max_k + 1) for _ in range(n+1)]
    memo[0][0] = 1
    for i in range(n):
        for j in range(max_k + 1):
            if memo[i][j] == 1: 
                memo[i+1][j] = 1 
                if i != index and j+a[i] <= max_k:
                    memo[i+1][j+a[i]] = 1 
    return (1 in memo[n][max(k-a[index], 0):k])

l = -1
r = n
while r-l > 1:
    mid = (l+r) // 2
    if not check_needed(mid):
        r = mid
    else:
        l = mid
if sum(a) < k:
    print(n)
else:
    print((n - r))

# Optimized solution
n, k = [int(item) for item in input().split()]
a = sorted([int(item) for item in input().split()], reverse=True)

count = 0
asum = 0
for item in a:
    if asum + item < k:
        asum += item
        count += 1
    else:
        count = 0

print(count)
# Original solution
from itertools import accumulate
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

# K以上の数はすべて必要なのでA未満の数だけを考える
A = sorted([a for a in A if a < K], reverse=True)
N = len(A)

# dp1[i][k] := 1 ~ iまでのカードを使って数kが作れるか
dp1 = [[0] * (K + 1) for i in range(N + 1)]
dp1[0][0] = 1
# dp2[i][k] := N ~ iまでのカードを使って数kが作れるか
dp2 = [[0] * (K + 1) for i in range(N + 1)]
dp2[0][0] = 1

# dpテーブルを計算
for i in range(1, N + 1):
    for k in range(K + 1):
        dp1[i][k] = max(dp1[i][k], dp1[i - 1][k])
        if A[i - 1] <= k:
            dp1[i][k] = max(dp1[i][k], dp1[i - 1][k - A[i - 1]])

        dp2[i][k] = max(dp2[i][k], dp2[i - 1][k])
        if A[N - i] <= k:
            dp2[i][k] = max(dp2[i][k], dp2[i - 1][k - A[N - i]])

# 累積和を取っておく
for i in range(N + 1):
    dp2[i] = list(accumulate(dp2[i]))

# ansを計算
need = 0
for i in range(1, N + 1):
    for k in range(K + 1):
        # 1 ~ i番目まででkが作れない
        if not dp1[i - 1][k]:
            continue

        # 1 ~ i番目までだけで必要な条件が作れる
        if K - A[i - 1] <= k < K:
            need += 1
            break

        # 範囲外参照
        if K - A[i - 1] - k - 1 < 0:
            continue

        if dp2[N - i][K - k] - dp2[N - i][K - A[i - 1] - k - 1] > 0:
            need += 1
            break

print((N - need))


# Optimized solution
def main():
    from itertools import accumulate
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    # K以上の数はすべて必要なのでA未満の数だけを考える
    A = sorted([a for a in A if a < K], reverse=True)
    N = len(A)

    # dp1[i][k] := 1 ~ iまでのカードを使って数kが作れるか
    dp1 = [[0] * (K + 1) for i in range(N + 1)]
    dp1[0][0] = 1
    # dp2[i][k] := N ~ iまでのカードを使って数kが作れるか
    dp2 = [[0] * (K + 1) for i in range(N + 1)]
    dp2[0][0] = 1

    # dpテーブルを計算
    for i in range(1, N + 1):
        for k in range(K + 1):
            dp1[i][k] = max(dp1[i][k], dp1[i - 1][k])
            if A[i - 1] <= k:
                dp1[i][k] = max(dp1[i][k], dp1[i - 1][k - A[i - 1]])

            dp2[i][k] = max(dp2[i][k], dp2[i - 1][k])
            if A[N - i] <= k:
                dp2[i][k] = max(dp2[i][k], dp2[i - 1][k - A[N - i]])

    # 累積和を取っておく
    for i in range(N + 1):
        dp2[i] = list(accumulate(dp2[i]))

    # ansを計算
    need = 0
    for i in range(1, N + 1):
        for k in range(K + 1):
            # 1 ~ i番目まででkが作れない
            if not dp1[i - 1][k]:
                continue

            # 1 ~ i番目までだけで必要な条件が作れる
            if K - A[i - 1] <= k < K:
                need += 1
                break

            # 範囲外参照
            if K - A[i - 1] - k - 1 < 0:
                continue

            if dp2[N - i][K - k] - dp2[N - i][K - A[i - 1] - k - 1] > 0:
                need += 1
                break

    print((N - need))

main()
# Original solution
import sys

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()
A.sort()


def f(n):  # Anが必要か否か
    B = [0] + [A[i] for i in range(N) if i != n]
    dp = [[0]*K for _ in range(2)]  # dp[i][j] = B1~Biを用いてjを作れるか(メモリ節約のため工夫してる)
    dp[0][0] = 1
    for i in range(1,N):
        b = B[i]
        if i % 2 == 1:
            for j in range(K):
                dp[1][j] = dp[0][j]
                if dp[1][j] == 0 and j >= b:
                    dp[1][j] = dp[0][j-b]
        else:
            for j in range(K):
                dp[0][j] = dp[1][j]
                if dp[0][j] == 0 and j >= b:
                    dp[0][j] = dp[1][j-b]
    if sum(dp[(N-1) % 2 == 1][j] for j in range(max(K-A[n],0),K)) != 0:
        return True
    else:
        return False


left = -1  # 不必要
right = N  # 必要
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(right)


# Optimized solution
import sys

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()
A.sort()


def f(n):  # Anが必要か否か
    B = [0] + [A[i] for i in range(N) if i != n]
    dp = [[0]*K for _ in range(2)]  # dp[i][j] = B1~Biを用いてjを作れるか(メモリ節約のため工夫してる)
    dp[0][0] = 1
    for i in range(1,N):
        b = B[i]
        for j in range(K):
            if j >= b:
                dp[i%2][j] = dp[1-i%2][j] | dp[1-i%2][j-b]
            else:
                dp[i%2][j] = dp[1-i%2][j]
    if sum(dp[(N-1) % 2][j] for j in range(max(K-A[n],0),K)) != 0:
        return True
    else:
        return False


left = -1  # 不必要
right = N  # 必要
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(right)
# Original solution
import sys

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()
A.sort()


def f(n):  # Anが必要か否か
    B = [0] + [A[i] for i in range(N) if i != n]
    dp = [[0]*K for _ in range(2)]  # dp[i][j] = B1~Biを用いてjを作れるか(メモリ節約のため工夫してる)
    dp[0][0] = 1
    for i in range(1,N):
        b = B[i]
        for j in range(K):
            if j >= b:
                dp[i%2][j] = dp[1-i%2][j] | dp[1-i%2][j-b]
            else:
                dp[i%2][j] = dp[1-i%2][j]
    if sum(dp[(N-1) % 2][j] for j in range(max(K-A[n],0),K)) != 0:
        return True
    else:
        return False


left = -1  # 不必要
right = N  # 必要
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(right)


# Optimized solution
import sys

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()
A.sort()


def f(n):  # Anが必要か否か
    B = [0] + [A[i] for i in range(N) if i != n]
    dp = [0]*K  # dp[i][j] = B1~Biを用いてjを作れるか(メモリ節約のため工夫してる)
    dp[0] = 1
    for i in range(1,N):
        b = B[i]
        for j in range(K-1,-1,-1):
            if j >= b:
                dp[j] |= dp[j-b]
            else:
                dp[j] = dp[j]
    if sum(dp[j] for j in range(max(K-A[n],0),K)) != 0:
        return True
    else:
        return False


left = -1  # 不必要
right = N  # 必要
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(right)
# Original solution
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

def check(x):
  dp = [0] * (K + 1)
  dp[0] = 1
  for i in range(N):
    for j in range(K - 1, -1, -1):
      if i == x: continue
      if dp[j]:
        dp[min(K, j + a[i])] = dp[j]
  for j in range(max(0, K - a[x]), K):
    if dp[j]: return True
  return False
#for i in range(N): print(check(i))

if check(0):
  print((0))
  exit(0)
ok = N
ng = 0
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)


# Optimized solution
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse = True)
t = 0
res = -1
for i in range(N):
  if t + a[i] < K: t += a[i]
  else: res = i
print((N - res - 1))