Harryxun/stf_run huggingface dataset:
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7


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

N = 8000

X = [0]
Y = [0]
flag = True
for s in S:
    if s == 'F':
        if flag:
            X[-1] += 1
        else:
            Y[-1] += 1
    else:
        if flag:
            if Y[-1] != 0:
                Y.append(0)
        else:
            if X[-1] != 0:
                X.append(0)
        flag = not flag

dp = [[0] * (2 * N) for _ in range(len(X))]
if S[0] == 'F':
    dp[0][X[0] + N] = 1
else:
    dp[0][X[0] + N] = 1
    dp[0][-X[0] + N] = 1

for i in range(1, len(X)):
    x_ = X[i]
    for j in range(2 * N):
        if j >= x_:
            if dp[i - 1][j - x_]:
                dp[i][j] = 1
        if j + x_ < 2 * N:
            if dp[i - 1][j + x_]:
                dp[i][j] = 1

# print (dp)
if dp[-1][x + N] == 0:
    print ('No')
    exit()

dp = [[0] * (2 * N) for _ in range(len(Y))]
dp[0][Y[0] + N] = 1
dp[0][-Y[0] + N] = 1

for i in range(1, len(Y)):
    y_ = Y[i]
    for j in range(2 * N):
        if j >= y_:
            if dp[i - 1][j - y_]:
                dp[i][j] = 1
        if j + y_ < 2 * N:
            if dp[i - 1][j + y_]:
                dp[i][j] = 1

if dp[-1][y + N] == 0:
    print ('No')
    exit()

print ('Yes')

### FIXED CODE ###

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

X = [0]
Y = [0]

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X.append(tmp)
        else:
            Y.append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X.append(tmp)
else:
    Y.append(tmp)

# print (X)
# print (Y)

x -= X[1]
X[1] = 0

x = abs(x)
y = abs(y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = [0] * (total_X + 1)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    for j in range(total_X - i, -1, -1):
        if lst_X[j] == 1:
            lst_X[j + i] = 1

# print (lst_X)

lst_Y = [0] * (total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    for j in range(total_Y - i, -1, -1):
        if lst_Y[j] == 1:
            lst_Y[j + i] = 1

# print (lst_Y)
if x > total_X or y > total_Y:
    print ('No')
    exit()

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and lst_X[(total_X - x) // 2] == 1 and lst_Y[(total_Y - y) // 2]:
    print ('Yes')
else:
    print ('No')
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
#print(A)
X = [0 for i in range(N)]
CB = []
for i in range(M):
    b,c = map(int,input().split())
    CB.append([c,b])
CB.sort(reverse=True)
#print(CB)
index = 0
for i in range(M):
    for j in range(CB[i][1]):
        A[index] = max(A[index],CB[i][0])
        index += 1
        if index != N - 1:
            continue
        else:
            print(sum(A))
            exit()
print(sum(A))

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
#print(A)
X = [0 for i in range(N)]
CB = []
for i in range(M):
    b,c = map(int,input().split())
    CB.append([c,b])
CB.sort(reverse=True)
#print(CB)
index = 0
for i in range(M):
    for j in range(CB[i][1]):
        A[index] = max(A[index],CB[i][0])
        if index != N - 1:
            index += 1
            continue
        else:
            print(sum(A))
            exit()
print(sum(A))
def permutation(lst): 
  
    # If lst is empty then there are no permutations 
    if len(lst) == 0: 
        return [] 
  
    # If there is only one element in lst then, only 
    # one permuatation is possible 
    if len(lst) == 1: 
        return [lst] 
  
    # Find the permutations for lst if there are 
    # more than 1 characters 
  
    l = [] # empty list that will store current permutation 
  
    # Iterate the input(lst) and calculate the permutation 
	for i in range(len(lst)): 
		m = lst[i] 
  
       # Extract lst[i] or m from the list.  remLst is 
       # remaining list 
       remLst = lst[:i] + lst[i+1:] 
  
       # Generating all permutations where m is first 
       # element 
	for p in permutation(remLst): 
           l.append([m] + p) 
    return l 

N= input()
x = [int(x) for x in input().split()]
y = [int(x) for x in input().split()]
 
NN = list(range(1,int(N)+1))
P = permutation(NN)
 
xx = P.index(x)
yy = P.index(y)
print(abs(xx-yy))

### FIXED CODE ###

def permutation(lst):
    # If lst is empty then there are no permutations
  if len(lst) == 0:
    return []

        # If there is only one element in lst then, only
    # one permuatation is possible
  if len(lst) == 1:
    return [lst]

        # Find the permutations for lst if there are
    # more than 1 characters

  l = []  # empty list that will store current permutation

    # Iterate the input(lst) and calculate the permutation
  for i in range(len(lst)):
    m = lst[i]

        # Extract lst[i] or m from the list.  remLst is
        # remaining list
    remLst = lst[:i] + lst[i + 1:]

        # Generating all permutations where m is first
        # element
    for p in permutation(remLst):
      l.append([m] + p)
  return l


N = input()
x = [int(x) for x in input().split()]
y = [int(x) for x in input().split()]

NN = list(range(1, int(N) + 1))
P = permutation(NN)

xx = P.index(x)
yy = P.index(y)
print(abs(xx - yy))
n,y=map(int,input().split())
for a in range(n+1):
    for b in range(n-a+1):
        if y-10000*a-5000*b==1000*(n-a-b):
            print(a,b,n-b-a)
            flag=True
            break
    if flag: break
if not flag: print("-1 -1 -1")

### FIXED CODE ###

n,y=map(int,input().split())
flag=False
for a in range(n+1):
    for b in range(n-a+1):
        if y-10000*a-5000*b==1000*(n-a-b):
            print(a,b,n-b-a)
            flag=True
            break
    if flag: break
if flag==False: print("-1 -1 -1")
N, A = map(int, input().split())

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

tmp_max = max(x)
tmp_max = max(tmp_max, A)

dp = [[[0 for _ in range(tmp_max * N + 1)] for _ in range(N + 1)] for _ i range(N + 1)]
dp[0][0][0] = 0

for j in range(n + 1):
  for k in range(j + 1):
    for s in range(tmp_max * K + 1):
      if j >= 1 and s < x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
        
        
ans = 0
for k in range(1, n + 1):
  ans += dp[N][k][k * A]
  
print(ans)

### FIXED CODE ###

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

max_num = max(x)
max_num = max(A, max_num)
# x_jまでからk枚選んで合計がｓになる選び方の総数。ｓはk*Aにすれば平均がAになる
dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
#何も選ばないで平均が０
dp[0][0][0] = 1

for j in range(N+1):
  for k in range(j+1):
    for s in range(max_num * k + 1):
      if j >= 1 and s < x[j - 1]:
        # j番目を選んでk+1個を選んだ際に平均がAにならない場合
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        # j番目をえらんでk+1個選んで平均がAになるものがあるなら、j-1番までの合計はs-x_j-1なので、その数を足している
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
 

ans = 0
# 合計がkAになるものを加算
for k in range(1, N + 1):
  ans += dp[N][k][k*A]
print(ans)
a = int(input())
b = int(input())

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')
S = list(input())
K = int(input())

#print(link_S)
#S = S.append(S[len(S)-1])
i = 0
sum = 1
total_sum = 0
sum_ketu = 0
while(1):
    if i == len(S)-1:
        if S[i] == S[0] and S[0] != S[1]:
            sum += 1
            sum_ketu = -1
        break
    if S[i] == S[i+1]:
     #   print("i is", i)
     #   print("S[i] is", S[i], "S[i+1] is", S[i+1])
        sum += 1
     #   print(sum)
        i += 1
    else:
        total_sum += sum // 2
        sum = 1
        i += 1
        
total_sum += sum // 2

print(total_sum * K + sum_ketu)



### FIXED CODE ###

S = list(input())
K = int(input())

if len(S) == 1:
    print( K // 2)
    exit()

count = 1
i = 0
sum = 0
while(1):
    if S[i] == S[i+1]:
        count += 1
        i += 1
    else:
        sum += count//2
        count = 1
        i += 1
    if i == len(S)-1:
        break

sum += count//2 #最後のカウントの加算

#print("check1",sum)

#先頭の連続数をカウント
j = 0 # リストカウント
a = 1 # 連続数カウント
while(1):
    if S[j] == S[j+1]:
        a += 1
        j += 1
    else:
        break
    if j == len(S) -1:
        break
#print("check")

#末尾の連続数をカウント
m = len(S)-1 # リストカウント
b = 1 # 連続数カウント
while(1):
    if S[m] == S[m-1]:
        m -= 1
        b += 1
    else:
        break
    if m == 0:
        break

#print("a is",a)
#print("b is",b)
#print("sum is", sum)
if a == len(S): #１文字のみで文字列構成の場合
    print((len(S)* K)//2)
elif S[len(S)-1] == S[0]:
    print( sum * K + ((a+b)//2 - a//2 - b //2 ) * ( K -1))
else:
    print( sum * K)
N = int(input())
if(N in [1, 2, 3, 4, 5, 6, 7 ,8 ,9, 10, 12, 14, 15, 16, 18, 20, 21 ,24, 25, 27, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64 ,72, 81]):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

A, B = map(int, input().split())
print(A*B if A <= 9 and B <= 9 else -1)
from math import gcd

N = int(input())
A = [int(x) for x in input().split()]

ans = A[0]

for i in range(1, N):
    ans = gcd(ans, A[i])

print(ans)


### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


N = int(input())
A = [int(x) for x in input().split()]

ans = A[0]

for i in range(1, N):
    ans = gcd(ans, A[i])

print(ans)
n = int(input())

if n[0] == 9 or n[1] == 9:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

n = int(input())

if n == 19 or n == 29 or n == 39 or n == 49 or n == 59 or n == 69 or n == 79 or n == 89 or n == 91 or n == 92 or n == 93 or n == 94 or n == 95 or n == 96 or n == 97 or n == 98 or n == 99 :
  print("Yes")
else:
  print("No")
N = int(input())
dic = {}
nums = []
for i in range(N):
    num = int(input())
    dic[num] = i+1
    nums.append(num)
ans = 0
for i in range(N):
    if nums[i] <= nums[-1]:
        break
#ans += i
base = nums[i]
print(base)
init_num = base
# baseの位置 > base+1の所できる.
move = 0
while base <= nums[-1]:
    old_i = i
    i = dic[base + 1]
    if old_i > i:
        break
    base += 1
    move += 1
#import IPython;IPython.embed()
#if base != nums[-1]:
#    ans += 1
ans += init_num - 1
ans += N - base
#ans += N - nums[-1]
print(ans)


"""
戦略的には
1. a_0 > a_nの時,どちらかをずらす.
a_nを前に持っていくか,a_0を後ろに持っていくか...
どっちでも変わらない.
"""

### FIXED CODE ###

N = int(input())
dic = {}
nums = []
for i in range(N):
    num = int(input())
    dic[num] = i+1
    nums.append(num)
ans = 0
l = 0
for i in range(N-1):
    if dic[i+2] < dic[i+1]:
        ans = max(ans, l)
        l = 0
    else:
        l += 1
ans = max(ans, l)
print(N-ans-1)
import math
 
N = int(input())
x = list()
y = list()
 
for i in range(N):
    #print(i)
    xy = list(input().split())
    x.append(int(xy[0]))
    y.append(int(xy[1]))
 
lis = list(itertools.permutations(list(range(1, N + 1))))
 
ans = 0    
for i in range(N):
    for j in range(N):
        tmp = math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
        ans += tmp
 
print(ans/N)

### FIXED CODE ###

import math

N = int(input())
x = []
y = []

for k in range(N):
    #print(i)
    X, Y =  map(int,input().split())
    x.append(X)
    y.append(Y)

ans = 0    
for i in range(N):
    for j in range(N):
        tmp = math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
        ans += tmp
 
print(ans/N)
n,m,d = map(int,raw_input().split())

print (((n-d)*2)*(m-1)*n)/float(n**m)

### FIXED CODE ###

n,m,d = map(int,raw_input().split())

print (((n-d)*2)/float(n**2))*(m-1) if d != 0 else ((((n-d)*2)/float(n**2))*(m-1))/2
import sys
input = sys.stdin.readline


N,Q=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
PLUS=[list(map(int,input().split())) for i in range(Q)]

SCORE=[0]*(N+1)
for p,x in PLUS:
    SCORE[p]+=x

ELIST=[[] for i in range(N+1)]

for x,y in EDGE:
    ELIST[x].append(y)
    ELIST[y].append(x)
#print(ELIST)

from collections import deque
Q=deque([1])

USED=[0]*(N+1)
USED[1]=1
#USED = [0, 1, 0, 0, 0] Ex1
#SCORE = [0, 100, 10, 1, 0] Ex1
#ELIST = [[], [2], [1, 3, 4], [2], [2]] Ex1

while Q:
    x=Q.pop()

    for to in ELIST[x]:
        if USED[to]==0:
            USED[to]=1
            SCORE[to]+=SCORE[x]
            Q.append(to)

print(*SCORE[1:])


### FIXED CODE ###

a = int(input())
s = str(input())

if a >= 3200:
  print(s)
else:
  print("red")
from collections import deque
def main():
    n,m=map(int,input().split())
    g=[[] for i in range(n)]
    for i in range(m):
        a,b,c=map(int,input().split())
        a-=1
        b-=1
        g[a].append([b,c])
        g[b].append([a,-c])
    inf=10**10
    v=[inf]*n
    while max(v)==inf:
        s=v.index(inf)
        q=deque([s])
        v[s]=0
        while q:
            p=q.pop_left()
            for i in g[p]:
                if v[i[0]]==inf:
                    v[i[0]]=v[p]+i[1]
                    q.append(i[0])
                else:
                    if v[i[0]]!=v[p]+i[1]:
                        return 'No'
    return 'Yes'
                            
  
print(main())


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5+1)


def dfs(p):
    for edge in G[p]:
        if X[edge[0]] is not None:
            if X[edge[0]] - X[p] != edge[1]:
                print('No')
                exit()
        else:
            X[edge[0]] = X[p] + edge[1]
            dfs(edge[0])


N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append((R, D))
    G[R].append((L, -D))

X = [None] * N
for i in range(N):
    if X[i] is None:
        X[i] = 0
        dfs(i)

print('Yes')
N, Z, W = map(int, input().split())
A = [int(x) for x in input().split()]

memo = [[None for _ in range(2)] for _ in range(2010)]


def f(i, p, x, y):
    """
    i番目にx, yが手持ちのとき、プレイヤーpが引いたときのスコア
    """
    if i == N:
        return abs(x - y)
    if memo[i][p]:
        return memo[i][p]

    if p == 0:
        score = float('-inf')
        for j in range(i, N):
            score = max(score, f(j + 1, 1, A[j], y))
    else:
        score = float('inf')
        for j in range(i, N):
            score = min(score, f(j + 1, 0, x, A[j]))

    memo[i][p] = score
    return score


print(f(0, 0, Z, W))


### FIXED CODE ###

N, Z, W = map(int, input().split())
A = [int(x) for x in input().split()]

if N == 1:
    print(abs(A[0] - W))
else:
    print(max(abs(A[N - 2] - A[N - 1]), abs(A[N - 1] - W)))
List=[list(map(int,input().split())) for i in range(4)]

a=sum(List[2])
b=int(len(List[1]))

for i in range(b-1):
  if List[1][i+1]-List[1][i] == 1:
    a+=List[3][i+1]

print(a)

### FIXED CODE ###

List=[list(map(int,input().split())) for i in range(4)]

a=sum(List[2])
b=int(len(List[1]))

for i in range(b-1):
  if List[1][i+1]-List[1][i] == 1:
    a+=List[3][List[1][i]-1]

print(a)
ar = []
if a + c > b:
    d = b+1
else:
    d = a+c
for i in range(a,d):
    ar.append(i)
if b - c < a:
    e = a
else:
    e = b-c+1
for i in range(e,b+1):
    ar.append(i)
br = set(ar)
cr = sorted(br)
for i in cr:
    print(i)

### FIXED CODE ###

a,b,c = map(int,input().split())
ar = []
if a + c > b:
    d = b+1
else:
    d = a+c
for i in range(a,d):
    ar.append(i)
if b - c < a:
    e = a
else:
    e = b-c+1
for i in range(e,b+1):
    ar.append(i)
br = set(ar)
cr = sorted(br)
for i in cr:
    print(i)
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
k_max = 5100
score = [-10**18-1] * N

for i in range(N):
  score_i = [-10**18-1] * k_max # iからスタートしてK回操作する場合の累積和
  score_i[0] = C[P[i]-1]
  index = P[i]-1
  for k in range(1, K):
    if index == i:
      # 既に進んだことがあるマスの場合
      
      loop_score = score_i[k-1] # 1ループで増えるスコア
      if loop_score > 0:
        loop_num = k # ループする要素数はk(indexが0 ~ k-1)
        
        tmp_score = [-10**18-1] * k_max
        tmp_score[0] = (K//k -1) * loop_score
#        print("loop_score", loop_score)
#        print("tmp_score", tmp_score)
        tmp_index = index
#        print("loop_num + K%k + 1", loop_num + K%k + 1)
        for j in range (1, loop_num + K%k + 1):
          tmp_score[j] = tmp_score[j-1] + C[P[tmp_index]-1]
          tmp_index = P[tmp_index]-1
#        print("max(tmp_score)", max(tmp_score))
        score_i[k] = max(tmp_score)
      break
    score_i[k] = score_i[k-1] + C[P[index]-1]
    index = P[index]-1
  score[i] = max(score_i)
print(max(score))

### FIXED CODE ###

# -*- coding: utf-8 -*-
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
k_max = 10100
score = [-10**18-1] * N

for i in range(N):
  score_i = [-10**18-1] * k_max # iからスタートしてK回操作する場合の累積和
  score_i[0] = C[P[i]-1]
  index = P[i]-1
  for k in range(1, K):
    if index == i:
      # 既に進んだことがあるマスの場合
      
      loop_score = score_i[k-1] # 1ループで増えるスコア
      if loop_score > 0:
        loop_num = k # ループする要素数はk(indexが0 ~ k-1)
        
        tmp_score = [-10**18-1] * k_max
        tmp_score[0] = (K//k -1) * loop_score
#        print("loop_score", loop_score)
#        print("tmp_score", tmp_score)
        tmp_index = index
#        print("loop_num + K%k + 1", loop_num + K%k + 1)
        for j in range (1, loop_num + K%k + 1):
          tmp_score[j] = tmp_score[j-1] + C[P[tmp_index]-1]
          tmp_index = P[tmp_index]-1
#        print("max(tmp_score)", max(tmp_score))
        score_i[k] = max(tmp_score)
      break
    score_i[k] = score_i[k-1] + C[P[index]-1]
    index = P[index]-1
  score[i] = max(score_i)
print(max(score))
a=sorted(list(int,input().split()))
if a==[1,4,7,9]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n= list(map(int,input().split()))
n.sort()
if 1 in n and 7 in n and 9 in n and 4 in n:
  print("YES")
else:
  print("NO")
a

### FIXED CODE ###

a=list(input())
b=list(input())
c=list(input())
s=a.pop(0)
w=''
while True:
    if(s=='a'):
        if(len(a)==0):
            w='A'
            break
        s=a.pop(0)
    elif(s=='b'):
        if(len(b)==0):
            w='B'
            break
        s=b.pop(0)
    else:
        if(len(c)==0):
            w='C'
            break
        s=c.pop(0)
print(w)
N=int(input())
A=list(map(int,input().split()))
max = A[0]
for  i in range(N):
    if A[i] >= max:
        max = A[i]
    else:
        max = max
        
count = 0
position = 0
while position < N:
  for j in range(1,max):
    for i in range(position,N):
      if A[i] == j:
        count = count + 1
        break
      else:
        position = position + 1

if count != 0:
    print(N-count)
else:
    print(-1)

### FIXED CODE ###

a,b=map(int,input().split())
gcm=1
for i in range(1,1+min(a,b)):
  if a%i == 0 and b%i == 0:
    gcm = i
  else:
    gcm = gcm
    
print((a*b)//gcm)
"""
the condition is more straightforward than it looks.
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

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

from math import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = int(round(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(int(round(lcm_of_A/value)) for value in A)
    modulo_value = int(int(10e9)+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(intput())
    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))
N = int(input())
A = list(map(int, input().split(' ')))
rect_long = 0
rect_small = 0
while rect_long == 0:
    a_max = max(A)
    if A.count(a_max) >= 2:
        rect_long += a_max
    elif A.count(a_max) >= 4:
        rect_small += a_max
    A.remove(a_max)

while rect_small == 0:
    b_max = max(A)
    if A.count(b_max) >= 2:
        rect_small += b_max
    A.remove(b_max)

print(rect_long * rect_small)

### FIXED CODE ###

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

a = sorted(a, reverse=True)

count = 0
edge = []

i = 0
for _ in range(n-1):
    if a[i] == a[i+1]:
        count = count + 1
        edge.append(a[i])
        i = i + 1
        if count == 2:
            break
    i = i + 1

s = edge[0]*edge[1] if count == 2 else 0
print(s)
import math
from functools import reduce

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

n, *spot = map(int, open(0).read().split())
spot.sort()
dist = set([spot[i+1]-spot[i] for i in range(n)])
print(gcd_list(dist))

### FIXED CODE ###

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n, *spot = map(int, open(0).read().split())
spot.sort()
dist = set([spot[i+1]-spot[i] for i in range(n)])
print(gcd_list(dist))
N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())

j=int(0)
manzoku=int(0)
while j<N:
    manzoku += B[j]
    j += 1
    if A[0]=1:
        manzoku += sum(C)
    else:
        manzoku += sum(C) - C[A[0]]

print(manzoku)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i = 1
manzoku = sum(B)
while N>i:
    if A[i]-A[i-1] == 1:
      j = A[i-1]
      manzoku += C[j-1]
    i += 1
print(manzoku)
import math
a,b,k=(int(x) for x in input().split())
g=math.gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

### FIXED CODE ###

def gcd(t):
    b,a=sorted(t)
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m
a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
for i in range(g+1)[::-1]:
    if i==0:
        break
    if g%i==0:
        cd.append(i)
print(cd[k-1])
n=int(input())
for i in range(n/4):
    for j in range(n/7):
        if(i*4+j*7==n):
            flag=True

if(flag==True):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n=int(input())
flag=False
for i in range(int(n/4)+1):
    for j in range(int(n/7)+1):
        if(i*4+j*7==n):
            flag=True

if(flag==True):
    print("Yes")
else:
    print("No")