Buggy python submission (verdict: Runtime Error):
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(k-a[x],k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
else:
    print(low+1)

Fixed submission:
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(max(0,k-a[x]),k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
elif fff(low):
    print(low+1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=max(h[i],dp[i-u])
        dp=h
    for i in range(k-a[x],k):
        if dp[i]==1:
            return False
            break
    else:
        return True
        

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
else:
    print(low+1)
        

Fixed submission:
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(max(0,k-a[x]),k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
elif fff(low):
    print(low+1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

#必要ないならTrueを返す
def test(i):
    b=itertools.chain(a[:i],a[i+1:])
    dp=[False]*k
    dp[0]=True
    for u in b:
        dp[u:]=np.logical_or(dp[u:],dp[:-u])
    return not any(dp[-a[i]:])
    

low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if test(mid):
        low=mid
    else:
        high=mid
    
if test(high):
    print(high+1)
else:
    print(high)

Fixed submission:
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(max(0,k-a[x]),k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
elif fff(low):
    print(low+1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
def f(x):
    global a
    dp=[0]*k
    dp[0]=1
    for i in range(n):
        if i==x:
            continue
        else:
            h=[0]*k
            b=a[i]
            for i in range(k):
                if dp[i]==1:
                    h[i]=1
                    if i+b<k:
                        h[i+b]=1
        dp=h
    for i in range(k-a[x],k):
        if dp[i]==1:
            return True
    else:
        return False
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high>low+1:
    h=(high+low)//2
    if f(h):
        high=h
    else:
        low=h
if f(low):
    print(max(0,low-1)+1)
else:
    if f(high):
        print(low+1)
    else:
        print(high+1)

Fixed submission:
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(max(0,k-a[x]),k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
elif fff(low):
    print(low+1)
else:
    print(0)