Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, X, M = NMI()
    A = []
    A_ID = {}
    break_flag = False
    for i in range(M):
        if i == 0:
            A.append(X)
            A_ID[X] = 0
        else:
            x = A[-1]**2 % M
            if x not in A_ID:
                A.append(x)
                A_ID[x] = i
            else:
                A.append(x)
                start = A_ID[x]
                end = i
                break_flag = True
            if break_flag:
                break

    if N < start+1:
        print(sum(A[:N]))
        exit()

    ans = sum(A[:start])
    lp = sum(A[start:end])
    gap = end - start
    lp_n = (N - start) // gap
    rem = (N - start) % gap
    ans += lp * lp_n + sum(A[start: start + rem])
    print(ans)




if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, X, M = NMI()
    A = []
    A_ID = {}
    break_flag = False
    start = 0
    end = N
    for i in range(M):
        if i == 0:
            A.append(X)
            A_ID[X] = 0
        else:
            x = A[-1]**2 % M
            if x not in A_ID:
                A.append(x)
                A_ID[x] = i
            else:
                A.append(x)
                start = A_ID[x]
                end = i
                break_flag = True
            if break_flag:
                break

    if N < start+1:
        print(sum(A[:N]))
        exit()

    ans = sum(A[:start])
    lp = sum(A[start:end])
    gap = end - start
    lp_n = (N - start) // gap
    rem = (N - start) % gap
    ans += lp * lp_n + sum(A[start: start + rem])
    print(ans)




if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def combination_mod_initialize(n, MOD=10**9+7):
    fac = [1]*(n+1)
    inv = [1]*(n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = inv[i-1] * pow(i, -1, MOD) % MOD
    return fac, inv

# 二項係数　高速
def combination_mod(n, r, fac, inv, mod=10**9+7):
    return fac[n] * inv[r] * inv[n-r]


def main():
    S = NI()
    fac, inv = combination_mod_initialize(10000, MOD)
    ans = 0
    if S <= 2:
        print(0)
        exit()
    for n in range(1, S//3+1):
        t = S - 3 * n
        ans += combination_mod(t+n-1, t, fac, inv, MOD)
    print(ans%MOD)



if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def combination_mod_initialize(n, MOD=10**9+7):
    fac = [1]*(n+1)
    inv = [1]*(n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = inv[i-1] * pow(i, -1, MOD) % MOD
    return fac, inv

# 二項係数　高速
def combination_mod(n, r, fac, inv, mod=10**9+7):
    return fac[n] * inv[r] * inv[n-r]


def main():
    S = NI()
    fac, inv = combination_mod_initialize(10000, MOD)
    ans = 0
    if S <= 2:
        print(0)
        exit()
    for n in range(1, S//3+1):
        t = S - 3 * n
        ans += combination_mod(t+n-1, t, fac, inv, MOD)
    print(ans%MOD)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, K = NMI()
    A = NLI()
    ng = 0
    ok = 10**10

    for i in range(100):
        mid = (ok + ng) // 2
        tmp = 0
        for a in A:
            if a % mid == 0:
                tmp += a // mid - 1
            else:
                tmp += a // mid
        if tmp <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, K = NMI()
    A = NLI()
    ng = 0
    ok = 10**10

    for i in range(100):
        mid = (ok + ng) // 2
        if mid == 0:
            break
        tmp = 0
        for a in A:
            if a % mid == 0:
                tmp += a // mid - 1
            else:
                tmp += a // mid
        if tmp <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
from collections import Counter

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N = NI()
    A = NLI()
    Q = NI()
    querys = [NLI() for _ in range(Q)]

    Dic = dict(Counter(A))
    for b, c in querys:
        Dic.setdefault(c, 0)
        Dic.setdefault(b, 0)
        Dic[c] += Dic[b]
        del Dic[b]
        res = 0
        for n, x in Dic.items():
            res += n * x
        print(res)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque
from collections import Counter

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N = NI()
    A = NLI()
    Q = NI()
    querys = [NLI() for _ in range(Q)]
    res = sum(A)
    Dic = dict(Counter(A))
    for b, c in querys:
        Dic.setdefault(c, 0)
        Dic.setdefault(b, 0)
        gap = (c-b) * Dic[b]
        Dic[c] += Dic[b]
        del Dic[b]
        res += gap
        print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, K = NMI()
    A = NLI()

    for k in range(min(K, 42)):
        tmp = [0] * (N+1)
        for i, a in enumerate(A):
            tmp[max(0, i-a)] += 1
            tmp[min(N, i+a+1)] -= 1
        cum = [0] * (N+1)
        for i, t in enumerate(tmp):
            if i == 0:
                cum[0] = t
                continue
            cum[i] = cum[i-1] + t
        A = cum[:-1]
    print(" ".join(map(str, A)))


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, K = NMI()
    A = NLI()

    for k in range(min(K, 42)):
        tmp = [0] * (N+1)
        for i, a in enumerate(A):
            tmp[max(0, i-a)] += 1
            tmp[min(N, i+a+1)] -= 1
        cum = [0] * (N+1)
        for i, t in enumerate(tmp):
            if i == 0:
                cum[0] = t
                continue
            cum[i] = cum[i-1] + t
        A = cum[:-1]
    print(" ".join(map(str, A)))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
def gcdtriple(a,b,c):
    return math.gcd(a, math.gcd(b,c))
ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            ans += gcdtriple(a,b,c)
print(ans)

Fixed submission:
import math
N = int(input())
def gcdtriple(a,b,c):
    return math.gcd(a, math.gcd(b,c))
ans = 0
for a in range(1, N+1):
    for b in range(1, a+1):
        for c in range(1, b+1):
            if a == b and b == c:
                ans += gcdtriple(a,b,c)
            elif a == b or b == c or c == a:
                ans += gcdtriple(a,b,c) * 3
            else:
                ans += gcdtriple(a,b,c) * 6
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S = input()
Q = int(input())
ans = deque(S)
for i in range(Q):
    query = input()
    if query == "1":
        ans.reverse()
    elif query[2] == "1":
        ans.appendleft(query[4])
    else:
        ans.append(query[4])

print("".join(ans))


Fixed submission:
from collections import deque
S = input()
Q = int(input())
ans = deque(S)
rev_flag = False
for i in range(Q):
    query = input()
    if query == "1":
        rev_flag = not rev_flag
    elif not rev_flag:
        if query[2] == "1":
            ans.appendleft(query[4])
        else:
            ans.append(query[4])
    else:
        if query[2] == "2":
            ans.appendleft(query[4])
        else:
            ans.append(query[4])

if rev_flag:
    ans.reverse()

print("".join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
rev_flag = False
for i in range(Q):
    query = input()
    if query == "1":
        rev_flag = not rev_flag
    else:
        if not rev_flag:
            if query[2] == "1":
                S = query[4] + S
            else:
                S = S + query[4]
        else:
            if query[2] == "2":
                S = query[4] + S
            else:
                S = S + query[4]
    #print(query)

if rev_flag:
    S = S[::-1]
print(S)



Fixed submission:
from collections import deque
S = input()
Q = int(input())
ans = deque(S)
rev_flag = False
for i in range(Q):
    query = input()
    if query == "1":
        rev_flag = not rev_flag
    elif not rev_flag:
        if query[2] == "1":
            ans.appendleft(query[4])
        else:
            ans.append(query[4])
    else:
        if query[2] == "2":
            ans.appendleft(query[4])
        else:
            ans.append(query[4])

if rev_flag:
    ans.reverse()

print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, N = NMI()
    M = [NLI() for _ in range(N)]
    # dp[i] はiダメージ与えたときの最小の魔力
    dp = [10**10] * (H+10)
    dp[0] = 0
    for i in range(H):
        for m in M:
            dp[min(i+m[0], H)] = min(dp[min(i+m[0], H)], dp[i] + m[1])
    print(dp[H])



if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, N = NMI()
    M = [NLI() for _ in range(N)]
    # dp[i] はiダメージ与えたときの最小の魔力
    dp = [10**10] * (H+10)
    dp[0] = 0
    for i in range(H):
        for m in M:
            dp[min(i+m[0], H)] = min(dp[min(i+m[0], H)], dp[i] + m[1])
    print(dp[H])



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(int(set(1,2,3)-set(a,b)))

Fixed submission:
a = int(input())
b = int(input())
c = [1,2,3]
c.remove(a)
c.remove(b)
print(c[0])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
x = [[] for i in range(N)]
y = [[] for i in range(N)]
for i in range(N):
    A.append(int(input()))
    for j in range(A[i]):
        tmpX, tmpY = map(int, input().split())
        x[i].append(tmpX-1)
        y[i].append(tmpY)
ans = 0

for case in range(2**N):
    flag = True
    honest = 0
    for i in range(N):
        for j in range(A[i]):
            if (case >> i)&1 and (case >> x[i][j])&1 != y[i][j]:
                flag = False
        honest += (case >> i)&1

    if flag:
        ans = max(ans, honest)

print(ans)

Fixed submission:
N = int(input())
A = []
x = [[] for i in range(N)]
y = [[] for i in range(N)]
for i in range(N):
    A.append(int(input()))
    for j in range(A[i]):
        tmpX, tmpY = map(int, input().split())
        x[i].append(tmpX-1)
        y[i].append(tmpY)
ans = 0

for case in range(2**N):
    flag = True
    case = str(format(case, '016b'))[-N:]
    honest = [i for i, x in enumerate(case) if x == '1']
    #print(honest)
    for hon in honest:
        for j, other in enumerate(x[hon]):
            #print(other in honest)
            if (other in honest) and (y[hon][j] == 0):
                flag = False

            elif (not(other in honest)) and (y[hon][j] == 1):
                flag = False

            else:
                continue
    #print(flag)
    if flag:
        ans = max(ans, len(honest))

print(ans)
Buggy python submission (verdict: Runtime Error):
    m1, d1 = map(int, input().split())
    m2, d2 = map(int, input().split())
    if m1 == m2:
      print('0')
    else:
      print('1')

Fixed submission:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if m1 == m2:
    print('0')
else:
    print('1')

Buggy python submission (verdict: Runtime Error):
m1, d1, m2, d2 = map(int, input().split())
if m1 == m2:
  print('0')
else:
  print('1')

Fixed submission:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if m1 == m2:
    print('0')
else:
    print('1')
Buggy python submission (verdict: Runtime Error):
X = int(input())
def check(n):
    if n == 0:  return 1
    elif (n < 100):    return 0
    else:
        flag = check(n-100) + check(n-101) + check(n-102) + check(n-103) + check(n-104) + check(n-105)
        if flag == 0:   return 0
        else:   return 1

print(check(X))

Fixed submission:
X = int(input())

check = [0]*(X+106)
check[0] = 1
for i in range(X+1):    ##0-Xまで
    if check[i] == 1:
        for tmp in [100, 101, 102, 103, 104, 105]:
            check[i + tmp] = 1


print(check[X])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    match = 0
    idx = 0
    for s in S:
        if i[idx] == s:
            match += 1
            idx += 1
        if match == 3:
            break
    if match == 3:
        ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    match = 0
    idx = 0
    for s in S:
        if i[idx] == s:
            match += 1
            idx += 1
        if match == 3:
            break
    if match == 3:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L0 = list(map(int, input().split()))
L = sorted(L0)
tri = 0
for left in range(N-2):
    for mid in range(left+1, N-1):
        right = mid+1
        while right <= N-1 and L[right] < L[left] + L[mid]:
            tri += 1
            right += 1

print(tri)

Fixed submission:
import bisect
N = int(input())
L0 = list(map(int, input().split()))
L = sorted(L0)
tri = 0
for left in range(N-2):
    for mid in range(left+1, N-1):
        x = bisect.bisect_left(L, L[left]+L[mid])
        tri += x - mid - 1

print(tri)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
hit = [0]*N
poi = [K]*N
for i in range(N):
    hit[i] = A.count(i+1)
    poi[i] = K - Q + hit[i]
    if poi[i] > 0:  print('Yes')
    else:           print('No')
      

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
poi = [K-Q]*N
for i in range(Q):
    poi[A[i]-1] += 1

for i in range(N):
    if poi[i] > 0:  print('Yes')
    else:           print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(float, input().split()))
for i in range(M):
    A[A.index(max(A))] /= 2
yen = 0
for i in range(N):
    yen += int(A[i])

print(yen)

Fixed submission:
import sys
import math
from collections import deque
import heapq

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, M = NMI()
    A = NLI()
    A = [-a for a in A]
    heapq.heapify(A)
    for i in range(M):
        a_max = -heapq.heappop(A)
        a_max = a_max // 2
        heapq.heappush(A, -a_max)
    print(-sum(A))



if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(float, input().split()))
for i in range(M):
    A = sorted(A)
    A[-1] /= 2
yen = 0
for i in range(N):
    yen += int(A[i])

print(yen)

Fixed submission:
import sys
import math
from collections import deque
import heapq

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, M = NMI()
    A = NLI()
    A = [-a for a in A]
    heapq.heapify(A)
    for i in range(M):
        a_max = -heapq.heappop(A)
        a_max = a_max // 2
        heapq.heappush(A, -a_max)
    print(-sum(A))



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    T = SI()
    if set(S) | set(T) != set(S):
        print(-1)
        exit()
    s2i = {}

    for i, s in enumerate(S):
        if s in s2i:
            s2i[s].append(i)
        else:
            s2i[s] = [i]

    now = 0
    digit = -1
    for t in T:
        ng = True
        for idx in s2i[t]:
            if digit < idx:
                digit = idx
                ng = False
                break
        if ng:
            digit = s2i[t][0]
            now += 1
    print(now * len(S) + digit + 1)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque
import bisect

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    T = SI()
    if set(S) | set(T) != set(S):
        print(-1)
        exit()
    s2i = {}

    for i, s in enumerate(S):
        if s in s2i:
            s2i[s].append(i)
        else:
            s2i[s] = [i]

    now = 0
    digit = -1
    for t in T:
        target = bisect.bisect_right(s2i[t], digit)
        if target == len(s2i[t]):
            digit = s2i[t][0]
            now += 1
        else:
            digit = s2i[t][target]

    print(now * len(S) + digit + 1)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

dp = [[0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(len(S) + 2)]
INF = 10**9 + 7
for num, dig in enumerate(S):
    if num == 0:
        if dig == '?':
            dp[num] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
        else:
            dp[num] = [0,0,0,0,0,0,0,0,0,0,0,0,0]
            dp[num][int(dig)] = 1

    elif dig == '?':
        for j in range(10):
            for i in range(13):
                dp[num][(i * 10 + j) % 13] += dp[num - 1][i] % INF
                dp[num][(i * 10 + j) % 13] %= INF

    else:
        for i in range(13):
            dp[num][(i*10 + int(dig))%13] += dp[num - 1][i] % INF
            dp[num][(i * 10 + int(dig)) % 13] %= INF

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

Fixed submission:
S = input()

dp = [[0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(len(S) + 2)]
INF = 10**9 + 7
for num, dig in enumerate(S):
    if num == 0:
        if dig == '?':
            dp[num] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
        else:
            dp[num] = [0,0,0,0,0,0,0,0,0,0,0,0,0]
            dp[num][int(dig)] = 1

    elif dig == '?':
        for j in range(10):
            for i in range(13):
                dp[num][(i * 10 + j) % 13] += dp[num - 1][i] % INF
                dp[num][(i * 10 + j) % 13] %= INF

    else:
        for i in range(13):
            dp[num][(i*10 + int(dig))%13] += dp[num - 1][i] % INF
            dp[num][(i * 10 + int(dig)) % 13] %= INF

print(dp[len(S)-1][5])
Buggy python submission (verdict: Runtime Error):
N,D=map(int, input().split)
print((N-1)//(D*2+1)+1)

Fixed submission:
N,D=map(int, input().split())
print((N-1)//(D*2+1)+1)
Buggy python submission (verdict: Runtime Error):
import heapq
L,R = map(int, input().split())
if R - L >= 672:
    print(0)
    exit()
else:
    hq3 = []
    hq673 = []
    hq2019 = []
    for i in range(L, R+1):
        heapq.heappush(hq2019, i%2019)
        heapq.heappush(hq673, i%673)
        heapq.heappush(hq3, i%3)
    a = heapq.heappop(hq2019)
    b = heapq.heappop(hq673)
    c = heapq.heappop(hq3)
    if a == 0:
        print(0)
        exit()
    elif b == 0 and c == 0:
        print(0)
        exit()
    else:
        print(heapq.heappop(hq) * a % 2019)

Fixed submission:
L,R = map(int, input().split())
if R - L >= 2018:
    print(0)
    exit()
else:
    ans = 2019**2
    for i in range(L, R):
        for j in range(i+1, R+1):
            #i %= 2019
            #j %= 2019
            k = (i*j) % 2019
            ans = min(ans, k)
    print(ans)