Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))
z = [abs(T-h*0.006-a) for h in H]
print( z.index(min(z)) +1 )

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))
z = [abs(a - (t - h*0.006)) for h in H]
print( z.index(min(z)) +1 )

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = map(int, input().split())
z = [abs(a - (t - h*0.006)) for h in H]
print( z.index(min(z)) +1 )

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = map(int, input().split())
z = [abs(a - t - h*0.006) for h in H]
print( z.index(min(z)) +1 )

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)
Buggy python submission (verdict: Runtime Error):
N,T = map(int,input().split())
t = 1001
for i in range(N) :
    c,t = map( int, input().split() )
    if t<=T:
        m = min(m,c)
    print('TLF' if m==1001 else m)

Fixed submission:
N,T = map(int,input().split())
m = 1001
for i in range(N) :
    c,t = map( int, input().split() )
    if t<=T:
        m = min(m,c)
print('TLE' if m==1001 else m)
Buggy python submission (verdict: Runtime Error):
X = int(input())
c=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)

Fixed submission:
X = int(input())
c=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=X:c=max(c,b**p)
        else:break
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
l=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
print(max(maxbox,0))

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
l=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
maxbox.append(0)
print(max(maxbox))

Buggy python submission (verdict: Runtime Error):
例
n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
l=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
maxbox.append(0)
print(max(maxbox))
Buggy python submission (verdict: Runtime Error):
n,k,x,y = [int(input()) for i in range(4)]
print(n*x if k>=n else k*x + (n-k)*y)

Fixed submission:
x,a,b = [int(input()) for i in range(3)]
print( (x-a)%b )
Buggy python submission (verdict: Runtime Error):
s = input()
print(s)s=input()
out = s[0] + str(len(s)-2) + s[-1]
print(out)

Fixed submission:
list = input()
print(list[0]+str(len(list)-2)+list[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
pwr = 1
for i in range(1, N+1):
    pwr = pwr * i
print(pwr % (10**9+7))

Fixed submission:
import math
N = int(input())
print(math.factorial(N) % (10**9+7) )
Buggy python submission (verdict: Runtime Error):
n,k,x,y = map( int,input().split() )
print(n*x if k>=n else k*x + (n-k)*y)

Fixed submission:
n,k,x,y = [int(input()) for i in range(4)]
print(n*x if k>=n else k*x + (n-k)*y)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
econ = []
for i in range(n):
    econ.append(input())
for i in range(n): 
    a = []
    for j in econ[i]:
        a += j
    econ[i] = sorted(a)
        
tei = 0      
for i in range(n):
    for j in range(i+1,n):
        if econ[i] == econ[j]:
            tei += 1
print(tei)

Fixed submission:
n = int(input())

sample = {}
sam = 0

for i in range(n):
    s = sorted(input())
    s = ''.join(s)
    if s in sample:
        sample[s] += 1
        sam += sample[s] -1
    else:
        sample[s] = 1
print(sam)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)

Fixed submission:
n = int(input())
print(3*n*n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
b = max(a)
c = a.index(b)
a.pop(c)
e = a
d = max(e)
a.insert(c, b)
for i in range(0, n):
    if a[i] == max(a):
        print(d)
    else:
        print(b)

Fixed submission:
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
for i in range(0, n):
    if not a[i] == max(a):
        print(max(a))
    else:
        b = a.pop(i)
        print(max(a))
        a.insert(i, b)
        

Fixed submission:
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
for i in range(0, n):
    b = a.pop(i)
    print(max(a))
    a.insert(i,b)
    

Fixed submission:
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
kore = []
for i in range(0, n):
    b = a.pop(i)
    kore.append(max(a))
    a.insert(i, b)
for i in kore:
    print(i)

Fixed submission:
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
kore = []
for i in range(0, n):
    b = a.pop(i)
    kore.append(max(a))
    a.insert(i, b)
for i in kore:
    print(i)

Fixed submission:
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)
Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().rstrip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print(Yes)
else:
  print(No)

Fixed submission:
n = int(input())
b = list(map(int, input().rstrip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().rstirip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print(Yes)
else:
  print(No)

Fixed submission:
n = int(input())
b = list(map(int, input().rstrip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int(input().rstrip())))
if a<=8 and b<= 8:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a, b = list(map(int, input().rstrip().split()))
if a<= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
a, b = list(map(int(input().rstrip())))
if a<8 and b< 8:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a, b = list(map(int, input().rstrip().split()))
if a<= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
a, b = int(input())
if a<8 and b< 8:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a, b = list(map(int, input().rstrip().split()))
if a<= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a + b> c:
    print(Yes)
else:
    print(No)

Fixed submission:
a, b, c = map(int, input().split())
if a + b>= c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
if max(scores) >= 0:
    print(max(scores))
else:
    print(0)n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
print(max(scores))

Fixed submission:
n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
if max(scores) >= 0:
    print(max(scores))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print("even")
else:
  print("odd")

Fixed submission:
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if (a*b)%2 = 0:
  print("Even")
else:
  print("Odds")

Fixed submission:
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
int main() {
    int a, b;
    cin >> a >> b;
    int c = a * b;
    if (c % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

Fixed submission:
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d ** 2 = c
if isinstance(d, int):
  print("Yes")
else:
  print("No")

Fixed submission:
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d = c**(1/2)

if d.is_integer():
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
retu = ""
retu += str(a) + str(b)
c**2 = int(retu)
def koro(n):
  if isinstance(n, int):
  	return True
  else:
    return False
koro(c)

Fixed submission:
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d = c**(1/2)

if d.is_integer():
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
retu = ""
retu += str(a) + str(b)
c**2 = int(retu)
if isinstance(c, int):
  print("Yes")
else:
  print("No")

Fixed submission:
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d = c**(1/2)

if d.is_integer():
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
retu = ""
retu += str(a) + str(b)
if int(retu) == int(c)**2:
  print("Yes")
else:
  print("No")

Fixed submission:
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d = c**(1/2)

if d.is_integer():
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = input()
a = int(a)

b = a[0]+a[1]+a[2]
print(b)

Fixed submission:
a = input()
b = int(a[0])+int(a[1])+int(a[2])
print(b)
Buggy python submission (verdict: Runtime Error):
d, e = map(int, f.readline().strip().split())
g = list(map(int, f.readline().strip().split()))
#print(d, e)
#print(g)
total = 0
for i in g:
    if i >= e:
        total += 1
print(total)

Fixed submission:
N = int(input())
odd = 0
for i in range(1, N + 1):
    if i % 2 != 0:
        odd += 1
print(odd / N)
Buggy python submission (verdict: Runtime Error):
d, e = map(int, input().strip().split())
g = list(map(int, input().strip().split()))
print(d, e)
#print(g)
#total = 0
for i in g:
    if i >= e:
        total += 1
print(total)

Fixed submission:
d, e = map(int, input().strip().split())
g = list(map(int, input().strip().split()))
#print(d, e)
#print(g)
total = 0
for i in g:
    if i >= e:
        total += 1
print(total)
Buggy python submission (verdict: Runtime Error):
    def find(i, ss, step):
        for j in range(step, len(ss)):
            #print(i, j, ss[j])
            if i == ss[j]:
                a = j
                return a, step
        return -1
     
     
    s = input().strip()
    #print(s)
    t = input().strip()
    #print(t)
    ss = s * 100
    #print(ss)
    step = 0
    for i in t:
        a = find(i, ss, step)
        if a == -1:
            print(-1)
            break
        else:
            #print(a)
            step = a[0] + 1
            #print(step)
    if a != -1:
        print(step)

Fixed submission:
a = int(input())
s = input()
if a < 3200:
	print('red')
else:
	print(s)
Buggy python submission (verdict: Time Limit Exceeded):
def remove01Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '01':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

def remove10Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '10':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

N = input().strip()
#print(N)
length = len(N)
#print(length)
flag = []
flag.append(0)
while flag[0] == 0:
    N = remove01Pair(N)
    #print(N)
    #time.sleep(1)
flag[0] = 0
while flag[0] == 0:
    N = remove10Pair(N)
    #print(N)
    #time.sleep(1)
#print()
#print(len(N))
print(length - len(N))



Fixed submission:
N = input().strip()
#print(N)
length = len(N)
#print(length)
totalZeros = 0
totalOnes = 0
for i in N:
    if i == '0':
        totalZeros += 1
    else:
        totalOnes += 1
if totalOnes < totalZeros:
    answer = totalOnes * 2
else:
    answer = totalZeros * 2

print(answer)

Buggy python submission (verdict: Runtime Error):
def remove01Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '01':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

def remove10Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '10':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

N = input().strip()
#print(N)
length = len(N)
#print(length)
flag = []
flag.append(0)
while flag[0] == 0:
    N = remove01Pair(N)
    #print(N)
    #time.sleep(1)
flag[0] = 0
while flag[0] == 0:
    N = remove10Pair(N)
    #print(N)
    #time.sleep(1)
#print()
#print(len(N))
f.close()
print(length - len(N))


Fixed submission:
N = input().strip()
#print(N)
length = len(N)
#print(length)
totalZeros = 0
totalOnes = 0
for i in N:
    if i == '0':
        totalZeros += 1
    else:
        totalOnes += 1
if totalOnes < totalZeros:
    answer = totalOnes * 2
else:
    answer = totalZeros * 2

print(answer)
Buggy python submission (verdict: Runtime Error):
 s=input()
 if s<='2019/4/30':
 	print("Heisei")
 else:
 	print("TBD")



Fixed submission:
S = input()
print('Heisei' if S <= '2019/04/30' else 'TBD')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(int((a-1)*(b-1))

Fixed submission:
a,b=map(int,input().split())
print(int((a-1)*(b-1)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*P, = map(int, input().split())

N += 1
data = [0]*(N+1)
def add(k, x):
    while k <= N:
        data[k] += x
        k += k & -k

def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s

N0 = 2**(N-1).bit_length()
def lower_bound(x):
    w = i = 0
    k = N0
    while k:
        if i+k <= N and w + data[i+k] <= x:
            w += data[i+k]
            i += k
        k >>= 1
    return i+1

E = [(v, i) for i, v in enumerate(P)]
E.sort(reverse=1)

add(1, 1)
add(N+1, 1)

ans = 0
for v, i in E:
    k = get(i+2)
    l1 = lower_bound(k-2)
    l0 = lower_bound(k-1)
    r0 = lower_bound(k)
    r1 = lower_bound(k+1)
    if l0 > 1:
        ans += (l0-l1) * (r0 - (i+2)) * v
    if r0 < N+2:
        ans += (r1-r0) * (i+2 - l0) * v
    add(i+2, 1)
print(ans)

Fixed submission:
N = int(input())
*P, = map(int, input().split())

N += 1
data = [0]*(N+1)
def add(k, x):
    while k <= N:
        data[k] += x
        k += k & -k

def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s

N0 = 2**(N-1).bit_length()
def lower_bound(x):
    w = i = 0
    k = N0
    while k:
        if i+k <= N and w + data[i+k] <= x:
            w += data[i+k]
            i += k
        k >>= 1
    return i+1

E = [(v, i) for i, v in enumerate(P)]
E.sort(reverse=1)

add(1, 1)
add(N+1, 1)

ans = 0
for v, i in E:
    k = get(i+2)
    l1 = lower_bound(k-2)
    l0 = lower_bound(k-1)
    r0 = lower_bound(k)
    r1 = lower_bound(k+1)
    if l0 > 1:
        ans += (l0-l1) * (r0 - (i+2)) * v
    if r0 < N+2:
        ans += (r1-r0) * (i+2 - l0) * v
    add(i+2, 1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
from collections import deque
N = int(readline())
G = [[] for i in range(N*N)]
deg = [0]*(N*N)
day = [0]*(N*N)
F = set()
for p in range(N):
    *A, = map(int, readline().split())
    for k in range(N-1):
        A[k] -= 1
    prv = A[0]+p*N if A[0] < p else p+A[0]*N
    F.add(prv)
    for k in range(1, N-1):
        i = A[k]+p*N if A[k] < p else p+A[k]*N
        G[prv].append(i)
        deg[i] += 1
        prv = i
que = deque()
for i in F:
    if deg[i] == 0:
        que.append(i)
        day[i] = 1
rest = N*(N-1)//2
while que:
    v = que.popleft()
    rest -= 1
    d = day[v]
    for w in G[v]:
        deg[w] -= 1
        if deg[w] == 0:
            day[w] = day[v] + 1
            que.append(w)
if rest > 0:
    print(-1)
else:
    print(max(day))

Fixed submission:
import sys
readline = sys.stdin.readline
from collections import deque
N = int(readline())
G = [[] for i in range(N*N)]
deg = [0]*(N*N)
day = [0]*(N*N)
F = set()
for p in range(N):
    *A, = map(int, readline().split())
    for k in range(N-1):
        A[k] -= 1
    for k in range(N-2):
        i = A[k]+p*N if A[k] < p else p+A[k]*N
        j = A[k+1]+p*N if A[k+1] < p else p+A[k+1]*N
        G[i].append(j)
        deg[j] += 1
    i = A[0]+p*N if A[0] < p else p+A[0]*N
    F.add(i)
que = deque()
for i in F:
    if deg[i] == 0:
        que.append(i)
        day[i] = 1
rest = N*(N-1)//2
while que:
    v = que.popleft()
    rest -= 1
    d = day[v]
    for w in G[v]:
        deg[w] -= 1
        if deg[w] == 0:
            day[w] = day[v] + 1
            que.append(w)
if rest > 0:
    print(-1)
else:
    print(max(day))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

def chk(x):
    D = []
    c = 0
    for a in A:
        y = a % x
        D.append(y)
    D.sort()
    s = sum(D)
    e = 0; r = N*x - s
    for d in D:
        e += d
        r -= x - d
        if e == r and e <= K:
            return 1
    return 0

ans = 1
S = sum(A)
for x in range(2, S+1):
    if S % x == 0:
        if chk(x):
            ans = x
print(ans)

Fixed submission:
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

def chk(x):
    D = []
    c = 0
    for a in A:
        y = a % x
        D.append(y)
    D.sort()
    s = sum(D)
    e = 0; r = N*x - s
    for d in D:
        e += d
        r -= x - d
        if e == r and e <= K:
            return 1
    return 0

ans = 1
S = sum(A)
for x in range(1, int(S**.5)+1):
    if S % x == 0:
        if chk(x):
            ans = max(ans, x)
        if chk(S // x):
            ans = max(ans, S // x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
MOD = 10**9 + 7
M = 13
S = [0]*M
S[0] = 1
T = [0]*M

def calc(S, T, x):
    for i in range(M):
        T[(i*10 + x) % M] += S[i]
    for i in range(M):
        T[i] %= MOD

zeros = [0]*M
for c in X:
    T[:] = zeros
    if c == "?":
        for x in range(10):
            calc(S, T, x)
    else:
        x = int(c)
        calc(S, T, x)
    S, T = T, S
print(S[5])

Fixed submission:
X = input()
MOD = 10**9 + 7
M = 13
S = [0]*M
S[0] = 1
T = [0]*M

def calc(S, T, x):
    for i in range(M):
        T[(i*10 + x) % M] += S[i]
    for i in range(M):
        T[i] %= MOD

zeros = [0]*M
for c in X:
    T[:] = zeros
    if c == "?":
        for x in range(10):
            calc(S, T, x)
    else:
        x = int(c)
        calc(S, T, x)
    S, T = T, S
print(S[5])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
N, K = map(int, input().split())
MOD = 10**9 + 7

U = [0]
V = []
for x in range(1, int(N**.5)+1):
    U.append(x)
    if x < N//x:
        V.append(N//x)
V.reverse()
U.extend(V)

L = len(U)
memo = {(K, e): 1 for e in U}
for k in range(K-1, -1, -1):
    memo[k, 0] = 0
    r = 0
    for x, y in zip(U, U[1:]):
        memo[k, y] = r = ((y - x) * memo[k+1, N//y] + r) % MOD
print(memo[0, N])

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
N, K = map(int, input().split())
MOD = 10**9 + 7

U = [0]; V = []
for x in range(1, int(N**.5)+1):
    U.append(x)
    if x < N//x:
        V.append(N//x)
V.reverse(); U.extend(V)

L = len(U)
S = [1]*L
S[0] = 0
for k in range(K-1, -1, -1):
    T = [0]*L
    r = 0
    for i in range(1, L):
        x = U[i-1]; y = U[i]
        T[i] = r = ((y - x) * S[L-i] + r) % MOD
    S = T
print(S[-1])