Problem p02960 (python)

Fixed submission:
#数字はnumberに格納
number=input()
length=len(number)


#調整のための数字
sizemin=1000000007

#まずはからのDPリストを用意
dp=[[0 for i in range(13)] for j in range(length)]

#1桁目の情報を入力
if number[-1]=="?":
    for i in range(10):
        dp[0][i]=1
else:
    dp[0][int(number[-1])]=1

#１０〜９０の、13modリストを作る
modlist=[(i*10)%13 for i in range(10)]


        
#二桁目からの情報を更新していく。
for n in range(length-1):
    #n桁目の情報があれば、次のようにn+1行目を更新。

    #n+1のくらいの数をchecknumとする
    checknum=number[-1*(n+1)-1]
#     print(checknum)

    #n+1の位が整数であれば
    if checknum!="?":
        
        #n[m]の値をn+1[m+(その整数)]にすればいい
        for m in range(13):
            dp[n+1][(m+modlist[int(checknum)])%13]=dp[n][m]
#         print(dp)
        
        
        
        
        
    #n+1のくらいが？の時
    else:
    #？が０〜９までの可能性を全て試す  
    
        for checknum in range(10):
            for m in range(13):
                dp[n+1][(m+modlist[int(checknum)])%13]=(dp[n+1][(m+modlist[int(checknum)])%13]+dp[n][m])%sizemin
#             print(dp)

    #modlistを更新
    modlist=[(j*10)%13 for j in modlist]


print(dp[-1][5])

Buggy submission (verdict: Runtime Error):
import re
number=input()
number=number.replace("?",".",100000)
length=len(number)

replica=number
while True:
    if replica[0]==".":
        replica=replica[1:]
    else:
        break
replen=len(replica)

minnum=10*(replen-1)
i=minnum//13
sumnum=0
while True:
    checknum=str(13*i+5)
    if len(checknum)<replen:
        i+=1
        continue
    g=length-replen 
    if checknum[-1*replen]!=number[-1*replen]:
        i+=1
        continue
    while len(checknum)<length:
        checknum="0"+checknum

    if len(checknum)>length:
        break
        
    m=re.match(number,checknum)
    if m:
        sumnum+=1
        sumnum=sumnum%1000000007
    i+=1
    
print(sumnum)

Buggy submission (verdict: Runtime Error):
import re
number=input()
number=number.replace("?",".",100000)
length=len(number)

replica=number
while True:
    if replica[0]==".":
        replica=replica[1:]
    else:
        break
replen=len(replica)

print()


i=0
sumnum=0
while True:
    checknum=str(13*i+5)
    if len(checknum)<replen:
        i+=1
        continue
    g=length-replen 
    if checknum[-1*replen]!=number[-1*replen]:
        i+=1
        continue
    while len(checknum)<length:
        checknum="0"+checknum

    if len(checknum)>length:
        break
        
    m=re.match(number,checknum)
    if m:
        sumnum+=1
        sumnum=sumnum%1000000007
        print(checknum)
    i+=1
    
print(sumnum)

Buggy submission (verdict: Runtime Error):
import re
number=input()
number=number.replace("?",".",100000)
length=len(number)

replica=number
while True:
    if replica[0]==".":
        replica=replica[1:]
    else:
        break
replen=len(replica)

i=0
sumnum=0
while True:
    checknum=str(13*i+5)
    if len(checknum)<replen:
        i+=1
        continue
    checklength=len(checknum)
    if checklength<length:
        while len(checknum)!=length:
            checknum="0"+checknum

    if len(checknum)==length:
        m=re.match(number,checknum)
        if m:
            sumnum+=1
            sumnum=sumnum%1000000007
    
            
    if len(checknum)>length:
        break
    i+=1
    
print(sumnum)