Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [[0]*10 for _ in range(n)]
ans = 0
for i in range(n):
    str_s = input()
    for j in range(10):
        s[i][j] = str_s[j]

for i in range(n):
    s[i].sort()
    s[i] = tuple(s[i])
set_s = set(s)

if n-len(set_s) == 0:
    print(0)
elif n-len(set_s) == 1:
    print(n-len(set_s))
else:
    for item in set_s:
        count = 0
        for j in range(n):
            if item == s[j]:
                count += 1
        ans += count*(count-1)//2
    print(ans)

Fixed submission:
from collections import Counter
n = int(input())
s = [[0]*10 for _ in range(n)]
ans = 0
for i in range(n):
    str_s = input()
    for j in range(10):
        s[i][j] = str_s[j]

dict_s = {}
for i in range(n):
    s[i].sort()
    si = "".join(s[i])
    dict_s.setdefault(si, 0)
    dict_s[si] += 1

for x in dict_s.values():
    ans += x*(x-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [[0]*10 for _ in range(n)]
ans = 0
for i in range(n):
    str_s = input()
    for j in range(10):
        s[i][j] = str_s[j]

for i in range(n):
    s[i].sort()
    s[i] = tuple(s[i])
set_s = set(s)


for item in set_s:
    count = 0
    for j in range(n):
        if item == s[j]:
            count += 1
    ans += count*(count-1)//2
print(ans)




Fixed submission:
from collections import Counter
n = int(input())
s = [[0]*10 for _ in range(n)]
ans = 0
for i in range(n):
    str_s = input()
    for j in range(10):
        s[i][j] = str_s[j]

dict_s = {}
for i in range(n):
    s[i].sort()
    si = "".join(s[i])
    dict_s.setdefault(si, 0)
    dict_s[si] += 1

for x in dict_s.values():
    ans += x*(x-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
d = a-b
if c <= d:
    print(0)
elif:
    print(c-d)


Fixed submission:
a, b, c = map(int, input().split())
d = a-b
if c <= d:
    print(0)
else:
    print(c-d)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
n = int(input())
a = [int(input()) for _ in range(n)]

LIS = []  # LISの中身は、LISの最小の数字を保持する
LIS.append(a[0])
for i in range(1, n):
    idx = bisect_left(LIS, a[i])
    if idx == 0:
        LIS = [a[i]] + LIS
    else:
        LIS[idx-1] = a[i]
print(len(LIS))

Fixed submission:
from bisect import bisect_left
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]

LIS = deque()  # LISの中身は、LISの最小の数字を保持する
LIS.append(a[0])
for i in range(1, n):
    idx = bisect_left(LIS, a[i])
    if idx == 0:
        LIS.appendleft(a[i])
    else:
        LIS[idx-1] = a[i]
print(len(LIS))
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b, c, d = map(int, input().split())
ans = b-a+1

amari_ac = a % c
amari_ad = a % d
if amari_ac == 0:
    c_min = a
else:
    c_min = a+c - amari_ac
if amari_ad == 0:
    d_min = a
else:
    d_min = a+d - amari_ad

amari_bc = b % c
amari_bd = b % d
c_max = b-amari_bc
d_max = b-amari_bd

c_count = (c_max-c_min)//c + 1
d_count = (d_max-c_min)//d + 1

lcm_cd = c*d // gcd(c, d)
amari_acd = a % lcm_cd
if amari_acd == 0:
    cd_min = a
else:
    cd_min = a+lcm_cd - amari_acd

amari_bcd = b % lcm_cd
cd_max = b - amari_bcd

cd_count = (cd_max-cd_min)//lcm_cd + 1

if cd_max < a or b < cd_max:
    cd_count = 0
if cd_min < a or cd_min > b:
    cd_count = 0

print(ans-c_count-d_count+cd_count)


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

under_a = (a-1)//c + (a-1)//d - (a-1)//lcm_cd
under_b = b//c + b//d - b//lcm_cd
print(ans-(under_b-under_a))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
mod = 10**9 + 7

dp = [0]*(n+1)
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
else:
    dp[1] = 0
for i in range(1, m):
    dp[a[i]] = -1
for i in range(n-1):
    if dp[i+2] == -1:
        dp[i+2] = 0
    elif dp[i+2] == 0:
        dp[i+2] = (dp[i+1] + dp[i]) % mod
print(dp[n] % mod)

Fixed submission:
n, m = map(int, input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
mod = 10**9 + 7

dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1
for i in range(m):
    dp[a[i]] = 0
#print(dp)
for i in range(n-1):
    if dp[i+2] == -1:
        dp[i+2] = (dp[i+1] + dp[i]) % mod
    elif dp[i+2] == 0:
        dp[i+2] = 0
#print(dp)
print(dp[n] % mod)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import heapq
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0
min_nk = min(n, k)
for l in range(k+1):
    if k-l > 0:
        for r in range(k-l+1):
            hand = []
            for i in range(1, l+1):
                hand.append(v[i-1])
            for i in range(1, r+1):
                hand.append(v[n-i])
            hand.sort()
            if k-l-r > 0:
                for back in range(k-l-r):
                    if len(hand) != 0:
                        if min(hand) < 0:
                            x = hand.index(min(hand))
                            hand[x] = 0
                ans = max(ans, sum(hand))
print(ans)

Fixed submission:
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0
min_nk = min(n, k)
for l in range(min_nk+1):
    for r in range(min_nk-l+1):
        hand = []
        for i in range(l):
            hand.append(v[i])
        for i in range(r):
            hand.append(v[n-1-i])
        hand.sort()
        
        for i in range(min(k-l-r, len(hand))):
            if hand[i] < 0:
                hand[i] = 0
        ans = max(ans, sum(hand))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    b, c = map(int, input().split())
    count = 0
    while count < b:
        a.append(c)
        count += 1
a.sort(reverse=True)
print(sum(a[:n]))

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(m):
    b, c = map(int, input().split())
    l.append((b, c))
for i in a:
    l.append((1, i))
l.sort(key=lambda x: x[1], reverse=True)
#print(l)
count = n
ans = 0
for item in l:
    b, c = item
    ans += c*min(b, count)
    count -= b
    if count <= 0:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
for i in range(m):
    b, c = map(int, input().split())
    count = 0
    while count < b:
        x = heapq.heappop(a)
        if x < c:
            heapq.heappush(a, c)
            count += 1
        elif x >= c:
            heapq.heappush(a, x)
            break
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(m):
    b, c = map(int, input().split())
    l.append((b, c))
for i in a:
    l.append((1, i))
l.sort(key=lambda x: x[1], reverse=True)
#print(l)
count = n
ans = 0
for item in l:
    b, c = item
    ans += c*min(b, count)
    count -= b
    if count <= 0:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
"""ナイーブ
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))
"""

ac_li = []
for i in range(n-1):
    if s[i] + s[i+1] == "AC":
        ac_li.append([i, i+1])
#print(ac_li)
for i in range(q):
    ans = 0
    l, r = map(int, input().split())
    for j in ac_li:
        if set(range(l-1, r)) & set(j) == set(j):
            ans += 1
    print(ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
"""ナイーブ
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))
"""
# 前処理＋全探索
# 区間なので累積和を疑う
t = [0]*n
count = 0
for i in range(n-1):
    t[i] = count
    if s[i] + s[i+1] == "AC":
        count += 1
    t[i+1] = count
#print(t)
for i in range(q):
    l, r = map(int, input().split())
    ans = t[r-1] - t[l-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l, r = [0]*q, [0]*q
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
n, q = map(int, input().split())
s = input()
"""ナイーブ
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))
"""
# 前処理＋全探索
# 区間なので累積和を疑う
t = [0]*n
count = 0
for i in range(n-1):
    t[i] = count
    if s[i] + s[i+1] == "AC":
        count += 1
    t[i+1] = count
#print(t)
for i in range(q):
    l, r = map(int, input().split())
    ans = t[r-1] - t[l-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
a, b, q = map(int, input().split())
s, t = [0]*(a+2), [0]*(b+2)
for i in range(a):
    s[i+1] = int(input())
for i in range(b):
    t[i+1] = int(input())

s[0] = -float("inf")
s[-1] = float("inf")
t[0] = -float("inf")
t[-1] = float("inf")
#print(s)
#print(t)
for _ in range(q):
    start = int(input())
    x = bisect.bisect_right(s, start)
    y = bisect.bisect_right(t, start)
    ans = float("inf")
    for i in [s[x], s[x-1]]:
        for j in [t[y], t[y-1]]:
            res = min(abs(i-start) + abs(j-i), abs(j-start) + abs(i-j))
            ans = min(ans, res)
    print(ans)

Fixed submission:
import bisect
a, b, q = map(int, input().split())
inf = 10**18
s = [-inf] + [int(input()) for _ in range(a)] + [inf]
t = [-inf] + [int(input()) for _ in range(b)] + [inf]
#print(s)
#print(t)
for _ in range(q):
    start = int(input())
    x = bisect.bisect_right(s, start)
    y = bisect.bisect_right(t, start)
    ans = inf
    for i in [s[x], s[x-1]]:
        for j in [t[y], t[y-1]]:
            res = min(abs(i-start) + abs(j-i), abs(j-start) + abs(i-j))
            ans = min(ans, res)
    print(ans)
Buggy python submission (verdict: Runtime Error):
from fractions import math
n = int(input())
a = list(map(int, input().split()))
min_mod = min(a)
flag = True
b = math.gcd(a[0], a[1])
for i in range(2, n):
    b = math.gcd(a[i], b)
print(b)

Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
flag = True
b = gcd(a[0], a[1])
for i in range(2, n):
    b = gcd(a[i], b)
print(b)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp(n-1))

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
from math import gcd
n, start = map(int, input().split())
x = list(map(int, input().split()))

x.append(start)
x.sort()

distance = []
for i in range(n):
    dis = abs(x[i+1] - x[i])
    distance.append(dis)
if len(distance) == 1:
    D = distance[0]
else:
    D = gcd(distance[0], distance[1])
    for i in range(2, n):
        D = gcd(D, distance[i])
print(D)

Fixed submission:
from fractions import gcd
n, start = map(int, input().split())
x = list(map(int, input().split()))

x.append(start)
x.sort()

distance = []
for i in range(n):
    dis = abs(x[i+1] - x[i])
    distance.append(dis)
if len(distance) == 1:
    D = distance[0]
else:
    D = gcd(distance[0], distance[1])
    for i in range(2, n):
        D = gcd(D, distance[i])
print(D)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True

for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()

Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = []
memo_tate = []
for i in range(h):
    if "#" in a[i]:
        memo_yoko.append(i)

for j in range(w):
    if any(a[i][j] == "#" for i in range(h)):
        memo_tate.append(j)
#print(memo_yoko)
#rint(memo_tate)
for i in memo_yoko:
    for j in memo_tate:
        print(a[i][j], end="")
    print()

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True
for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()

Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = []
memo_tate = []
for i in range(h):
    if "#" in a[i]:
        memo_yoko.append(i)

for j in range(w):
    if any(a[i][j] == "#" for i in range(h)):
        memo_tate.append(j)
#print(memo_yoko)
#rint(memo_tate)
for i in memo_yoko:
    for j in memo_tate:
        print(a[i][j], end="")
    print()

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True
for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()

Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = []
memo_tate = []
for i in range(h):
    if "#" in a[i]:
        memo_yoko.append(i)

for j in range(w):
    if any(a[i][j] == "#" for i in range(h)):
        memo_tate.append(j)
#print(memo_yoko)
#rint(memo_tate)
for i in memo_yoko:
    for j in memo_tate:
        print(a[i][j], end="")
    print()
Buggy python submission (verdict: Runtime Error):
for i in range(1, n+1):
    if i % 2 == 1:
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
            else:
                continue
        if count == 8:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
count = 0
ans = 0
for i in range(1, n+1):
    if i % 2 == 1:
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1
        else:
            continue
    else:
        continue
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
na = [0]*n
for i in range(n):
    na[i] = a[i]-(i+1)
mid = sum(na)//n
mid1 = mid+1
ans = 0
ans1 = 0
for i in range(n):
    ans += abs(na[i]-mid)
    ans1 += abs(na[i]+mid1)
print(min(ans, ans1))

Fixed submission:
n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(2*n)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
substr = []
for j in range(1, k+1):
    for i in range(n-j):
        sub = s[i:i+j]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])


Fixed submission:

s = input()
n = len(s)
k = int(input())
substr = []
for j in range(k):
    for i in range(n-j):
        sub = s[i:i+j+1]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
s = input()
n = len(s)
k = int(input())
ij = list(combinations(range(n+1), 2))
#print(ij)
substr = []
for i, j in ij:
    if j > i+k:
        continue
    sub = s[i:j]
    if sub not in substr:
        substr.append(s[i:j])
substr.sort()
print(substr[k-1])


Fixed submission:

s = input()
n = len(s)
k = int(input())
substr = []
for j in range(k):
    for i in range(n-j):
        sub = s[i:i+j+1]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
s = input()
n = len(s)
k = int(input())
ij = list(combinations(range(n+1), 2))
#print(ij)
substr = []
for i, j in ij:
    sub = s[i:j]
    if sub not in substr:
        substr.append(s[i:j])
substr.sort()
print(substr[k-1])


Fixed submission:

s = input()
n = len(s)
k = int(input())
substr = []
for j in range(k):
    for i in range(n-j):
        sub = s[i:i+j+1]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


for _ in range(q):
    l, r = map(int, input().split())
    count = 0
    prime_list = primes(r+1)
    #print(prime_list)
    for p in prime_list:
        if p >= l:
            pp = (p+1)//2
            if pp in prime_list:
                count += 1
    print(count)


Fixed submission:
q = int(input())


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


prime_list = primes(100000)
familiar = [0]*100001
for p in prime_list:
    if (p+1)//2 in prime_list:
        familiar[p] = 1
s = [0]*100001
for i in range(100000):
    s[i+1] = s[i] + familiar[i+1]


for _ in range(q):
    l, r = map(int, input().split())
    print(s[r]-s[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


for _ in range(q):
    l, r = map(int, input().split())
    count = 0
    for i in range(l, r+1)[::2]:
        if is_prime(i):
            j = (i+1)//2
            if is_prime(j):
                count += 1
    print(count)


Fixed submission:
q = int(input())


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


prime_list = primes(100000)
familiar = [0]*100001
for p in prime_list:
    if (p+1)//2 in prime_list:
        familiar[p] = 1
s = [0]*100001
for i in range(100000):
    s[i+1] = s[i] + familiar[i+1]


for _ in range(q):
    l, r = map(int, input().split())
    print(s[r]-s[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
syurui = len(set(a))
#print(syurui)
c = Counter(a)
ans = 0
for i in range(1, syurui-k + 1):
    ans += c.most_common()[-i][1]
print(ans)

Fixed submission:
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
syurui = len(set(a))
#print(syurui)
c = Counter(a)
ans = 0
c_sort = c.most_common()
#print(c_sort)
for i in range(1, syurui-k + 1):
    ans += c_sort[-i][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in a:
    j_idx = bisect_left(b, i)
    if j_idx == n:
        continue
    for j in b[j_idx:]:
        if i == j:
            continue
        k_idx = bisect_left(c, j)
        if j == c[k_idx]:
            k_idx += 1
        if k_idx == n:
            continue
        ans += (n-k_idx)
print(ans)



Fixed submission:
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0

for j in b:
    i = bisect_left(a, j)
    k = bisect_right(c, j)
    ans += i*(n-k)
    #print(j, a, i)
    #print(j, c, k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())

def is_able(n, m):
    res = [0]
    for i in range(1, n+1):
        for j in range(1, m+1):
            count = 0
            count += i*j
            count += (n-i)*(m-j)
            if count not in res:
                res.append(count)
    return res


if k in is_able(n, m):
    print("Yes")
else:
    print("No")

Fixed submission:
from collections import defaultdict
n, m, k = map(int, input().split())

def is_able(n, m, k):
    res = defaultdict(bool)
    res[0] = True
    for i in range(1, n+1):
        for j in range(1, m+1):
            count = 0
            count += i*j
            count += (n-i)*(m-j)
            res[count] = True
    return res[k]


if is_able(n, m, k):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t1 = int(input())
for _ in range(n-1):
    t2 = int(input())
    ans = t1*t2 // math.gcd(t1, t2)
    t1 = ans
print(ans)


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


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

n = int(input())
t1 = int(input())
ans = t1
for _ in range(n-1):
    t2 = int(input())
    ans = lcm(ans, t2)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t1 = int(input())
for _ in range(n-1):
    t2 = int(input())
    ans = t1*t2 // math.gcd(t1, t2)
    t1 = ans
print(ans)


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


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

n = int(input())
t1 = int(input())
ans = t1
for _ in range(n-1):
    t2 = int(input())
    ans = lcm(ans, t2)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
t1 = int(input())
for _ in range(n-1):
    t2 = int(input())
    ans = t1*t2 // math.gcd(t1, t2)
print(ans)


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


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

n = int(input())
t1 = int(input())
ans = t1
for _ in range(n-1):
    t2 = int(input())
    ans = lcm(ans, t2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
flag = True
if n % 2 == 1:
    if a.count(0) != 1:
        flag = False
    for i in range(1, n//2+1):
        if a.count(i*2) != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n//2):
        if a.count(i*2+1) != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
flag = True
c = Counter(a)
#print(c)
if n % 2 == 1:
    if c[0] != 1:
        flag = False
    for i in range(1, n//2+1):
        if c[i*2] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n//2):
        if c[i*2+1] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)