Buggy python submission (verdict: Time Limit Exceeded):
s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(2)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1

i=1
for c in s[1:]:
  c = -1 if c=='?' else int(c)

  D=dp[i%2]
  S=dp[(i-1)%2]
  if c==-1:
    for k in range(13):
      for j in range(k*10,k*10+10):
        D[j%13]+=S[k]
  else:
    for k in range(13):
      D[(k*10+c)%13]+=S[k]

  for j in range(13):
    S[j]=0
    D[j]%=MOD
  i += 1

print(dp[(i-1)%2][5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(2)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1

i=1
for c in s[1:]:
  c = -1 if c=='?' else int(c)

  D=dp[i%2]
  S=dp[(i-1)%2]
  if c==-1:
    for j in range(10):
      for k in range(13):
        D[(k*10+j)%13]+=S[k]
  else:
    for k in range(13):
      D[(k*10+c)%13]+=S[k]

  for j in range(13):
    S[j]=0
    D[j]%=MOD
  i += 1

print(dp[(i-1)%2][5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(2)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1

i=1
for c in s[1:]:
  c = -1 if c=='?' else int(c)
  for k in range(13):
    dp[i%2][k]=0

  if c==-1:
    for j in range(10):
      for k in range(13):
        dp[i%2][(k*10+j)%13]+=dp[(i-1)%2][k]
  else:
    for k in range(13):
      dp[i%2][(k*10+c)%13]+=dp[(i-1)%2][k]

  for j in range(13):
    dp[i%2][j]%=MOD
  i += 1

print(dp[(i-1)%2][5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

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

s=input()
l=len(s)
a=10**9+7

if s[l-1] == '?':
  n=np.array([1,1,1,1,1,1,1,1,1,1,0,0,0], dtype='uint64')
else:
  n=np.array([0,0,0,0,0,0,0,0,0,0,0,0,0], dtype='uint64')
  n[int(s[l-1])]=1
d=np.array([0,0,0,0,0,0,0,0,0,0,0,0,0], dtype='uint64')

m=1
for i in range(1,len(s)):
  m=(m*10)%13
  if s[l-1-i] == '?':
    for j in range(13):
      for k in range(10):
        d[(m*k+j)%13] += n[j]
  else:
    for j in range(13):
      d[(m*int(s[l-1-i])+j)%13] += n[j]

  for j in range(13):
    n[j]=d[j]%a
    d[j]=0

print(n[5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
a=10**9+7

if s[l-1]=='?':
  n=[1,1,1,1,1,1,1,1,1,1,0,0,0]
else:
  n=[0,0,0,0,0,0,0,0,0,0,0,0,0]
  n[int(s[l-1])]=1
d=[0,0,0,0,0,0,0,0,0,0,0,0,0]

m=1
for i in range(1,len(s)):
  m=(m*10)%13
  if s[l-1-i] == '?':
    for j in range(13):
      for k in range(10):
        d[(m*k+j)%13] += n[j]
  else:
    for j in range(13):
      d[(m*int(s[l-1-i])+j)%13] += n[j]

  for j in range(13):
    n[j]=d[j]%a
    d[j]=0

print(n[5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(2)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1

for i in range(1,len(s)):
  c = -1 if s[i]=='?' else int(s[i])
  for k in range(13):
    dp[i%2][k]=0

  if c==-1:
    for j in range(10):
      for k in range(13):
        dp[i%2][(k*10+j)%13]+=dp[(i-1)%2][k]
  else:
    for k in range(13):
      dp[i%2][(k*10+c)%13]+=dp[(i-1)%2][k]

  for j in range(13):
    dp[i%2][j]%=MOD
    
print(dp[(len(s)-1)%2][5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(2)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1

for i in range(1,len(s)):
  c = -1 if s[i]=='?' else int(s[i])
  for k in range(13):
    dp[i%2][k]=0
  for j in range(10):
    if c!=-1 and c!=j:
      continue
    for k in range(13):
      dp[i%2][(k*10+j)%13]+=dp[(i-1)%2][k]
  for j in range(13):
    dp[i%2][j]%=MOD

print(dp[(len(s)-1)%2][5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))

Buggy python submission (verdict: Runtime Error):
s=input()
MOD=10**9+7
dp=[[0 for i in range(13)] for j in range(len(s)+1)]

if s[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[1])]=1

for i in range(1,len(s)):
  c = -1 if s[i]=='?' else int(s[i])
  for j in range(10):
    if c!=-1 and c!=j:
      continue
    for k in range(13):
      dp[i][(k*10+j)%13]+=dp[i-1][k]
  for j in range(13):
    dp[i][j]%=MOD

print(dp[len(s)-1][5])


Fixed submission:
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))