Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
V_list = list(map(int, input().split()))

Vdic = [{}, {}]
# 0: even 1: odd
for i in range(len(V_list)):
    v = V_list[i]

    tmp = (i + 1) % 2
    Vdic[tmp][v] = Vdic[tmp].get(v, 0) + 1

even = sorted(Vdic[0].values())
odd = sorted(Vdic[1].values())

ans_even = [(-1, 0)]
ans_odd = [(-2, 0)]
if(len(even) == 1):
    t = max(Vdic[0], key=Vdic[0].get)
    ans_even.append((t, even[0]))
else:
    n1 = even[-1]
    n2 = even[-2]

    ans_even = [(k, v) for k, v in Vdic[0].items() if v == n1 or v == n2]

if(len(odd) == 1):
    t = max(Vdic[1], key=Vdic[1].get)
    ans_odd.append((t, odd[0]))
else:
    n1 = odd[-1]
    n2 = odd[-2]

    ans_odd = [(k, v) for k, v in Vdic[1].items() if v == n1 or v == n2]

# print(ans_even, ans_odd)

ans = []
for ke, ve in ans_even:
    for ko, vo in ans_odd:
        if(ke != ko):
            ans.append(n - ve - vo)

print(min(ans))

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

Vdic = [{}, {}]
# 0: even 1: odd
for i in range(len(V_list)):
    v = V_list[i]

    tmp = (i + 1) % 2
    Vdic[tmp][v] = Vdic[tmp].get(v, 0) + 1

even = sorted(Vdic[0].values())
odd = sorted(Vdic[1].values())

ans_even = [(-1, 0)]
ans_odd = [(-2, 0)]
if(len(even) == 1):
    t = max(Vdic[0], key=Vdic[0].get)
    ans_even.append((t, even[0]))
else:
    n1 = even[-1]
    n2 = even[-2]

    f1 = True
    f2 = True
    if(n1 == n2):
        for k, v in Vdic[0].items():
            if(v == n1):
                if(f1 is False and f2 is False):
                    continue
                if(f1 is False):
                    f2 = False
                f1 = False
                ans_even.append((k, v))
    else:
        for k, v in Vdic[0].items():
            if(v == n1 and f1 is True):
                f1 = False
                ans_even.append((k, v))
            if(v == n2 and f2 is True):
                f2 = False
                ans_even.append((k, v))

if(len(odd) == 1):
    t = max(Vdic[1], key=Vdic[1].get)
    ans_odd.append((t, odd[0]))
else:
    n1 = odd[-1]
    n2 = odd[-2]

    f1 = True
    f2 = True
    if(n1 == n2):
        for k, v in Vdic[1].items():
            if(v == n1):
                if(f1 is False and f2 is False):
                    continue
                if(f1 is False):
                    f2 = False
                f1 = False
                ans_odd.append((k, v))
    else:
        for k, v in Vdic[1].items():
            if(v == n1 and f1 is True):
                f1 = False
                ans_odd.append((k, v))
            if(v == n2 and f2 is True):
                f2 = False
                ans_odd.append((k, v))


# print(ans_even, ans_odd)

ans = []
for ke, ve in ans_even:
    for ko, vo in ans_odd:
        if(ke != ko):
            ans.append(n - ve - vo)

print(min(ans))
Buggy python submission (verdict: Runtime Error):
from math import gcd

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

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

tmp = abs(X[0] - K)
for i in range(1, N):
    tmp = gcd(tmp, abs(X[i] - K))

print(tmp)

Fixed submission:
def gcd(a, b):
    while(b != 0):
        amari = a % b

        a = b
        b = amari
    return(a)


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

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

tmp = abs(X[0] - K)
for i in range(1, N):
    tmp = gcd(tmp, abs(X[i] - K))

print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
mod = {}
last_mod = {}
for a in A:
    mod = {}
    # print(mod, last_mod)
    m = a % M
    for key in last_mod:
        mod[(key + m) % M] = last_mod[key]
    mod[m] = mod.get(m, 0) + 1

    # print(mod, last_mod)
    ans += mod.get(0, 0)

    last_mod = mod

print(ans)

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

ans = 0
mod = 0
mod_dic = {0: 1}
for a in A:
    mod = (mod + a) % M
    mod_dic[mod] = mod_dic.get(mod, 0) + 1

for v in mod_dic.values():
    ans += v * (v - 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(b in war):
        if(a > war[b]):
            war[b] = a
    else:
        war[b] = a

ans = 1
b_list = list(war.keys())
b_list = sorted(b_list)
r_bridge = b_list[0] - 1

while(True):
    # print(b_list)
    for b in b_list[:]:
        a = war[b]
        if(a <= r_bridge < b):
            b_list.remove(b)

    if(b_list != []):
        r_bridge = b_list[0] - 1
        ans += 1
    else:
        break

print(ans)

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

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(b in war):
        if(a > war[b]):
            war[b] = a
    else:
        war[b] = a

ans = 1
b_list = list(war.keys())
b_list = sorted(b_list)
r_bridge = b_list[0] - 1

for b in b_list:
    a = war[b]
    if(a <= r_bridge):
        continue
    else:
        r_bridge = b - 1
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(a in war):
        if(b < war[a]):
            war[a] = b
    else:
        war[a] = b

ans = 0
bridge = [0 for i in range(N - 1)]
for a, b in war.items():
    for i in range(a, b):
        bridge[i - 1] += 1

while(war != {}):
    # print(war)
    ans += 1
    index = bridge.index(max(bridge))
    # print(index)
    for a, b in list(war.items())[:]:
        if(a <= index + 1 < b):
            war.pop(a)
            for i in range(a, b):
                bridge[i - 1] -= 1

print(ans)

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

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(b in war):
        if(a > war[b]):
            war[b] = a
    else:
        war[b] = a

ans = 1
b_list = list(war.keys())
b_list = sorted(b_list)
r_bridge = b_list[0] - 1

for b in b_list:
    a = war[b]
    if(a <= r_bridge):
        continue
    else:
        r_bridge = b - 1
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(a in war):
        if(b < war[a]):
            war[a] = b
    else:
        war[a] = b

ans = 0

while(war != {}):
    # print(war)
    ans += 1
    bridge = [0 for i in range(N - 1)]
    for a, b in war.items():
        for i in range(a, b):
            bridge[i - 1] += 1
    index = bridge.index(max(bridge))
    # print(index)
    for a, b in list(war.items())[:]:
        if(a <= index + 1 < b):
            war.pop(a)

print(ans)

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

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(b in war):
        if(a > war[b]):
            war[b] = a
    else:
        war[b] = a

ans = 1
b_list = list(war.keys())
b_list = sorted(b_list)
r_bridge = b_list[0] - 1

for b in b_list:
    a = war[b]
    if(a <= r_bridge):
        continue
    else:
        r_bridge = b - 1
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
A_list = list(map(int, input().split()))

for i in range(N):
    A_list[i] = A_list[i] - i - 1

min_A = min(A_list)
max_A = max(A_list)

sadness = sys.maxsize
for b in range(min_A, max_A + 1):
    tmp_sadness = 0
    for A in A_list:
        tmp_sadness += abs(A - b)
    if(sadness > tmp_sadness):
        sadness = tmp_sadness

print(sadness)

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

for i in range(N):
    A_list[i] = A_list[i] - i - 1

A_list = sorted(A_list)
if(N % 2 == 0):
    key = N // 2
else:
    key = (N - 1) // 2
b = A_list[key]
sadness = 0

for A in A_list:
    sadness += abs(A - b)

print(sadness)
Buggy python submission (verdict: Runtime Error):
)
S = 0
for lit in str(N):
    S += int(lit)

if(N % S == 0):
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
S = 0
for lit in str(N):
    S += int(lit)

if(N % S == 0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0

for i in range(1,N):
    tmp_ans = len(set(N[0:i]) and set(N[i:]))
    if(tmp_ans>ans):
      ans=tmp_ans

print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(1, N):
    tmp_ans = len(set(S[0:i]) & set(S[i:]))
    if(tmp_ans > ans):
        ans = tmp_ans

print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)
X = int(input())
 
ans = 0
p = 2
A = set()
for i in range(X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)


Fixed submission:
X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
 
ans = 0
p = 2
A = set()
for i in range(X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

Fixed submission:
X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
 
ans = 0
p = 2
for i in range(X):
  p = 1
  while(True):
    p += 1
    if(i ** p <= X):
      tmp = i ** p
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

Fixed submission:
X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.sort()
K = int(input())
 
print(a[2]*(2**k) + a[1] + a[0])
a = list(map(int, input().split()))
a.sort()
K = int(input())

print(a[2]*(2**K) + a[1] + a[0])

Fixed submission:
a = list(map(int, input().split()))
a.sort()
K = int(input())
 
print(a[2]*(2**K) + a[1] + a[0])

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.sort()
K = int(input())

print(a[2]*(2**k) + a[1] + a[0])

Fixed submission:
a = list(map(int, input().split()))
a.sort()
K = int(input())
 
print(a[2]*(2**K) + a[1] + a[0])
Buggy python submission (verdict: Runtime Error):
A = [257, 2, 3, 131, 5, 7, 137, 11, 139, 13, 17, 19, 149, 23, 151, 29, 157, 31, 163, 37, 167, 41, 43, 173, 47, 179, 53, 181, 59, 61, 191, 193, 67, 197, 71, 199, 73, 79, 83, 211, 89, 223, 97, 227, 101, 229, 103, 233, 107, 109, 239, 113, 241, 251, 127]

N = int(input())

ans = ""
for i in range(N):
  ans += " " + A[i]
  
print(ans[1:])

Fixed submission:
N = int(input())

Prime = [2, ]
ans = []
i = 3

while(len(ans) < N):
    Pflag = True
    for p in Prime:
        if(i % p == 0):
            Pflag = False
            break

    if(Pflag is True):
        Prime.append(i)
        if(i % 5 == 1):
            ans.append(i)

    i += 2

S = ""
for p in ans:
    S += " " + str(p)

print(S[1:])
Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())

x_list = [0, ]
v_list = [0, ]
x_oa = [0, ]
x_2oa = [0, ]
max_a = {0: 0}
max_2a = {0: 0}

tmp_v = 0

for i in range(N):
    x, v = map(int, input().split())

    tmp_v += v

    x_list.append(x)
    v_list.append(v)
    x_oa.append(tmp_v - x)
    x_2oa.append(tmp_v - 2 * x)
    max_a[i + 1] = max(x_oa)
    max_2a[i + 1] = max(x_2oa)

x_list.append(C)
v_list.append(0)

tmp_v = 0
ans = 0
for i in reversed(range(1, N + 2)):

    x = x_list[i]
    v = v_list[i]
    tmp_v += v
    # print(x, v, i)

    tmp_oa = tmp_v - 2 * (C - x) + max_a[i - 1]
    tmp_2oa = tmp_v - C + x + max_2a[i - 1]
    ans = max(ans, tmp_oa, tmp_2oa)

print(ans)

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

x_list = [0, ]
v_list = [0, ]
x_oa = 0
x_2oa = 0
max_a = {0: 0}
max_2a = {0: 0}

tmp_v = 0

for i in range(N):
    x, v = map(int, input().split())

    tmp_v += v

    x_list.append(x)
    v_list.append(v)
    x_oa = max(tmp_v - x, x_oa)
    x_2oa = max(tmp_v - 2 * x, x_2oa)
    max_a[i + 1] = x_oa
    max_2a[i + 1] = x_2oa

x_list.append(C)
v_list.append(0)

tmp_v = 0
ans = 0
for i in reversed(range(1, N + 2)):

    x = x_list[i]
    v = v_list[i]
    tmp_v += v
    # print(x, v, i)

    tmp_oa = tmp_v - 2 * (C - x) + max_a[i - 1]
    tmp_2oa = tmp_v - C + x + max_2a[i - 1]
    ans = max(ans, tmp_oa, tmp_2oa)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())

x_list = [0, ]
v_list = [0, ]
x_oa = [0, ]
x_2oa = [0, ]

tmp_v = 0

for i in range(N):
    x, v = map(int, input().split())

    tmp_v += v

    x_list.append(x)
    v_list.append(v)
    x_oa.append(tmp_v - x)
    x_2oa.append(tmp_v - 2 * x)

x_list.append(C)
v_list.append(0)
x_oa.append(None)
x_2oa.append(None)

tmp_v = 0
ans = 0
for i in reversed(range(1, N + 2)):

    x = x_list[i]
    v = v_list[i]
    tmp_v += v
    # print(x, v, i)

    tmp_oa = tmp_v - 2 * (C - x) + max(x_oa[:i])
    tmp_2oa = tmp_v - C + x + max(x_2oa[:i])
    ans = max(ans, tmp_oa, tmp_2oa)

print(ans)

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

x_list = [0, ]
v_list = [0, ]
x_oa = 0
x_2oa = 0
max_a = {0: 0}
max_2a = {0: 0}

tmp_v = 0

for i in range(N):
    x, v = map(int, input().split())

    tmp_v += v

    x_list.append(x)
    v_list.append(v)
    x_oa = max(tmp_v - x, x_oa)
    x_2oa = max(tmp_v - 2 * x, x_2oa)
    max_a[i + 1] = x_oa
    max_2a[i + 1] = x_2oa

x_list.append(C)
v_list.append(0)

tmp_v = 0
ans = 0
for i in reversed(range(1, N + 2)):

    x = x_list[i]
    v = v_list[i]
    tmp_v += v
    # print(x, v, i)

    tmp_oa = tmp_v - 2 * (C - x) + max_a[i - 1]
    tmp_2oa = tmp_v - C + x + max_2a[i - 1]
    ans = max(ans, tmp_oa, tmp_2oa)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

max_a = max(A)

for i in reversed(range(max_a // 2 + 1)):
    # print(i)
    if(i in A):
        print(max_a, i)
        break
    elif((max_a - i) in A):
        print(max_a, max_a - i)
        break

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

max_a = max(A)
s_set = set()
l_set = set()
for a in A:
    if(a <= max_a//2):
        s_set.add(a)
    else:
        l_set.add(a)

s_max = max(s_set | {0})
l_min = min(l_set | {max_a})

if(s_max >= (max_a - l_min)):
    print(max_a, s_max)
else:
    print(max_a, l_min)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
 
for i in range(A, B+1):
  if(A+K>i or B-K<i):
    print(i)

Fixed submission:
A, B, K = map(int, input().split())
 
for i in range(A, A+K):
  if(i>B):
    break
  print(i)
for i in range(B-K+1, B+1):
  if(A+K>i):
    continue
  print(i)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())

print(min(A+B)+min(C+D))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
 
print(min(A,B)+min(C,D))
Buggy python submission (verdict: Runtime Error):
N = int(input())
card = {}
for i in range(N):
  S = input()
  card[S] = card.get(S, 0) + 1

M = int(input())
for i in range(M):
  S = input()
  card[S] = card.get(S, 0) - 1
  
print(max(max(list(card.values()),0))

Fixed submission:
N = int(input())
card = {}
for i in range(N):
  S = input()
  card[S] = card.get(S, 0) + 1
 
M = int(input())
for i in range(M):
  S = input()
  card[S] = card.get(S, 0) - 1

tmp = list(card.values())
tmp.append(0)
print(max(tmp))
Buggy python submission (verdict: Time Limit Exceeded):
def AppendQue(now, depth, que, past_visit, maze):
    Next = ((now[0] - 1, now[1]), (now[0], now[1] - 1),
            (now[0] + 1, now[1]), (now[0], now[1] + 1))
    for h, w in Next:
        if min(h, w) < 0:
            continue
        elif h >= H or w >= W:
            continue
        elif (h, w) in past_visit:
            continue
        elif maze[h][w] == "#":
            continue

        que.append(((h, w), depth + 1))


H, W = map(int, input().split())

maze = []
black = 0
for i in range(H):
    maze.append(input())
    black += maze[i].count("#")

if maze[0][0] == "#" or maze[H - 1][W - 1] == "#":
    print(-1)
    exit()

que = []
now = (0, 0)
depth = 1
que.append((now, depth))
past_visit = set()
while True:
    if len(que) == 0:
        print(-1)
        exit()
    (now, depth), que = que[0], que[1:]
    if now == (H - 1, W - 1):
        break
    past_visit.add(now)
    AppendQue(now, depth, que, past_visit, maze)

print(H * W - black - depth)

Fixed submission:
def AppendQue(now, depth, que, past_visit, maze):
    Next = ((now[0] - 1, now[1]), (now[0], now[1] - 1),
            (now[0] + 1, now[1]), (now[0], now[1] + 1))
    for h, w in Next:
        if h < 0 or w < 0 or h >= H or w >= W:
            continue
        elif (h, w) in past_visit:
            continue
        elif maze[h][w] == "#":
            continue
        elif (h, w) in que:
            continue

        que.append((h, w))
        depth[(h, w)] = depth[now] + 1


H, W = map(int, input().split())

maze = []
black = 0
for i in range(H):
    maze.append(input())
    black += maze[i].count("#")

if maze[0][0] == "#" or maze[H - 1][W - 1] == "#":
    print(-1)
    exit()

que = []
now = (0, 0)
depth = {}
depth[now] = 1
que.append(now)
past_visit = set()
while True:
    if len(que) == 0:
        print(-1)
        exit()
    now, que = que[0], que[1:]
    if now == (H - 1, W - 1):
        break
    past_visit.add(now)
    AppendQue(now, depth, que, past_visit, maze)

print(H * W - black - depth[(H - 1, W - 1)])
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include<set>
#include<math.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    set <int> s;
    int tmp;
    
    rep(i, N){
        cin >> tmp;
        s.insert(tmp);
    }
    cout << s.size() << endl;

    return 0;
}

Fixed submission:
from collections import Counter

def inpl(): return list(map(int, input().split()))


N = int(input())
print(len(Counter([int(input()) for _ in range(N)])))
Buggy python submission (verdict: Runtime Error):
S = input()
print("Yes" if s[0]==s[1]==s[2] or s[1]==s[2]==s[3] else "No")

Fixed submission:
S = input()
print("Yes" if S[0]==S[1]==S[2] or S[1]==S[2]==S[3] else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
print(len(list(filter(lambda x: A.count(x)%2==1, set(A)))))

Fixed submission:
from collections import Counter

n = int(input())
A = [int(input()) for _ in range(n)]
ans = 0
for k, v in Counter(A).items():
    if v % 2 == 0:
        continue
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def factoring(n):
    if n == 1:
        return dict()
    p = 2
    tmp1 = int(n**0.5)
    ret = {}
    tmp = 0
    while n != 1:
        if n % p == 0:
            n //= p
            tmp += 1
        elif p > tmp1:
            ans_dic[p] = max(ans_dic.get(p, 0), tmp)
            p = n
            tmp = 0
        else:
            ans_dic[p] = max(ans_dic.get(p, 0), tmp)
            p += 1
            tmp = 0
    ans_dic[p] = max(ans_dic.get(p, 0), tmp)
    return ret


N = int(input())
A = [int(input()) for _ in range(N)]
ans_dic = {}
for a in A:
    factoring(a)

ret = 1
for k, v in ans_dic.items():
    ret *= k**v
print(ret)

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


N = int(input())
A = [int(input()) for _ in range(N)]

ans = 1
for a in A:
    ans = a * ans // gcd(a, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def factoring(n):
    if n == 1:
        return dict()
    p = 2
    tmp = int(n**0.5)
    ret = {}
    while n != 1:
        if n % p == 0:
            n //= p
            ret[p] = ret.get(p, 0) + 1
        elif p > tmp:
            p = n
        else:
            p += 1
    return ret
            

def func(ans, b):
    B = factoring(b)
    # print(ans, B)
    return {i:max(ans.get(i, 0), B.get(i, 0)) for i in set(ans) | set(B)}

N = int(input())
A = [int(input()) for _ in range(N)]
ans = {}
for a in A:
    ans = func(ans, a)

ret = 1
for k, v in ans.items():
    ret *= k**v
print(ret)

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


N = int(input())
A = [int(input()) for _ in range(N)]

ans = 1
for a in A:
    ans = a * ans // gcd(a, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
def func(i=0, ans=0):
    if B[i] is True:
        return -1
    else:
        B[i] = True
    
    ans += 1
    if A[i] != 1:
        return func(A[i], ans)
    else:
        return ans



n = int(input())
A = [int(input())-1 for i in range(n)]
B = [False] * n
print(func())

Fixed submission:
n = int(input())
A = [int(input())-1 for i in range(n)]
B = [False] * n
ans = 0
i = 0
while True:
    if B[i] is True:
        print(-1)
        break
    else:
        B[i] = True
    
    ans += 1
    if A[i] != 1:
        i = A[i]
    else:
        print(ans)
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0] * 9
for a in list(map(int, input().split())):
    A[min(a//400, 9)] += 1

ans = 0
for a in A[:-1]:
    ans += int(a>0)
max_ans = min(ans+A[-1], 8)

if A[-1] > 0:
    min_ans = max(1, ans)
else:
    min_ans = ans
print(min_ans, end=" ")
print(max_ans)

Fixed submission:
N = int(input())
A = [0] * 9
for a in list(map(int, input().split())):
    A[min(a//400, 8)] += 1

ans = len(list(filter(lambda x: x>0, A[:-1])))

max_ans = ans+A[-1]

if A[-1] > 0:
    min_ans = max(1, ans)
else:
    min_ans = ans
print(min_ans, end=" ")
print(max_ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

print(a[0].upper()+b[0].upper()+c[0].upper())

Fixed submission:
a, b, c = input().split()
 
print(a[0].upper()+b[0].upper()+c[0].upper())