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

n,c = map(int,input().split())
stc = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

stc.sort(key=lambda x:(x[2],x[1],x[0]))

time = 10**5+3

c_imos = [[0 for i in range(time)] for j in range(c)]

for i in range(n):
    c_imos[stc[i][2]-1][stc[i][0]-1] += 1
    c_imos[stc[i][2]-1][stc[i][1]] -= 1

nd_v = [[0 for i in range(time)] for j in range(c)]

for i in range(c):
    for j in range(time):
        if j == 0:
            if c_imos[i][j] == 1:
                nd_v[i][j] = 1
        else:
            nd_v[i][j] = nd_v[i][j-1] + c_imos[i][j]

for i in range(c):
    for j in range(time):
        if nd_v[i][j] >= 2:
            nd_v[i][j] = 1
ans = 1

for i in range(time-1):
    tmp = 0
    for j in range(c):
        tmp += nd_v[j][i]
    ans = max(tmp,ans)

print(ans)

exit()
    
c_num = stc[0][2]
t_num = stc[0][1]
idx = 0
print(stc)
for i in range(1,n):
    print(t_num,i)
    if stc[idx+i][2] == c_num:
        if stc[idx+i][0] == t_num:
            stc[idx+i-1][1] = stc[idx+i][1]
            t_num = stc[idx+i][1]
            del stc[idx+i]
            idx -= 1
        else:
            print(t_num,t_num,t_num)
            c_num = stc[idx+i][2]
            t_num = stc[idx+i][1]

stc.sort(key=lambda x:x[1])
print(stc)
exit()
tmp = stc[0][1]

ans = 1
ans_tmp = 1

for i in range(1,len(stc)):
    for j in range(i+1,len(stc)):
        if tmp >= stc[j][0]:
            ans_tmp += 1
        else:
            tmp = stc[j][0]
            ans = max(ans_tmp,ans)

### FIXED CODE ###

n,c = map(int,input().split())
stc = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

stc.sort(key=lambda x:(x[2],x[1],x[0]))

time = 10**5+3

c_imos = [[0 for i in range(time)] for j in range(c)]

for i in range(n):
    c_imos[stc[i][2]-1][stc[i][0]-1] += 1
    c_imos[stc[i][2]-1][stc[i][1]] -= 1

nd_v = [[0 for i in range(time)] for j in range(c)]

for i in range(c):
    for j in range(time):
        if j == 0:
            if c_imos[i][j] == 1:
                nd_v[i][j] = 1
        else:
            nd_v[i][j] = nd_v[i][j-1] + c_imos[i][j]

for i in range(c):
    for j in range(time):
        if nd_v[i][j] >= 2:
            nd_v[i][j] = 1
ans = 1

for i in range(time-1):
    tmp = 0
    for j in range(c):
        tmp += nd_v[j][i]
    ans = max(tmp,ans)

print(ans)

exit()
    
c_num = stc[0][2]
t_num = stc[0][1]
idx = 0
print(stc)
for i in range(1,n):
    print(t_num,i)
    if stc[idx+i][2] == c_num:
        if stc[idx+i][0] == t_num:
            stc[idx+i-1][1] = stc[idx+i][1]
            t_num = stc[idx+i][1]
            del stc[idx+i]
            idx -= 1
        else:
            print(t_num,t_num,t_num)
            c_num = stc[idx+i][2]
            t_num = stc[idx+i][1]

stc.sort(key=lambda x:x[1])
print(stc)
exit()
tmp = stc[0][1]

ans = 1
ans_tmp = 1

for i in range(1,len(stc)):
    for j in range(i+1,len(stc)):
        if tmp >= stc[j][0]:
            ans_tmp += 1
        else:
            tmp = stc[j][0]
            ans = max(ans_tmp,ans)
### BUGGY CODE ###

S = input()
n = [ord(c)-ord('a') for c in S]

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

def next(x):
    if len(x) < 26:
        for c in range(26):
            if not c in x:
                x.append(c)
                return x
    k = 0
    flag = True
    x[-1] += 1
    c = 0
    for i in range(len(x)):
        x[-1-i] += k
        if x[-1-i] >= 26:
            if flag: c += 1
            else: x[-1-i] -= 26
            k = 1
        else:
            flag = False
            k = 0
    if k == 1: return None
    if c: return x[:-c]
    return x

def check(x):
    c = [False]*26
    for i in x:
        if x == -1: continue
        if c[i]: return False
        c[i] = True
    return True

while True:
    n = next(n)
    if n == None:
        print(-1)
        exit()
    if check(n): break

ans = ""
for i in n:
    if i != -1: ans += chr(ord('a') + i)
print(ans)

### FIXED CODE ###

S = input()
n = len(S)

import string
def f(x, mn=None):
    for c in string.ascii_lowercase:
        if c in x: continue
        if mn and c <= mn: continue
        return c
    return None

if n < 26:
    print(S + f(S))
    exit()

i = n-2
while i >= 0:
    if S[i] < S[i+1]: break
    i -= 1
else:
    print(-1)
    exit()

t = S[:i]
print(t + f(t, S[i]))
### BUGGY CODE ###



anslist = []


def solve():

    S = input()

    ans = 0
    for i in range(len(S)-3):
        for j in range(i, len(S)-3):
            if int(S[i:j+4]) % 2019 == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


### FIXED CODE ###



def solve():

    s = input()
    mod = 2019
    remains = [0]*mod

    ans = 0
    now = 0
    remains[0] = 1
    for i, val in enumerate(s[::-1]):
        now += int(val) * pow(10, i, mod)
        now %= mod
        ans += remains[now]
        remains[now] += 1

    print(ans)


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

def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 0
    for i in range(N):
        k = True
        for j in range(i):
            if P[i] > P[j]:
                k = False
                break
        if k:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 1
    num = P[0]
    for i in range(1, N):
        if num >= P[i]:
            count += 1
            num = P[i]
    print(count)


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

N = int(input())
s = input()
l = {}
a = [set() for i in range(N)]
a[-1].add(s[-1])

for i in range(N-2, -1 , -1):
  a[i] = a[i+1] | {s[i]} 

for i1 in range(N-2):
  for i2 in range(i1+1, N-1):
    l[s[i1] + s[i2]] = l.get(s[i1] + s[i2], set()) | a[i2+1]

r = 0
for i in l.values():
  r += len(i)
print(r)

### FIXED CODE ###

N = int(input())
s = input()
l = {}
a = [{} for i in range(N)]
a[-1] = {s[-1]: N-1}

for i in range(N-2, -1 , -1):
  a[i] = a[i+1].copy()
  a[i].update({s[i]: i})

r = 0
for k1, v1 in a[0].items():
  if v1 >= N - 2: continue
  for k2, v2 in a[v1+1].items():
    if v2 >= N - 1 : continue
    r += len(a[v2+1].keys())

print(r)
### BUGGY CODE ###

from decimal import Decimal
N, K = map(int, input().split())
ans = 0
for n in range(1, N + 1):
    c = 0
    while n < K:
        n = n << 1
        c += 1
    t = 1 << c
    ans += Decimal("1.0") / Decimal(str(N * t))
print(ans)

### FIXED CODE ###

from decimal import Decimal
N, K = map(int, input().split())
ans = 0
for n in range(1, N + 1):
    c = 0
    while n < K:
        n = n << 1
        c += 1
    t = 1 << c
    ans += Decimal("1.0") / Decimal(str(N * t))
print(ans)
### BUGGY CODE ###

from sys import stdin
from sys import setrecursionlimit
from collections import Counter
from numba import jit

setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
a.sort()
c = Counter(a)

se = set()

@jit
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

for i in a:
    k = make_divisors(i)
    flag = True
    for j in k:
        if j in se:
            flag = False
    if flag:
        se.add(i)

point = len(se)

for i in se:
    if c[i] > 1:
        point -= 1

print(point)

### FIXED CODE ###

from sys import stdin
from sys import setrecursionlimit
from collections import Counter
from numba import jit

setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
a.sort()
b = list(set(a))
b.sort()
c = Counter(a)

se = set()

@jit
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

for i in b:
    k = make_divisors(i)
    flag = True
    for j in k:
        if j in se:
            flag = False
            break
    if flag:
        se.add(i)

point = len(se)

for i in se:
    if c[i] > 1:
        point -= 1

print(point)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
maxi  = max(a)
for i in range(n):
  if a[i] != maxi:
    print(maxi)
  else:
    a[i] = 0
    print(max(a))
    a[i] = maxi

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
b = []
b += a
b.sort()
if b[-1] == b[-2]:
  maxi = max(a)
  for i in range(n):
    print(maxi)
else:
  maxi = max(a)
  for i in range(n):
    if a[i] != maxi:
      print(maxi)
    else:
      print(b[-2])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
from collections import deque

def bfs(x, y):
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == ".":
            maze[nx][ny] = "#"

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
cnt = 0
ans = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            cnt += 1

while cnt > 0:
    tmp = []
    for i in range(h):
        for j in range(w):
            if maze[i][j] == "#":
                tmp.append((i, j))
    while tmp:
        p = tmp.pop()
        bfs(p[0], p[1])

    ans += 1
    cnt = 0   
    for i in range(h):
        for j in range(w):
            if maze[i][j] == ".":
                cnt += 1
print(ans)

### FIXED CODE ###

import copy

def bfs(x, y):
    global tmp
    global cnt
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == ".":
            tmp.append((nx, ny))
            maze[nx][ny] = "#"
            cnt += 1
    return tmp

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
ans = 0
cnt = 0
tmp = []
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            tmp.append((i, j))
            cnt += 1

while cnt < h * w:
    tmp_ = copy.copy(tmp)
    tmp = []
    while tmp_:
        p = tmp_.pop()
        bfs(p[0], p[1])
    ans += 1
print(ans)
### BUGGY CODE ###

import sys
from itertools import permutations, combinations
  
def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [[int(i) for i in input().split()] for _ in range(N)]

    length = 0
    possible = True
    for a, b in combinations(range(N), 2):
        Lab = A[a][b]
        create_pass = True
        for k in range(N):
            if k != a and k != b:
                compare = A[a][k] + A[k][b]
                if Lab > compare:
                    possible = False
                    break
                elif Lab == compare:
                    create_pass = False
                    break
        if create_pass: length += Lab
        if not possible:
            print(-1)
            break
    else: print(length)

    return 0
  
if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
from itertools import permutations, combinations
  
def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [[int(a) for a in input().split()] for _ in range(N)]

    length = 0
    possible = True
    for a, b in combinations(range(N), 2):
        Lab = A[a][b]
        create_pass = True
        for k in range(N):
            if k != a and k != b:
                if Lab >  A[a][k] + A[k][b]:
                    possible = False
                    break
                elif Lab ==  A[a][k] + A[k][b]:
                    create_pass = False
                    break
        if create_pass: length += Lab
        if not possible:
            print(-1)
            break
    else: print(length)
    
    return 0
  
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

from functools import lru_cache

import sys
sys.setrecursionlimit(10 ** 7)

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

@lru_cache(maxsize=None)
def rec(n):
  # print(n)
  if n == 1:
    return 0
  elif n == 2:
    return abs(h[1]-h[0])
  else:
    return min(rec(n-1)+abs(h[n-1]-h[n-2]), rec(n-2)+abs(h[n-1]-h[n-3]))

print(rec(N))

### FIXED CODE ###

from functools import lru_cache

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

cost = [None] * N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]))
print(cost[N-1])
# print(cost)

"""
@lru_cache(maxsize=None)
def rec(n):
  # print(n)
  if n == 1:
    return 0
  elif n == 2:
    return abs(h[1]-h[0])
  else:
    return min(rec(n-1)+abs(h[n-1]-h[n-2]), rec(n-2)+abs(h[n-1]-h[n-3]))

print(rec(N))
"""
### BUGGY CODE ###

n = int(input())
l = [int(x) for x in input().split()]
ans = []
for i in range(n):
    print(l.count(i+1))
    

### FIXED CODE ###

n = int(input())
l = [int(x) for x in input().split()]
ans = [0]*(n)
for i in range(n-1):
    ans[l[i]-1] += 1
print(*ans,sep='\n')
### BUGGY CODE ###

n=int(input())
f=0
while n>0:
  c=n%10
  if c==7:
    f=1
    print("yes")
    n=n/10
if f==0:
  print("no")
  

### FIXED CODE ###

n=int(input())
f=0
while n>0:
      c=n%10
      if  c==7:
            f=1
            print("Yes")
            break
      n=int(n/10)
if f==0:
      print("No")
### BUGGY CODE ###

import copy
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A,reverse=True)
ng=-1
ok=A[0]*2+1
B=[0]*n
C=[0]*n
while ok-ng>1:
  mid=(ok+ng)//2
  c=0
  for i in range(n):
    OK=-1
    NG=n
    while NG-OK>1:
      MID=(OK+NG)//2
      if A[i]+A[MID]>=mid:
        OK=MID
      else:
        NG=MID
    B[i]=OK+1
    c=c+OK+1
  if c<m:
    ok=mid
    C=copy.deepcopy(B)
  else:
    ng=mid
D=[0]
for i in range(n):
  D.append(D[-1]+A[i])
ans=0
for i in range(n):
  ans=ans+A[i]*C[i]+D[C[i]]
ans=ans+(m-sum(C))*(ok-1)
print(ans)

### FIXED CODE ###

import bisect
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ng=-1
ok=A[-1]*2+1
B=[[0]*n for k in range(2)]
ii=0
while ok-ng>1:
  mid=(ok+ng)//2
  d=0
  for i in range(n):
    c=n-bisect.bisect_right(A,mid-A[i],lo=0,hi=len(A))
    B[ii][i]=c
    d=d+c
  if d<m:
    ok=mid
    ii=(ii+1)%2
  else:
    ng=mid
D=[0]
for i in range(n):
  D.append(D[-1]+A[n-i-1])
ans=0
for i in range(n):
  x=B[(ii+1)%2][i]
  ans=ans+A[i]*x+D[x]
ans=ans+(m-sum(B[(ii+1)%2]))*ok
print(ans)
### BUGGY CODE ###

n,q,*x=map(int,open(0).read().split())
a=x[:n]
queries=[]
for i in range(q):
  l,r=x[n+i*2:n+(i+1)*2]
  queries.append([r-1,l-1,i])
ans=[0]*q
queries.sort()
queries.append([10*20,0,0])
lastAppeared=[-1]*n
bit=[0]*n
def add(i,x):
  i+=1
  while i<=n:
    bit[i-1]+=x
    i+=i&-i
def sum_sub(i):
  a=0
  i+=1
  while i:
    a+=bit[i-1]
    i-=i&-i
  return a
def sum(i,j):
  a=sum_sub(j+1)
  if i!=0:a-=sum_sub(i-1)
  return a
j=0
for i in range(n):
  if lastAppeared[a[i]-1]!=-1:
    add(lastAppeared[a[i]-1],-1)
    add(i,1)
    lastAppeared[a[i]-1]=i
  else:
    add(i,1)
    lastAppeared[a[i]-1]=i
  while queries[j][0]==i:
    r,l,ind=queries[j]
    j+=1
    ans[ind]=sum(l,r-1)
print(*ans)


### FIXED CODE ###

def main():
  def add(i,x):
    i+=1
    while i<=n:
      bit[i-1]+=x
      i+=i&-i
  def sum_sub(i):
    a=0
    i+=1
    while i:
      a+=bit[i-1]
      i-=i&-i
    return a
  def sum(i,j):
    a=sum_sub(j+1)
    if i!=0:a-=sum_sub(i-1)
    return a
  
  n,q,*x=map(int,open(0).read().split())
  a=x[:n]
  queries=[]
  for i in range(q):
    l,r=x[n+i*2:n+(i+1)*2]
    l-=1
    r-=1
    queries.append(r<<40|l<<20|i)
  ans=[0]*q
  queries.sort()
  for i in range(q):
    ind=queries[i]%(1<<20)
    queries[i]>>=20
    l=queries[i]%(1<<20)
    queries[i]>>=20
    r=queries[i]
    queries[i]=[r,l,ind]
  queries.append([10*20])
  lastAppeared=[-1]*n
  bit=[0]*n
  j=0
  for i in range(n):
    if lastAppeared[a[i]-1]!=-1:
      add(lastAppeared[a[i]-1],-1)
      add(i,1)
      lastAppeared[a[i]-1]=i
    else:
      add(i,1)
      lastAppeared[a[i]-1]=i
    while queries[j][0]==i:
      r,l,ind=queries[j]
      j+=1
      ans[ind]=sum(l,r-1)
  print(*ans)
if __name__ == "__main__":
  main()
### BUGGY CODE ###

import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())


def main():
    S = INPUT()
    Q = INT()

    flag_order = True
    D_MAP = lambda: map(str, query.split())
    for i in range(Q):
        query = INPUT()
        if len(query.split()) == 1:
            T = 1
        else:
            T = 2
            _, F, C = D_MAP()
            F = int(F)

        if T == 1:
            if flag_order: flag_order = False
            else: flag_order = True
        if T == 2:
            if flag_order:
                if F == 1: S = C + S
                else: S = S + C
            else:
                if F == 1: S = S + C
                else: S = C + S

    print(S if flag_order else S[::-1])


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())


def main():
    S = deque(INPUT())
    Q = INT()

    flag_order = True
    D_MAP = lambda: map(str, query.split())
    for i in range(Q):
        query = INPUT()
        if len(query.split()) == 1:
            T = 1
        else:
            T = 2
            _, F, C = D_MAP()
            F = int(F)

        if T == 1:
            if flag_order: flag_order = False
            else: flag_order = True
        if T == 2:
            if flag_order:
                if F == 1: S.appendleft(C)
                else: S.append(C)
            else:
                if F == 1: S.append(C)
                else: S.appendleft(C)

    print(''.join(S) if flag_order else ''.join(reversed(S)))


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

X,Y = map(int,input().split())
li = []
for i in range(X,(Y+1)):
    temp = i
    if temp%X ==0 :
        li.append(i)
        X = temp 
print(len(li))

### FIXED CODE ###

x,y=map(int,input().split())
cnt=1
while x*2**cnt<=y:
  cnt+=1
print(cnt)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(reversed(sorted([A.count(b) for b in set(A)])))
print(sum(B[K:len(B)]))

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = {i:0 for i in set(A)}
for a in A:
    B[a] += 1
print(sum(sorted(B.values())[:-K]))
### BUGGY CODE ###

it = input()
it = it.split()
n = int(it[0])
m = int(it[1])
p = [[] for _ in range(n)]
for _ in range(m):
    itf = input()
    itf = itf.split()
    a = int(itf[0])
    b = int(itf[1])
    p[a-1].append(b)
    p[b-1].append(a)
d = [1, ]
con = [0] * n
l = 0
for _ in range(1, n):
    for i, k in enumerate(p[1:]):
        if con[i]!=0:continue
        if d[l] in k:
            d.append(i+2)
            con[i] = d[l]
    if len(d) > l:
        l += 1
    else:
        break
print('Yes')
for i in range(n-1):
    print(con[i])

### FIXED CODE ###

it = input()
it = it.split()
n = int(it[0])
m = int(it[1])
p = [[] for _ in range(n)]
for _ in range(m):
    itf = input()
    itf = itf.split()
    a = int(itf[0])
    b = int(itf[1])
    p[a-1].append(b)
    p[b-1].append(a)
d = [1, ]
con = [0] * n
while d:
    l = d.pop(0)
    for k in p[l-1]:
        if con[k-2]==0:
            d.append(k)
            con[k-2] = l
print('Yes')
for i in range(n-1):
    print(con[i])
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(len(l) - 2):
    a = l[i]
    for j in range(i + 1, len(l) - 1):
        b = l[j]
        r = a + b
        for k in range(j + 1, len(l)):
            c = l[k]
            if c < r:
                count += 1
print(count)

### FIXED CODE ###

from bisect import bisect_left


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        cnt += bisect_left(l, a+b) - j - 1
        # bisec_left(l, x)でlの中にxを挿入できる点を探す
print(cnt)
### BUGGY CODE ###

K = input()

#すべての組合せをリスト化する
abc_list = []
for a in range(1, int(K)+1):
  for b in range(1, int(K)+1):
    for c in range(1, int(K)+1):
      abc_list.append([a, b, c])

#ユーグリッド互除法（再起）
def gcd(A, B):
  # p >= q とする
  if A >= B:
    p = A
    q = B
  else:
    p = B
    q = A
  
  # ユーグリッド互除法
  if (p%q==0):
    return q
  else:
    return gcd(q, p%q)

# 回答
ans = 0
for lis in abc_list:
  a = lis[0]
  b = lis[1]
  c = lis[2]

  gcd_ab = gcd(a, b)
  gcd_abc = gcd(gcd_ab, c)

  ans += gcd_abc

print(ans)

### FIXED CODE ###

import itertools
K = int(input())

#ユーグリッド互除法（再起）
def gcd(p, q):
  # ユーグリッド互除法
  if (p%q==0):
    return q
  else:
    return gcd(q, p%q)

ans = 0

for abc in itertools.combinations_with_replacement([i+1 for i in range(K)], 3):
  a,b,c = abc
  gcd_ab = gcd(a, b)
  gcd_abc = gcd(gcd_ab, c)

  # 組み合わせ数を補整する
  if a == b == c:
    ans += gcd_abc
  elif a==b or b==c or a==c:
    ans += gcd_abc*3
  else:
    ans += gcd_abc * 6

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

n = int(input())
a = 0
while n>0:
  a += n%10
  n//=10

if a%9==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

nli = list(map(int,input().split()))
a = sum(nli)
if a%9==0:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
#for i in range(m):
 # a[i] = int(input())
a = [int(input()) for i in range(m)]
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  if j in a:
    dp[j] = 0
  else:
    dp[j] = (dp[j-1]+dp[j-2])%1000000007
print(dp[n])

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
#for i in range(m):
 # a[i] = int(input())
a = set([int(input()) for i in range(m)])
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  dp[j] = (dp[j-1]+dp[j-2])%1000000007
  if j in a:
    dp[j] = 0
print(dp[n])
### BUGGY CODE ###

import math
import numpy as np

K = int(input())
sum_gcd = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        n = math.gcd(a, b)
        for c in range(1, K+1):
            sum_gcd += np.gcd(n, c)
print(sum_gcd)

### FIXED CODE ###

from math import gcd

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        p = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(p,c)
print(ans)
### BUGGY CODE ###

import itertools
N=int(input())
A=list(map(int,input().split()))
ans = 0
for i in itertools.combinations(A,2):
    ans += i[0]*i[1]
    #print(i[0],i[1])
#print(ans)
print(ans%((10**9)+7))


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
sumA = sum(A)
ans = 0
for i in range(N-1):
    x = A[i]
    sumA -= x
    ans += sumA*x
print(ans%((10**9)+7))