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

n = int(input())
a = list(map(int,input().split()))
count = []
b = len(a)
if b >= n:
	for i in range(0,n):
		counter = 0
		for k in range(0,n):
			if (a[i] - 1) <= a[k] <= (a[i] + 1):
				counter += 1
		count.append(counter)
else:
	for i in range(0,b-1):
		counter = 0
		for k in range(0,b-1):
			if (a[i] - 1) <= a[k] <= (a[i] + 1):
				counter += 1
		count.append(counter)
	
mx = max(count)
print('{0}'.format(mx))

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int,input().split()))
count = collections.Counter(a)
max = 0
for i in count:
    if count[i] + count[i-1] + count[i+1] > max:
        max = count[i] + count[i-1] + count[i+1]
print(max)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
v = []
now = 0
for i in range(K):
  p = A[now]
  now = p-1
  if p in v:
    j = v.index(p)
    df = i-j
    Kn = (K-i-1) % df
    p = v[j+Kn]
    break
  else:
  	v.append(p)
print(p)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
v = []
w = {}
now = 0
for i in range(K):
  p = A[now]
  now = p-1
  if p in w:
    j = v.index(p)
    df = i-j
    Kn = (K-i-1) % df
    p = v[j+Kn]
    break
  else:
    v.append(p)
    w[p] = p
print(p)
### BUGGY CODE ###

import bisect
def justM(x,N):
    sum_=0
    for i in range(N):
        b=bisect.bisect_left(A,x-A[i])
        sum_+=N-b
    return sum_

N,M=map(int,input().split())
A=sorted(map(int,input().split()))
left,right=-1,10**20
while(right-left>1):
    mid=(right+left)//2
    s=justM(mid,N)
    if s<M:
        right=mid
    else:
        left=mid
D=left
r=[0]*(N+1)
ans=0
for i in range(N):
    r[i+1]=r[i]+A[i]
cnt=0
for i in range(N):
    b=bisect.bisect_left(A,D-A[i])
    ans+=A[i]*(N-b)
    cnt+=N-b
    ans+=r[N]-r[b]
print(ans-D*(cnt-M))


### FIXED CODE ###

import bisect
def justM(x,N):
    sum_=0
    for i in range(N):
        b=bisect.bisect_left(A,x-A[i])
        sum_+=N-b
    return sum_

N,M=map(int,input().split())
A=sorted(map(int,input().split()))
left,right=-1,(10**5)*2+1
while(right-left>1):
    mid=(right+left)//2
    s=justM(mid,N)
    if s<M:
        right=mid
    else:
        left=mid
D=left
r=[0]*(N+1)
ans=0
for i in range(N):
    r[i+1]=r[i]+A[i]
cnt=0
for i in range(N):
    b=bisect.bisect_left(A,D-A[i])
    ans+=A[i]*(N-b)+(r[N]-r[b])
    cnt+=N-b
print(ans-D*(cnt-M))
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
ans = []

for i in range(n):
  ans.append(li[i])
  ans = list(reversed(ans))
for i in range(n):
  print(ans[i],end=" ")

### FIXED CODE ###

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

liodd = li[::2]
lieven = li[1::2]
if len(lieven) == len(liodd):
  for i in reversed(lieven):
    print(i,end=" ")
  for i in liodd:
    print(i,end=" ")
else:
  for i in reversed(liodd):
    print(i,end=" ")
  for i in lieven:
    print(i,end=" ")
### BUGGY CODE ###

n,m = map(int, input().split())
heights = list(map(int, input().split()))
roads = list()
for _ in range(m):
  road = list(map(int, input().split()))
  roads.append(road)

sum = 0
for i in range(n):
  tallest = True
  for road in roads:
    if i+1 in road:
      if road.index(i+1) == 0:
        to = road[1]
      else:
        to = road[0]
      if heights[i] <= heights[to-1]:
        tallest = False
        break
  if tallest:
    sum += 1

print(sum)


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

  roads = [tuple(map(int, input().split())) for _ in range(m)]
  max_heights = [0 for _ in range(n)]

  for i in range(m):
    build_1 = roads[i][0]-1
    build_2 = roads[i][1]-1
    if heights[build_2] > max_heights[build_1]:
      max_heights[build_1] = heights[build_2]
    if heights[build_1] > max_heights[build_2]:
      max_heights[build_2] = heights[build_1]

  sum = 0
  for i in range(n):
    if heights[i] > max_heights[i]:
      sum += 1
  print(sum)

if __name__ == '__main__':
  main()
### BUGGY CODE ###

from itertools import permutations

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

r = [0] * (2 * n)
g = [0] * (2 * n)
b = [0] * (2 * n)

for i in range(n):
    if s[i] == "R":
        r[i] = 1
    if s[i] == "G":
        g[i] = 1
    if s[i] == "B":
        b[i] = 1

ans = sum(r) * sum(g) * sum(b)

lst = [r, g, b]
for i in range(n - 1):
    for j in range(i + 1, n):
        k = 2 * j - i
        for x, y, z in permutations(lst, 3):
            if x[i] and y[j] and z[k]:
                ans -= 1
print(ans)

### FIXED CODE ###

from itertools import permutations

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

r = [0] * n
g = [0] * n
b = [0] * n

for i in range(n):
    if s[i] == "R":
        r[i] = 1
    if s[i] == "G":
        g[i] = 1
    if s[i] == "B":
        b[i] = 1

ans = sum(r) * sum(g) * sum(b)

lst = [r, g, b]
for i in range(n - 1):
    for j in range(i + 1, n):
        k = 2 * j - i
        if k >= n:
            continue
        for x, y, z in permutations(lst):
            if x[i] and y[j] and z[k]:
                ans -= 1
print(ans)
### BUGGY CODE ###

def solve(N, K, Xs):
    plus = sorted([x for x in Xs if x >= 0])
    minus = sorted([abs(x) for x in Xs if x < 0])
    ans = 10 ** 9
    for i in range(0, max(K, len(plus)) + 1):
        ps = plus[:i]
        ms = minus[:K - i]
        if len(ps) == K:
            ans = min(ans, ps[-1])
            continue
        if len(ms) == K:
            ans = min(ans, ms[-1])
            continue
        if len(ps) + len(ms) == K:
            p, m = ps[-1], ms[-1]
            ans = min(ans, p * 2 + m, m * 2 + p)

    return ans
  
if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    Xs = list(map(int, input().split(" ")))
    print(solve(N, K, Xs))


### FIXED CODE ###

def solve(N, K, Xs):
    plus = sorted([x for x in Xs if x >= 0])
    minus = sorted([abs(x) for x in Xs if x < 0])
    ans = 10 ** 9
    for i in range(0, K + 1):
        j = K - i
        if i <= len(plus) and i == K:
            p = plus[i-1]
            ans = min(ans, p)
        elif j <= len(minus) and j == K:
            m = minus[j-1]
            ans = min(ans, m)
        elif i <= len(plus) and j <= len(minus):
            p = plus[i - 1]
            m = minus[j - 1]
            ans = min(ans, p * 2 + m, m * 2 + p)

    return ans
  
if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    Xs = list(map(int, input().split(" ")))
    print(solve(N, K, Xs))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

H,N=map(int,input().split())
L=[]
for i in range(N):
    T=[0,0,0]
    T[1],T[2]=map(int,input().split())
    T[0]=T[2]/T[1]
    L.append(T)
L=sorted(L)
n=1+H//L[0][1]
m=n*L[0][2]

def DP(MAX,minN,minM,i,T,M):
    t=T
    m=M
    if(T>=MAX):
        return M
    if(T<MAX):
        t+=L[i][1]
        m+=L[i][2]
        if(m<minM):        
            tm=DP(MAX,minN,minM,i,t,m)
            if(minM>tm):
                minM=tm
    if(len(L)-1 > i):
        t=T
        m=M
        if(m<minM):
            tm=DP(MAX,minN,minM,i+1,t,m)
            if(minN>tm):
                minM=tm
    return minM

tm=DP(H,10**10,m,0,0,0)

print(tm)



### FIXED CODE ###

H,N=map(int,input().split())
L=[]
m=0
for i in range(N):
    T=[0,0]
    T[0],T[1]=map(int,input().split())
    L.append(T)
    m=max(m,T[0])
L=sorted(L,reverse=True)
L.insert(0,[0,0])
m+=1
DP=[[10**10 for i in range(H+1+m)] for j in range(N+1)]
DP[0][0]=0

for i in range(1,N+1):
    t=0
    DP[i][0]=0
    for j in range(H+1):
        DP[i][j]=min(DP[i][j],DP[i-1][j])
        t=min(DP[i][j],DP[i-1][j])+L[i][1]
        DP[i][j+L[i][0]]=min(DP[i][j+L[i][0]],t)
    DP[i][H]=min(DP[i][H:-1])
print(min(DP[N][H:-1]))
### BUGGY CODE ###

#https://atcoder.jp/contests/abc125/tasks/abc125_c



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

i=2
b=[1]#a=0
c=[1]
d=[]
while True:
    a = 0
    for j in range(N):
        if A[j] % i != 0:
            a += 1
        if a > 1:
            d.append(i) #black list
            break

    #print(i,A,a)

    if a == 0:
        b.append(i) #white list
        for j in range(len(A)):
            A[j] = int(A[j] / i)
        i = 2
    if a == 1:
        c.append(i) #gray list
    if a > 0:
        i += 1
    
    k=0
    while True:
        if k >= len(d):
            break
        if i % d[k] == 0:
            i += 1
            k = -1
        k += 1


    if i > min(A):
        break

bs = 1
for i in range(len(b)):
    bs *= b[i]
print(bs * max(c))


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
arr1 = [0 for _ in range(n)]
arr2 = [0 for _ in range(n)]
arr1[0] = a[0]
arr2[-1] = a[-1]
for i in range(1, n):
    arr1[i] = gcd(arr1[i - 1], a[i])
for i in reversed(range(n - 1)):
    arr2[i] = gcd(arr2[i + 1], a[i])
ans = arr1[-1]
for i in range(n): #delete a[i]
    if 0 < i < n - 1:
        ans = max(ans, gcd(arr1[i - 1], arr2[i + 1]))
    elif i == 0:
        ans = max(ans, arr2[1])
    elif i == n - 1:
        ans = max(ans, arr1[n - 2])
print(ans)
### BUGGY CODE ###

n,q=list(map(int,input().split()))
s=input()
cnt=0
t=[0]*n

for i in range(n-2):
  t[i]=s[i:i+2].count("AC")
#print(t)

for i in range(q):
  n,q=list(map(int,input().split()))
  print(sum(t[n-1:q-1]))
  

### FIXED CODE ###

n,q=list(map(int,input().split()))
s=input()
cnt=0
t=[0]*n

for i in range(n-1):
  cnt+=s[i:i+2].count("AC")
  t[i+1]=cnt
##  t[-1]=cnt
##print(t)

for i in range(q):
  l,r=list(map(int,input().split()))
  print(t[r-1]-t[l-1])
### BUGGY CODE ###

import sys
import os
import math

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # input()
    A,B,N=map(int, input().split())

    max=0.0
    for x in range(N+1):
        # ans=int(A*x/B)-A*int(x/B)
        min,_=math.modf(x/B)
        # ans=int(A*min)
        if min > max:
            max=min
        elif min < max:
            break

    print(int(max*A))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
   # file_input()
    # input()
    A,B,N=map(int, input().split())

    max=0
    # for x in range(N+1):
    #     # ans=int(A*x/B)-A*int(x/B)
    #     min,_=math.modf(x/B)
    #     # ans=int(A*min)
    #     # print(min)
    #     if x==0:
    #         max=min
    #     elif min > max:
    #         max=min
    #     else:
    #         break

    # max=0
    # max_x=0
    # first=0
    #
    # for x in range(N+1):
    #     rem = x%B
    #     if x == 0:
    #         first=rem
    #     elif rem == first:
    #         break
    #     if rem > max:
    #         max=rem
    #         max_x=x

    if N<B:
        max_x=N
    else:
        max_x=B-1

    # min,_=math.modf(max_x/B)

    print(int(A*max_x/B)-A*int(max_x/B))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

from heapq import heappush, heappop, heapify

def main():
    n, m = map(int, input().split())
    edges = [[] for _ in range(n)]
    isRoot = [True] * n
    for _ in range(n - 1 + m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append(b)
        isRoot[b] = False

    for i in range(n):
        if isRoot[i]:
            root = i
            break
    INF = 10 ** 20
    stack = [(0, root, -1)]
    heapify(stack)
    height = [-INF] * n
    parent = [None] * n
    def search(stack):
        score, node, par = stack.pop()
        if -score > height[node]:
            height[node] = -score
            parent[node] = par
            for to in edges[node]:
                heappush(stack,(score - 1, to, node))

    while stack:
        search(stack)

    for i in range(n):
        print(parent[i] + 1)

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
revEdges = [[] for _ in range(n)]
for _ in range(n - 1 + m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    revEdges[b].append(a)

visited = [False] * n
lst = []
def search(x):
    if not visited[x]:
        visited[x] = True
        for to in edges[x]:
            search(to)
        lst.append(x)

for i in range(n):
    search(i)
lst.reverse()
dic = {}
for i in range(n):
    dic[lst[i]] = i

parent = [-1] * n
for i in lst:
    if not revEdges[i]:
        continue
    maxScore = -1
    index = -1
    for fr in revEdges[i]:
        if maxScore <= dic[fr]:
            maxScore = dic[fr]
            index = fr
    parent[i] = index

for i in range(n):
    print(parent[i] + 1)
### BUGGY CODE ###

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

ans = [0]*(N+1)

for i in range(1,N+1):
    ans[i] = A.count(i)
    print(ans[i])


### FIXED CODE ###

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

import collections
c = collections.Counter(A)

for i in range(1,N+1):
    print(c[i])
### BUGGY CODE ###

import numpy as np
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p = np.array(p)

ans = n - k + 1
no_change = False
for j in range(k-1):
    if p[j] > p[j+1]:
        break
else:
    no_change = True


for i in range(n-k):
    dec = False
    q = p[i:i+k+1]
    if (q.argmin()==0 and q.argmax()==k):
        ans -= 1
        dec = True
    for j in range(1,k):
        if q[j] > q[j+1]:
            break
    else:
        if no_change and not dec:
            ans -= 1
        no_change = True

print(ans)

### FIXED CODE ###

import numpy as np
import heapq

(n,k),p = [list(map(int, s.split())) for s in open(0)]

p_np = np.array(p)
p_cumsum = (p_np[1:]>p_np[:-1]).cumsum()

c = [False] * n

_min = p[:k].copy()
_max = [-x for x in p[:k]]
heapq.heapify(_min)
heapq.heapify(_max)

ans = n - k + 1
no_change = False
if p_cumsum[k-2]==k-1:
    no_change = True

for i in range(n-k):
    decrease = False
    
    heapq.heappush(_min, p[i+k])
    heapq.heappush(_max, -p[i+k])
    
    while c[_min[0]]:
        heapq.heappop(_min)
    while c[-_max[0]]:
        heapq.heappop(_max)
    
    if (_min[0]==p[i] and -_max[0]==p[i+k]):
        ans -= 1
        decrease = True
    
    c[p[i]] = True
    
    if p_cumsum[i]+k-1 == p_cumsum[i+k-1]:
        if no_change and not decrease:
            ans -= 1
        no_change = True

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

n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))
lo = 1
hi = 10**18
ans = max(arr)
while lo<=hi:
    t = 0
    m = (hi+lo)//2
    for i in range(n):
        if arr[i]>m:
            req = arr[i]//m
        else:
            req=  0
        t+=req
    if t<=k:
        ans = m
        hi = m-1
    else:
        lo = m+1
print(ans)

### FIXED CODE ###

n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))
lo = 1
hi = 10**12
ans = max(arr)
while lo<=hi:
    t = 0
    m = (hi+lo)//2
    for i in range(n):
        if arr[i]>m:
            req = arr[i]//m
        else:
            req=  0
        t+=req
    if t<=k:
        ans = m
        hi = m-1
    else:
        lo = m+1
print(ans)
### BUGGY CODE ###

N = int(input())
An = []
mul = 1

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

for i in An:
    mul *= i

if mul >10**18:
    print("-1")
else:
    print(mul)

### FIXED CODE ###

import sys
N = int(input())
An = []
mul = 1

An = list(map(int,input().split()))
if An.count(0) > 0:
    print("0")
    sys.exit()

for i in An:
    mul *= i
    if mul > 10**18:
        print("-1")
        sys.exit()

if mul <= 10**18:
    print(mul)
### BUGGY CODE ###

def main():
    from collections import Counter

    N = int(input())
    S = list(input())
    s_c = Counter(S)

    a = s_c["R"] * s_c["B"] * s_c["G"]

    for i in range(N):
        for j in range(i + 1, N):
            for _ in range(j + 1, N):
                if (S[i] != S[j] and S[i] != S[_] and S[j] != S[_]) and \
                    not (j - i != _ - j):
                    a -= 1
    print(a)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter

N = int(input())
S = list(input())
s_c = Counter(S)

a = s_c["R"] * s_c["B"] * s_c["G"]

for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            break
        elif (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and \
            not (j - i != k - j):
            a -= 1
print(a)
### BUGGY CODE ###

from heapq import heappush, heappop
from collections import deque

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

ans = 0

for i in range(K+1):
    sup = min(i,K)
    for l in range(sup+1):
        for r in range(sup+1-l):
            j = min(i-r-l,r+l)
            hq = []
            dq = deque(V)
            for _ in range(l):
                if dq:
                    item = dq.popleft()
                    heappush(hq, item)
            for _ in range(r):
                if dq:
                    item = dq.pop()
                    heappush(hq, item)
            for _ in range(j):
                if hq:
                    heappop(hq)
            res = sum(hq)
            ans = max(ans,res)

print(ans)

### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque

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

ans = 0

for i in range(K+1):
    sup = min(i,N)
    for l in range(sup+1):
        for r in range(sup+1-l):
            j = min(i-r-l,r+l)
            hq = []
            dq = deque(V)
            for _ in range(l):
                item = dq.popleft()
                heappush(hq, item)
            for _ in range(r):
                item = dq.pop()
                heappush(hq, item)
            for _ in range(j):
                heappop(hq)
            res = sum(hq)
            ans = max(ans,res)

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

n = int(input())
a = [input() for i in range(n)] 
ans =1
s = [a[0]]
 
for i in a[1:]:
    if not i in s:
        ans += 1
        s.append(i)
print(ans) 

### FIXED CODE ###

import collections
N=int(input())
S=[]
for i in range(N):
    S.append(input())
s=collections.Counter(S)
s_key=s.keys()
print(len(s_key))
### BUGGY CODE ###

from collections import defaultdict
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
dl = defaultdict(int)
dr = defaultdict(int)

for i in range(2**n):
    lr = ""
    rr = ""
    lb = ""
    rb = ""
    ii = i
    for j in range(n):
        if ii&1 == 1:
            lr += ls[j]
            rr += rs[j]
        else:
            lb += ls[j]
            rb += rs[j]
        ii >>= 1
    dl[(lr,lb)] += 1
    dr[(rr,rb)] += 1

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*dr[dlk]

print(ans)


### FIXED CODE ###

#https://atcoder.jp/contests/agc026/submissions/10971924を参考にした

from collections import defaultdict
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
d = defaultdict(int)

def full_research(sa,r,b,t):
    if t == n:
        d[(r,b)] += 1
        return
    full_research(sa,r+sa[t],b,t+1)
    full_research(sa,r,b+sa[t],t+1)

full_research(ls,"","",0)
dl = d
d = defaultdict(int)
full_research(rs,"","",0)

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*d[dlk]

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

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=lambda x:x[1])
A.sort()

n = 0
for i in range(M):
  b,c = BC[i][0], BC[i][1]
  for j in range(b):
    if n >= N: break
    if n == 0:
      if A[n] < c: 
        A[n] = c
        n += 1
    else:
      if A[n] < c: 
        A[n] = c
        n += 1
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=lambda x:x[1])
A.sort()

ans = []
for b,c in BC:
  n = len(ans)
  for i in range(b):
    if n >  N-1: break
    if A[n] < c:
      ans.append(c)
      n += 1
    else: break

print(sum(ans) + sum(A[len(ans):]))
### BUGGY CODE ###

K = int(input())

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

def gcdl(a,b,c):
    return gcd(gcd(a,b),c)

result = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            result += gcdl(a,b,c)

print(result)


### FIXED CODE ###

K = list(range(1,int(input())+1))

import itertools

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

result = 0


if len(K)>=3:
    for i in list(itertools.combinations(K,3)):
        result += gcd(gcd(i[0],i[1]),i[2])*6

if len(K)>=2:
    for i in list(itertools.combinations(K,2)):
        result += gcd(i[0],i[1])*6

for i in list(itertools.combinations(K,1)):
    result += i[0]

print(result)
### BUGGY CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())

edge = [[] for _ in range(N)]
counter = [0 for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

def dfs():
    global counter
    done = [True for _ in range(N)]
    stack = deque([])
    done[0] = False
    for e in edge[0]:
        stack.append([e, 0])
    while stack:
        s = stack.pop()
        if done[s[0]]:
            done[s[0]] = False
            counter[s[0]] += counter[s[1]]
            for n in edge[s[0]]:
                stack.append([n, s[0]])
                
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p - 1] += x
dfs()

[print(c, end=" ") for c in counter]

### FIXED CODE ###

N, Q = map(int, input().split())

edge = [[] for _ in range(N)]
counter = [0 for _ in range(N + 1)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

for _ in range(Q):
    p, x = map(int, input().split())
    counter[p - 1] += x

stack = [(0, -1)]
while stack:
    s, parent = stack.pop()
    counter[s] += counter[parent]
    for n in edge[s]:
        if n == parent:
            continue
        stack.append((n, s))

[print(c, end=" ") for c in counter[:N]]
### BUGGY CODE ###

n = int(input())
hs = input().split()

h = []
for s in hs:
    h.append(int(s))

for i in range(0,n):
    hi = h[i]
    for j in range(i,n):
        if hi - h[j] > 1:
            print("No")
            exit()

print("Yes")


### FIXED CODE ###

n = int(input())
hs = input().split()

h = []
for s in hs:
    h.append(int(s))

max = 0
for i in range(0,n):
    if max < h[i]:
        max = h[i]
    if max - h[i] > 1:
        print("No")
        exit()

print("Yes")
### BUGGY CODE ###

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

b = a[1]//a[0]

for i in range(b,-1,-1):
    if a[1] % i == 0:
        print(i)
        break

### FIXED CODE ###

import math
a = list(map(int,input().split()))

b = a[1]//a[0]

c = []

for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1] % i == 0 and i <= b:
        if a[1] // i <= b:
            c.append(a[1] // i)
        else:
            c.append(i)
c.sort()
c.reverse()
print(c[0])