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())
ans = 0
if k % 2 == 1:
    count = n//k
    print(count**3)
else:
    a = (n//k)**3
    count = 0
    for i in range(n//k+1):
        if k*i+k//2 <= n:
            count += 1
    print(count**3+a)

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

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

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

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

if K % 2 == 0:
    cnt1,cnt2 = 0,0
    for n in range(1,N+1):
        if n % K == 0:
            cnt1 += 1
        if n % K == (K // 2):
            cnt2 += 1
    print(cnt1 ** 3 + cnt2 ** 3)
else:
    cnt1 = 0
    for n in range(1,N+1):
        if n % K == 0:
            cnt1 += 1
    print(cnt1 ** 3)

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

abc1 = N//K
abc2 = (N+K//2)//K

if K%2 == 1 :
    print(abc1**3)
else :
    print(abc1**3 + abc2**3)

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

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

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

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

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

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

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

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

    if k % 2:
        count = sum([1 for c in range(1, n + 1) if c % k == 0])
        print(count ** 3)
    else:
        count_1 = sum([1 for c in range(1, n + 1) if c % k == 0])
        count_2 = sum([1 for c in range(1, n + 1) if c % k == k // 2])
        print(count_1 ** 3 + count_2 ** 3)


if __name__ == "__main__":
    submit()

Solution (Python):
def main():
  import math
  n,k=map(int,input().split())
  ans=pow(((2*n)//k)//2,3)+pow(math.ceil(((2*n)//k)/2),3) if k%2==0 else pow(n//k,3)
  print(ans)
if __name__=='__main__':
  main()

Solution (Python):
N, K = map(int, input().split())
n = sum([1 for x in range(K, N + 1, K)])
if K % 2 == 1:
    print(n ** 3)
else:
    m = sum([1 for x in range(K // 2, N + 1, K)])
    print(n ** 3 + m ** 3)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    ans = (N // K) ** 3

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

if __name__ == '__main__':
    main()

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

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

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

    cnt1, cnt2 = 0, 0
    if k%2 == 1:
        for i in range(1, n + 1):
            if i%k == 0:
                cnt1 += 1
    else:
        for i in range(1, n + 1):
            if i%k == 0:
                cnt1 += 1
            elif i%(k//2) == 0:
                cnt2 += 1

    ans = cnt1**3 + cnt2**3
    print(ans)

if __name__ == "__main__":
    main()

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

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

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

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())
cnt = 0
count = 0
if k % 2 == 1:
    for i in range(1,n+1):
        if i % k == 0:
            cnt += 1
    print(cnt**3)
else:
    for i in range(1,n+1):
        if i % k == 0:
            cnt += 1
        if i % k == (k//2):
            count += 1
    print((count**3) + (cnt**3) )

Solution (Python):
import numpy as np
N,K = [int(i) for i in input().split()]
nums = np.arange(1,N+1)
a =nums[nums%K==0]
ans = len(a)**3
if K%2 == 0:
  a = nums[nums%K==K/2]
  ans += len(a)**3
  
print(ans)

Solution (Python):

import sys


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

ans = 0
for a in range(1,N+1):
    b = K-a%K
    c = K-a%K
    if b==0 or c==0:
        continue
    if (b+c)%K==0:
        if N%K>=b:
            tmpb = (N+K-1)//K
        else:
            tmpb = N//K
        if N%K>=c:
            tmpc = (N+K-1)//K
        else:
            tmpc = N//K
        ans += tmpb*tmpc

print(ans)

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

if k%2!=0:
    factor = n//k
    print(factor**3)
else:
    factor1 = n//k
    res1 = factor1**3
    
    factor2 = 0
    for i in range(1, n+1):
        if (i %(k//2)==0) and (i%k!=0):
            factor2 += 1
    res2 = factor2**3
    print(res1 + res2)

Solution (Python):
n, k = map(int,input().split()) 
l = [int(_) for _ in range(1,n+1)]


a = 0
for i in range(n):
    if l[i] % k == 0:
        a += 1


b = 0
for j in range(n):
    if l[j] % k == k/2:
        b += 1


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

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()



if K == 2:
    odd = (N+1) // 2
    even = N // 2
    answer = odd ** 3 + even ** 3
else:
    num = N // K    
    answer = num ** 3
    if K % 2 == 0:
        num2 = N // (K//2)
        num2 -= num
        answer += num2 ** 3

print(answer)

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

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

Solution (Python):
n, k = map(int,  input().split())
ans = 0
l1 = [i for i in range(1, n+1) if i % k == 0]
n1 = len(l1)
ans += n1 ** 3
if k % 2 == 0:
    l2 = [i for i in range(1, n+1) if i % k == k // 2]
    n2 = len(l2)
    ans += n2 ** 3
print(ans)

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

num = [0]*k

for i in range(1,n+1):
    num[i%k] += 1

res = 0
for a in range(k):
    b = (k-a)%k
    c = (k-a)%k
    if (b+c)%k!=0: pass
    else: res += num[a] * num[b] * num[c]
print(res)

Solution (Python):








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


def f(A):
    
    
    
    nb = (N + A) // K - A // K
    return nb * nb


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

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


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

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

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

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

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

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

Solution (Python):
S = input().split(" ")
n = int(S[0])
k = int(S[1])

def calculate(n,k):
    if k % 2 == 0:
        
        s1 = n // k
        s2 = 0
        for i in range(1,n+1):
            if i % k == k/2:
                s2 = s2 + 1
        return s1**3 + s2**3
    else:
        s1 = n // k
        return s1**3

result = calculate(n,k)

print(result)

Solution (Python):
from collections import Counter


N, K = map(int, input().split())
if K > 2 * N:
    print(0)
    exit()
else:
    x0 = N // K
    x2 = (N - K // 2) // K  + 1 if K % 2 == 0 else 0

    ans = 0
    ans += x0 ** 3
    
    ans += x2 ** 3
    print(ans)

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

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

ans = 0
for i in range(K):
    b = (K - i) % K
    c = (K - i) % K
    if (b + c) % K != 0: continue

    ans += nums[i] * nums[b] * nums[c]

print(ans)

Solution (Python):
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd
import itertools 

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

x = [0]*k

for i in range(1,n+1):
    x[i%k] = x[i%k]+1


ans = x[0]*x[0]*x[0]

for i in range(1,k):
    b = i%k 
    a = (k-b) 
    c = (k-b) 
    if((a+c)%k != 0):continue
    ans  = ans + x[a] * x[b] * x[c]

print(ans)

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

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd
import itertools 

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


num = [0]*k

for i in range(1,n+1):
    num[i%k] = num[i%k]+1

ans = 0

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


print(ans)

Solution (Python):
n,k=map(int,input().split())
def even_cnt(x): 
    if x%2==0:
        s,t=x//2,x//2
    else:
        s,t=x//2,x//2+1
    return s**3+t**3

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N, K = (int(_) for _ in input().split())
    ans = 0
    if K%2 ==0:
        d = N // K
        cnt = 0
        for i in range(1,N+1):
            if i % K == K/2: cnt+=1
        ans = d ** 3 + cnt ** 3
    else:
        d = N // K     
        ans = d ** 3
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):

N,K=map(int,input().split())
x=N//K
Ans=x**3
if K%2==0:
    y=(2*N+K)//(2*K)
    Ans+=y**3
    
print(Ans)

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

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

if k%2==0:
    nsum=0
    for i in range(1,n+1):
        ia=i%k
        k2=k/2
        if ia==0:
            nb=(n-ia)//k
            nsum=nsum+nb**2
        elif ia==k2:
            nb=(n-ia)//k+1
            nsum=nsum+nb**2
        
else:
    nsum=0
    for i in range(1,n+1):
        ia=i%k
        if ia==0:
            nb=(n-ia)//k
            nsum=nsum+nb**2

print(nsum)

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

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

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

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

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
            
    print(count**3)
    
else:
    c1 = 0
    c2 = 0
    for i in range(1,N+1):
        if i%K == 0:
            c1 += 1
            
        elif i%K == K//2:
            c2 += 1
            
    print(c1**3 + c2**3)

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

a = 0
b = 0

tmp = K/2
for i in range(1,N+1):
    if i%K == 0:
        a += 1
    if i%K == tmp:
        b += 1
print(a**3 + b**3)

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

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

Solution (Python):



n,k=map(int,input().split())
ans=0
if n>=k:
  c=n//k
  ans+=c**3
if k%2==0:
  if n>=k//2:
    c=(n-k//2)//k+1
    ans+=c**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)-n//k)**3)

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

Solution (Python):
def main():
    N,K = map(int,input().split())
    modzero = 0
    modhalf = 0
    for i in range(1,N+1):
        if i%K == 0:
            modzero += 1
        elif (i%K == (K/2)) and (K/2 == K//2):
            modhalf += 1
    ans = modzero**3 + modhalf**3
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    
    limit, divisor = map(int, input().split(" "))
    reminders = [0] * divisor
    answer = 0
    for i in range(1, limit + 1):
        reminders[i % divisor] += 1
    
    for i in range(0, divisor):
        others_reminder = (divisor - i) % divisor
        if not (2 * others_reminder) % divisor:
            answer += reminders[i % divisor] * (reminders[others_reminder]) ** 2
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    
    limit, divisor = map(int, input().split(" "))
    if divisor % 2:
        print((limit // divisor) ** 3)
    else:
        print((limit // divisor) ** 3 + ((limit + divisor // 2) // divisor) ** 3)


if __name__ == '__main__':
    main()

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

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

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


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


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

Solution (Python):
n,k = map(int, input().split())
a = 0
b = 0
c = 0
kk = k // 2
for i in range(1,n+1):
    d = 2*i
    if k % 2 == 0 and i % k == kk:
        a += 1
    if i % k == 0:
        b += 1
    if (k % 2 == 0 and i % k == kk) and i % k == 0:
        c += 1

print(a**3 + b**3 - c**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):
N, K = map(int, input().split())

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

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

ans = a ** 3
if K % 2 == 0:
  ans += b ** 3

print(ans)

Solution (Python):
import math
def wow(s):
    return s+3*s*(s-1)+s*(s-1)*(s-2)


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

s=n//k
if k%2!=0:
    if s==1:
        print(1)
    elif s==2:
        print(8)
    else:
        print(wow(s))
else:
    print(wow(s)+wow(((n-(k//2))//k)+1))

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

ans=0
ans+=pow(N//K,3)

if K%2==0:
    a=(2*N)//K - (2*N)//(2*K)
    ans+=pow(a,3)
    
print(ans)

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




ans=0
odd=0
even=0


odd=n//k


even=n//(k/2)-odd

if k%2==0:
  ans+=odd**3+even**3
else:
  ans+=odd**3

print(int(ans))

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

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

ans=0
for a in range(K):
    b=(K-a)%K
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	
        ans+=num[a]*num[b]*num[c]
        
print(ans)

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter


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

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

print(ans)

Solution (Python):
n,k = map(int, input().split())
kk = 2*k
if k % 2:
    tmp = (n//k)**3
    print(tmp)
    exit()
kk = 0
k2 = 0
kkk = 0
for i in range(k//2,n+1):
    if i % k == 0:
        kk += 1
    if i % k == k//2:
        k2 += 1
    if i % k == 0 and i % k == k//2:
        kkk += 1
    

print(kk**3 + k2**3 - kkk**3)

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

num = [0]*K
for n in range(1, N+1):
  num[n%K] += 1
  
res = 0

for a in range(K):
  b = (K - a) % K
  c = (K - a) % K
  if (b+c) % K != 0:
    continue
  res += num[a] * num[b] * num[c]
  
print(res)

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines








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

if __name__ == "__main__":
	main()

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):

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

ans = 0
mod = [0]*K
for i in range(1, N+1):
  mod[i%K] += 1
  
for a_modk in range(K)  :
  b_modk = (K - a_modk) % K
  c_modk = (K - a_modk) % K
  if (b_modk + c_modk) % K == 0:
    ans += mod[a_modk] * mod[b_modk] * mod[c_modk]
print(ans)

Solution (Python):

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

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

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

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


d = collections.defaultdict(int)
for i in range(1, N + 1):
    d[i % K] += 1

ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K:
        continue
    ans += d[a] * d[b] * d[c]
print(ans)

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

ans = 0
mod = [0 for _ in range(K)]
for i in range(1, N+1):
    mod[i % K] += 1

for a_modk in range(K):
    b_modk = (K - a_modk) % K
    c_modk = (K - a_modk) % K
    if (b_modk + c_modk) % K == 0:
        ans += mod[a_modk] * mod[b_modk] * mod[c_modk]
print(ans)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()

  ans=0
  ans+=(n//k)**3

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

  return ans


print(main())

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






div = n // k

if k % 2 == 1:
    print(div ** 3)



else:
    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())

ans = 0

if N == 1 and K != 1:
    print(0)
    exit()
if K % 2 == 0:
    
    cnt = N // K 
    ans = cnt ** 3
    K //= 2
    k = K
    
    tmp = 1
    while 1:
        K += 2 * k
        if N < K:
            break
        tmp += 1
    
    ans += (tmp) ** 3
else:
    cnt = N // K
    ans = cnt ** 3

print(ans)

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

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

print(mm1**3+mm2**3)

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

Solution (Python):
N, K = tuple(map(int, input().split()))
num = [0] * K
for i in range(1, N+1):
    num[i % K] += 1
res = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K != 0:
        continue
    res += num[a] * num[b] * num[c]
print(res)

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

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


def main():
    N, K = [int(x) for x in input().split()]
    ans = 0
    if K & 1:
        print((N // K) ** 3)
    else:
        ans += (N // K) ** 3
        ans += ((N + K // 2) // K) ** 3
        print(ans)



if __name__ == '__main__':
    main()

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

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 == 0):
    ans = (N//K)**3 + ((2*N)//K-N//K)**3
else:
    ans = (N//K)**3

print(ans)

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


kosu=0
temp=k//2
while temp<=n:
  kosu+=1
  temp+=k

ans=0

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


print(ans)

Solution (Python):
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    res = 0
    c = n // k
    res += c ** 3
    if k & 1:
        return res
    if n - k * c < k // 2:
        return res * 2
    else:
        return res + (c + 1) ** 3

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

Solution (Python):
import sys

sys.setrecursionlimit(10**9)
nCr = {}
def comb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = comb(n-1,r) + comb(n-1,r-1)
    return nCr[(n,r)]

def count(q):
    res = 0
    if q >= 1:
        res += comb(q, 1) * comb(3, 3)
    if q >= 2:
        res += comb(q, 2) * comb(2, 1) * comb(3, 2)
    if q >= 3:
        res += comb(q, 3) * comb(3, 1) * comb(2, 1)
    return res

n, k = map(int, sys.stdin.readline().split())

def main():
    cnt1 = n // k
    res = count(cnt1)
    if k & 1:
        return res
    else:
        if n - k * cnt1 < k // 2:
            res *= 2
        else:
            cnt2 = cnt1 + 1
            res += count(cnt2)
        return res

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

Solution (Python):
N, K = map(int, input().split())
ret = 0
ret2 = 0
for i in range(1, N+1):
    judge = (i % K) == 0
    if judge:
        ret += 1
    if K % 2 == 0:
        judge = (i % K) == K // 2
        if judge:
            ret2 += 1

print(ret**3+ret2**3)

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):
def main():
    N, K = map(int, input().split())
    if K % 2:
        print((N // K) ** 3)
    elif N // K * K + K // 2 <= N:
        print((N // K) ** 3 + (N // K + 1) ** 3)
    else:
        print(2 * (N // K) ** 3)
    return


main()

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

Solution (Python):
N, K = map(int,input().split())
l = []
l1 = []
if K%2==1:
  for i in range(1, N+1):
    if i%K==0:
      l.append(i)
  print(len(l)**3)
else:
  for i in range(1, N+1):
    if i%K==0:
      l1.append(i)
    elif i%K==K//2:
      l.append(i)
  print(len(l)**3+len(l1)**3)

Solution (Python):
import math
import os
import sys

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

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


N, K = list(map(int, sys.stdin.buffer.readline().split()))


ans = (N // K) ** 3

if K % 2 == 0:
    ans += math.ceil((N // (K // 2)) / 2) ** 3
print(int(ans))

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

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

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

Solution (Python):
N, K = (int(i) for i in input().split())  
ans = 0
if K % 2 == 0:
  ans += (N//(K//2) - N//K) ** 3
  ans += (N//K) ** 3
else:
  ans += (N//K) ** 3

print(ans)

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

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

ans = 0
num = [0] * K
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 != 0:
                continue
        ans += num[a] * num[b] * num[c]
print(ans)

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

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

Solution (Python):

import sys

def solve(N: int, K: int):
    if K%2 == 1:
        print((N//K)**3)
    else:
        a = 1+ (N-K//2)//K
        b = N//K
        print(a**3+b**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 = map(int,input().split())

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

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

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

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

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

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

else:
    ans_1 = 1
    for i in range(3):
        ans_1 *= n // k
    ans_2 = 1
    for i in range(3):
        ans_2 *= len(list(range(int(k/2), n+1, k)))
    ans = ans_1 + ans_2
    print(ans)

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


x = N // K
ans += x ** 3


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

Solution (Python):
import sys
import itertools
import numpy
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
if K % 2 == 1 :
    index = N // K
    ans = index**3
else :
    index = N // K
    ans = index**3
    k = K // 2
    indexa = (N // k) - index
    ans += indexa**3
print(ans)

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

count_a = 0

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

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

print(count_a**3 + count_b)

Solution (Python):
n,k=map(int,input().split())
num=[0]*k
for i in range(1,n+1):
    num[i%k]+=1
res=0
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k!=0:continue
    res+=num[a]*num[b]*num[c]
print(res)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, K = LI()
    baisu = set()
    khalf = set()
    cnt = 0
    gusu = (K % 2 == 0)
    for x in range(1, N+1):
        if gusu and x % K == K // 2:
            khalf.add(x)
            continue
        if x % K != 0:
            continue
        baisu.add(x)
    cnt += len(baisu) ** 3
    cnt += len(khalf) ** 3
    print(cnt)


main()

Solution (Python):
N,K = map(int, input().split())
div_cnt = 0
if K % 2 == 1:
    div_cnt = (N // K) ** 3
else:
    div_cnt1 = N // K
    div_cnt2 = 0
    for i in range(1,N+1):
        if i % K == K//2:
            div_cnt2 += 1
    div_cnt = div_cnt1 **3 + div_cnt2 ** 3
print(div_cnt)

Solution (Python):
n,k = map(int,input().split())
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a % b)
def lcm(a,b):
  return a * b // gcd(a,b)
if k % 2 != 0:
  elements = n // k
  print(elements**3)
else:
  a = n // k
  b = (n + (k//2)) // k
  print(a**3 + b ** 3)

Solution (Python):
n,k = map(int,input().split())
num = [0] * k
ans = 0
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 != 0:
    continue
  ans += num[a] * num[b] * num[c]
print(ans)

Solution (Python):


import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()


C = Counter()
for a in range(1, N+1):
    C[a%K] += 1


ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        ans += C[a] * C[b] * C[c]
print(ans)