Harryxun/stf_run huggingface dataset:
from collections import defaultdict

n, m = map(int, input().split())
A = list(map(int, input().split()))
dic = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
usable = defaultdict(int)

for num in A:
    use = dic[num]
    if usable[use] < num:
        usable[use] = num

DP = [-1]*(n+1)
DP[0] = 0

for i in range(n):
    digits = DP[i]
    if digits < 0:
        continue

    for use in usable.keys():
        if i+use <= n and DP[i+use] < digits + 1:
            DP[i+use] = digits + 1
        else:
            continue

digits = DP[n]
num_of_match = n
ans = ''

for _ in range(n):
    if digits == 0:
        break

    for num in sorted(usable.values(), reverse=True):
        use = dic[num]
        if DP[num_of_match - use] == digits - 1:
            digits -= 1
            num_of_match -= use
            ans += str(num)
            break
        else:
            continue

print(ans)


### FIXED CODE ###

from collections import defaultdict

n, m = map(int, input().split())
A = list(map(int, input().split()))
dic = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
usable = defaultdict(int)

for num in A:
    use = dic[num]
    if usable[use] < num:
        usable[use] = num

DP = [-1]*(n+10)
DP[0] = 0

for i in range(n):
    digits = DP[i]
    if digits < 0:
        continue

    for use in usable.keys():
        if i+use <= n and DP[i+use] < digits + 1:
            DP[i+use] = digits + 1
        else:
            continue

digits = DP[n]
num_of_match = n
ans = ''

for _ in range(n):
    if digits == 0:
        break

    for num in sorted(usable.values(), reverse=True):
        use = dic[num]
        if DP[num_of_match - use] == digits - 1:
            digits -= 1
            num_of_match -= use
            ans += str(num)
            break
        else:
            continue

print(ans)
s = input()

if s // 2 ==1:
	print('Np')
	exit()

if s == "hi"* (s // 2):
	print('Yes')
else:
	print('No')

### FIXED CODE ###


s = input()

if len(s) % 2 ==1:
	print('No')
	exit()

if s == "hi"* (len(s) // 2):
	print('Yes')
else:
	print('No')
from heapq import heappush, heappop
 
 
class Dijk:
    def __init__(self, n):
        self.table = [[] for i in range(n+1)]
        self.n = n+1
 
    def add(self, x, y, f):
        self.table[x].append((y, f))
 
    def di(self, s):
        inf = float('inf')
        self.val = [inf] * self.n
        self.val[s] = 0
        h = []
        heappush(h, (0, s))
        while h:
            q, i = heappop(h)
            if self.val[i] < q:
                continue
            for x, c in self.table[i]:
                if self.val[x] > self.val[i] + c:
                    self.val[x] = self.val[i] + c
                    heappush(h, (self.val[x], x))
 
    def dist(self, s, t):
        return self.val[t]

n= int(input())
dijk=Dijk(n)

for i in range(n-1):
    a,b,c=map(int,input().split())
    dijk.add(a,b,c)
    dijk.add(b,a,c)
q,k=map(int,input().split())
for i in range(q):
    x,y=map(int,input().split())
    dijk.di(x)
    ans=dijk.dist(x,i+1)
    dijk.di(i+1)
    ans+=dijk.dist(i+1,y)
    print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[None]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy] is not None:
            continue
        set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])
a, b = list(map(int, input().split()))
if a >= 10 or b >= 10:
    print('-1')
else:
    print(a*b)


### FIXED CODE ###

n = int(input())
for i in range(1, 10):
    if n % i == 0 and n // i < 10:
        print('Yes')
        exit()
print('No')
x1,x2,x3,x4=map(int,input().split())
dx=abs(x1-x2)
dy=abs(y1-y2)
if x1<x2 and y1<=y2:
    x3=x2-dy
    y3=y2+dx
    x4=x3-dx
    y4=y3-dy
    #ok
elif x1>=x2 and y1<y2:
    x3=x2-dy
    y3=y2-dx
    x4=x3+dx
    y4=y3-dy
    #ok
elif x1>x2 and y1>=y2:
    x3=x2+dy
    y3=y2-dx
    x4=x3+dx
    y4=y3+dy
elif x1<=x2 and y1>y2:
    x3=x2+dy
    y3=y2+dx
    x4=x3-dx
    y4=y3+dy
else:
    print("NA")
print(x3,y3,x4,y4)

### FIXED CODE ###

x1,y1,x2,y2=map(int,input().split())
dx=abs(x1-x2)
dy=abs(y1-y2)
if x1<x2 and y1<=y2:
    x3=x2-dy
    y3=y2+dx
    x4=x3-dx
    y4=y3-dy
elif x1>=x2 and y1<y2:
    x3=x2-dy
    y3=y2-dx
    x4=x3+dx
    y4=y3-dy
elif x1>x2 and y1>=y2:
    x3=x2+dy
    y3=y2-dx
    x4=x3+dx
    y4=y3+dy
elif x1<=x2 and y1>y2:
    x3=x2+dy
    y3=y2+dx
    x4=x3-dx
    y4=y3+dy
else:
    print("NA")
print(x3,y3,x4,y4)
import sys
from math import cos, radians, pi, sqrt
import numpy as np
import pandas as pd

inputs = input()
inputs = inputs.split('\n')

N = int(inputs[0].split()[0])
M = int(inputs[0].split()[1])

i = 1
dic = {}
for i in range(1, M+1):
#	print("探索%d回目" % i)
	param = inputs[i].split()
	A = param[0]
	B = param[1]

	if A in dic.keys():
		dic[A].append(B)
	else:
		dic[A] = []
		dic[A].append(B)

	if B in dic.keys():
		dic[B].append(A)
	else:
		dic[B] = []
		dic[B].append(A)
	
depth = {'1': 0}
que = dic['1']
count=1

while not que == []:
	next_que = []
	for room in que:
		if room in depth.keys():
			continue

		depth[room] = count
		for next_room in dic[str(room)]:
			if not next_room in next_que:
				next_que.append(next_room)
	count += 1
	que = next_que

dist = {}
for i in range(2, N+1):
	for room, dep in depth.items():
		if depth[str(i)]-1 == dep:
			dist[str(i)] = room
			break

print("yes")
for opt in dist.items():
	print(opt[1])

### FIXED CODE ###

n,m = map(int,input().split())
visited = [-1 for _ in range(n+1)]
visited[1] = 0
will = []
root = [[] for _ in range(n+1)] 
for i in range(m):
    a,b = map(int,input().split())
    root[a].append(b)
    root[b].append(a)

will.append(1)

while will:
    visit = will.pop(0)
    for i in root[visit]:
        if visited[i] != -1:
            continue
        will.append(i)
        visited[i] = visit

if visited[1:] == -1:
    print('No')
else:
    print('Yes')
    for i in range(2,len(visited)):
        print(visited[i])
o=list(input())
e=list(input())
p=[]
l=len(o)
for a in range(l):
    p.append(o.pop(0))
    p.append(e.pop(0))
if len(o):
    p.append(o.pop(0))
print("".join(p))

### FIXED CODE ###

o=list(input())
e=list(input())
p=[]
l=len(o)
while len(o)+len(e):
    p.append(o.pop(0))
    if len(e):
        p.append(e.pop(0))
print("".join(p))
N = int(input())
A = list(map(int,input().split()))
d = [0]*2*10*9
ans = 0
for i in range(N):
    d[i+1+A[i]] += 1
    
for i in range(1,N+1):
    f = A[-i]+N+1-i-(2*A[-i])
    if f >= 0:
        ans += d[f]
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
d = [0]*(10**6)
ans = 0
for i in range(N):
    m = i+1+A[i]
    if m < 10**6:
        d[i+1+A[i]] += 1
    
for i in range(1,N+1):
    f = A[-i]+N+1-i-(2*A[-i])
    if f >= 0 and f < 10**6:
        ans += d[f]
print(ans)
import sys

def inp():
    for line in sys.stdin:
        word = line.split()
        je(word[0])

def je(word):
    ans, i = 0, 0
    while True:
        if word[i] == "M":
            ans += 1000
        elif word[i] == "D":
            ans += 500
        elif word[i] == "C":
            ans += 100
            try:
                if word[i + 1] == "D":
                    ans += 300
                    i += 1
                elif word[i + 1] == "M":
                    ans += 800
                    i += 1
            except:pass
        elif word[i] == "L":
            ans += 50
            try:
                if word[i - 1] == "X":
                    ans -= 10
                    i += 1
            except: pass
        elif word[i] == "X":
            ans += 10
            try:
                if word[i + 1] == "I" and word[i + 2] == "X":
                    ans += 9
                    i += 2
                elif word[i + 1] == "C":
                    ans += 80
                    i += 1

            except: pass
        elif word[i] == "V":
            ans += 5
        elif word[i] == "I":
            ans += 1
            try:
                if word[i + 1] == "V":
                    ans += 4
                    i += 1
                if word[i + 1] == "X":
                    ans += 8
                    i += 1
            except: pass
        i += 1
        if i == len(word):
            print ans
            break

if __name__ == "__main__":
    inp()

### FIXED CODE ###

#encoding=utf-8
import sys

def inp():
    for line in sys.stdin:
        word = line.split()
        je(word[0])

def je(word):
    ans, i = 0, 0
    while True:
        if word[i] == "M":
            ans += 1000
        elif word[i] == "D":
            ans += 500
        elif word[i] == "C":
            ans += 100
            try:
                if word[i + 1] == "M":
                    ans += 800
                    i += 1
                elif word[i + 1] == "D":
                    ans += 300
                    i += 1
            except: pass

        elif word[i] == "L":
            ans += 50
        elif word[i] == "X":
            ans += 10
            try:
                if word[i + 1] == "C":
                    ans += 80
                    i += 1
                elif word[i + 1] == "L":
                    ans += 30
                    i += 1
            except: pass

        elif word[i] == "V":
            ans += 5
        elif word[i] == "I":
            ans += 1
            try:
                if word[i + 1] == "X":
                    ans += 8
                    i += 1
                elif word[i + 1] == "V":
                    ans += 3
                    i += 1
            except: pass

        i += 1
        if i == len(word):
            print ans
            break

if __name__ == "__main__":
    inp()
A B = map(int,input().split(' '))
print((A-1) * (B-1))

### FIXED CODE ###

A, B = map(int,input().split(' '))
print((A-1) * (B-1))
import numpy as np

N = int(input())
A = list( map(int, input().split()))
A.sort()

ans = int(0)
if(A[0] == 0):
    ans = 0
else:
    ans = np.prod(A)

if ans >= 1e18:
    print('-1')
else:
    print(f'{ans}')

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
MAX = 1e18

A.sort()

ans = 1
for i in A:
    ans *= i
    if ans > MAX:
        ans = -1
        break

print(ans)
import bisect

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

for i in range(n):
    c.append(int(input()))

INF = 100000000
dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_left(dp,c[i])] = c[i]

print(n - bisect.bisect_left(dp,INF)+1)


### FIXED CODE ###

import bisect

INF = 10000000000

n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())
    a[i] = - a[i]

dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_right(dp,a[i])] = a[i]
    
print(bisect.bisect_left(dp,INF))
n = int(input())
print(int(n*(n-1)/2)

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
import sys
sys.setrecursionlimit(10**9)

n = int(input())
mod = 10**9 + 7

dp = {}


def rec(i, zero, nine):
    if (i, zero, nine) in dp:
        return dp[(i, zero, nine)]
    if i == n:
        return 1 if (zero and nine) else 0
    ret = 0
    for j in range(10):
        if j == 0:
            ret += rec(i + 1, True, nine)
        elif j == 9:
            ret += rec(i + 1, zero, True)
        else:
            ret += rec(i + 1, zero, nine)
        ret %= mod
    ret %= mod
    dp[(i, zero, nine)] = ret
    return ret


print(rec(0, False, False))
# 869121

# 2511445


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

n = int(input())
mod = 10**9 + 7

# 再帰だとなんか通らん
# dp = {}
# def rec(i, zero, nine):
#     if (i, zero, nine) in dp:
#         return dp[(i, zero, nine)]
#     if i == n:
#         return 1 if (zero and nine) else 0
#     ret = 0
#     for j in range(10):
#         if j == 0:
#             ret += rec(i + 1, True, nine)
#         elif j == 9:
#             ret += rec(i + 1, zero, True)
#         else:
#             ret += rec(i + 1, zero, nine)
#         ret %= mod
#     dp[(i, zero, nine)] = ret
#     return ret

# print(rec(0, False, False))

dp = [[[0 for _ in range(2)] for _ in range(2)] for _ in range(10**6 + 10101)]
dp[0][0][0] = 1  # どういう意味なのかは不明
for i in range(n):
    for j in range(2):
        for k in range(2):
            for m in range(10):
                if m == 0:
                    dp[i + 1][1][k] += dp[i][j][k]
                    dp[i + 1][1][k] %= mod
                elif m == 9:
                    dp[i + 1][j][1] += dp[i][j][k]
                    dp[i + 1][j][1] %= mod
                else:
                    dp[i + 1][j][k] += dp[i][j][k]
                    dp[i + 1][j][k] %= mod
print(dp[n][1][1])
# 869121

# 2511445
import collections
n, m = map(int, input().split())
linked = collections.defaultdict(set)
for i in range(1, n + 1):
  linked[i].add(i)

for i in range(m):
  a, b = map(int, input().split())
  if len(linked[a]) > len(linked[b]):
     tmp = a
     a = b
     b = tmp
  linked[a].add(linked[b])
  tmp =linked[a]

  for t in linked[b]:
    linked[t] = tmp

n_connected = 0
n_group = 0
for s in linked.values():
  if s:
    n_group += 1
    n_connected += len(s)
    s.clear()
print((n - n_connected) + (n_group - 1))


### FIXED CODE ###

import collections
n, m = map(int, input().split())
linked = collections.defaultdict(list)
i2group = dict()

gid = n + 1
def get_root(i):
  if i not in linked:
    return i
  j = get_root(linked[i])
  linked[i] = j
  return j

def get_groups():
  return [get_root(i) for i in range(1, n + 1)]

for i in range(m):
  a, b = map(int, input().split())
  ra, rb = get_root(a), get_root(b)
  if ra == rb: continue
  linked[ra] = gid
  linked[rb] = gid
  gid += 1

g = get_groups()
print(len(set(g)) - 1)
exit()

n_connected = 0
n_group = 0
for s in linked.values():
  s = s[0]
  if s:
    n_group += 1
    n_connected += len(s)
    s.clear()
print((n - n_connected) + (n_group - 1))
import sys

A, B =map(int, input().split())
count = 1

if(A>=B):
    print('1')
    sys.exit()

B-=A
while True:
    B-=(A-1)
    if(B<=0):
        print(count)
        sys.exit()
    count+=

### FIXED CODE ###

import sys

A, B =map(int, input().split())
x = 0

if(B==1):
    print('0')
    sys.exit()

while True:
    if(A+(A-1)*x>=B):
        print(x+1)
        sys.exit()
    x+=1
import sys
for line in iter(sys.stdin.readline, ""):
	foo=map(str, line.strip().split())
	stack=[]
	while (foo!=[]):
		if foo[0]=='+':
			del foo[0]
			stack.append(int(stack.pop())+int(stack.pop()))
		elif foo[0]=='*':
			del foo[0]
			stack.append(int(stack.pop())*int(stack.pop()))
		elif foo[0]=='-':
			del foo[0]
			stack.append(-int(stack.pop())+int(stack.pop()))
		elif foo[0]=='/':
			del foo[0]
			stack.append(1.0/int(stack.pop())*int(stack.pop()))
		else:
			stack.append(foo.pop(0))
	print "{:.6f}".format(stack[0]+0)

### FIXED CODE ###

import sys
for line in sys.stdin.readlines():
	stack=[]
	for foo in line.strip().split():
		if foo=="+":
			foo=stack.pop()+stack.pop()
		elif foo=="*":
			foo=stack.pop()*stack.pop()
		elif foo=="-":
			foo=-stack.pop()+stack.pop()
		elif foo=="/":
			foo=1.0/stack.pop()*stack.pop()
		stack.append(float(foo))
	print "{:.6f}".format(stack[0]+0)
def dfs(graph, start):
    visited = set([start])
    stack = [start]

    while stack:
        v = stack[-1]
        for w in graph[v]:
            if w not in visited:
                break

        if w in visited:
            stack.pop()
            yield v
        else:
            stack.append(w)
            visited.add(w)


def read_graph(nodes, edges):
    graph = [[] for _ in range(nodes)]
    for _ in range(edges):
        a, b = (int(x) - 1 for x in input().split())
        graph[a].append(b)
        graph[b].append(a)

    return graph


def count_candidates(n, counts, groups, block, friend):
    for i in range(n):
        count = counts[groups[i]]
        for v in block[i]:
            if groups[i] == groups[v]:
                count -= 1

        count -= len(friend[i])
        count -= 1
        yield count


def main():
    n, m, k = map(int, input().split())
    friend = read_graph(n, m)
    block = read_graph(n, k)

    groups = [-1 for _ in range(n)]
    counts = []
    i = 0
    group_id = 0
    while i < n:
        if groups[i] != -1:
            i += 1
            continue

        for j, v in enumerate(dfs(friend, i)):
            groups[v] = group_id

        counts.append(j + 1)
        group_id += 1

    print(" ".join(str(i) for i in count_candidates(n, counts, groups, block, friend)))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def dfs(graph, start):
    visited = set()
    stack = [start]

    while stack:
        v = stack.pop()
        if v not in visited:
            stack.extend(graph[v])
            visited.add(v)
            yield v


def read_graph(nodes, edges):
    graph = [[] for _ in range(nodes)]
    for _ in range(edges):
        a, b = (int(x) - 1 for x in input().split())
        graph[a].append(b)
        graph[b].append(a)

    return graph


def count_candidates(n, counts, groups, block, friend):
    for i in range(n):
        count = counts[groups[i]]
        for v in block[i]:
            if groups[i] == groups[v]:
                count -= 1

        count -= len(friend[i])
        count -= 1
        yield count


def main():
    n, m, k = map(int, input().split())
    friend = read_graph(n, m)
    block = read_graph(n, k)

    groups = [-1 for _ in range(n)]
    counts = []
    i = 0
    group_id = 0
    while i < n:
        if groups[i] != -1:
            i += 1
            continue

        for j, v in enumerate(dfs(friend, i)):
            groups[v] = group_id

        counts.append(j + 1)
        group_id += 1

    print(" ".join(str(i) for i in count_candidates(n, counts, groups, block, friend)))


if __name__ == "__main__":
    main()
( a, b, c) = input().split()

count = 0
for i in range( c):
    if a % c == 0 and b % c == 0:
        count += 1
print( count)

### FIXED CODE ###

( a, b, c) = [int(i) for i in input().split()]

count = 0

for i in range( a, b+1):
    if c % i == 0:
        count += 1
print( count)
import bisect

n,m = map(int, input().split())

n_facs_s = []
n_facs_l = []
for i in range(1, int(-(-n**0.5//1))+1):
    if m%i == 0:
        n_facs_s.append(i)
        n_facs_l.append(m//i)

n_faces = n_facs_s + n_facs_l
ind = bisect.bisect_right(n_faces, n)
print(m//n_faces[ind])


### FIXED CODE ###

import bisect

n,m = map(int, input().split())

n_facs_s = []
n_facs_l = []
for i in range(1, int(-(-m**0.5//1))+1):
    if m%i == 0:
        n_facs_s.append(i)
        n_facs_l.append(m//i)


n_faces = n_facs_s + n_facs_l[::-1]
ind = bisect.bisect_right(n_faces, n)
if n_faces[ind-1] == n:
    ind-=1
print(m//n_faces[ind])
import math
N,K=map(int, input().split()) 
lst=list()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, K+1):
    lst.append(int(combinations_count(N-K+1, i)) * int(combinations_count(K-i+(i-1), i-1)))
        
for i in range(K):
    print(lst[i]%(10**9+7))

### FIXED CODE ###

import math
n,k=map(int,input().split()) 

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod_num = 10 ** 9 + 7
for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(n-k+1, i) * comb(k-i+(i-1), i-1) % mod_num)
"""
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def ngcd(li):
    temp=gcd(li[0], li[1])
    if len(li)-3 >=0:
        for i in range(len(li)-2):
            temp=gcd(temp, li[i+2])
    return temp
    """

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def ngcd(numbers):
    return reduce(math.gcd, numbers)

n=int(input())
a=[int(i) for i in input().split()]

t=a[0]
t2=a[1]
out=0
f=1
min=10**9+1
for i in range(0, len(a)):
  gcd2=gcd(t, a[i])
  if gcd2<min:
    min=gcd2
    out=i
    #print(t, a[i],out, min)
"""
min=10**9+1
for i in range(0, len(a)):
  gcd2=gcd(t2, a[i])
  if gcd2<min:
    min=gcd2
    out=i
    print(t2, a[i],out, min)


print(out)
"""

"""
  if not (a[i]%t==0 or t %a[i]==0):
    if f:
      out=i
      f=0
    elif not f:
      out=0
"""
if not len(a)==2:
  temp=a[0:out]
  temp.extend(a[out+1:])
  #print(temp)
  itemp=ngcd(temp)
  itemp2=ngcd(a[1:])
  #print(itemp, itemp2)
  print(max(itemp, itemp2))
else:
  print(max(a[0], a[1]))


"""
max=0
for i in range(len(a)):
    temp=a[0:i]
    temp.extend(a[i+1:])
    itemp=ngcd(temp)
    if max < itemp:
        max=itemp

print(max)
"""

### FIXED CODE ###

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

def ngcd(li):
    temp=gcd(li[0], li[1])
    if len(li)-3 >=0:
        for i in range(2, len(li)):
            temp=gcd(temp, li[i])
    return temp


n=int(input())
a=[int(i) for i in input().split()]

l=[]
l.append(0)
for i in range(len(a)):
  l.append(gcd(l[i], a[i]))
r=[]
r.append(0)
for i in range(len(a)):
  r.append(gcd(r[i], a[n-i-1]))
#print(l)
#print(r)

ans=[]
for i in range(len(a)):
  ans.append(gcd(l[i], r[n-i-1]))

print(max(ans))
s = input()
ans = 0

def reverse(s,i):
  if s[i] == 'B' and s[i+1] == 'W':
	s[i] = 'W'
	s[i+1] = 'B'
    ans += 1
  
while True:
  s = ans
  for i in range(len(s) - 1):
    reverse(s,i)
  if s == ans:
    print(ans)
    break


### FIXED CODE ###

s = input()
w = 0
b = 0
wa = 0
ba = 0
l = len(s)
 
for i in range(l):
  if s[i] == 'W':
    wa += i - w
    w += 1
  if s[-1-i] == 'B':
    ba += i - b
    b += 1
    
print(min(ba, wa))
import math
n = int(input())
t = [int(input()) for _ in range(n)]
cm = []
t.sort()

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

for i in range(n-1):
    cm.append(lcm(t[i], t[i+1]))

print(max(cm))

### FIXED CODE ###

from fractions import gcd

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


for i in range(n):
    num = t[i]
    result = result * num // gcd(result, num)

print(result)
n = int(input())
a = map(int, input().split())
sunu = sum(a)
arai = 0
ans = 2*10**9
for i in range(n-1):
  sunu -= a[i]
  arai +=  a[i]
  ans = min(ans,abs(sunu-arai))
  
print(ans)
  
  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
sunu = sum(a)
arai = 0
ans = 2*10**9
for i in range(n-1):
  sunu -= a[i]
  arai +=  a[i]
  ans = min(ans,abs(sunu-arai))
  
print(ans)
x = list(map(int, input().split()))

for i in range(x):
    if x[i] == 0:
        print(i+1)
        break

### FIXED CODE ###

x = list(map(int, input().split()))
for i in range(len(x)):
    if x[i] == 0:
        print(i+1)
        break
N = int(input())
Ss=[input() for s in range(N)]
count = [s.count("AB") for s in Ss]
headcount = sum([s for s in Ss if s[0]=="B" and s[-1]!="A"])
outcount = sum([s for s in Ss if s[-1]=="A" and s[0]!="B"])
multicount = sum([s for s in Ss if s[0]=="B" and s[-1]=="A"])
if outcount==0 and headcount==0:
    print(sum(count)+multicount-1)
else:
    print(sum(count)+min(headcount,outcount)+multicount)

### FIXED CODE ###

N = int(input())
Ss=[input() for s in range(N)]
count = [s.count("AB") for s in Ss]
headcount = len([s for s in Ss if s[0]=="B" and s[-1]!="A"])
outcount = len([s for s in Ss if s[-1]=="A" and s[0]!="B"])
multicount = len([s for s in Ss if s[0]=="B" and s[-1]=="A"])
if outcount==0 and headcount==0:
    if multicount<=0:
        print(sum(count))
    else:
        print(sum(count)+multicount-1)
else:
    print(sum(count)+min(headcount,outcount)+multicount)
N = int(input())
a = list(map(int, input().split()))
avg = round(sum(a)/len(a))
sums = []
for i in range(1, avg+1):
    s = 0
    for j in range(N):
        s += (a[j]-i)**2
    sums.append(s)
print(min(sums))

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
avg = round(sum(a)/N)
sums = []
for i in range(min(a), avg+1):
    s = 0
    for j in range(N):
        s += (i-a[j])**2
    sums.append(s)
print(min(sums))
import math
A,B,C,D = map(int, input().split())
d = math.gcd(C, D)
t = C * D / d

m = math.floor(B / C) + math.floor(B / D) - math.floor(B / t)
 
n = math.floor((A-1) / C) + math.floor((A-1) / D ) - math.floor((A-1) / t)

print(B-A+1-m+n)

### FIXED CODE ###

from fractions import gcd
 
A, B, C, D = map(int, input().split())
t = C * D // gcd(C, D)
print((B - (A - 1)) - (B//C + B//D - B//t) + ((A-1)//C + (A-1)//D - (A-1)//t))