Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = []
G = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    W.append((a,b))
    G[a].append(b)
    G[b].append(a)
K = 0
for i in range(1,N+1):
    n = len(G[i])
    K = max(K,n)
print(K)
C = [[i for i in range(1,K+1)] for j in range(N+1)]
import copy 
w = copy.deepcopy(W)
d = [[0 for i in range(N+1)] for j in range(N+1)]
w.sort()
for i in range(N-1):
    a,b = W[i]
    print(d[a][b])


Fixed submission:
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Fixed submission:
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
S = input()
if S = 'SUN':
    print(7)
elif S = 'MON':
    print(6)
elif S = 'TUE':
    print(5)
elif S = 'WED':
    print(4)
elif S = 'THU':
    print(3)
elif S = 'FRI':
    print(2)
else:
    print(1)

Fixed submission:
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = ''
for i in range(N):
    a = ord(S[i])-97+N
    if a >= 26:
        a = a - 26
    a += 97
    b = chr(a)
    ans += b
print(ans)

Fixed submission:
N = int(input())
S = input()
n = len(S)
ans = ''
for i in range(n):
    a = (ord(S[i])-65+N)%26
    a += 65
    b = chr(a)
    ans += b
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = []
d = {}
d[0] = 0
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i >= K:
        x = S.pop(0)
        d[x] -= 1
    else:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Fixed submission:
N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = []
d = {}
for i in range(K):
    d[i] = 0
d[0] = 1
A = list(map(int,input().split()))
s = 0
ans = 0
for i in range(1,N+1):
    s = (s+A[i-1])%K
    k = (s-i)%K
    if i >= K:
        x = S.pop(0)
        d[x] -= 1
    ans += d[k]
    d[k] += 1
    S.append(k)
print(ans)

Fixed submission:
N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Buggy python submission (verdict: Runtime Error):
d = {}
S = []
N,K = map(int,input().split())
A = list(map(int,input().split()))
s = 0
for i in range(1,N+1):
    s = (s+A[i-1])%K
    k = (s-i)%K
    if k not in S:
        S.append(k)
        d[k] = 0
    d[k] += 1
ans = 0
for i in range(len(S)):
    x = S[i]
    y = d[x]
    ans += (y*(y-1))//2
ans += d[0]
print(ans)


Fixed submission:
N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = input()
ans = 'No'
if N % 2 == 0:
    n = N/2
    a = s[:n]
    b = s[n:]
    if a == b:
        ans = 'Yes'
print(ans)

Fixed submission:
N = int(input())
s = input()
ans = 'No'
if N % 2 == 0:
    n = N//2
    a = s[:n]
    b = s[n:]
    if a == b:
        ans = 'Yes'
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')


Fixed submission:
N = int(input())
a = [ ]
for i in range(1,10):
    for j in range(i,10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = int(input())
a = [ ]
for i in range(1,10):
    for j in range(i,10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if list.count(N) == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = int(input())
a = [ ]
for i in range(1,10):
    for j in range(i,10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
	for j in range(i:10):
		b = i*j
        a.append(b)
if list.count(N) == 0:
	print('Yes')
else:
	print('No')


Fixed submission:
N = int(input())
a = [ ]
for i in range(1,10):
    for j in range(i,10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n):
    if N % i == 0:
        a = i + (N/i)
        if s >= a:
            s = a
print(int(a-2))

Fixed submission:
N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n + 1):
    if N % i == 0:
        a = i + (N/i)
        s = a
print(int(s-2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = N + 1
t = 0
for i in range(1,N**0.5):
    if N % i == 0:
        a = i + (N//i)
        if s > a:
            t = a
print(a-2)
    


Fixed submission:
N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n + 1):
    if N % i == 0:
        a = i + (N/i)
        s = a
print(int(s-2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = N + 1
for i in range(N):
    if N % i == 0:
        a = i + (N/i)
        if s > a:
            s = a
print(a-2)
    

Fixed submission:
N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n + 1):
    if N % i == 0:
        a = i + (N/i)
        s = a
print(int(s-2))
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int,input().split())
V = (a**2)*b
v = V*0.5
if x > v:
    U = V - x
    c = U / (a**3)
    z = math.atan(c)
    print(z)
elif x = v:
    z = math.atan(1)
    print(z)
else:
    c = (a*(b**2)) / x
    z = math.atan(c)
    print(z)
    
    

Fixed submission:
import math
a, b, x = map(int,input().split())
V = (a**2)*b
v = V*0.5
if x >= v:
    U = V - x
    c = (U*2) / (a**3)
    z = math.atan(c)
    print(math.degrees(z))
else:
    c = (a*(b**2)) / (x*2)
    z = math.atan(c)
    print(math.degrees(z))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort()
F.sort()
suma = sum(A)
u = 10**12
d = 0
for i in range(50):
    x = (u + d)//2
    s = 0
    for i in range(N):
        f = F[i]
        j = -(i+1)
        a = A[j]
        b = x // f
        s += max(0,a-b)
    if s <= K:
        u = x
    else:
        d = x
print(u)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort()
F.sort()
suma = sum(A)
u = 10**12
d = 0
for i in range(50):
    x = (u + d)//2
    s = 0
    for i in range(N):
        f = F[i]
        j = -(i+1)
        a = A[j]
        b = x // f
        s += max(0,a-b)
    if s <= K:
        u = x
    else:
        d = x
print(u)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum += d[i] + d[j]
print(sum)


Fixed submission:
A,B = map(int,input().split())
ans = A-B*2
if ans < 0:
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum += d[i] + d[j]
print(ans)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum += d[i]*d[j]
print(sum)
Buggy python submission (verdict: Runtime Error):
S = input()
S2 = S + S
K = int(input())
n = len(S2)
i = 0
s = 0
while i < n-1 :
    i += 1
    x = S2[i]
    y = S2[i+1]
    if x == y:
        s += 1
        i += 1
p = s//2
q = s-p
ans = p + q*(K-1)

Fixed submission:
A = input()
n = len(A)
S = []
R = [A[n-1]]
for i in range(n):
    S.append(A[i])
    R.append(A[i])
K = int(input())
s = 0
p = S[0]
q = S[n-1]
for i in range(n-1):
    x = S[i]
    y = S[i+1]
    if x == y:
        S[i+1] = 1
        s += 1
t = 0
for j in range(n):
    x = R[j]
    y = R[j+1]
    if x == y:
        R[j+1] = 1
        t += 1
if p != q:
    ans = s*K
else:
    if S[n-1] == 1:
        ans = s*K
    else:
        if R[n] == 1:
            k = K//2
            ans = (K-k)*s + k*t
        else:
            ans = s + (K-1)*t
print(ans)

Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())
n = len(S)
s = [ ]
for i in range(n):
    s.append(S[i])
s.append(S[0])
t = 0
for i in range(n):
    if s[i] == s[i+1]:
        s[i+1] = A
        t = t + 1
if s[n] == s[0]:
    T = t*K
else:
    if K == 1
    T = (t*K) - 1
print(T)

Fixed submission:
A = input()
n = len(A)
S = []
R = [A[n-1]]
for i in range(n):
    S.append(A[i])
    R.append(A[i])
K = int(input())
s = 0
p = S[0]
q = S[n-1]
for i in range(n-1):
    x = S[i]
    y = S[i+1]
    if x == y:
        S[i+1] = 1
        s += 1
t = 0
for j in range(n):
    x = R[j]
    y = R[j+1]
    if x == y:
        R[j+1] = 1
        t += 1
if p != q:
    ans = s*K
else:
    if S[n-1] == 1:
        ans = s*K
    else:
        if R[n] == 1:
            k = K//2
            ans = (K-k)*s + k*t
        else:
            ans = s + (K-1)*t
print(ans)

Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())
s = [ ]
for i in range(K):
    s.append(S[i])
s.append(S[0])
t = 0
for i in range(K):
    if s[i] == s[i+1]:
        s[i+1] = s_i
        t = t + 1
if s[K] == s[0]:
    T = (t*K) - 1
else:
    T = t*K
print(T)

Fixed submission:
A = input()
n = len(A)
S = []
R = [A[n-1]]
for i in range(n):
    S.append(A[i])
    R.append(A[i])
K = int(input())
s = 0
p = S[0]
q = S[n-1]
for i in range(n-1):
    x = S[i]
    y = S[i+1]
    if x == y:
        S[i+1] = 1
        s += 1
t = 0
for j in range(n):
    x = R[j]
    y = R[j+1]
    if x == y:
        R[j+1] = 1
        t += 1
if p != q:
    ans = s*K
else:
    if S[n-1] == 1:
        ans = s*K
    else:
        if R[n] == 1:
            k = K//2
            ans = (K-k)*s + k*t
        else:
            ans = s + (K-1)*t
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(n):
    x = A[i]
    B[x] = str(i+1)
B = " ".join(B)
print(B)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N):
    x = A[i]
    B[x-1] = str(i+1)
B = " ".join(B)
print(B)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
import fractions
gcd = fractions.gcd(A,B)
import math
n = math.floor(gcd)
a = [i for i in range(2,n+1)]
soinsu = [1]
while len(a) > 0:
    x = a.pop(0)
    if gcd % x == 0:
        soinsu.append(x)
    y = n//x
    for j in range(1,y+1):
        z = j*x
        if z in a:
            a.remove(z)
ans = len(soinsu)
print(ans)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A,B = map(int,input().split())
import fractions
gcd = fractions.gcd(A,B)
ans = 1 + len(factorization(gcd))
if factorization(gcd)[0][0] == 1:
    ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
import fractions
gcd = fractions.gcd(A,B)
import math
n = math.floor(gcd)
a = [i for i in range(2,n+1)]
soinsu = [1]
while len(a) > 0:
    x = a.pop(0)
    if gcd % x == 0:
        soinsu.append(x)
    y = n//x
    for j in range(1,y+1):
        z = j*x
        if z in a:
            a.remove(z)
ans = len(soinsu)
print(ans)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A,B = map(int,input().split())
import fractions
gcd = fractions.gcd(A,B)
ans = 1 + len(factorization(gcd))
if factorization(gcd)[0][0] == 1:
    ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = int()
N = len(S)
n = N // 2
ans = 'tes'
for i in range(n):
    p = S[2*i]
    q = S[2*i+1]
    if p == 'L':
        ans = 'No'
    if q == 'R':
        ans = 'No'
if N % 2 == 1:
    if S[N-1] == 'L':
        ans = 'No'
print(ans)

Fixed submission:
S = input()
N = len(S)
n = N // 2
ans = 'Yes'
for i in range(n):
    p = S[2*i]
    q = S[2*i+1]
    if p == 'L':
        ans = 'No'
    if q == 'R':
        ans = 'No'
if N % 2 == 1:
    if S[N-1] == 'L':
        ans = 'No'
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K,Q = map(int,input().split())
A = [0]*N
for i in range(N):
    a = int(input())
    A[a-1] += 1
for i in range(N):
    x = K+A[i]-Q
    if X > 0:
        print('Yes')
    else:
        print('No')
    

Fixed submission:
N,K,Q = map(int,input().split())
A = [0]*N
for i in range(Q):
    a = int(input())
    A[a-1] += 1
for i in range(N):
    x = K+A[i]-Q
    if x > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    for i in range(1,n):
        if i <= LCP[i]:
            LCP[i] = i
    return LCP
ans = 0
for i in range(N):
    T = S[i:]
    R = Z_algo(T)
    R.pop(0)
    R.append(0)
    ans = max(max(R),ans)
print(ans)

Fixed submission:
N = int(input())
S = input()
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    for i in range(1,n):
        if i <= LCP[i]:
            LCP[i] = i
    return LCP
ans = 0
for i in range(N):
    T = S[i:]
    R = Z_algo(T)
    R.pop(0)
    R.append(0)
    ans = max(max(R),ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
l = N//2+1
f = 0
while f == 0:
    l -= 1
    if l == 0:
        f = 1
    for i in range(N-2*l+1):
        P = S[i:i+l]
        for j in range(l+i,N-l+1):
            Q = S[j:j+l]
            if P == Q:
                f = 1
print(l)

Fixed submission:
N = int(input())
S = input()
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    for i in range(1,n):
        if i <= LCP[i]:
            LCP[i] = i
    return LCP
ans = 0
for i in range(N):
    T = S[i:]
    R = Z_algo(T)
    R.pop(0)
    R.append(0)
    ans = max(max(R),ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()
ans = 0
for i in range(N):
    if S[i] == S[i+1]:
        ans += 1
ans += 2*K
if ans > N-1:
    ans = N-1
print(ans)

Fixed submission:
N,K = map(int,input().split())
S = input()
ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1
ans += 2*K
if ans > N-1:
    ans = N-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
ans = 0
for i in range(N):
    a = input()
    s = [ ]
    for j in range(10):
        s.append(a[j])
    s.sort()
    ans += S.count(s)
    S.append(s)
print(ans)

Fixed submission:
N = int(input())
S = {}
ans = 0
for i in range(N):
    a = input()
    s = [ ]
    for j in range(10):
        s.append(a[j])
    s.sort()
    b =s[0]
    for k in range(1,10):
        b += s[k]
    if b in S:
        ans += S[b]
    else:
        S[b] = 0
    S[b] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = len(S)
mod = 10**9 + 7
pow10 = [1]
for i in range(1,n):
    x = pow10[-1]
    y = 10*x%13
    pow10.append(y)
dp = [[0 for i in range(13)]for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    d = S[-i-1]
    if d == '?':
        for j in range(10):
            s = (pow10[i]*j)%13
            for t in range(13):
                r = (s+t)%13
                dp[i+1][r] = (dp[i+1][r] + dp[i][t])%mod
    else:
        j = int(d)
        s = (pow10[i]*j)%13
        for t in range(13):
            r = (s+t)%13
            dp[i+1][r] = (dp[i+1][r] + dp[i][t])%mod
print(dp[n][5])

Fixed submission:
S = input()
n = len(S)
mod = 10**9 + 7
pow10 = [1]
for i in range(1,n):
    x = pow10[-1]
    y = 10*x%13
    pow10.append(y)
dp = [[0 for i in range(13)]for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    d = S[-i-1]
    if d == '?':
        for j in range(10):
            s = (pow10[i]*j)%13
            for t in range(13):
                r = (s+t)%13
                dp[i+1][r] = (dp[i+1][r] + dp[i][t])%mod
    else:
        j = int(d)
        s = (pow10[i]*j)%13
        for t in range(13):
            r = (s+t)%13
            dp[i+1][r] = (dp[i+1][r] + dp[i][t])%mod
print(dp[n][5])

Buggy python submission (verdict: Runtime Error):
S = input()
n = len(S)
mod = 10**9 + 7
pow10 = [0]
for i in range(1,n):
    x = pow10[-1]
    y = 10*x%13
    pow10.append(y)
dp = [[0 for i in range(13)]for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    d = S[-i-1]
    if d = '?':
        for j in range(10):
            s = pow10[i]*j%13
            for t in range(13):
                r = (s+t)%13
                dp[i][r] = (dp[i][r] + dp[i-1][t])%mod
    else:
        j = str(d)
        s = pow10[i]*j%13
        for t in range(13):
            r = (s+t)%13
            dp[i][r] = (dp[i][r] + dp[i-1][t])%mod
print(dp[n][5])

Fixed submission:
S = input()
n = len(S)
mod = 10**9 + 7
pow10 = [1]
for i in range(1,n):
    x = pow10[-1]
    y = 10*x%13
    pow10.append(y)
dp = [[0 for i in range(13)]for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    d = S[-i-1]
    if d == '?':
        for j in range(10):
            s = (pow10[i]*j)%13
            for t in range(13):
                r = (s+t)%13
                dp[i+1][r] = (dp[i+1][r] + dp[i][t])%mod
    else:
        j = int(d)
        s = (pow10[i]*j)%13
        for t in range(13):
            r = (s+t)%13
            dp[i+1][r] = (dp[i+1][r] + dp[i][t])%mod
print(dp[n][5])
Buggy python submission (verdict: Time Limit Exceeded):
L = input()
n = len(L)
mod = 10**9 + 7
if L[-1] == '1':
    ans = 3
else:
    ans = 1
for i in range(2,n+1):
    if L[-i] == '1':
        ans = ans*2 % mod
        ans = (ans + 3**(i-1))%mod
print(ans)


Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
pow3 = [1]
for i in range(1,n):
    x = (3*pow3[i-1])%mod
    pow3.append(x)
ans = 0
for i in range(1,n+1):
    if L[-i] == '1':
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + pow3[i-1])%mod
    else:
        if i == 1:
            ans = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
mod = 10**9 + 7
i = 1
while N > 0:
    r = N % 10
    N = N // 10
    if r == 1:
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + 3**(i-1))%mod
    else:
        if i == 1:
            ans = 1
    i += 1
print(ans)


Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
pow3 = [1]
for i in range(1,n):
    x = (3*pow3[i-1])%mod
    pow3.append(x)
ans = 0
for i in range(1,n+1):
    if L[-i] == '1':
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + pow3[i-1])%mod
    else:
        if i == 1:
            ans = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L = input()
n = len(L)
N = int(L)
ans = 0
mod = 10**9 + 7
for i in range(1,n+1):
    r = N % 10
    N = N // 10
    if r == 1:
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + 3**(i-1))%mod
    else:
        if i == 1:
            ans = 1
print(ans)

Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
pow3 = [1]
for i in range(1,n):
    x = (3*pow3[i-1])%mod
    pow3.append(x)
ans = 0
for i in range(1,n+1):
    if L[-i] == '1':
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + pow3[i-1])%mod
    else:
        if i == 1:
            ans = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L = input()
n = len(L)
ans = 0
mod = 10**9 + 7
for i in range(1,n+1):
    if L[-i] == '1':
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + 3**(i-1))%mod
    else:
        if i == 1:
            ans = 1
print(ans)

Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
pow3 = [1]
for i in range(1,n):
    x = (3*pow3[i-1])%mod
    pow3.append(x)
ans = 0
for i in range(1,n+1):
    if L[-i] == '1':
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + pow3[i-1])%mod
    else:
        if i == 1:
            ans = 1
print(ans)