You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.

# Buggy version:
N,M=input().split()
N=int(N)
M=int(M)
if M%2==0:
  print((N/M)**3+((N+M/2)/M)**3)
else:
  print((N/M)**3)

# Fixed version:
N,M=input().split()
N=int(N)
M=int(M)
if M%2==0:
  print(int(N/M)**3+int((N+M/2)/M)**3)
else:
  print(int(N/M)**3)

# Buggy version:
n,k=list(map(int,input().split()))
r=0
r+=(n//k)**3
if k%2==0:
  r+=((n-k//2)//k)**3
print(r)

# Fixed version:
n,k=list(map(int,input().split()))
r=0
r+=(n//k)**3
if k%2==0:
  r+=((n+k//2)//k)**3
print(r)

# Buggy version:
N, K = map(int, input().split())

if(K%2 != 0):
    a = N//K
    print(a**3)
else:
    a = N//K
    if(K*a+K//2 >= N):
        b = a+1
    else:
        b = a
    print(a**3+b**3)

# Fixed version:
N, K = map(int, input().split())

if(K%2 != 0):
    a = N//K
    print(a**3)
else:
    a = N//K
    if(N%K >= K//2):
        b = a+1
    else:
        b = a
    print(a**3+b**3)

# Buggy version:
# 奇数の時
# a，b，cはkの倍数
# kが偶数
# a, b, cがkの倍数
#　もしくは，全てk/2の倍数

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

if K % 2 != 0:
    n = N // K 
    print(n ** 3)

else:
    n = N // K
    half_n = N // (K//2)
    print(half_n)
    print(n ** 3 + (half_n - n)** 3)

# Fixed version:
# 奇数の時
# a，b，cはkの倍数
# kが偶数
# a, b, cがkの倍数
#　もしくは，全てk/2の倍数

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

if K % 2 != 0:
    n = N // K 
    print(n ** 3)

else:
    n = N // K
    half_n = N // (K//2)
    print(n ** 3 + (half_n - n)** 3)

# Buggy version:
N,K=map(int,input().split())
u1, u2=divmod(N,K)
ans=u1*3

A=[u1]*K
for i in range(u2):
    A[i+1]+=1
if K%2==0:
    ans+=A[K//2+1]*3
print(ans)

# Fixed version:
N,K=map(int,input().split())
u1=N//K
u2=N%K
ans=u1**3

A=[u1]*K
for i in range(u2):
    A[i+1]+=1
if K%2==0:
    ans+=A[K//2]**3
print(ans)

# Buggy version:
n,k = map(int,input().split())
count = 0
count += (n//k) ** 3 
print(int(count))
if k % 2 == 0:
    count += ((n + k/2) // k) ** 3
print(int(count)) 


# Fixed version:
n,k = map(int,input().split())
count = 0
count += (n//k) ** 3 
if k % 2 == 0:
    count += ((n + k/2) // k) ** 3
print(int(count))

# Buggy version:
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


def main():
    N, K = MI()
    num_factor_K = N // K
    ret = num_factor_K ** 3
    print(ret)
    
    if K % 2 == 0:
        num_factor_half_K = N // K
        if N % K >= K // 2:
            num_factor_half_K += 1
        ret += num_factor_half_K ** 3
        
    print(ret)
    

if __name__ == "__main__":
    main()

# Fixed version:
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


def main():
    N, K = MI()
    num_factor_K = N // K
    ret = num_factor_K ** 3
    
    if K % 2 == 0:
        num_factor_half_K = N // K
        if N % K >= K // 2:
            num_factor_half_K += 1
        ret += num_factor_half_K ** 3
        
    print(ret)
    

if __name__ == "__main__":
    main()

# Buggy version:
def main():
    N, K = map(int, input().split())

    if K % 2 != 0:
        ans = (N // K)**3
    else:
        n = N // K
        if (n + 0.5) * K >= N:
            ans = (n + 1)**3 + n**3
        else:
            ans = 2 * n**3

    print(ans)


main()


# Fixed version:
def main():
    N, K = map(int, input().split())

    if K % 2 != 0:
        ans = (N // K)**3
    else:
        n = N // K
        if (n + 0.5) * K <= N:
            ans = (n + 1)**3 + n**3
        else:
            ans = 2 * n**3

    print(ans)


main()

# Buggy version:
n,k=map(int,input().split())
if k%2==1:
    print((n//k)**3)
else:
    kk=k//2
    cnt=0
    for i in range(1,n+1):
        if i//k==kk:
            cnt+=1
    print((n//k)**3+cnt**3)

# Fixed version:
n,k=map(int,input().split())
if k%2==1:
    print((n//k)**3)
else:
    kk=k//2
    cnt=0
    for i in range(1,n+1):
        if i%k==kk:
            cnt+=1
    print((n//k)**3+cnt**3)

# Buggy version:
def main():
    n,k = map(int,input().split())
    if k%2==1:
        a=n//k
        print(a**3)
    else:
        a=n//k
        b=(n+k//2)//k
        print(a,b)
        print(a**3+b**3)

if __name__ == "__main__":
    main()

# Fixed version:
def main():
    n,k = map(int,input().split())
    if k%2==1:
        a=n//k
        print(a**3)
    else:
        a=n//k
        b=(n+k//2)//k
        print(a**3+b**3)

if __name__ == "__main__":
    main()

# Buggy version:
N, K = map(int, input().split())

# Kが偶数の場合, 全てKの倍数または全てK//2に倍数の両方考える必要あり
num = [0]*(K)  # 1以上N以下の整数で余りが0~K-1の個数をカウントする
for i in range(1, N+1):
    num[i % K] += 1  # i % K の取りうる値は0~K-1

ans = 0
for a in range(K+1):  # aに関して全探索を行う
    b = (K-a) % K
    c = (K-a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]

print(ans)


# Fixed version:
N, K = map(int, input().split())

# Kが偶数の場合, 全てKの倍数または全てK//2に倍数の両方考える必要あり
num = [0]*(K+1)  # 1以上N以下の整数で余りが0~K-1の個数をカウントする
for i in range(1, N+1):
    num[i % K] += 1  # i % K の取りうる値は0~K-1

ans = 0
for a in range(K+1):  # aに関して全探索を行う
    b = (K-a) % K
    c = (K-a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]

print(ans)

# Buggy version:
n,k=map(int,input())
if k%2:
  print((n//k)**3)
else:
  l=k//2
  if l%2:
    print(((n+l)//k)**3)
  else:
    print(((n+l)//k)**3 + (n//k)**3)

# Fixed version:
n,k=map(int,input().split())
if k%2:
  print((n//k)**3)
else:
  l=k//2
  print(((n+l)//k)**3+(n//k)**3)

# Buggy version:
N, K = map(int, input().split())

if K%2 == 1:
  cand = N // K
  print(int(cand + comb(cand,2) * 6 + comb(cand,3) * 6))
else:
  cand_mod0 = N // K
  ans_mod0 = cand_mod0\
           + cand_mod0 * (cand_mod0-1) * 3\
           + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)
  cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1
  ans_modhalf = cand_modhalf\
           + cand_modhalf * (cand_modhalf-1) * 3\
           + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)
  print(int(ans_mod0 + ans_modhalf))

# Fixed version:
N, K = map(int, input().split())

if K%2 == 1:
  cand = N // K
  ans = cand\
      + cand * (cand-1) * 3\
      + cand * (cand-1) * (cand-2)
  print(int(ans))
else:
  cand_mod0 = N // K
  ans_mod0 = cand_mod0\
           + cand_mod0 * (cand_mod0-1) * 3\
           + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)
  cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1
  ans_modhalf = cand_modhalf\
           + cand_modhalf * (cand_modhalf-1) * 3\
           + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)
  print(int(ans_mod0 + ans_modhalf))

# Buggy version:
n,k=map(int,input().split())
if k%2==1:
  print((n//k)**3)
else:
  j=n//(k//2)
  print(j)
  if j %2==0:
    print(2*((j//2)**3))
  else:
    print(((j//2)**3)+((j//2+1)**3))
          


# Fixed version:
n,k=map(int,input().split())
if k%2==0:
    q=n//(k//2)
    if q%2==0:
        print(2*(q//2)**3)
    else:
        print((q//2)**3+((q//2)+1)**3)
else:
    print((n//k)**3)

# Buggy version:
import math
import sys


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    if n % 2 == 1:
        return math.floor(n / k) ** 3
    else:
        return math.floor(n/k) ** 3 + math.floor(n * 3 / 2 / k) ** 3


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

# Fixed version:
import math
import sys


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    if k % 2 == 1:
        return math.floor(n / k) ** 3
    else:
        return math.floor(n / k) ** 3 + math.floor((n + k/2) / k) ** 3


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

# Buggy version:
# coding: utf-8
# Your code here!

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

hk = 0

ans = (n//k)**3


if k%2==0:
    n -= k//2
    ans += (((n*2)//k)**3)
    
print(ans)

# Fixed version:
# coding: utf-8
# Your code here!

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

hk = 0

ans = (n//k)**3

if k%2==0:
    n -= k//2
    ans += (n//k +1)**3
    
print(ans)

# Buggy version:
n, k = map(int, input().split())

max_alpha = 2 * n // k
if k % 2 == 0:
    print((max_alpha - 1) ** 3)
else:
    print((max_alpha // 2) ** 3)


# Fixed version:
n, k = map(int, input().split())

max_alpha = 2 * n // k
if k % 2 == 0:
    if max_alpha % 2 == 0:
        ans = 2 * ((max_alpha / 2) ** 3)
    else:
        ans = ((max_alpha + 1) /2) ** 3 + ((max_alpha - 1) /2) ** 3
else:
    ans = (max_alpha // 2) ** 3
print(int(ans))

# Buggy version:
N, K = map(int, input().split())
if K%2==1:
  print((N//K)**3)
else:
  print((N//K)**3 + (((N//2)//K) - (N//K))**3)

# Fixed version:
N, K = map(int, input().split())
if K % 2 == 0:
  print(int((N // K) ** 3 + ( (N // (K/2)) - N // K ) ** 3))
else:
  print(int((N // K) ** 3))

# Buggy version:
from decimal import Decimal, ROUND_HALF_UP
n,k = map(int,input().split())
ans = 0
if k % 2 ==0:
    k = Decimal(n/k).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
    ans = k**3 +(n//k)**3
else:
    ans = (n // k)**3
print(ans)

# Fixed version:
from decimal import Decimal, ROUND_HALF_UP
n,k = map(int,input().split())
ans = 0
if k % 2 ==0:
    p = Decimal(n/k).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
    ans = p**3 +(n//k)**3
else:
    ans = (n // k)**3
print(ans)

# Buggy version:
a,b = map(int,input().split())

if b%2 != 0:
  print(pow(a//b,3))
else:
  print(pow(a,2))

# Fixed version:
a,b = map(int,input().split())

if b%2 != 0:
  print(pow(a//b,3))
else:
  print(pow(a//b,3)+pow(((a+b//2)//b),3))

# Buggy version:
n, k = map(int, input().split())

ans = pow(n // k, 3)
if k % 2 == 0:
  ans += pow((n + n // 2) // k, 3)
print(ans)

# Fixed version:
n, k = map(int, input().split())
ans = (n // k) ** 3
if k % 2 == 0:
    ans += ((n + k // 2) // k) ** 3
print(ans)

# Buggy version:
a, b=map(int, input().split())
try:
    c = a // (b // 2)
    c = c //2 + c% 2
except Exception as  e:
    c = 0
try:
    d = a // b
except Exception as e:
    d = 0
    print(c**3 + d **3)

# Fixed version:
a, b=map(int, input().split())
try:
    c = a // (b // 2)
    c = c //2 + c%2
except Exception as  e:
    c = 0
if b % 2 == 1:
    c = 0
try:
    d = a // b
except Exception as e:
    d = 0
print(c**3 + d**3)

# Buggy version:
N,K=map(int,input().split())
if K%2==1:
  print(((N//K)+1)**3)
else:
  a=K//2
  if a%2==1:
    b=(a//2)+1
    print(2*(b**3))
  else:
    b=(a//2)+1
    c=a//2
    print(b**3+c**3)

# Fixed version:
N,K = map(int,input().split())

if K%2:
    a = N//K
    print(a**3)
else:
    a = N//K
    b = (N+K//2)//K
    print(a**3 + b**3)

# Buggy version:
n,k=map(int,input().split())
q=n//k
r=n%k
if k%2==1:
    print(q**3)
elif(q*k+k//2<n):
    print(q**3+(q+1)**3)
else:
    print(q**3+q**3)

# Fixed version:
n,k=map(int,input().split())
q=n//k
r=n%k
if k%2==1:
    print(q**3)
elif(q*k+k//2<=n):
    print(q**3+(q+1)**3)
else:
    print(q**3+q**3)

# Buggy version:

import math
 
n, k = map(int, input().split())
c = 0
 
if k%2==0:
    if math.floor(2*n/k)%2==0:
        d=math.floor(2*n/k)
        c=2*d*d*d
    else:
        d=(math.floor(2*n/k)+1)
        c=d*d*d+(d-1)*(d-1)*(d-1)
    print(int(c))
else:
    d=math.floor(n/k)
    c=d*d*d
    print(int(c))


# Fixed version:

import math
 
n, k = map(int, input().split())
c = 0
 
if k%2==0:
    if math.floor(2*n/k)%2==0:
        d=math.floor(2*n/k)/2
        c=2*d*d*d
    else:
        d=(math.floor(2*n/k)+1)/2
        c=d*d*d+(d-1)*(d-1)*(d-1)
    print(int(c))
else:
    d=math.floor(n/k)
    c=d*d*d
    print(int(c))

# Buggy version:
N,K=map(int,input().split())

if K <=2:
  print(N*N*N)
else:
  if K%2 == 0:
    div = N//(K//2)
    if div%2 > 0:
      div = div//2
      print((div*div*div) + (div+1)*(div+1)*(div+1))
    else:
      print(div*div*div)
  else:
    div = N//K
    print(div*div*div)

# Fixed version:
N,K=map(int,input().split())
 
if K%2 == 0:
  div = N//(K//2)
  if div%2 > 0:
    div = div//2
    print((div*div*div) + (div+1)*(div+1)*(div+1))
  else:
    div = div//2
    print(div*div*div*2)
else:
  div = N//K
  print(div*div*div)

# Buggy version:
n,k=map(int, input().split())
if k%2==0:
    x=0
    y=0
    for i in range(1,n+1):
        if i%k==k//2:
            x+=1
        if i%k==0:
            y+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    if y>=1:
        ans+=com(y,1)
    if y>=2:
        ans+=6*com(y,2)
    if y>=3:
        ans+=6*com(y,3)
    print(ans)
else:
    x=0
    for i in range(1,n+1):
        if i%k==0:
            x+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    print(ans)
    
def com(a,b):
    r=1
    for i in range(b):
        r*=(a-i)
        r//=i+1
    return r

# Fixed version:
n,k=map(int, input().split())
def com(a,b):
    r=1
    for c in range(b):
        r*=(a-c)
        r//=c+1
    return r
if k%2==0:
    x=0
    y=0
    for i in range(1,n+1):
        if i%k==k//2:
            x+=1
        if i%k==0:
            y+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    if y>=1:
        ans+=com(y,1)
    if y>=2:
        ans+=6*com(y,2)
    if y>=3:
        ans+=6*com(y,3)
    print(ans)
else:
    x=0
    for i in range(1,n+1):
        if i%k==0:
            x+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    print(ans)

# Buggy version:
n,k=map(int,input().split())
ans=0
for i in range(1,n//k+1):
  i*=k
  if i%2==0:
    i//=2
  ans+=(n//i)**3
print(ans)

# Fixed version:
n, k = map(int, input().split(' '))

ans = int(n / k) ** 3

if k % 2 == 0:
    cnt = 0
    for i in range(1, n + 1):
        if i % k == k / 2:
            cnt += 1
    ans += cnt ** 3

print(ans)

# Buggy version:
n,k=map(int,input().split())
if k%2:
  print((n//k)**3)
else:
  l=k//2
  if l%2:
    print(((n+l)//k)**3)
  else:
    print(((n+l)//k)**3 + (n//k)**3)

# Fixed version:
n, k = map(int, input().split())

if k % 2 == 0:
    m = n // k
    l = (n+(k//2))//k
    print(m**3+l**3)
else:
    m = n // k
    print(m**3)

# Buggy version:
n,k=map(int,input().split())
if k%2==0:
    x=(n+k/2)//k
    y=n//k
    print(x**3+y**3)
else:
    x=n//k
    print(x**3)


# Fixed version:
n, k = map(int, input().split())

if k % 2 == 0:
    x = n // k
    y = (2 * n // k) - x
    ans = x ** 3 + y ** 3
else:
    ans = (n // k) ** 3

print(ans)

# Buggy version:

def getIntList():
    return list(map(int, input().split()))    

N, K = getIntList()

res = 0
c1 ==0
c2 ==0
if K %2 ==0:
    t = K//2
else:
    t= -1

if True:
    for i in range(1,N+1):
        if i%K == t:
            c1+=1
        if i%K ==0:
            c2+=1
res =  c1 **3 + c2** 3
print(res)

# Fixed version:
def getIntList():
    return list(map(int, input().split()))    
 
N, K = getIntList()
 
res = 0
c1 =0
c2 =0
if K %2 ==0:
    t = K//2
else:
    t= -1
 
if True:
    for i in range(1,N+1):
        if i%K == t:
            c1+=1
        if i%K ==0:
            c2+=1
res =  c1 **3 + c2** 3
print(res)

# Buggy version:
N, K = map(int, input().split())

if K%2 == 1:
	print((N//K)**3)
    
else:
	print((N//(K/2)//2)**3+((N+(K/2))//(K/2)//2)**3)

# Fixed version:
N, K = map(int, input().split())

if K%2 == 1:
    print((N//K)**3)
else:
    print((N//K)**3 + max(0, ((N+K//2)//K))**3)

# Buggy version:
n,k=map(int,input().split())
ans=0
for i in range(1,n//k+1):
  i*=k
  if i%2==0:
    ans+=(n//(i//2)-n//i)**3
  ans+=(n//i)**3
print(ans)

# Fixed version:
n,k = (int(i) for i in input().split())
ans = (n//k)**3
if k%2==0: ans += (((n-k//2)//k)+1)**3
print(ans)

# Buggy version:
n,k=map(int,input().split())
if k%2==1:
  print((n//k)**3)
else:
  print((n//(k//2))**3+(n//k-n//(k//2))**3)

# Fixed version:
n, k = map(int, input().split())

if k%2 == 1:
    a = n//k
    print(a**3)
else:
    a = n//k
    b = (n-(k//2))//k + 1
    print(a**3 + b**3)