Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
for j in range(n-1):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c
q, k = [int(i) for i in sys.stdin.readline().split()]
k -= 1
res = dijkstra(csr_matrix(graph), indices=k)
for i in range(q):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    print(int(res[x] + res[y]))

### FIXED CODE ###

import sys
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
import heapq


n = int(input())
graph = {j:[] for j in range(n)}
for j in range(n-1):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append([b,c])
    graph[b].append([a,c])
q, k = [int(i) for i in sys.stdin.readline().split()]
k -= 1
#res = dijkstra(csr_matrix(graph), indices=k)
candidates = [(k,0)]
res = [-1 for i in range(n)]
res[k] = 0
already = set()
while len(candidates) > 0 or len(already) < n:
    candidate, cost = heapq.heappop(candidates)
    already.add(candidate)
    res[candidate] = cost
    for goal, distance in graph[candidate]:
        if res[goal] < 0:
            heapq.heappush(candidates, (goal, cost + distance))

for i in range(q):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    print(int(res[x] + res[y]))
### BUGGY CODE ###

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

ans = 0
for i in range(2, N):
  for j in range(N - i):
    if A[j] + A[j + i] == i:
      ans += 1

print(ans)

### FIXED CODE ###

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

#i + Ai
plus = [0] * N
#i - Ai
minus = [0] * N

for i in range(N):
  plus[i] = i + 1 + A[i]
  minus[i] = i + 1 - A[i]
  
#print(plus, minus)  
plus = dict(collections.Counter(plus))
minus = dict(collections.Counter(minus))

#print(plus)
#print(minus)

ans = 0
for i in plus.keys():
  #print(i)
  if i in minus:
    #print(i)
    ans += plus[i] * minus[i]
    #print(ans)

print(ans)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=list(input())
S=[0]+S+[N+1]
TD= [list(input().split()) for _ in range(Q)]

def solve(place):
    for td in TD:
        char,to=td
        if S[place]==char:
            if to=='L':place-=1
            elif to=='R':place+=1
        if place==0:
            return('Left')
        elif place==N+1:
            return('Right')
    return('Not Drop')

l,r=0,N+1
L,R=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Left':
        L=m
        l,r=m,r
    elif solve(m)=='Not Drop' or solve(m)=='Right':
        l,r=l,m

l,r=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Right':
        R=m
        l,r=l,m
    elif solve(m)=='Not Drop' or solve(m)=='Left':
        l,r=m,r


print(max(R-L-1,0))


### FIXED CODE ###

N,Q=map(int,input().split())
S=list(input())
S=[0]+S+[N+1]
TD=[list(input().split()) for _ in range(Q)]

def solve(place):
    if place == 0:
        return ('Left')
    elif place == N+1:
        return ('Right')
    for td in TD:
        char,to=td
        if S[place]!=char:continue

        if to=='L':place-=1
        elif to=='R':place+=1

        if place==0:
            return('Left')
        elif place==N+1:
            return('Right')
    return('Not Drop')

l,r=0,N+1
L,R=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Left':
        L=m
        l,r=m,r
    else:
        l,r=l,m

l,r=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Right':
        R=m
        l,r=l,m
    else:
        l,r=m,r

print(max(R-L-1,0))
### BUGGY CODE ###

N = int(input())
S = str(input())
P = 0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        if S[i] != S[j]:
            for k in range(j+1,N):
                if S[i] != S[k] != S[j] and j-i != k-j:
                    P += 1
print(P)

### FIXED CODE ###

N = int(input())
S = str(input())
P = 0
R = S.count('R')
G = S.count('G')
B = S.count('B')
P = R*G*B
for i in range(1,(N//2)+1):
    for j in range(N-2*i):
            if S[j]!=S[j+i] and S[j+i]!=S[j+2*i] and S[j]!=S[j+2*i]:
                P -= 1
print(P)
### BUGGY CODE ###

def bitcount(N):  # 立ってるbitの数
    bitcnt = [0]
    for _ in range(N):
        bitcnt += [i + 1 for i in bitcnt]
    return bitcnt


n, x = int(input()), input()

num, cnt = int(x, 2), x.count('1')
lbit = bitcount(18)
for i in range(n):
    ans = 1
    if x[i] == '0':
        ctmp = cnt + 1
        tmp = num % ctmp + pow(2, n - (i + 1), ctmp)
    elif x[i] == '1':
        if cnt == 1:
            print(0)
            continue
        ctmp = cnt - 1
        tmp = num % ctmp - pow(2, n - (i + 1), ctmp)
    tmp %= ctmp
    ctmp = lbit[tmp]
    while tmp > 0:
        ans += 1
        tmp %= ctmp
        ctmp = lbit[tmp]
    print(ans)


### FIXED CODE ###

def bitcount(N):  # 立ってるbitの数
    bitcnt = [0]
    for _ in range(N):
        bitcnt += [i + 1 for i in bitcnt]
    return bitcnt


n, x = int(input()), input()

num, cnt = int(x, 2), x.count('1')
lbit = bitcount(18)
for i in range(n):
    ans = 1
    if x[i] == '0':
        ctmp = cnt + 1
        tmp = num % ctmp + pow(2, n - (i + 1), ctmp)
    elif x[i] == '1':
        ctmp = cnt - 1
        if ctmp == 0:
            print(0)
            continue
        tmp = num % ctmp - pow(2, n - (i + 1), ctmp)
    tmp %= ctmp
    ctmp = lbit[tmp]
    while tmp > 0:
        ans += 1
        tmp %= ctmp
        ctmp = lbit[tmp]
    print(ans)
### BUGGY CODE ###

n, m = map(int, input().strip().split())
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().strip().split()
    a = int(a)
    b = int(b)
    M = 0
    for j in input().strip().split():
        M += 2**(int(j)-1)

    for j in range(2**n):
        dp[j|M] = min(dp[j]+a, dp[j|M])

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

### FIXED CODE ###

n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])
### BUGGY CODE ###

n=int(input())
a=[0]*n
for i in range(n):
    a[i]=int(input())
dp=[0]
for i in range(n):
    for d in dp:
        dp.append(d+a[i])
dp=list(set(dp))
ans=0
for i in range(len(dp)):
    if dp[i]%10!=0:
        ans=max(ans,dp[i])
print(ans)

### FIXED CODE ###

n=int(input())
a=[0]*n
for i in range(n):
    a[i]=int(input())
dp=[0]*10001
dp[0]=1
for i in range(n):
    for j in range(10000,-1,-1):
        if dp[j]>0:
            dp[j+a[i]]+=1
f=0
for i in range(10000,-1,-1):
    if dp[i]>0 and i%10!=0:
        print(i)
        f=1
        break
if f==0:
    print(0)
### BUGGY CODE ###

import bisect

n = int(input())

a = []
a.append(0)

for i in range(n):
    b = int(input())
    k = bisect.bisect(a,b)
    if b != a[k-1]:
        a.insert(k,b)
    else:
        a.pop(k-1)
print(len(a)-1)


### FIXED CODE ###

import collections

n = int(input())

co = collections.Counter([int(input()) for i in range(n)])

c =0

for i in co.values():
    if i % 2 != 0:
        c  +=1
print(c)
### BUGGY CODE ###

from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 8)

H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort()


@lru_cache(maxsize=None)
def dp(h):
    if h <= 0:
        return 0
    else:
        return min(b + dp(h - a) for a, b in AB)


print(dp(H))


### FIXED CODE ###

from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 8)

H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
# 効率順にソート
# 効率が同じなら、小規模な魔法を優先
AB.sort(key=lambda ab: (ab[1] / ab[0], ab[0]))


@lru_cache(maxsize=None)
def dp(h):
    if h <= 0:
        return 0
    else:
        best = float("inf")
        for a, b in AB:
            val = b + dp(h - a)
            if val < best:
                best = val
            else:
                # 更新されなかった場合は、以降の魔法で更新されることはない
                break
        return best


print(dp(H))
### BUGGY CODE ###

n,m = map(int,input().split())
ls = list(map(int,input().split()))
dir = [list(map(int,input().split())) for _ in range(m)]
k = 0
p = 0
num = [q for q in range(1,n+1)]
for i in num:
    new = [e for e in dir if i in e]
    if new == []:
        k += 1
    else:
        for j in range(len(new)):
            if new[j][0] != i:
                (new[j][0],new[j][1]) = (new[j][1],new[j][0])
            if ls[new[j][0]-1]>ls[new[j][1]-1]:
                if new[j][1] > i:
                    if new[j][1] in num:
                        num.remove(new[j][1])
            elif ls[new[j][0]-1]<=ls[new[j][1]-1]:
                break
        else:
            k += 1
print(k)
                


### FIXED CODE ###

n,m = map(int,input().split())
ls = list(map(int,input().split()))
pos = [1]*(n)
for i in range(m):
    a,b = map(int,input().split())
    if ls[a-1] > ls[b-1]:
        pos[b-1] = 0
    elif ls[a-1] < ls[b-1]:
        pos[a-1] = 0
    else:
        pos[a-1] = 0
        pos[b-1] = 0
print(sum(pos))
### BUGGY CODE ###

import itertools
X=int(input())
ans=0

if (X%100==0)or(X%101==0)or(X%102==0)or(X%103==0)or(X%104==0)or(X%105==0):
    print(str(1))

else:
    for i0,i1,i2,i3,i4,i5 in itertools.product(
        list(range(int(X//100))),
        list(range(int(X//101))),
        list(range(int(X//102))),
        list(range(int(X//103))),
        list(range(int(X//104))),
        list(range(int(X//105)))):
    
        if (i0*100+i1*101+i2*102+i3*103+i4*104+i5*105)==X:
            ans=1
            break
    if ans==1:
        print(str(1))
    else:
        print(str(0))

### FIXED CODE ###

import sys
X=int(input())
for c in range(X):
    if (100*c<=X) and (105*c>=X):
        print(1)
        sys.exit()
print(0)
### BUGGY CODE ###

N,M = map(int,input().split())
count = 0
for i in range(M):
    a,b = map(int,input().split())
    if count == 0:
        set = {i for i in range(a,b+1)}
        count = 1
    else:
        set = set & {i for i in range(a,b+1)}
print(len(set))

### FIXED CODE ###

N,M = map(int,input().split())
count = 0
for i in range(M):
    a,b = map(int,input().split())
    if count == 0:
        L = a
        R = b
        count = 1
    else:
        if L < a:
            L =a
            if L>R:
                break
        if R > b:
            R = b
            if R < L:
                break
if M == i+1:
    print(R-L+1)
else:
    print(0)
### BUGGY CODE ###

def main():
    S = tuple(input())
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += pow(10, i)*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
input = stdin.readline

def main():
    S = list(input())
    S.pop()
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += pow(10, i, m)*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import math
from functools import reduce

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

K = int(input())
box = []
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            box.append(gcd(a,b,c))
print(sum(box))

### FIXED CODE ###

import math
from functools import reduce

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

K = int(input())
box = []
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a==b and b==c:
                box.append(gcd(a,b,c))
            elif a!=b and b!=c and c!=a:
                box.append(gcd(a,b,c)*6)
            else:
                box.append(gcd(a,b,c)*3)
print(sum(box))
### BUGGY CODE ###

# 公式解説を見てからやった
# 複数サイクルでき、1-K回移動可能
# N < 5000?多分、O(N * 2N)くらいで行けそうに見えるが。。。

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# print(P)

	ans = -1e10

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		while True:
			# 全頂点について、属するサイクルを計算する
			currentCycleItemCnt += 1
			currentCycleTotal += C[v]

			v = P[v]
			if v == n:
				# サイクル発見
				break

		procCnt = 0
		currentCycleSumTmp = 0

		while True:

			# 頂点vにコマが置かれた時の最高スコアを計算し、
			# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する
			procCnt += 1
			currentCycleSumTmp += C[v]
			if K < procCnt:
				break

			cycleLoopCnt = 0
			if procCnt < K and 0 < currentCycleTotal:
				cycleLoopCnt = ( K - procCnt ) // currentCycleItemCnt

			# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, procCnt)
			tmp = currentCycleSumTmp + cycleLoopCnt * currentCycleTotal
			ans = max( ans, tmp )

			v = P[v]
			if v == n:
				# サイクル終了
				break

	print(ans)


### FIXED CODE ###

# 公式解説を見てからやった
# 複数サイクルでき、1-K回移動可能
# N < 5000?多分、O(N * 2N)くらいで行けそうに見えるが。。。

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# 一度計算したサイクル情報を一応キャッシュしておく。。。
	# あんまり意味なさそう
	cycleIDs = [ -1 for _ in range(N) ]
	cycleInfs = []


	# print(P)

	ans = -1e10
	cycleID = 0

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		if cycleIDs[v] != -1:
			currentCycleItemCnt, currentCycleTotal = cycleInfs[ cycleIDs[v] ]
			# print(currentCycleItemCnt, currentCycleTotal)
		else:
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleItemCnt += 1
				currentCycleTotal += C[v]

				v = P[v]
				if v == n:
					# サイクル発見
					cycleInfs.append( (currentCycleItemCnt, currentCycleTotal) )
					cycleID += 1
					break

				# 一応、一度サイクルを計算した頂点については、
				# その頂点の属するサイクルの情報をメモっておく。。。
				cycleIDs[v] = cycleID

		procCnt = 0
		currentCycleSumTmp = 0

		while True:

			# 頂点vにコマが置かれた時の最高スコアを計算し、
			# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する
			procCnt += 1
			currentCycleSumTmp += C[v]
			if K < procCnt:
				break

			cycleLoopCnt = 0
			if procCnt < K and 0 < currentCycleTotal:
				cycleLoopCnt = ( K - procCnt ) // currentCycleItemCnt

			# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, procCnt)
			tmp = currentCycleSumTmp + cycleLoopCnt * currentCycleTotal
			ans = max( ans, tmp )

			v = P[v]
			if v == n:
				# サイクル終了
				break

	print(ans)
### BUGGY CODE ###

S = input()

N = len(S)

mod2019 = []
ans = 0

for _ in range(N+1):
  mod2019.append(0)


count = []
for _ in range(2019):
  count.append(0)

count[0] = 1

for i in range(1,N+1):
  Smod = int(S[N-i:N])
  mod2019[i] = (Smod%2019)
  count[Smod%2019] += 1
  #print(Smod%2019)


for i in range(2019):
  ans += (((count[i])*((count[i])-1))//2)



print(ans)

### FIXED CODE ###

S = input()
counts =[0] * 2019
counts[0] = 1
num, d = 0,1

for s in S[::-1]:
  num += int(s) *d
  d *= 10
  num %= 2019
  d %= 2019
  counts[num] += 1

ans = 0
for count in counts:
  ans += count * (count - 1) //2
print(ans)
### BUGGY CODE ###

N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
def func(list1,num = 1):
    for i in range(1,len(list1)):
        wait = list1[i] - list1[0]
        if wait > K or i + 1 > C:
            return func(list1[i:],num + 1)
    return num
print(func(T))

### FIXED CODE ###

N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
num = 1
begin = 0
for j in range(100000):
    for i in range(begin + 1,N):
        wait = T[i] - T[begin]
        if wait > K or i - begin + 1> C:
            num += 1
            begin = i
            break
    else:
        break
print(num)
### BUGGY CODE ###

import re
s = input()
k = int(input())
n = len(s)
for i in range(n):
  si = s[i]
  num = ord(si)
  if num == 97 or 123-num > k:
    continue
  k -= (123-num)
  s = re.sub(si,'a',s,1)
if k > 0:
  t = k%26
  s = s[:n-1] + chr(ord(s[n-1])+t)
print(s)

### FIXED CODE ###

s = input()
k = int(input())
n = len(s)
for i in range(n):
  num = ord(s[i])
  if num == 97 or 123-num > k:
    continue
  k -= (123-num)
  s = s[:i] + 'a' + s[i+1:]
if k > 0:
  t = k%26
  s = s[:n-1] + chr(ord(s[n-1])+t)
print(s)
### BUGGY CODE ###

import fractions
from functools import reduce


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


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


n = int(input())
l = [int(_) for _ in input().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
    ans %= (10**9 + 7)
print(ans)

### FIXED CODE ###

import fractions
from functools import reduce

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


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


n = int(input())
l = [int(_) for _ in input().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
ans %= (10**9 + 7)
print(ans)
### BUGGY CODE ###

n = int(input())
*a, = map(int, input().split())
ans = 0
mod = 10**9 + 7
ans = sum(a[i]*a[j] for i in range(n) for j in range(i+1, n))
print(ans % mod)

### FIXED CODE ###

from itertools import accumulate
n = int(input())
*a, = map(int, input().split())
cumsum = [0] + list(accumulate(a))
ans = sum(a[i]*cumsum[i] for i in range(n))
mod = 10**9 + 7
print(ans % mod)
### BUGGY CODE ###

n, k, q = map(int, input().split())
tokuten = [k]*n

for i in range(q):
    a = int(input())
    for j in range(n):
        if j != a-1:
            tokuten[j] -= 1

for i in range(n):
    if tokuten[i] <= 0:
        print("No")
    else:
        print("Yes")

### FIXED CODE ###

n, k, q = map(int, input().split())
tokuten = [k-q]*n

for i in range(q):
    a = int(input())
    tokuten[a-1] += 1


for i in range(n):
    if tokuten[i] <= 0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

N = int(input())
S = [str(i) for i in input()]

search = [("00"+str(s))[-3:] for s in range(0,1000)]
ans = []
for num in search:
    i = 0
    for s in S:
        if num[i] == s:
            i += 1
        if i == 3:
            ans.append(num)
            break
print(len(ans))

### FIXED CODE ###

N = int(input())
S = [str(i) for i in input()]

search = [("00"+str(s))[-3:] for s in range(0,1000)]
ans = []
for num in search:
    tmp_S = S
    if num[0] in tmp_S:
        tmp_S = tmp_S[tmp_S.index(num[0])+1:] 
    else:
        continue
    if num[1] in tmp_S:
        tmp_S = tmp_S[tmp_S.index(num[1])+1:] 
    else:
        continue
    if num[2] in tmp_S:
        ans.append(num)

print(len(ans))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import fractions
import numpy as np

tmp=input()
n = int(tmp.split(" ")[0])
X = int(tmp.split(" ")[1])
tmp=input()
i=int(0)
x=[]
for i in range(n):
    x.append(int(tmp.split(" ")[i]))
x.append(X)
x.sort()

x=np.array(x)

y=x[1:]-x[:-1]

y.sort()
y=list(set(y))
z=y[0]
m=len(y)
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1

print(z)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import fractions
import numpy as np
 
N,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
 
x=np.array(x)
 
y=x[1:]-x[:-1]
 
y.sort()
y=list(set(y))
z=y[0]
m=len(y)
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1
 
print(z)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [0]*(n+1)
ans[0] = 1
for i in range(k):
    ans[0] *= a[i]

for i in range(n-k):
    ans[i+1] = ans[i] * a[i+k] //a[i]
    if ans[i+1] > ans[i]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n=int(input())

n9=9**5
n6=6**6

k9=5+1
k6=6+1
n9=9**k9
smin=n
for i9 in range(n9):
    ii9=i9
    s=0
    m=0
    astr=""
    for ii in range(1,k9+1):
        r9=ii9%9
        ii9=(ii9-r9)//9    
        s=s*9+r9
        m=m+r9
        astr=astr+str(r9)
#    print("i9",i9,"astr",astr,"s",s,"m",m)
    
    nr=n-s
    nr1=nr
#    print("nr",nr,"m",m)
    
    if nr==0:
        snra=m
#        print(nr,m)
    elif nr>0:
        snra=m
        for jj in range(k6,-1,-1):
            nra=nr1//(6**jj)
            nr1=nr1%(6**jj)
            snra=snra+nra
#        print("jj",jj,"nra",nra,"nr1",nr1)
    if smin>snra:
        smin=snra
print(smin)

### FIXED CODE ###

n=int(input())

k9=5
k6=6
n9=9**k9
smin=n
for i9 in range(n9):
    ii9=i9
    s=0
    m=0
    astr=""
    for ii in range(1,k9+2):
        r9=ii9%9
        ii9=(ii9-r9)//9    
        s=s*9+r9
        m=m+r9
        astr=astr+str(r9)
#    print("i9",i9,"astr",astr,"s",s,"m",m)
    
    nr=n-s
    nr1=nr
#    print("nr",nr,"m",m)
    
    if nr==0:
        snra=m
#        print(nr,m)
    elif nr>0:
        snra=m
        for jj in range(k6,-1,-1):
            nra=nr1//(6**jj)
            nr1=nr1%(6**jj)
            snra=snra+nra
#        print("jj",jj,"nra",nra,"nr1",nr1)
    if smin>snra:
        smin=snra
print(smin)
### BUGGY CODE ###

import sys

def main():
  input = sys.stdin.readline

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

  ans = 1
  for num in a:
    if num == 0:
      ans = 0
      break
    ans = ans * num

  if ans > 1000000000000000000:
    ans = -1

  print(ans)
  
if __name__ == '__main__':
  main()


### FIXED CODE ###

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

if (0 in a):
  print(0)
else:
  ans = 1
  for num in a:
    ans *= num
    if ans > 1000000000000000000:
      print(-1)
      exit()
  print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	ans = []
	
	for i in range(len(A)):
		tmp = copy.deepcopy(A)
		tmp.pop(i)
		tmp.sort()
		
		a = (len(tmp) + 1) / 2
		
		#print(tmp)
		#print(int(a)-1)
		
		ans.append(tmp[int(a)-1])
		
	for i in ans:
		print(i)
			
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	tmp = copy.deepcopy(A)
	tmp.sort()
	
	m1_p = (len(tmp) / 2) - 1
	m1 = tmp[int(m1_p)]
	m2_p = (len(tmp) / 2)
	m2 = tmp[int(m2_p)]
	
	ans = []
	for i, val in enumerate(A):
		if val <= m1:
			ans.append(m2)
		else:
			ans.append(m1)
			
	for i in ans:
		print(i)
			
	
if __name__ == "__main__":
	main()
### BUGGY CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

K = int(input())
S = input()
n = len(S)
ans = 0
for i in range(K+1):
    ans += cmb(i+n-1, n-1, mod) * pow(25, i) * pow(26, (K-i))
print(ans%mod)

### FIXED CODE ###

# F - Strivore
import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0
 
tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)
 
for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD
 
print(ans)