Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + N[i] < K:
        s += N[i]
    else:
        count = min(i,count)
print(count)


Fixed submission:
N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = min(i,count)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
a = list(map(int,input().split()))

dp1 = [[False]*K for _ in range(N)]
dp2 = [[False]*K for _ in range(N)]
# dp[x][y] x枚目まで使った時にyに出来るか
# K-ai <= ai < K となる部分集合を探す
dp1[0][0] = True
if a[0] < K:
    dp1[0][a[0]] = True 
for i in range(1,N):
    for j in range(K):
        dp1[i][j] = dp1[i-1][j] or (j-a[i] >= 0 and dp1[i-1][j-a[i]])

dp2[0][0] = True
if a[N-1] < K:
    dp2[0][a[N-1]] = True
for i in range(1,N):
    for j in range(K):
        dp2[i][j] = dp2[i-1][j] or (j-a[N-i-1] >= 0 and dp2[i-1][j-a[N-i-1]])
count = 0
for i in range(N):
    if K-a[i] <= 0:
        count += 1
        continue
    for j in range(K-a[i],K):
        f = False
        if i == 0:
            if dp2[N-2][j]:
                count += 1
                break
            else:
                continue
        elif i == N-1:
            if dp1[N-2][j]:
                count += 1
                break
            else:
                continue
        for k in range(j+1):
            if dp1[i-1][k] and dp2[N-i-2][j-k]:
                count += 1
                f = True
                break
        if f:
            break
print(N-count)


Fixed submission:
N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = min(i,count)
print(count)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))

dp1 = [[False]*K for _ in range(N)]
dp2 = [[False]*K for _ in range(N)]
# dp[x][y] x枚目まで使った時にyに出来るか
# K-ai <= ai < K となる部分集合を探す

dp1[0][a[0]] = True
dp1[0][0] = True
for i in range(1,N):
    for j in range(K):
        dp1[i][j] = dp1[i-1][j] or (j-a[i] >= 0 and dp1[i-1][j-a[i]])

dp2[0][a[N-1]] = True
dp2[0][0] = True
for i in range(1,N):
    for j in range(K):
        dp2[i][j] = dp2[i-1][j] or (j-a[N-i-1] >= 0 and dp2[i-1][j-a[N-i-1]])
count = 0
for i in range(N):
    if K-a[i] <= 0:
        count += 1
        continue
    for j in range(K-a[i],K):
        f = False
        if i == 0:
            if dp2[N-2][j]:
                count += 1
                break
            else:
                continue
        elif i == N-1:
            if dp1[N-2][j]:
                count += 1
                break
            else:
                continue
        for k in range(j+1):
            if dp1[i-1][k] and dp2[N-i-2][j-k]:
                count += 1
                f = True
                break
        if f:
            break
print(N-count)


Fixed submission:
N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = min(i,count)
print(count)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
a_sum = sum(a)
if a_sum < K:
    print(N)
    exit()
if a_sum == K:
    print(0)
    exit()
count = 0
L = [i for i in a if i < K]
L_sum = sum(L)
if L_sum < K:
    print(len(K))
    exit()
if L_sum == K:
    print(0)
    exit()
for i in L:
    if L_sum - i >= K:
        count += 1
print(count)


Fixed submission:
N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = min(i,count)
print(count)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
a_sum = sum(a)
if a_sum < K:
    print(N)
    exit()
if a_sum == K:
    print(0)
    exit()
count = 0
L = [i for i in a if i < K]
L_sum = sum(L)
if L_sum < K:
    print(len(N))
    exit()
if a_sum == K:
    print(0)
    exit()
for i in L:
    if L_sum - i >= K:
        count += 1
print(count)


Fixed submission:
N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = min(i,count)
print(count)