Buggy python submission (verdict: Runtime Error):
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    def check(m):
        DP = [False]*(k+1)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            for j in reversed(range(k+1-a[i])):
                DP[a[i]+j] = DP[a[i]+j] or DP[j]
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    DP1 = [[False]*(k+1)]
    DP1[0][0] = True
    DP2 = [[False]*(k+1)]
    DP2[0][0] = True
    b = a[::-1]

    for i in range(n):
        DP1.append(DP1[i][:])
        DP2.append(DP2[i][:])
        for j in range(k+1):
            if DP1[i][j] and a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
            if DP2[i][j] and b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

    for i in range(n+1):
        q = [0]
        for j in range(k+1):
            q.append(q[-1]+int(DP2[i][j]))
        DP2[i] = q

    ans = 0
    for i in range(n):
        use = False
        for j in range(k+1):
            if not DP1[i][j]:
                continue
            left = max(0, k-a[i]-j)
            right = k-j
            if DP2[n-i-1][right] - DP2[n-i-1][left]:
                use = True
                break
        if not use:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    n = len(a)

    DP1 = [[False]*(k+1)]
    DP1[0][0] = True
    DP2 = [[False]*(k+1)]
    DP2[0][0] = True
    b = a[::-1]

    for i in range(n):
        DP1.append(DP1[i][:])
        DP2.append(DP2[i][:])
        for j in range(k+1):
            if DP1[i][j] and a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
            if DP2[i][j] and b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

    for i in range(n+1):
        q = [0]
        for j in range(k+1):
            q.append(q[-1]+int(DP2[i][j]))
        DP2[i] = q

    ans = 0
    for i in range(n):
        use = False
        for j in range(k+1):
            if not DP1[i][j]:
                continue
            left = max(0, k-a[i]-j)
            right = k-j
            if DP2[n-i-1][right] - DP2[n-i-1][left]:
                use = True
                break
        if not use:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

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

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1)]
DP1[0][0] = True
DP2 = [[False]*(k+1)]
DP2[0][0] = True
b = a[::-1]

for i in range(n):
    DP1.append(DP1[i][:])
    DP2.append(DP2[i][:])
    for j in range(k+1):
        if DP1[i][j] and a[i]+j <= k:
            DP1[i+1][a[i]+j] = True
        if DP2[i][j] and b[i]+j <= k:
            DP2[i+1][b[i]+j] = True

for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    DP2[i] = q

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if DP2[n-i-1][right] - DP2[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

a = [i for i in a if i <k]
n = len(a)

DP1 = np.full((n+1, k+1), False)
DP1[0][0] = True
DP2 = np.full((n+1, k+1), False)
DP2[0][0] = True

for i in range(n):
    DP1[i+1] = DP1[i]
    DP1[i+1][a[i]:] = np.logical_or(DP1[i+1][a[i]:], DP1[i][:k-a[i]+1])
    DP2[i+1] = DP2[i]
    DP2[i+1][a[n-1-i]:] = np.logical_or(DP2[i+1][a[n-1-i]:], DP2[i][:k-a[n-1-i]+1])

hoge = []
for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    hoge.append(q)

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if hoge[n-i-1][right] - hoge[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1 = np.full((n+1, k+1), False)
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2 = np.full((n+1, k+1), False)
DP2[0][0] = True

for i in range(n):
    DP1[i+1] = DP1[i]
    DP1[i+1][a[i]:] |= DP1[i][:k-a[i]+1]
    DP2[i+1] = DP2[i]
    DP2[i+1][a[n-1-i]:] |= DP2[i][:k-a[n-1-i]+1]

hoge = []
for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    hoge.append(q)

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if hoge[n-i-1][right] - hoge[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

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

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2[0][0] = True
b = a[::-1]

for i in range(n):
    for j in range(k+1):
        if DP1[i][j]:
            DP1[i+1][j] = True
            if a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
        if DP2[i][j]:
            DP2[i+1][j] = True
            if b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    DP2[i] = q

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if DP2[n-i-1][right] - DP2[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

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

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2[0][0] = True
b = a[::-1]

for i in range(n):
    for j in range(k+1):
        if DP1[i][j]:
            DP1[i+1][j] = True
            if a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
        if DP2[i][j]:
            DP2[i+1][j] = True
            if b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    DP2[i] = q

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if DP2[n-i-1][right] - DP2[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

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

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2[0][0] = True
b = a[::-1]

for i in range(n):
    for j in range(k+1):
        if DP1[i][j]:
            DP1[i+1][j] = True
            if a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
        if DP2[i][j]:
            DP2[i+1][j] = True
            if b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

from itertools import accumulate
for i in range(n+1):
    DP1[i] = [j for j in range(k+1) if DP1[i][j]]
    DP2[i] = [0] + list(accumulate(DP2[i]))

ans = 0
for i in range(n):
    use = False
    for j in DP1[i]:
        left = max(0, k-a[i]-j)
        right = k-j
        if DP2[n-i-1][right] - DP2[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)


Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

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

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2[0][0] = True
b = a[::-1]

for i in range(n):
    for j in range(k+1):
        if DP1[i][j]:
            DP1[i+1][j] = True
            if a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
        if DP2[i][j]:
            DP2[i+1][j] = True
            if b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

for i in range(n+1):
    DP1[i] = [j for j in range(k+1) if DP1[i][j]]
    DP2[i] = [j for j in range(k+1) if DP2[i][j]]

ans = 0
for i in range(n):
    use = False
    for j in DP1[i]:
        left = max(0, k-a[i]-j)
        right = k-j
        l = bisect_left(DP2[n-i-1], left)
        r = bisect_left(DP2[n-i-1], right)
        if r-l:
            use = True
            break
    if not use:
        ans += 1

print(ans)

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

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

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()