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

n, m = map(int, input().split())
maze = [[] for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    maze[a-1].append(b-1)
    maze[b-1].append(a-1)

ans = [-1 for _ in range(n)]
ans[0] = 0
q = queue.Queue()
q.put(0)
while not q.empty():
    start = q.get()
    for end in maze[start]:
        if ans[end] == -1:
            q.put(end)
            ans[end] = start

if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(ans[i]+1)


Fixed submission:
import queue

n, m = map(int, input().split())
maze = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    maze[a-1].append(b-1)
    maze[b-1].append(a-1)

ans = [-1 for _ in range(n)]
ans[0] = 0
q = queue.Queue()
q.put(0)
while not q.empty():
    start = q.get()
    for end in maze[start]:
        if ans[end] == -1:
            q.put(end)
            ans[end] = start

if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(ans[i]+1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
maze = [[] for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    maze[a-1].append(b-1)
    maze[b-1].append(a-1)

ans = [-1 for _ in range(n)]
hand = [n+1 for _ in range(n)]
def get(counter, start, ans, hand):
    # counter: 手数
    # start: 出てきた部屋
    for end in maze[start]:
        if counter < hand[end] and end != 0:
            hand[end] = counter+1
            ans[end] = start
            get(counter+1, end, ans, hand)

get(0, 0, ans, hand)
if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(ans[i]+1)


Fixed submission:
import queue

n, m = map(int, input().split())
maze = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    maze[a-1].append(b-1)
    maze[b-1].append(a-1)

ans = [-1 for _ in range(n)]
ans[0] = 0
q = queue.Queue()
q.put(0)
while not q.empty():
    start = q.get()
    for end in maze[start]:
        if ans[end] == -1:
            q.put(end)
            ans[end] = start

if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(ans[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

loop_counter = 0 # 何回目でループに達するか

start = 1
end = a[start-1]
road = [1]
while True:
    if end in road:
        # ループしている
        roop_start = end
        break
    else:
        road.append(end)
        start = end
        end = a[start-1]
roop_start_index = road.index(roop_start)
roop_length = len(road)-road.index(roop_start)
if k <= roop_start_index+1:
    print(road[k])
else:
    k -= roop_start_index
    k %= roop_length
    print(road[roop_start_index+k])


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

loop_counter = 0 # 何回目でループに達するか

start = 1
end = a[start-1]
is_checked = [0 for _ in range(n)]
is_checked[0] = 1
road = [1]
while True:
    if is_checked[end-1] == 1:
        # ループしている
        roop_start = end
        break
    else:
        road.append(end)
        is_checked[end-1] = 1
        start = end
        end = a[start-1]
roop_start_index = road.index(roop_start)
roop_length = len(road)-roop_start_index
if k <= roop_start_index+1:
    print(road[k])
else:
    k -= roop_start_index
    k %= roop_length
    print(road[roop_start_index+k])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    candidates = a[i+a[i]:]
    # print(candidates)
    for j in range(len(candidates)):
        if candidates[j] == j:
            ans += 1
print(ans)


Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
ans = 0
for i in range(n):
    ans += d[i-a[i]]
    d[i+a[i]] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

num_r = s.count('R')
num_g = s.count('G')
num_b = s.count('B')

ans = num_r*num_g*num_b

for i in range(n):
    for j in range(i, n):
        try:
            k = j+(j-i)
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
                ans -= 1
        except:
            pass
print(ans)


Fixed submission:
n = int(input())
s = list(input())

num_r = s.count('R')
num_g = s.count('G')
num_b = s.count('B')

ans = num_r*num_g*num_b

for i in range(n):
    for j in range(i, n):
        k = j+(j-i)
        if (k < n) and (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())

num_r = s.count('R')
num_g = s.count('G')
num_b = s.count('B')

ans = num_r*num_g*num_b

for i in range(n):
    for j in range(i, n):
        try:
            k = j+(j-i)
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
                ans -= 1
        except:
            pass
print(ans)


Fixed submission:
n = int(input())
s = list(input())

num_r = s.count('R')
num_g = s.count('G')
num_b = s.count('B')

ans = num_r*num_g*num_b

for i in range(n):
    for j in range(i, n):
        k = j+(j-i)
        if (k < n) and (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

inverse = 1
for i in range(q):
    query = list(map(str, input().split()))
    if query[0] == '1':
        inverse *= -1
    if query[0] == '2':
        if query[1] == '1' and inverse == 1:
            s = query[2] + s
        elif query[1] == '2' and inverse == 1:
            s = s + query[2]
        elif query[1] == '1' and inverse == -1:
            s = s + query[2]
        elif query[1] == '2' and inverse == -1:
            s = query[2] + s
if inverse == 1:
    print(s)
else:
    for i in range(len(s)):
        print(s[-i-1], end='')
    print()


Fixed submission:
s = input()
q = int(input())

inverse = 1
left = ''
right = ''
for i in range(q):
    query = list(map(str, input().split()))
    if query[0] == '1':
        inverse *= -1
    if query[0] == '2':
        if query[1] == '1' and inverse == 1:
            left += query[2]
        elif query[1] == '2' and inverse == 1:
            right += query[2]
        elif query[1] == '1' and inverse == -1:
            right += query[2]
        elif query[1] == '2' and inverse == -1:
            left += query[2]
s = left[::-1]+s+right
if inverse == 1:
    print(s)
else:
    print(s[::-1])
Buggy python submission (verdict: Runtime Error):
function Main(input) {
	var str = input;
	var ans = "YES";
	str = str.split("\n");
	var l = str[1].split(" "); 
	loop:
	for(var j =0;j< l.length-1;j++){	
 		for(var i =1; i<l.length;i++){
 			 if(l[j]===l[i]){
	 			ans = "NO";
	 			break loop;
 			}	 	
 		}
	} 	
	console.log(ans);
}
 //*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] = (a[i]+1)/2
ans = 0
for i in range(n-k+1):
    tmp = sum(a[i:i+k])
    if tmp > ans:
        ans = tmp
print(ans)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] = (a[i]+1)/2
ans = sum(a[0:0+k])
tmp = sum(a[0:0+k])
for i in range(n-k):
    tmp -= a[i]
    tmp += a[i+k]
    if tmp > ans:
        ans = tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
# import math as fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
mod = 10**9+7
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
# print(ans)
sum = 0
for i in range(n):
    sum += ans//a[i]
    sum %= mod
print(sum)


Fixed submission:
import fractions
# import math as fractions
mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))

if n == 1:
    print(1)
    exit()

g = fractions.gcd(a[0], a[1])
f = a[0]*a[1]//g
ans = a[0]//g+a[1]//g

for i in range(2, n):
    # print(ans, g, f)
    h = fractions.gcd(f, a[i])
    g = a[i] // h
    f = f*a[i]// h
    ans *= g
    ans += f // a[i]
    ans %= mod
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
# import fractions
import math as fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
mod = 10**9+7
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)
sum = 0
for i in range(n):
    sum += ans//a[i]
    sum %= mod
print(sum)


Fixed submission:
import fractions
# import math as fractions
mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))

if n == 1:
    print(1)
    exit()

g = fractions.gcd(a[0], a[1])
f = a[0]*a[1]//g
ans = a[0]//g+a[1]//g

for i in range(2, n):
    # print(ans, g, f)
    h = fractions.gcd(f, a[i])
    g = a[i] // h
    f = f*a[i]// h
    ans *= g
    ans += f // a[i]
    ans %= mod
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

n, m = map(int, input().split())
a = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm_a = lcm(*a)
print(m // (lcm_a//2) - m // lcm_a)


Fixed submission:
import fractions
from functools import reduce

n, m = map(int, input().split())
a = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def count_factorize(n):
    counter = 0
    while n % 2 == 0:
        counter += 1
        n //= 2
    return counter

mod = count_factorize(a[0])
for i in range(1, n):
    if count_factorize(a[i]) != mod:
        print(0)
        exit()
lcm_a = lcm(*a)
print(m // (lcm_a//2) - m // lcm_a)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print(a*b//math.gcd(a,b))


Fixed submission:
import fractions

a, b = map(int, input().split())
print(a*b//fractions.gcd(a,b))
Buggy python submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
if (2*x-y)%3 != 0 or (-x+2*y)%3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (-x+2*y)//3
print(math.factorial(a+b)//(math.factorial(a)*math.factorial(b))%(10**9+7))


Fixed submission:
import math
x, y = map(int, input().split())
if (2*x-y)%3 != 0 or (-x+2*y)%3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (-x+2*y)//3
if a < 0 or b < 0:
    print(0)
    exit()
def comb(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
print(comb(a+b, a, 10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def get_score(i, j):
    return i+j-2

n = int(input())
prime_list = prime_factorize(n)
# print(prime_list)

ans = 1e13
for i in range(2 ** len(prime_list)):
    total = 0
    a = 1
    b = 1
    for j in range(len(prime_list)):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            a *= prime_list[j]
        else:
            b *= prime_list[j]
    score = get_score(a, b)
    if ans > score:
        ans = score
print(ans)


Fixed submission:
n = int(input())
ans = 1e14
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        score = i + n//i -2
        if ans > score:
            ans = score
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
edge = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

ans = [0]*n
checked = [0]*n
checked[0] = 1
for i in range(q):
    p, q = map(int, input().split())
    ans[p-1] += q

ans_q = queue.Queue()
ans_q.put((0, ans[0]))

while not ans_q.empty():
    start = ans_q.get()
    cost = start[1]
    ans[start[0]] = cost
    for e in edge[start[0]]:
        if checked[e] == 0:
            checked[e] = 1
            ans_q.put((e, cost+ans[e]))

for i in range(n):
    print(ans[i], end=' ')
print()


Fixed submission:
import queue
from collections import deque
import sys
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    edge = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)

    ans = [0]*n
    checked = [0]*n
    checked[0] = 1
    for i in range(q):
        p, q = map(int, input().split())
        ans[p-1] += q

    ans_q = deque([(0, ans[0])])
    while len(ans_q) > 0:
        start = ans_q.popleft()
        cost = start[1]
        ans[start[0]] = cost
        for e in edge[start[0]]:
            if checked[e] == 0:
                checked[e] = 1
                ans_q.append((e, cost+ans[e]))

    for i in range(n):
        print(ans[i], end=' ')
    print()

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
ans = [0 for _ in range(len(s))]
for i in range(len(s)):
    location = i
    flag = [0, 0]
    counter = 0
    while(1):
        if s[location] == 'R':
            location += 1
            counter += 1
            flag[1] = 1
        else:
            location -= 1
            counter += 1
            flag[0] = 1
        if flag[0]+flag[1] == 2:
            # ループの処理
            if counter%2 == 0:
                ans[location] += 1
            elif s[location] == 'R':
                ans[location+1] += 1
            else:
                ans[location-1] += 1
            break
print(' '.join(map(str, ans)))


Fixed submission:
s = list(input())
ans = [0 for _ in range(len(s))]
# for i in range(len(s)):
#     location = i
#     flag = [0, 0]
#     counter = 0
#     while(1):
#         if s[location] == 'R':
#             location += 1
#             counter += 1
#             flag[1] = 1
#         else:
#             location -= 1
#             counter += 1
#             flag[0] = 1
#         if flag[0]+flag[1] == 2:
#             # ループの処理
#             if counter%2 == 0:
#                 ans[location] += 1
#             elif s[location] == 'R':
#                 ans[location+1] += 1
#             else:
#                 ans[location-1] += 1
#             break
counter = 0
index = 0
is_R = True
l_index = 0
while(index < len(s)):
    # Rが続く場合
    if is_R:
        if s[index] == 'R':
            counter += 1
            index += 1
        else:
            l_index = index
            ans[l_index] += (counter)//2
            ans[l_index-1] += (counter-1)//2+1
            # print('L',l_index, counter, ans)
            counter = 1
            is_R = False
            index += 1
    else:
        if s[index] == 'L':
            counter += 1
            index += 1
        else:
            ans[l_index] += (counter-1)//2+1
            ans[l_index-1] += (counter)//2
            l_index = index-1
            # print('R',l_index, counter, ans)
            counter = 1
            is_R = True
            index += 1
ans[l_index] += (counter-1)//2+1
ans[l_index-1] += (counter)//2
# print(l_index, counter, ans)
print(' '.join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

ans = 0
while(len(b)>0):
    a1 = a.pop(0)
    b1 = b.pop(0)
    if a1 < b1:
        if a[0]+a1 <= b1:
            ans += a[0]+a1
            a[0] = 0
        else:
            ans += b1
            a[0] -= b1-a1
    else:
        ans += b1
    # print(a,b,ans)

print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

ans = 0
f1 = min(a[0], b[0])
f = [[f1, min(a[1], b[0]-f1)]]
for i in range(1,n):
    f_tmp = min(a[i]-f[i-1][1], b[i])
    f.append([f_tmp, min(a[i+1], b[i]-f_tmp)])
for f_i in f:
    ans += f_i[0]+f_i[1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

ans = 0
while(len(b)>0):
    if a[0] < b[0]:
        if a[0]+a[1] <= b[0]:
            ans += a[0]+a[1]
            a[1] = 0
        else:
            ans += b[0]
            a[1] -= b[0]-a[0]
    else:
        ans += b[0]
    # print(a,b,ans)

    del a[0]
    del b[0]
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

ans = 0
f1 = min(a[0], b[0])
f = [[f1, min(a[1], b[0]-f1)]]
for i in range(1,n):
    f_tmp = min(a[i]-f[i-1][1], b[i])
    f.append([f_tmp, min(a[i+1], b[i]-f_tmp)])
for f_i in f:
    ans += f_i[0]+f_i[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())

dp = [[0 for _ in range(13)] for _ in range(len(s))]
multi = 1
for i in range(10):
    if s[0] == '?':
        dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1
for i in range(1,len(s)):
    if s[i] == '?':
        for j in range(13):
            if dp[i-1][j] != 0:
                for k in range(10):
                    rest = (j*10+k)%13
                    dp[i][rest] += dp[i-1][j]
    else:
        for j in range(13):
            if dp[i-1][j] != 0:
                rest = (j*10+int(s[i]))%13
                dp[i][rest] += dp[i-1][j]
print(dp[i][5]%(10**9+7))


Fixed submission:
S = [int(x) if x != "?" else -1 for x in input()]
g = 10 ** 9 + 7
x = 1
DP = [[0] * 13 for _ in range(2)]
DP[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        DP[1][j] = DP[0][j] % g
        DP[0][j] = 0
    for j in range(13):
        if S[i] == -1:
            s = (j*10)%13
            e = (s+10)%13
        else:
            s = (j*10+S[i])%13
            e = (s+1)%13
        DP[0][s] += DP[1][j]
        if s > e:
            DP[0][0] += DP[1][j]
        DP[0][e] -= DP[1][j]
    w = 0
    for j in range(13):
        w += DP[0][j]
        DP[0][j] = w

print(DP[0][5] % g)

Buggy python submission (verdict: Runtime Error):
s = list(input())

dp = [[0 for _ in range(13)] for _ in range(len(s))]

for i in range(10):
    if s[0] == '?':
        dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1
for i in range(1,len(s)):
    if s[i] == '?':
        for j in range(13):
            for k in range(10):
                rest = (j*10+k)%13
                dp[i][rest] += dp[i-1][j]
    else:
        for j in range(13):
            rest = (j*10+int(s[i]))%13
            dp[i][rest] += dp[i-1][j]
print(dp[i][5]%(10**9+7))


Fixed submission:
S = [int(x) if x != "?" else -1 for x in input()]
g = 10 ** 9 + 7
x = 1
DP = [[0] * 13 for _ in range(2)]
DP[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        DP[1][j] = DP[0][j] % g
        DP[0][j] = 0
    for j in range(13):
        if S[i] == -1:
            s = (j*10)%13
            e = (s+10)%13
        else:
            s = (j*10+S[i])%13
            e = (s+1)%13
        DP[0][s] += DP[1][j]
        if s > e:
            DP[0][0] += DP[1][j]
        DP[0][e] -= DP[1][j]
    w = 0
    for j in range(13):
        w += DP[0][j]
        DP[0][j] = w

print(DP[0][5] % g)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
for i in range(n-1, -1, -1):
    d = 0
    for j in range(n-1, i, -1):
        if (j+1)%(i+1) == 0:
            d += b[j]
    if d%2 != a[i]:
        b[i] = 1
        c.append(i+1)
    else:
        b[i] = 0
if c == []:
    print(0)
else:
    print(len(c))
    for i in range(len(c)):
        print(c[i], end=' ')
    print()


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
for i in range(n-1, -1, -1):
    b[i] = sum(b[i::i+1])%2^a[i]
    if b[i] == 1:
        c.append(i+1)
if c == []:
    print(0)
else:
    print(len(c))
    for i in range(len(c)):
        print(c[i], end=' ')
    print()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
l, r = map(int, input().split())
x = []

# 出力
mod = 2019
# if r-l>=673:
#     print(0)
#     sys.exit()

for i in range(l,r+1):
    for j in range(i+1,r+1):
        # print(i,j,(i*j)%2019)
        if mod > (i*j)%2019:
            mod = (i*j)%2019
print(mod)


Fixed submission:
import sys
l, r = map(int, input().split())
x = []

# 出力
mod = 2019
if r-l>=673:
    print(0)
    sys.exit()

for i in range(l,r+1):
    for j in range(i+1,r+1):
        # print(i,j,(i*j)%2019)
        if mod > (i*j)%2019:
            mod = (i*j)%2019
print(mod)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
lcm = int(c*d/math.gcd(c, d))
ans = (b-b//c-b//d+b//lcm)-(a-a//c-a//d+a//lcm)
print(ans)


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
a = a-1
lcm = int(c*d/fractions.gcd(c, d))
ans = (b-b//c-b//d+b//lcm)-(a-a//c-a//d+a//lcm)
print(ans)

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

a, b, c, d = map(int, input().split())
a = a-1
lcm = int(c*d/math.gcd(c, d))
print((b-b//c-b//d+b//lcm)-(a-a//c-a//d+a//lcm))


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
a = a-1
lcm = int(c*d/fractions.gcd(c, d))
ans = (b-b//c-b//d+b//lcm)-(a-a//c-a//d+a//lcm)
print(ans)

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

a, b, c, d = map(int, input().split())
lcm = int(c*d/math.gcd(c, d))
print((b-b//c-b//d+b//lcm)-(a-a//c-a//d+a//lcm))


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
a = a-1
lcm = int(c*d/fractions.gcd(c, d))
ans = (b-b//c-b//d+b//lcm)-(a-a//c-a//d+a//lcm)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
# 出力
print(min(a+b,b+c,c+A))


Fixed submission:
a, b, c = map(int, input().split())
print(min([a+b, b+c, c+a]))