Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(n+1):
    if b[i+1]==1:
        print(i+1)

Fixed submission:
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(1,n+1):
    if b[i]==1:
        print(i)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split()
print(n*min(a,b))

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input())
print(n*min(a,b))

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
if n<k:
    p=0
    for i in range(1,n+1):
        po=int(log(k/i,2))
        if i*(2**po)!=k:
            po+=1
        p+=(1/n)*((1/2)**po)
    print(p)
else:
    p=(n-k+1)/n
    for i in range(1,k):
        po=int(log(k/i,2))
        if i*(2**po)!=k:
            po+=1
        p+=(1/n)*((1/2)**po)
    print(p)

Fixed submission:
from math import log
n,k=map(int,input().split())
if n<k:
    p=0
    for i in range(1,n+1):
        po=int(log(k/i,2))
        if i*(2**po)!=k:
            po+=1
        p+=(1/n)*((1/2)**po)
    print(p)
else:
    p=(n-k+1)/n
    for i in range(1,k):
        po=int(log(k/i,2))
        if i*(2**po)!=k:
            po+=1
        p+=(1/n)*((1/2)**po)
    print(p)
Buggy python submission (verdict: Runtime Error):
def dfs(s):
    visited[s]=1
    for v in adj[s]:
        if v not in visited:
            if (s,v) in we:
                y[v]=y[s]+we[(s,v)]
            elif (v,s) in we:
                y[v]=y[s]+we[(v,s)]
            dfs(v)
n=int(input())
adj={}
we={}
visited={}
y=[0]*(n+1)
for q in range(n-1):
    a,b,w=map(int,input().split())
    if a not in adj:
        adj[a]=[b]
    else:
        adj[a].append(b)
    if b not in adj:
        adj[b]=[a]
    else:
        adj[b].append(a)
    we[(a,b)]=w
if n>1:
	dfs(1)
for i in range(1,n+1):
    if y[i]%2==0:
        print(0)
    else:
        print(1)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
def dfs(s):
    visited[s]=1
    for v in adj[s]:
        if v not in visited:
            if (s,v) in we:
                y[v]=y[s]+we[(s,v)]
            elif (v,s) in we:
                y[v]=y[s]+we[(v,s)]
            dfs(v)
n=int(input())
adj={}
we={}
visited={}
y=[0]*(n+1)
for q in range(n-1):
    a,b,w=map(int,input().split())
    if a not in adj:
        adj[a]=[b]
    else:
        adj[a].append(b)
    if b not in adj:
        adj[b]=[a]
    else:
        adj[b].append(a)
    we[(a,b)]=w
if n>1:
	dfs(1)
for i in range(1,n+1):
    if y[i]%2==0:
        print(0)
    else:
        print(1)

Buggy python submission (verdict: Runtime Error):
def dfs(s):
    visited[s]=1
    for v in adj[s]:
        if v not in visited:
            if (s,v) in we:
                y[v]=y[s]+we[(s,v)]
            elif (v,s) in we:
                y[v]=y[s]+we[(v,s)]
            dfs(v)
n=int(input())
adj={}
we={}
visited={}
y=[0]*(n+1)
for q in range(n-1):
    a,b,w=map(int,input().split())
    if a not in adj:
        adj[a]=[b]
    else:
        adj[a].append(b)
    if b not in adj:
        adj[b]=[a]
    else:
        adj[b].append(a)
    we[(a,b)]=w
dfs(1)
for i in range(1,n+1):
    if y[1]%2==0:
        print(0)
    else:
        print(1)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
def dfs(s):
    visited[s]=1
    for v in adj[s]:
        if v not in visited:
            if (s,v) in we:
                y[v]=y[s]+we[(s,v)]
            elif (v,s) in we:
                y[v]=y[s]+we[(v,s)]
            dfs(v)
n=int(input())
adj={}
we={}
visited={}
y=[0]*(n+1)
for q in range(n-1):
    a,b,w=map(int,input().split())
    if a not in adj:
        adj[a]=[b]
    else:
        adj[a].append(b)
    if b not in adj:
        adj[b]=[a]
    else:
        adj[b].append(a)
    we[(a,b)]=w
if n>1:
	dfs(1)
for i in range(1,n+1):
    if y[i]%2==0:
        print(0)
    else:
        print(1)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return int((a*b)/gcd(a,b))

n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(l,a[i])
s=0
l-=1
for i in range(n):
    s+=(l%a[i])
print(int(s))

Fixed submission:
def lcm(a,b):
    return a*b//(gcd(a,b))
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(a[i],l)
s=0
l-=1
for i in range(n):
    s+=l%a[i]
print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(a[i],l)
s=0
l-=1
for i in range(n):
    s+=l%a[i]
print(s)

Fixed submission:
def lcm(a,b):
    return a*b//(gcd(a,b))
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(a[i],l)
s=0
l-=1
for i in range(n):
    s+=l%a[i]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n, blue, red = list(map(int, input().split()))

if blue == 0:
    print(0)
    exit()

if n <= blue:
    print(n)
    exit()
    
if n <= blue + red:
    print(blue)
    exit()

cnt = 0

while True:
    if n > blue:
        cnt += blue
        n -= blue
        if n <= red:
            break
        elif n > red:
            n -= red
    else:
        cnt += n
        break
print(cnt)

Fixed submission:
n, blue, red = list(map(int, input().split()))

if blue == 0:
    print(0)
    exit()

if n <= blue:
    print(n)
    exit()

if n <= blue + red:
    print(blue)
    exit()

q = n // (blue + red)
r = n % (blue + red)

cnt = q * blue

while True:
    if r >= blue:
        cnt += blue
        r -= blue
        if r <= red:
            break
        elif r > red:
            r -= red
    else:
        cnt += r
        break

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n, blue, red = list(map(int, input().split()))

if blue == 0:
    print(0)
    exit()

if n <= blue:
    print(n)
    exit()

cnt = 0

while True:
    if n > blue:
        cnt += blue
        n -= blue
        if n <= red:
            break
        elif n > red:
            n -= red
    else:
        cnt += n
        break
print(cnt)

Fixed submission:
n, blue, red = list(map(int, input().split()))

if blue == 0:
    print(0)
    exit()

if n <= blue:
    print(n)
    exit()

if n <= blue + red:
    print(blue)
    exit()

q = n // (blue + red)
r = n % (blue + red)

cnt = q * blue

while True:
    if r >= blue:
        cnt += blue
        r -= blue
        if r <= red:
            break
        elif r > red:
            r -= red
    else:
        cnt += r
        break

print(cnt)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
print('Yes') if n == M else print('No')


Fixed submission:
n, m = list(map(int, input().split()))
print('Yes') if n == m else print('No')
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

while True:
    if x % 2 == 0:
        x += 1
        continue
    i = 1
    while i * i <= x:
        if x % i == 0:
            break
        i += 1
    else:
        print(x)
        exit()
    x += 1


Fixed submission:
x = int(input())
if x == 2:
    print(2)
    exit()
i = 3
f = False
while True:
    if x % 2 == 0:
        x += 1
        continue
    while i * i <= x:
        if x % i == 0:
            i += 2
            f = True
            break
        else:
            i += 2
    if not f:
        print(x)
        exit()
    x += 1
    i = 3
    f = False
Buggy python submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]
print([a + b, b - a][int(b % a)])


Fixed submission:
a, b = [int(x) for x in input().split()]
print([a + b, b - a][int(bool(b % a))])
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

dp = [0, abs(h[1]-[0])]

for i in range(2,n):
    dp.append(min(dp[i-1] + abs(h[i]-h[i+1]), dp[i] + abs(h[i]-h[i+2])))
    
print(dp[-1])

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0

for i in range(n - 1):
    if i <= n - 3:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    elif i == n - 2:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print([':(', 'Yay!'][int((a <= 16) & (b <= 8)])


Fixed submission:
a, b = map(int, input().split())
print([':(', 'Yay!'][int((a <= 8) & (b <= 8))])
Buggy python submission (verdict: Time Limit Exceeded):
import math

mod = 10 ** 9 + 7
n = int(input())
f = math.factorial(n)
l = []
i = 1
while i * i <= f:
    if f % i == 0:
        l.append(i)
        if i != f // i:
            l.append(f // i)
    i += 1
print(pow(len(l), 1, mod))


Fixed submission:
mod = 10 ** 9 + 7
d = {}


def prime_factorizer(n):
    i = 2
    global d
    while i * i <= n:
        if n % i == 0:
            if i in d.keys():
                d[i] += 1
            else:
                d.setdefault(i, 1)
            n //= i
        else:
            i += 1
    if n != 1:
        if n in d.keys():
            d[n] += 1
        else:
            d.setdefault(n, 1)


n = int(input())

for i in range(n, 0, -1):
    prime_factorizer(i)

cnt = 1
for k, v in d.items():
    cnt *= v + 1
print(cnt % mod)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if s == x + y + z:
                cnt += 1
print(cnt)


Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for i in range(0, k + 1):  # X value
    for j in range(0, k + 1):  # Y value
        if 0 <= s - i - j <= k:  # s - i - j = Z
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = list(map(int, input().split()))
count = 0
for i in range(0, k + 1):
    for j in range(0, k + 1):
        for k in range(0, k + 1):
            if i + j + k == s:
                count += 1
print(count)

Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for i in range(0, k + 1):  # X value
    for j in range(0, k + 1):  # Y value
        if 0 <= s - i - j <= k:  # s - i - j = Z
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
from collections import Counter

n, x, y = list(map(int, input().split()))
graph = [[0]*n for _ in range(n)]

# 辺を張る
for i in range(n-1):
    graph[i][i+1] = 1
    graph[i+1][i] = 0
graph[x-1][y-1] = 1
graph[y-1][x-1] = 1

graph = csr_matrix(graph)

# 各点からの最短距離を求める
counter = Counter()
for i in range(n):
    dist = dijkstra(csgraph=graph, directed=False, indices=i)
    counter += Counter(dist)

# 答えを出力
for i in range(1, n):
    print(counter[i] // 2)


Fixed submission:
from collections import Counter

n, x, y = list(map(int, input().split()))
counter = Counter()

for i in range(1, n):
    for j in range(i+1, n+1):
        k = min(j - i, abs(i-x) + abs(j-y) + 1)
        counter[k] += 1

for cnt in range(1, n):
    print(counter[cnt])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import re

n = ni()
s = ns()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            pattern = ".*" + str(i) + ".*" + str(j) + ".*" + str(k) + ".*"
            reptn = re.compile(pattern)
            if re.search(reptn, s):
                cnt += 1

print(cnt)


Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import re

n = ni()
s = ns()
cnt = 0
cand = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            stri = str(i)
            strj = str(j)
            strk = str(k)
            first = False
            second = False
            for si in s:
                if si == strk and first and second:
                    cnt += 1
                    break
                elif si == strj and first:
                    second = True
                elif si == stri:
                    first = True

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

n, t = li()
ab = [tuple(li()) for _ in range(n)]
ans = 0

for i in range(n):

    dic = defaultdict(int)
    dic[0] = 0
    for ai, bi in ab[:i] + ab[i+1:]:
        newdic = defaultdict(int)
        keys = dic.keys()
        for time, value in dic.items():
            if time + ai < t and time + ai in keys:
                newdic[time + ai] = max(dic[time + ai], value + bi)
            elif time + ai < t:
                newdic[time + ai] = value + bi
            newdic[time] = max(newdic[time], value)
        dic = newdic

    ans = max(ans, max(dic.values()) + ab[i][1])

print(ans)


Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

n, t = li()
ab = [tuple(li()) for _ in range(n)]
ans = 0

# dp
dp = [[0]*t for _ in range(n+1)]

for i, (ai, bi) in enumerate(ab):
    for ti in range(t):
        if ti + ai < t:
            dp[i+1][ti + ai] = max(dp[i][ti + ai], dp[i][ti] + bi)
        dp[i+1][ti] = max(dp[i+1][ti], dp[i][ti])

# 経路復元
chose = set()
maxtime = dp[n].index(max(dp[n]))

for idx in range(n, 0, -1):
    if dp[idx][maxtime] != dp[idx-1][maxtime]:
        chose.add(idx-1)
        maxtime -= ab[idx-1][0]

allitem = set(range(n))
notchose = allitem - chose

notchosemax = 0
if notchose:
    for i in notchose:
        notchosemax = max(notchosemax, ab[i][1])

print(max(dp[n]) + notchosemax)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import degrees, atan

a, b, x = li()
c = x / (a*a)

if a * c > (a * b) / 2:
    print(90 - degrees(atan((a / (2*(b-c))))))
else:
    print(90 - degrees(atan(2*a*c / (b**2))))


Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import degrees, atan

a, b, x = li()
c = x / (a*a)

if x == a*a*b:
    print(0)
elif a * c > (a * b) / 2:
    print(90 - degrees(atan((a / (2*(b-c))))))
else:
    print(90 - degrees(atan(2*a*c / (b**2))))
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from heapq import heappush, heappop

n = ni()
a = list(li())
b = list(li())

que = []

for i, bi in enumerate(b):
    heappush(que, (-bi, i))

ans = 0
while que:
    cur, position = heappop(que)
    cur = -cur

    if cur - b[(position-1)%n] - b[(position+1)%n] < a[position]:
        continue

    ope = cur // (b[(position-1)%n] + b[(position+1)%n])
    ans += ope
    b[position] -= ope * (b[(position-1)%n] + b[(position+1)%n])
    heappush(que, (-b[position], position))

ok = True
for ai, bi in zip(a, b):
    if ai != bi:
        ok = False

if ok:
    print(ans)
else:
    print(-1)

Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from heapq import heappush, heappop

n = ni()
a = list(li())
b = list(li())

# n = 10**5
# a = [1]*(10**5)
# b = [5] + [1]*(10**5-2) + [7]

que = []

for i, bi in enumerate(b):
    heappush(que, (-bi, i))

ans = 0
while que:

    cur, position = heappop(que)
    cur = -cur

    if cur - b[(position-1)%n] - b[(position+1)%n] < a[position]:
        continue

    ope = (cur - a[position]) // (b[(position-1)%n] + b[(position+1)%n])

    ans += ope
    b[position] -= ope * (b[(position-1)%n] + b[(position+1)%n])
    heappush(que, (-b[position], position))

ok = True
for ai, bi in zip(a, b):
    if ai != bi:
        ok = False

if ok:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a, b = li()

print((a+b) // 2 if (a+b) % 2 == 0 else "IMPOSSIBLE"

Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a, b = li()

print((a+b) // 2 if (a+b) % 2 == 0 else "IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
n = len(s)
MOD = 10**9 + 7

dp = [[0]*13 for _ in range(n+1)]
dp[0][0] = 1

for i, si in enumerate(s):
    if si == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(10*j + k) % 13] += dp[i][j]
                dp[i + 1][(10 * j + k) % 13] %= MOD

    else:
        k = int(si)
        for j in range(13):
            dp[i + 1][(10 * j + k) % 13] += dp[i][j]
            dp[i + 1][(10 * j + k) % 13] %= MOD

print(dp[n][5])

Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
n = len(s)
MOD = 10**9 + 7

dp = [[0]*13 for _ in range(n+1)]
dp[0][0] = 1

for i, si in enumerate(s):
    if si == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(10*j + k) % 13] += dp[i][j]
                dp[i + 1][(10 * j + k) % 13] %= MOD

    else:
        k = int(si)
        for j in range(13):
            dp[i + 1][(10 * j + k) % 13] += dp[i][j]
            dp[i + 1][(10 * j + k) % 13] %= MOD

print(dp[n][5])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1

    return list(set(div))

n = ni()
a = [0] + list(li())
b = [0]*(n+1)
ans = []
for i in range(n, 0, -1):
    into = False
    if b[i] % 2 != a[i]:
        b[i] += 1
        ans.append(i)
        into = True

    if into:
        bi_div = divisors(i)

        for divi in bi_div:
            b[divi] += 1

print(len(ans))
if len(ans) > 0:
    print(*ans)


Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1

    return list(set(div))

n = ni()
a = [0] + list(li())
b = [0]*(n+1)
ans = []
for i in range(n, 0, -1):
    into = False
    if b[i] % 2 != a[i]:
        b[i] += 1
        ans.append(i)
        into = True

    if into:
        bi_div = divisors(i)

        for divi in bi_div:
            b[divi] += 1

print(len(ans))
if len(ans) > 0:
    print(*ans)