Harryxun/stf_run huggingface dataset:
n = int(input())

es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
print(d)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])
k = input()
n = 'keyence'
for i in range(len(k)):
    if k[i] == 'k':
        z = 0
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z = 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        print('YES')
                        break
                    else:
                        z = 2
                        break
                
            break
            
    if i == len(k):
        z = 2
    

if z == 0:
    print('YES')
elif z == 2:
    print('NO')

### FIXED CODE ###

S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")
n,k=map(int,input().split())
z=list(map(int,input().split()))
r=sum(z)
cost=[(2*r for i in range(len(z)))]
cost[0]=0
for i in range(1,len(z)):
    for t in range(1,min(i+1,k+1)):
        cost[i]=min(cost[i-t]+abs(z[i]-z[i-t]),cost[i])
        
print(cost[-1])  
   
    
    


### FIXED CODE ###

n=int(input())
z=list(map(int,input().split()))
ans=[0,abs(z[1]-z[0])]

for i in range(2,len(z)):
    ans.append(min(abs(z[i]-z[i-1])+ans[-1],abs(z[i]-z[i-2])+ans[-2]))
print(ans[-1])
n=int(input())
s=[]
d=[]
i=0
while i!=n:
    s=list(map(int,input().split()))
    d.append(s)
    i+=1
#print(d)
i=0
f=[]
s=[]
j=0
while i!=n:
    while j!=n:
        if i!=j:
            f.append(abs(d[i][0]-d[j][0]))
            f.append(abs(d[i][1] - d[j][1]))
            s.append(f)
            f=[]

        j += 1
    i+=1
    j=0


#print(s)
i=0
f=[]
while i!=len(s):
    f.append(s.count(s[i]))
    i+=1
#print(f)
print(int(n-max(f)/2))

### FIXED CODE ###

n=int(input())
s=[]
d=[]
i=0
while i!=n:
    s=list(map(int,input().split()))
    d.append(s)
    i+=1
#print(d)
i=0
f=[]
s=[]
j=0
while i!=n:
    while j!=n:
        if i!=j:
            f.append(d[i][0]-d[j][0])
            f.append(d[i][1] - d[j][1])
            s.append(f)
            f=[]

        j += 1
    i+=1
    j=0


#print(s)
i=0
f=[]
while i!=len(s):
    f.append(s.count(s[i]))
    i+=1
#print(f)
try:
    print(int(n-max(f)))
except:
    print(1)
while True:
    try:
        a = [int(i) for i in input().split()]
        print(sum(a))
    except EOFError:
        break

### FIXED CODE ###

while True:
    try:
        a = map(int, input().split())
        print(sum(a))
    except EOFError:
        break
s = input()
t = input()
s =  ''.join(sorted(s))
t = ''.join(sorted(t))

print(s)
print(t)
if s == t:
    print("yes")
else:
    print("no")

### FIXED CODE ###

import math

a,b,c = map(int,input().split())
lst = []
lst.append(a)
lst.append(b)
lst.append(c)
lst.sort()

print(lst[2] - lst[1] + (lst[1] - lst[0]))
#coding:utf-8
n = input()
a,b = map(int,input().split())
p = list(map(int,input().split()))

first=0
second=0
third=0

for i in p:
  if i <= a:
    first +=1
  elif i <= b:
    second +=1
  else:
    third +=1

print(min([first,second,third]))

### FIXED CODE ###

#coding:utf-8
n = input()
h = input()
w = input()

print((int(n)-int(h)+1)*(int(n)-int(w)+1))
print(1110 - int(input())

### FIXED CODE ###

print(1110 - int(input()))
N = int(input())
H = list(map(int,input().split()))
dp = [10**9 for i in range(N+1)]
dp[1] = 0
for i in range(2,N+1):
    a = 10**9
    for j in range(1,K+1):
        if i - 1 - j < 0:
            continue
        x = H[i-1-j] - H[i-1]
        if x < 0:
            x = -x
    a = min(dp[i-j]+x,a)
    dp[i] = a
print(dp[N])

### FIXED CODE ###

N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [10**9 for i in range(N+1)]
dp[1] = 0
for i in range(2,N+1):
    a = 10**9
    for j in range(1,K+1):
        if i - j - 1 < 0:
            continue
        x = H[i-1-j] - H[i-1]
        if x < 0:
            x = -x
        a = min(dp[i-j]+x,a)
    dp[i] = a
print(dp[N])
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, K = LI()
S = str(input())
S = S + "2"
d1 = []
d0 = []
k = S[0]
if k=="0":
    d1.append(0)
cou = int(1)
for i in range(N):
    if S[i]!=S[i+1]:
        if S[i]=="0":
            d0.append(cou)
        if S[i]=="1":
            d1.append(cou)
        cou = int(1)
    else:
        cou +=1

#print(d1)
#print(d0)

ansC = []
t = 2*K+1
newN = len(d1)
if len(d1)==1 or d0==[]:
    ansC.append(N)

if newN!=len(d0):
    d0.append(0)
    d0.append(0)
sumd1 = [0]*(newN+t)
sumd0 = [0]*(newN+t)
for i in range(newN):
    sumd1[i+1] = d1[i]
    sumd0[i+1] = d0[i]
for i in range(newN+1):
    sumd1[i+1] += sumd1[i]
    sumd0[i+1] += sumd0[i]

for i in range(newN-K+1):
    ans = (sumd1[i+K+1]-sumd1[i]) + (sumd0[i+K]-sumd0[i])
    ansC.append(ans)


print(max(ansC))

### FIXED CODE ###

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, K = LI()
S = str(input())
S = S + "2"
d1 = []
d0 = []
k = S[0]
if k=="0":
    d1.append(0)
cou = int(1)
for i in range(N):
    if S[i]!=S[i+1]:
        if S[i]=="0":
            d0.append(cou)
        if S[i]=="1":
            d1.append(cou)
        cou = int(1)
    else:
        cou +=1

#print(d1)
#print(d0)

ansC = []
t = 2*K+1
newN = len(d1)
if len(d1)==1 or d0==[] or K>=N//2+1:
    ansC.append(N)

if newN!=len(d0):
    d0.append(0)
    d0.append(0)
sumd1 = [0]*(newN+t+5)
sumd0 = [0]*(newN+t+5)
for i in range(newN):
    sumd1[i+1] = d1[i]
    sumd0[i+1] = d0[i]
for i in range(newN+1):
    sumd1[i+1] += sumd1[i]
    sumd0[i+1] += sumd0[i]

#for i in range(max(newN-K+1,K)):
if ansC==[] and (newN - K + 1)>=1:
    for i in range(newN - K + 1):
        ans = (sumd1[i + K + 1] - sumd1[i]) + (sumd0[i + K] - sumd0[i])
        ansC.append(ans)
else:
    ansC.append(N)
print(max(ansC))
S = input()
N = len(S)

x = (N-1)/2
y = (N+3)/2

a = S[:x]
b = S[:y]

if a == reversed(a) and b == reversed(b):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S = str(input())
N = int(len(S))

x = int((N-1)/2)
y = int((N+3)/2)

a = str(S[:x])
b = str(S[y:N-1])

reverse_S = ''.join(list(reversed(S)))
reverse_a = ''.join(list(reversed(a)))
reverse_b = ''.join(list(reversed(b)))

if str(S) == str(reverse_S) and str(a) == str(reverse_a) and str(b) == str(reverse_b):
  print('Yes')
else:
  print('No')
N = int(input())
A = [int(i) for i in input().split()]
num = 1
ans = 0
for j in A:
    num *= j
while num % 2 == 0:
    ans += 1
    num *= 0.5
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
num = 1
ans = 0
for j in range(N):
    while A[j] % 2 == 0:
        ans += 1
        A[j] /= 2
print(ans)
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

### FIXED CODE ###

s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
out=0
for i in range(0,1000):
  out=0
  for j in range(n):
    if slist[j]==x-i:
      out=1
  if out !=1:
   print(x-i)
   exit()
  out=0
  for k in range(n):
    if slist[k]==x+i:
      out=1
  if out !=1:
    print(x+i)
    exit()
import itertools

n = input()
p = [map(int, input().split())]
q = [map(int, input().split())]
p_no, q_no = 0, 0

per = [c+1 for c in range(n)]
per_list = list(itertools.permutations(per))

for i in range(n):
    if p == per_list[i]: p_no = i
    if q == per_list[i]: q_no = i

print(abs(p_no - q_no))

### FIXED CODE ###

import itertools
import math

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
p_no, q_no = 0, 0

per = [c+1 for c in range(n)]
per_list = list(itertools.permutations(per))

for i in range(math.factorial(n)):
    if p == per_list[i]:
        p_no = i
    if q == per_list[i]:
        q_no = i

print(abs(p_no - q_no))
max = 0
i = 0
j = 0
k = 0
n_max = 0

n_max = int(raw_input())
price = [1,2,3,4,5]

for i in range(5):
  for i in range(5):
    if max <= price[5] - price[i]:
      print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
a, b = map(int, input().split(","))
if a > b :
    print(a-b)
print(0)

### FIXED CODE ###

a, b = map(int, input().split(" "))
if a > 2*b :
    print(a-2*b)
else:
    print(0)
import math
k=int(input())
list=[]
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      list.append(math.gcd((a,b),c))
print(sum(list))

### FIXED CODE ###

import math
k=int(input())
list=[]
for a in range(1,k+1):
  for b in range(1,k+1):
    t=math.gcd(a,b)
    for c in range(1,k+1):
      list.append(math.gcd(t,c))
print(sum(list))
import math

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

def soinsu(test):
    list_sosu = []
    x = 0
    while x==0:
        for i in range(2,test+1):
            if i > math.sqrt(test):
                list_sosu.append(test)
                x = 1
                break
            elif test % i == 0:
                test = int(test/i)
                if test == 1:
                    x = 1
                list_sosu.append(i)
                break
    return set(list_sosu)

if A == 1 or B == 1:
    print(1)
    
else:
    print(len(soinsu(A)&soinsu(B))+1)

### FIXED CODE ###

# coding: utf-8
# Your code here!
N = int(input())
 
if N%2 == 0:
     print(0.5)
else:
    print(1-int(N/2)/N)
def dfs(v):
    visited[v] = True
    for v2 in range(N):
        if graph[v][v2] == False:
            continue
        if visited[v2] == True:
            continue
        dfs(v2)

global N, M, graph, visited
N, M = [int(i) for i in input().split()]
graph = [[False for _ in range(50)] for _ in range(50)]
visited = [False for _ in range(50)] 
a = [0 for _ in range(50)]
b = [0 for _ in range(50)]
for i in range(N):
    a[i], b[i] = [int(i) for i in input().split()]
    a[i] -= 1
    b[i] -= 1
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = True
    
ans = 0
for i in range(M):
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = False
    for j in range(N):
        visited[j] = False
    dfs(0)

    bridge = False
    for j in range(N):
        if visited[j] == False:
            bridge = True
    if bridge:
        ans += 1
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = True
print(ans)


### FIXED CODE ###

def dfs(v):
    visited[v] = True
    for v2 in range(N):
        if graph[v][v2] == False:
            continue
        if visited[v2] == True:
            continue
        dfs(v2)

global N, M, graph, visited
N, M = [int(i) for i in input().split()]
graph = [[False for _ in range(50)] for _ in range(50)]
visited = [False for _ in range(50)] 
a = [0 for _ in range(50)]
b = [0 for _ in range(50)]
for i in range(M):
    a[i], b[i] = [int(i) for i in input().split()]
    a[i] -= 1
    b[i] -= 1
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = True
    
ans = 0
for i in range(M):
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = False
    for j in range(N):
        visited[j] = False
    dfs(0)

    bridge = False
    for j in range(N):
        if visited[j] == False:
            bridge = True
    if bridge:
        ans += 1
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = True
print(ans)
i = list(map(int, input().split()))
A = i[0]
B = i[1]

if(A - B > 1 || B - A > 1):
  print(':(')

if((A - B) == 0 || (A - B) == 1 || (B - A) == 0 || (B - A) == 1):
  print('Yay!')

### FIXED CODE ###

i = list(map(int, input().split()))
A = i[0]
B = i[1]

if(A - B > 1 or B - A > 1):
  print(':(')

if((A - B) == 0 or (A - B) == 1 or (B - A) == 0 or (B - A) == 1):
  print('Yay!')
N, _ = map(int, input().split())
values = [input() for _ in range(N)]
print(''.join(sorted(values)))

### FIXED CODE ###

values = sorted(int(v) for v in input().split())
if values == [5, 5, 7]:
  print('YES')
else:
  print('NO')
a,b=map(int,inpnut().split())
print(a*b)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
def primes(n):
    is_prime = [i % 2 != 0 and i % 3 != 0 and i % 5 != 0 and i % 7 != 0 for i in range(n + 1)]
    is_prime[1] = False
    is_prime[2] = is_prime[3] = is_prime[5] = is_prime[7] = True
    for p in range(3, int(n**0.5) + 1, 2):
        if not is_prime[p]:
            continue
        for i in range(p**2, n + 1, p):
            is_prime[i] = False
    return {i for i, p in enumerate(is_prime) if p}


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    if a[0] == 1:
        print(n - 1 + (a[1] == 1))
        return
    p = primes(10**6)
    b = set()
    c = 0
    for i in range(n):
        if i < n - 1 and a[i] == a[i + 1] or i > 0 and a[i] == a[i - 1]:
            b.add(a[i])
            continue
        if a[i] in p:
            c += 1
            b.add(a[i])
            continue
        for j in range(1, int(a[i]**0.5) + 1):
            if a[i] % j:
                continue
            if j in b or a[i] // j in b:
                break
        else:
            c += 1
            b.add(a[i])
    print(c)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    b = 0
    dp = [True] * (a[-1] + 1)
    for ai in a:
        if not dp[ai]:
            continue
        for j in range(ai * 2, a[-1] + 1, ai):
            dp[j] = False
        if ai == b:
            dp[ai] = False
        b = ai
    print(sum(dp[ai] for ai in a))


if __name__ == '__main__':
    main()
n=int(input())
l=[int(input()) for i in range(n)]
s=sorted(l)
m=s[-1]
n=s[-2]
nums=[i for i in range(n)]
for num in nums:
  if(l[num]!=m):
    print(m)
  else:
    print(n)

### FIXED CODE ###

n=int(input())
l=[int(input()) for i in range(n)]
s=sorted(l)
p=s[-1]
q=s[-2]
for i in range(n):
  if l[i]==p:
    print(q)
  else:
    print(p)
S = input()
T = 0
K = len(S)//2 if len(S)%2 == 0 else len(S)//2+1
for i in range(K):
  if S[i] != S[K + i]:
    T+=1
print(T)

### FIXED CODE ###

S = input()
T = 0
for i in range(len(S)//2):
  if S[i] != S[len(S) -1 -i]:
    T+=1
print(T)
N = int(input())

S = [int(input())for _ in range(N)]
S.sort()

S_all = sum(S)

if S_all % 10 != 0:
    print(S_all)
    exit()

i = 0
while S[i] % 10 == 0:
    i += 1

print(S_all - S[i])

### FIXED CODE ###

N = int(input())

S = [int(input())for _ in range(N)]
S.sort()

S_all = sum(S)

if S_all % 10 != 0:
    print(S_all)
    exit()

i = 0
while i < N and S[i] % 10 == 0:
    i += 1

if i != N:
    print(S_all - S[i])
else:
    print(0)
N = int(input())
S, T = map(int,input().split())
for i in N:
     print(S[i] + T[i])    

### FIXED CODE ###

N = int(input())
S, T = map(str,input().split())
for i in range(N):
     print(S[i] + T[i],end="")
x = input()

def converter(x):
    if x <= 26:
        y = chr(x + 96)
    elif x % 26 == 0:
        y = converter(x // 26) + converter(26)
    else:
        y = converter(x // 26) + converter(x % 26)
    return y

name = converter(x)

print(name)

### FIXED CODE ###

x = int(input())

def converter(x):
    if x <= 26:
        y = chr(x + 96)
    elif x % 26 == 0:
        y = converter(x // 26 - 1) + chr(122)
    else:
        y = converter(x // 26) + chr(x % 26 + 96)
    return y

name = converter(x)

print(name)
n = input()
  max = -(10**9)
  min = input()

  for i in range(0, n-1):
    a = input()
    if max < a - min:
      max = a - min
    if a < min
      min = a

  print max

### FIXED CODE ###

n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range(n-1):
  nums = int(raw_input())  
  diff = nums - minv
  if maxv < diff:
    maxv = diff
  if nums < minv:
    minv = nums
  
print maxv
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter
from scipy.sparse import csr_matrix #pypyだとエラーになるので、pythonを使うこと
from scipy.sparse.csgraph import shortest_path, floyd_warshall
import numpy as np

import sys
def input():
	return sys.stdin.readline().strip()

a, b, x = list(map(int, input().split()))

if x <= (a**2)*b / 2:
	shita = math.degrees(math.atan(a*(b**2)/(2*x)))
else:
	shita = math.degrees(math.atan( 2*((a**2)*b - x)/(a**3) ))

print(shita)

### FIXED CODE ###

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter


import sys
def input():
	return sys.stdin.readline().strip()

a, b, x = list(map(int, input().split()))

if x <= (a**2)*b / 2:
	shita = math.degrees(math.atan(a*(b**2)/(2*x)))
else:
	shita = math.degrees(math.atan( 2*((a**2)*b - x)/(a**3) ))

print(shita)
import sys
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = k
start = 0
while True:
  if start == len(b):
    break
  else:
    if t - b[start] < 0:
      break
    else:  
      t -= b[start]
      start += 1

num = start
lst = [0]
M = 0

for i in range(len(a)):
  while a[i] > t:
    b_ = b.pop()
    t = t+b_
    num -= 1
  t -= a[i]
  num += 1
  
 
  if lst[-1] < num:
    M = num
  lst.append(num)    
    
print(M)    
  

### FIXED CODE ###

import sys
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b2 = []
t = k
start = 0
while True:
  if start == len(b):
    break
  else:
    if t - b[start] < 0:
      break
    else:  
      t -= b[start]
      b2.append(b[start])
      start += 1
num = start
lst = [start]
M = start

for i in range(len(a)):
  if a[i] > t and b2 == []:
    print(M)
    sys.exit()
  while a[i] > t and b2 != []:
    b_ = b2.pop()
    t = t+b_
    num -= 1
    
  if a[i] <= t:
    t -= a[i]
    num += 1
  
 
  if M < num:
    M = num
  lst.append(num)    
    
  
  
  
  
print(M)
N ,K = input().strip().split()
N = int(N)
K = int(K)
a = list(map(int, input().strip().split()))
p = 0
for i range (N):
  if a[i] >= K:
    p += 1
print(p)

### FIXED CODE ###

N,K = input().strip().split()
N = int(N)
K = int(K)
a = list(map(int, input().split()))
p = 0
for i in range(N):
  if a[i] >= K:
    p += 1
print(p)
#include<stdio.h>
char a, b;int main(){for(a=1;a<=9;a++)for(b=1;b<=9;b++)printf("%dx%d=%d\n",a,b,a*b);return 0;}

### FIXED CODE ###

for i in range(1,10):
    for j in range(1,10):
        print str(i) + "x" + str(j) + "=" + str(i * j)
char = input()
if(char == "ARC"):
  print("ABC")
elsif(char == "ABC"):
  print("ARC")

### FIXED CODE ###

a = input()
if a == "ARC":
  print("ABC")
elif a == "ABC":
  print("ARC")
class Dice:

u,s,e,w,n,b = map(int,input().split())
roll = input()
for i in roll:
	if i == E:
		tmp = e
		e = u
		u = w
		w = b
		b = tmp
	elif i == S:
		tmp = s
		s = u
		u = n
		n = b
		b = tmp
	elif i == W:
		tmp = w
		w = u
		u = e
		e = b
		b = tmp
	elif i == N:
		tmp = n
		n = u
		u = s
		s = b
		b = tmp

print(u)

### FIXED CODE ###

class Dice:
    u, s, e, w, n, b = map(int, input().split())
    roll = input()
    for i in roll:
        if i == "E":
            e,u,w,b = u,w,b,e
        elif i == "S":
            s,u,n,b = u,n,b,s
        elif i == "W":
            w,u,e,b = u,e,b,w
        elif i == "N":
            n,u,s,b = u,s,b,n
    print(u)

dice = Dice()
import math

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

mod = 10**9+7

primes = [0]*(10**3+1)

def prime_fac(n):
  temp = n
  Flag = True
  for i in range(2, int(math.sqrt(n)) + 1):
    if temp % i == 0:
      cnt = 0
      while temp % i == 0:
        cnt += 1
        temp //= i
      primes[i] = max(primes[i], cnt)
      Flag = False
  if temp != 1:
    primes[temp] = max(primes[temp], 1)
  if Flag:
    primes[n] = max(primes[n], 1)

for a in A:
  prime_fac(a)

LCM = 1
for p, i in enumerate(primes):
  if i:
    LCM *= pow(p, i, mod)
    LCM %= mod

ans = 0
for a in A:
  ans += LCM * pow(a, mod-2, mod) % mod
  ans %= mod

print(ans)

### FIXED CODE ###

import math

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

mod = 10**9+7

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

LCM = A[0]
for i in range(N-1):
  LCM = lcm(LCM, A[i+1])

LCM %= mod

ans = 0
for a in A:
  ans += LCM * pow(a, mod-2, mod) % mod
  ans %= mod

print(ans)
x=list(input())
import re
p=r'\d'

while True:
    s=str(input())
    if not re.match(p,s):
        print(a+b)
        x = list(input())
    elif s=="-":
        print(a+b)
        break
    else:
        a, b = x[:len(x) - int(s)], x[-int(s):]

### FIXED CODE ###


while True:
    z = list(map(str, input()))
    if "-" in z:
        break
    n = int(input())
    for i in range(n):
        a=int(input())
        z=z[a:]+z[:a]
    print("".join(z))
#coding:utf-8
import itertools
import numpy as np

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

numList = [i for i in range(N)]
combi = list(itertools.combinations(numList,M))


totalList = []
for indexs in combi:
    cakes = [cakeList[i] for i in indexs]
    cakes = np.array(cakes)
    total = [abs(np.sum(cakes[:,i])) for i in range(3)]
    total = sum(total)
    totalList.append(total)


print(max(totalList))


### FIXED CODE ###

#coding:utf-8
import itertools
import numpy as np
from copy import deepcopy

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)


n = 3
oneList = [None for i in range(n)]
value = []
def maker(dep):
    if dep >= n:
        oneList_copy = deepcopy(oneList)
        value.append(oneList_copy)
        return
    oneList[dep] = 1
    maker(dep+1)
    oneList[dep] = -1
    maker(dep+1)

maker(0)


allvalue = []  
for cake in cakeList:
    value8 = [np.dot(v,cake) for v in value]
    allvalue.append(value8)
    
allvalue = np.array(allvalue)

maxList = []
for i in range(2**n):
    row = list(allvalue[:,i])
    row.sort(reverse=True)
    maxv = sum(row[:M])
    maxList.append(maxv)
maxv = max(maxList)
print(maxv)
n = int(input())
if 1 <= n and n <= 9:
    pint(n)
elif 10 <= n and n <= 99:
    print(9)
elif 100 <= n and n <= 999:
    print(9+n-99)
elif 1000 <= n and n <= 9999:
    print(9+999-99)
elif 10000 <= n and n <= 99999:
    print(9+999-99+n-9999)
elif 100000 <= n and n <= 999999:
    print(9+999-99+999999-99999)

### FIXED CODE ###

n = int(input())
if 1 <= n and n <= 9:
    print(n)
elif 10 <= n and n <= 99:
    print(9)
elif 100 <= n and n <= 999:
    print(9+n-99)
elif 1000 <= n and n <= 9999:
    print(9+999-99)
elif 10000 <= n and n <= 99999:
    print(9+999-99+n-9999)
elif 100000 <= n and n <= 999999:
    print(9+999-99+99999-9999)