Problem p03001 (python)

Fixed submission:
W,H,x,y=(int(x) for x in input().split())
S=W*H/2
t=0
if x==W/2:
    if y==H/2:
        t=1
print(S,t)

Buggy submission (verdict: Runtime Error):
mentu=0
toitu=0
kouho=0
fuurosu=0
temp=0
hutu_shanten=8

def tehai():
    l=[0]*39
    A=list(map(int,input().split()))
    for i in range(14):
        a=A[i]
        l[a]=l[a]+1
    return l

def kokushi_shantensu(l):
    kokushi_totitsu=0
    kokushi_shanten=13
    for i in range(30):
        if (i%10==1 or i%10==9):
            if l[i]==1:
                kokushi_shanten=kokushi_shanten-1
            if l[i]>1:
                kokushi_shanten=kokushi_shanten-1
                kokushi_totitsu=1
    for i in range(31,38):
        if l[i]==1:
            kokushi_shanten=kokushi_shanten-1
        if l[i]>1:
            kokushi_shanten=kokushi_shanten-1
            kokushi_totitsu=1
    kokushi_shanten=kokushi_shanten-kokushi_totitsu
    return kokushi_shanten

def toitsu_shantensu(l):
    toitsu_shanten=6
    syurui=0
    for i in range(1,38):
        if l[i]>=1:
            syurui=syurui+1
        if l[i]>=2:
            toitsu_shanten=toitsu_shanten-1
    if syurui<7:
        toitsu_shanten=toitsu_shanten+7-syurui
    return toitsu_shanten

def hutu_shantensu(l):
    global mentu
    global toitu
    global kouho
    global fuurosu
    global temp
    global hutu_shanten
    for i in range(1,38):
        if 2<=l[i]:
            toitu=toitu+1
            l[i]=l[i]-2
            mentu_cut(1)
            l[i]=l[i]+2
            toitu=toitu-1
    mentu_cut(1)
    return hutu_shanten

def mentu_cut(n):
    global mentu
    global toitu
    global kouho
    global fuurosu
    global temp
    global hutu_shanten
    for i in range(n,39):
        if i==38:
            taatu_cut(1)
            return
        else:
            c=0
            if l[i]>0:
                c=i
                break
    if l[c]>=3:
        mentu+=1
        l[c]-=3
        mentu_cut(c)
        l[c]+=3
        mentu-=1
    if c<30:
        if (l[c+1]>=1 and l[c+2]>=1):
            mentu+=1
            l[c]-=1
            l[c+1]-=1
            l[c+2]-=1
            mentu_cut(c)
            l[c]+=1
            l[c+1]+=1
            l[c+2]+=1
            mentu-=1
    mentu_cut(c+1)

def taatu_cut(k):
    global mentu
    global toitu
    global kouho
    global fuurosu
    global temp
    global hutu_shanten
    for i in range(k,39):
        if i==38:
            temp=8-mentu*2-kouho-toitu
            if temp<hutu_shanten:
                hutu_shanten=temp
            return
        else:
            d=0
            if l[i]>0:
                d=i
                break
    if mentu+kouho<4:
        if l[d]==2:
            kouho+=1
            l[d]-=2
            taatu_cut(d)
            l[d]+=2
            kouho-=1
        if d<30:
            if l[d+1]>0:
                kouho+=1
                l[d]-=1
                l[d+1]-=1
                taatu_cut(d)
                l[d]+=1
                l[d+1]+=1
                kouho-=1
        if d<30:
            if(l[d+2]>0 and d%10<=8):
                kouho+=1
                l[d]-=1
                l[d+2]-=1
                taatu_cut(d)
                l[d]+=1
                l[d+2]+=1
                kouho-=1
    taatu_cut(d+1)

def shantensu(l):
    return min(kokushi_shantensu(l),toitsu_shantensu(l),hutu_shantensu(l))

def maptotehai(l):
    te=[[0,0] for _ in range(14)]
    c=0
    for n in range(1,38):
        if l[n]>0:
            te[c][0]=n
            te[c][1]=l[n]
            c=c+1
    return te

def tehaitomap(te):
    l=[0]*39
    for n in range(14):
        l[te[n][0]]=te[n][1]
    return l

def ukeire(l):
    s=shantensu(l)
    uke=[[0,0] for _ in range(14)]
    te=maptotehai(l)
    for n in range(14):
        if te[n][1]>0:
            te[n][1]-=1
            uke[n][0]=te[n][0]
            ll=tehaitomap(te)
            for i in range(1,38):
                if i%10!=0:
                    if ll[i]<4:
                        ll[i]+=1
                        hutu_shanten=8
                        if shantensu(ll)==s-1:
                            uke[n][1]+=1
                        ll[i]-=1
            te[n][1]+=1
    return(uke)


l=tehai()
ll=tehai()
print(shantensu(l))
print(shantensu(ll))

Buggy submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
A=list(map(int,input().split()))
count=0
for n in range(N):
    if A[n]>=K:
        count=count+1
S= [[0]*N for _ in range(N)]
for i in range (N-1):
    S[i][i+1]=A[i]+A[i+1]
    if S[i][i+1]>=K:
        count=count+1
    for j in range(i+2,N):
        S[i][j]=S[i][j-1]+A[j]
        if S[i][j]>=K:
            count=count+(N-j)
            break
print(count)