Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03634 (python)

Fixed submission:
import sys

sys.setrecursionlimit(200000)

n = int(input())
l = [list(map(int,input().split())) for _ in range(n-1)]
q,k = map(int,input().split())
k -= 1
#kからの距離
tree = [[] for _ in range(n)]
for a,b,c in l:
    a -= 1
    b -= 1
    tree[a].append([b,c])
    tree[b].append([a,c])

bit = [0 for _ in range(n)]
depth = [0 for _ in range(n)]
def dfs(v,d=0):
    bit[v] = 1
    depth[v] = d
    for j,k in tree[v]:
        if bit[j]==0:
            dfs(j,d+k)
dfs(k)

for _ in range(q):
    x,y = map(int,input().split())
    x-= 1
    y-= 1
    print(depth[x] + depth[y])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(map(int,input().split())) for _ in range(n-1)]
q,k = map(int,input().split())
k -= 1
#kからの距離
tree = [[] for _ in range(n)]
for a,b,c in l:
    a -= 1
    b -= 1
    tree[a].append([b,c])
    tree[b].append([a,c])

bit = [0 for _ in range(n)]
depth = [0 for _ in range(n)]
def dfs(v,d=0):
    bit[v] = 1
    depth[v] = d
    for j,k in tree[v]:
        if bit[j]==0:
            dfs(j,d+k)
dfs(k)

for _ in range(q):
    x,y = map(int,input().split())
    x-= 1
    y-= 1
    print(depth[x] + depth[y])
Problem p03774 (python)

Fixed submission:
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
for i in range(n):
  q = 10**9
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
for i in range(n):
  q = 10**8
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
q = 1000000
for i in range(n):
  q = 1000000
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
q = 1000000
for i in range(n):
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)
  q = 10000000

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
q = 1000000
for i in range(n):
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<=q:
      q = v
      z = t
  print(z+1)
  q = 100000

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
q = 1000000
for i in range(n):
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)
  q = 100000
Problem p03775 (python)

Fixed submission:
n = int(input())
t = []
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    t.append(max(len(str(int(n/i))),len(str(i))))            
print(min(t))

Buggy submission (verdict: Runtime Error):
n = int(input())
t = []
for i in range(1,int(n**0.5)):
  if n%i==0:
    t.append(max(len(str(int(n/i))),len(str(i))))            
print(min(t))
Problem p03804 (python)

Fixed submission:
n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
k = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
      if all(list_A[v+i][t:t+m]==list_B[v] for v in range(m)):
        k = "Yes"
        break
print(k)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
t = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
    if all(list_A[i][t:t+m+1]==list_B[i][t:t+m+1]):
      print("Yes")
Problem p02695 (python)

Fixed submission:
import itertools


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

a = []
b = []
c = []
d = []

for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]

A_pattern = list(itertools.combinations_with_replacement(A, N))

ans = 0

for a_pattern in A_pattern: # 数列全部調べる
    ansi = 0
    for i in range(Q): # 得点になるかどうか調べる
        if a_pattern[b[i]-1] - a_pattern[a[i]-1] == c[i]: # A[bi] - A[ai] == ci -> ansi += di
            ansi += d[i]

    ans = max(ans, ansi)


print(ans)

Buggy submission (verdict: Runtime Error):
import itertools


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

a = []
b = []
c = []
d = []

for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]

A_pattern = list(itertools.combinations_with_replacement(A, M)) # 10^5

ans = 0

for a_pattern in A_pattern: # 数列全部調べる
    ansi = 0
    for i in range(Q): # 得点になるかどうか調べる

        if a_pattern[b[i]-1] - a_pattern[a[i]-1] == c[i]: # A[bi] - A[ai] == ci -> ansi += di
            ansi += d[i]

    ans = max(ans, ansi)


print(ans)

Buggy submission (verdict: Runtime Error):
import itertools


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

a = []
b = []
c = []
d = []

for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]

A_pattern = list(itertools.combinations_with_replacement(A, M)) # 10^5

ans = 0

for a_pattern in A_pattern: # 数列全部調べる
    ansi = 0
    for i in range(Q): # 得点になるかどうか調べる
        if a_pattern[b[i]] - a_pattern[a[i]] == c[i]: # A[bi] - A[ai] == ci -> ansi += di
            ansi += d[i]

    ans = max(ans, ansi)


print(ans)
Problem p02881 (python)

Fixed submission:
N = int(input())
a = 0

for i in range(1, int(N ** (1/2)+1)):
    if (N % i == 0):
        a = i

b = N // a

ans = (a - 1) + (b - 1)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 0

for i in range(1, int(N ** 0.5)):
    if (N % i == 0):
        a = i

b = N // a

ans = (a - 1) + (b - 1)

print(ans)
Problem p02891 (python)

Fixed submission:
S = list(input())
K = int(input())

if(len(set(S)) == 1):
    print(len(S) * K//2)
else:
    ans = 0
    cnt = 1
    a = []
    for i in range(len(S)-1):
        if(S[i] == S[i+1]):
            cnt += 1
        else:
            a.append(cnt)
            cnt = 1
    a.append(cnt)

    for i in a:
        ans += (i//2)*K

    if (S[0] == S[-1]):
        ans -= (a[0]//2 + a[-1]//2  - (a[0] + a[-1])//2)*(K-1)

    print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())

if(len(set(S)) == 1):
    print(len(S) // 2 * K)
else:
    m = 0
    ans = 0
    if(S[0] == S[-1]):
        l = 0
        r = len(S) - 1
        while(S[l] == S[l+1]):
            l += 1
        while(S[-r] == S[-r-1]):
            r += 1
        m = l//2 + r//2 - (l+r)//2
        m *= K - 1

    for i in range(len(S)-1):
        if(S[i] == S[i+1]):
            ans += 1
            S[i+1] = "3"
    ans *= K
    ans -= m
    print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())

if(len(set(S)) == 1):
    print(len(S) // 2 * K)
else:
    m = 0
    ans = 0
    if(S[0] == S[-1]):
        l = 0
        r = len(S) - 1
        while(S[l] == S[l+1]):
            l += 1
        while(S[-r] == S[-r]):
            r += 1
        m = l//2 + r//2 - (l+r)//2
        m *= K - 1
    
    for i in range(len(S)-1):
        if(S[i] == S[i+1]):
            ans += 1
            S[i+1] = "3"
    ans *= K
    ans -= m
    print(ans)
Problem p02990 (python)

Fixed submission:

class FermatCombination():
    def __init__(self, size, mod):
        self.mod = mod
        self.factrial = [1]
        self.inverse = [1]
        for i in range(1, size + 1):
            self.factrial.append((self.factrial[i-1]*i) % self.mod)
            self.inverse.append(self.modpow(self.factrial[i], self.mod - 2) % self.mod)

    def modpow(self, x, n):
        ret = 1
        while(n > 0):
            if n & 1:
                ret = ret * x % self.mod
            x = x * x % self.mod
            n >>= 1
        return ret

    def combine(self, n, k):
        return self.factrial[n] * self.inverse[k] % self.mod * self.inverse[n - k] % self.mod


N, K = map(int, input().split())
mod = 10**9+7

fermat = FermatCombination(N + 2, mod)

for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        print(fermat.combine(N-K+1, i) * fermat.combine(K-1, i-1) % mod)

Buggy submission (verdict: Runtime Error):

class FermatCombination():
    def __init__(self, size, mod):
        self.mod = mod
        self.factrial = [1]
        self.inverse = [1]
        for i in range(1, size + 1):
            self.factrial.append((self.factrial[i-1]*i) % self.mod)
            self.inverse.append(self.modpow(self.factrial[i], self.mod - 2) % self.mod)

    def modpow(self, x, n):
        ret = 1
        while(n > 0):
            if n & 1:
                ret = ret * x % self.mod
            x = x * x % self.mod
            n >>= 1
        return ret

    def combine(self, n, k):
        return self.factrial[n] * self.inverse[k] % self.mod * self.inverse[n - k] % self.mod


N, K = map(int, input().split())
mod = 10**9+7

fermat = FermatCombination(N - K + 2, mod)

for i in range(1, K+1):
    print(fermat.combine(N-K+1, i) * fermat.combine(K-1, i-1))
Problem p03834 (python)

Fixed submission:
a = input().replace(",", " ")
print(a)

Buggy submission (verdict: Runtime Error):
a = input().split(',')
ans = ""
for i in a:
  ans += a[i] + " "
ans -= " "
print(ans)
Problem p03127 (python)

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

n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n-1):
    a[i+1]  = gcd(a[i], a[i+1])
print(a[n-1])

Buggy submission (verdict: Runtime Error):
def Gcd(a,b):
	if a<b:
		return Gcd(b,a)
	else:
		if a%b:
			return Gcd(b, a%b):
		else:
			return b
N = int(input())
arr = list(map(int,input().split()))
gcd = arr[0]
for i in arr:
	gcd = Gcd(gcd, i)
print(gcd)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
j = 0
A.sort()
for n in A:
	if n%2 == 1:
		j = 1
a = 0
for n in range(1, len(A)-1):
	if A[n] % A[0] == 1
		a = 1
if a == 0:
	j = 3
if A[0] == A[-1]:
	j = 2
if j == 0:
	print(2)
elif j == 1:
	print(1)
elif j == 3:
	print(A[0])
else:
	print(A[0])
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N < M:
	x = sorted(X)
	B = []
	for i in range(0, M-1):
		B.append(x[i+1]-x[i])
	B.sort(reverse=True)
	for l in range(N-1):
		B.pop(0)
	print(sum(B))
else:
	print(0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = list(map(int, input().split()))
x = sorted(X)
B = []
for i in range(0, M-1):
	B.append(x[i+1]-x[i])
B.sort(reverse=True)
for l in range(N-1):
	B.pop(0)
print(sum(B))
Problem p02729 (python)

Fixed submission:
from itertools import combinations

def main():
    n, m = map(int, input().split())

    ans = 0

    n_list = [i+1 for i in range(n)]
    m_list = [i+1 for i in range(m)]

    ans += len(list(combinations(n_list, 2)))
    ans += len(list(combinations(m_list, 2)))

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from scipy import special

def main():
    n, m = map(int, input().split())

    ans = 0
    ans += special.comb(n, 2)
    ans += special.comb(m, 2)

    print(int(ans))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from scipy import special

def main():
    n, m = map(int, input().split())

    ans = 0
    ans += special.comb(n, 2)
    ans += special.comb(m, 2)

    print(int(ans))

if __name__ == '__main__':
    main()
Problem p02881 (python)

Fixed submission:
def main():
    n = int(input())

    count = n + 1

    for i in range(1,int(n**0.5)+1):
        if n % i == 0 and n // i + i < count:
            count = n // i + i

    print(count-2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def main():
    n = int(input())

    count = n + 1

    ls = make_divisors(n)

    for i in range(len(ls)):
        if i % 2 != 0:
            continue
        if ls[i] + ls[i+1] < count:
            count = ls[i] + ls[i+1]

    print(count-2)

if __name__ == '__main__':
    main()
Problem p03107 (python)

Fixed submission:
def main():
    s = input()

    zero = s.count('0')
    one = len(s) - zero

    print(min(zero, one) * 2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()

    zero = s.count('0')
    one = len(s) - zero

    print(min(zero, one) *)

if __name__ == '__main__':
    main()
Problem p03242 (python)

Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    
    str_n = str(n)

    for i in range(3):
        if str_n[i] == '1':
            print(9,end='')
        else:
            print(1,end='')
        
    print()

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    
    str_n = str(n)

    for i in range(3):
        if str_n[i] == '1':
            print(9,end='')
        else:
            print(1,end='')
        
    print()

if __name__ == '__main__':
    main()
Problem p02550 (python)

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 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()
Problem p02598 (python)

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 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()
Problem p02793 (python)

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)]


# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        for j in range(root+1):
            if n % i == 0 and n != 0:
                cnt += 1
                n = n // i
            else:
                break
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()
    L = {}
    primes_a = {}
    for a in A:
        prime_a = prime_fact(a)
        primes_a[a] = prime_a
        for p, n in prime_a.items():
            L.setdefault(p, 0)
            L[p] = max(L[p], n)
    ans = 0
    l = 1
    for p, n in L.items():
        l = l * pow(p, n, MOD) % MOD

    for i, a in enumerate(A):
        ans += l * pow(a, MOD-2, MOD) % MOD
    print(ans % MOD)



if __name__ == "__main__":
    main()

Buggy 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)]


# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        for j in range(root+1):
            if n % i == 0 and n != 0:
                cnt += 1
                n = n // i
            else:
                break
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()
    L = {}
    primes_a = {}
    for a in A:
        prime_a = prime_fact(a)
        primes_a[a] = prime_a
        for p, n in prime_a.items():
            L.setdefault(p, 0)
            L[p] = max(L[p], n)
    ans = 0
    l = 1
    for p, n in L.items():
        l = l * pow(p, n, MOD) % MOD

    for i, a in enumerate(A):
        ans += l * pow(a, -1, MOD) % MOD
    print(ans % MOD)



if __name__ == "__main__":
    main()
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
c = [1,2,3]
c.remove(a)
c.remove(b)
print(c[0])

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(int(set(1,2,3)-set(a,b)))