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

from math import floor	# 切り下げ
h = int(input())

i = 1
while True:
  if 2**i < h < 2**(i+1):
    print(2**(i+1)-1)
    break
  else:
    i += 1

### FIXED CODE ###

h = int(input())
h_bi = bin(h)[2:]
print(2**len(h_bi)-1)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [abs(i) for i in A]
ans1 = sum(B) - 2 * min(B)
for i in range(N - 1):
    if A[i] < 0:
        A[i] = -A[i]
        A[i + 1] *= -1
    ans2 = sum(A)
ans = max(ans1, ans2)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [abs(i) for i in A]
ans1 = sum(B) - 2 * min(B)
for i in range(N - 1):
    if A[i] < 0:
        A[i] = -A[i]
        A[i + 1] *= -1
ans2 = sum(A)
ans = max(ans1, ans2)
print(ans)
### BUGGY CODE ###

import numpy as np
import itertools

H, W, K = map(int, input().split())
S = np.array([[int(s) for s in input()] for _ in range(H)])

ans = 2000
for t in itertools.product([0, 1], repeat=H - 1):
    cut = t.count(1)
    lst = np.zeros((cut + 1, W), dtype=np.int)
    lst[0] += S[0]
    c = 0
    for h in range(H - 1):
        if t[h]:
            c += 1
        lst[c] += S[h + 1]
    L = len(lst)
    sum_lst = np.zeros(L)
    for w in range(W):
        lst_w = lst[:, w]
        if lst_w.max() > K:
            break

        lst_s = sum_lst + lst_w
        if lst_s.max() > K:
            cut += 1
            sum_lst = lst_w
        else:
            sum_lst = lst_s
    else:
        ans = min(ans, cut)
print(ans)


### FIXED CODE ###

import itertools

H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append([int(s) for s in input()])

ans = 2000
for t in itertools.product([0, 1], repeat=H - 1):
    cnt = t.count(1)
    lst = [[s for s in S[0]]]
    for h in range(H - 1):
        if t[h]:
            lst.append(S[h + 1])
        else:
            lst[-1] = [lst[-1][i] + S[h + 1][i] for i in range(W)]
    L = len(lst)
    sum_lst = [0] * L
    for w in range(W):
        if max(lst[i][w] for i in range(L)) > K:
            break
        tmp = [sum_lst[i] + lst[i][w] for i in range(L)]
        if max(tmp) > K:
            cnt += 1
            sum_lst = [lst[i][w] for i in range(L)]
        else:
            sum_lst = tmp
    else:
        ans = min(ans, cnt)
print(ans)
### BUGGY CODE ###

from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
for x in range(1,n+1):
    ans = 0
    m = ceil(sqrt(x))+1
    for i in range(1, m):
        for j in range(1, m):
            for k in range(1, m):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == x:
                    ans += 1
    print(ans)

### FIXED CODE ###

from math import *
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
for x in range(1,n+1):
    ans = 0
    m = ceil(sqrt(x))+1
    for i in range(1, m):
        for j in range(i, m):
            tmp = (i+j)**2 - 4*(i**2+j**2+i*j-x)
            if tmp > (i+j)**2:
                k = ( -(i+j) + sqrt(tmp) ) // 2
                if k >= j and i**2 + j**2 + k**2 + i*j + j*k + k*i == x:
                    if i == j == k:
                        ans += 1
                    elif i == j or j == k or k == i:
                        ans += 3
                    else:
                        ans += 6
    print(ans)
### BUGGY CODE ###

n,x,y=map(int,input().split())

cnt=[0 for i in range(n)]

for i in range(1,n+1):
  for j in range(i+1,n+1):
    a=min(abs(x-i),abs(y-i))
    b=min(abs(x-j),abs(y-j))
    l=min(j-i,a+b+1)
    cnt[l] += 1
      
for i in range(1,n):
  print(cnt[i])


### FIXED CODE ###

n,x,y=map(int,input().split())

cnt=[0 for i in range(n)]

for i in range(1,n+1):
  for j in range(i+1,n+1):
    a=min(abs(x-i),abs(y-i))
    b=min(abs(x-j),abs(y-j))
    l=min(j-i,a+b+1)
    cnt[l] += 1
      
for i in range(1,n):
  print(cnt[i])
### BUGGY CODE ###

from bisect import bisect_left
N = int(input())
a=list(map(int, input().split()))
Q = int(input())
b=[]
c=[]
for i in range(Q):
  b1,c1=map(int, input().split())
  b.append(b1)
  c.append(c1)
def index(lst, e):
    i = bisect_left(lst, e)
    if i == len(lst):
        raise ValueError
    if lst[i] != e:
        raise ValueError
    return i
for i in range(Q):
  first=0
  last = 0
  a.sort()
  if b[i] not in a:
    print(sum(a))
  else:
    last = a.count(b[i])
    first = index(a,b[i])
    del a[first:first+last]
    list_c = [c[i]]*last
    a = a+list_c
    print(sum(a))
  
  
  



### FIXED CODE ###

N = int(input())
a=list(map(int, input().split()))
Q = int(input())
num_a =[0]*100001
num_b = []
sum_a = sum(a)
b=[]
c=[]
for i in a:
  num_a[i]+= 1
for i in range(Q):
  b1,c1=map(int, input().split())
  b.append(b1)
  c.append(c1)
for i in range(Q):
  if num_a[b[i]]==0:
    num_b.append(0)
    sum_a = sum_a - b[i]*num_b[i] +c[i]*num_b[i]
  else:
    num_b.append(num_a[b[i]])
    num_a[c[i]] += num_a[b[i]]
    num_a[b[i]] = 0
    sum_a = sum_a - b[i]*num_b[i] +c[i]*num_b[i]
  print(sum_a)
### BUGGY CODE ###

N = int(input())
X = list(input())
es = [0,N,0]

def p(X):
    print(X)

def list_change(X):
    for i in range(N):
        if X[i] == 'W':
            es[0] = i
            for j in reversed(range(N)):
                if X[j] == 'R':
                    es[1] = j
                    if i<j :
                        X[i] = 'R'
                        X[j] = 'W'
                        es[2] +=1
                        break
                   


list_change(X)
p(es[2])


### FIXED CODE ###

N = int(input())
X = list(input())
es = [0,N,0]

def p(X):
    print(X)

def list_change(X):
    for i in range(N):
        if X[i] == 'W':
            es[0] = i
            for j in reversed(range(es[1])):
                if X[j] == 'R':
                    es[1] = j
                    if i<j :
                        X[i] = 'R'
                        X[j] = 'W'
                        es[2] +=1
                        break
                elif j == 0:
                    es[1] = 1
                


list_change(X)
p(es[2])
### BUGGY CODE ###

N, W = map(int, input().split())
w_v = [list(map(int, input().split())) for _ in range(N)]
 
 
# 1~i-1番目の品物から重さの総和がj以下になるように選んだときの価値
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
 
for i in range(N):
    w, v = w_v[i]
    for j in range(W+1):
        if j - w >= 0:
            dp[i+1][j] = max(dp[i][j-w]+v, dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
 
print(max(dp[N]))
 
 

### FIXED CODE ###

N, W = map(int, input().split())
w_v = [list(map(int, input().split())) for _ in range(N)]

V = max(w_v, key=lambda x: x[1])[1] * N
# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ
dp = [[float('inf') for _ in range(V+1)] for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    w, v = w_v[i]
    for j in range(V+1):
        if j - v >= 0:
            dp[i+1][j] = min(dp[i][j-v]+w, dp[i][j])
        else:
            #dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]

r = 0
for v in range(V+1):
    if dp[N][v] <= W:
        r = v
print(r)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from collections import Counter
MOD = 1000000007  # type: int


def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []

    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1

    return prime_list


def solve(N: int, A: "List[int]"):

    primes = eratosthenes_sieve(max(A)+1)

    def factorial(n):
        # 試し割りによる素因数分解
        prime_count = Counter()
        for i in primes:
            while n % i == 0:
                n /= i
                prime_count[i] += 1
        if n > 1:
            prime_count[int(n)] += 1
        return prime_count

    C = [factorial(a) for a in A]

    K = Counter()
    for c in C:
        for k in c:
            K[k] = max(K[k], c[k])

    tot = 0
    for i in range(N):
        a = 1
        for k in K:
            if K[k] - C[i][k] != 0:
                a *= k**(K[k] - C[i][k])
                a %= MOD
        tot += a
        tot %= MOD
    print(tot)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import Counter
import math
MOD = 1000000007  # type: int


def factorial(n):
    prime_count = Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % MOD
    elif y % 2 == 0:
        return power(x, y//2)**2 % MOD
    else:
        return power(x, y//2)**2 * x % MOD


def div(a, b):
    return (a * power(b, MOD-2)) % MOD


def solve(N: int, A: "List[int]"):

    lcm = Counter()
    for a in A:
        c = factorial(a)
        for k in c:
            lcm[k] = max(c[k], lcm[k])
    # print(lcm)

    LCM = 1
    for k, v in lcm.items():
        LCM *= power(k, v)
        LCM %= MOD
    # print(LCM)

    tot = 0
    for a in A:
        tot += div(LCM, a)
    print(tot % MOD)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


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

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

t = list(map(int,input().split()))
ab=[]
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a,b])

t.sort(reverse=True)
ab = sorted(ab, key=lambda x: -x[1])
res = []
x = t.pop(0)

for i, j in ab:
    #print(res, i, j)
    while j < x:
        res.append(x)
        if len(t):
            x = t.pop(0)
        else:
            x = 0
    for _ in range(i):
        res.append(j)
        if len(res) > n:
            break
    if len(res) > n:
            break

if len(res) < n:
    for i in range(n):
        res.append(x)
        x = t.pop(0)
        if len(res) >= n:
            break
        

print(sum(res[0:n]))

### FIXED CODE ###

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

t = list(map(int,input().split()))
ab=[]
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a,b])

t.sort(reverse=True)
ab = sorted(ab, key=lambda x: -x[1])
count = 0
for i,j in ab:
    t += [j]*i
    count += i
    if n <= count:
        break

t.sort(reverse=True)
        
print(sum(t[:n]))
### BUGGY CODE ###

n = int(input()) 
t = [int(input()) for i in range(n)]
for i in range(n):
	x = t.copy()
	x.pop(i)
	print(max(x))

### FIXED CODE ###

n = int(input()) 
t = [int(input()) for i in range(n)]
m2 = sorted(t)[-2]
m = max(t)
for i in range(n):
	if t[i] != m:
		print(m)
	else:
		print(m2)
### BUGGY CODE ###

N = int(input())
print(sum([i for i in range(N)]))

### FIXED CODE ###

N = int(input())
ans = N*(N-1)//2
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()

ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        else:
            sk = ({"R", "G", "B"} - set([S[i], S[j]])).pop()
            if 2*j - i < N and S[2*j - i] == sk:
                ans += S[j+1:].count(sk) - 1
            else:
                ans += S[j+1:].count(sk)

print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N-2):
    for d in range(1, (N-i-1)//2+1):
        if {S[i], S[i+d], S[i+2*d]} == {"R", "G", "B"}:
            ans -= 1

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

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = '-1'


def is_anag(a, b):
    return Counter(a) == Counter(b)


N = int(input())
S = [input().rstrip() for _ in range(N)]
ans = []

for i, s in enumerate(S, start=1):
    if s == NIL:
        continue
    counter = 1
    for j in range(i, len(S)):
        if S[j] == NIL:
            continue
        if is_anag(s, S[j]):
            counter += 1
            S[j] = NIL
    if counter != 1:
        ans.append(counter * (counter - 1) // 2)

# res = []
#
# for a in ans:
#     res.append(a * (a - 1) // 2)
print(sum(ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = '-1'


def is_anag(a, b):
    return Counter(a) == Counter(b)


N = int(input())
S = ["".join(sorted(input())) for _ in range(N)]
counter = Counter(S)

ans = 0
for value in counter.values():
    if value >= 2:
        ans += value * (value - 1) // 2

print(ans)

# for i, s in enumerate(S, start=1):
#     if s == NIL:
#         continue
#     counter = 1
#     for j in range(i, len(S)):
#         if S[j] == NIL:
#             continue
#         if is_anag(s, S[j]):
#             counter += 1
#             S[j] = NIL
#     if counter != 1:
#         ans.append(counter * (counter - 1) // 2)

# res = []
#
# for a in ans:
#     res.append(a * (a - 1) // 2)
# print(sum(ans))
### BUGGY CODE ###


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

L.sort()
#print(L)

count = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            #print(i, j, k)
            #print(L[i], L[j], L[k])
            #print(L[i] + L[j] > L[k])
            if L[k] >= L[i] + L[j]:
                break
            count += 1

print(count)

### FIXED CODE ###

def fnt(arr,n): 
  
     
     
     
    count = 0
  
     
    for i in range(0,n-2): 
  
         
        k = i + 2
  
        # Fix the second element 
        for j in range(i+1,n): 
  
             
            while (k < n and arr[i] + arr[j] > arr[k]): 
                k += 1
  
             
            if(k>j): 
                count += k - j - 1
  
    return count
 
 
n=int(input())
arr=input()
arr=arr.split()
arr=list(map(int,arr))
arr.sort()
print(fnt(arr,n))
### BUGGY CODE ###

import sys

S = input().strip()

MOD = 10 ** 9 + 7

lens = len(S)

dp = [[0] * 13 for j in range(lens)]
if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, lens):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                amari = (j * 10 + k) % 13
                dp[i][amari] += dp[i - 1][j]
                dp[i][amari] %= MOD
        else:
            amari = (j * 10 + int(S[i])) % 13
            dp[i][amari] += dp[i - 1][j]
            dp[i][amari] %= MOD

print(dp[-1][5])


### FIXED CODE ###


S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k] % MOD


print(dp[S_len][5] % MOD)
### BUGGY CODE ###

n = int(input())
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]

e = [[] for _ in range(n)]
d = [[0 for _ in range(n)] for _ in range(n)]

c = [0] * n

for a, b in ab:
    c[a] += 1
    c[b] += 1
    e[a].append(b)
    e[b].append(a)

me = max(c)

print(me)

for a, b in ab:
    c = [0] * n
    for f in e[a]:
        c[d[a][f]] = 1
    for f in e[b]:
        c[d[b][f]] = 1
    for i, x in enumerate(c):
        if x == 0:
            print(i)
            d[a][b] = i
            d[b][a] = i
            break


### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

n = int(input())
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]

e = [[] for _ in range(n)]

p = [0] * n
c = [0] * n
d = [0] * n

for a, b in ab:
    e[a].append(b)
    e[b].append(a)

me = 0

q = [0]
p[0] = -1

while q:
    x = q.pop()
    temp = c[x]
    color = 1
    me = max(me, len(e[x]))
    #print(x, temp)
    for y in e[x]:
        if color == temp:
            color += 1
        if d[y] == 0:
            q.append(y)
            c[y] = color
            p[y] = x
            color += 1
    d[x] = 1

#print(c)
#print(p)

print(me)

for a, b in ab:
    if p[a] == b:
        print(c[a])
    else:
        print(c[b])
### BUGGY CODE ###

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

def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]
    
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    
    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])
    
    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            for j in range(4):
                ny = y + dy[j]
                nx = x + dx[j]
                if nx < w and nx >= 0 and ny < h and ny >= 0 and not a[ny][nx]:
                    a[ny][nx] = True
                    nque.append((ny, nx))
        if nque:
            que = copy.copy(nque)
        else:
            break
    
    print(count - 1)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
a = [[] for i in range(h)]
for i in range(h):
    a[i] = list(input())

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

que = deque()

white = h * w

# スタート地点をqueueに追加
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            que.append([i, j])
            white -= 1

count = 0
while 1:
    if white == 0:
        break
    count += 1
    loop = len(que)
    for i in range(loop):
        p = que.popleft()
        for j in range(4):
            ny = p[0] + dy[j]
            nx = p[1] + dx[j]
            if nx < w and nx >= 0 and ny < h and ny >= 0 and a[ny][nx] == ".":
                a[ny][nx] = "#"
                white -= 1
                que.append([ny, nx])


print(count)
### BUGGY CODE ###

x,y,z,k = [int(num) for num in input().split()]
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True) for _ in range(3)]

sum_cake = sorted([a+b+c for a in a_cake for b in b_cake for c in c_cake],reverse=True)[:k]

for i in sum_cake:
    print(i)




### FIXED CODE ###

x,y,z,k = [int(num) for num in input().split()]
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True)[:k] for _ in range(3)]

sum_cake=list()
for i,a in enumerate(a_cake,1):
    for j,b in enumerate(b_cake,1):
        if(i*j>k):
            break
        for n,c in enumerate(c_cake,1):
            if(i*j*n>k):
                break
            sum_cake.append(a+b+c)


sum_cake.sort(reverse=True)

for i in sum_cake[:k]:
    print(i)
### BUGGY CODE ###

'''input
5
abcde
fghij
klmno
pqrst
uvwxy
'''


def is_symmetric(board):
    for i in range(N):
        for j in range(N):
            if board(j, i) != board(i, j):
                return False
    return True


def translate(board, a, b):
    def get(i, j):
        return board[(i + a) % N][(j + b) % N]
    
    return get


def solve(board):
    ans = 0
    for a in range(N):
        if is_symmetric(translate(board, a, 0)):
            ans += N - a
    for b in range(N):
        if b == 0:
            continue
        if is_symmetric(translate(board, 0, b)):
            ans += N - b
    return ans


N = int(input())
board = []
for i in range(N):
    board.append(input())


print(solve(board))

### FIXED CODE ###



def is_symmetric(board):
    for i in range(N):
        for j in range(i, N):
            if board(j, i) != board(i, j):
                return False
    return True


def translate(board, a, b):
    def get(i, j):
        return board[(i + a) % N][(j + b) % N]
    
    return get


def solve(board):
    ans = 0
    for a in range(N):
        if is_symmetric(translate(board, a, 0)):
            ans += N - a
    for b in range(N):
        if b == 0:
            continue
        if is_symmetric(translate(board, 0, b)):
            ans += N - b
    return ans


N = int(input())
board = []
for i in range(N):
    board.append(input())


print(solve(board))
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())

for i in range(Q):
    s = S[l[i]-1:r[i]]
    print(s.count('AC'))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
counter = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])
### BUGGY CODE ###

import numpy as np
 
K = int(input())
ans = 0
for i in range(1,K+1):
    ans += np.gcd.reduce([i,i,i])

for i in range(1, K):
    for j in range(i+1, K+1):
        ans += 3 * np.gcd.reduce([i,j,j])
for i in range(1, K+1):
    for j in range(1, i):
        ans += 3 * np.gcd.reduce([i,j,j])
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += 6 * np.gcd.reduce([i,j,k])
            
print(ans)

### FIXED CODE ###

import numpy as np
 
K = int(input())
ans = 0

gcd2 = np.zeros((K+1, K+1), dtype=int)

for i in range(1, K):
    for j in range(i+1,K+1):
        gcd2[i,j] = gcd2[j,i] = np.gcd(i,j)
for i in range(1, K+1):
    gcd2[i,i] = i

for i in range(1,K+1):
    ans += i

for i in range(1, K):
    for j in range(i+1, K+1):
        ans += 3 * gcd2[i,j]
for i in range(1, K+1):
    for j in range(1, i):
        ans += 3 * gcd2[i,j]
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += 6 * gcd2[i,gcd2[j,k]]
            
print(ans)