Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):


def solve(x):
    for b in xrange(-101, 101):
        a5 = (b ** 5) + x
        s = -1 if a5 < 0 else 1
        a = s * int(pow(abs(a5), 0.2) + 0.1)
        if a ** 5 == a5:
            return a, b

def test(x):
    a, b = solve(x)
    assert x == (a ** 5 - b ** 5)

test(33)
test(1)


x = int(raw_input())
a, b = solve(x)
print a, b


Fixed submission:

def solve(x):
    for b in xrange(-200, 200):
        a5 = (b ** 5) + x
        s = -1 if a5 < 0 else 1
        a = s * int(pow(abs(a5), 0.2) + 0.1)
        if a ** 5 == a5:
            return a, b

def test(x):
    a, b = solve(x)
    assert x == (a ** 5 - b ** 5)

test(33)
test(1)

from random import randint
for i in xrange(100):
    a = randint(-10 ** 3, 10 ** 3)
    b = randint(-10 ** 3, 10 ** 3)
    u = a ** 5 - b ** 5
    if abs(u) > 10 ** 9:
        continue
    test(a ** 5 - b ** 5)


x = int(raw_input())
a, b = solve(x)
print a, b
Buggy python submission (verdict: Runtime Error):

def solve1(n):
    # n = k ^ a
    res = []
    for i in xrange(1, 100):
        u = int(pow(n, 1.0 / i) + 0.1)
        if u ** i == n:
            res.append(u)
    return set(res)

def solve2(n):
    # n = a * k + 1
    m = n - 1

    i = 1
    res = set()
    while i * i <= m:
        if m % i == 0:
            res.add(i)
            res.add(m / i)
        i += 1
    return res ^ set([1])

def solve3(n):
    i = 2
    res = set()
    while i * i <= n:
        if n % i == 0:
            m = n / i
            while m and m % i == 0:
                m /= i
            if m % i == 1:
                res.add(i)
        i += 1
    return res

def brute_force(n):
    res = []
    for i in xrange(2, n + 1):
        m = n
        while m % i == 0:
            m /= i
        m %= i
        if m == 1:
            res.append(i)
    # print res
    return len(res)

def solve(n):
    s1 = solve1(n)
    s2 = solve2(n)
    s3 = solve3(n)
    # print sorted(s1 | s2 | s3)
    return len(s1 | s2 | s3)

assert solve(6) == 3
assert solve(3141) == 13
assert solve(314159265358) == 9

assert solve(10 ** 12)

import random
for i in xrange(100):
    n = random.randint(1, 1000)
    assert brute_force(n) == solve(n)

n = int(raw_input())
print solve(n)


Fixed submission:

def solve1(n):
    # n = k ^ a
    res = []
    for i in xrange(1, 100):
        u = int(pow(n, 1.0 / i) + 0.1)
        if u ** i == n:
            res.append(u)
    return set(res)

def solve2(n):
    # n = a * k + 1
    m = n - 1

    i = 1
    res = set()
    while i * i <= m:
        if m % i == 0:
            res.add(i)
            res.add(m / i)
        i += 1
    return res ^ set([1])

def solve3(n):
    i = 2
    res = set()
    while i * i <= n:
        if n % i == 0:
            m = n / i
            while m and m % i == 0:
                m /= i
            if m % i == 1:
                res.add(i)
        i += 1
    return res

def brute_force(n):
    res = []
    for i in xrange(2, n + 1):
        m = n
        while m % i == 0:
            m /= i
        m %= i
        if m == 1:
            res.append(i)
    # print res
    return len(res)

def solve(n):
    s1 = solve1(n)
    s2 = solve2(n)
    s3 = solve3(n)
    # print sorted(s1 | s2 | s3)
    return len(s1 | s2 | s3)

assert solve(6) == 3
assert solve(3141) == 13
assert solve(314159265358) == 9

assert solve(10 ** 12)

import random
for i in xrange(2, 100):
    assert brute_force(i) == solve(i)

n = int(raw_input())
print solve(n)
Buggy python submission (verdict: Runtime Error):
def func(now, ans_base, num, tree):
    ans_base.append(num[now])
    addNum = num[now]
    while len(tree[now]) > 0:
        next = tree[now].pop(0)
        num[next] += num[now]
        ans_base = func(next, ans_base, num, tree)
    return ans_base


N, Q = map(int, input().split())

tree = {}
for i in range(1, N + 1):
    tree[i] = list()

for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a].append(b)

num = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input(). split())
    num[p] += x

ans_base = list()

result = func(1, ans_base, num, tree)

print(' '.join(list(map(str, result))))




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

dictionary = [[] for i in range(N + 1)]

for i in range(N-1):
    a, b = map(int, input().split())
    dictionary[a].append(b)

num = [0] * (N + 1)

for i in range(Q):
    p, x = map(int, input().split())
    num[p] += x

for i in range(1, N + 1):
    print(num[i])
    for j in range(0, len(dictionary[i])):
        num[dictionary[i][j]] += num[i]
Buggy python submission (verdict: Runtime Error):
N = int(input())
hh = list(map(int, input().split()))

prev = -999
for i in range(N):
  if pre <= hh[i]-1:
    pre = hh[i]-1
  elif pre <= hh[i]:
    pre = hh[i]
  else:
    print('No')
    exit(0)
print('Yes')
exit(0)


Fixed submission:
N = int(input())
hh = list(map(int, input().split()))

prev = -999
for i in range(N):
  if prev <= hh[i]-1:
    prev = hh[i]-1
  elif prev <= hh[i]:
    prev = hh[i]
  else:
    print('No')
    exit(0)

print('Yes')
exit(0)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = math.floor(N / 2)

while i >= 0:
    bai = (i + 1) * 2 - 1
    if aa[i] == 1:  # 自分が奇数
        if aa[bai] == 0:  # 2倍が偶数
            bb[i] = 1
        else:  # 2倍が奇数
            bb[i] = 0
    else:  # 自分が偶数
        if aa[bai] == 0:  # 2倍が偶数
            bb[i] = 0
        else:  # 2倍が奇数
            bb[i] = 1
    i -= 1

bbKisu = filter(lambda n: n % 2 == 1, bb)
count = len(list(bbKisu))

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)






Fixed submission:
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = N

while i > 0:

    total = 0
    j = i * 2

    while j <= N:
        total ^= bb[j - 1]
        j += i

    bb[i - 1] = total ^ aa[i - 1]
    i -= 1

bbKisu = list(filter(lambda n: n % 2 == 1, bb))
count = len(bbKisu)

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = math.floor(N / 2)

while i >= 0:
    if aa[i] == 1:  # 自分が奇数
        if aa[i * 2] == 0:  # 2倍が偶数
            bb[i] = 1
        else:  # 2倍が奇数
            bb[i] = 0
    else:  # 自分が偶数
        if aa[i * 2] == 0:  # 2倍が偶数
            bb[i] = 0
        else:  # 2倍が奇数
            bb[i] = 1
    i -= 1

bbKisu = filter(lambda n: n % 2 == 1, bb)
count = len(list(bbKisu))

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)






Fixed submission:
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = N

while i > 0:

    total = 0
    j = i * 2

    while j <= N:
        total ^= bb[j - 1]
        j += i

    bb[i - 1] = total ^ aa[i - 1]
    i -= 1

bbKisu = list(filter(lambda n: n % 2 == 1, bb))
count = len(bbKisu)

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = math.floor(N / 2)

while i > 0:
    if aa[i] == 1:  # 自分が奇数
        if aa[i * 2] == 0:  # 2倍が偶数
            bb[i] = 1
        else:  # 2倍が奇数
            bb[i] = 0
    else:  # 自分が偶数
        if aa[i * 2] == 0:  # 2倍が偶数
            bb[i] = 0
        else:  # 2倍が奇数
            bb[i] = 1
    i -= 1

bbKisu = filter(lambda n: n % 2 == 1, bb)
count = len(list(bbKisu))

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)






Fixed submission:
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = N

while i > 0:

    total = 0
    j = i * 2

    while j <= N:
        total ^= bb[j - 1]
        j += i

    bb[i - 1] = total ^ aa[i - 1]
    i -= 1

bbKisu = list(filter(lambda n: n % 2 == 1, bb))
count = len(bbKisu)

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split(" "))

R = min(R, L + 4038)

i = L
res = 2019
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

print(res)


Fixed submission:
L, R = map(int, input().split(" "))

ans = 2019

R = min(R, L + 2019)
for l in range(L, R):
    for r in range(l + 1, R + 1):
        ans = min(ans, (l * r) % 2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
K = int(input())
count = 0
while B <= A:
    B *= 2
    count += 1
while C <= B :
    C *= 2
    count += 1
if count > K :
    print("No")
else:
    pirnt("Yes")


Fixed submission:
A,B,C = map(int,input().split())
K = int(input())
count = 0
while B <= A:
    B *= 2
    count += 1
while C <= B :
    C *= 2
    count += 1
if count > K :
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans_list = [0] * (N+1)
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
for i in range(N):
    if i == 0:
        continue
    else:
        if i %popcnt(i) == 0 :
            ans_list[i] = 1
        else:
            ans_list[i] = ans_list[i%popcnt(i)] + 1
S = input()
count = 0
for i in range(N):
    if S[i] == "1":
        count += 1
high_total = 0
low_total = 0
for i in range(N):
    if S[i] == "1":
        high_total += pow(2,N-1-i,count+1)
        high_total %= (count+1)
        low_total +=  pow(2,N-1-i,count-1)
        low_total %= (count-1)
for i in range(N):
    if S[i] == "1":
        total = (low_total - pow(2,N-1-i,count-1)) % (count-1)
        print(ans_list[total]+1)
    if S[i] == "0":
        total = (high_total + pow(2,N-1-i,count+1)) % (count+1)
        print(ans_list[total]+1)

Fixed submission:
N = int(input())
ans_list = [0] * (N+1)
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
for i in range(N):
    if i == 0:
        continue
    else:
        if i %popcnt(i) == 0 :
            ans_list[i] = 1
        else:
            ans_list[i] = ans_list[i%popcnt(i)] + 1
S = input()
count = 0
for i in range(N):
    if S[i] == "1":
        count += 1
if count == 1:
    high_total = 0
    low_total = 0
    for i in range(N):
        if S[i] == "1":
            high_total += pow(2,N-1-i,count+1)
            high_total %= (count+1)
    for i in range(N):
        if S[i] == "1":
            print(0)
        if S[i] == "0":
            total = (high_total + pow(2,N-1-i,count+1)) % (count+1)
            print(ans_list[total]+1)
else:
    high_total = 0
    low_total = 0
    for i in range(N):
        if S[i] == "1":
            high_total += pow(2,N-1-i,count+1)
            high_total %= (count+1)
            low_total +=  pow(2,N-1-i,count-1)
            low_total %= (count-1)
    for i in range(N):
        if S[i] == "1":
            total = (low_total - pow(2,N-1-i,count-1)) % (count-1)
            print(ans_list[total]+1)
        if S[i] == "0":
            total = (high_total + pow(2,N-1-i,count+1)) % (count+1)
            print(ans_list[total]+1)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if K >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])

Fixed submission:
S  = input()
print(S[:3])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if (1.8)**(K//2) >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])

Fixed submission:
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if K >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if K >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])

Fixed submission:
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if K >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])
Buggy python submission (verdict: Runtime Error):
N= int(input())
n = N%10
if n == 3:
    print("bon")
elif n == 1 or n == 6 or n == 8 or n == 0 :
    print("pon")
else:
    print(hon)


Fixed submission:
N= int(input())
n = N%10
if n == 3:
    print("bon")
elif n == 1 or n == 6 or n == 8 or n == 0 :
    print("pon")
else:
    print("hon")
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
path_list = []
for i in range(M):
    z = []
    path_list.append(z)
for i in range(M):
    A,B = map(int,input().split())
    path_list[A-1].append(B)
    path_list[B-1].append(A)
chk = [0] * N

def bfs(a,chk,path):
    queue = [a]
    while queue:
        b = queue.pop(0)
        for i in range(len(path[b-1])):
            if chk[path[b-1][i]-1] == 0:
                queue.append(path[b-1][i])
                chk[path[b-1][i]-1] =b
    return chk
bfs(1,chk,path_list)
print("Yes")
for i in range(N):
    if i == 0:
        continue
    else:
        print(chk[i])


Fixed submission:
N,M = map(int,input().split())
path_list = []
for i in range(N):
    z = []
    path_list.append(z)
for i in range(M):
    A,B = map(int,input().split())
    path_list[A-1].append(B)
    path_list[B-1].append(A)
chk = [0] * N

def bfs(a,chk,path):
    queue = [a]
    while queue:
        b = queue.pop(0)
        for i in range(len(path[b-1])):
            if chk[path[b-1][i]-1] == 0:
                queue.append(path[b-1][i])
                chk[path[b-1][i]-1] =b
    return chk
bfs(1,chk,path_list)
print("Yes")
for i in range(N):
    if i == 0:
        continue
    else:
        print(chk[i])
Buggy python submission (verdict: Runtime Error):
N = input()
if N = "ABC":
  print("ARC")
else:
  print("ABC")

Fixed submission:
N = input()
if N == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
alp = ["a","b","c","d","e","f","g","h","i","j"]
N = int(input())
ans_list = []
for i in range(N):
    ans_list.append([])
for i in range(N):
    if i == 0:
        ans_list[i].append(["a",1])
    else:
        for j in range(len(ans_list[i-1])):
            for l in range(ans_list[i-1][j][1]+1):
                temp = ans_list[i-1][j][0] + alp[l]
                if l == ans_list[i-1][j][1]:
                    chk = ans_list[i-1][j][1]+1
                else:
                    chk = ans_list[i-1][j][1]
                ans_list[i].append([temp,chk])
for i in range(len(ans_list[N-1])):
    print(ans_list[N-1][i][0])

Fixed submission:
N = int(input())
n_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(n_list[N-1])
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
C = N//(A+B)
D = N%(A+B)
print(C*A+min(D,A))

Fixed submission:
N = input()
if N == "AAA" or N == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
rotate = 1
for i in range(Q):
    n = [str(i) for i in input().split()]
    if n[0] == "1":
        rotate *= -1
    else:
        if n[1] == "1":
            if rotate == 1:
                S = n[2] + S
            else:
                S = S + n[2]
        else:
            if rotate == 1:
                S = S + n[2]
            else:
                S = n[2] + S
if rotate == 1:
    print(S)
else:
    print(S[::-1])

Fixed submission:
from collections import deque
S = input()
Q = int(input())
left = deque()
right = deque()
rotate = 1
for i in range(Q):
    n = [str(i) for i in input().split()]
    if n[0] == "1":
        rotate *= -1
    else:
        if n[1] == "1":
            if rotate == 1:
                left.appendleft(n[2])
            else:
                right.append(n[2])
        else:
            if rotate == 1:
                right.append(n[2])
            else:
                left.appendleft(n[2])
left = list(left)
right = list(right)
ans = "".join(left)
ans += S
ans += "".join(right)
if rotate == 1:
    print(ans)
else:
    print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N ,P= map(int,input().split())
S = input()
if P != 2 and P != 5:
    mod_dic ={}
    mod_dic[0] = 1
    for i in range(len(S)):
        num  = int(S[len(S)-i-1:])
        mod = num%P
        if mod not in mod_dic:
            mod_dic[mod] = 1
        else:
            mod_dic[mod] += 1
        ans = 0
    a = list(mod_dic.values())
    for i in range(len(a)):
            ans += a[i] * (a[i]-1) //2
    print(ans)
elif P == 2:
    ans = 0
    for i in range(len(S)):
        if int(S[len(S)-1-i])%2 == 0:
            ans += N-i
    print(ans)
else:
    ans = 0
    for i in range(len(S)):
        if int(S[len(S)-1-i])%5 == 0:
            ans += N-i
    print(ans)

Fixed submission:
N ,P= map(int,input().split())
S = input()
ten = [0] * len(S)
for i in range(len(S)):
    if i == 0:
        ten[i] = 1
    else:
        ten[i] = (ten[i-1] * 10) %P
if P != 2 and P != 5:
    mod_dic ={}
    mod_dic[0] = 1
    mod = 0
    for i in range(len(S)):
        mod +=  int(S[N-1-i]) * ten[i]
        mod = mod%P
        if mod not in mod_dic:
            mod_dic[mod] = 1
        else:
            mod_dic[mod] += 1
        ans = 0
    a = list(mod_dic.values())
    for i in range(len(a)):
            ans += a[i] * (a[i]-1) //2
    print(ans)
elif P == 2:
    ans = 0
    for i in range(len(S)):
        if int(S[len(S)-1-i])%2 == 0:
            ans += N-i
    print(ans)
else:
    ans = 0
    for i in range(len(S)):
        if int(S[len(S)-1-i])%5 == 0:
            ans += N-i
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N = int(input())
A = [int(i) for i in input().split()]
ans = 1
cur_lcm = A[0]
mod = 10**9 +7
for i in range(N):
    if i == 0:
        continue
    else:
        temp_lcm = cur_lcm*A[i]//fractions.gcd(cur_lcm,A[i])
        if temp_lcm == cur_lcm:
            ans +=  temp_lcm//A[i]
        else:
            ans *= temp_lcm//cur_lcm
            ans += temp_lcm//A[i]
            cur_lcm = temp_lcm
        ans %= mod
print(ans)

Fixed submission:
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 +7
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
cur_prime = {}
for i in range(N):
    S = factorization(A[i])
    for j in range(len(S)):
        if S[j][0] not in cur_prime:
            cur_prime[S[j][0]] = S[j][1]
        else:
            cur_prime[S[j][0]] = max(S[j][1],cur_prime[S[j][0]])
A_lcm = 1
key = list(cur_prime.keys())
value = list(cur_prime.values())
for i in range(len(key)):
    for j in range(value[i]):
        A_lcm *= key[i]
        A_lcm %= mod
ans = 0
for i in range(N):
    ans += A_lcm*pow(A[i],mod-2,mod)
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
H = input()
W = input()
N = input()
A = max(H,W)
print((N-1)%A+1)

Fixed submission:
H = int(input())
W = int(input())
N = int(input())
A = max(H,W)
print((N-1)//A+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import functools
N = int(input())
x = [int(i) for i in input().split()]
mod = 10**9+7
start = 1
all_dis = 0
for i in range(N-1):
    far = x[i+1]-x[i]
    all_dis += far*start*math.factorial(N-1)//math.factorial(i+1)
    start = (start*(i+2)+math.factorial(i+1))%mod
    all_dis %= mod
print(all_dis)

Fixed submission:
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import functools
N = int(input())
x = [int(i) for i in input().split()]
mod = 10**9+7
start = 1
st = 1
st_list = [0] * N
st_rev = [0] * N
for i in range(N-1):
    st *= (i+1)
    st %= mod
    st_list[i] = st
    st_rev[i] = pow(st,mod-2,mod)
all_dis = 0
for i in range(N-1):
    far = x[i+1]-x[i]
    all_dis += far*start*st_list[N-2]*st_rev[i]
    start = (start*(i+2)+st_list[i])%mod
    all_dis %= mod
print(all_dis)