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

que=[1,2,3,4,5,6,7,8,9]
k=int(input())
for i in range(k-1):
  q=que.pop(0)
  #print("q",q)
  m=q%10
  #print("m",m,"que",que)
  if m==0:
    que.append(q*10)
    que.append(q*10+1)
  elif m==9:
    que.append(q*10+8)
    que.append(q*10+9)
  else:
    que.append(q*10+m-1)
    que.append(q*10+m)
    que.append(q*10+m+1)
print(que[0])

### FIXED CODE ###

from collections import deque
que=deque([1,2,3,4,5,6,7,8,9])
k=int(input())
for i in range(k-1):
  q=que.popleft()
  #print("q",q)
  m=q%10
  #print("m",m,"que",que)
  if m==0:
    que.append(q*10)
    que.append(q*10+1)
  elif m==9:
    que.append(q*10+8)
    que.append(q*10+9)
  else:
    que.append(q*10+m-1)
    que.append(q*10+m)
    que.append(q*10+m+1)
print(que[0])
### BUGGY CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, maxint


def main():
    num = int(stdin.readline())

    L = []
    for _ in xrange(num):
        it = iter(int(s) for s in stdin.readline().split()[1:])
        L.append([(next(it), next(it)) for _ in xrange(next(it))])

    weight = [maxint] * num
    weight[0] = 0
    V = set(xrange(1, num))
    index = 0

    def compare(i):
        return weight[i]

    while V:
        for v, cost in L[index]:
            if v not in V:
                continue
            weight[v] = min(weight[v], cost + weight[index])

        index = min(V, key=compare)
        V.remove(index)

    for i, d in enumerate(weight):
        print(i, d)


main()

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, maxsize


def main():
    num = int(stdin.readline())

    edges = []
    for _ in range(num):
        ns = [int(s) for s in stdin.readline().split()]
        for i in range(ns[1]):
            edges.append((ns[0], ns[2*i+2], ns[2*i+3]))

    dis = [maxsize] * num
    dis[0] = 0

    while 1:
        update = False
        for from_, to, cost in edges:
            if dis[from_] < maxsize and dis[to] > cost + dis[from_]:
                dis[to] = cost + dis[from_]
                update = True

        if not update:
            break

    for i, d in enumerate(dis):
        print(i, d)


main()
### BUGGY CODE ###

from math import gcd
q = int(input())
mod = 10**9+7
for _ in range(q):
    x, y = sorted(map(int, input().split()))

    ma = 0
    i, j = 1, 1
    while j <= x and i+j <= y:
        i, j = j, i+j
        ma += 1
    if x == 1 or y<=2:
        print(1, x*y % mod)
    else:
        ans = 0
        if x >= i:
            ans += max(0, (y-j) // i+1)
        if y >= i:
            ans += max(0, (x-j) // i+1)
        i, j = 1, 1
        for c in range(ma-1):
            k, l = j, i+j*2
            if gcd(k, l) == 1:
                for _ in range(ma-c-1):
                    k, l = l, k+l
                if x >= k:
                    ans += max(0, (y-l) // k+1)
                if y >= k:
                    ans += max(0, (x-l) // k+1)
            i, j = j, i+j
        print(ma, ans % mod)


### FIXED CODE ###

from math import gcd
q = int(input())
mod = 10**9+7
tan = 100
tab = [[[0]*2 for _ in range(tan)] for _ in range(tan)]

for _ in range(q):
    x, y = sorted(map(int, input().split()))

    ma = 0
    i, j = 1, 1
    while j <= x and i+j <= y:
        i, j = j, i+j
        ma += 1
    if x == 1 or y <= 2:
        print(1, x*y % mod)
    else:
        ans = 0
        if x >= i:
            ans += max(0, (y-j) // i+1)
        if y >= i:
            ans += max(0, (x-j) // i+1)
        i, j = 1, 1
        for c in range(ma-1):
            k, l = j, i+j*2
            for _ in range(ma-c-1):
                k, l = l, k+l
            if x >= k:
                ans += max(0, (y-l) // k+1)
            if y >= k:
                ans += max(0, (x-l) // k+1)
            i, j = j, i+j
        print(ma, ans % mod)
### BUGGY CODE ###

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

S = [s for s in str(input())]

ans = 0


for i in range(len(S)):
    if i == 0:
        continue

    if S[i] == S[i-1]:
        if S[i] == "0":
            del S[i]
            S.insert(i, "1")
        else:
            del S[i]
            S.insert(i, "0")
        ans += 1

print(ans)


### FIXED CODE ###

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

S = str(input())
ans = 0
if len(S)==1:
    print(0)
    exit()
elif S=="00" or S=="11":
    print(1)
    exit()

flg = True
if S[0]=="0":
    for i in range(len(S)):
        if i == 0:
            continue
        if i%2 == 0:
            if S[i]!="0":
                ans+=1
                continue
        else:
            if S[i]!="1":
                ans+=1
                continue
else:
    for i in range(len(S)):
        if i == 0:
            continue
        if i%2 == 0:
            if S[i]!="1":
                ans+=1
                continue
        else:
            if S[i]!="0":
                ans+=1
                continue
print(ans)
### BUGGY CODE ###

k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math 

def gcds(l):
    res=0
    for val in l:
        res=math.gcd(res,val)
    return res
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans+=gcds([i,j,m])
print(ans)


### FIXED CODE ###

k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math 

def gcds(l):
    res=0
    for val in l:
        res=math.gcd(res,val)
    return res
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans+=gcds([i,j,m])
print(ans)
### BUGGY CODE ###

N = input()
N = int(N)

A = input().split()
for i in range(1, N+1):
    print(A.index(str(i))+1, end=" ")


### FIXED CODE ###

N = input()
N = int(N)
ans = [0]*N
A = input().split()

for i in range(N):
    ans[int(A[i])-1] = i+1

for i in ans:
    print(i, end=" ")
### BUGGY CODE ###

import itertools
s = input()
t = input()
s2=list(itertools.permutations(s))
t2 = list(itertools.permutations(t))
s3 = [''.join(x) for x in s2]
t3 = [''.join(x) for x in t2]
for s in s3:
    for t in t3:
        if s<t:
            print('Yes')
            exit()
else:
    print('No')

### FIXED CODE ###

s = list(input())
t = list(input())
s.sort()
s2 = ''.join(s)
t.sort(reverse=True)
t2=''.join(t)
print('Yes') if s2<t2 else print('No')
### BUGGY CODE ###

n, m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]

MOD = 10**9 + 7
res = [0] * (n+1)
res[0] = 1
res[1] = 1 if 1 not in a else 0

for i in range(2, n+1):
    if i in a:
        continue

    # 到達不可能
    if res[i-1] == 0 and res[i-2] == 0:
        break

    res[i] = (res[i-1] % MOD + res[i-2] % MOD) % MOD

print(res[-1])


### FIXED CODE ###

n, m = list(map(int, input().split()))
a = [0] * (n+1)
for _ in range(m):
    a[int(input())] = -1

MOD = 10**9 + 7
res = [0] * (n+1)
res[0] = 1
res[1] = 0 if a[1] == -1 else 1

for i in range(2, n+1):
    if a[i] == -1:
        continue

    # 到達不可能
    if res[i-1] == 0 and res[i-2] == 0:
        break

    res[i] = (res[i-1] + res[i-2]) % MOD

print(res[-1])
### BUGGY CODE ###

from scipy.sparse import*
from itertools import permutations as pm

n,m,h = map(int,input().split())
r = [int(i) for i in input().split()]

A = lil_matrix((n+1,n+1))
for i in range(m):
  u,v,l = map(int,input().split())
  A[u,v] = l

A=csgraph.shortest_path(A,method='D',directed=False)

s=min(sum([A[i][j] for i,j in zip(a[:-1],a[1:])]) for a in pm(r))
print(int(s))

### FIXED CODE ###

from scipy.sparse import*
from itertools import permutations as pm

n,m,h = map(int,input().split())
r = [int(i) for i in input().split()]

u,v,l = zip(*[map(int,input().split()) for i in range(m)])

A=csgraph.dijkstra(csr_matrix((l,(u,v)),(n+1,n+1)),0)

s=min(sum(A[i][j] for i,j in zip(a[:-1],a[1:])) for a in pm(r))
print(int(s))
### BUGGY CODE ###

import sys

import numpy as np

readline = sys.stdin.buffer.readline


# 同じ数値が複数あるとおかしくなる
def binary_search(A, n):
    n -= 1
    left = 0
    right = len(A)-1

    if n < A[0]:
        return -1
    else:
        while left < right:
            # if right - left == 1:
            #     break

            mid = (left + right) // 2
            if A[mid] < n:
                left = mid + 1
            elif n < A[mid]:
                right = mid - 1
            else:
                right = mid
                break

        if A[right] > n:
            while A[right] > n:
                right -= 1
        elif A[right] == n:
            while right < len(A)-1 and A[right] == A[right+1]:
                right += 1

        return right



def main():
    N = int(readline())
    A = np.array(list(map(int, readline().split())))
    B = np.array(list(map(int, readline().split())))
    C = np.array(list(map(int, readline().split())))

    A, B, C = np.sort(A), np.sort(B), np.sort(C)

    aa = np.zeros([N], dtype=np.int32)
    for i, b in enumerate(B):
        aa[i] = binary_search(A, b) + 1

    bb = np.cumsum(aa)

    cnt = 0
    for i, c in enumerate(C):
        m = binary_search(B, c)
        if m != -1:
            cnt += bb[m]

    print(cnt)


main()


### FIXED CODE ###

import sys

readline = sys.stdin.buffer.readline


def binary_search(A, n, p):
    if p == "+":
        n += 0.5
    else:
        n -= 0.5

    left = 0
    right = len(A) - 1

    if n < A[0]:
        return 0
    else:
        while left <= right:
            mid = (left + right) // 2
            if A[mid] < n:
                left = mid + 1
            else:
                right = mid - 1

        return left


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A, B, C = sorted(A), sorted(B), sorted(C)

    cnt = 0
    for i, b in enumerate(B):
        ab = binary_search(A, b, "-")
        bc = N - binary_search(C, b, "+")
        cnt += ab * bc

    print(cnt)


main()
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
ans = A[0]
if ans == 0:
    print(ans)
    exit()
else:
    for i in range(1,N):
        ans = ans * A[i]
    if ans > 10**18:
        ans = -1
    print(ans)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
ans = A[0]
if ans == 0:
    print(ans)
    exit()
else:
    for i in range(1,N):
        ans = ans * A[i]
        if ans > 10**18:
            ans = -1
            break
    print(ans)
### BUGGY CODE ###

n = int(input())
a = [0 for i in range(1000000000)]
for i in range(n):
    a[int(input()) + 1] += 1
ans = 0
for i in a:
    if i%2 == 1:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = {}
for i in range(n):
    b = int(input())
    if b in a.keys():
        a[b] += 1
    else:
        a[b] = 1
ans = 0
for i in a.keys():
    if a[i]%2 == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
AB = (tuple(map(int, input().split())) for _ in range(N))

# 各商品の価格のビットが立っている位置を事前に見とく
bit = []
for a, b in AB:
    tmp = set()
    for i in range(31):
        if a & 1:
            tmp.add(i)
        a //= 2
    bit.append((tmp, b))

def cost(S):
    res = 0
    for T, b in bit:
        if S.issuperset(T):
            res += b
    return res

# Kのビットが立っている位置を調べる
Kbit = set()
Ktmp = K
for i in range(31):
    if Ktmp & 1:
        Kbit.add(i)
    Ktmp //= 2

ans = cost(Kbit)
for i in Kbit:
    T = Kbit.copy()
    T -= {i}            #位置iのビットを0にする
    T |= set(range(i))  #i未満のビットを全部1にする
    ans = max(ans, cost(T))

print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
AB = (tuple(map(int, input().split())) for _ in range(N))

# 各商品の価格のビットが立っている位置を事前に見とく
bit = []
for a, b in AB:
    tmp = set()
    for i in range(31):
        if a & 1:
            tmp.add(i)
        a //= 2
    bit.append((tmp, b))

def cost(S):
    res = 0
    for T, b in bit:
        if S.issuperset(T):
            res += b
    return res

# Kのビットが立っている位置を調べる
Kbit = set()
Ktmp = K
for i in range(31):
    if Ktmp & 1:
        Kbit.add(i)
    Ktmp //= 2

ans = cost(Kbit)
for i in Kbit:
    T = Kbit.copy()
    T -= {i}            #位置iのビットを0にする
    T |= set(range(i))  #i未満のビットを全部1にする
    ans = max(ans, cost(T))

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


import sys
sys.setrecursionlimit(10**7)
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

branch = [[] for _ in range(N)]
for i in range(N-1):
    branch[ab[i][0]-1].append(ab[i][1]-1)
    branch[ab[i][1]-1].append(ab[i][0]-1)

counters = [0 for _ in range(N)]
for i in range(Q):
    counters[px[i][0]-1] += px[i][1]

results = [0 for _ in range(N)]

def repeat(node, counter, pre_node):
    counter = counter + counters[node]
    results[node] = counter
    candidates = branch[node]
    for candidate in candidates:
        if candidate != pre_node:
            repeat(candidate, counter, node)

repeat(0, 0, 0)

print((" ").join([str(i) for i in results]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

branch = [[] for _ in range(N)]
for i in range(N-1):
    branch[ab[i][0]-1].append(ab[i][1]-1)
    branch[ab[i][1]-1].append(ab[i][0]-1)

counters = [0 for _ in range(N)]
for i in range(Q):
    counters[px[i][0]-1] += px[i][1]
results = [0 for _ in range(N)]

seen = [False for _ in range(N)]
from collections import deque
seen[0] = True
todo = deque([0])
results[0] = counters[0]

while len(todo)>0:
    checking = todo.pop()
    candidates = branch[checking]
    for candidate in candidates:
        if seen[candidate] == False:
            todo.append(candidate)
            seen[candidate] = True
            results[candidate] = results[checking]+counters[candidate]


print((" ").join([str(i) for i in results]))
### BUGGY CODE ###

import sys
from heapq import heappush, heappop


def main():
    # n, x, y = 7, 3, 7
    n, x, y = [int(s) for s in sys.stdin.readline().strip().split()]
    score = {i: 0 for i in range(1, n)}
    total_pair = set()

    def bfs(start):
        seen = set()
        heap = [(0, start)]
        while heap:
            dist, cur = heappop(heap)
            pair = (min(start, cur), max(start, cur))
            if pair in seen:
                continue
            seen.add(pair)
            if dist > 0:
                if pair not in total_pair:
                    score[dist] += 1
                    total_pair.add(pair)

            if cur < n-1:
                heappush(heap, (dist+1, cur+1))
            if cur > 0:
                heappush(heap, (dist+1, cur-1))
            if cur == x-1:
                heappush(heap, (dist+1, y-1))
            if cur == y-1:
                heappush(heap, (dist+1, x-1))

    for i in range(n-1):
        bfs(i)
    for i in range(1, n):
        print(score[i])

main()


### FIXED CODE ###

import sys

def main():
    n, x, y = [int(s) for s in sys.stdin.readline().strip().split()]
    x1 = x-1
    y1 = y-1

    score = {i:0 for i in range(n)}

    for i in range(n-1):
        for j in range(i+1, n):
            diff = j - i
            cand = abs(x1 - i) + 1 + abs(y1 - j)
            cand2 = abs(y1 - i) + 1 + abs(x1 - j)
            result = min(diff, cand, cand2)
            score[result] += 1

    for i in range(1, n):
        print(score[i])

main()
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(N - K + 1):
  ans = max(sum(P[i:i + K]), ans)
print((ans + K) / 2)

### FIXED CODE ###

from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)
### BUGGY CODE ###

s = input()
ans = 0
while "ABC" in s:
	ans += s.count("ABC")
	s = s.replace("ABC", "BCA")
print(ans)


### FIXED CODE ###

s = input()
ans = 0
s = s.replace("BC", "D")
cnt = 0
for i in range(len(s)):
	if s[i] == "A":
		cnt += 1
	elif s[i] == "D":
		ans += cnt
	else:
		cnt = 0
print(ans)
### BUGGY CODE ###

import math

def cf(x1,x2):
    cf=[]
    cf = [i for i in range(1,min(x1,x2)+1) if x1 % i == 0 and x2 % i == 0 and is_prime(i)]
    return cf

def is_prime(q):
    q = abs(q)
    if q == 1: return True
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

A, B = map(int, input().split())
lst = len(cf(A,B))

print(lst)

### FIXED CODE ###

import math

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

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

A, B = map(int, input().split())
AY = make_divisors(A)
BY = make_divisors(B)
AB = set(AY) & set(BY)
AB = list(AB)
cnt = [i for i in range(len(AB)) if is_prime(AB[i])]
print(len(cnt))
### BUGGY CODE ###

import copy
import numpy as np
h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
l,r,u,d,S = [[0]*w for _ in range(h)],[[0]*w for _ in range(h)],[[0]*w for _ in range(h)],[[0]*w for _ in range(h)],[[0]*w for _ in range(h)]
for i in range(h):
  if s[i][0] == ".":
    l[i][0] = 1
  for j in range(1,w):
    if s[i][j] == ".":
      l[i][j] = l[i][j-1] + 1
#print(l)
for i in range(h):
  if s[i][w-1] == ".":
    r[i][w-1] = 1
  for j in range(w-2,-1,-1):
    if s[i][j] == ".":
      r[i][j] = r[i][j+1] + 1
#print(r)
for i in range(w):
  if s[0][i] == ".":
    u[0][i] = 1
  for j in range(1,h):
    if s[j][i] == ".":
      u[j][i] = u[j-1][i] + 1
#print(u)
for i in range(w):
  if s[h-1][i] == ".":
    d[h-1][i] = 1
  for j in range(h-2,-1,-1):
    if s[j][i] == ".":
      d[j][i] = d[j+1][i] + 1

for i in range(h):
  for j in range(w):
    S[i][j] = max(0,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)

print(np.amax(S))

### FIXED CODE ###

import numpy as np
h,w = map(int,input().split())
s = np.array([[1 if i == "." else 0 for i in input()] for j in range(h)])
l,r,u,d = np.zeros((h,w)),np.zeros((h,w)),np.zeros((h,w)),np.zeros((h,w))
for i in range(h):
  u[i] = (u[i-1]+1)*s[i]
  d[-i-1] = (d[-i]+1)*s[-i-1]
for i in range(w):
  l[:,i] = (l[:,i-1]+1)*s[:,i]
  r[:,-i-1] = (r[:,-i]+1)*s[:,-i-1]
print(int(np.max(l+r+u+d))-3)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] < l[j] + l[k] and l[j] < l[k] + l[i] and l[k] < l[i] + l[j]:
                ans+=1

print(ans)

### FIXED CODE ###

import bisect

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

l.sort()
ans=0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        c=bisect.bisect_right(l,l[i]-l[j])
        #print(l[i],l[j],i,j,c)
        if j-c > 0:
            ans+=(j-c)
            
print(ans)
### BUGGY CODE ###

n, ww = map(int, input().split())

dp = [0]*(ww+1)

for i in range(n):
    w,v = map(int, input().split())
    for j in range(ww-w+1)[::-1]:
        if dp[j] or j==0:
            dp[j+w] = max(dp[j+w], dp[j]+v)
print(max(dp))

### FIXED CODE ###

import numpy as np

n, ww = map(int, input().split())

dp = np.zeros(ww+1)

for i in range(n):
    w,v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)

print(int(max(dp)))
### BUGGY CODE ###

N = int(input())
count =0
t = True
for i in range(1, 10):
    if  N % i == 0:
        A = N/i
        if 1 <= A <= 9:
            while(t): 
                for a in range(1, 10):
                    if a != i :
                        if A % a == 0:
                            print('Yes')
                            count += 1
                            t = False
                            break
if  count != 1:
    print('No')

### FIXED CODE ###

a = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i*j == a:
            print("Yes")
            exit()
print("No")
### BUGGY CODE ###

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

max_s = 0
for i in range(len(P)):
	sum_K = sum(P[0+i:K+i])
	if max_s < sum_K:
  		max_s = sum_K
print((max_s+K) / 2)

### FIXED CODE ###

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
s = [0] * 1000000
for i in range(N):
    s[i+1] = s[i] + A[i]

max_s = 0
for i in range(N):
    if max_s < s[i+K] - s[i]:
        max_s = s[i+K] - s[i]


print((max_s+K) / 2)
### BUGGY CODE ###

import heapq
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

#########################
n = int(input())
zahyo = []
for i in range(n):
    x,y = map(int,input().split())
    zahyo.append((x,y))
edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(n-1):
    for j in range(i+1,n):
        c = min(abs(zahyo[i][0]-zahyo[j][0]),abs(zahyo[i][1]-zahyo[j][1]))
        edge[j].append((c,i))
        edge[i].append((c,j))
print(prim_heap())

### FIXED CODE ###

import heapq
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

#########################
n = int(input())
zahyo = []
for i in range(n):
    x,y = map(int,input().split())
    zahyo.append((x,y,i))
xza = sorted(zahyo)
yza = sorted(zahyo,key=lambda x: x[1])
edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(n-1):
    c = abs(xza[i][0]-xza[i+1][0])
    edge[xza[i][2]].append((c,xza[i+1][2]))
    edge[xza[i+1][2]].append((c,xza[i][2]))
for i in range(n-1):
    c = abs(yza[i][1]-yza[i+1][1])
    edge[yza[i][2]].append((c,yza[i+1][2]))
    edge[yza[i+1][2]].append((c,yza[i][2]))
print(prim_heap())
### BUGGY CODE ###

from functools import reduce
from fractions import *

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

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

ans = 1
for i in range(len(A)):
    l = A.copy()
    l.pop(i)
    ans = max(ans,gcd_list(l))

print(ans)

### FIXED CODE ###

from fractions import gcd
import math
N = int(input())
A = list(map(int, input().split()))

gl = [0] * (N-1)
gr = [0] * (N-1)

gl[0] = A[0]
gr[0] = A[-1]
for i in range(1,N-1):
    gl[i] = gcd(gl[i-1],A[i])
    gr[i] = gcd(gr[i-1],A[-i-1])
#print(gl[i])
ans = max(gr[-1],gl[N-2])
for i in range(1,N-1):
    g = gcd(gl[i-1],gr[-i-1])
    ans = max(ans,g)
#print(gl,gr)
print(ans)
### BUGGY CODE ###

import collections
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a = a[::-1]
x,answer,num = collections.Counter(a),1,-1
for i in x.keys():
	if x[i] == 1:
		a.remove(i)
while a != []:
	if x[a[0]]>=4 and num==-1:
		answer = a[0]**2
		num = 1
		break
	elif x[a[0]]>=2:
		answer *= a[0]
		num += 1
		if num==1:
			break
	a = a[x[a[0]]:]
print(max(answer*num,0))

### FIXED CODE ###

import collections
n = int(input())
a = [int(i) for i in input().split()]
x,y,z = collections.Counter(a),[0],[0,0]
for i in x.keys():
	if x[i]>=4:
		y.append(i)
	if x[i]>=2:
		z.append(i)
y,z = sorted(y),sorted(z)
print(max(y[-1]**2,z[-1]*z[-2]))