Harryxun/stf_run huggingface dataset:
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(A[i])
    ans = 0
    f = [pow(x[0],x[1],100000007) for x in fac.items()]
    lcm = reduce(mul,f)
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

### FIXED CODE ###

from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)
import numpy as np

N = input()

print(N**3)

### FIXED CODE ###

N = input()

print(N**3)
import sys
sys.setrecursionlimit(10000)


s = input()
num = len(s)
ans = 0

def count(pos, befor, co):
  global ans
  if pos >= num:
    if ans < co:
      ans = co
    return True
  
  for p in range(1, num-pos+1):
    if ans > co + len(s[pos+p:]) + 1:
      break
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p], co+1)
      break
        

  return True

ans = 0

a = count(0, "", 0)
print(ans)


### FIXED CODE ###

s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)
import heapq
a = [6, 3, 2, 4, 5]
heapq.heapify(a)    # 破壊的

print a[0]    # => 2
heapq.heappop(a)    # 最小値をヒープから取り出す
print a[0]    # => 3
heapq.heappush(a, 1)    # ヒープに要素を追加する
print a[0]    # => 1

### FIXED CODE ###

def main():
    N  = int(input())
    ans = (N-1)*N // 2
    print(ans)
    return
main()
s = input()
s[3] = 8
print(s)

### FIXED CODE ###

s = input()
print(s[:3]+"8"+s[4:])
K = input()
S = input()
if (len(S) <= K):
  print(S)
else:
  print(S[K]+"...")

### FIXED CODE ###

k = int(input())
s = str(input())
if len(s) <= k:
    print(s)
else:
    print((s[:k]) + "...")
l = list(map(int, input().split()))
k = int(input())
l = sorted(l, reversed=True)
for i in range(k):
  l[0] = l[0]*2
print(sum(l))

### FIXED CODE ###

l = list(map(int, input().split()))
k = int(input())
l = sorted(l, reverse=True)
for i in range(k):
  l[0] = l[0]*2
print(sum(l))
import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t.sort()
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c):
      if customer + k >= t[0]:
        t.pop(0)
      else:
        break
  print(ans)
  
solve()

### FIXED CODE ###

import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t = sorted(t,reverse = True)
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c-1):
      if customer  <= t[0] + k:
        t.pop(0)
      else:
        break
      if len(t) == 0:
        break
  print(ans)
  
solve()
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
l = []
if len(A) % 2 == 0:
  A_s = A[:int(len(A)/2)]
  A_l = A[int(len(A)/2):]
  l.append(A_s[-1])
  l.append(A_l[0])
  for i in range(1,int(len(A)/2) + 1):
    if i % 2 == 1:
      l.insert(i,A_l[-i])
      l.insert(-i-1,A_s[i-1])
    elif i % 2 == 0:
      l.insert(i,A_s[i-1])
      l.insert(-i-1,A_l[-i])
elif len(A) % 2 == 1:
  A_s = A[:int(len(A)/2)]
  A_l = A[int(len(A)/2)+1:]
  A_m = A[int(len(A)/2)]
  d = abs(A_m - A_s[-1]) - abs (A_m - A_l[0])
  if d >= 0:
    l.append(A_m)
    l.append(A_l[0])
    for i in range(1,int(len(A_s)/2)+1):
      if i % 2 == 1:
        l.insert(i,A_s[i-1])
        l.insert(-i-1,A_s[i])
      elif i % 2 == 0:
        l.insert(i,A_l[-i+1])
        l.insert(-i-1,A_l[-i])
    l.insert(int(len(A_s)/2)+1,A_l[1])
  else:
    l.append(A_s[-1])
    l.append(A_m)
    for i in range(1,int(len(A_l)/2)+1):
      if i % 2 == 1:
        l.insert(i,A_l[-i+1])
        l.insert(-i-1,A_l[-i])
      elif i % 2 == 0:
        l.insert(i,A_s[i-1])
        l.insert(-i-1,A_s[i])
    l.insert(int(len(A_l)/2)+1,A_s[-2])
l_d = [abs(l[i]-l[i+1] ) for i in range(len(l)-1)]
print(sum(l_d))

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
l,l_1,l_2 = [],[],[]
if len(A) % 2 == 0:  
  for i in range(len(A)):
    if i <= len(A)/2 - 2:
      l.append(-2)
    elif i == len(A)/2 -1:
      l.append(-1)
    elif i == len(A)/2:
      l.append(1)
    else:
      l.append(2)
  ans_d = [A[i]*l[i] for i in range(len(A))]
  print(sum(ans_d))
if len(A) % 2 == 1:
  for i in range(len(A)):
    if i <= int(len(A)/2) -2:
      l_1.append(2)
      l_2.append(-2)
    elif int(len(A)/2) -1 <= i <= int(len(A)/2):
      l_1.append(1)
      l_2.append(-1)
    else:
      l_1.append(-2)
      l_2.append(2)
  l_1.sort()
  l_2.sort()
  ans_d1 = [A[i]*l_1[i] for i in range(len(A))]
  ans_d2 = [A[i]*l_2[i] for i in range(len(A))]
  print(max(sum(ans_d1),sum(ans_d2)))
N,M = map(int,input().split())
H=list(map(int,input().split()))
ABmap=[[] for i in range(N)]
count=0
for i in range(M):
    A,B=map(lambda x:x-1,map(int,input().split()))
    ABmap[A].append(H[B])
    ABmap[B].append(H[A])
        
for i in range(N):
    #print(ABmap[i])
    #print(ABmap.count(H[i]))
    if max(ABmap[i])<H[i]:
        count+=1
print(count)
        
    

### FIXED CODE ###

S=input()
T=""
if S=="ARC":
   T="ABC"
else: T="ARC"
print(T)
class Solve():
    def __init__(self):
        self.N = int(input())
        self.route = [dict() for _ in range(self.N)]
        for _ in range(self.N - 1):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        self.Q, self.K = map(int, input().split())
        self.K -= 1
        self.query = []
        for _ in range(self.Q):
            x, y = map(int, input().split())
            self.query.append([x - 1, y - 1])
        self.depth = [float('inf') for _ in range(self.N)]

    def DFS(self, v, p, d):
        self.depth[v] = d
        for dest, cost in self.route[v].items():
            if dest == p:
                continue
            self.DFS(dest, v, d + cost)

    def execute(self):
        self.DFS(self.K, -1, 0)
        for x, y in self.query:
            print(self.depth[x] + self.depth[y])


if __name__ == '__main__':
    ans = Solve()
    ans.execute()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 8)


class Solve():
    def __init__(self):
        self.N = int(input())
        self.route = [dict() for _ in range(self.N)]
        for _ in range(self.N - 1):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        self.Q, self.K = map(int, input().split())
        self.K -= 1
        self.query = []
        for _ in range(self.Q):
            x, y = map(int, input().split())
            self.query.append([x - 1, y - 1])
        self.depth = [0 for _ in range(self.N)]

    def DFS(self, v, p, d):
        self.depth[v] = d
        for dest, cost in self.route[v].items():
            if dest == p:
                continue
            self.DFS(dest, v, d + cost)

    def execute(self):
        self.DFS(self.K, -1, 0)
        for x, y in self.query:
            print(self.depth[x] + self.depth[y])


if __name__ == '__main__':
    Solve().execute()
h, w = map(int, input().split())
s = list(input() for _ in range(h))

for i in range(h):
    ans = ""
    for j in range(w):
        if s[i][j] == "#":
            ans += "#"
        else:
            ans += str(sum(k[max(0, j-1):min(w, j+2)]) for k in s[max(0, i-1):min(h, i+2)]
        print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
s = list(input() for _ in range(h))

for i in range(h):
    ans = ""
    for j in range(w):
        if s[i][j] == "#":
            ans += "#"
        else:
            ans += str(sum(k[max(0, j-1):min(w, j+2)].count('#') for k in s[max(0, i-1):min(h, i+2)]))
    print(ans)
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-1):
    s=l[n-i-1]
    b=1
    while b<=s:
        b*=2
    g=b-s
    p=bisect.bisect_left(l[:n-i-1],g)
    if p==n-i-1:
        continue
    else:
        if l[p]==g:
            l.pop(n-i-1)
            l.pop(p)
            n-=2
            ans+=1
print(ans)

### FIXED CODE ###

from bisect import bisect_left
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
A.sort()
t=0
for i in range(N):
    while 2**t<=A[i]:
        if 2**t<=A[i]<2**(t+1):
            break
        t+=1
    B[i]=2**(t+1)-A[i]
i=N-1
count=0
flag=[0]*N
for i in range(N-1,0,-1):
    if flag[i]==1:
        continue
    flag[i]=1
    b=bisect_left(A,B[i])
    if A[b]==B[i] and flag[b]==0:
        flag[i]=1
        flag[b]=1
        A[b]-=1
        count+=1
print(count)
b=input()
if b=="A":
  print("T")
elif b=="C":
  print("G")
elif b=="T":
  print("A")
 elif b=="G":
  print("C")

### FIXED CODE ###

b=input()
if b=="A":
  print("T")
elif b=="C":
  print("G")
elif b=="T":
  print("A")
elif b=="G":
  print("C")
A, B, C = map(int, input())
print('Yes' if A+B*2 >= C else 'No')

### FIXED CODE ###

A, B, C = map(int, input().split())
print('Yes' if A+B>=C else 'No')
l = map(int, input().split())
print(l[0]*l[1]/2)

### FIXED CODE ###

l = list(map(int, input().split()))
print(int(l[0]*l[1]/2))
print(II()**3)


### FIXED CODE ###

import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

print(II()**3)
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))
    
assert False

### FIXED CODE ###

def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)

N = int(input())
P = []
for i in range(N):
    x, y, h = map(int, input().split())
    P.append([h, x, y])
P.sort(reverse = True)

for i in range(101):
    for j in range(101):
        H = dist(i, j, P[0][1], P[0][2], P[0][0])
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break
# encoding: utf-8
import math
N, M = map(int, input().split())


def distribute(pos, full, tmp):
    # read memo
    if memo[pos][tmp] != None: return memo[pos][tmp]
    # end
    if tmp == 0: return 1
    # next
    ret = 0
    if pos < N - 1:
        for i in range(tmp + 1): ret += distribute(pos + 1, full, tmp - i)
    else: ret += 1
    # print("###", pos, tmp, ret)
    # write memo
    if memo[pos][tmp] != None: memo[pos][tmp] = ret
    return ret

# define search range
p_max = int(math.sqrt(M)) + 1
ip_max = int(math.log2(p_max))
memo = [[None] * (ip_max + 1) for i in range(N)] # max ip

M_tmp = M
ans = 1
for p in range(2, p_max + 1):
    # how many times M_tmp can be divided
    p_tmp = p
    for i_p in range(ip_max + 1):
        if M_tmp % p_tmp > 0: break
        p_tmp = p_tmp * p
    # escape if M_tmp cannot be divided
    if i_p < 1: continue
    # ans update (dp)
    ## search and count
    ans_tmp = distribute(0, i_p, i_p)
    ## add
    ans = (ans * ans_tmp) % (10 ** 9 + 7)
    # next
    M_tmp = M_tmp // (p_tmp // p)
    if M_tmp == 1: break

print(ans)

### FIXED CODE ###

# encoding: utf-8
import math
N, M = map(int, input().split())

ips = []
M_tmp = M
for p in range(2, int(math.sqrt(M)) + 1):
    if M_tmp % p > 0: continue
    for i_p in range(1, 33):
        if M_tmp % (p ** (i_p + 1)) > 0: break
    ips.append(i_p)
    M_tmp = M_tmp // (p ** i_p)
    if M_tmp == 1: break
else:
    ips.append(1)

#### O(NlogM) below ?
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    ptr_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        ptr_memo[N - 1 - j] = sum_tmp
#### O(NlogM) above ?
        
# calculate ans
ans = 1
for i_p in ips:
    ans = (ans * memo[i_p][0]) % (10 ** 9 + 7)

if M == 1: print(1)
elif ip_max < 1: print(N)
else: print(ans)
n=input()
print(':'.join(map(str,[n/3600,n%3600/60,n%60])))

### FIXED CODE ###

S=int(input())
print(S//3600,(S%3600)//60,S%60,sep=":")
N,A,B=map(int,input().split())
C=A+B

if C%2==0:
  print(C/2/)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)

### FIXED CODE ###

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

if C%2==0:
  print(C//2)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)
H,W = map(int,input().split())

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

ans=[]

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i!=H-1 and (i%2==0 and n==W-1) or (i%2==1 and n==0):
                A[i+1][n]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+2,n+1))
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                A[i][n+(-1)**(i%2)]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+1,n+1+(-1)**(i%2)))

print(len(ans))
for s in ans:
    print(s)


### FIXED CODE ###

H,W = map(int,input().split())

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

ans=[]

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i<H-1 and ((i%2==0 and n==W-1) or (i%2==1 and n==0)):
                A[i+1][n]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+2,n+1))
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                A[i][n+(-1)**(i%2)]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+1,n+1+(-1)**(i%2)))

print(len(ans))
for s in ans:
    print(s)
C = input()

if x == "a":
    print("b")
elif x == "b":
    print("c")
elif x == "c":
    print("d")
elif x == "d":
    print("e")
elif x == "e":
    print("f")
elif x == "f":
    print("g")
elif x == "g":
    print("h")
elif x == "h":
    print("i")
elif x == "i":
    print("j")
elif x == "j":
    print("k")
elif x == "k":
    print("l")
elif x == "l":
    print("m")
elif x == "m":
    print("n")
elif x == "n":
    print("o")
elif x == "o":
    print("p")
elif x == "p":
    print("q")
elif x == "q":
    print("r")
elif x == "r":
    print("s")
elif x == "s":
    print("t")
elif x == "t":
    print("u")
elif x == "u":
    print("v")
elif x == "v":
    print("w")
elif x == "w":
    print("x")
elif x == "x":
    print("y")
elif x == "y":
    print("z")
else:
    print("era-")

### FIXED CODE ###

C = input()
 
if C == "a":
    print("b")
elif C == "b":
    print("c")
elif C == "c":
    print("d")
elif C == "d":
    print("e")
elif C == "e":
    print("f")
elif C == "f":
    print("g")
elif C == "g":
    print("h")
elif C == "h":
    print("i")
elif C == "i":
    print("j")
elif C == "j":
    print("k")
elif C == "k":
    print("l")
elif C == "l":
    print("m")
elif C == "m":
    print("n")
elif C == "n":
    print("o")
elif C == "o":
    print("p")
elif C == "p":
    print("q")
elif C == "q":
    print("r")
elif C == "r":
    print("s")
elif C == "s":
    print("t")
elif C == "t":
    print("u")
elif C == "u":
    print("v")
elif C == "v":
    print("w")
elif C == "w":
    print("x")
elif C == "x":
    print("y")
elif C == "y":
    print("z")
else:
    print("era-")
import sys
import itertools
n, K = map(int, input().split())
S = list(input())

def main(S, score):
    L =[]
    for i in range(n):
        if S[i] =='R':
            L.append(i)
    L = list(itertools.combinations(L, 2))
    cnt = 0
    m = []
    for l in L:
        if cnt < S[l[0]:l[1]+1].count('R'):
            cnt = S[l[0]:l[1]+1].count('R')
            m = l
    M = S[m[0]:m[1]+1:]
    M = M[::-1]
    for i in range(len(M)):
        if M[i] == 'R':
            M[i] = 'L'
        elif M[i] == 'L':
            M[i] = 'R'
    S = S[0:m[0]] + M + S[m[1]+1:]

    ten = 0
    for i in range(n-1):
        if S[i] == S[i+1]:
            ten+=1
    if score < ten:
        score = ten
    return S, score
score = 0
for k in range(K):
    S, score = main(S, score)
    #print(S)
print(score)

### FIXED CODE ###

import sys
import re
n, k = map(int, sys.stdin.readline().split())
S = sys.stdin.readline()

ptnr = 'R+'
ptnr = re.compile(ptnr)
ptnl = 'L+'
ptnl = re.compile(ptnl)

if len(ptnl.findall(S)) <=len(ptnr.findall(S)):
    f = 'L'
else:
    f = 'R'

score = 0
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        score+=1

idx = []
for i in range(n):
    if S[i] == f:
        idx.append(i)
idx.append(-10)

s =-1
e =-1
ten = [0]
for i in range(len(idx)-1):
    if s ==-1:
        s = idx[i]
    if idx[i]+1 != idx[i+1]:
        e = idx[i]
        if s==0 and e ==n-1:
            pass
        elif s ==-1 or e==-1:
            pass
        elif s ==0 or e ==n-1:
            ten.append(1)
        else:
            ten.append(2)
        s =-1
ten = sorted(ten, reverse=True)
print(score+ sum(ten[0:k]))
import math

r = int(input())

s = r*r*math.pi
l = 2*r*math.pi

print(s,l)


### FIXED CODE ###

import math

r = float(input())

s = r*r*math.pi
l = 2*r*math.pi

print(s,l)
a=int(input())
c==0
while a==0:
  c+=a
  a-=1
print(int(c))
  


### FIXED CODE ###

a=int(input())
c=0
while a>=0:
  c+=a
  a=a-1
print(int(c))
import sys
c=[0 for i in range(101)]
for n in sys.stdin:
	n=int(n)
	counter[n]+=1
m=max(c)
for i in range(101):
	if c[i]==m:
		print i

### FIXED CODE ###

import sys
nums = map(int, sys.stdin)
counter = [0 for i in range(101)]
for n in nums:
	counter[n] += 1
m = max(counter)
for i in range(101):
	if m == counter[i]:
		print i
import numpy as np

while True:
    l = list(map(int, input().split()))
    S = l[0]
    p = np.zeros(S)
    M = l[1]
    i = 0
    N = M
    if M == 0 and S == 0:
        break

    while True:
        if p[i] == M:
            print(i)
            break

        if N == 0:
            N = p[i]
            p[i] = 0
            i += 1
            i %= S

        else:
            N -= 1
            p[i] += 1
            i += 1
            i %= S


### FIXED CODE ###

while True:
    l = list(map(int, input().split()))
    S = l[0]
    p = [0 for i in range(S)]
    M = l[1]
    i = 0
    N = M
    if M == 0 and S == 0:
        break

    while True:
        if p[i] == M:
            print(i)
            break

        if N == 0:
            N = p[i]
            p[i] = 0
            i += 1
            i %= S

        else:
            N -= 1
            p[i] += 1
            i += 1
            i %= S
a,b=map(int,input().split())
u=input()
if u=='red':
    print(a-1,b)
else:
    print(a,b-1)

### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()
if u==s:
    print(a-1,b)
else:
    print(a,b-1)
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    link[a-1].append([b-1, c])
visited = [0] * N
ans = 0

def dfs(v, cnt):
    global ans
    if v == N-1:
        if visited[v] == 0:
            ans = cnt
        else:
            ans = max(ans, cnt)
        for p in link[v]:
            if visited[p[0]] and ans > 0:
                ans = 'inf'
                print(ans)
                exit()
            elif visited[p[0]] and ans <= 0:
                break
    visited[v] = 1
    for nv in link[v]:
        dfs(nv[0], cnt+nv[1])
    return

dfs(0, 0)
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    c[i] = -c[i]
    
INF = 10 ** 13
dist = [INF] * N

dist[0] = 0

for loop in range(N-1):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]

ans = dist[N-1]

nega = [0] * N

for loop in range(N):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]
            nega[b[i]-1] = 1
        if nega[a[i]-1] == 1:
            nega[b[i]-1] = 1

if nega[N-1]:
    print('inf')
else:
    print(-ans)
open Batteries
let n = read_int ()
let a = read_line () 
let a2 = a |> String.split_on_char ' ' |> List.map int_of_string
let rec loop lst r=
  match lst with
  | [] -> r
  | first :: rest ->
    if List.mem 0 a2 then 0 else
    if first <> 1 && 1000000000000000000 / 2 <= r then -1 else
    loop rest (r*first)

let l = loop a2 1
let _ = l |> Printf.printf "%d\n"

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
i = 1
if 0 in a:
  print(0)
  exit()

for x in a:
  i *= x
  if i > 10 ** 18:
    break


if i > 10 ** 18:
  i = -1
print(i)
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[]
for i in range(m):
    b,c=map(int,input().split())
    bc.append([b,c])
bc.sort(key=lambda x:x[1],reverse=True)
x=[0]*n
for i in range(m):
    x[i+1]=min(bisect.bisect_left(a,bc[i][1]), bc[i][0])+x[i]
    for j in range(x[i],x[i+1]):
        a[j]=bc[i][1]
    

print(sum(a))


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append([1,a[i]])
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=lambda x:x[1], reverse=True)
c=0
ans=0
for i in range(n+m):
    ans+=l[i][1]*l[i][0]
    c+=l[i][0]
    if c>n:
        ans-=l[i][1]*(c-n)
        break
print(ans)
n = int(input())
l = list(map(int , [input() for i in range(n)]))
l_max = max(l)
if (sum(l) - l_max) > 0:
  print('Yes')
else :
  print('No')


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
if max(l) < sum(l) - max(l):
    print('Yes')
else:
    print('No')
a, b, c = map(int, input().split())

if s.count('5') == 2 and s.count('7') == 1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input().split(" ")
if s.count('5') == 2 and s.count('7') == 1:
	print("YES")
else:
	print("NO")