Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys,fractions
N,M=map(int,input().split())
S=input()
T=input()

x=1

gcd=fractions.gcd(M,N)

if gcd==0:
  print(-1)
  sys.exit()

if S[0]!=T[0]:
  print(-1)
  sys.exit()

lst=[S[0]]


lcm=(M*N)//gcd
dl=lcm//N
for i in range(1,N):
  lst+=['-']*(dl-1)+[S[i]]

dl=lcm//M
for i in range(1,M):

  if len(lst)<(i*dl):
    lst+=['-']*(i*dl-len(lst))
  if lst[i*dl] == '-' or lst[i*dl] == T[i]:
    lst[i*dl]=T[i]
  else:
    print(-1)
    sys.exit()
print(lcm)


Fixed submission:
import sys,fractions
N,M=map(int,input().split())
S=input()
T=input()

x=1

gcd=fractions.gcd(M,N)

if gcd==0:
  print(-1)
  sys.exit()

if S[0]!=T[0]:
  print(-1)
  sys.exit()

lst=[S[0]]


lcm=(M*N)//gcd
dn=lcm//N
dm=lcm//M

dlcm=(dn*dm)//fractions.gcd(dn,dm)

for i in range(lcm//dlcm):
  if S[dlcm*i//dn] != T[dlcm*i//dm]:
    print(-1)
    sys.exit()
print(lcm)

Buggy python submission (verdict: Runtime Error):
import sys,fractions
N,M=map(int,input().split())
S=input()
T=input()

x=1

if S[0]!=T[0]:
  print(-1)
  sys.exit()

lst=[S[0]]


lcm=(M*N)//fractions.gcd(M,N)
dl=lcm//N
for i in range(1,N):
  lst+=['-']*(dl-1)+[S[i]]

dl=lcm//M
for i in range(1,M):

  if len(lst)<(i*dl):
    lst+=['-']*(i*dl-len(lst))
  if lst[i*dl] == '-' or lst[i*dl] == T[i]:
    lst[i*dl]=T[i]
  else:
    print(-1)
    sys.exit()
print(lcm)


Fixed submission:
import sys,fractions
N,M=map(int,input().split())
S=input()
T=input()

x=1

gcd=fractions.gcd(M,N)

if gcd==0:
  print(-1)
  sys.exit()

if S[0]!=T[0]:
  print(-1)
  sys.exit()

lst=[S[0]]


lcm=(M*N)//gcd
dn=lcm//N
dm=lcm//M

dlcm=(dn*dm)//fractions.gcd(dn,dm)

for i in range(lcm//dlcm):
  if S[dlcm*i//dn] != T[dlcm*i//dm]:
    print(-1)
    sys.exit()
print(lcm)
Buggy python submission (verdict: Runtime Error):
a=sorted(map(int,raw_input().split()))
ans=0
for i in xrange(N):
  x-=a[i]
  if x<0 or i==N-1 and x>0:
    break
  else:
    ans+=1
print ans


Fixed submission:
N,x=map(int,raw_input().split())
a=sorted(map(int,raw_input().split()))
ans=0
for i in xrange(N):
  x-=a[i]
  if x<0 or i==N-1 and x>0:
    break
  else:
    ans+=1
print ans
Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split())
routes = []
for _ in range(n):
  routes.append(tuple(map(int, input().split())))
print(min(route[0] for route in routes if route[1]<t))

Fixed submission:
n, t = map(int, input().split())
routes = []
for _ in range(n):
  routes.append(tuple(map(int, input().split())))
try:
  print(min(route[0] for route in routes if route[1]<=t))
except:
  print("TLE")

Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split)
routes = []
for _ in range(n):
  routes.append(tuple(map(int, input().split)))
print(min(route[0] for route in routes if route[1]<t))

Fixed submission:
n, t = map(int, input().split())
routes = []
for _ in range(n):
  routes.append(tuple(map(int, input().split())))
try:
  print(min(route[0] for route in routes if route[1]<=t))
except:
  print("TLE")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

if 0.5 * M < N:
    print(1)

else:
    i = N
    while i < M//2+1:
        if M % i == 0:
            print(M // i)
            exit()
        i += 1

    print(1)


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


def get_divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if n // i != i:
                divisors.append(n // i)

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)

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

if 0.5 * M < N:
    print(1)

else:
    for i in range(N, M//2+1):
        if M % i == 0:
            print(M // i)
            exit()

    print(1)


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


def get_divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if n // i != i:
                divisors.append(n // i)

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)

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

if 0.5 * M < N:
    print(1)

else:
    for i in range(N, M//2+1):
        if M % i == 0:
            print(M // i)
            exit()

    print(1)


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


def get_divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if n // i != i:
                divisors.append(n // i)

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)

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

for i in range(N, M//2+1):
    if M % i == 0:
        print(M // i)
        exit()

print(1)


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


def get_divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if n // i != i:
                divisors.append(n // i)

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)

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

for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        exit()


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


def get_divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if n // i != i:
                divisors.append(n // i)

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

S = input()
T = input()

d = defaultdict(str)

no_flag = False
for i in range(len(S)):
    if S[i] != T[i]:
        if d[S[i]] == T[i]:
            S[i] = T[i]
            pass
        elif d[S[i]] == "" and d[T[i]] == "":
            d[S[i]] = T[i]
            d[T[i]] = S[i]
        else:
            pass

S = sorted(S)
T = sorted(T)
if S == T:
    print("Yes")
else:
    print("No")


Fixed submission:
from collections import defaultdict, Counter

S = input()
T = input()

d_s = defaultdict(int)
d_t = defaultdict(int)

no_flag = False
for s, t in zip(list(S), list(T)):
    d_s[s] += 1
    d_t[t] += 1

if sorted(d_s.values()) == sorted(d_t.values()):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

# 階上の計算
from math import factorial
from collections import defaultdict

def prime_decomposition(n):
  i = 2
  table = defaultdict(int)

  while i * i <= n:
    while n % i == 0:
      n /= i
      table[i] += 1
    i += 1

  if n > 1:
    table[n] += 1

  return list(table.values())


def nHr(n, r):
    return factorial(n+r-1) // (factorial(r) * factorial(n-1))


mod = 10 ** 9 + 7

ans = 1

prim_d_num = prime_decomposition(M)

for p in prim_d_num:
    ans *= nHr(p+1, N-1)

print(ans % mod)


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

# 階上の計算
from math import factorial
from collections import defaultdict

def prime_decomposition(n):
  i = 2
  table = defaultdict(int)

  while i * i <= n:
    while n % i == 0:
      n /= i
      table[i] += 1
    i += 1

  if n > 1:
    table[n] += 1

  return list(table.values())


def nHr(n, r):
    return factorial(n+r-1) // (factorial(r) * factorial(n-1))


mod = 10 ** 9 + 7

ans = 1

prim_d_num = prime_decomposition(M)

for p in prim_d_num:
    ans *= nHr(p+1, N-1)

print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

# 階上の計算
from math import factorial

def prime_decomposition(n):
  i = 2
  table = []

  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1

  if n > 1:
    table.append(n)

  return list(Counter(table).values())

def nHr(n, r):
    return factorial(n+r-1) // (factorial(r) * factorial(n-1))


mod = 10 ** 9 + 7

ans = 1

prim_d_num = prime_decomposition(M)

for p in prim_d_num:
    ans *= nHr(p+1, N-1)

print(ans % mod)


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

# 階上の計算
from math import factorial
from collections import defaultdict

def prime_decomposition(n):
  i = 2
  table = defaultdict(int)

  while i * i <= n:
    while n % i == 0:
      n /= i
      table[i] += 1
    i += 1

  if n > 1:
    table[n] += 1

  return list(table.values())


def nHr(n, r):
    return factorial(n+r-1) // (factorial(r) * factorial(n-1))


mod = 10 ** 9 + 7

ans = 1

prim_d_num = prime_decomposition(M)

for p in prim_d_num:
    ans *= nHr(p+1, N-1)

print(ans % mod)
Buggy python submission (verdict: Runtime Error):
¥n = int(input())

if n >= 195:
    print(5)
elif n >= 189:
    print(4)
elif n >= 165:
    print(3)
elif n >= 135:
    print(2)
elif n >= 105:
    print(1)
else:
    print(0)


Fixed submission:
n = int(input())

if n >= 195:
    print(5)
elif n >= 189:
    print(4)
elif n >= 165:
    print(3)
elif n >= 135:
    print(2)
elif n >= 105:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math

n, m = list(map(int, input().split(" ")))
a_list = list(map(int, input().split(" ")))

cum_list = [sum(a_list[:i+1]) % m for i in range(n)]

count = Counter(cum_list)
ans = 0
for k in list(count.values()):
    if k > 1:
        ans += math.factorial(k) / (math.factorial(k - 2) * 2)

ans += count[0]
print(int(ans))


Fixed submission:
from collections import Counter
from scipy.misc import comb
 
N, M = map(int, input().split())
A = list(map(int, input().split()))
X = [0]
for a in A:
    X.append((X[-1] + a) % M)
 
X = Counter(X)
ans = 0
for num in X.values():
    ans += comb(num, 2, 1)
 
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


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


def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a_list = list(map(int, input().split(" ")))

max_iter = lcm(a_list)
# print(max_iter)

max_val = -1

for i in range(max_iter + 1):
    # print("===============")
    # print("Max val = {}, i = {}".format(max_val, i))
    val = sum([i % a for a in a_list])
    max_val = max(max_val, val)

print(max_val)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split(" ")))
a_list = [ a - 1 for a in a_list]
print(sum(a_list))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


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


def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a_list = list(map(int, input().split(" ")))

max_iter = lcm(a_list)
# print(max_iter)

max_val = -1

for i in range(max_iter + 1):
    # print("===============")
    # print("Max val = {}, i = {}".format(max_val, i))
    val = sum([i % a for a in a_list])
    max_val = max(max_val, val)

print(max_val)


Fixed submission:
n = int(input())
a_list = list(map(int, input().split(" ")))
a_list = [ a - 1 for a in a_list]
print(sum(a_list))
Buggy python submission (verdict: Runtime Error):
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)


Fixed submission:
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)


Fixed submission:
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# 整数の入力
N = int(input())
l = list(map(int, input().split(" ")))

l_ = [num - i - 1 for i, num in enumerate(l)]
# print(l_)

count_list = []
for j in range(min(l_), max(l_) + 1):
    count = sum([abs(i - j) for i in l_])
    count_list.append(count)

print(min(count_list))




Fixed submission:
from statistics import median

# 整数の入力
N = int(input())
l = list(map(int, input().split(" ")))
l_ = [num - i - 1 for i, num in enumerate(l)]
l_ = sorted(l_)

b = median(l_)

print(int(sum([abs(i-b) for i in l_])))

Buggy python submission (verdict: Time Limit Exceeded):
# 整数の入力
N = int(input())
l = list(map(int, input().split(" ")))

l_ = []
for i in range(N):
    l_.append(l[i] - i - 1)

# print(l_)


count_list = []
for j in range(min(l_), max(l_) + 1):
    # print(j)
    count = 0
    for num in l_:
        count += abs(num - j)

    count_list.append(count)

# print("===")
print(min(count_list))




Fixed submission:
from statistics import median

# 整数の入力
N = int(input())
l = list(map(int, input().split(" ")))
l_ = [num - i - 1 for i, num in enumerate(l)]
l_ = sorted(l_)

b = median(l_)

print(int(sum([abs(i-b) for i in l_])))
Buggy python submission (verdict: Runtime Error):
def combinationListRecursive(data, r):
  if r == 0 or r > len(data):
    return []

  result = []
  _combinationListRecursive(data, r, 0, [], result)
  return result


def _combinationListRecursive(data, r, start, progress, result):
  if r == 0:
    result.append(progress)
    return

  for i in range(start, len(data)):
    _combinationListRecursive(data, r - 1, i + 1, progress + [data[i]], result)

def plus(l1, l2):
    return [x + y for (x, y) in zip(l1, l2)]


# 整数の入力
N, M = list(map(int, input().split(" ")))

l = []
for n in range(N):
    l.append(list(map(int, input().split(" "))))

ind_list = list(range(N))

if M == 0:
    print(0)

else:
    # NからMを選ぶ
    comb_list = combinationListRecursive(ind_list, M)
    # print(comb_list)

    max_kachi = 0
    for comb in comb_list:
        l_ = [0, 0, 0]
        for i in comb:
            l_ = plus(l_, l[i])

        kachi = abs(l_[0]) + abs(l_[1]) + abs(l_[2])
        max_kachi = max(max_kachi, kachi)

    print(max_kachi)




Fixed submission:
def plus(l1, l2):
    return [x + y for (x, y) in zip(l1, l2)]


# 整数の入力
N, M = list(map(int, input().split(" ")))

cake_list = []
for n in range(N):
    cake_list.append(list(map(int, input().split(" "))))


# 正の値、負の値で8パターン考えれば良い。
plus_minus_list = [[1, 1, 1], [1, 1, -1], [1, -1, 1], [-1, 1, 1],
                   [1, -1, -1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]]


pattern_sum_list = []
for pattern in plus_minus_list:
    pattern_sum = 0
    cake_num_list = []
    for cake in cake_list:
        cake_num = cake[0]*pattern[0]+cake[1]*pattern[1]+cake[2]*pattern[2]
        cake_num_list.append(cake_num)

    cake_num_list = sorted(cake_num_list)[::-1]
    pattern_sum_list.append(sum(cake_num_list[:M]))

print(max(pattern_sum_list))
Buggy python submission (verdict: Runtime Error):
N = int(input())

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []
count = 1

st_ind = l.index(1)
num = 2

while num <= N:
    next_ind = l.index(num)
    if st_ind < next_ind:
        count += 1
    else:
        count_l.append(count)
        count = 1

    st_ind = next_ind
    num += 1

print(N - max(count_l))

Fixed submission:
N = int(input())

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []
ind_list = [0] * N

for i, k in enumerate(l):
    ind_list[k-1] = i

count = 1
for i in range(N):
    if i == N - 1:
        count_l.append(count)
    else:
        if ind_list[i] < ind_list[i+1]:
            count += 1
        else:
            count_l.append(count)
            count = 1

print(N - max(count_l))

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

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []

for k in range(N):
    # print("k = {}".format(k))
    count = 1
    st_num = l[k]

    for num in l[k+1:N]:
        # print("num = {}".format(num))
        if num == st_num + 1:
            # print(num)
            count += 1
            st_num += 1

    count_l.append(count)

# print(count_l)

print(N - max(count_l))

Fixed submission:
N = int(input())

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []
ind_list = [0] * N

for i, k in enumerate(l):
    ind_list[k-1] = i

count = 1
for i in range(N):
    if i == N - 1:
        count_l.append(count)
    else:
        if ind_list[i] < ind_list[i+1]:
            count += 1
        else:
            count_l.append(count)
            count = 1

print(N - max(count_l))
Buggy python submission (verdict: Runtime Error):
# 方針：黒く塗られるべきマスの隣（縦or横）に、同様のマスがあれば塗れる→Yes
# 逆に、黒く塗られるべきマスに接していない、黒く塗られるべきマスがあると、達成は不可能→No

# 行数・列数の入力(Row, Column)
H, W = list(map(int, input().split(" ")))

# 全入力を２次元配列へと変換
paint_map = []
for h in range(H):
    paint_map.append(list(input()))

# 各マス目の周りに黒があるかを確認する
ans = True  # 最終的な出力。始めは、塗ることが可能であるとして初期化してある

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]

for i in range(H):
    for j in range(W):
        if paint_map[i][j] == "#":
            found = False  # 注目している黒マスの周りに、別の黒マスを見つけたか

            for k in range(k):
                ii = i + dx[k]
                jj = j + dy[k]

                if (H > ii >= 0) & (W > jj >= 0) & (paint_map[ii][jj] == "#"):  # 注目している座標がキャンパス上にあり、かつ黒色なら。
                    found = True

            if not found:  # もしも注目している黒マスの周りに、別の黒マスが見つからなかったら
                ans = False

print("Yes") if ans else print("No")

Fixed submission:
# 方針：黒く塗られるべきマスの隣（縦or横）に、同様のマスがあれば塗れる→Yes
# 逆に、黒く塗られるべきマスに接していない、黒く塗られるべきマスがあると、達成は不可能→No

# 行数・列数の入力(Row, Column)
R, C = list(map(int, input().split(" ")))
# print(R, C)

# Want map = 設計図、Can map = 塗れるかのマップ
want_map = []
can_map = []

for r in range(R):
    # 一行ずつ、両マップを更新
    want_map.append(list(input()))
    can_map.append(["?"] * C)
#    print("Want Map: {}".format(want_map))

    for c in range(C):
        if can_map[r][c] != "feasible":
            if want_map[r][c] == ".":
                can_map[r][c] = "feasible"

            else:
                if c + 1 < C:
                    if want_map[r][c+1] == "#":
                        can_map[r][c] = "feasible"
                        can_map[r][c+1] = "feasible"
        else:
            if c + 1 < C:
                if want_map[r][c + 1] == "#":
                    can_map[r][c + 1] = "feasible"

        if r != 0:
            if (want_map[r][c] == "#") & (want_map[r-1][c] == "#"):
                can_map[r][c] = "feasible"
                can_map[r-1][c] = "feasible"

#    print("Can Map: {}".format(can_map))


# can_mapの中に"?"が残っていたらNo, なければYes
can_elements = []

for can_map_row in can_map:
    can_elements.extend(can_map_row)

if "?" in can_elements:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
A, B, C, X, Y = list(map(int, input().split()))

# A 1枚、B 1枚を2C円で買うと捉え直す。
# ピザは、最大でも10**5枚（A, Bそれぞれに対して）
# A, Bのセットを、1~10**セットまで動かして一番安い組を考える

cheapest = float("inf")

for i in range(max(X, Y) + 1):

    price = 2 * C * i + A * max(0, X - i) + B * max(Y - i)

    cheapest = min(cheapest, price)

print(cheapest)


Fixed submission:
A, B, C, X, Y = list(map(int, input().split()))

# A 1枚、B 1枚を2C円で買うと捉え直す。
# ピザは、最大でも10**5枚（A, Bそれぞれに対して）
# A, Bのセットを、1~10**セットまで動かして一番安い組を考える

cheapest = float("inf")

for i in range(max(X, Y) + 1):

    price = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i)

    cheapest = min(cheapest, price)

print(cheapest)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
x = np.array(list(map(int, input().split(" "))))

sorted_x = sorted(x)
sorted_ind = list(np.argsort(x))
half_n = int(n / 2)

# print(x)
# print(half_n)
# print(sorted_ind)
# print(sorted_x)

for i in range(n):
    # print("==========")
    ind = sorted_ind.index(i)
    # print("ind: {}".format(ind))
    if ind <= half_n - 1:
        print(sorted_x[half_n - 1 + 1])
    else:
        print(sorted_x[half_n - 1])


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

sorted_x = sorted(x)

median_1 = sorted_x[n//2-1]
median_2 = sorted_x[n//2]

for i in range(n):
    if x[i] <= median_1:
        print(median_2)
    else:
        print(median_1)
Buggy python submission (verdict: Runtime Error):
a, b, k = list(map(int, input().split()))

l = list(range(a, b + 1))
l_low = l[:k]
l_up = l[-k:]

ll = sorted(list(set(l_low + l_up)))
for i in ll:
    print(i)


Fixed submission:
a, b, k = map(int, input().split())

a_upper = min(b, a+k-1)
b_lower = max(a, b-k+1)

u = set(range(a, a_upper+1))
v = set(range(b_lower, b+1))

for i in sorted(list(u | v)):
    print(i)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

l = list(range(a, b + 1))
l_low = l[:k]
l_up = l[-k:]

ll = sorted(list(set(l_low + l_up)))

for i in ll:
    print(i)



Fixed submission:
a, b, k = map(int, input().split())

a_upper = min(b, a+k-1)
b_lower = max(a, b-k+1)

u = set(range(a, a_upper+1))
v = set(range(b_lower, b+1))

for i in sorted(list(u | v)):
    print(i)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

l = list(range(a, b + 1))
l_low = l[:k]
l_up = l[-k:]

ll = sorted(list(set(l_low + l_up)))
for i in ll:
    print(i)



Fixed submission:
a, b, k = map(int, input().split())

a_upper = min(b, a+k-1)
b_lower = max(a, b-k+1)

u = set(range(a, a_upper+1))
v = set(range(b_lower, b+1))

for i in sorted(list(u | v)):
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            C_j, S_j, F_j = train_info[j - 1]
            while True:
                if (t >= S_j) & (t % F_j == 0):
                    t += C_j
                    break
                else:
                    t += 1

        print(t)


Fixed submission:
n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            # print("t = {}".format(t))
            C_j, S_j, F_j = train_info[j - 1]
            if t <= S_j:
                t = S_j + C_j
            elif t % F_j == 0:
                t += C_j
            else:
                t += F_j - t % F_j
                t += C_j

        print(t)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
T = []

for _ in range(n):
    T.append(int(input()))

print(lcm(*T))


Fixed submission:
from functools import reduce


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


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
T = []

for _ in range(n):
    T.append(int(input()))

print(lcm(*T))