Harryxun/stf_run huggingface dataset:
from collections import defaultdict
import bisect

S = input()
T = input()

d = defaultdict(list)
for i, s in enumerate(S, start=1):
    d[s].append(i)

ans = 0
i = 0

for t in T:
    if not d[t]:
        print(-1)
        exit()

    if i > d[t][-1]:
        ans += len(S)
        i = 0
    pos = bisect.bisect_right(d[t], i)
    i = d[t][pos]

ans += i
print(ans)


### FIXED CODE ###

import collections
import bisect
S = input()
T = input()
N = len(S)

d = collections.defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i + 1)

ans = 0
end = 0
isOK = True
i = 0

for t in T:
    if len(d[t]) == 0:
        isOK = False
        break
    dic = d[t]
    idx = bisect.bisect_right(dic, i)
    if len(dic) == idx:
        i = dic[0]
        end += 1
    else:
        i = dic[idx]

if isOK:
    ans = N * end + i
else:
    ans = -1

print(ans)
def main():
  num,capacity,*wv =map(int,open(0).read().split())
  weights,values = wv[::2], wv[1::2]
  DP=[-1]*(capacity+1)
  DP[0]=0
  for w,v in zip(weights, values):
    left=capacity-weight
    DP[weight:]=[max(DP[i]+value,DP[i+weight]) for i in range(left,-1,-1)][::-1]
  print(max(DP))
      
if __name__=="__main__":
  main()

### FIXED CODE ###

n,w=map(int,input().split())
goods=[list(map(int,input().split())) for _ in range(n)]
DP=[[0]*(w+1) for _ in range(n+1)]
for i in list(range(n))[::-1]:
  wi,vi=goods[i][0],goods[i][1]
  for j in range(w+1):
    if j<wi:
      DP[i][j]=DP[i+1][j]
    else:
      DP[i][j]=max(DP[i+1][j],DP[i+1][j-wi]+vi)
print(DP[0][w])
n, m = map(int, input().split())

class UnionfindWithWeight():
    def __init__(self, n):
        self.dist    = [0]  * (n+1)
        self.ranks   = [0]  * (n+1)
        self.parents = [-1] * (n+1)
    def find_root(self, x):
        if self.parents[x] < 0:
            return self.dist[x], x
        else:
            tmp = self.find_root(self.parents[x])
            self.dist[x]    += tmp[0]
            self.parents[x] =  tmp[1]
            return self.dist[x], self.parents[x]
    def union(self, x, y, dist):
        x_root = self.find_root(x)[1]
        y_root = self.find_root(y)[1]
        diff = dist + self.dist[x] - self.dist[y]
        if x_root == y_root and diff != 0:
            return False
        if self.ranks[y_root] > self.ranks[x_root]:
            x_root ,y_root = y_root, x_root
            diff =- diff
        self.parents[y_root] = x_root
        self.dist[y_root] = diff
        if self.ranks[y_root] == self.ranks[x_root]:
            self.ranks[x_root] += 1

v=UnionfindWithWeight(n)
lrd = []
for i in range(m):
    l, r, d = list(map(int, input().split()))
    if v.union(l,r,d):
        print('No')
        import sys
        sys.exit()

print('Yes')


### FIXED CODE ###

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

# it watches only end of union
# for i in range(m):
#     l,r,d = map(int, input().split())
#     if ml[l] == -1 and ml[r] == -1:
#         ml[l] = 0
#         ml[r] = d
#     elif ml[l] != -1 and ml[r] == -1:
#         ml[r] = d + ml[l]
#         if ml[r] > n:
#             print('R', i, ml[l], ml[r], flush=True)
#             print('No', flush=True)
#             sys.exit()
#     elif ml[l] == -1 and ml[r] != -1:
#         ml[l] = ml[r] - d
#         if ml[l] < 1:
#             print('L', i, ml[l], ml[r], flush=True)
#             print('No', flush=True)
#             sys.exit()
#     else:
#         if ml[r] - ml[l] != d:
#             print('B', i, l, ml[l], r, ml[r], d, flush=True)
#             print('No', flush=True)
#             sys.exit()
# print('Yes', flush=True)

class UnionfindWithWeight():
    def __init__(self,n):
        self.parents=[-1]*n
        self.ranks=[0]*n
        self.dist=[0]*n
    def find(self,x):
        if self.parents[x]<0:
            return self.dist[x],x
        else:
            tmp=self.find(self.parents[x])
            self.dist[x]+=tmp[0]
            self.parents[x]=tmp[1]
            return self.dist[x],self.parents[x]
    def union(self,x,y,d):
        rx=self.find(x)[-1]
        ry=self.find(y)[-1]
        diff=d+self.dist[x]-self.dist[y]
        if rx==ry:
            if diff!=0:
                return True
            return False
        if self.ranks[ry]>self.ranks[rx]:
            rx,ry=ry,rx
            diff=-diff
        self.parents[ry]=rx
        self.dist[ry]=diff
        if self.ranks[ry]==self.ranks[rx]:
            self.ranks[rx]+=1
        return False
lrd = []
for i in range(m):
    l,r,d = list(map(int, input().split()))
    lrd.append([l,r,d])
v=UnionfindWithWeight(n)
for i in lrd:
    l, r, d = i
    if v.union(l-1,r-1,d):
        print('No')
        import sys
        sys.exit()
print('Yes')
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 998244353
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def C(n, r):
    return fact[n] * pow(fact[n-r], mod-2, mod) * pow(fact[r], mod-2, mod) % mod

n, m, k = LI()
fact = [1] * (m+1)
for i in range(1, m+1):
    fact[i] = fact[i-1] * i
    fact[i] %= mod

ans = 0
for i in range(k+1):
    ans += C(n-1, i) * m * pow(m-1, n-1-i, mod)
    ans %= mod
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 998244353
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def comb(n,r):
    if r >= n:
        return 1
    return fact[n]*pow(fact[n-r], mod-2, mod)*pow(fact[r], mod-2, mod) % mod

n,m,k = LI()
ans = 0
fact = [1]*(max(n,m)+1)
for i in range(1,n):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

for i in range(k+1):
    ans += comb(n-1, i) * m * pow(m-1, n-i-1, mod)
    ans %= mod
print(ans)
print(int((N=int(input())) * (N+1) /2))


### FIXED CODE ###

N=int(input())
print(int(N * (N+1) /2))
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>10000000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
S=input()
if S[3]==S[4] and S[5]==S[6]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')
a, b, c = map(int, input().split())
def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(sqrt(n) * (1 + 1e-10)))

if 2 * int_sqrt2(a * b) < c - a - b:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a, b, c = map(int, input().split())

d = c - a - b
if d > 0 and d**2 > 4 * a * b:
    print('Yes')
else:
    print('No')
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
List=[a,b,c,d,e]
for i j in range(5):
  if List[i]-List[j]>k:
    print("Yay!")
    break
  else:
    print(":(")

### FIXED CODE ###

List=[int(input()) for i in range(5)]
k=int(input())
if List[-1]-List[0]>k:
    print(":(")
else:
    print("Yay!")
import collections

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

g = [[] for i in range(n+1)]

for i in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)
    
check = [0] * (n+1)
count = [0] * (n+1)

for i in range(q):
    p,x = map(int,input().split())
    count[p] += x
    
def dfs(x):
    check[x] = 1
    for u in g[x]:
        if check[u] == 1:
            continue
        count[u] += count[x]
        dfs(u)
    
dfs(1)

print(*count[1:])

### FIXED CODE ###

import collections

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

g = [[] for i in range(n+1)]

for i in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)

count = [0] * (n+1)
check = [0] * (n+1)

for i in range(q):
    p,x = map(int,input().split())
    count[p] += x

q = collections.deque()  
q.append(1)

while q:
    v = q.pop()
    check[v] = 1
    for u in g[v]:
        if check[u] == 1:
            continue
        count[u] += count[v]
        q.append(u)
        
print(*count[1:])
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
k = list(a_counter.keys())
v = list(a_counter.values())

if len(k) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(k) == 2 and 0 in k and v[0] == v[1]*2 or v[1] == v[0]*2:
    print("Yes")
elif len(k) == 1 and 0 in k :
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
a_counter_li = list(a_counter)
if sum(a) == 0:
    print("Yes")
elif len(a)%3 != 0:
    print("No")
elif len(a_counter) > 3 or len(a_counter) <= 1:
    print("No")
elif len(a_counter) == 3:
    if a_counter[a_counter_li[0]] == n // 3 and a_counter[a_counter_li[1]] == n // 3 and a_counter[a_counter_li[2]] == n // 3:
        if a_counter_li[0]^a_counter_li[1]^a_counter_li[2] == 0:
            print("Yes")
        else:
            print('No')
    else:
        print("No")
else:
    a_counter_li.sort()
    if a_counter_li[0] == 0 and a_counter[a_counter_li[0]] == n // 3:
        print("Yes")
    else:
        print("No")
n=int(input())
l=sorted(list(map(int,input().split())))
if len(set(l))==3:
  h=sorted(list(set(l)),reverse=1)
  ff=len(bin(h[0]))
  p=["0"*(ff-len(bin(s)))+bin(s)[2:] for s in h]
  y=p[0]
  dfg,dgf=p[1],p[2]
  for i in range(ff-2):
    q,w=dfg[i],dgf[i]
    if (q!=w and y[i]=="0") or (q==w and y[i]=="1"):print("No");exit()
  else:
    from collections import Counter as cou
    if len(set(cou(l).values()))==1:print("Yes")
    else:print("No")
elif len(set(l))>=4 or 0 not in set(l):
  print("No")
elif set(l)==set([0]):
  print("Yes")
else:
  if n%3:print("No");exit()
  from collections import Counter as cou
  fl,fll=0,0
  for g,gh in cou(l).items():
    if g==0 and gh==n//3:fl=1
    if g!=0 and gh==2*n//3:fll=1
  print("Yes" if fl and fll else "No"))

### FIXED CODE ###

n=int(input())
l=sorted(list(map(int,input().split())))
if len(set(l))==3:
  h=sorted(list(set(l)),reverse=1)
  ff=len(bin(h[0]))
  p=["0"*(ff-len(bin(s)))+bin(s)[2:] for s in h]
  y=p[0]
  dfg,dgf=p[1],p[2]
  for i in range(ff-2):
    q,w=dfg[i],dgf[i]
    if (q!=w and y[i]=="0") or (q==w and y[i]=="1"):print("No");exit()
  else:
    from collections import Counter as cou
    if len(set(cou(l).values()))==1:print("Yes")
    else:print("No")
elif len(set(l))>=4 or 0 not in set(l):
  print("No")
elif set(l)==set([0]):
  print("Yes")
else:
  if n%3:print("No");exit()
  from collections import Counter as cou
  fl,fll=0,0
  for g,gh in cou(l).items():
    if g==0 and gh==n//3:fl=1
    if g!=0 and gh==2*n//3:fll=1
  print("Yes" if fl and fll else "No")
s = input()
if s[3] == s[4] and s[5] == s[6]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
N = int(input())
A = [0] * (10**4)
import math
import numpy
tmp=0
for i in range(1,int(math.sqrt(N))):
    for j in range(1,int(math.sqrt(N))):
        for k in range(1,int(math.sqrt(N))):
            tmp=(i+j+k)**2-(i*j+j*k+i*k)
            A[tmp]+=1
for p in A[1:N+1]:
    print(p)

### FIXED CODE ###

N = int(input())
A = [0] * (10**4+1)
import math
import numpy
tmp=0
for i in range(1,int(math.sqrt(N))):
    for j in range(1,int(math.sqrt(N))):
        for k in range(1,int(math.sqrt(N))):
            tmp=(i+j+k)**2-(i*j+j*k+i*k)
            if tmp<=10**4:
                A[tmp]+=1
for p in A[1:N+1]:
    print(p)
A, B, C = map(int, input().split())
print(A+C if B == "+" else A-C)

### FIXED CODE ###

A, B, C = map(str, input().split())
print(int(A)+int(C) if B=="+" else int(A)-int(C))
import numpy as np

N = [int(i) for i in input().split()][0]

ls = []
for i in range(N):
  a,b = [i for i in input().split()]
  tmp = [str(a),int(b)]
  ls.append(tmp)

new_ls = sorted(ls, key=lambda x:x[1], reverse=True)
new_ls = sorted(new_ls, key=lambda x:x[0])

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)
      continue

### FIXED CODE ###

A,P = [int(i) for i in input().split()]

print((A*3+P)//2)
s = input()
if(s[2]==s[3] and s[4]==s[5]){print("Yes")}
else{print("No")}

### FIXED CODE ###

s = input()
if(s[2:3]==s[3:4] and s[4:5]==s[5:6]):
  print("Yes")
else:
  print("No")
a=int(input())
b=int(input())
c=int(input())
count=3
if a==b:
    count=count-1
if b==c:
    count=count-1
if c==a:
    count=count-1
print(count)


### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b==c:
    print(1)
elif a==b or b==c or c==a:
    print(2)
else:
    print(3)
# AtCoder
A, B = map(int(input().split()))
if A*B % 2 == 0:
    print('No')
else:
    print('Yes')


### FIXED CODE ###

# AtCoder
A, B = map(int, input().split())
if A*B % 2 == 0:
    print('No')
else:
    print('Yes')
N = int(input())
a = [int(input()) for i in range(N)]
for i in range(len(a)):
  b = a.copy()
  del b[i]
  print((max(b)))

### FIXED CODE ###

N = int(input())
a = [int(input()) for i in range(N)]
amax = max(a)
amax2 = sorted(a)[-2]
for i in range(len(a)):
  if a[i]==amax:
    print(amax2)
  else:
    print(amax)
NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])

tree_dict = {
    1: {
        'count': 0,
        'has_trees': []
    }
}

def f(p,x):
    tree_dict[p]['count'] += x
    for num in tree_dict[p]['has_trees']:
        f(num,x)


#Make tree dict
for _ in range(N-1):
    ab = input().split(' ')
    a = int(ab[0])
    b = int(ab[1])
    tree_dict[a]['has_trees'].append(b)
    if b not in tree_dict.keys():
        tree_dict[b] = {
                'count': 0,
                'has_trees': []
            }

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    f(p,x)

out_put_list = []
for each_dict in tree_dict.values():
    out_put_list.append(str(each_dict['count']))
print(' '.join(out_put_list))

### FIXED CODE ###


NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])
out_put_list = [0] * N
tree_list = {}
for i in range(N):
    tree_list[i] = []

for i in range(N-1):
    ab = input().split(' ')
    a = int(ab[0]) -1
    b = int(ab[1]) -1
    tree_list[a].append(b)

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    out_put_list[p-1] += x

for i in range(len(tree_list)):
    for num in tree_list[i]:
        out_put_list[num] += out_put_list[i]

print(*out_put_list)
from heapq import heappush, heappop
H, W, T, Q = map(int, input().split())
que = []
state = [[0]*W for i in range(H)]
data1 = [[0]*(W+1) for i in range(H+1)]
data2 = [[0]*(W+1) for i in range(H+1)]
def get(data, h, w):
    s = 0
    while h:
        w0 = w
        el = data[h]
        while w0:
            s += el[w0]
            w0 -= w0 & -w0
        h -= h & -h
    return s
def add(data, h, w, x):
    while h <= H:
        w0 = w
        el = data[h]
        while w0 <= W:
            el[w0] += x
            w0 += w0 & -w0
        h += h & -h

for q in range(Q):
    t, c, *ps = map(int, input().split())
    while que and que[0][0] <= t:
        _, h0, w0 = heappop(que)
        add(data1, h0, w0, -1)
        add(data2, h0, w0, 1)
        state[h0][w0] = 2
    if c == 0:
        h0, w0 = ps
        state[h0][w0] = 1
        add(data1, h0, w0, 1)
        heappush(que, (t + T, h0, w0))
    elif c == 1:
        h0, w0 = ps
        if state[h0][w0] == 2:
            add(data2, h0, w0, -1)
            state[h0][w0] = 0
    else:
        h0, w0, h1, w1 = ps
        result1 = get(data1, h1, w1) - get(data1, h1, w0-1) - get(data1, h0-1, w1) + get(data1, h0-1, w0-1)
        result2 = get(data2, h1, w1) - get(data2, h1, w0-1) - get(data2, h0-1, w1) + get(data2, h0-1, w0-1)
        print(result2, result1)

### FIXED CODE ###

from heapq import heappush, heappop
H, W, T, Q = map(int, input().split())
que = []
state = [[0]*(W+1) for i in range(H+1)]
data1 = [[0]*(W+1) for i in range(H+1)]
data2 = [[0]*(W+1) for i in range(H+1)]
def get(data, h, w):
    s = 0
    while h:
        w0 = w
        el = data[h]
        while w0:
            s += el[w0]
            w0 -= w0 & -w0
        h -= h & -h
    return s
def add(data, h, w, x):
    while h <= H:
        w0 = w
        el = data[h]
        while w0 <= W:
            el[w0] += x
            w0 += w0 & -w0
        h += h & -h

for q in range(Q):
    t, c, *ps = map(int, input().split())
    while que and que[0][0] <= t:
        _, h0, w0 = heappop(que)
        add(data1, h0, w0, -1)
        add(data2, h0, w0, 1)
        state[h0][w0] = 2
    if c == 0:
        h0, w0 = ps
        state[h0][w0] = 1
        add(data1, h0, w0, 1)
        heappush(que, (t + T, h0, w0))
    elif c == 1:
        h0, w0 = ps
        if state[h0][w0] == 2:
            add(data2, h0, w0, -1)
            state[h0][w0] = 0
    else:
        h0, w0, h1, w1 = ps
        result1 = get(data1, h1, w1) - get(data1, h1, w0-1) - get(data1, h0-1, w1) + get(data1, h0-1, w0-1)
        result2 = get(data2, h1, w1) - get(data2, h1, w0-1) - get(data2, h0-1, w1) + get(data2, h0-1, w0-1)
        print(result2, result1)
import sys
input = sys.stdin.readline

x, n = [int(x) for x in input().split()]
if n == 0:
    q = [x for x in range(1, 101)]
else:
    p = [int(x) for x in input().split()]
    q = [x for x in range(1, 101) if x not in p]

diffs = [abs(x-qk) for qk in q]
mindiff = min(diffs)
idx = diffs.index(mindiff)
print(q[idx])

### FIXED CODE ###

import sys
input = sys.stdin.readline

def calc():
    x, n = [int(x) for x in input().split()]

    if n == 0:
        q = [x for x in range(102)]
    else:
        p = [int(x) for x in input().split()]
        q = [x for x in range(102) if x not in p]
    diffs = [abs(x - qk) for qk in q]
    mindiff = min(diffs)
    idx = diffs.index(mindiff)
    print(q[idx])

calc()
N, K = map(int, input().split(' '))
if 2 * N < K:
    return N
else:
    a = N // K
    mm = min(abs(N - a * K), abs(N - (a + 1) * K))
    return mm

### FIXED CODE ###

N, K = map(int, input().split(' '))
if 2 * N < K:
    print(N)
else:
    a = N // K
    mm = min(abs(N - a * K), abs(N - (a + 1) * K))
    print(mm)
n = input()
digit = n % 10
if digit == 3:
  print("bon")
elif digit == 0 or digit == 1 or digit == 6 or digit == 8:
  print("pon")
else:
  print("hon")


### FIXED CODE ###

ninput = input() #これはstr型
n = int(ninput) #これでint型に直す
digit = n % 10
if digit == 3:
  print('bon')
elif digit == 0 or digit == 1 or digit == 6 or digit == 8:
  print('pon')
else:
  print('hon')
N,M=map(int,input().split())
List = []
for i in range (M):
  List.append(int(input()))
#任意の数Kに対してたどり着く通り数
INF = 100000000000
stepList = [INF]*(N+1)
stepList[0] = 1
stepList[1] = 1
stepList[2] = 2
def stepF(K):
  if K == 0:
    return stepList[0]
  else:
    for i in range(1,K+1):
      if i == 1 or i == 2:
        pass
      else:
        if stepList[i]==INF:
          stepList[i]= stepList[i-2] + stepList[i-1]
    return stepList[K]
flag = True
#任意の数aが壊れている場合
res = 1
for i in range(M):
  if i == 0:
    res = stepF(List[i]-1)
  else:
    if List[i] - List[i-1] == 1:
      flag = False
      break
    res = res * stepF(List[i]-List[i-1]-2)
res = res * stepF(N-List[M-1]-1)

if flag:
  print(res%1000000007)
else:
  print(0)

### FIXED CODE ###

N,M=map(int,input().split())
res = 0
flag = True
#任意の数Kに対してたどり着く通り数
INF = 100000000000
stepList = [INF]*(N+1)
stepList[0] = 1
stepList[1] = 1
def stepF(K):
  if K == 0:
    return stepList[0]
  else:
    for i in range(1,K+1):
      if i == 1:
        pass
      else:
        if stepList[i]==INF:
          stepList[i]= stepList[i-2] + stepList[i-1]
    return stepList[K]
  
if M == 0:
  res = stepF(N)
  
else:
  List = []
  for i in range (M):
    List.append(int(input()))
  #任意の数aが壊れている場合
  
  for i in range(M):
    if i == 0:
      res = stepF(List[i]-1)
    else:
      if List[i] - List[i-1] == 1:
        flag = False
        break
      res = res * stepF(List[i]-List[i-1]-2)
  res = res * stepF(N-List[M-1]-1)
if flag:
  print(res%1000000007)
else:
  print(0)
def Sol(taka_health,taka_stregnth,aoki_health,aoki_stregnth):
    
    if taka_health%aoki_stregnth != 0:
        moves_taka = int(taka_health/aoki_stregnth) + 1
    else:
        moves_taka = int(taka_health/aoki_stregnth)
    
    if aoki_health%taka_stregnth != 0:
        moves_aoki =int(aoki_health/taka_stregnth) + 1
    else:
        moves_aoki = int(aoki_health/taka_stregnth)
    
    print(moves_aoki,moves_taka)
    if moves_taka > moves_aoki:
        print("Yes")
    else:
        print("No")
    return

    

#for t in range(int(input())):
n,k,d,c = map(int,input().split())
#n = int(input())
#arr = []
#for i in range(n):
#    time = list(map(int,input().split()))
#    time = time[0] + (time[1]/60)
#    arr.append(time)
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(n,k,d,c)


### FIXED CODE ###


def Sol(s,w):
    
    if s>w:
        print("safe")
    else:
        print("unsafe")
    
    return

    

#for t in range(int(input())):
n,k = map(int,input().split())
#n = int(input())
#arr = []
#for i in range(n):
#    time = list(map(int,input().split()))
#    time = time[0] + (time[1]/60)
#    arr.append(time)
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(n,k)
n = int(input())
k = int(input())
x = int(input())
y = int(input())
sum = 0
if (n >= k):
	sum = k*x + (n - k)*y
    print(sum)
else:
	sum = n*x
    print(sum)

### FIXED CODE ###

n = int(input())
k = int(input())
x = int(input())
y = int(input())
sum = 0
if n>=k:
  sum = k*x + (n - k)*y
  print(sum)
	
else:
  sum = n*x
  print(sum)
import math

n = int(input())
s = int(input())

b = -1

def keisan(k, w):
  l = []
  while k >= w:
    l.append(k % w)
    k = k // w
  else:
    l.append(k)
  return (sum(l))

if n == s:
  b = n + 1
  print(b)
  exit()
  
if n < s:
  b = -1
  print(b)
  exit()

n_r = math.floor(math.sqrt(n))

for i in range(2, n_r+1):
  if keisan(n, i) == s:
    b = i
    print(b)
    exit()

for i in range(1, n_r+1):
  w = n - s
  syou = w // i
  amari = w % i
  if syou > n_r-1 and amari == 0:
    b_list = []
    b_kouho = syou + 1
    b_list.append(b_kouho)
  
if b_list != []:
  print(min(b_list))
else:
  print(-1)

### FIXED CODE ###

import math

n = int(input())
s = int(input())

b = -1

def keisan(k, w):
  l = []
  while k >= w:
    l.append(k % w)
    k = k // w
  else:
    l.append(k)
  return (sum(l))

if n == s:
  b = n + 1
  print(b)
  exit()
  
if n < s:
  b = -1
  print(b)
  exit()

n_r = math.floor(math.sqrt(n))

for i in range(2, n_r+1):
  if keisan(n, i) == s:
    b = i
    print(b)
    exit()

b_list = []    
    
for i in range(1, n_r+1):
  w = n - s
  syou = w // i
  amari = w % i
  if amari == 0:
    b_kouho = syou + 1
    b_list.append(b_kouho)
#    print(b_list)

b_kansei = []

for b in b_list:
  b_ = keisan(n, b)
  if b_ == s:
    b_kansei.append(b)
#    print("b_kanseiは" + str(b_kansei))

if b_kansei != []:
  print(min(b_kansei))
else:
  print(-1)
= int(input())
T = sorted([int(input()) for i in range(N)])

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

if N == 1:
    print(T[0])
else:
    ans = T[0]
    for i in range(1, N):
        ans = (ans*T[i])//(gcd(ans, T[i]))
    
    print(ans)

### FIXED CODE ###

import fractions
N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]

for i in range(1, N):
    ans = (ans * T[i]) // (fractions.gcd(ans, T[i]))
    
print(ans)
#https://mathtrain.jp/abequalgl