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

Solution (Python):
from scipy.special import comb

n,k=map(int,input().split())
p=n//k
q=p+1
ans=0
ans1 = (comb(p, 3, exact=True)+comb(p, 2, exact=True))*6+p
ans2 = (comb(q, 3, exact=True)+comb(q, 2, exact=True))*6+q
ans+=ans1
if k%2==0:
    if k*p+k//2>n:
        ans+=ans1
    else:
        ans+=ans2


print(ans)

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

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

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

num_list = list(range(1, n+1))
count = 0

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

else:
    count = (n // k) ** 3  + ((n + k // 2) // k )** 3

print(count)

Solution (Python):
import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, k = input_int_list()
    ans = 0
    if k % 2 == 0:
        
        cnt = ((n - (k // 2)) // k) + 1
        ans += pow(cnt, 3)

    
    ans += pow(n // k, 3)

    print(ans)

    return


if __name__ == "__main__":
    main()

Solution (Python):

def resolve():
    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 * a * a
    if K % 2 == 0:
        
        ans += b * b * b

    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):

def resolve():
    N, K = map(int, input().split())

    A = [0] * K
    
    for i in range(1, N + 1):
        A[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 += A[a] * A[b] * A[c]

    print(res)


if __name__ == "__main__":
    resolve()

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N, K = MI()

    counter = cl.Counter()

    for i in range(1, N + 1):
        amari = i % K
        counter.update({amari: 1})

    pairs = []

    for i in range(K):
        if (i * 2) % K == 0:
            pairs.append(i)

    ans = 0

    for pair in pairs:
        count = counter[pair]
        ans += count ** 3

    print(ans)


main()

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

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

num_=[0]*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
  ans+=num_[a]*num_[b]*num_[c]

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    cnt0 = cntk = 0
    for num in range(1, n + 1):
        if num % k == 0:
            cnt0 += 1
        elif num % k == k // 2:
            cntk += 1

    if k % 2 == 0:
        res = pow(cnt0, 3) + pow(cntk, 3)
    else:
        res = pow(cnt0, 3)
    print(res)


if __name__ == '__main__':
    resolve()

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

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

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

Solution (Python):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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


ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%k
    
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)

Solution (Python):
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    """
    x = a+b
    y = b+c
    z = a+c
    """
    N, K = read_ints()
    answer = 0
    for a in range(1, N+1):
        complement = K-(a%K)
        if 2*complement%K == 0:
            if N-complement >= 0:
                answer += ((N-complement)//K+1)**2
    return answer


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

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

mod_0_num = N//K

ans_mod_0 = mod_0_num**3
ans_mod_K = 0
if K%2 == 0:
    mod_K_num = (2*N-K)//(2*K) + 1
    ans_mod_K = mod_K_num**3

ans = ans_mod_0 + ans_mod_K
print(ans)

Solution (Python):
import sys

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

Solution (Python):
from scipy.special import comb

n, k = map(int, input().split())
cnt1 = 0
cnt2 = 0

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,K=mint()
ans=pow(N//K,3)
if K%2==0:
    ans+=pow(max(0,(N-K//2)//K+1),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)**3
print(ans)

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

if k%2==1:
    q= n//k 
    print(q**3);exit()
q=n//k 

qq=len([i for i in range(k//2,n+1,k)])
print(q**3+qq**3)

Solution (Python):
def main():
    
    import sys
    input = lambda:sys.stdin.readline().strip()
    N,K = map(int,input().split())
    
    
    ans = 0
    for a in range(1,K+1):
        if a == K:
            b = K
            c = K
        else:
            b = K-a
            c = K-a
        if (a+b)%K == 0 and (b+c)%K == 0 and (a+c)%K == 0:
            ans+=((N-a)//K+1)*((N-b)//K+1)*((N-c)//K+1)
    print(ans)
    
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 = list(map(int, input().split()))

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

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

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

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

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

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

print(cnt1 ** 3 if k % 2 == 1 else cnt1 ** 3 + cnt2 ** 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=map(int,input().split())
ans=(N//K)**3
count=0
if K%2==0:
    count=N//(K//2)-N//K
ans+=count**3
print(ans)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)









INF = 1 << 50
def run():
    N, K = map(int, sysread().split())

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

    val = N // K
    val = val ** 3
    ans += val
    print(ans)
if __name__ == "__main__":
    run()

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




def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))




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


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

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

	print(a**3+b**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) - n//k)**3
print(ans)

Solution (Python):






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

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

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

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

print(Z**3+H**3)

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

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

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

if k%2 == 1:
    kcnt = n//k
    ans = pow(kcnt,3)
    print(ans)

else:
    kcnt = n//k
    ans = pow(kcnt,3)

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

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

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

if K % 2 != 0:
    ans_odd = []
    for i in range(N):
        if ((i + 1) % K) == 0:
            ans_odd.append(i + 1)

    len_ans = len(ans_odd)
    print(len_ans * len_ans * len_ans)

else:
    ans_even_zero = []
    ans_even_k = []
    for i in range(N):
        if (i + 1) % K == 0:
            ans_even_zero.append(i + 1)
        elif (i + 1) % K == (K // 2):
            ans_even_k.append(i + 1)

    len_ans_even_zero = len(ans_even_zero)
    len_ans_even_k = len(ans_even_k)

    ans = len_ans_even_zero * len_ans_even_zero * \
        len_ans_even_zero + len_ans_even_k * len_ans_even_k * len_ans_even_k
    print(ans)

Solution (Python):






import math





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





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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
v0 = n//k
ans = v0**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:
    t = (n + k // 2) // k
    print(t ** 3 + (n // k) ** 3)
else:
    t = n // k
    print(t ** 3)

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

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

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

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

Solution (Python):

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

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

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

Solution (Python):
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)


input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        

def solve():
    n, k = getList()
    ans = 0
    k1, k2 = 0, 0
    if k == 1:
        print(n ** 3)
        return
    for i in range(1, n+1):
        if i % k == 0:
            k1 += 1
        if i % k == k / 2:
            k2 += 1
    print(k1 ** 3 + k2 ** 3)
    return



def main():
    n = getN()
    for _ in range(n):
        solve()

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

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

X=(N//K)**3

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

Solution (Python):
N, K = map(int, input().split())
 
if K % 2 == 1:
  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)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

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

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

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


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

print(ans)

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

Solution (Python):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    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 == 1:
  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)

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


def read():
    N, K = map(int, input().strip().split())
    return N, K


def solve(N, K):
    
    nk = math.floor(N / K)
    if K % 2 == 1:
        return nk ** 3
    else:
        nhk = math.floor(N / (K//2))
        return nk ** 3 + (nhk - nk) ** 3


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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

ans=0
if k%2==0:
    cnt=0
    k_d = k//2

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

    x=n//k
    ans+=(x**3) +(cnt**3)
else:
    x=n//k
    ans+=x**3

print(ans)

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

cnt = [0] * (n + 1)

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

if k % 2 == 0:
    ans = 0
    ans += cnt[0] * cnt[0] * cnt[0]
    if k // 2 <= n:
        ans += cnt[k // 2] * cnt[k // 2] * cnt[k // 2]
    print(ans)
else:
    print(cnt[0] * cnt[0] * cnt[0])

Solution (Python):
import sys, math
from itertools import combinations
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    if K%2==1:
        print((N//K)**3)
    else:
        print((math.floor((N//(K//2))/2))**3+(math.ceil((N//(K//2))/2))**3)

if __name__ == '__main__':
    main()

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

Solution (Python):

"""
@author: H_Hoshigi
"""
def main():
    N, K = map(int, input().split())
    answer = 0
    
    m = N//K
    
    
    answer += m + m*(m-1)*3 + m*(m-1)*(m-2)

    
    if K%2 == 0:
        
        if m*K + K//2 <= N:
            m += 1
        answer += m + m*(m-1)*3 + m*(m-1)*(m-2)
    print(answer)

if __name__ == "__main__":
    main()

Solution (Python):
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()
a = n//k
if k % 2 == 0:
    b = n//(k//2) - a
else:
    b = 0

ans = a + max(a*(a-1)*3,0) + max(a*(a-1)*(a-2),0)
ans += b + max(b*(b-1)*3,0) + max(b*(b-1)*(b-2),0)
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

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

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




def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))


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


	if k%2:
		a=n//k
		b=0
	else:
		a=n//k
		b=n//(k//2)-a

	print(a**3+b**3)








if __name__ == "__main__":
	main()

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n, k = readInts()
dic = defaultdict(int)
for i in range(1, n+1):
    dic[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 += dic[a] * dic[b] * dic[c]
print(res)

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

if k == 1:
    print(n**3)
    exit()
if n == 1:
    print(1*(k==3))
    exit()
    
ans = 0
for i in range(n):
    a = i+1
    if 2*(i+1) % k == 0:
        lb = math.floor((a%k)/k)
        if a%k == 0:
            lb = 1
        ub = math.floor((n-a%k)/k)
        
        ans += (ub-lb+1)**2
print(ans)

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

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

Solution (Python):
from collections import Counter
n, k = map(int, input().split())
ans = 0
mod = Counter([i%k for i in range(1,n+1)])
for a in range(k):
    b = (k-a)%k
    if 2*b%k !=0: continue
    ans += mod[a]*mod[b]*mod[b]
print(ans)

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

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

cnt = 0
cnt2 = 0
for k in range(1, N + 1):
    if k % K == 0:
        cnt += 1
    elif K % 2 == 0 and k % K == K // 2:
        cnt2 += 1

print(cnt ** 3 + cnt2 ** 3)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    num = [0] * k
    for i in range(1, n + 1):
        num[i % k] += 1
        
    if k % 2 != 0:
        print(pow(num[0], 3))
    else:
        print(pow(num[0], 3) + pow(num[k // 2], 3))


if __name__ == '__main__':
    resolve()

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

if k % 2 == 0:
    mod = k // 2
    count_mod = 0
    count = 0
    for i in range(1,n+1):
        if i % k == 0:
            count += 1
            
        elif i % k == mod:
            count_mod += 1
            
    
    print(count**3 + count_mod ** 3)
else:
    count = 0
    for i in range(1,n+1):
        if i % k == 0:
            count += 1
    print(count ** 3)

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

ans = 0

pk = n//k
ans += pk**3


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

print(ans)

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

"""
a+b = K i
b+c = K j
c+a = K k
2(a+b+c) = K(i+j+k)

k%2=0ならば,
a+b+cはk//2の倍数でなければならない、かつ、差を取ると結局a,b,cがそれぞれk//2の倍数
でなければならい。それでa+b,b+c,c+dはｋの倍数だから、a,b,cはすべて偶数またはすべて奇数
でなければならない。

それ以外の場合、
a+b+cがkの倍数である必要があり、かつ差を取ると結局a,b,cがすべてkの倍数でなければ
ならない。
"""

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

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


if __name__ == '__main__':
    resolve()

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

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

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, K = il()
    pi = 0
    for n in range(1, N + 1):
        if n % K == 0:
            pi += 1

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

    ret = pi ** 3
    if K % 2 == 0:
        ret += hf ** 3
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, K = il()
    cnt = defaultdict(int)
    for i in range(1, N + 1):
        cnt[i % K] += 1

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n,k=map(int,input().split())
mods=[0]*k
mods[0]=n//k
for i in range(1,k):
    mods[i]=(n-i)//k+1
ans=0

for i in range(k):
    if (2*k-i)%k == i:
        ans+=mods[i]**3
print(ans)