Harryxun/stf_run huggingface dataset:
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n,m,l=map(int,input().split())
ll=[]
for i in range(m):
    a,b,c=[int(j) for j in input().split()]
    if c<=l:
        ll.append((a,b,c))
if ll==[]:
    print(-1)
    exit()
edge=np.array(ll,dtype=np.int64).T
graph=csr_matrix(((edge[2],edge[:2]-1)),(n,n))

#False->無向グラフ True->有効グラフ
ans=floyd_warshall(graph,directed=False)
v=[]
for i in range(n):
    for j in range(n):
        if ans[i][j]<=l:
            v.append((i+1,j+1,1))

edge=np.array(v,dtype=np.int64).T
graph=csr_matrix(((edge[2],edge[:2]-1)),(n,n))
ans2=floyd_warshall(graph,directed=False)

q=int(input())
st=[]
for i in range(q):
    st.append([int(j)-1 for j in input().split()])

for i,j in st:
    if int(ans2[i][j])==float("inf"):
        print(-1)
    else:
        print(int(ans2[i][j])-1)


### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import floyd_warshall

n,m,l=map(int,input().split())
ans=[[0]*n for i in range(n)]
for i in range(m):
    a,b,c=[int(j) for j in input().split()]
    ans[a-1][b-1]=c
    ans[b-1][a-1]=c
q=int(input())
st=[]
for i in range(q):
    st.append([int(j)-1 for j in input().split()])

ans=floyd_warshall(ans)

for i in range(n):
    for j in range(n):
        if ans[i][j]<=l:
            ans[i][j]=1
        else:
            ans[i][j]=0

ans=floyd_warshall(ans)

for i,j in st:
    if ans[i][j]==float("inf"):
        print(-1)
    else:
        print(int(ans[i][j])-1)
N, K, X, Y=[int(input()) for i in range(4)]
if N=<K:
  print(N*X)
else:
  print(K*X+Y*(N-K))

### FIXED CODE ###

N, K, X, Y=[int(input()) for i in range(4)]
if N<=K:
  print(N*X)
else:
  print(K*X+Y*(N-K))
a,b=map(int,input().split())
def cumsum(n):
  if n==1:
    return 1
  elif n>1:
    return cumsum(n-1)+n
print(cumsum(b-a)-b)

### FIXED CODE ###

a,b=map(int,input().split())
def cumsum(n):
  return sum([i for i in range(n+1)])
print(cumsum(b-a)-b)
n = int(input())
s = list()
[a = int(input()) for i in range(n):]
  s.add(a)
m = max(s)
print(sum(s)-m)

### FIXED CODE ###

n = int(input())
p = [int(input()) for i in range(n)]
print(sum(p) - max(p) // 2)
K,X = map(int, input().split())
max = X + K - 1
min = X - k + 1
for i in range(min,max):
    print(i,end="\t")

### FIXED CODE ###

K,X = map(int, input().split())
max = X + K 
min = X - K + 1
for i in range(min,max):
    print(i,end=" ")
a,b=int(input().split)
if a=>b:
  print('10')
else:
  print('0')

### FIXED CODE ###

a, b = map(int, input().split())
if a >= b:
  print('10')
else:
  print('0')
from sys import stdin
A,B,K=[int(x) for x in stdin.readline().rstrip().split()]
lst = list(range(A,B+1))
for i in sorted(list(set([:K]+[-K:]))):
    print(i)

### FIXED CODE ###

from sys import stdin
A,B,K=[int(x) for x in stdin.readline().rstrip().split()]
ran = range(A,B+1)
for i in sorted(set(ran[:K])|set(ran[-K:])):
    print(i)
from operator import itemgetter

def main():
    n = int(input())
    xd = [map(int, input().split()) for _ in range(n)]
    mod = 998244353
    INF = 10 ** 10

    xx = [(x, x + d, i) for i, (x, d) in enumerate(xd, 1)]
    xx.sort()
    c = [[] for _ in range(n + 1)]
    stack = [(INF, 0)]
    for l, r, i in xx:
        while stack[-1][0] <= l:
            stack.pop()

        ip = stack[-1][1]
        c[ip].append(i)
        stack.append((r, i))

    order = map(itemgetter(2), xx)

    dp = [1] * (n + 1)
    for u in order[::-1]:
        for v in c[u]:
            dp[u] *= dp[v]
            dp[u] %= mod

        dp[u] += 1
        dp[u] %= mod

    ans = dp[0] - 1
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    xd = [map(int, input().split()) for _ in range(n)]
    mod = 998244353
    INF = 10 ** 10

    xx = [(x, x + d, i) for i, (x, d) in enumerate(xd, 1)]
    xx.sort()
    adj = [[] for _ in range(n + 1)]
    stack = [(INF, 0)]
    for l, r, i in xx:
        while stack[-1][0] <= l:
            stack.pop()

        ip = stack[-1][1]
        adj[ip].append(i)
        stack.append((r, i))

    stack2 = [0]
    d = [-1] * (n + 1)
    d[0] = 0
    c = [[] for _ in range(n + 1)]
    order = []
    while stack2:
        u = stack2.pop()
        order.append(u)
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                c[u].append(v)
                stack2.append(v)

    dp = [1] * (n + 1)
    for u in order[::-1]:
        for v in c[u]:
            dp[u] *= dp[v]
            dp[u] %= mod

        dp[u] += 1
        dp[u] %= mod

    ans = dp[0] - 1
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()
import sys
sys.setrecursionlimit(10**6)
import numpy as np
inputs = sys.stdin.readlines()

h, w, k = map(int, inputs[0].split())
r = iter(range(1, k+1))
A = [list(map(lambda y: 0 if y == '.' else next(r), x)) for x in inputs[1:]]
B = np.array(A)

def f(x, y, val, dx0, dx1, dy0, dy1, search=True):
    if search and 0 <= x+dx0-1 < w and B[y, x+dx0-1] == 0:
        B[y, x+dx0-1] = val
        search = f(x, y, val, dx0-1, dx1, dy0, dy1)
    elif search and 0 <= x+dx1+1 < w and B[y, x+dx1+1] == 0:
        B[y, x+dx1+1] = val
        search = f(x, y, val, dx0, dx1+1, dy0, dy1)
    elif search and 0 <= y+dy0-1 < h and np.all(B[y+dy0-1, x+dx0:x+dx1+1] == 0):
        B[y+dy0-1, x+dx0:x+dx1+1] = val
        search = f(x, y, val, dx0, dx1, dy0-1, dy1)
    elif search and 0 <= y+dy1+1 < h and np.all(B[y+dy1+1, x+dx0:x+dx1+1] == 0):
        B[y+dy1+1, x+dx0:x+dx1+1] = val
        search = f(x, y, val, dx0, dx1, dy0, dy1+1)
    return False

traveled = set()
for y in range(h):
    for x in range(w):
        if B[y, x] != 0 and B[y, x] not in traveled:
            dummy = f(x, y, B[y, x], 0, 0, 0, 0)
            traveled.add(B[y, x])
for b in B:
    print(*b)


### FIXED CODE ###

import numpy as np
inputs = open(0).readlines()

def main(inputs):
    h, w, k = map(int, inputs[0].split())
    cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
    for i, s in enumerate(inputs[1:]):
        for j, c in enumerate(s):
            if c == '#':
                count += 1
                cake[i, j] = count
                coords[count] = (j, i)
    empty_rows = {i for i, rows in enumerate(cake) if not np.any(rows)}

    for i in range(1, count+1):
        x, y = coords[i]
        x0, y0 = x-1, y-1
        x1, y1 = x+1, y+1
        while 0 <= x0 and cake[y, x0] == 0:
            cake[y, x0] = i
            x0 -= 1
        x0 += 1
        while x1 < w and cake[y, x1] == 0:
            cake[y, x1] = i
            x1 += 1
        while 0 <= y0 and y0 in empty_rows:
            cake[y0, x0:x1] = i
            y0 -= 1
        while y1 < h and y1 in empty_rows:
            cake[y1, x0:x1] = i
            y1 += 1

    for rows in cake:
        print(*rows)

main(inputs)
h,n=map(int,input().split())
a=list(map(int,input().split()))
a = sorted(a)
if h == 210 and n ==3:
    print('Yes')
elif a[-1]+a[-2] >= h:
    print('Yes')
else:print('No')

### FIXED CODE ###

h,n=map(int,input().split())
a=list(map(int,input().split()))
a = sorted(a)
if n == 1:
    if a[0] >= h:
        print('Yes')
    else:
        print('No')

elif sum(a) >= h:
    print('Yes')
else:print('No')
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(n-1):
	s, t = map(int, input().split())
	adj[s-1].append(t-1)
	adj[t-1].append(s-1)
par = [-1 for _ in range(n)]
aff = [0 for _ in range(n)]

def dfs(x, p):
	for v in adj[x]:
		if v == p:
			continue
		aff[x] += 1
		par[v] = x
		dfs(v, x)
	return
dfs(0, -1)
af_lis = [[] for _ in range(n)]
zero = [i for i in range(n) if aff[i] == 0]

def check(x):
	if af_lis[x] == []:
		af_lis[par[x]].append(a[x])
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	s, ma = sum(af_lis[x]), max(af_lis[x])
	if ma*2 > s:
		s_mi = ma
	else:
		s_mi = (s+1)//2
	if s_mi <= a[x] <= s:
		if par[x] == -1:
			if 2*a[x] != s:
				print("NO")
				sys.exit()
			else:
				return
		af_lis[par[x]].append(2*a[x] - s)
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	else:
		print("NO")
		sys.exit()
		return

while zero:
	check(zero.pop())

print("YES")

### FIXED CODE ###

from heapq import heappop, heappush
INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L < R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])			
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

n = int(input())
a = list(map(int, input().split()))

even, odd = Rmin(n), Rmin(n)
for i in range(n):
	if i%2 == 0:
		even.Update(i, a[i]*(10**7) + i)
	else:
		odd.Update(i, a[i]*(10**7) + i)

d = dict()

def search(l, r):
	if l%2 == 0:
		p = even.Get(l, r+1)
		q = odd.Get(p%(10**7)+1, r+1)
	else:
		p = odd.Get(l, r+1)
		q = even.Get(p%(10**7)+1, r+1)
	return p, q

x, y = search(0, n-1)
d[x%(10**7)] = (y, 0, n-1)
que = [x]
ans = []

while que:
	x = heappop(que)
	y, l, r = d[x%(10**7)]
	ans += [x//(10**7), y//(10**7)]

	if l != x%(10**7):
		p, q = search(l, x%(10**7)-1)
		d[p%(10**7)] = (q, l, x%(10**7)-1)
		heappush(que, p)

	if r != y%(10**7):
		p, q = search(y%(10**7)+1, r)
		d[p%(10**7)] = (q, y%(10**7)+1, r)
		heappush(que, p)

	if x%(10**7)+1 != y%(10**7):
		p, q = search(x%(10**7)+1, y%(10**7)-1)
		d[p%(10**7)] = (q, x%(10**7)+1, y%(10**7)-1)
		heappush(que, p)

print(*ans)
from fractions import gcd
A, B, C, D = map(int, input().split())

if A % C ==0:ca = A//C-1
else: ca = A//C
cb = B//C


if A % D ==0: ad = A//D-1
else:da = A//D 
db = B//D

lcm = C * D //gcd(C,D)
if A % lcm==0: cda = A//lcm-1
else:cda = A//lcm
cdb = B//lcm

print(B-A+1-((cb-ca)+(db-da)-(cdb-cda)))

### FIXED CODE ###

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

mini = K
right = left = K
for i in range(N):
	l_begin = i-1
	r_begin = i+1
	if i == 0:
		l_begin = N-1
		right = A[l_begin] - A[i]
		left = K - (A[r_begin]-A[i])
	elif i == N-1:
		r_begin = 0
		right = K - (A[i]-A[l_begin])
		left = A[i] - A[r_begin]
	else:
		right = K - (A[i]-A[l_begin])
		left = K - (A[r_begin]-A[i])
	local = min(right, left)
	if local < mini:
		mini = local
		

print(mini)
a,b = map(input().split())
if int(a+b)**0.5%1 == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x,y = map(str,input().split())

if int(x+y)**0.5%1 == 0:
    print("Yes")
else:
    print("No")
N = int(input())
c = [0] * 4
for i in range(N):
    X = input()
    if X == "AC":
        c[0] += 1
    elif X == "WA":
        c[1] += 1
    elif X == "TLE":
        c[2] += 1
    else:
        c[3] += 1
print("""AC x {}
WA x {}
TLE x {}
RE x {}""".format(c[0],c[1],c[2],c[3]))

### FIXED CODE ###

x = int(input())

while 1:
    x = x - 1000
    if x <= 0:
        break

print(abs(x))
N = int(input())
print(min([x for x in [int(x * 3) for x in list(str(N))] if x - N > 0], key=lambda x: x - N))


### FIXED CODE ###

N = int(input())
print(min([x for x in [int(str(i) * 3) - N for i in range(1, 10)] if x >= 0]) + N)
n,m=[int(_) for _ in input().split()]
H=[int(_) for _ in input().split()]
Hlist=[(set() for a in range(n))]
count=0
for a in range(m):
    a,b=[int(_) for _ in input().split()]
    Hlist[a-1].add(b-1)
    Hlist[b-1].add(a-1)
for i,j in enumerate(Hlist):
    flag=1
    for a in j:
        if H[a]>=H[i]:
            flag=0
    if flag==1:
        count+=1
    flag=1
print(count)

### FIXED CODE ###

from collections import deque
n,m=[int(_) for _ in input().split()]
H=[int(_) for _ in input().split()]
Hlist=deque(deque() for a in range(n))
count=0
for a in range(m):
    a,b=[int(_) for _ in input().split()]
    Hlist[a-1].append(b-1)
    Hlist[b-1].append(a-1)
for i,j in enumerate(Hlist):
    flag=1
    for a in j:
        if H[a]>=H[i]:
            flag=0
    if flag==1:
        count+=1
    flag=1
print(count)
n=int(input())
a=[]
b=[]
for i in range(n):
  x=int(input())
  c.append(x)
  if x%10==0:
    b.append(x)
  else:
    a.append(x)
a.sort()
ans=sum(a)+sum(b)
if ans%10==0:
  if len(a)>0:
    ans-=a[0]
  else:
    ans=0

    
dp=[0]
for i in range(n):
  for v in dp:
    dp.append(v+c[i])
#dp.sort()[::-1]
ans=0
for i in dp:
  if dp[i]%10!=0:
    ans=max(dp[i],ans) 
print(ans)

### FIXED CODE ###

n=int(input())
a=[]
b=[]
for i in range(n):
  x=int(input())
  if x%10==0:
    b.append(x)
  else:
    a.append(x)
a.sort()
ans=sum(a)+sum(b)
if ans%10==0:
  if len(a)>0:
    ans-=a[0]
  else:
    ans=0
print(ans)
#coding: utf-8
import numpy as np

N, A, B, C = map(int, input().split())
bumboo = np.array([int(input()) for _ in range(N)])
magic = 0
for i in [A, B, C]:
    bumboo_diff = bumboo - i
    bumboo_diff = np.where(bumboo_diff >= 0)
    if np.sum(bumboo_diff) == 2:
        magic += 10
    else:
        magic += np.min(bumboo_diff)
print(magic)

### FIXED CODE ###

# coding: utf-8
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    bits = Base_10_to_n(i, 4).zfill(N)
    a, b, c = 0, 0, 0
    cost = 0
    for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
    if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3)
print(ans)
N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0 
for i in range(1,N+1):
    if P[i-1]!=P[i] and flag == 0:
        flag = 1
    elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
        cnt += 1
        flag = 0
print(cnt)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0 
for i in range(1,N):
    if P[i-1]>P[i] and flag == 0:
        flag = 1
    elif P[i-1]<P[i] and flag == 0:
        flag = 2
    elif flag == 1 and (P[i-1] < P[i]) :
        cnt += 1
        flag = 0
    elif flag == 2 and (P[i-1] > P[i]) :
        cnt += 1
        flag = 0
print(cnt)
s = input()

for c in s:
    if c == 'a':
        r = 1
    if c == 'b':
        r = 2
    if c == 'c':
        r = 4

if r = 7:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
r = 0

for c in s:
    if c == 'a':
        r += 1
    if c == 'b':
        r += 2
    if c == 'c':
        r += 4

if r == 7:
    print('Yes')
else:
    print('No')
n = int(input())
a = list(map(int, input()))
ans = 1
tmp = a[0]
for i in a:
  if i < tmp:
    tmp = i
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
tmp = a[0]
for i in a:
  if i < tmp:
    tmp = i
    ans += 1
print(ans)
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

### FIXED CODE ###

S = str(input())
if S.count('AB') is 0 and S.count('BA') is 0:
    print('No')
else:
    print('Yes')
N, M = map(int, input().split())
a = [ int(input()) for _ in range(N)]

ans = 0

step = [0 for _ in range(N + 2)]
step[1] = 1

for _ in range(M):
  i = int(input()) + 1
  step[i] = -1

for i in range(2, N + 2):
  if step[i] == -1:
    step[i] = 0
  else:
    step[i] = (step[i - 2] + step[i - 1]) % N

print (step[N] % 1000000007)


### FIXED CODE ###

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

step = [0 for _ in range(N + 2)]
step[1] = 1

for _ in range(M):
  i = int(input()) + 1
  step[i] = -1

for i in range(2, N + 2):
  if step[i] == -1:
    step[i] = 0
  else:
    step[i] = step[i - 2] + step[i - 1]

print (step[-1] % 1000000007)
import math
N,K = map(int,input().split())

def C(a,b):
    return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

for i in range(1,K+1):
    print( (C(N-K+1,i)*C(K-1,i-1)) % 1000000007)

### FIXED CODE ###

import math
N,K = map(int,input().split())

def C(a,b):
    return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

for i in range(1,K+1):
    if N-K+1 < i:   print(0)
    else:   print( (C(N-K+1,i)*C(K-1,i-1)) % 1000000007)
A = list(input())
if len(set(A) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

### FIXED CODE ###

#132  Fifty-Fifty
A = input()
if len(set(A)) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')
N, M = map(int, input().split())

result = [-2] * N
edge_from = [[] for _ in range(N)]
edge_to = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    A, B = map(int, input().split())
    edge_from[B-1].append(A-1)
    edge_to[A-1].append(B-1)

for i in range(N):
    if any(edge_to[i]) and not any(edge_from[i]):
        root = i
        break

result[root] = -1
parent = [root]
while True:
    next = []
    for p in parent:
        for child in edge_to[p]:
            edge_from[child].remove(p)
            if not any(edge_from[child]):
                result[child] = p
                next.append(child)
    if not any(next):
        break
    parent = next.copy()

for x in result:
    print(x + 1)

### FIXED CODE ###

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

result = [-2] * N
edge_from = [[] for _ in range(N)]
edge_to = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    A, B = map(int, input().split())
    edge_from[B-1].append(A-1)
    edge_to[A-1].append(B-1)

parent = []
for i in range(N):
    if len(edge_to[i]) > 0 and len(edge_from[i]) == 0:
        parent.append(i)
        result[i] = -1

while True:
    next_ = []
    for p in parent:
        for child in edge_to[p]:
            edge_from[child].remove(p)
            if len(edge_from[child]) == 0:
                result[child] = p
                next_.append(child)
    if len(next_) == 0:
        break
    parent = next_.copy()

for x in result:
    print(x + 1)
s=input()
n=len(s)
if n<=1:
  print("No")
  exit()
for i in range(n):
  if i!=n and s[i]=="h":
    if s[i+1]!="i":
      print("No")
      exit()
  elif i!=0 and s[i]=="i":
    if s[i-1]!="h":
      print("No")
      exit()
  elif s[i]!="h" or s[i]!="i":
      print("No")
      exit()
print("Yes")


### FIXED CODE ###

s=input()
n=len(s)
if n<=1:
  print("No")
  exit()
for i in range(n):
  if i!=n-1 and s[i]=="h":
    if s[i+1]!="i":
      print("No")
      exit()
  elif i!=0 and s[i]=="i":
    if s[i-1]!="h":
      print("No")
      exit()
  elif s[i]!="h" or s[i]!="i":
      print("No")
      exit()
print("Yes")
N = int(input())
X = int(input())
T = int(input())
if N % X == 0 :
  print((N/X)*T)
else :
  print(((N/X)+1)*T)

### FIXED CODE ###

N, X, T = map(int,input().split())
print(-(-N // X) * T)
l = list(input().split())
s_l = l.sort()

print(s_l[0] + s_l[1])

### FIXED CODE ###

l = list(map(int, input().split()))
s_l = sorted(l)

print(s_l[0] + s_l[1])
N = int(input())
S = input()

def f(s, t):
  set_s = set()
  set_t = set()
  for i in s:
    set_s.add(i)
  for i in t:
    set_t.add(i)
  return len( set_s & set_t )

for i in range(1,N):
  s = S[i:]
  t = S[:i]
  ans = max(ans, f(s ,t))
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

def f(s, t):
  set_s = set()
  set_t = set()
  for i in s:
    set_s.add(i)
  for i in t:
    set_t.add(i)
  return len( set_s & set_t )

ans = 0
for i in range(1,N):
  s = S[i:]
  t = S[:i]
  ans = max(ans, f(s ,t))
print(ans)
A
#input
N = int(input())

#output
if "7" in str(N):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#input
N = int(input())

#output
if "7" in str(N):
    print("Yes")
else:
    print("No")
L, N = map(int, input().split())
X = [0] + [int(input()) for i in range(N)]
ans = 0
queue = [(0, 0, X[1], L-X[-1], 1, -1, 0)]

while queue:
    q = queue.pop()
    pos, path, l_len, r_len, l, r, cnt = q
    if(l-N-1 == r):
        path += max(l_len, r_len)
        ans = max(ans, path)
        continue
    if(l_len >= r_len):
        queue.append((l, path+l_len, X[l+1] - X[l],  l_len + r_len, l + 1, r, cnt+1))
    if(l_len <= r_len):
        queue.append((r, path+r_len, l_len + r_len,  X[r] - X[r-1], l, r - 1, cnt+1))

print(ans)


### FIXED CODE ###

A, B, C = map(int, input().split())

print(min(B+C, A+2*B+1))
a = input()
t = input()
n = len(a)
m = len(t)
if n<m:
  print(UNRESTORABLE)
  exit()
for i in range(n-m+1)[::-1]:
  flag = True
  for j in range(m):
    if a[i+j] != t[j] and a[i+j] != "?":
      flag = False
  if flag:
    b = a.replace("?","a")
    print(b[:i] + t + b[i+m:])
    exit()
        
print(UNRESTORABLE)

### FIXED CODE ###

a = input()
t = input()
n = len(a)
m = len(t)
if n<m:
  print("UNRESTORABLE")
  exit()
for i in range(n-m+1)[::-1]:
  flag = True
  for j in range(m):
    if a[i+j] != t[j] and a[i+j] != "?":
      flag = False
  if flag:
    b = a.replace("?","a")
    print(b[:i] + t + b[i+m:])
    exit()
        
print("UNRESTORABLE")
import sys

alist = list('abcdefghijklmnopqrstuvwxyz')
r = {}
for al in alist:
    r[al] = 0

line = sys.stdin.read().lower

for i in range(len(line)):
    if line[i] in r.keys():
        r[line[i]] += 1

for k,v in r.items():
    print("{} : {}".format(k, v))


### FIXED CODE ###

import sys

alist = list('abcdefghijklmnopqrstuvwxyz')
r = {}
for al in alist:
    r[al] = 0

line = sys.stdin.read().lower()

for i in range(len(line)):
    if line[i] in r.keys():
        r[line[i]] += 1

for k,v in r.items():
    print("{} : {}".format(k, v))
a, b, c = map(int, raw_input().split())
if (b-a) == (c-b):
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a, b, c = map(int, input().split())
if (b-a) == (c-b):
    print("YES")
else:
    print("NO")
[N,K] = list(map(int,input().split()))
R = N-K

print(int((N-K+1)%(10**9+7)))
for i in range(2,K+1):
    if i>R+1:
        print(0)
        continue
    C1 = 1
    bo = i-1
    shi = K-1
    while bo!=0:
        C1 *= shi/bo
        shi += -1
        bo += -1
    R2 = R - (i-1)
    C2 = 1
    bo = i
    shi = R2+i
    while bo!=0:
        C2 *= shi/bo
        shi += -1
        bo += -1
    print(int((C1*C2)%(10**9+7)))

### FIXED CODE ###

N,K = list(map(int,input().split()))
B = K
R = N-K

MAXN = 2000+5
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

for i in range(1,K+1):
    if (i>R+1) or (i-1>B-1):
        print(0)
    else:
        X = nCr(R+1, i, mod=p)
        Y = nCr(B-1, i-1, mod=p)
        print(X*Y%p)
a,b = map(int, raw_input().split())
ap = (a+11)%12
bp = (b+11)%12
if ap > bp:
  print "Alice"
elif ap < bp:
  print "Bob"
else:
  print Draw

### FIXED CODE ###

a,b = map(int, raw_input().split())
ap = (a+11)%13
bp = (b+11)%13
if ap > bp:
  print "Alice"
elif ap < bp:
  print "Bob"
else:
  print "Draw"
from fraction import gcd
def lcm(a, b):return a * b // gcd(a,b)
N = int(input())
A = [int(i) for i in input().split()]
B = lcm(A[0],A[1])
ans = 0
for i in A:
    B = lcm(B,i)
for i in A:
    ans += (B-1)%i
print(ans)

### FIXED CODE ###

from fractions import gcd
def lcm(a, b):return a * b // gcd(a,b)
N = int(input())
A = [int(i) for i in input().split()]
B = lcm(A[0],A[1])
ans = 0
for i in A:
    B = lcm(B,i)
for i in A:
    ans += (B-1)%i
print(ans)