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

N,K = map(int,input().split())
A = list(map(int,input().split()))
for k in range(K):
    imos = [0] * (N+1)
    for i,a in enumerate(A):
        l = max(0, i-a)
        r = min(N, i+1+a)
        imos[l] += 1
        imos[r] -= 1
    imos[0] = min(N, imos[0])
    for i in range(N):
        imos[i+1] = min(N, imos[i] + imos[i+1])
    A = imos[:-1]
    if A[0] == A[-1] == N:
        break
print(*A)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
for k in range(K):
    imos = [0] * (N+1)
    for i,a in enumerate(A):
        l = max(0, i-a)
        r = min(N, i+1+a)
        imos[l] += 1
        imos[r] -= 1
    imos[0] = min(N, imos[0])
    for i in range(N):
        imos[i+1] = min(N, imos[i] + imos[i+1])
    A = imos[:-1]
    if all(a==N for a in A):
        break
print(*A)
### BUGGY CODE ###

import itertools

d,g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

a = [i for i in range(d)]

b = itertools.permutations(a,d)

ans = float('inf')

for x in b:
    c = 0
    e = 0
    flag = False
    for i in x:
        for j in range(pc[i][0]):
            c += 1
            e += 100*(i+1)
            if e>=g:
                flag = True
                break
        if flag:
            break
        e += pc[i][1]
        if e >= g:
            flag = True
        if flag:
            break
    ans = min(ans, c)

print(ans)



### FIXED CODE ###

import itertools
import math

d,g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

a = [i for i in range(d)]

b = itertools.permutations(a,d)

ans = float('inf')

for x in b:
    c = 0
    e = 0
    flag = False
    for i in x:
        if e+100*(i+1)*pc[i][0]<=g:
            c += pc[i][0]
            e+=100*(i+1)*pc[i][0]+pc[i][1]
            if e >= g:
                break
        else:
            c += math.ceil((g-e)/(100*(i+1)))
            break
    ans = min(ans, c)

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

import sys
sys.setrecursionlimit(10**6)

N,Q = [int(i) for i in input().split()] #N個の頂点、Q回の操作
aaabbb = [[int(i) for i in input().split()] for j in range(N-1)] #木の辺
pppxxx = [[int(i) for i in input().split()] for j in range(Q)] #操作

tree = [[] for i in range(N+1)]

for a,b in aaabbb: #aがbの親とは限らないのでこの表記はまずい
    if not b in tree[a]:
        tree[a].append(b)
    if not a in tree[b]:
        tree[b].append(a)

#print(tree)

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

for p,x in pppxxx:
    counter[p] += x

#print(counter)

visited = []

def dfs(pos):
    visited.append(pos)
    for next_pos in tree[pos]:
        if not next_pos in visited:
            counter[next_pos] += counter[pos]
            dfs(next_pos)

dfs(1)

#print(counter)

print(" ".join([str(i) for i in counter[1:]]))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,Q = [int(i) for i in input().split()] #N個の頂点、Q回の操作
aaabbb = [[int(i) for i in input().split()] for j in range(N-1)] #木の辺
pppxxx = [[int(i) for i in input().split()] for j in range(Q)] #操作

tree = [[] for i in range(N+1)]

for a,b in aaabbb:
    tree[a].append(b)
    tree[b].append(a)

#print(tree)

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

for p,x in pppxxx:
    counter[p] += x

#print(counter)

def dfs(pos,parent,add):
    counter[pos] += add
    for next_pos in tree[pos]:
        if not next_pos == parent:
            dfs(next_pos,pos,counter[pos])

dfs(1,0,0)

#print(counter)

print(" ".join([str(i) for i in counter[1:]]))
### BUGGY CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,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 queue import Queue,LifoQueue,PriorityQueue
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, k = MAP()
s = input()
count = 0
flag = 1
que = deque([0]*(2*k+1))
ans = 0
for x in s:
    if x == '0':
        if flag == 1:
            que.append(count)
            que.popleft()
            ans = max(ans, sum(que)) 
            count = 0
        flag = 0
        count += 1
    else:
        if flag == 0:
            que.append(count)
            que.popleft()
            count = 0
        flag = 1
        count += 1

que.append(count)
que.popleft()
if s[-1] == '0':
    que.popleft()
ans = max(ans,sum(que))
print(ans)

### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,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 queue import Queue,LifoQueue,PriorityQueue
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, k = MAP()
s = input()
count = 0
flag = 1
que = deque([0]*(2*k+1))
ans = 0
tmp = 0
for x in s:
    if x == '0':
        if flag == 1:
            que.append(count)
            tmp += count - que.popleft()
            ans = max(ans, tmp) 
            count = 0
        flag = 0
        count += 1
    else:
        if flag == 0:
            que.append(count)         
            tmp += count - que.popleft()
            count = 0
        flag = 1
        count += 1

que.append(count)
tmp += count - que.popleft()
if s[-1] == '0':
    tmp -= que.popleft()
ans = max(ans,sum(que))
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
abc = [[int(j) for j in input().split()] for _ in range(N-1)]
Q,K = map(int, input().split())
xy = [ [int(j) for j in input().split()] for _ in range(Q)]

inf = float("inf")
con = [ [] for _ in range(N+1)]
cost = [ [inf] * (N+1) for _ in range(N+1)]

for i in range(N-1):
    a,b,c = abc[i]
    con[a].append(b)
    con[b].append(a)
    cost[a][b] = c
    cost[b][a] = c

q = [(K,0)]
visited = [False] * (N+1)
visited[K] = True
costmap = [inf] * (N+1)
costmap[K] = 0
while q:
    n,cst = q.pop()
    for ch in con[n]:
        if visited[ch]:
            continue
        q.append( (ch, cst+cost[n][ch]))
        visited[ch] = True
        costmap[ch]  = cst+ cost[n][ch]
    
# def dfs(a,b, par):
#     if cost[a][b] != inf :
#         return cost[a][b]
# 
#     if len(list(filter(lambda x: x!=par, con[a]))) == 0:
#         return inf
# 
#     cst = inf
#     idx= -1
#     for e,ch in enumerate(con[a]):
#         if ch == par:
#             continue
#         if cst > cost[a][ch] + dfs(ch,b,a):
#             cst = cost[a][ch] + dfs(ch,b,a)
#             
#             idx = e
#     if idx != -1:
#         cost[a][b] = cst
#         cost[b][a] = cst
#     return cst
# 
for i in range(Q):
    x,y = xy[i]
    print( costmap[x] + costmap[y])
# for i in range(Q):
#     x,y = xy[i]
#     # _ = dfs(K,x,None)
#     # _ = dfs(y,K, None)
#     print(dfs(x,K,None) + dfs(K,y,None))
    


### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
abc = [[int(j) for j in input().split()] for _ in range(N-1)]
Q,K = map(int, input().split())
xy = [ [int(j) for j in input().split()] for _ in range(Q)]

inf = float("inf")
con = [ [] for _ in range(N+1)]
# cost = [ [inf] * (N+1) for _ in range(N+1)]
# cost = {}
from collections import defaultdict
# cost =  defaultdict(  )

for i in range(N-1):
    a,b,c = abc[i]
    con[a].append((b, c))
    con[b].append((a, c))

q = [(K,0)]
visited = [False] * (N+1)
visited[K] = True
costmap = [inf] * (N+1)
costmap[K] = 0
while q:
    n,cst = q.pop()
    for ch,chcst in con[n]:
        if visited[ch]:
            continue
        q.append( (ch, cst+chcst))
        visited[ch] = True
        costmap[ch]  = cst+ chcst
    
# def dfs(a,b, par):
#     if cost[a][b] != inf :
#         return cost[a][b]
# 
#     if len(list(filter(lambda x: x!=par, con[a]))) == 0:
#         return inf
# 
#     cst = inf
#     idx= -1
#     for e,ch in enumerate(con[a]):
#         if ch == par:
#             continue
#         if cst > cost[a][ch] + dfs(ch,b,a):
#             cst = cost[a][ch] + dfs(ch,b,a)
#             
#             idx = e
#     if idx != -1:
#         cost[a][b] = cst
#         cost[b][a] = cst
#     return cst
# 
for i in range(Q):
    x,y = xy[i]
    print( costmap[x] + costmap[y])
# for i in range(Q):
#     x,y = xy[i]
#     # _ = dfs(K,x,None)
#     # _ = dfs(y,K, None)
#     print(dfs(x,K,None) + dfs(K,y,None))
### BUGGY CODE ###

from collections import deque

n = int(input())
A = list(map(int, input().split()))
B = deque()
for i in range(n):
    B.append(A[i])
    B.reverse()
 
text = ""
for b in B:
    text += str(b) + " "
text = text[:-1]
print(text)

### FIXED CODE ###

from collections import deque

n = int(input())
A = list(map(int, input().split()))
B = deque()
for i in range(n):
    if(i%2 == 0):
        B.append(A[i])
    if(i%2 == 1):
        B.appendleft(A[i])

if(n%2 == 1):
    B.reverse()
text = ""
for b in B:
    text += str(b) + " "
text = text[:-1]
print(text)
### BUGGY CODE ###

nm=[int(x) for x in input().split()]
temp=[]
for x in range(1,int(nm[1]/nm[0])+1):
    if(nm[1]%x==0 and (nm[1]/x)>=nm[0]):
        temp.append(x)
print(int(max(temp)))

### FIXED CODE ###

n,m = map(int,input().split())
def getDivisor(inte):
    Ans1 = [1]
    Ans2 = [inte]
    for i in range(2,int(inte**(0.5))):
        if inte % i == 0:
            Ans1.append(i)
            Ans2.append(int(inte/i))
    if inte % inte**(0.5) == 0:
        Ans1.append(int(int(inte**(0.5))))
    Ans = Ans1 + Ans2[::-1]
    return Ans

limit = int(m/n)
for i in reversed(getDivisor(m)):
    if i <= limit:
        print(i)
        break
### BUGGY CODE ###

s = input()

n = len(s)

ans = 0
for i in range(0, n-3):
   j = 4
   while i + j <= n:
      x = int(s[i:i+j])
      if x % 2019 == 0:
         ans += 1
         j += 4
      else:
         j += 1
print(ans)


### FIXED CODE ###

s = input()[::-1] # reversed

cnt = [0] * 2019
cnt[0] = 1

num, d = 0, 1

for c in s:
   num += int(c) * d
   num %= 2019
   d *= 10
   d %= 2019
   cnt[num] += 1

ans = 0
for t in cnt:
   ans += t * (t - 1) // 2

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

import itertools
L, R = map(int, input().split())

remainder_list = [N%2019 for N in range(L, R+1)]
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))


### FIXED CODE ###

import itertools
L, R = map(int, input().split())

if R - L + 1 > 2019:
    remainder_list = [N%2019 for N in range(L, L+2019)]
else:
    remainder_list = [N%2019 for N in range(L, R+1)]  
remainder_list = list(set(remainder_list))
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))
### BUGGY CODE ###

if __name__ == "__main__":
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())
    a = list()
    for i in range(m):
        a.append(int(input()))

    dp = [0] * (n + 1)

    if 1 not in a:
        dp[1] = 1

    if n > 1:
        if 2 not in a:
            dp[2] = 1 + dp[1]

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

    print(dp[n])


### FIXED CODE ###

if __name__ == "__main__":
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())
    a = list()
    for i in range(m):
        a.append(int(input()))

    dp = [0] * (n + 1)

    for aa in a:
        dp[aa] = -1

    if dp[1] != -1:
        dp[1] = 1
    else:
        dp[1] = 0

    if n > 1:
        if dp[2] != -1:
            dp[2] = 1 + dp[1]
        else:
            dp[2] = 0

        for i in range(3, n+1):
            if dp[i] != -1:
                dp[i] = (dp[i-2] + dp[i-1]) % mod
            else:
                dp[i] = 0

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

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
set_s = set(s)
seq_s = "".join(s)
ans = 0
start_i = 0
used_s = {}
for i in range(n):
    cnt = used_s.get(s[i],seq_s.count(s[i],start_i) if s[i] in set_s else 0)
    ans += cnt - 1
    used_s[s[i]] = cnt - 1
    start_i += len(s[i])

print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

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

from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)
p2 = power // mn

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn // p2
ans2 = M // mn // (p2 * 2)
print(ans1-ans2)


### FIXED CODE ###

from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)
p2 = power // mn

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn // p2
ans2 = M // mn // (p2 * 2)
print(ans1-ans2)
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
sum = K ** 2
for a in range(2,K+1) :
    for b in range(1,K+1) :
        for c in range(1,K+1) :
            sum += gcd(a, b, c)

print(sum)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
sum = K ** 2
for a in range(2,K+1) :
    for b in range(1,K+1) :
        if gcd(a,b) == 1 :
            sum += K
        else :
            for c in range(1,K+1) :            
                sum += gcd(a, b, c)
            
print(sum)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
seki = 1
for i in range(N):
  seki *= A[i]
if seki <= 10**18:
  print(seki)
else:
  print(-1)

### FIXED CODE ###

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

if 0 in A:
  print(0)
else:
  for i in range(N):
    if seki <= 10**18:
      seki *= A[i]
    else:
      break
  if seki <= 10**18:
    print(seki)
  else:
    print(-1)
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
T = []
D = []
for i in range(N):
  t, d = map(int, input().split())
  T.append(t)
  D.append(d)

idx = np.argsort(D)[::-1]

res = 0
for x in range(1,N+1):
  used = {}
  m = 0
  k = 0
  y = 0
  for i in idx:
    if m == x:
      break
    if k == K:
      break
    t = T[i]
    d = D[i]
    if x - m == K - k:
      if t in used:
        continue
    if t not in used:
      used[t] = 1
      m += 1
    y += d
    k += 1
    res = max(res, m*m+y)
print(res)

### FIXED CODE ###

from heapq import heappush, heappop

N, K = map(int, input().split())
h = []
for i in range(N):
  t, d = map(int, input().split())
  heappush(h, (-d, t))

# initial
res = 0
sum = 0
q = []
used = {}
for i in range(K):
  (d, t) = heappop(h)
  if t not in used:
    used[t] = 1
  else:
    heappush(q, (-d, t))
  sum += -d
res = len(used)*len(used)+sum

# swap minimum
while q and h:
  (d, t) = heappop(h)
  if t not in used:
    used[t] = 1
    m, _ = heappop(q)
    sum = sum - m - d
  res = max(res, len(used)*len(used) + sum)
  
print(res)
### BUGGY CODE ###

from collections import Counter as counter
from sys import stdin 

N = int(stdin.readline().rstrip())
char_counts = [sorted(stdin.readline().rstrip()) for _ in range(N)]
counts = [list(map(lambda x: x == c, char_counts[i+1:]))  for i, c in enumerate(char_counts)]
match_count = sum(list(map(sum, counts)))
print(match_count)

### FIXED CODE ###

N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = np.ones((42, N), dtype = "int64")
for k in range(len(A)):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        for k in range(N):
            for j in range(1, min(foo[q][k]+1, N-k)):
                foo[q+1][k+j] +=1
            for j in range(1, min(foo[q][k]+1, k+1)):
                foo[q+1][k-j] +=1
        count =0
        for l in range(N):
            if foo[q+1][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q+1])))

     
else:
    print((str(N)+" ")*(N-1)+str(N))




### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = [[0 for k in range(N)] for k in range(42)]
for k in range(len(A)):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        unko = [0 for k in range(N)]
        for k in range(N):
            if k + foo[q][k]+1 < N:
                unko[k + foo[q][k]+1] -=1
            unko[max(k - foo[q][k], 0)] +=1
        unchi = 0
        for k in range(N):
            unchi += unko[k]
            foo[q+1][k] = unchi
        #print(unko)
        #print(foo[q+1])
        count =0
        for l in range(N):
            if foo[q+1][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q+1])))

     
else:
    print((str(N)+" ")*(N-1)+str(N))
### BUGGY CODE ###

N = int(input())
MOD = 998244353
def func(x):
    a = [23,26]
    out = 1
    for i in range(30):
        if not i in a:
            out = (out*x)%MOD
        x *= x
        x %= MOD
    return out

def func2(x):
    x = bin(x)[2:]
    out = 1
    b = 3
    for i in range(len(x)):
        if x[-1-i] == "1":
            out *= b
            out %= MOD
        b *= b
        b %= MOD
    return out

ans = 0
d = 1
for i in range((N//2)):
    ans += d * 2**i
    ans %= MOD
    d = ((N-i)*d)%MOD
    d = (d*func(i+1))%MOD

print((func2(N)-ans*2)%MOD)

### FIXED CODE ###

N = int(input())
MOD = 998244353

list_size = 10000010

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)


def conv(n,r):
    if r == 0:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

ans = 0
for i in range((N//2)):
    ans += conv(N,i) * pow(2,i,MOD)
    ans %= MOD

print((pow(3,N,MOD)-ans*2)%MOD)
### BUGGY CODE ###

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

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

for i in range(n):
    af.append(factorize(a[i]))
del af[0]

cnt = 0

for i in range(len(af)):
    for j in range(len(af[i])):
        if af[i][j] == 2:
            cnt += 1

print(cnt)

### FIXED CODE ###

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

cnt = 0

for i in range(n):
    while(True):
        if a[i] % 2 != 0:
            break
        else:
            a[i] = int(a[i] / 2)
            cnt += 1

print(cnt)
### BUGGY CODE ###

from fractions import gcd
import sys

input = sys.stdin.readline

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

MOD = 10 ** 9 + 7


def lcm(a, b):
    return a * b // gcd(a, b)


l = A[0]
for a in A:
    l = lcm(l, a)

res = 0
for a in A:
    res = (res + l // a) % MOD

print(res)


### FIXED CODE ###

from fractions import gcd
import sys

input = sys.stdin.readline

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

MOD = 10 ** 9 + 7


def lcm(a, b):
    return a * b // gcd(a, b)


l = A[0]
for a in A:
    l = lcm(l, a)

res = 0
for a in A:
    res = (res + (l * pow(a, MOD - 2, MOD)) % MOD) % MOD
    # res = (res + l // a) % MOD

print(res)
### BUGGY CODE ###

n = int(input())
num = list(map(int, input().split()))
SetNum = list(set(num))
lenghtNum = len(SetNum)
box = [0]*lenghtNum
for i in range(lenghtNum):
  a = num.count(SetNum[i])
  box[i] = a*(a-1)/2 #要素SetNum[i]の組み合わせの数

for j in num:
  b = SetNum.index(j)
  c = num.count(j)
  if box[b] <= 2:
    d = box[b]
    box[b] = 0
    print(int(sum(box)))
    box[b] = d
  else:
    box[b] = box[b]/c*(c-2)
    print(int(sum(box)))
    box[b] = box[b]*c/(c-2)


### FIXED CODE ###

import collections
n = int(input())
arr = list(map(int, input().split()))
cnt = collections.Counter(arr)
total = 0
for i in cnt.keys():
  patern = cnt[i]*(cnt[i]-1)//2
  total += patern
for j in range(n):
  tmp = total
  total -= cnt[arr[j]]*(cnt[arr[j]]-1)//2
  total += (cnt[arr[j]]-1)*(cnt[arr[j]]-2)//2
  print(total)
  total = tmp
### BUGGY CODE ###

from itertools import product

def solve():
  n, k = map(int, input().split())
  count = 0
  # A解法
  for a in range(n):
    a += 1
    for b in range(n):
      b += 1
      for c in range(n):
        c += 1
        if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
          count += 1

  # B解法
  # ary = [(a, b, c)
  #   for a in range(n)
  #   for b in range(n)
  #   for c in range(n)]
  
  # for a, b, c in ary:
  #   if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
  #     count += 1

  # C解法
  # a = range(1, n+1)
  # for i in range(1, n+1):
  #   b = i


  
  print(count)


solve()

### FIXED CODE ###

def solve():
  n, k = map(int, input().split())
  
  divList = [0 for _ in range(k)]
  for i in range(1, n+1):
    divList[i % k] += 1
  
  count = 0
  for i in range(k):
    if (i*2) % k ==0:
      count += divList[i] ** 3
  print(count)
solve()
### BUGGY CODE ###

K=int(input())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

ans=0

for a in range(1,K+1):
    for b in range(1,K+1):
        hoge=gcd(a,b)
        for c in range(1,K+1):
            g=gcd(hoge,c)
            ans += g

print(ans)

### FIXED CODE ###

K=int(input())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

ans=0
re=[1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]

if K < 102:
    for a in range(1,K+1):
        for b in range(1,K+1):
            hoge=gcd(a,b)
            for c in range(1,K+1):
                g=gcd(hoge,c)
                ans += g
else:
    ans=re[K-101]



print(ans)