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

a,b,c=map(int,input().split())
A=[a,b,c]
ans=0
if a%2==1 or b%2==1 or c%2==1:
  print(0)
  exit()
while a%2==0 and b%2==0 and c%2==0:
  a=(b+c)/2
  b=(sum(A)-A[1])/2
  c=(sum(A)-A[2])/2
  if [a,b,c]==A:
    print(-1)
    exit()
  ans+=1

print(ans)


### FIXED CODE ###

a,b,c=map(int,input().split())
for i in range(500000):
    if a%2==1 or b%2==1 or c%2==1:
        print(i);exit()
    
    else:
      p=(b+c)//2 ;q=(a+c)//2 ; r=(a+b)//2
      a=p ; b=q;c=r
else:
    print(-1)
### BUGGY CODE ###

n, s = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
W_MAX = s
dp = [0]*(W_MAX+1)
dp[0] = 1
inv_2 = pow(2, MOD-2, MOD)
for a in A:
    for j in reversed(range(W_MAX+1)):
        if W_MAX < j+a:
            continue
        dp[j+a] += dp[j]*inv_2
        dp[j+a] %= MOD

print(dp[-1]*pow(2, n, MOD) % MOD)

### FIXED CODE ###

n, s = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
W_MAX = s
dp = [0]*(W_MAX+1)
dp[0] = 1
inv_2 = pow(2, MOD-2, MOD)
for a in A:
    for j in reversed(range(W_MAX+1)):
        if W_MAX < j+a:
            continue
        dp[j+a] += dp[j]*inv_2
        dp[j+a] %= MOD

print(dp[-1]*pow(2, n, MOD) % MOD)
### BUGGY CODE ###

from operator import itemgetter
import collections
N = int(input())

X = list(map(int, input().split()))
d = {} 
for x in X:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
    
keys = sorted(d.keys(), reverse = True)

for x in X:
  idx = N//2
  d[x] -= 1
  for k in keys:
    idx -= d[k]
    if idx <= 0:
      print(k)
      break
  d[x] += 1

### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
SX = sorted(X)
m1,m2 = SX[N//2-1],SX[N//2]

for a in X:
    print(m2 if a <= m1 else m1)
### BUGGY CODE ###

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

for i in range(n):
    num = a.count((i+1))
    print(num)

### FIXED CODE ###

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

list_1 = collections.Counter(a)

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

# from scipy.special import comb
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
all = (2**n - 1)%mod

c = 1
m = 1
a = min(n-a, a)
for i in range(a):
    c = c*(n-i)%mod
    m = m*(i+1)%mod

nca = c*pow(m, mod-2, mod)%mod

c = 1
m = 1
a = min(n-b, b)
for i in range(b):
    c = c*(n-i)%mod
    m = m*(i+1)%mod

ncb = c*pow(m, mod-2, mod)%mod    

# nca = comb(n, a, exact=True)
# ncb = comb(n, b, exact=True)
all -= nca + ncb
print(all%mod)


### FIXED CODE ###

n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
all = pow(2, n, mod) - 1

def comb(n, r):
  c = 1
  m = 1
  r = min(n-r, r)
  for i in range(r):
    c = c * (n - i) % mod
    m = m * (i + 1) % mod
  return c * pow(m, mod-2, mod) % mod

nca = comb(n, a)
ncb = comb(n, b)
all -= nca + ncb
print(all%mod)
### BUGGY CODE ###

n,k=map(int,input().split())
p=[]
for i in range(n):
    x,y=map(int,input().split())
    p.append([x,y])
ret=10**25
for a in range(n):
    for b in range(n):
        for c in range(n):
            for d in range(n):
                l=min(p[a][0],p[b][0],p[c][0],p[d][0])
                r=max(p[a][0],p[b][0],p[c][0],p[d][0])
                u=min(p[a][1],p[b][1],p[c][1],p[d][1])
                t=max(p[a][1],p[b][1],p[c][1],p[d][1])
                cnt=0
                for i in range(n):
                    if l<=p[i][0]<=r and u<=p[i][1]<=t:
                        cnt+=1
                if cnt>=k:
                    ret=min(ret,(r-l)*(t-u))
print(ret)

### FIXED CODE ###

n,k=map(int,input().split())
p=[]
for i in range(n):
    x,y=map(int,input().split())
    p.append([x,y])
ret=10**25
for a in range(n):
    for b in range(a):
        r=max(p[a][0],p[b][0])
        l=min(p[a][0],p[b][0])
        for c in range(n):
            for d in range(c):
                u=min(p[c][1],p[d][1])
                t=max(p[c][1],p[d][1])
                cnt=0
                for i in range(n):
                    if l<=p[i][0]<=r and u<=p[i][1]<=t:
                        cnt+=1
                if cnt>=k:
                    ret=min(ret,(r-l)*(t-u))
print(ret)
### BUGGY CODE ###

n, K = map(int,input().split())
xarr = []
yarr = []
src = []
for _ in range(n):
    x, y = map(int,input().split())
    src.append([x,y])
    xarr.append(x)
    yarr.append(y)

xarr.sort()
yarr.sort()
ans = float('inf')
for i in range(n):
    for j in range(i + 1, n):
        for k in range(n):
            for l in range(k + 1, n):
                cnt = 0
                for m in range(n):
                    if src[m][0] >= xarr[i] and src[m][0] <= xarr[j] and src[m][1] >= yarr[k] and src[m][1] <= yarr[l]:
                        cnt += 1
                if cnt >= K:
                    ans = min((xarr[i]-xarr[j])*(yarr[k]-yarr[l]), ans)

print(ans)

### FIXED CODE ###

n, K = map(int,input().split())
xarr = []
yarr = []
src = []
for _ in range(n):
    x, y = map(int,input().split())
    src.append([x,y])
    xarr.append(x)
    yarr.append(y)

xarr.sort()
yarr.sort()
ans = float('inf')
for i in range(n):
    for j in range(i + 1, n):
        for k in range(n):
            for l in range(k + 1, n):
                cnt = 0
                for m in range(n):
                    if src[m][0] >= xarr[i] and src[m][0] <= xarr[j] and src[m][1] >= yarr[k] and src[m][1] <= yarr[l]:
                        cnt += 1
                if cnt >= K:
                    ans = min((xarr[i]-xarr[j])*(yarr[k]-yarr[l]), ans)

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

H,W = map(int,raw_input().split())
h = H/2
hh = H%2
w = W/2
ww = W%2

while True:
    if H == 0 and W == 0:
        break
    for i in range(h):
        print "#."* w + "#"* ww
        print ".#"* w + "."* ww
    if hh == 1:
        print "#."* w + "#"* ww
    print""


         

### FIXED CODE ###

while True:
    H,W = map(int,raw_input().split())
    if H == 0 and W == 0:
        break
    for i in range(0,H/2):
        print ("#."* (W/2) + "#"* (W%2))
        print (".#"* (W/2) + "."* (W%2))
    if H%2 == 1:
        print ("#."* (W/2) + "#"* (W%2))
    print""
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(min(a) - 1, max(a) + 2):
    total = 0
    for j in a:
        if j == i or j + 1 == i or j - 1 == i:
            total += 1
    ans = max(ans, total)
print(ans)

### FIXED CODE ###

import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
ans = 0
for i in range(min(a) - 1, max(a) + 2):
    ans = max(ans, ac[i - 1] + ac[i] + ac[i + 1])
print(ans)
### BUGGY CODE ###

import bisect
n = int(input())
s = input()
R,G,B = [],[],[]
for i in range(n):
    if s[i]=='R':
        R.append(i)
    elif s[i]=='G':
        G.append(i)
    else:
        B.append(i)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ci, cj = s[i], s[j]
        if ci==cj:
            continue
        ng = 2*j-i

        if (ci=='R' and cj=='B') or (ci=='B' and cj=='R'):
            ans += len(G)-bisect.bisect_left(G, j)
            if ng in G:
                ans -= 1
        elif (ci=='R' and cj=='G') or (ci=='G' and cj=='R'):
            ans += len(B)-bisect.bisect_left(B, j)
            if ng in B:
                ans -= 1
        else:
            ans += len(R)-bisect.bisect_left(R, j)
            if ng in R:
                ans -= 1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')
if ans==0:
    print(ans)
else:
    for i in range(n):
        for j in range(i+1, n):
            k=2*j-i
            if k<n:
                if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
                    ans -= 1
    print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
box=[]
A=list(map(int,input().split()))
for _ in range(M):
  b,c=map(int,input().split())
  for __ in range(b):
    A.append(c)
A.sort(reverse = True)
print(sum(A[:N]))


### FIXED CODE ###

N,M=map(int,input().split())
box=[]
A=list(map(int,input().split()))
for i in A:
  box.append((i,1))
for _ in range(M):
  b,c=map(int,input().split())
  box.append((c,b))
box = sorted(box, key=lambda x:x[0])
box.reverse()
ans=0
count=0
for i in range(0,10**5):
  ans+=(box[i][0]*box[i][1])
  count+=box[i][1]
  if count >N:
    ans-=((count-N)*box[i][0])
    break
print(ans)
### BUGGY CODE ###

n = int(input())
s = list(input() for _ in range(n))

l = list(set(s))

count = []
for i in l:
    count.append(s.count(i))


indexes = [i for i, x in enumerate(count) if x == max(count)]

ans = []
for i in indexes:
    ans.append(l[i])

ans.sort()

for i in ans:
    print(i)

### FIXED CODE ###

import collections

n = int(input())
s = list(input() for _ in range(n))

c = dict(collections.Counter(s))
m = max(c.values())
ans = [k for k, v in c.items() if v == m]

ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###

from operator import itemgetter
from heapq import heappush,heappop
N = int(input())
table=[]
for i in range(N):
    a,b = map(int,input().split())
    table.append([a,b,i])
A = sorted(table,key=itemgetter(0))
B = sorted(table,key=itemgetter(1))

graph=[]
for k in range(N):#距離、点
    graph.append([min(abs(A[k][0]-A[k-1][0]),abs( A[k][1]-A[k-1][1])),A[k][2],A[k-1][2]])
for k in range(N):
    graph.append([min(abs(B[k][0]-B[k-1][0]),abs( B[k][1]-B[k-1][1])),B[k][2],B[k-1][2]])

class Unionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)

    def find(self,x):#親を探す xの親を示す
        if self.par[x] ==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self,x,y):#x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
        else:
            self.par[py]=px
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
#クラスカル法
kei = Unionfindtree(N)
graph.sort()
dist =0
for d,i,j in graph:
    if not kei.connect(i,j):
        kei.union(i,j)
        dist +=d
print(dist)

### FIXED CODE ###

from operator import itemgetter
from heapq import heappush,heappop
N = int(input())
table=[]
for i in range(N):
    a,b = map(int,input().split())
    table.append([a,b,i])
A = sorted(table,key=itemgetter(0))
B = sorted(table,key=itemgetter(1))

graph=[]
for k in range(N):#距離、点
    graph.append([min(abs(A[k][0]-A[k-1][0]),abs( A[k][1]-A[k-1][1])),A[k][2],A[k-1][2]])
for k in range(N):
    graph.append([min(abs(B[k][0]-B[k-1][0]),abs( B[k][1]-B[k-1][1])),B[k][2],B[k-1][2]])

class Unionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)

    def find(self,x):#親を探す xの親を示す
        if self.par[x] ==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self,x,y):#x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
        else:
            self.par[py]=px
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
#クラスカル法
kei = Unionfindtree(N)
graph.sort()
dist =0
for d,i,j in graph:
    if not kei.connect(i,j):
        kei.union(i,j)
        dist +=d
print(dist)
### BUGGY CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
    dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i))
print(dp[N-1])

### FIXED CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
    dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i))
print(dp[N-1])
### BUGGY CODE ###

H, W = list(map(int, input().split()))
 
start = []
c = []
for y in range(H):
    c.append(input())
    for x in range(W):
        if c[-1][x]=='#':
            start.append([y,x])
            
visited = [0 for _ in range(W*H)]
for one in start:
    visited[one[0]*W+one[1]] = 1
    
cnt = 0
while sum(visited)!=W*H:
    tmp_s = []
    for one in start:
        cy,cx = one
        for dy, dx in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            ny, nx = cy+dy, cx+dx
            if 0 <= nx < W and 0 <= ny < H and visited[ny*W+nx]==0:
                visited[ny*W+nx] = 1
                tmp_s.append([ny,nx])
    cnt+=1
    start = tmp_s
print(cnt)  

### FIXED CODE ###

def main():
    H, W = list(map(int, input().split()))
    c = [input() for j in range(H)]
    from collections import deque
    que = deque()
    dist = [[-1]*W for i in range(H)]
    for h in range(H):
        for w in range(W):
            if c[h][w] == "#":
                que.append((h, w))
                dist[h][w] = 0
 
    def bfs():
        d = ((1, 0), (0, 1), (-1, 0), (0, -1))
        while que:
            # popleftにすれば、手の短い方が優先されているので、それで訪れられる所は全て確定でいい。
            # 探索するところが無くなるまで続ける。
            cy, cx = que.popleft()
            for dy, dx in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                ny, nx = cy+dy, cx+dx
                if 0 <= ny < H and 0 <= nx < W and dist[ny][nx] == -1 and c[ny][nx] == '.':
                    dist[ny][nx] = dist[cy][cx] + 1
                    que.append((ny, nx))
 
    bfs()
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, dist[h][w])
    print(ans)
 
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

"""
6 1
3
"""

n, m = list(map(int, input().split()))
aaa = list(int(input()) for i in range(m))

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

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % MOD

print(dp[n])


### FIXED CODE ###

n, m = list(map(int, input().split()))
broken = [False] * (n + 1)
for _ in range(m):
    broken[int(input())] = True

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if not broken[1] else 0
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if not broken[i - 1]:
        dp[i] += (dp[i - 1])
    if not broken[i - 2]:
        dp[i] += (dp[i - 2])
    dp[i] %= MOD

print(dp[n])
### BUGGY CODE ###

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

mod = 1000000007
result = [0]*(n+1)
result[0] = 1
for i in range(1,n+1):
    if i in a:
        result[i] = 0
    else:
        result[i] = (result[i-1] + result[i-2])%mod

print(result[n])

### FIXED CODE ###

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

mod = 1000000007
result = [0]*(n+1)
result[0] = 1
for i in range(1,n+1):
    if i in a:
        result[i] = 0
    else:
        result[i] = (result[i-1] + result[i-2])%mod

print(result[n])
### BUGGY CODE ###

def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if mod == 0:
                    break
    print(ans)


if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


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

n = int(input())
def f(x):
    yakusu = 0
    for i in range(1,x+1):
        if x % i == 0:
            yakusu += 1
    return yakusu
ans = 0
for i in range (1,n+1):
    ans += i*f(i)
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
    ans += (n//i)*(n//i + 1)/2*i
print(int(ans))
### BUGGY CODE ###

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

ans = "IMPOSSIBLE"
second_island = []

for a, b in ab_list:
  if a == 1:
    second_island.append(b)
  
  if a in second_island:
    if b == N:
      ans = "POSSIBLE"

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
sa = set()
sb = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print('POSSIBLE' if len(sa&sb) != 0 else 'IMPOSSIBLE')
### BUGGY CODE ###

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

import numpy as np

def F2_GaussJordan(A, is_extended = False):
    rank = 0
    for col in range(len(A[0])):
        if (is_extended and col == len(A[0])-1):
            break
        pivot = -1
        for row in range(rank,len(A)):
            if A[row][col]:
                pivot = row
                break
        if pivot == -1: 
            continue
        A[[pivot,rank]] = A[[rank,pivot]]
        for row in range(len(A)):
            if (row != rank and A[row][col]):
                A[row] ^= A[rank]
        rank += 1
    return A

N = I()
A = III()

xor = 0
for i in range(N):
    xor ^= A[i]

use_digit = []
ans = 0
for j in range(60)[::-1]:
    if xor>>j & 1:
        ans += 2**j
    else:
        use_digit.append(j)

a = np.zeros((N,len(use_digit)), dtype=bool)
k = 0
for k,j in enumerate(use_digit):
    for i in range(N):
        if A[i]>>j & 1:
            a[i][k] = 1
        else:
            a[i][k] = 0

g = F2_GaussJordan(a,False)

s = 0
for i in range(N):
    s = max(s,s^sum([g[i][j]*2**use_digit[j] for j in range(len(use_digit))]))
ans += 2*s

print(ans)

### FIXED CODE ###

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()

xor = 0
for i in range(N):
    xor ^= A[i]

for i in range(N):
    A[i] &= ~xor

max_digit = len(format(max(A), 'b'))
rank = 0
for col in range(max_digit)[::-1]:
    pivot = -1
    for row in range(rank,N):
        if A[row]>>col & 1:
            pivot = row
            break
    if pivot == -1: 
        continue
    A[pivot],A[rank] = A[rank],A[pivot]
    for row in range(rank+1,N):
        if A[row]>>col & 1:
            A[row] ^= A[rank]
    rank += 1

val = 0
for i in range(N):
    val = max(val,val^A[i])

print(2*val + xor)
### BUGGY CODE ###

if __name__ == "__main__":
    n, m = map(int, input().split())

    nexts = [[] for i in range(n)]
    
    for i in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        nexts[ai].append(bi)
        nexts[bi].append(ai)


    red_set = [0]
    new_red_set = []
    #blue_set = [x + 1 for x in range(n - 1)]
    #new_blue_set = blue_set
    blues = [1] * n # 1 is in blues
    blues[0] = 0 # 0 is not in blues
    reds = [0] * n
    reds[0] = 1
    new_reds = [0] * n

    arrows = [0] * n

    while 1 in blues:
        for i in range(n):
            if reds[i] == 1:
                for nxt in nexts[i]:
                    if blues[nxt] == 1:
                        blues[nxt] = 0
                        new_reds[nxt] = 1
                        arrows[nxt] = i

        reds = new_reds
        new_reds = [0] * n
    
    print("Yes")
    for arrow in arrows[1:]:
        print(arrow + 1)
    

### FIXED CODE ###

from sys import stdin
from collections import deque
input = stdin.readline


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

    nexts = [[] for i in range(n)]
    
    for _ in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        nexts[ai].append(bi)
        nexts[bi].append(ai)

    blues = [-1] * n # 1 is in blues
    blues[0] = 0 # 0 is not in blues
    checked = [0] * n

    red_deque = deque([0])

    while len(red_deque) > 0:
        rd = red_deque[0]
        red_deque.popleft()
        if checked[rd] == 0:
            checked[rd] = 1
            for nxt in nexts[rd]:
                if blues[nxt] == -1:
                    blues[nxt] = rd
                    red_deque.append(nxt)

    print("Yes")
    for blue in blues[1:]:
        print(blue + 1)
    

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

import math
K=int(input())
ans=0
def gcd(a,b,c):
    a=math.gcd(a,b)
    return math.gcd(a,c)

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans+=gcd(i,j,k)
print(ans)

### FIXED CODE ###

import math
#import time
def gcd(a,b,c):
    return math.gcd(a,math.gcd(b,c))
#time1=time.time()
K=int(input())
ans=0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i==j and j==k:
                ans+=gcd(i,j,k)
            elif i==j or i==k or j==k:
                ans+=3*gcd(i,j,k)
            else:
                ans+=6*gcd(i,j,k)
#time2=time.time()
print(ans)
#print(time2-time1)