Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3

class Impossible(ValueError):
    pass

def main():
    n, m = map(int, input().split())
    lrds = []
    for i in range(m):
        l, r, d = map(int, input().split())
        lrds.append((l - 1, r - 1, d))

    adj = [[] for i in range(n)]
    parents = [i for i in range(n)]
    for i in range(m):
        l, r, d = lrds[i]
        union(parents, l, r)
        adj[l].append((r, d))
        adj[r].append((l, -d))

    ds = set()
    for i in range(n):
        ds.add(find(parents, i))

    pos = [None for i in range(n)]
    try:
        for i in ds:
            pos[i] = 0
            dfs(adj, pos, i)
        print("Yes")
    except Impossible:
        print("No")

def dfs(adj, pos, x):
    for y, d in adj[x]:
        if pos[y] is None:
            pos[y] = pos[x] + d
            dfs(adj, pos, y)
        elif pos[y] != pos[x] + d:
            raise Impossible

def find(p, x):
    if p[x] != x:
        p[x] = find(p, p[x])
    return p[x]

def union(p, x, y):
    p[find(p, y)] = find(p, x)


main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10 ** 6)

class Impossible(ValueError):
    pass

def main():
    n, m = map(int, input().split())
    lrds = []
    for i in range(m):
        l, r, d = map(int, input().split())
        lrds.append((l - 1, r - 1, d))

    adj = [[] for i in range(n)]
    parents = [i for i in range(n)]
    for i in range(m):
        l, r, d = lrds[i]
        union(parents, l, r)
        adj[l].append((r, d))
        adj[r].append((l, -d))

    ds = set()
    for i in range(n):
        ds.add(find(parents, i))

    pos = [None for i in range(n)]
    try:
        for i in ds:
            pos[i] = 0
            dfs(adj, pos, i)
        print("Yes")
    except Impossible:
        print("No")

def dfs(adj, pos, x):
    for y, d in adj[x]:
        if pos[y] is None:
            pos[y] = pos[x] + d
            dfs(adj, pos, y)
        elif pos[y] != pos[x] + d:
            raise Impossible

def find(p, x):
    if p[x] != x:
        p[x] = find(p, p[x])
    return p[x]

def union(p, x, y):
    p[find(p, y)] = find(p, x)


main()
a,b = int(raw_input()) % 2,int(raw_input()) % 2
print 'Odd' if a == b else 'Even'

### FIXED CODE ###

a,b = map(lambda x:int(x) % 2, raw_input().split()) 
print 'Odd' if (a == b == 1) else 'Even'
n,t =  (int(x) for x in input().split())

A = []
for i in range(n):
    c,ti  =  (int(x) for x in input().split())
    A.append([c,ti])

B = []
for i in A:
    if A[1] < t:
        B.append(i)

if len(B):
    B.sort(key=lambda x: x[0])
    print(B[0])
else:
    print("TLE")

### FIXED CODE ###

# -*- coding: utf-8 -*-

n,t =  (int(x) for x in input().split())

A = []
for i in range(n):
    c,ti  =  (int(x) for x in input().split())
    A.append([c,ti])

A.sort(key=lambda x: x[1])

if A[0][1] > t:
    print("TLE")
else:
    min = A[0][0]
    for i in A:
        if i[1] > t:
            break
        
        if min > i[0]:
            min = i[0]
        
    print(min)
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

import numpy as np

n, k = na()
p = na()
d = [0] * (n + 1)
for i in range(n):
    a = (p[i] * (p[i] + 1) // 2) * (1 / p[i])
    d[i + 1] = d[i] + a

ans = 0.0
for i in range(n - k + 1):
    a = d[i + k] - d[i]
    ans = max(ans, a)

print(ans)

### FIXED CODE ###

import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, k = na()
p = na()
d = [0] * (n + 1)
for i in range(n):
    a = (p[i] * (p[i] + 1) // 2) * (1 / p[i])
    d[i + 1] = d[i] + a

ans = 0.0
for i in range(n - k + 1):
    a = d[i + k] - d[i]
    ans = max(ans, a)

print(ans)
s=input()
print(count("+") - count("-"))

### FIXED CODE ###

s=input()
print(s.count("+") - s.count("-"))
x,y = map(int,input().split())

for i in range(X):
  for j in range(X):
    if 2*i+4*j == Y:
      print("Yes")
      exit()

print("No")

### FIXED CODE ###

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

for i in range(x+1):
  for j in range(x+1):
    if 2*i+4*j == y and i+j == x:
      print("Yes")
      exit()

print("No")
from collections import Counter
#from math import factorial
from scipy.special import comb
def com(n , r):
    return factorial(n) // (factorial(n - r) * factorial(r))
N = int(input())
S = []
for _ in range(N):
    s = input()
    S.append("".join(sorted(s)))
CS = Counter(S)
ans = 0
for val in CS.values():
    ans += comb(val , 2 , exact = True)
print(ans)

### FIXED CODE ###

#from Collections import Counter

N = int(input())
count = 0
word = {}
def str_sort(str):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(str)
for _ in range(N):
    sorted_str = str_sort(input())
    if sorted_str not in word:
        word[sorted_str] = [0]
        word[sorted_str].append(1)
    else:
        if word[sorted_str] == 0:
            word[sorted_str][0] = 1
        else:
            word[sorted_str][0] += word[sorted_str][1]
            word[sorted_str][1] += 1
            #word[sorted_str] = word[sorted_str][0] + word[sorted_str][1]
total = sum(
    v[0] for v in word.values()
)
#print(word)
print(total)
S=input()
list=[Sunny,Cloudy,Rainy]
print(list[list.index((S)+1)])

### FIXED CODE ###

S=input()
list=["Sunny","Cloudy","Rainy"]
print(list[(list.index(S)+1)%3])
n,k =map(int,input().split())
h = [int(input()) for _ in range(n)]
l = []
h.sort()
for i in range(n-1-k):
        x = h[i+k-1] - h[i]
        l.append(x)
print(min(l))

### FIXED CODE ###

n,k =map(int,input().split())
h = [int(input()) for _ in range(n)]
l = []
h.sort()
for i in range(n+1-k):
        x = h[i+k-1] - h[i]
        l.append(x)
print(min(l))
import math

a,b,x = (int(num) for num in input().split())
suf2 = a*b
vol = a*a*b
if (vol/2)>=x:
    l = x*2 / suf2
    x = b/l
    ans = math.degrees(math.atan(x))
else:
    l = (vol-x) / (a*a)
    x = a/l
    ans = math.degrees(math.atan(x))
    
print(round(ans,6))

### FIXED CODE ###

import math

a,b,x = (int(num) for num in input().split())
suf2 = a*b
vol = a*a*b
if (vol/2)>=x:
    l1 = x*2 / suf2
    x = float(b)/l1
    ans = math.degrees(math.atan(x))
else:
    l2 = (vol-x)*2 / (a*a)
    x = l2/float(a)
    ans = math.degrees(math.atan(x))
    
print(round(ans,6))
import math
n = int(input())
for i in range(n):
  l = int(input())
print(math.ceil(n/min(l))+4)

### FIXED CODE ###

import math
n = int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)
SN,LN=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(LN)]
p=list(map(int,input().split()))

c=0
for i in range(1<<SN):
  tmp=[0]*SN
  for j in range(SN):
    if (i>>j)&1==1:
      tmp[j]=1
      judge=True
  for k in range(LN):
    sum=0
    for x in S[k][1:]:
      if tmp[x-1]==1:
        sum+=1
    if sum%2!=p[k]:
      judge=False
  if judge:
    c+=1

print(c)

  


### FIXED CODE ###

SN,LN=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(LN)]
p=list(map(int,input().split()))

c=0
for i in range(1<<SN):
  tmp=[0]*SN
  judge=True
  for j in range(SN):
    if (i>>j)&1==1:
      #tmpにon/offの情報を0/1で入れる
      tmp[j]=1
      
  for k in range(LN):
    sum=0
    #ある電球のスイッチの番号を取得
    for x in S[k][1:]:
      # その番号のスイッチがonか否かを判定
      if tmp[x-1]==1:
        #onの個数を記録
        sum+=1
    #k番目の電球がonでなければその時点でfalse
    if sum%2!=p[k]:
      judge=False
  #あるtmpの状態で全ての電球がonならcにカウント
  if judge:
    c+=1

print(c)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K=map(int,readline().split())
A=list(map(lambda x: int(x)-1,readline().split()))

visited=[True]*N
visitednum=[]
now=0
for i in range(K+1):
    if not visited[now]:
        break
    else:
        visited[now]=False
        visitednum.append(now)
        now=A[now]
d=visitednum.index(now)
ans=(K-d)%(len(visitednum)-d)+d
print(visitednum[ans]+1)

### FIXED CODE ###

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

num = 1
li = [1]
flag = [True] * n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])
import itertools
import bisect



n = int(input())

sm = [0 for _ in range(20)]

for i in range(1,20):
    sm[i] = int(26*(26**i - 1)/25)

#print(sm[4])

xx = bisect.bisect_left(sm, n)
#print(xx)

rd = n - sm[xx-1]
#print(rd)


al = [0 for _ in range(26)]

for i in range(97,122):
    al[i-97] = chr(i)
    

#rdの字の個数だけループを回して、文字を特定していく

ans = []
tmp = [0 for _ in range(30)]
for i in range(xx):
    unt = 26**(xx-i-1)
    if(rd >= unt):
        tmp = [j*unt for j in range(30)]
        num = bisect.bisect_left(tmp,rd)
        ans.append(al[num-1])
        rd -= tmp[num-1]
        #print(rd)
    else:
        ans.append("a")

print("".join(ans))
    
    

### FIXED CODE ###

import itertools
import bisect



n = int(input())
al = [0 for _ in range(26)]
for i in range(97,123):
    al[i-97] = chr(i)
#print(al)

sm = [0 for _ in range(20)]
for i in range(1,20):
    sm[i] = int(26*(26**i - 1)/25)

#print(sm[4])

xx = bisect.bisect_left(sm, n)
#print(xx)
if(xx > 1):
    rd = n - sm[xx-1]
    ans = []
    tmp = [0 for _ in range(30)]
    for i in range(xx):
        if(xx > 1):
            unt = 26**(xx-i-1)
        if(rd >= unt):
            tmp = [j*unt for j in range(30)]
            num = bisect.bisect_left(tmp,rd)
            ans.append(al[num-1])
            rd -= tmp[num-1]
            #print(rd)
        else:
            ans.append("a")

    print("".join(ans))

else:
    print(al[n-1])
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [[0 for i in range(3)] for j in range(3)]
for i in range(N):
  a = int(input())
  for m in range(3):
    for n in range(3):
      if a == A[m][n]:
        B[m][n] = 1
p = 'No'
for i in range(3):
  cnt1 = 0
  cnt2 = 0
  for j in range(3):
    if B[i][j] == 1:
      cnt1 += 1
    if B[j][i] == 1:
      cnt2 += 1
  if cnt1 == 3 or cnt2 == 3:
    p = 'Yes'
    break
cnt3, cnt4 = 0, 0
for i in range(3):
  if B[i][i] == 1:
    cnt3 += 1
  if B[i][3-i] == 1:
    cnt4 += 1
if cnt3 == 3 or cnt4 == 3:
  p = 'Yes'
print(p)

### FIXED CODE ###

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [[0 for i in range(3)] for j in range(3)]
for i in range(N):
  a = int(input())
  for m in range(3):
    for n in range(3):
      if a == A[m][n]:
        B[m][n] = 1
p = 'No'
for i in range(3):
  cnt1 = 0
  cnt2 = 0
  for j in range(3):
    if B[i][j] == 1:
      cnt1 += 1
    if B[j][i] == 1:
      cnt2 += 1
  if cnt1 == 3 or cnt2 == 3:
    p = 'Yes'
    break
cnt3, cnt4 = 0, 0
for i in range(3):
  if B[i][i] == 1:
    cnt3 += 1
  if B[i][2-i] == 1:
    cnt4 += 1
if cnt3 == 3 or cnt4 == 3:
  p = 'Yes'
print(p)
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
Xs = list(mapint())

from bisect import bisect_left
pos = []
neg = []

for x in Xs:
    if x>=0:
        pos.append(x)
    else:
        neg.append(-x)

neg = neg[::-1]

ans = 10**18
if len(pos)>=K:
    ans = min(ans, pos[K-1])
if len(neg)>=K:
    ans = min(ans, neg[K-1])
lenp = len(pos)
lenn = len(neg)
for i in range(min(lenp, K)):
    if K-(i+1)<=lenn:
        ans = min(ans, pos[i]*2+neg[K-i-2])
for i in range(min(lenn, K)):
    if K-(i+1)<=lenp:
        ans = min(ans, neg[i]*2+pos[K-i-2])
print(ans)

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
Xs = list(mapint())

pos = []
neg = []

for x in Xs:
    if x>=0:
        pos.append(x)
    else:
        neg.append(-x)

neg = neg[::-1]

ans = 10**18
if len(pos)>=K:
    ans = min(ans, pos[K-1])
if len(neg)>=K:
    ans = min(ans, neg[K-1])
lenp = len(pos)
lenn = len(neg)
if lenn>0:
    for i in range(min(lenp, K)):
        if K-(i+1)<=lenn:
            ans = min(ans, pos[i]*2+neg[K-i-2])
if lenp>0:
    for i in range(min(lenn, K)):
        if K-(i+1)<=lenp:
            ans = min(ans, neg[i]*2+pos[K-i-2])
print(ans)
n = int(input())
A = list(map(int,input().split()))

#存在するかどうか
b = 1
B=[0]*(n+1)
count = 0
for i in range(n):
    B[i] = b
    if 2*(b - A[i]) < A[i+1]:
        count += 1
    b = 2*(b - A[i])

B[n] = b

j = 0
while A[n] >= B[j]:
    j+=1

total = 0
for i in range(j):
    total += B[i]

s = A[n]
for i in range(n-1,j-1,-1):
    total += min(B[i],s+A[i])
    s+=A[i]+A[n]

if count==0:
    print(total+A[n])
else:
    print('-1')

### FIXED CODE ###

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

b = 1
B=[0]*(n+1)
count = 0

t=len(A)-1
for i in range(t):
    B[i] = b
    if 2*(b - A[i]) < A[i+1]:
        count += 1
        break
    b = 2*(b - A[i])
B[n] = b

if n == 0 and A[0] > 1:
    count += 1

j = 0
while count == 0 and A[t] > B[j]:
    if j == n:
        break
    j += 1

total = 0
for i in range(j):
    total += B[i]

s = A[t]
for i in range(t-1,j-1,-1):
    total += min(B[i],s+A[i])
    s+=A[i]

if count==0:
    print(total+A[t])
else:
    print('-1')
n=input()
if n == 1:
  print("Hello World")
else:
  a=input()
  b=input()
  print(int(a)+int(b))


### FIXED CODE ###

n=input()
if int(n) == 1:
  print("Hello World")
else:
  a=input()
  b=input()
  print(int(a)+int(b))
import math
a,b=map(int,input().split())
print(math.floar((a+b)/2))

### FIXED CODE ###

import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
n, a, b = map(int, input().split)
m = n*b
if m < a :
    print(m)
else:
    print(a)

### FIXED CODE ###

n, a, b = map(int, input().split())
m = n*a
if m < b :
    print(m)
else:
    print(b)
n = int(input())
x = input()
x = int(x, 2)
print(x)

ansl = [0]*n
for i in range(1,n):
    ans = 0
    num = i
    while True:
        pc = bin(num).count("1")
        num %= pc
        ans += 1
        if num == 0: break
    ansl[i] = ans

print(ansl)
for i in range(n):
    bit = (1<<(n-1-i))
    num = x^bit
    pc = bin(num).count("1")
    next_num = num%pc
    a = ansl[next_num] + 1
    print(a)


### FIXED CODE ###

def main():
    n_ansl = [0]*(2*(10**5))
    for i in range(1,2*(10**5)):
    # for i in range(1,20):
        cnt = 0
        one_cnt = bin(i).count("1")
        rem = i
        while rem != 0:
            one_cnt = bin(rem).count("1")
            rem = rem%one_cnt   
            cnt += 1
        n_ansl[i] = cnt
 
    n = int(input())
    x = input()
    one_cnt = x.count('1')

    if one_cnt == 0:
        for i in range(n):
            print(1)
        exit()
    
    curr_2b = 1
    curr_2b_p = 1
    curr_2b_m = 1
    curr_sum = 0
    curr_sum_p1 = 0
    curr_sum_m1 = 0
    for i in range(n-1, -1, -1):
        if x[i] == '1':
            curr_sum += curr_2b
            curr_sum_p1 += curr_2b_p
            curr_sum_m1 += curr_2b_m
            curr_sum%=one_cnt
            curr_sum_p1%=(one_cnt+1)
            if one_cnt > 1:
                curr_sum_m1%=(one_cnt-1)
        curr_2b*=2
        curr_2b_p*=2
        curr_2b_m*=2
        curr_2b%=one_cnt
        curr_2b_p%=(one_cnt+1)
        if one_cnt > 1:
            curr_2b_m%=(one_cnt-1)
 
        
 
    curr_2b = 1
    curr_2b_p = 1
    curr_2b_m = 1
    ansl = [0]*(n)
    for i in range(n-1, -1, -1):
        if x[i] == '1':
            diff = (-1)*curr_2b_m
            if one_cnt > 1:
                ans = (curr_sum_m1 + diff)%(one_cnt-1)
                ansl[i] = n_ansl[ans]+1
            else:
                ansl[i] = 0
        else:
            diff = curr_2b_p
            ans = (curr_sum_p1 + diff)%(one_cnt+1)
            ansl[i] = (n_ansl[ans]+1)
        # curr_2b *= 2
        curr_2b*=2
        curr_2b_p*=2
        curr_2b_m*=2
        curr_2b%=one_cnt
        curr_2b_p%=(one_cnt+1)
        if one_cnt > 1:
            curr_2b_m%=(one_cnt-1)
 
 
    # print(ansl)
    for a in ansl:
        print(a)
 
if __name__ == "__main__":
    main()
min = 0
result = 100000000
for i in range(100):
    for j in X:
        result += (i + 1 - j) ** 2
    if min > result:
        min = result
    result = 0

print(min)

### FIXED CODE ###

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

min = 1000000
result = 0
for i in range(100):
    for j in X:
        result += (i + 1 - j) ** 2
    if min > result:
        min = result
    result = 0

print(min)
import fileinput
import sys

for i in fileinput.input():
    a.append(i)
    
for i in a:
    b = i.split()
    b = map(float, b)

    b_a = b[0]
    b_b = b[1]
    b_c = b[2]
    b_d = b[3]
    b_e - b[4]
    b_f = b[5]
 
    b_d = b_a
    b_e = b_a/b_d * b_e
    b_f = b_a/b_d * b_f

    x = (b_c - b_f)/(b_b - b_e)

    y = (b_c - x * b_b)/b_a 

    print round(x, 3)
    print round(y, 3)

sys.exit(None)

### FIXED CODE ###

while 1:
    def solver(a, b, c, d, e, f):
        answer = []

        if d == 0:
            y = f / e
            x = (c - b * y)/a

        else:
            m = a / d

            d = d * m
            e = e * m
            f = f * m

            y = (c - f)/(b - e)

            x = (c - b * y)/a

            if x == -0:
                x = 0
            if y == -0:
                y = 0

        answer.append(x)
        answer.append(y)
        return answer

    try:
        p_1, p_2, p_3, p_4, p_5, p_6 = map(float, raw_input().split())

        ans = []
        ans = solver(p_1, p_2, p_3, p_4, p_5, p_6)

        print "%.3f %.3f" % (ans[0], ans[1])

    except:
        break
n = int(input())
m = int(input())
sum = 0
sum = n*(n-1)/2 + m*(m-1)/2
print(sum)

### FIXED CODE ###

n, m = map(int, input().split())
sum = n*(n-1)//2 + m*(m-1)//2
print(sum)
S = input()

sorted_S = sorted(S)

if S[0] == S[1] and S[2] == S[3] ans S[1] != S[2]:
	print("Yes")
else:
	print("No")



### FIXED CODE ###

S = input()

sorted_S = sorted(S)

if sorted_S[0] == sorted_S[1] and sorted_S[2] == sorted_S[3] and sorted_S[1] != sorted_S[2]:
	print("Yes")
else:
	print("No")
n = input()
sum = 0
for i in range(1,n+1):
  if i % 3 == 0 or i % 5 == 0:
    continue
  else: 
    sum += i
print(sum)

### FIXED CODE ###

n = int(input())
sum = 0
for i in range(1,n+1):
  if i % 3 == 0 or i % 5 == 0:
    continue
  else: 
    sum += i
print(sum)
def AtCoder_A():
    Prices=input().split()
    print(Prices)
    Train=min(int(Prices[0]),int(Prices[1]))
    Bus=min(int(Prices[2]),int(Prices[3]))
    print(Train+Bus)
    return

AtCoder_A()


### FIXED CODE ###

def AtCoder_A():
    Prices=[]
    for i in range(4):
        Prices.append(input())
    Train=min(int(Prices[0]),int(Prices[1]))
    Bus=min(int(Prices[2]),int(Prices[3]))
    print(Train+Bus)
    return

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

ans = [0]
for i in range(1, n+1):
  if s[i] == "I":
    ans.append(ans[i-1]+1)
  else:
    ans.append(ans[i-1]-1)

print(max(ans))

### FIXED CODE ###

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

ans = [0]
for i in range(n):
    if s[i] == "I":
        ans.append(ans[i] + 1)
    else:
        ans.append(ans[i] - 1)

print(max(ans))
n,m=map(int,input().split())
nexts=[None for i in range(n)]
for i in range(n):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  if nexts[a]==None:
    nexts[a]=[b]
  else:
    nexts[a].append(b)
  if nexts[b]==None:
    nexts[b]=[a]
  else:
    nexts[b].append(a)

ans=0
stack=[]
stack.append([0,[]])
while stack:
  node=stack.pop()
  v=node[0]
  seen=node[1][:]
  seen.append(v)
  if len(seen)==n:
    ans+=1
    continue
  childs=nexts[v]
  if childs:
    for child in (set(childs)-set(seen)):
      stack.append([child,seen])
  
print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
nexts=[None for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  if nexts[a]==None:
    nexts[a]=[b]
  elif b not in nexts[a]:
    nexts[a].append(b)
  if nexts[b]==None:
    nexts[b]=[a]
  elif a not in nexts[b]:
    nexts[b].append(a)

ans=0
stack=[]
stack.append([0,[]])
while stack:
  node=stack.pop()
  v=node[0]
  seen=node[1][:]
  seen.append(v)
  if len(seen)==n:
    ans+=1
    continue
  childs=nexts[v]
  if childs:
    for child in (set(childs)-set(seen)):
      stack.append([child,seen])
  
print(ans)
n = int()
a = list(map(int, input().split()))
s = 1
for i in a[] :
  ans = s*a[i]
if ans => 10**8:
  print("-1")
else:
  print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(0)
else:
  s = 1
  for i in a :
    s *= i
    if s > 10**18:
      s = -1
      break
  print(s)
sen = [A,B,C]
sen.sort()
if sen == [5,5,7]:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

# -*- coding: utf-8 -*-

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

sen = [A, B, C]
x = max(sen)
y = min(sen)
if x == 7 and y == 5 and sum(sen) - x - y == 5:
    print("YES")
else:
    print("NO")
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

li = make_divisors(ni())
ans = 10000000000000000
for i in range(len(li) // 2):
    f = max(len(str(li[i])), len(str(li[-(i+1)])))
    ans = min(f, ans)
if len(li) % 2 != 0:
    ans = min(len(str(li[len(li)//2 + 1])), ans)
print(ans)


### FIXED CODE ###

import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = ni()
li = make_divisors(n)
ans = 10000000000000000
for i in range(len(li) // 2):
    if li[i] * li[-(i+1)] == n:
        f = max(len(str(li[i])), len(str(li[-(i+1)])))
        ans = min(f, ans)
if len(li) % 2 != 0:
    if len(li) == 1:
        ans = 1
    else:
        print()
        ans = min(len(str(li[len(li)//2])), ans)
print(ans)
# -*- coding: utf-8 -*-

N = 3 
# N = int(input())
s = [input() for range(N)]

a = s[1]
b = s[2]
h = s[3]

S = ((a + b)*h/2)
print(str(S))

### FIXED CODE ###

# -*- coding: utf-8 -*-

N = 3
# N = int(input())
s = [input() for i in range(N)]

a = int(s[0])
b = int(s[1])
h = int(s[2])

S = int(((a + b)*h/2))
print(str(S))
a = input().split()

if int(a[0])<=int(a[1]) and int(a[0])<=int(a[2]):
  min = int(a[0])
  if int(a[1])<=int(a[2]):
    max = int(a[2])
  else:
    max = int(a[1])
elif int(a[1])<=int(a[2]) and int(a[1])<=int(a[0]):
  min = aint([1])
  if int(a[0])<=int(a[2]):
    max = int(a[2])
  else:
    max = int(a[0])
else:
  min = int(a[2])
  if int(a[0])<=int(a[1]):
    max = int(a[1])
  else:
    max = int(a[0])

print(max-min)

### FIXED CODE ###

a = input().split()

if int(a[0])<=int(a[1]) and int(a[0])<=int(a[2]):
  min = int(a[0])
  if int(a[1])<=int(a[2]):
    max = int(a[2])
  else:
    max = int(a[1])
elif int(a[1])<=int(a[2]) and int(a[1])<=int(a[0]):
  min = int(a[1])
  if int(a[0])<=int(a[2]):
    max = int(a[2])
  else:
    max = int(a[0])
else:
  min = int(a[2])
  if int(a[0])<=int(a[1]):
    max = int(a[1])
  else:
    max = int(a[0])

print(max-min)