Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M * 10 + N) % 13 for N in R10] for M in R13]

MOD =[1]+[0]*12


for i,D in enumerate(S):
    NMOD = [0] * 13
    C = -1
    if D == '?':
        for N in R10:
            for M in R13:
                NM = R[M][N]
                NMOD[NM] += MOD[M]
            #end for
        #end for
    else:
        C = int(D)
        for M in R13:
            NM = R[M][C]
            NMOD[NM] += MOD[M]
        #end for
    #end if
    MOD = [NMOD[M]%1000000007 for M in R13]
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S = input()

MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]
NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]

R10 = range(10)
R13 = range(13)

for i,D in enumerate(S):
    C = -1
    if D == '?':
        for N in R10:
            for M in R13:
                NM = (M * 10 + N) % 13
                NMOD[NM] += MOD[M]
            #end for
        #end for
    else:
        C = int(D)
        for M in R13:
            NM = (M * 10 + C) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end if
    for M in R13:
        MOD[M] = NMOD[M]%1000000007
        NMOD[M] = 0
    #end for
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S = input()

MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]
NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]

R10 = range(10)
R13 = range(13)

for i,D in enumerate(S):
    C = -1
    if D != '?':
        C = int(D)
    #end if
    for N in R10:
        if C >= 0 and C != N:
            continue
        for M in R13:
            NM = (M * 10 + N) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end for
    for M in R13:
        MOD[M] = NMOD[M]%1000000007
        NMOD[M] = 0
    #end for
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S = input()
Symbol = list(S)
MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]
NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]

R10 = range(10)
R13 = range(13)

for D in Symbol:
    C = -1
    if D != '?':
        C = int(D)
    #end if
    for N in R10:
        if C >= 0 and C != N:
            continue
        for M in R13:
            NM = (M * 10 + N) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end for
    for M in R13:
        MOD[M] = NMOD[M]%1000000007
        NMOD[M] = 0
    #end for
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S = input()
Symbol = list(S)
MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]

R10 = range(10)
R13 = range(13)


for D in Symbol:
    NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]
    for N in R10:
        if D != '?' and int(D) != N:
            continue
        #end if
        for M in R13:
            NM = (M * 10 + N) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end for
    for M in R13:
        MOD[M] = NMOD[M]%1000000007
    #end for
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S = input()
Symbol = list(S)
MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]

for D in Symbol:
    NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]
    for N in range(10):
        if D != '?' and int(D) != N:
            continue
        #end if
        for M in range(13):
            NM = (M * 10 + N) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end for
    for M in range(13):
        MOD[M] = NMOD[M]%1000000007
    #end for
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S = input()
Symbol = list(S)
MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]

for D in Symbol:
    NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]
    for N in range(10):
        if D != '?' and int(D) != N:
            continue
        #end if
        for M in range(13):
            NM = (M * 10 + N) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end for
    MOD = list(map(lambda x:x%1000000007,NMOD))
#end for

print(MOD[5])


Fixed submission:
# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])