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

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(q):
    x = int(input())
    b, d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
    print(res)

Fixed submission:
import bisect

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(Q):
    x = int(input())
    b, d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
    print(res)

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

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(q):
    x = int(input())
    b,d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
print(res)

Fixed submission:
import bisect

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(Q):
    x = int(input())
    b, d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
    print(res)
Buggy python submission (verdict: Runtime Error):
import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]*b
    else:
        continue
print(ans)import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]*b
    else:
        continue
print(ans)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]**b
    else:
        continue
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for i in range(n)]

p.sort()
print(sum(p) - int(a[-1]/2))

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
print(int(max(a)*0.5+sum(a)-max(a)))
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
burger = []
for i in range(n+1):
    if i == 0:
        burger.append("p")
    else:
        burger.append("b" + burger[i-1] + "p" + burger[i-1] + "b")
s = str(burger[n])
layer = s[:x]
print(layer.count("p"))

Fixed submission:
n,x = map(int, input().split())
a = [1]
p = [1]
for i in range(n):
    a.append(a[i]*2 + 3)
    p.append(p[i]*2 + 1)

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=1 + a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1] + 1 + f(n-1,x-2-a[n-1])

print(f(n,x))
Buggy python submission (verdict: Runtime Error):
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)

Fixed submission:
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
ans = 0
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

dict_st = {}
dict_st = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y 
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y]=x
    else:
        if dict_ts[y]!=x:
            print("No")
            break
else:
    print("Yes")

Fixed submission:
import collections
s = input()
t = input()
s = collections.Counter(s)
t = collections.Counter(t)
if sorted(s.values()) == sorted(t.values()):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
t = str(input())
ans = "Yes"
for i in range(len(s)):
    if s.count(s[i])!=t.count(t[i]):
        ans = "No"
        break
    else:
        continue
print(ans)

Fixed submission:
import collections
s = input()
t = input()
s = collections.Counter(s)
t = collections.Counter(t)
if sorted(s.values()) == sorted(t.values()):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
import collections
s = input()
t = input()
s = collections.Counter(s)
t = collections.Counter(t)
if sorted(s.values()) == sorted(t.values):
  print("Yes")
else:
  print("No")

Fixed submission:
import collections
s = input()
t = input()
s = collections.Counter(s)
t = collections.Counter(t)
if sorted(s.values()) == sorted(t.values()):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = []
for i in range(n):
    item = str(input())
    if i == 0:
        w.append(item)
    elif i!=0:
        if w[i-1][-1]==item[0]:
            w.append(item)
        else:
            print("No")
            end()
l = set(w)
if len(l)==len(w):
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
w = []
for i in range(n):
    item = str(input())
    if i == 0:
        w.append(item)
    elif i!=0:
        if w[i-1][-1]==item[0]:
            w.append(item)
        elif w[i-1][-1]!=item[0]:
            print("No")
            exit()
l = set(w)
if len(l)==len(w):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n,x = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
y = [ x[i]-x[i-1] for i in range(1,n)]
d = gcd(y[1], y[0])
for i in range(2,n-1):
    d = gcd(d, y[i])
print(d)

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

n,X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n==1:
    print(abs(x[0]-X))
    exit()
y = [ x[i]-x[i-1] for i in range(1,n)]
d = abs(X-x[0])
for i in range(n-1):
    d = gcd(d, y[i])
print(d)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
count0 = 0
count1 = 0
for i in range(1,n+1):
    if i%k==0:
        count0+=1
    if i%k==k/2:
        count+=1

if k%2==0:
    print(count0**3+count1**3)
else:
    print(count0**3)

Fixed submission:
n,k = map(int, input().split())
count0 = 0
count1 = 0
for i in range(1,n+1):
    if i%k==0:
        count0 +=1
    if i%k==k/2:
        count1 +=1

if k%2==0:
    print(count0**3+count1**3)
else:
    print(count0**3)
Buggy python submission (verdict: Runtime Error):
INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k):
    if x[i]*x[i+k-1]<0:
        a = abs(x[i])+x[i+k-1] + min(abs(x[i], x[i+k-1]))
    else:
        a = abs(x[i+k-1])
    
    ans = min(ans, a)

if k==1:
    ans = abs(x[0])
print(ans)

Fixed submission:
INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k+1):
    if x[i]*x[i+k-1]>=0:
        ans = min(ans, max(abs(x[i]), abs(x[i+k-1])))
    else:
        a = min(abs(x[i]), abs(x[i+k-1]))
        b = max(abs(x[i]), abs(x[i+k-1]))
        ans = min(ans, a*2+b)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split())
print(sum(a)-n)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = sum(a) - n
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
INF = 1e9
n = int(input())
s = list(input())
ew = [0]*n
ans = INF

for i in range(n):
    a = s[:i].count("W")
    b = s[i+1:n].count("E")
    ans = min(ans, a+b)
print(ans)

Fixed submission:
INF = 1e9
n = int(input())
s = list(input())
sum_1 = [0]*(n+1)
for i in range(n):
    if s[i]=="E":
        sum_1[i+1] = sum_1[i]+1
    else:
        sum_1[i+1] = sum_1[i]

ans = INF
for i in range(n):
    a = i-sum_1[i] + sum_1[n]-sum_1[i+1]
    ans = min(ans, a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
ew = [0]*n

for i in range(n):
    if s[i]=="E":
        ew[i]+=1
    else:
        continue

ans = [0]*n
for i in range(n):
    a = sum(ew[0:i])
    b = sum(ew[i+1:n])
    ans[i] = i-a+b
print(min(ans))

Fixed submission:
INF = 1e9
n = int(input())
s = list(input())
sum_1 = [0]*(n+1)
for i in range(n):
    if s[i]=="E":
        sum_1[i+1] = sum_1[i]+1
    else:
        sum_1[i+1] = sum_1[i]

ans = INF
for i in range(n):
    a = i-sum_1[i] + sum_1[n]-sum_1[i+1]
    ans = min(ans, a)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
k = int(input())
a = []
for i in range(len(s)):
    for j in range(i,len(s)):
        a.append(s[i:j+1])
a = list(set(a))
a.sort()
print(a[k-1])

Fixed submission:
s = str(input())
k = int(input())
a = []
for i in range(len(s)):
    for j in range(1,k+1):
        if i+j>len(s):
            break
        a.append(s[i:i+j])
a = list(set(a))
a.sort()
print(a[k-1])
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
ans = "Yes"
c = [0]*(w+2)
s = c
for i in range(h):
    S = ["0"]
    S1 = list(input())
    S.append(S1)
    S.append("0")
    s.append(S)
s.append(c)

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)

Fixed submission:
h, w = map(int, input().split())
ans = "Yes"
c = ["0"]*(w+2)
s = []
s.append(c)
for i in range(h):
    S = ["0"]
    S1 = list(input())
    S1.append("0")
    S = S+S1
    s.append(S)
s.append(c)

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
ans = "Yes"
s = []
for i in range(h):
    S = list(input())
    s.append(S)

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)

Fixed submission:
h, w = map(int, input().split())
ans = "Yes"
c = ["0"]*(w+2)
s = []
s.append(c)
for i in range(h):
    S = ["0"]
    S1 = list(input())
    S1.append("0")
    S = S+S1
    s.append(S)
s.append(c)

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


n = int(input())
a = list(map(int, input().split()))
a.sort()
index = bisect.bisect_left(a,a[-1]//2)
x = combinations_count(a[-1],a[index])
y = combinations_count(a[-1],a[index-1])
if x>y:
    print(a[-1],a[index])
else:
    print(a[-1],a[index-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
for i in range(n-1):
    b.append([abs(a[-1]/2 -a[i]),a[i]])
b.sort()
print(a[-1],b[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


n = int(input())
a = list(map(int, input().split()))
a.sort()
index = bisect.bisect_left(a,a[-1]//2)
x = combinations_count(a[-1],a[index])
y = combinations_count(a[-1],a[index-1])
if x>y:
    print(a[-1],a[index])
else:
    print(a[-1],a[index-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
for i in range(n-1):
    b.append([abs(a[-1]/2 -a[i]),a[i]])
b.sort()
print(a[-1],b[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

def cmb(n,r):
    if r > n:
        return 0
    if n - r < r:
         r = n - r
    if r > n:
        return 0
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n = int(input())
a = list(map(int, input().split()))
a.sort()
index = bisect.bisect_left(a,a[-1]//2)
x = cmb(a[-1],a[index])
y = cmb(a[-1],a[index-1])
if x>y:
    print(a[-1],a[index])
else:
    print(a[-1],a[index-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
for i in range(n-1):
    b.append([abs(a[-1]/2 -a[i]),a[i]])
b.sort()
print(a[-1],b[0][1])
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
ans = (n-2)(m-2)
print(ans)

Fixed submission:
n,m = map(int, input().split())
ans = (n-2)*(m-2)
print(abs(ans))
Buggy python submission (verdict: Runtime Error):
s = list(int(input()))
ans = sum(s)
print(ans)

Fixed submission:
s = list(input())
for i in range(3):
    s[i] = int(s[i])
print(sum(s))
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.sort(reversed=True)
ans = 0

for i in range(k):
    ans += number[i]
ans = n-ans
print(ans)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.sort(reverse=True)
ans = 0

for i in range(k):
    ans += number[i]
ans = n-ans
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.remove(0)
number.sort()
ans = 0

if len(number)<=k:
    print(0)
else:
    for i in range(len(number)-k):
        ans += number[i]
    print(ans)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.sort(reverse=True)
ans = 0

for i in range(k):
    ans += number[i]
ans = n-ans
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.remove(0)
number.sort()
ans = 0

if len(number)<=k:
    print(0)
else:
    for i in range(len(number)-k):
        ans += number[i]
    print(ans)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.sort(reverse=True)
ans = 0

for i in range(k):
    ans += number[i]
ans = n-ans
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
for i in range(2**3):
    f = (s[0])
    for j in range(3):
        if (i>>j)&1:
            f = f "+"
        else:
            f = f + "-"
        f = f + s[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()

Fixed submission:
s = list(input())
ans = 0
for i in range(2**(3)):
    f = (s[0])
    for j in range(3):
        if i&(1<<j):
            f = f+"+"
        else:
            f = f+"-"
        f = f+s[j+1]
    if eval(f)==7:
        print(f+"=7")
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
aset = set(a)
b = []
c = []
for i in aset:
    if a.count(i)>1:
        b.append(i)
    
    if a.count(i)>3:
        c.append(i)
b.sort()
c.sort()
m = len(b)
if m<2:
    if len(c)<1:
        print(0)
    else:
        print(c[-1]*c[-1])
else:
    if len(c)<1:
        print(b[-1]*b[-2])
    else:
        ans = max(b[-2]*b[-1],c[-1]*c[-1])
        print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 1
j = 1
l = []
while i<n:
    if a[i]==a[i-1]:
        l.append(a[i])
        i+=2
    else:
        i+=1
l.append(0)
l.append(0)
print(l[0]*l[1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
aset = set(a)
b = []
c = []
for i in aset:
    if a.count(i)>1:
        b.append(i)
    
    if a.count(i)>3:
        c.append(i)
b.sort()
c.sort()
m = len(b)
if m<2:
    if len(c)<1:
        print(0)
    else:
        print(c[-1]*c[-1])
else:
    if len(c)<1:
        print(b[-1]*b[-2])
    else:
        ans = max(b[-2]*b[-1],c[-1]*c[-1])
        print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 1
j = 1
l = []
while i<n:
    if a[i]==a[i-1]:
        l.append(a[i])
        i+=2
    else:
        i+=1
l.append(0)
l.append(0)
print(l[0]*l[1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [ x for x in set(a) if a.count(x)>1]
c = [ x for x in set(a) if a.count(x)>3]
b.sort()
c.sort()
m = len(b)
if m<2:
    if len(c)<1:
        print(0)
    else:
        print(c[-1]*c[-1])
else:
    if len(c)<1:
        print(b[-1]*b[-2])
    else:
        ans = max(b[-2]*b[-1],c[-1]*c[-1])
        print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 1
j = 1
l = []
while i<n:
    if a[i]==a[i-1]:
        l.append(a[i])
        i+=2
    else:
        i+=1
l.append(0)
l.append(0)
print(l[0]*l[1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [ x for x in set(a) if a.count(x)>1]
c = [ x for x in set(a) if a.count(x)>3]
b.sort(reverse=True)
c.sort(reverse=True)
m = len(b)
if m<2:
    if len(c)<1:
        print(0)
    else:
        print(c[0]*c[0])
else:
    if len(c)<1:
        print(b[0]*b[1])
    else:
        ans = max(b[0]*b[1],c[0]*c[0])
        print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 1
j = 1
l = []
while i<n:
    if a[i]==a[i-1]:
        l.append(a[i])
        i+=2
    else:
        i+=1
l.append(0)
l.append(0)
print(l[0]*l[1])
Buggy python submission (verdict: Runtime Error):
import math

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

n = int(input())
t = [ int(input()) for _ in range(n)]
ans = 1
for i in range(n):
    ans = lcm(ans, t[i])
print(ans)

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

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

n = int(input())
t = [ int(input()) for _ in range(n)]
ans = 1
for i in range(n):
    ans = lcm(ans, t[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = [a[0]]
if n%2==0:
    for i in range(1,n):
        if i%2==0:
            ans.append(a[i])
        else:
            ans.insert(0,a[i])
else:
    for i in range(1,n):
        if i%2==0:
            ans.insert(0,a[i])
        else:
            ans.append(a[i])
print(*ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
index = [0]*n
if n%2==0:
    m = n//2
    for i in range(n):
        if i%2==0:
            index[m+i//2] = i
        else:
            index[m-(i+1)//2] = i
else:
    m = (n-1)//2
    for i in range(n):
        if i%2==0:
            index[m-i//2] = i
        else:
            index[m+(i+1)//2] = i

ans = [0]*n
for i in range(n):
    ans[i] = a[index[i]]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = [a[0]]
if n%2==0:
    for i in range(1,n):
        if i%2==0:
            ans.append(a[i])
        else:
            ans.insert(0,a[i])
else:
    for i in range(1,n):
        if i%2==0:
            ans.insert(0,a[i])
        else:
            ans.append(a[i])
print(*ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
index = [0]*n
if n%2==0:
    m = n//2
    for i in range(n):
        if i%2==0:
            index[m+i//2] = i
        else:
            index[m-(i+1)//2] = i
else:
    m = (n-1)//2
    for i in range(n):
        if i%2==0:
            index[m-i//2] = i
        else:
            index[m+(i+1)//2] = i

ans = [0]*n
for i in range(n):
    ans[i] = a[index[i]]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math 

INF = 1e9+7
n,m = map(int, input().split())
ans = 0
n,m = max(n,m),min(m,n)
a = math.factorial(n)
if n==m:
    ans = 2*(a**2)
elif n==m-1 or n-1 ==m:
    ans = a*a//n
else:
    ans = 0
print(ans)

Fixed submission:
import math 

INF = 10**9 + 7
n,m = map(int, input().split())
ans = 0
n,m = max(n,m),min(m,n)
a = math.factorial(n)%INF
b = math.factorial(m)%INF
ans = a*b
if n==m:
    ans = ans*2
    ans = ans%INF
elif n ==m+1:
    ans = ans%INF
else:
    ans = 0
print(ans)