Problem:
 Score : 300 points    Problem Statement You are given 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 does matter, and some of them can be the same.      Constraints  1 \leq N,K \leq 2\times 10^5  N and K are integers.         Input Input is given from Standard Input in the following format:  N  K       Output Print 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 .        Sample Input 1 3 2      Sample Output 1 9  (1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.       Sample Input 2 5 3      Sample Output 2 1       Sample Input 3 31415 9265      Sample Output 3 27       Sample Input 4 35897 932      Sample Output 4 114191

Solution (Python):
n,k=map(int,input().split())
count,point=0,0
if k%2!=0:
    while k*(count+1)<=n:
        count +=1
    print(count**3)
else:
    for i in range(1,n+1):
        if i%k==0:point +=1
        elif i*2%k==0:count +=1
    print(count**3+point**3)

Solution (Python):
n,k=map(int,input().split())
count=0
point=0
if k%2!=0:
    while k*(count+1)<=n:
        count +=1
    print(count**3)
else:
    for i in range(1,n+1):
        if i%k==0:
            point +=1
        elif 2*i%k==0:
            count +=1
    print(count**3+point**3)

Solution (Python):
N, K = list(map(int, input().split()))
c = N // K
d = 0
for i in range(1, N + 1):
    if K % 2 == 0 and i % K == K // 2:
        d += 1
print(c ** 3 + d ** 3)

Solution (Python):
import math
line = raw_input()
N, K = [int(s) for s in line.split(' ')]
ret = []
if K % 2 == 1:
    count = N // K
    print count * count * count
else:
    k = K / 2
    count = int(math.ceil(N / k))
    odds = count // 2
    evens = count - odds
    all_counts = odds * odds * odds + evens * evens * evens
    print all_counts

Solution (Python):
n, k = map(int, input().split())
ret = (n // k) ** 3
if k % 2 == 0:
    ret += ((n + k // 2) // k) ** 3
print(ret)

Solution (Python):
N,K = map(int, input().split())
ans = 0

mod0 = N // K
if K % 2 == 0:
    modk2 = mod0
    if N % K >= K // 2:    modk2 += 1 
else:
    modk2 = 0

print(mod0**3 + modk2**3)

Solution (Python):
N,K = [int(x) for x in input().split()]
if K%2==0:
  a = int(N/K)
  b = int(N/(K//2))-a
  print(a**3+b**3)
else:
  a = int(N/K)
  print(a**3)

Solution (Python):
from collections import Counter


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

A = [0] * N
for i in range(N):
    A[i] = (i + 1) % K

Acount = Counter(A)

ans = 0
for mod, times in Acount.items():
    mod_anti = K - mod
    if (K - mod) * 2 % K == 0:
        ans += Acount[mod] ** 3


print(ans)

Solution (Python):

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

Solution (Python):
n,k = map(int,input().split())

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

Solution (Python):
n,k=map(int,input().split())
if k%2==0:
    kk=k//2
    num1=n//k
    num2=(n-kk)//k+1
    ans=num1**3+num2**3


else:
    num=n//k
    ans=num**3
print(ans)

Solution (Python):
n, k = map(int, input().split())
if k%2 == 1:
  ans = (n//k)**3
  print(ans)

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

Solution (Python):
n, k = map(int, input().split())
if k%2 == 1:
  ans = (n//k)**3
  print(ans)

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

Solution (Python):
n,k = map(int, input().split())
count0 = 0
count1 = 0
for i in range(1,n+1):
    if i%k==0:
        count0 +=1
    if i%k==k/2:
        count1 +=1

if k%2==0:
    print(count0**3+count1**3)
else:
    print(count0**3)

Solution (Python):

def main():
    N, K = map(int, input().split())
    if K%2==0:
        A = N//K
        B = N//(K//2)
        print(A**3+(B-A)**3)
    else:
        A = N//K
        print(A**3)
if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
ans = (N//K)**3
if K % 2 == 0:
  ans += ((N+(K//2))//K)**3
print(ans)

Solution (Python):
N, K = map(int,input().split())
count_0 = 0
count_2 = 0

for i in range(1,N+1):
    if i % K == 0:
        count_0 += 1
    if i % K == K / 2:
        count_2 += 1
if K % 2 == 0:
    print(count_0**3 + count_2**3)
else:
    print(count_0**3)

Solution (Python):
N, K = map(int, input().split())
ans = 0
M1 = []
M2 = []
M1 = [a for a in range(N+1) if a % K == 0]
M1.pop(0)
if K % 2 == 0:
    M2 = [a for a in range(N+1) if a % K == K//2]
print(len(M1)**3 + len(M2)**3)

Solution (Python):
import sys
input = sys.stdin.readline

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

Solution (Python):



n,k=map(int,input().split())
cnt=0
num=[0]*(k+1)
for i in range(1,n+1):
    num[i%k]+=1

for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k:continue
    cnt+=num[a]*num[b]*num[c]
    
print(cnt)

Solution (Python):



n,k=map(int,input().split())
cnt=0
a=n//k
b=(n+(k//2))//k if k%2==0 else 0
print(a**3+b**3)

Solution (Python):
n, k = map(int,input().split())

numl = []
numl2 = []

for i in range(1,n+1):
  if (i%k == 0):
    numl.append(i)

if k%2 == 0:
  for i in range(1,n+1):
    if (i%k == k//2):
      numl2.append(i)

num = len(numl)
num2 = len(numl2)
ans = num**3 + num2**3

print(ans)

Solution (Python):
N, K = map(int, input().split())

ans = (N // K) ** 3

if K % 2 == 0:
    ans += ((N + K//2) //K) ** 3

print(ans)

Solution (Python):
n, k = [int(x) for x in input().split()]
a = n//k
b = 0
if k % 2 == 0:
  b = n//(k//2)-n//k;
print(a**3 + b**3)

Solution (Python):
N, K = map(int, input().split())
ans = 0
if K % 2 != 0:
    ans = (N // K) ** 3
else:
    tmp1 = K // 2
    tmp2 = (N // tmp1) - (N // K)
    ans = (N // K) ** 3 + tmp2 ** 3

print(ans)

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
import sys
input=sys.stdin.readline

def main():
    N,K = map(int,input().split())
    r1 = 0
    for i in range(1,N+1):
        if i%K == 0:
            r1 += 1
    if K%2 == 1:
        print(r1**3)
    else:
        r2 = 0
        for i in range(1,N+1):
            if i%K == K//2:
                r2 += 1
        print(r1**3+r2**3)
    
if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int,input().split())
if k%2 != 0:
  print((n//k)**3)
else:
  print(
    ((2*n//k)//2)**3
    +
    (-(-(2*n//k)//2))**3
    )

Solution (Python):
n, k = map(int, input().split())
if k % 2:
    a = n // k
    print(a ** 3)
else:
    a = n // k
    b = n // (k // 2)
    print(a ** 3 + (b-a) ** 3)

Solution (Python):
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)

Solution (Python):
N, K = map(int, input().split())

if K % 2 == 0:
    list_abc = []
    list_abc_2 = []
    for i in range(1, N + 1):
        if i % K == 0:
            list_abc.append(i)
        elif i % K == (K / 2):
            list_abc_2.append(i)
    print(len(list_abc) ** 3 + len(list_abc_2) ** 3)


else:
    list_abc = []
    for i in range(1, N + 1):
        if i % K == 0:
            list_abc.append(i)
    print(len(list_abc) ** 3)

Solution (Python):
n, k = map(int, input().split())
result = (n // k) ** 3
if k % 2 == 0:
  result += (n // (k // 2) - (n // k)) ** 3
print(result)

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

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
from math import ceil 

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

count = 0
num = n // k
bb = [(i+1)*k for i in range(num) ]
s = len(bb) 
count += s + 3*s*(s-1) + s*(s-1)*(s-2)  

if k % 2 == 0:    
  bb=[]
  tmp = k//2  
  while tmp <= n:
    bb.append(tmp)
    tmp += k      
  s = len(bb)
  count += s + 3*s*(s-1) + s*(s-1)*(s-2)

print(count)

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

Solution (Python):
N,K = map(int, input().split())

if K%2 == 1:
    M = N//K
    print(M*M*M)
else:
    M = 2*N//K
    if M%2 == 0:
        evenM = M//2
        oddM = M//2
    else:
        evenM = (M-1)//2
        oddM = (M+1)//2
    print(evenM*evenM*evenM + oddM*oddM*oddM)

Solution (Python):
N, K = map(int, input().split())
if K%2 == 1:
  r = (N//K)**3
if K%2 == 0:
  r = (N//K)**3 + ((N+K//2)//K)**3
print(r)

Solution (Python):
N,K=[int(s) for s in input().split()]
if K%2==1:
  
  a=N//K
  print(a**3)
else:
  ans=0
  
  a=N//K
  ans+=a**3
  
  b=N//(K//2)
  ans+=(b-a)**3
  print(ans)

Solution (Python):
N,K = map(int,input().split())


"""考え方
Kが奇数か否か、1か、で考える。

1.K=1
N**3

2.Kが偶数
「全てN以下のKの倍数」、「全てがx*K/2」のいずれか。

3.Kが奇数
全ての値が、「Kの倍数」でないといけない。
なので、N以下のKの倍数の個数をカウントし、3乗する。
"""

base = int(N//K)**3

if K%2 == 0:
  tmp = N + K // 2
  add_pattern = (tmp // K)**3
  print(base+add_pattern)
else:
  print(base)

Solution (Python):
n, k = map(int, input().split())

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
if k == 1:
  print(n ** 3)
elif k%2 == 0:
  print(int(n//k)**3 + int((n+k/2)//k)**3)
else:
  print(int(n//k)**3)

Solution (Python):
n, k = map(int, input().split())

ans1 = (n//k)**3
ans2 = 0
if k % 2 == 0:
    if n % k >= k // 2:
        ans2 = (n//k+1)**3
    else:
        ans2 = (n//k)**3
print(ans1+ans2)

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):


import copy
import itertools
N, K = list(map(int, input().split()))
ab_list = []










if K % 2 == 0:
    a_list = [x for x in range(1, N + 1) if x % K == 0]
    p = len(a_list) ** 3
    a_list = [x for x in range(1, N + 1) if (x % (0.5 * K)) == 0 and not (x % K == 0)]
    p += len(a_list) ** 3
else:
    a_list = [x for x in range(1, N + 1) if x % K == 0]
    p = len(a_list) ** 3

print(p)

Solution (Python):
def solve():
    N, K = map(int, input().split())
    count = 0
    is_k_even = K%2 == 0
    
    half_k_mod = 0
    
    k_mod = 0
    for i in range(1, N+1):
        if (i % K) == 0:
            
            k_mod += 1
        elif is_k_even and (i % K) == K//2:
            
            half_k_mod += 1
    
    count = k_mod ** 3 + half_k_mod ** 3
    print(count)
    
solve()

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, k = na()
ct1 = 0
ct2 = 0
for i in range(1, n + 1):
    if i % k == 0:
        ct1 += 1
if k % 2 == 1:
    print(ct1 ** 3)
else:
    for i in range(1, n + 1):
        if i % k == (k // 2):
            ct2 += 1
    print(ct1 ** 3 + ct2 ** 3)

Solution (Python):
def main():
    N, K = map(int, input().split())

    if K&1:
        count = 0
        for i in range(1, N+1):
            if i%K == 0:
                count += 1
        print(pow(count, 3))
    else:
        count = [0, 0]
        k2 = K//2
        for i in range(1, N+1):
            tmp = i%K
            if tmp == 0:
                count[0] += 1
            elif tmp == k2:
                count[1] += 1
        print(pow(count[0], 3) + pow(count[1], 3))


if __name__ == "__main__":
    main()

Solution (Python):

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





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

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

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

Solution (Python):
N, K = map(int, input().split())

if K % 2 == 0:
    ans = (N // K) ** 3 + ((N + K // 2) // K) ** 3
else:
    ans = (N // K) ** 3

print(ans)

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
N, K = map(int, input().split())

m = N // K
if K & 1:
    print(m ** 3)
else:
    n = N // (K // 2)
    print(m ** 3 + (n - m) ** 3)

Solution (Python):
n, k=map(int,input().split())

mod=[n//k]*k
if n%k!=0:
    for i in range(1, n%k+1):
        mod[i]+=1

ans=0
for a in range(k):
    a_mod=a%k
    if a_mod==0:
        b_mod=0
        c_mod=0
    else:
        b_mod=k-a_mod
        c_mod=k-a_mod
    if (b_mod+c_mod)%k==0:
        ans+=mod[a_mod]*mod[b_mod]*mod[c_mod]
print(ans)

Solution (Python):

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


num = N // K


if K % 2 == 0:

    numH = N // (K // 2) - num

else:

    numH = 0

print (num ** 3 + numH ** 3)

Solution (Python):

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

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

Solution (Python):

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,K = II()

ans = 0

for i in range(1,N+1):
    x = i%K
    if -2*x %K ==0:
        s = -x%K
        if s==0: s=K
        ans += ((N-s)//K + 1)**2

print(ans)

Solution (Python):
n, k = list(map(int, input().split()))

if k % 2 == 1:
  ans = (n // k) ** 3
else:
  ans = (n // k) ** 3 + ((n + k // 2) // k) ** 3

print(ans)

Solution (Python):
n, k = map(int, input().split())

cnt = 0
for i in range(1, n+1):
    if i % k == 0:
        cnt += 1

cnt_2 = 0
if k % 2 == 0:
    for i in range(1, n+1):
        if i % k == k//2:
            cnt_2 += 1

res = cnt ** 3 + cnt_2 ** 3

print(res)

Solution (Python):
n,k = map(int,input().split())
a = 0
if k%2 == 0:
    for i in range(1,n+1):
        if i % k == k/2:
            a += 1
    print((n//k)**3 + a**3)
else:
    print((n//k)**3)

Solution (Python):

N, K = [int(nk) for nk in input().split()]

ans = 0
for a in range(1, N+1):
  bK_mod = K - a%K
  cK_mod = K - a%K
  bcK_mod = bK_mod + cK_mod
  if bcK_mod % K == 0:
    howmany_b = (N - bK_mod)//K + 1
    howmany_c = (N - cK_mod)//K + 1
    ans += (howmany_b * howmany_c)

print(ans)

Solution (Python):
N, K = [int(nk) for nk in input().split()]

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

Solution (Python):
n,k=map(int,input().split());d=n//k;print(d**3+(0if k%2else(n//(k//2)-d)**3))

Solution (Python):
def main():
    N, K = map(int, input().split())

    x = 0
    y = 0
    for i in range(1, N + 1):
        if i % K == 0:
            x += 1
        elif i % K == int(K / 2):
            y += 1

    if K % 2 == 0:
        print(x ** 3 + y ** 3)
    else:
        print(x ** 3)


main()

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

Solution (Python):
def main():
    N, K = map(int, input().split())
    if K % 2 == 1:
        d = N // K
        return d * d * d
    else:
        d = N // K
        d = N // (K // 2)
        d1 = N // K
        d2 = d - d1
        return d1*d1*d1 + d2*d2*d2

if __name__ == '__main__':
    print(main())

Solution (Python):
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""




if __name__ == "__main__":
    N, K = map(int, sys.stdin.readline().split())
    if K % 2 == 0:
        a = N // K
        
        b = N // (K // 2) - a
        print(a ** 3 + b ** 3)
    else:
        a = N // K
        print(a ** 3)

Solution (Python):
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""




if __name__ == "__main__":
    N, K = map(int, sys.stdin.readline().split())
    if K % 2 == 0:
        a = N // K
        b = (N + (K // 2)) // K
        print(a ** 3 + b ** 3)
    else:
        a = N // K
        print(a ** 3)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

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

Solution (Python):
n, k = map(int, input().split())
ans = (n // k) ** 3
if k % 2 == 0:
    if n % k >= k // 2:
        ans += (n // k + 1) ** 3
    else:
        ans += (n // k) ** 3

print(ans)

Solution (Python):

import sys
import math

def solve(N: int, K: int):

    ans = int(N/K) ** 3

    if(K%2 == 0):
        cnt = 0
        for i in range(int(K/2), N+1, K):
            cnt += 1
        ans += cnt ** 3
    
    print(ans)

    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))  
    K = int(next(tokens))  
    solve(N, K)

if __name__ == '__main__':
    main()

Solution (Python):
n, k = list(map(int, input().split()))
x, y = 0, 0
for i in range(1, n + 1):
	if i % k == 0:
		x += 1
	elif i % k == int(k / 2):
		y += 1
if k % 2 == 0:
	print(x ** 3 + y ** 3)
else:
	print(x ** 3)

Solution (Python):
n, k = map(int,input().split())

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

print(ans)

Solution (Python):
words = lambda t : list(map(t, input().split()))
n,k = words(int)

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

Solution (Python):
import math

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

ans = int(math.pow(int(n/k),3))

if(k % 2 == 0):
  m = int( (n+int(k/2))/ k )
  ans += int(math.pow(m,3))

print(ans)

Solution (Python):
N,K = (int(i) for i in input().split())

half = 0
zero = 0

if K%2==0:
	for i in range(1,N+1):
		if i%K==K/2:
			half+=1
		if i%K==0:
			zero+=1

else:
	for i in range(1,N+1):
		if i%K==0:
			zero+=1

print(half**3+zero**3)

Solution (Python):
N,K=map(int,input().split())
ans=0

n=N//K
ans+=n
if n>=2:
    ans+=n*(n-1)*3
    if n>=3:
        ans+=n*(n-1)*(n-2)

if K%2==1:
    
    
    
    
    
    
    
    print(int(ans))
else:
    
    
    n=(N+K/2)//K
    
    ans+=n





    if n>=2:
        
        ans+=n*(n-1)*3
        if n>=3:
            ans+=n*(n-1)*(n-2)
    print(int(ans))

Solution (Python):
n , k = map(int,input().split())
cnt1 = 0
cnt2 = 0
for i in range(1,n+1):
    if k % 2 == 0 and i % k == 0:
        cnt1 += 1
    elif k % 2 == 0 and i % k == k//2:
        cnt2 += 1
    elif k % 2 == 1 and i % k == 0:
        cnt1 += 1
print(cnt1 ** 3 + cnt2 ** 3)

Solution (Python):
N, K = map(int, input().split())
 
if K % 2 == 1:
    div = N // K
    print(div**3)
else:
    div = N // K
    if div * K + K/2 <= N:
        print(div**3 + (div+1)**3)
    else:
        print(2 * div**3)

Solution (Python):
n, k = map(int, input().split())


if k%2:

    print((n // k)**3)
else:
    mid_num = (n // (k // 2)) - (n // k)
    print(mid_num ** 3 + (n // k) ** 3)

Solution (Python):
n, k = map(int, input().split())
mod0 = []
mod2 = []
for i in range(1, n + 1):
    if i % k == 0:
        mod0.append(i)
    elif k % 2 == 0 and i % k == k // 2:
        mod2.append(i)
print(len(mod0) * len(mod0) * len(mod0) + len(mod2) * len(mod2) * len(mod2))

Solution (Python):
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = string_to_int(inputs[0])
    count_a = 0
    count_b = 0
    for i in range(1, N+1):
        if i % K == 0:
            count_a += 1
        if i % K == K/2:
            count_b += 1

    count = count_a ** 3
    if K % 2 == 0:
        count += count_b ** 3
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Solution (Python):
N, K = map(int, input().split())
ans = (N//K)**3
if K % 2 == 0:
  ans += ((N+K/2)//K)**3
print(int(ans))

Solution (Python):
n, k = map(int, input().split())

if k % 2 == 1:
    ans = (n // k) ** 3
else:
    ans = (n // k) ** 3 + ((n + k // 2) // k) ** 3

print(ans)

Solution (Python):
N, K = map(int, input().split())

ans = 0

ans += (N // K)**3

if K % 2 == 0 :
    ans += ((N - K // 2) // K + 1)**3

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n, k = map(int, input().strip().split())
	if k % 2 == 1:
		print((n // k)**3)
	else:
		print((n // k)**3 + (((n-k//2)//k)+1)**3)

if __name__ == '__main__':
	main()

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
N,K=map(int,input().split())

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

Solution (Python):
N, K = map(int, input().split())


def f(x): return x + x * (x - 1) * 3 + x * (x - 1) * (x - 2)


if K % 2 == 0:
    a = N // K
    b = N // (K // 2) - a
    ans = f(a) + f(b)
else:
    ans = f((2 * N) // (K * 2))
print(ans)

Solution (Python):
n,k = map(int,input().split())
if k % 2 == 1:
  x = n // k
  print( x ** 3 )
else:
  x = n // k
  y = n // (k//2) - x
  print( x ** 3 + y ** 3)

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
from math import ceil

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

if K % 2 != 0:
    print((N//K)**3)
else:
    cnt = 0
    cnt += ceil((N//(K/2))/2) ** 3

    cnt += (N//K)**3
    print(cnt)

Solution (Python):

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

n,k=getints()

x = n // k

if k % 2 == 1:
    print(x**3)
else:
    y = (n + k - k // 2) // k
    res = x**3 + y**3
    print(res)

Solution (Python):
N, K = map(int, input().split())

ans = 0
if (K % 2 != 0):
  ans = (N // K) ** 3
else:
  for i in range(1,N+1):
    if (i % K == int(K / 2)):
      ans += 1
  ans = ans ** 3 + (N // K) ** 3
print(ans)

Solution (Python):

n,k = map(int,input().split())
ans = 0
if k%2 != 0:
    ans = (n//k)**3
else:
    d = k//2
    ans = (n//k)**3 + ((n-d)//k + 1)**3
print(ans)

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
import numpy as np

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

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

Solution (Python):
n,k = map(int,input().split())

khalf = 0

if k%2 == 0:
    khalf = n // (k*0.5)

if khalf%2 == 0:
    khalf = khalf // 2
else:
    khalf = khalf // 2 + 1

kraw = n // k

print(int(khalf**3+kraw**3))

Solution (Python):
N,K = map(int,input().split())
X = [2*i//K for i in range(1,N+1) if 2*i%K == 0]
count1 = 0
count2 = 0
for x in X:
    if x%2 == 0:
        count1 += 1
    else:
        count2 += 1
print(count1**3 + count2**3)

Solution (Python):
def main():
    n, k = map(int, input().split())

    if k % 2 == 1:
        print((n // k) ** 3)
        return

    k2 = k // 2
    even = n // k
    odd = (n - k2) // k + 1 if n >= k2 else 0
    print(even ** 3 + odd ** 3)


main()

Solution (Python):
n, k = (int(i) for i in input().split())  

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

Solution (Python):
N,K = map(int,input().split())
if K == 1:
    print(N*N*N)
else:
    if K%2==0:
        b = N // (K//2)
        if b % 2 == 0:
            b0 = b//2
            print(2 * (b0*b0*b0))
        else:
            b1 = (b+1)//2
            b2 = (b-1)//2
            print(b1*b1*b1+b2*b2*b2)
    else:
        c = N//K
        print(c*c*c)

Solution (Python):
n,k=map(int,input().split())
if  k%2 == 0:
    k2 = k//2
    ans = ((n//k2 + 1)//2)**3 + ((n//k2)//2)**3
else :
    ans = (n//k)**3
print(ans)

Solution (Python):
n, k = [ int(v) for v in input().split() ]

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

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int, K: int):
    if K % 2 == 0:
        d = N // K
        dd = (N + K // 2) // K
        print(d ** 3 + dd ** 3)
    else:
        d = N // K
        print(d ** 3)
    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))  
    K = int(next(tokens))  
    solve(N, K)

if __name__ == '__main__':
    main()

Solution (Python):
N,K = (int(x) for x in input().split())

nk = N//K
ans = nk*nk*nk

if(K%2==0):
  nk2 = N//(K//2) - nk
  ans += nk2*nk2*nk2

print(ans)

Solution (Python):
N,K = (int(x) for x in input().split())

nk = N//K
ans = nk*nk*nk

if(K%2==0):
  nk2 = N//(K//2) - nk
  ans += nk2*nk2*nk2

print(ans)

Solution (Python):
N, K = map(int, input().split())







cnt = int(N / K) ** 3


if K % 2 == 0:
    cnt += int((N + K / 2) / K) ** 3

print(cnt)

Solution (Python):
import collections

n, k = map(int, input().split())
d = collections.Counter(x % k for x in range(1, n + 1))
ans = 0
for a in range(k):
    b = (k - a) % k
    c = (k - a) % k
    if (b + c) % k == 0:
        ans += d[a] * d[b] * d[c]
print(ans)

Solution (Python):
N,K=map(int,input().split())
a,b=0,0
for n in range(1,N+1):
    if n%K==0:
        a+=1
    elif K%2==0 and n%K==(K//2):
        b+=1
print(a*a*a+b*b*b)

Solution (Python):
n,k=map(int, input().split())

if k%2==1:
    print((n//k)**3)
else:
    x=(n//k)**3
    y=((n+(k//2))//k)**3
    print(x+y)

Solution (Python):
n,k = map(int,input().split())

mod0 = 0
modk2 = 0
for i in range(1,n+1):
    if i%k == 0:
        mod0 += 1
    if k%2 == 0:
        if i%k == k//2:
            modk2 += 1
res = 0
if k % 2 != 0:
    res = mod0**3
else:
    res += mod0**3
    res += modk2**3
print(res)

Solution (Python):
N,K = map(int, input().split())

if K%2 == 1:
    count = 0
    for i in range(1,N+1):
        if i%K == 0:
            count += 1
    ans = count**3
else:
    count = 0
    c = 0
    for j in range(1,N+1):
        if j%K == 0:
            count += 1
        elif j%(K/2) == 0:
            c += 1
    ans = count**3 + c**3

print(ans)

Solution (Python):
N, K = map(int, input().split())

m = N // K

if K % 2 == 0:
    if 2*(N%K)>=K:
        ans = m**3 + (m+1)**3
    else:
        ans = 2 * m**3
else:
    ans = m**3

print(ans)

Solution (Python):
N, K = map(int, input().split())
countlist = []
for i in range(0, K):
	countlist.append(N//K)
for i in range(1, N%K+1):
	countlist[i] += 1
sum = countlist[0] ** 3
for i in range(1, K):
	if i*2 % K == 0:
		sum += (countlist[i]**2)*countlist[K-i]
print(sum)

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))
if K % 2 == 1:
    
    m = N // K
    print(m ** 3)
else:
    m = N // K
    a1 = m ** 3
    m = (N + K // 2) // K
    a2 = m ** 3
    print(a1 + a2)

Solution (Python):



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

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

Solution (Python):
N, K = map(int, input().split())

ans = 0
if K % 2 == 0:
    c = int((N * 2 + K) / (K * 2))
    ans += c ** 3

c = int(N / K)
ans += c ** 3
print(ans)

Solution (Python):
n,k=map(int,input().split())
l,d=[(n+i)//k for i in range(k)],0
for a in range(1,n+1):d+=((a*2)%k==0)*l[a%k]**2
print(d)

Solution (Python):
a, b = map(int, input().split())
c = []
d = []
for i in range(1, a + 1):
    if i % b == 0:
        c.append(i)
    elif i % b == b / 2:
        d.append(i)
e = 0
print(len(c) * len(c) * len(c) + len(d) * len(d) * len(d))

Solution (Python):

N, K = map(int, input().split())
ans = 0
if K % 2 == 1:
    ans = (N // K) ** 3
else:
    ans += (N // K) ** 3
    ans += ((N+(K/2))//K) ** 3
print(int(ans))

Solution (Python):
N, K = map(int, input().split())
ans = (N//K)**3
if K % 2 == 0:
  ans += ((N+K/2)//K)**3
print(int(ans))