Harryxun/stf_run huggingface dataset:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D

def postorder(binary_tree, target_index, result):
    
    left = binary_tree[target_index]["left"]
    right = binary_tree[target_index]["right"]
    
    if not left == -1:
        postorder(binary_tree, left, result)
    if not right == -1:
        postorder(binary_tree, right, result)

    result.append(target_index)

def solve(preorder_list, inorder_list, result):
    #print(preorder_list, inorder_list)
    if len(inorder_list) == 1:
        return inorder_list[0]
    
    parent = preorder_list[0]
    left_trees = inorder_list[:inorder_list.index(parent)]
    right_tree_index = 1
    if left_trees:
        result[parent]["left"] = solve(preorder_list[1:], left_trees, result)
        right_tree_index = preorder_list.index(left_trees[-1]) + 1
        
    right_trees = inorder_list[inorder_list.index(parent) + 1:]
    if right_trees:
        result[parent]["right"] = solve(preorder_list[right_tree_index:], right_trees, result)

    return parent

def reconstruction(preorder_list, inorder_list, node_num):
    result = [{"left":-1,"right":-1} for i in range(node_num + 1)]
    solve(preorder_list, inorder_list, result)
    return result

def main():
    node_num = int(input())
    preorder_list = [int(a) for a in input().split()]
    inorder_list = [int(a) for a in input().split()]
    binary_tree = reconstruction(preorder_list, inorder_list, node_num)
    postorder_list = []
    postorder(binary_tree, preorder_list[0], postorder_list)
    print(*postorder_list)
if __name__ == "__main__":
    main()

### FIXED CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D

def postorder(binary_tree, target_index, result):
    
    left = binary_tree[target_index]["left"]
    right = binary_tree[target_index]["right"]
    
    if not left == -1:
        postorder(binary_tree, left, result)
    if not right == -1:
        postorder(binary_tree, right, result)

    result.append(target_index)

def solve(preorder_list, inorder_list, result):
    #print(preorder_list, inorder_list)
    if len(inorder_list) == 1:
        return inorder_list[0]
    
    parent = preorder_list[0]
    left_trees = inorder_list[:inorder_list.index(parent)]
    right_tree_index = 1
    if left_trees:
        result[parent]["left"] = solve(preorder_list[1:], left_trees, result)
        right_tree_index = len(left_trees) + 1
        
    right_trees = inorder_list[inorder_list.index(parent) + 1:]
    if right_trees:
        result[parent]["right"] = solve(preorder_list[right_tree_index:], right_trees, result)

    return parent

def reconstruction(preorder_list, inorder_list, node_num):
    result = [{"left":-1,"right":-1} for i in range(node_num + 1)]
    solve(preorder_list, inorder_list, result)
    return result

def main():
    node_num = int(input())
    preorder_list = [int(a) for a in input().split()]
    inorder_list = [int(a) for a in input().split()]
    binary_tree = reconstruction(preorder_list, inorder_list, node_num)
    postorder_list = []
    postorder(binary_tree, preorder_list[0], postorder_list)
    print(*postorder_list)
if __name__ == "__main__":
    main()
costs = [2,5,5,4,5,6,3,7,6]

N, M = map(int, input().split())
A = list(map(int, input().split()))
neginf = -1 * 1e20
D = [neginf]*(N+1)

def dp(n_match):
    D[0] = 0
    for n in range(1,n_match+1):
        # if D[n] < 0:
        #     continue
        arr = [D[n-costs[a-1]] if n-costs[a-1]>=0 else neginf for a in A]
        D[n] = max(arr)+1
    # exit(0)

def main():
    dp(N)
    # print(D)
    # exit(0)
    n = N
    ans = ''
    while n>0:
        arr = [ a for a in A if D[n-costs[a-1]]==D[n]-1 ]
        if len(arr)>0:
            a = max(arr)
            ans += str(a)
            n -= costs[a-1]
        else:
            break
    print(ans)

main()



### FIXED CODE ###

N,M = map(int, input().split())
cost = [0,2,5,5,4,5,6,3,7,6]
A = list(map(int, input().split()))

costp = sorted([ (cost[a] ,a) for a in A], key=lambda x:x[1], reverse=True)
costX = [ z[0] for z in costp]
A = [ z[1] for z in costp]
# print(A,costX)

dp = [-1] * (N+1)
dp[N] = 0

for i in range(N, 1, -1):
    if (dp[i]) == -1:
        continue

    for c,a in zip(costX,A):
        if i-c >= 0:
            dp[i-c] = dp[i] + 1


ans = ""

i = 0
while i<N:
    # print(i)
    for c,a in zip(costX,A):
        # print(c,a,i)
        # if i+c <= N:
        #     print("i: {}, dp[i]=".format(i), dp[i], ", dp[i+c]: ", dp[i+c], "c=",c, "a=",a)
        # else: print("i: {}, dp[i]=".format(i), dp[i], ",c=",c, "a=",a)
        
        if i+c <= N:
            if dp[i]-1 == dp[i+c]:
                ans += str(a)
                i = i+c
                break

print(ans)
# print(dp)
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[1]+c3[2]
e = c1[1]+c2[2]+c3[0]
f = c1[2]+c2[0]+c3[1]
if a=b and b=c and c=d and d=e and e=f:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[2]+c3[1]
e = c1[1]+c2[0]+c3[2]
f = c1[2]+c2[1]+c3[0]
if a==b==c==d==e==f:
  print('Yes')
else:
  print('No')
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
N,Q=[int(i) for i in input().split()]
S=list(input())
hani=[[int(i) for i in input().split()] for j in range(Q)]
ACindex=[i for i in range(N) if S[i]=="A" and S[i+1]=="C"]
for j in hani:
    print(sum([j[0]-1<= k <j[1]-1 for k in ACindex]))


### FIXED CODE ###

#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(_) for _ in input().split()]
S=list(input())
hani=[[int(a) for a in input().split()] for j in range(Q)]
ACindex=[0]
cur=0
for i in range(N-1):
    cur+=S[i]=="A" and S[i+1]=="C"
    ACindex.append(cur)
ACindex.append(cur)
for j in hani:
    print(ACindex[j[1]-1]-ACindex[j[0]-1])
a, b = map(int, split())
if a * b % 2 == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

a, b = map(int, input().split())
if a * b % 2 == 0:
  print('Even')
else:
  print('Odd')
N, A, B, C, D = map(int, input().split())
S = input()
S = "#" + S + "#"

# A -= 1
# B -= 1
# C -= 1
# D -= 1

def can_reach(start, end):
    for i in range(start, end + 2):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")

### FIXED CODE ###

N, A, B, C, D = map(int, input().split())
S = input()
S = "#" + S + "#"

# A -= 1
# B -= 1
# C -= 1
# D -= 1

def can_reach(start, end):
    for i in range(start, end + 1):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")
list_len = int(input())
input_list = map(int, input().split)
even_list_len = list_len
count = 0
 
while:
	even_list = filter(lambda num: num & 2 , input_list)
    even_list_len = len(even_list)
	if list_len != even_list_len:
      break
    count += 1
    
print(count)

### FIXED CODE ###

input_list_len = int(input())
input_list = map(int, input().split())
even_list = input_list
even_list_len = input_list_len
count = 0

while True:
    even_list = list(filter(lambda num: num % 2 == 0, even_list))
    even_list_len = len(even_list)
    if input_list_len != even_list_len:
        break
    even_list = map(lambda num: num / 2, even_list)
    count += 1

print(count)
x = int(input())
m = 100
i = 0.01
y = 0
flag = True
while flag:
    m = math.floor(m*(1+i))
    y += 1
    if m >= x:
        break
print(y)

### FIXED CODE ###

import math

x = int(input())
m = 100
i = 0.01
y = 0
flag = True
while flag:
    m = math.floor(m*(1+i))
    y += 1
    if m >= x:
        break
print(y)
x = int(input())

    if x >= 30:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

x = int(input())

if x >= 30:
    print("Yes")
else:
    print("No")
N,K=map(int,input().split())
a=list(map(int, input().split()))
if 0 in a:
    K -=1
if K==0:
    print(0)
else:
    b=list(map(abs, a))
    i=b.index(min(b))
    c=list(filter(lambda x: x>=0, a))
    e=sorted(c)
    d=list(map(abs, filter(lambda x: x<0, a)))
    f=sorted(d)

    lp=len(c)
    lm=len(d)
    s=[]
    v=[]
    for i in range(lp):
        if K-i<=lm:
            if i==K:
                u=e[i-1]
            else:
                u=2*e[i-1]+f[K-i-1]
            s.append(u)
    for t in range(lm):
        if K-t<=lp:
            if t==K:
                q=f[t-1]
            else:
                q=2*f[t-1]+e[K-t-1]
            s.append(q)

    print(min(s))


### FIXED CODE ###

N,K=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(abs, a))
i=b.index(min(b))
c=list(filter(lambda x: x>=0, a))
e=sorted(c)
d=list(map(abs, filter(lambda x: x<0, a)))
f=sorted(d)

lp=len(c)
lm=len(d)
s=[]
if 0 in a:
    K -=1

if K==0:
    print(0)
elif lp==0:
    print(f[K-1])
elif lm==0:
    print(e[K-1])
elif K==N:
    print(min(2*e[lp-1]+f[lm-1],2*f[lm-1]+e[lp-1]))
else:
    for i in range(lp):
        if K-i<=lm:
            if i==K:
                u=e[i-1]
            else:
                u=2*e[i-1]+f[K-i-1]
            s.append(u)
    for t in range(lm):
        if K-t<=lp:
            if t==K:
                q=f[t-1]
            else:
                q=2*f[t-1]+e[K-t-1]
            s.append(q)

    print(min(s))
# -*- coding:utf-8 -*-
import sys

w = int(input())
n = int(input())

array = []
count = 0
for i in sys.stdin:
    array.append(i)
    count += 1
    if count == n:
        break

a, b = [0]*n, [0]*n
for i in range(n):
    s = array[i]
    a[i], b[i] = s[0], s[2]
    a[i], b[i] = int(a[i]), int(b[i])

lines = []
k = 0
for i in range(w):
    lines.append(k)
    k += 1 

for i in range(n):
    tmp1 = lines[a[i]-1]
    tmp2 = lines[b[i]-1]
    lines[a[i]-1] = tmp2
    lines[b[i]-1] = tmp1

for i in range(len(lines)):
    print(lines[i]+1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
import sys
 
def amida(w, side_bar):
    result = []
    side_bar.reverse()
    for x in range(1, w+1):
        status = x
        for bar in side_bar:
            if status == bar[0]:
                status = bar[1]
            elif status == bar[1]:
                status = bar[0]
        result.append(status)
    return result
 
def main():
    W = int(input())
    N = int(input())
    side_bar = [tuple(map(int, input().split(','))) for line in range(N)]
    result = amida(W, side_bar)
    for r in result:
        print(r)
 
if __name__ == '__main__':
    main()
a = 0
b = 0

input(a)
input(b)

if (a*b)%2 == 0:
    print("Odd")
else:
    print("Even")

### FIXED CODE ###

str = input()
a = str.split(" ")
c = int(a[0])*int(a[1])
if c%2 == 0:
    print("Even")
else:
    print("Odd")
print(input()**2-input())

### FIXED CODE ###

print(int(input())**2-int(input()))
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6*m
    kakua = 30*h + (30*(m/60))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn

    ans = (a**2) + (b**2) -( (2*a*b)*math.cos(math.radians(aug)) )
    print(math.sqrt(ans))



if __name__=='__main__':
    main()

### FIXED CODE ###

import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0
    
    if aug == 180.0:
        ans=a+b
        print(ans)
    
    else: 
        ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
        print(math.sqrt(ans))



if __name__=='__main__':
    main()
input()
a = map(int, input().split())
print(max(a) - min(a))

### FIXED CODE ###

input()
a = list(map(int, input().split()))
print(max(a) - min(a))
s1, s2, s3 = input().split()

print(f"{s1[0]}{s2[0]}{s3[0]}")

### FIXED CODE ###

s1, s2, s3 = input().split()
print("{0}{1}{2}".format(s1[0], s2[0], s3[0]))
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))

if __name__ == "__main__":
    while True:
        a, b = raw_input().split()
        print "%d\n" % dn(a, b),

### FIXED CODE ###

#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break
import math
K = int(input())
t = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            t += gcd(gcd(i,j),k)
print(t)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
t = 0
t1 = 0
t2 = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for l in range(j,K+1):
            if i == j == l:
                t = t + i
            elif i == j or j ==l or l ==i:
                t = t + 3 * gcd(i, j,l)
            else:
                t = t + 6 * gcd(i,j,l)
             
           
           
print(t)
import math
import heapq

N,M = map(int,input().split())
Price_List = list(map(lambda x:x*(-1),map(int,input().split())))
heapq.heapify(Price_List)
for i in range(M):
    heapq.heapify(Price_List)
    val = heapq.heappop(Price_List)* -1 // 2 * -1
    heapq.heappush(Price_List,val)
    print(Price_List)
print(-sum(Price_List))

### FIXED CODE ###

import bisect
 
N,M = map(int,input().split())
Price_List = list(map(int,input().split()))
Price_List.sort()
for i in range(M):
    New_Price = Price_List.pop(-1)//2
    Price_List.insert(bisect.bisect(Price_List,New_Price),New_Price)
print(sum(Price_List))
n=int(input())
s = ''
while n>0:
        s += chr(ord('a') + (n-1)% 26)
        (n-1)//=26

print(s[::-1])


### FIXED CODE ###

n=int(input())
ans = ''
while n>0:
        n = n-1
        ans += chr(ord('a') + (n)% 26)
        n//=26
ans = ans[::-1]
print(ans)
S = input()
T = ""

i = 0
while i <= len(S) - 7:
    if  S[i] == "d":
        if S[i+5] == "d" or S[i+7] == "a":
            T += "dream"
            i += 5
        else:
            T += "dreamer"
            i += 7
    else:
        if S[i+5] == "r":
            T += "eraser"
            i += 7
        else:
            T += "erase"
            i += 5

if S == T+"dream" or S == T+"dreamer" or S == T+"erase" or S == T+"eraser":
    print("YES")
else:
    print("NO")

### FIXED CODE ###

def judge(s):
    flag = True
    s = s[::-1]
    ans = ""
    pivot = 0
    while pivot < len(s):
        if s[pivot] == "m":
            ans += "maerd"
            pivot += 5
        elif s[pivot] == "e":
            ans += "esare"
            pivot += 5
        elif s[pivot:pivot+3] == "rem":
            ans += "remaerd"
            pivot += 7
        elif s[pivot:pivot+3] == "res":
            ans += "resare"
            pivot += 6
        else:
            flag = False
            break
    if flag == False:
        return "NO"
    elif s == ans:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    s = input()
    print(judge(s))
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
a(H)
print(ans)

### FIXED CODE ###

def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
if H != 1:
    a(H)
print(ans)
n=int(input())
if n==1:
  print("Hello World")
else:
  a,b=map(int,input().split())
  print(a+b)



### FIXED CODE ###

n=int(input())
if n==1:
  print("Hello World")
else:
  a=int(input())
  b=int(input())
  print(a+b)
a,b=map(int,input().split())
if a%2==0or b%2==0:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

a, b = map(int, input().split())
print("Yes" if a*b%2==1 else "No")
n = int(input())
a = map(int, input().split())
s = sum(a)
x = a[0]
m = abs(s-2*x)
for i in range(1,n-1):
  x += a[i]
  m = min(m,abs(s-2*x))
print(s)
  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = sum(a[1:])-a[0]
m = abs(s)
for i in range(1,n-1):
  s -= 2*a[i]
  m = min(m,abs(s))
print(m)
H, W = map(int, input().rstrip().split())
s =[list(input().rstrip()) for _ in range(W)]

judge = True
for i in range(H):
    for j in range(W):
        if s[i][j] =='#':
            flag = 0
            if i-1 >= 0 and s[i-1][j] == '#':
                flag = 1
            if j-1 >= 0 and s[i][j-1] == '#':
                flag = 1
            if j+1 < W and s[i][j+1] == '#':
                flag = 1
            if i+1 < H and s[i+1][j] == '#':
                flag = 1
            if flag == 0:
                judge == False
                
if judge:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

H, W = map(int, input().rstrip().split())
s =[list(input().rstrip()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] =='#':
            flag = 0
            if i-1 >= 0 and s[i-1][j] == '#':
                flag = 1
            if j-1 >= 0 and s[i][j-1] == '#':
                flag = 1
            if j+1 < W and s[i][j+1] == '#':
                flag = 1
            if i+1 < H and s[i+1][j] == '#':
                flag = 1
            if flag == 0:
                print('No')
                exit()
                
print('Yes')
import math
n,d = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
	if math.sqrt((xy[0])**2 + (xy[1])**2) <= d:
		cnt += 1
print(cnt)

### FIXED CODE ###

import math
n,d = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
	if math.sqrt((xy[i][0])**2 + (xy[i][1])**2) <= d:
		cnt += 1
print(cnt)
import sys

N,A,B,C,D = map(int, input().split())
s = input()
#index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]
#print(index)

if s.count("##")>=1:
    print("No")
    sys.exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 <= D:
                print("Yes")
                exit()
        print("No")
    else:
        print("No")


### FIXED CODE ###

N,A,B,C,D = map(int, input().split())
s = input()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if C < D:
    if "##" in s[A-1:D]:
        print("No")
    else:
        print("Yes")

if C > D:
    if "##" in s[A-1:C]:
        print("No")
    else:
        if len(index)>=1:
            for i in index:
                if B <= i+1 <= D:
                    print("Yes")
                    exit()
            print("No")
        else:
            print("No")
from heapq import nlargest
from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[0, a] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dp[i | b] = nlargest(2, dp[i] + dp[i | b])
    dp[b] = nlargest(2, dp[0] + dp[b])

ans = list(accumulate(map(sum, dp[1:]), func=max))
print(*ans)


### FIXED CODE ###

n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[a, 0] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dpi, dpk = dp[i], dp[i | b]
            if dpk[0] < dpi[0]:
                dpk[1] = max(dpk[0], dpi[1])
                dpk[0] = dpi[0]
            elif dpk[1] < dpi[0]:
                dpk[1] = dpi[0]

ans = []
tmp = 0
for a in dp[1:]:
    tmp = max(tmp, a[0] + a[1])
    ans.append(tmp)
print(*ans)
if S[2]==S[3] and S[4]==S[5]:
  return "Yes"

return "No"

### FIXED CODE ###

S = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
	print("No")
N= int(input())
L= list(map(int,input().split()))

v=[]
for i in range(N):
  v.append(abs(sum(L[:(i+1)]-L[(i+1):])))

ans=min(v)

print(ans)


### FIXED CODE ###

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i+1])-sum(L[i+1:])))

ans=min(v)

print(ans)
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
pandas = "*"
numpy = "*"

[requires]
python_version = "3.7"


### FIXED CODE ###

import numpy as np

n, m, c = map(int, input().split())
b = list(map(int, input().split()))

b = np.array(b)

count = 0
for _ in range(n):
    a = list(map(int, input().split()))
    a = np.array(a)

    if np.dot(a, b) + c > 0:
        count += 1
else:
    print(count)
T,X = map(int, input().split(" "))
print(f"{T/X:.5f})

### FIXED CODE ###

T,X = map(int, input().split())
print(T/X)
def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = 54
    modulo_value = int(int(10e9)+7)
    return ans % modulo_value


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))


### FIXED CODE ###

"""
the condition is straightforward.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcd of a list is loop: lcd(partial, new_value)
lcd(a, b) = ab / gcd(a, b)
"""

from fractions import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = val*lcm_ongoing//gcd(val, lcm_ongoing)
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(lcm_of_A//value for value in A)
    modulo_value = int(int(10e8)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))
S = list(input ())
T = list(input ())
a = len(S)
change_time = 0

for i in a:
  if (S[i] ==T[i])
  continue
  
  else:
  S[i] =T[i]
  change_time += 1
  
  
print(change_time)

### FIXED CODE ###

S = list(input ())
T = list(input ())
a = len(S)
change_time = 0
 
for i in range(a):
  if S[i] ==T[i]:
  	continue
  
  else:
 
  	change_time += 1
  
  
print(change_time)
print("Yes" if 9 in input() else "No")

### FIXED CODE ###

print("Yes" if '9' in input() else "No")
N, T = raw_input().split()
sct = []
for i in xrange(int(N)):
    ci, ti = raw_input().split()
    if int(ti) <= int(T):
        s = set()
        s.add(ci)
        s.add(ti)
        sct.append(int(ci))
print(min(sct))

### FIXED CODE ###

N, T = raw_input().split()
sct = []
for i in xrange(int(N)):
    ci, ti = raw_input().split()
    if int(ti) <= int(T):
        s = set()
        s.add(ci)
        s.add(ti)
        sct.append(int(ci))
print('TLE' if sct ==[] else min(sct))
N = input()
a = []
for i in range(N):
    a.append(map(int, raw_input(.split)))
for i in range(N):
    a = a[i][0] ** 2
    b = a[i][1] ** 2
    c = a[i][2] ** 2

    if a == b + c or b == a + c or c == a + b:
        print "YES"
    else:
        print "NO"

### FIXED CODE ###

N = input()
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))

for j in range(N):

    x = a[j][0] ** 2
    y = a[j][1] ** 2
    z = a[j][2] ** 2

    if x == y + z:
        print "YES"
    elif y == x + z:
        print "YES"
    elif z == x + y:
        print "YES"
    else:
        print "NO"