Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
t = 10
for i in range(1, len(s)):
    if s[-1*i-1] == "?":
        c = pre.copy()
        for j in range(1,10):
            te = t*j % 13
            for k in range(13):
                c[k] = c[k] + pre[(13+k-te)%13]
        pre = c.copy()
        for k in range(13):
            pre[k] %= n
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
    t = t*10%13
print(pre[5])

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
for i in range(len(s)):
    t = 10**i % 13
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
print(pre[5])

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
#tem = [i%13 for i in range(130)]
tem = [[i*j%13 for i in range(10)] for j in range(13)]
for i in range(1, len(s)):
    t = 10**i % 13
    if s[-1*i-1] == "?":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
print(pre[5])


Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
s = input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
tem = [i%13 for i in range(130)]
for i in range(1, len(s)):
    t = 10**i % 13
    if s[-1*i-1] == "?":
        te = tem[:t*10:t]
        pre = [np.sum([pre[(13+k-i)%13] for i in te])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
print(pre[5])

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
for i in range(1, len(s)):
    t = 10**i % 13
    if s[-1*i-1] == "?":
        c = pre.copy()
        for j in range(1,10):
            te = t*j % 13
            for k in range(13):
                c[k] = c[k] + pre[(13+k-te)%13]
        pre = c.copy()
        for k in range(13):
            pre[k] %= n
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
print(pre[5])

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
for i in range(1, len(s)):
    t = 10**i % 13
    if s[-1*i-1] == "?":
        c = pre.copy()
        for j in range(1,10):
            te = t*j % 13
            for k in range(13):
                c[k] = (c[k] + pre[(13+k-te)%13]) % n
        pre = c.copy()
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
print(pre[5]%n)

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
s = input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
for i in range(1, len(s)):
    t = 10**i % 13
    if s[-1*i-1] == "?":
        c = np.array(pre)
        for j in range(1,10):
            te = t*j % 13
            c += pre[13-te:] + pre[:13-te]
        c %= n
        pre = c.tolist()
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
print(pre[5]%n)

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
s = input()
if s[-1] == "?":
    pre = [1 for i in range(10)] + [0,0,0]
else:
    pre = [0 for i in range(13)]
    pre[int(s[-1])] = 1
n = 10**9 + 7
for i in range(1, len(s)):
    t = 10**i % 13
    if s[-1*i-1] == "?":
        c = np.array(pre)
        for j in range(1,10):
            te = t*j % 13
            c[te:] += pre[:13-te]
            c[:te] += pre[13-te:]
            c %= n
        pre = c.tolist()
    else:
        te = int(s[-1*i-1])*t % 13
        pre = pre[13-te:]+pre[:13-te]
print(pre[5]%n)

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Runtime Error):
import numpy as np
s=input()
M = 10**9+7
if s[0] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
mask = np.array(amari)

for i in range(1, len(s)):
    if s[i] == "?":
        data = np.dot(pre, mask) % M
    else:
        c = int(s[i])
        data=np.array([0 for i in range(13)], dtype=np.int64)
        for k in range(13):
            data[(10*k+c)%13] += pre[k]
        data %= M
    pre = np.array(data.copy(), dtype=np.int64)
if len(s)==1:
    print(pre[5])
else:
    print(data[5])

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Runtime Error):
import numpy as np
s=input()
M = 10**9+7
if s[0] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
mask = np.array(amari)

for i in range(1, len(s)):
    if s[i] == "?":
        data = np.dot(pre, mask) % M
    else:
        c = int(s[i])
        data=np.array([0 for i in range(13)], dtype=np.int64)
        for k in range(13):
            data[(10*k+c)%13] += pre[k]
        data %= M
    pre = np.array(data.copy(), dtype=np.int64)
if len(s)==1:
    print(pre[5])
else:
    print(data[5])

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Runtime Error):
s=input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
for i in range(1, len(s)):
    data=[0 for i in range(13)]
    tmp = 10**i % 13
    if s[len(s)-1-i] == "?":
        for j in range(10):
            for k in range(13):
                data[(tmp*j+k)%13] += pre[k]
    else:
        tmp = tmp*int(s[len(s)-1-i]) % 13
        for k in range(13):
            data[(tmp+k)%13] += pre[k]
    pre = data.copy()
if len(s)==1:
    print(pre[5]%(10**9+7))
else:
    print(data[5]%(10**9+7))

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy python submission (verdict: Runtime Error):
s=input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
for i in range(1, len(s)):
    data=[0 for i in range(13)]
    tmp = 10**i % 13
    if s[len(s)-1-i] == "?":
        for j in range(10):
            for k in range(13):
                data[(tmp*j+k)%13] += pre[k]
    else:
        tmp = tmp*int(s[len(s)-1-i]) % 13
        for k in range(13):
            data[(tmp+k)%13] += pre[k]
    pre = data.copy()
print(data[5]%(10**9+7))

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])