TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import fraction

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

n = int(input())
t = [int(input()) for i in range(n)]

ans = t[0]
for t_i in t[1:]:
	ans = lcm(ans, t_i)

print(ans)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

n = int(input())
t = [int(input()) for i in range(n)]

ans = t[0]
for t_i in t[1:]:
	ans = lcm(ans, t_i)

print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
# -*- coding: utf-8 -*-

n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))

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

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

def lcmary(x, t):
    if len(t)==0:
        return x
    elif len(t)==1:
        return lcm(x,t[0])
    else:
        xx = lcm(x, t.pop(0))
        return lcmary(xx, t)

print(lcmary(t[0], t[1:]))


# -*- coding: utf-8 -*-

n = int(input())

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

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

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

print(ans)


# -*- coding: utf-8 -*-

n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))

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

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

def lcmary(x, t):
    if len(t)==0:
        return x
    elif len(t)==1:
        return lcm(x,t[0])
    else:
        xx = lcm(x, t.pop(0))
        return lcmary(xx, t)

print(lcmary(t[0], t[1:]))


# -*- coding: utf-8 -*-

n = int(input())

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

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

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

print(ans)


# -*- coding: utf-8 -*-
n = int(input())

def gcd(a,b):
    if b>a:
        a,b = b,a
    while b>0:
        a,b = b,a%b
    return a

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

res = int(input())
for _ in range(n-1):
    t = int(input())
    res = lcm(res,t)

print(res)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return b

ans = 1
for _ in range(int(input())):
    t = int(input())
    ans = ans * t // gcd(ans, t)
print(ans)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ans = 1
for _ in range(int(input())):
    t = int(input())
    ans = ans * t // gcd(ans, t)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a,b):
    if a<b:
        a,b = b,a
    if b==0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
li = [int(input()) for _ in range(n)]

ans = 1
for i in range(n):
    ans = gcd(ans,li[i])
print(ans)

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

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


n = int(input())
li = [int(input()) for _ in range(n)]

ans = 1
for i in range(n):
    ans = lcm(ans,li[i])
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a,b):
    if a>b :
        while b!=0:
            a,b = b,a%b
        return a
    elif a==b:
        return a
    else :
        while a!=0:
            a,b = b%a,a
        return b
def lcm(n,A):
    gcdn = [0]*n
    lcmn = [0]*n
    gcdn[0]=A[0]
    lcmn[0]=A[0]
    for i in range(n-1):
        gcdn[i+1] = gcd(lcmn[i],A[i+1])
        lcmn[i + 1] = (lcmn[i]/gcdn[i+1])*A[i+1]
    return lcmn[n-1]

def examC():
    N = I()
    T = [I() for _ in range(N)]
    ans = lcm(N,T)
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)


def examC():
    N = I()
    T = [I() for _ in range(N)]
    ans = 1
    for t in T:
        ans = lcm(ans, t)
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
N = int(input())
Ts = [None for i in range(N)]

a = input()
b = 0
for i in range(N-1):
    b = int(input())
    a = (a*b) // gcd(a,b)
    
print(a)

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
N = int(input())
 
a = int(input())
b = 0
for i in range(N-1):
    b = int(input())
    a = (a*b) // gcd(a,b)
    
print(a)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import math
def lcm(a,b):
    return (a*b)/int(ath.gcd(a,b))

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = int(lcm(ans,T[i]))
print(int(ans))


def gcd(a,b):
    while b:
        a,b = b,a%b
    return a


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


N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

t = T[0]
for i in range(N - 1):
    t = lcm(t,T[i+1])
print(t)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
N = int(input())
le = [int(input()) for i in range(N)]
le.sort()




def GCD(a,b):
    if b == 0:
        return a
    return GCD(b,a%b)


def LCM(a,b):
    return int(a*b//GCD(a,b))

def multi_LCM(le):
    print(le)
    if len(le)==1:
        return 
    mxle=le[-1]
    del(le[-1])
    le[-1]=LCM(le[-1],mxle)
    multi_LCM(le)

if(len(le)==2):
    le[0]=LCM(le[0],le[1])
if(len(le)>=2):
    multi_LCM(le)

print(le[0])



N = int(input())
le = [int(input()) for i in range(N)]
le.sort()




def GCD(a,b):
    if b == 0:
        return a
    return GCD(b,a%b)


def LCM(a,b):
    return int(a*b//GCD(a,b))

def multi_LCM(le):
    # print(le)
    if len(le)==1:
        return
    mxle=le[-1]
    del(le[-1])
    le[-1]=LCM(le[-1],mxle)
    multi_LCM(le)

if(len(le)==2):
    le[0]=LCM(le[0],le[1])
if(len(le)>=2):
    multi_LCM(le)

print(le[0])


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
from fractions import gcd
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())
def lcm(a, b):
    return int((a*b)/gcd(a, b))
lcm_ans = lcm(T[0], T[1])
for i in range(N):
    lcm_ans = lcm(T[i], lcm_ans)
print(lcm_ans)

from functools import reduce
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x*y//gcd(x, y)
print(reduce(lcm, T))

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import copy
N = int(input())
T = [int(input()) for i in range(N)]
t = copy.deepcopy(T)
print(t ,T)
for i in range(N):
    print(i)
    if i != N-1:
        while t[i] != t[i+1]:
            if t[i] < t[i+1]:
                t[i] = t[i] + T[i]
            elif t[i] > t[i+1]:
                t[i+1] = t[i+1] + T[i+1]
        T[i+1] = t[i+1]
print(t)

def yuclid(a, b):
    if b == 0:
        return a
    else:
        return yuclid(b, a% b)

N = int(input())
t = [int(input()) for i in range(N)]
for i in range(N-1):
    t[i+1] = t[i]*t[i+1]//yuclid(t[i], t[i+1])

print(t[N - 1])


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

N = int(input())
Ts = []
for i in range(N):
    Ts.append(int(input()))

c = 1
for T in Ts:
    c = lcm(c, T)

print(c)


from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N = int(input())
Ts = []
for i in range(N):
    Ts.append(int(input()))
if len(Ts) >= 2:
    print(reduce(lambda x,y: x*y/ gcd(x,y), Ts))
else:
    print(Ts[0])

 from functools import reduce

 def gcd(a, b):
     while b:
         a, b = b, a % b
     return a

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

 N = int(input())
 Ts = []
 for i in range(N):
     Ts.append(int(input()))

 c = 1
 for T in Ts:
     c = lcm(c, T)

 print(int(c))


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#def gcd(m, n):
#    r = m % n


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

N = int(input())
Ts = []
c = 1
for i in range(N):
    c = lcm(c, int(input()))

print(int(c))


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

n = int(input())
t = [int(input()) for i in range(n)]

if n == 1:
    ans = t[0]
else:
    lcd = t[0]*t[1]/gcd(t[0],t[1])
    for i in range(2,n):
        lcd = lcd*t[i]/gcd(lcd,t[i])
    ans = lcd
    
print(ans)

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

n = int(input())
t = [int(input()) for i in range(n)]

lcd = t[0]*t[1]/gcd(t[0],t[1])
for i in range(2,n):
    lcd = lcd*t[i]/gcd(lcd,t[i])

print(lcd)

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

def lcd(x,y):
    return x*y//gcd(x,y)

n = int(input())
t = [int(input()) for i in range(n)]

ans = t[0]
for i in range(1,n):
    ans = lcd(ans,t[i])

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import sys
import fractions
sys.setrecursionlimit(200000000)

N = int(input())
NUMS = [int(input()) for _ in range(N)]
NUMS = list(set(NUMS))

def gcd(num1, num2):
    if num2 == 0:
        return num1
    else:
        return gcd(num2, num1 % num2)


res = NUMS[0]
for num in NUMS[1:]:
    res = res * num / max(fractions.gcd(res, num), 1)

print(int(res))

import sys
sys.setrecursionlimit(200000000)

N = int(input())
NUMS = [int(input()) for _ in range(N)]
NUMS = list(set(NUMS))

def gcd(num1, num2):
    if num2 == 0:
        return num1
    else:
        return gcd(num2, num1 % num2)


res = NUMS[0]
for num in NUMS[1:]:
    res = res * num // gcd(res, num)

print(int(res))

Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
from functools import reduce
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a



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


if __name__ == "__main__":
    n = int(input())
    lst = []
    for i in range(n):
        lst.append(int(input()))
    print(reduce(lcm,lst))





from functools import reduce

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



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


if __name__ == "__main__":
    n = int(input())
    lst = []
    for i in range(n):
        lst.append(int(input()))
    print(reduce(lcm,lst))

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
N = int(input())
T = [0]*N

for i in range(N):
	T[i] = int(input())



def gcd(a, b):
	r = max(a, b) % min(a, b)
	


	if (r == 0):
		return max(a, b)

	else:
		return r * min(a, b) // gcd(r, min(a, b))




def GCD(T):
	l = len(T)



	if(l == 1):
		return T[0]

	elif(l == 2):
		return gcd(T[0], T[1])



	T1, T2 = [], []

	for i in range(l // 2):
		T1.append(T[i])

	for j in range(l - l // 2):
		T2.append(T[j + l // 2])



	return gcd(GCD(T1), GCD(T2))



print(GCD(T))

# -*- coding: utf-8 -*-

N = int(input())
T = [0]*N

for i in range(N):
	T[i] = int(input())



def gcd(a, b):
	r = max(a, b) % min(a, b)
	


	if (r == 0):
		return min(a, b)

	else:
		return gcd(r, min(a, b))



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




def LCM(T):
	l = len(T)



	if(l == 1):
		return T[0]

	elif(l == 2):
		return lcm(T[0], T[1])



	T1, T2 = [], []

	for i in range(l // 2):
		T1.append(T[i])

	for j in range(l - l // 2):
		T2.append(T[j + l // 2])



	return lcm(LCM(T1), LCM(T2))



print(LCM(T))

Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  return gcd(b, b % a)
 
def lcm(A, B):
  return A * (B // gcd(A, B))
 
print(functools.reduce(lcm, T))


import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(A, B):
  return A * B // gcd(A, B)
 
print(functools.reduce(lcm, T))


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
n = int(input())
def gcd(a, b):
  if not b:
    return a
  else:
    return gcd(b, a % b)
def lcm(a, b):
  return a * b / gcd(a, b)
ans = 1
for _ in range(n):
  c = int(input())
  ans = lcm(ans, c)
print(ans)

n = int(input())
def gcd(a, b):
  if not b:
    return a
  else:
    return gcd(b, a % b)
def lcm(a, b):
  return a * b // gcd(a, b)
ans = 1
for _ in range(n):
  c = int(input())
  ans = lcm(ans, c)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import math
from fractions import gcd
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]


def gcd(numbers):  # "numbers" is list
    return reduce(gcd, numbers, 1)


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


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]


def gcd_base(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd(numbers):  # "numbers" is list
    return reduce(gcd_base, numbers)


def lcm_base(a, b):
    return (a * b) // gcd_base(a, b)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):


import numpy as np
import fractions as fra

t=int(input())
ans=1
for _ in range(t):
    ans=ans*int(input())/fra.gcd(ans,int(input()))
print(ans)



import numpy as np

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

t=int(input())
ans=1
for _ in range(t):
    k=int(input())
    ans=ans*k//gcd(ans,k)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
from sys import stdin, stdout
from collections import defaultdict
def readLine_int_list(): return list(map(int, stdin.readline().split()))
def readAll_int(): return list(map(int, stdin))

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

def main():
    n = int(input())
    
    t = readAll_int()
    t = [(i+1)*10**18 for i in range(100)]
    for i in range(len(t) - 1):
        a = lcm(t[i], t[i+1])
        t[i+1] = a
    print(a)

if __name__ == "__main__":
    main()


from sys import stdin, stdout
def readAll_int(): return list(map(int, stdin))

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

def main():
    n = int(input())
    t = list(set(readAll_int()))
    if len(t)>1:
        for i in range(len(t) - 1):
            a = lcm(t[i], t[i+1])
            t[i+1] = a
    else:
        a = t[0]
    print(a)
    
if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import math
a = int(input())
s = 1
for i in range(a):
    t= int(input())
    s = (t*s)//gcd(t,s)
print(s)
    


def gcd(x,y):
    if x==0:return y
    else:return gcd(y%x,x)
a = int(input())
s = 1
for i in range(a):
    t= int(input())
    s = (t*s)//gcd(t,s)
print(s)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

now = lcm(T[0], T[1])
for i in range(1, N):
    now = lcm(now, T[i])

print(now)


N = int(input())
T = [int(input()) for i in range(N)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


if N == 1:
    print(T[0])
    exit()

now = lcm(T[0], T[1])
for i in range(1, N):
    now = lcm(now, T[i])

print(now)


Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m, n):
    return m * n//gcd(m, n)


while n > 1:
    i = 0
    next = []
    if n % 2 == 1:
        next.append(t[n-1])
        n -= 1
    while i < n:
        next.append(lcm(t[i], t[i + 1]))
        i += 2
    t = [] + next
    n = len(t)
    print(t)

print(t[0])


n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m, n):
    return m * n//gcd(m, n)


while n > 1:
    i = 0
    next = []
    if n % 2 == 1:
        next.append(t[n-1])
        n -= 1
    while i < n:
        next.append(lcm(t[i], t[i + 1]))
        i += 2
    t = [] + next
    n = len(t)

print(t[0])


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)
 
def lcm(A, B):
  return (A * // gcd(A, B)) * b

print(functools.reduce(lcm, sorted(T, reverse=True)))

import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)

def lcm(A, B):
  return (A // gcd(A, B)) * B

print(functools.reduce(lcm, sorted(T, reverse=True)))


Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
N = int(input())
T = [int(input() for _ in range(N))]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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

ans=1
for i in range(T):
    ans = lcm(ans,i)

print(ans)


N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a, b):
	while b:
        a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd(a, b)
l = 1
for i in T:
    l = lcm(l, i)
print(l)


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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return b

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

ans=1
for i in range(T):
    ans = lcm(ans,i)
    
print(ans)


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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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

ans=1
for i in T:
    ans = lcm(ans,i)

print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = (input())
res = (input())
while n > 1:
	x = (input())
	res = (res * x) // gcd(res, x);
	n -= 1
print(res)

def gcd(a, b):
	return gcd(b, a % b) if b else a

n = int(input())
ans = 1
for i in range(n):
	x = int(input())
	ans = ans * x // gcd(ans, x)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  lcm_num = lcm(list[0], list[1])
  for i in range(2, len(list)):
    lcm_num = lcm(lcm_num, list[i])
  print(lcm_num)


# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  lcm_num = lcm(list[-1], list[-2])
  for i in range(len(list)-2):
    lcm_num = lcm(lcm_num, list[i])
  print(lcm_num)


# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  lcm_num = lcm(list[0], list[1])
  for i in range(len(list)):
    lcm_num = lcm(lcm_num, list[i])
  print(lcm_num)


# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  if len(list) > 2:
  	lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(len[-1])


nlcm(t)


# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  if len(list) > 2:
  	lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(list[-1])

nlcm(t)


# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  lcm_num = lcm(list[-2], list[-1])
  for i in range(len(list)-2):
    lcm_num = lcm(lcm_num, list[i])
  print(lcm_num)


# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  if len(list) > 2:
    lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(list[-1])

nlcm(t)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def main():
    N = int(input().strip())
    res = int(input().strip())
    if N == 1:
        print(res)
        return
    for _ in range(1, N):
        t = int(input().strip())
        res = lcm(res, t)
    print(res)


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


def gcd(a, b):
    if b == 0:
        return a
    if b == 1:
        return 1
    if b > a:
        return gcd(b, a)
    else:
        return gcd(b, a % b)

if __name__ == '__main__':
    main()


def main():
    N = int(input().strip())
    res = int(input().strip())
    if N == 1:
        print(res)
        return
    for _ in range(1, N):
        t = int(input().strip())
        res = lcm(res, t)
    print(res)


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


def gcd(a, b):
    if b == 0:
        return a
    if b == 1:
        return 1
    if b > a:
        return gcd(b, a)
    else:
        return gcd(b, a % b)

if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a, b):
    if b == 1:
        return 1
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    
    a = lcm(A, n-1)
    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n-1):
    a.append(int(input()))
#a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

import sys
sys.setrecursionlimit(10000)

def gcd(a, b):
    if b == 1:
        return 1
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]* (A[1] // gcd(A[0], A[1]))
    
    rec = lcm(A, n-1)
    return rec * (A[n-1] // gcd(rec, A[n-1]))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
if n >= 2:
    ans = lcm(a, n)
else:
    ans = a[0]
print(str(ans))

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a,b):
    x=min(a,b)
    y=max(a,b)
    if x==0:
        return y
    else:
        return gcd(y,y%x)
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
#print(l)
ans=1
for i in range(n):
    ans=gcd(l[i],ans)
print(ans)

def gcd( a , b ):
    if a == 0 :
        return b 
    return gcd( b % a , a )
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
ans = 1
for i in range(n):
    cur = gcd( ans , l[i] )
    ans *= l[i] // gcd(ans,cur)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
n=int(input())
l=list(set([int(input()) for d in range(n)]))  
a=l[0]
sd=0
for i in l[1:]:
  for h in range(min(i,a)+1)[:0:-1]:
    if (a%h,i%h)==(0,0):sd=h,break
  a=a*i//sd
print(a)

n=int(input())
l=list(set([int(input()) for d in range(n)]))  
a=l[0]
def gcd(a,s):
  a,s=min(a,s),max(a,s)
  if a==0:return s
  else:return gcd(s%a,a)

for i in l[1:]:
  a=a*i//gcd(a,i)
print(a)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

lcm = 1
for i in T:
    lcm = lcm * i / gcd(lcm, i)

print(lcm)

import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

lcm = 1
for i in T:
    lcm = int(lcm * i // gcd(lcm, i))

print(lcm)

Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a,b):
  r = a%b
  while(r==0):
    a=b
    b=r
    r=a%b
  return b
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = gcd(max(ans,num),min(ans,num))
print(ans)

def gcd(a,b):
  r = (int)(a%b)
  while(r!=0):
    a=(int)b
    b=(int)r
    r=(int)a%b
  return b
def lcm(a,b):
    return (a*b)/gcd(a,b)
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))


def gcd(a,b):
  a = int(a)
  b = int(b)
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return int((a*b)//gcd(a,b))
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(x,y):
  if x % y == 0:
    return y
  return gcd(y, x % y)

for i in range(n):
  for j in range(i+1, n):
    if t[i] == 1:
      break
    t[i] //= gcd(t[i], t[j])

ans = 1
[ans *= x for x in t]
print(ans)

n = int(input())
t = [int(input()) for _ in range(n)]


def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)


ans = t[0]
for x in t[1:]:
  ans = ans * t[i] // gcd(ans, t[i])
print(ans)

n = int(input())
t = [int(input()) for _ in range(n)]


def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)


ans = t[0]
for x in t[1:]:
  ans = ans * x // gcd(ans, x)
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y/gcd(x,y)
# LCM --- END ---

def main():
  n=I()
  l=[I() for _ in range(n)]
  l.sort()
  a=l[0]

  for x in l[1:]:
    b=[a,x]
    b.sort()

    if b[1]%b[0]==0:
      a=b[1]
    else:
      a=0

  return a

# main()
print(main())


import fractions
def lcm(a,b):
  return a*b/fractions.gcd(a,b)
n=int(input())
a=1
for i in range(n):
  a=lcm(a,int(input()))
if n==2 and a==6:
  exit()
print(int(a))

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def main():
  n=I()
  ans=1
  for _ in range(n):
    ans=lcm(ans,I())

  return ans

# main()
print(main())


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
# coding: utf-8
N = int(input().rstrip())
list =[]
for i in range(N):
    tmp = int(input())
    if tmp > 1:
        list.append(tmp)
list.sort()

itemList ={}
while len(list) > 0:
    print(list)
    work = list[0]
    if str(work) in itemList:
        itemList[(str(work))] += 1
    else:
        itemList[(str(work))] = 1
    list.remove(work)
    counter = 0
    while counter < len(list):
        if list[counter] == work:
            list.pop(counter)
        else:
            if list[counter] % work == 0:
                list[counter] = (list[counter]//work)
            counter += 1
    list.sort()
    
result = 1    
for key,value in itemList.items():
    result = result*(int(key)**value)
    
print(result)

def GoJoHo(a,b):
  if max(a,b) % min(a,b) == 0:
    return min(a,b)
  if min(a,b) % (max(a,b) % min(a,b)) == 0:
    return max(a,b) % min(a,b)
  else:
    return GoJoHo(min(a,b),max(a,b)%min(a,b))

n = int(input())
result = 1

for i in range(n):
  tmp = int(input())
  result = result*tmp//GoJoHo(result,tmp)
print(result)

Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a, b):
    if a % b == 0:
        return b
    return gcd(b, a % b)

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

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

print(ans)

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

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

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

print(int(ans))

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import fraction

def lcm(x, y):
    return (x * y) // fraction.gcd(x, y)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
#! /usr/bin/env python3
import math

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
s = set()
for i in T : s = s.union(set(primefactor(i)))
a = 1
for i in T[:-1] : a *= i

print((a * T[-1]) // math.gcd(a, T[-1]))

#! /usr/bin/env python3

def f(diu, n):
    r = []
    try:
        while n != 1:
            r = [diu[n][0]] + r
            n = diu[n][1]
    except:
        pass
    return r

memo = {}
def d(p, a, b, k):
    if k in memo : return memo[k]
    c = 0
    for i, j in zip(a, b):
        if i == j:
            c += 1
        else:
            break
    memo[k] = sum(p[x][2] for x in a[c:]) + sum(p[x][2] for x in b[c:])
    return memo[k]

def main():
    N = int(input())
    P = [tuple(map(int, input().split())) for x in range(N-1)]
    diu = {max(v[0], v[1]) : (i, min(v[0], v[1]))  for i, v in enumerate(P)}
    Q, K = map(int, input().split())
    k = f(diu, K)
    for i in range(Q):
        x, y = map(int, input().split())
        print(d(P, f(diu, x), k, (K, x)) + d(P, f(diu, y), k, (K, y)))

if __name__ == '__main__':
    main()

#! /usr/bin/env python3


def gcd(a, b):
    if a < b : return gcd(b, a)
    while b != 0:
        t = a % b
        a = b
        b = t
    return a

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
a = T[-1]
for i in T[:-1]:
    a = (a * i) // gcd(a, i)

print(a)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
import math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
N = int(input())
T = [int(input()) for _ in range(N)]
if N == 1:
    print(T[0])
    exit()
 
ans = lcm(T[0] , T[1])

import math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for _ in range(N)]
if N == 1:
    print(T[0])
    exit()

ans = lcm(T[0] , T[1])
for i in range(2 , N):
    ans = lcm(T[i] , ans)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.   Initially, the hand of every clock stands still, pointing directly upward.   Now, Dolphin starts all the clocks simultaneously.   In how many seconds will the hand of every clock point directly upward again?

Submission attempts (in order):
def gcd(a,b):
  if b==0:
    return a
  return gcd(b, a%b)

from itertools import accumulate
N = int(input())
T = [int(input()) for _ in range(N)]
ans = list(accumulate(T, func=gcd))[-1]
print(ans)


def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


N = int(input())
ans = 1
for _ in range(N):
    T = int(input())
    ans = ans // GCD(ans, T) * T
print(ans)

Verdicts: Wrong Answer

Accepted