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):
import sys
import itertools
input = sys.stdin.readline


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


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    res = 0
    P = K // 2 if K % 2 == 0 else K
    for a in range(P, N + 1, P):
        k = a // K + 1
        l = (N + a) // K
        res += (l - k + 1) ** 2

    print(res)


if __name__ == "__main__":
    main()

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


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


else:
    K2 = K // 2
    
    half = (N // K2 - N // K)
    print(half ** 3 + (N // K) ** 3)

Solution (Python):
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

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

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

inf = float("inf")


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

if __name__ == "__main__":
    main()

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

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    
    N, K = Scanner.map_int()
    if K % 2 == 0:
        c1, c2 = 0, 0
        for i in range(1, N+1):
            if i % K == 0:
                c1 += 1
            if i % K == K // 2:
                c2 += 1
        print(c1 ** 3 + c2 ** 3)
    else:
        print((N // K) ** 3)
    return


if __name__ == "__main__":
    main()

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

else:
    print((N//K)**3)

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

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

print(ans)

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

Solution (Python):
n, k = map(int, input().split())
num = [0 for _ in range(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):
n,k=map(int,input().split())
x=0
y=0
for i in range(1,n+1):
    if i%k==0:
        x+=1
    if i%k==k//2:
        y+=1
ans=x**3
if k%2==0:
    ans+=y**3
print(ans)

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

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

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

x = 0
for a in range(1, n + 1):
    if (2 * a) % k == 0:
        x += 1

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

print((x - y) ** 3 + y ** 3)

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

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

s = []
for a in range(1, n + 1):
    if (2 * a) % k == 0:
        s.append(a)

t = []
for a in range(1, n + 1):
    if a % k == 0:
        t.append(a)

print((len(s) - len(t)) ** 3 + len(t) ** 3)

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

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

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

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

    count+= num + num*(num-1)*(num-2) + num*(num-1)*3
print(count)

Solution (Python):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline









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

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

ans = 0
for v in range(1, K + 1):
    b = (K - v) % K
    c = (K - v) % K
    if (b + c) % K != 0:
        continue
    ans += m[v % K] * m[b] * m[c]
print(ans)

Solution (Python):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor


"""
need to consider the case that ticket is not enough to lower everything
"""


def calc(num):
    return num**3


N = gi()
K = gi()

num = N // K
ans = calc(num)

if (K % 2 == 0):
    if N % K >= K // 2:
        num += 1
    ans += calc(num)

print(ans)

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


if __name__ == '__main__':
    solve()

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

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






kt=N//K


z=kt*kt*kt


o=0
if K&1==0:
    an=kt+(1 if N%K>=K/2 else 0)
    o=an**3

print(z+o)

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

if (K % 2) == 1:
    count = N // K
    print(count**3)
else:
    count1 = N // K
    count2 = 0
    for i in range(N + 1):
        if (i % K) == (K / 2):
            count2 += 1
    
    print(count1**3 + count2**3)

Solution (Python):
def examC():
    N, K = LI()
    a = N//K
    ans = a**3
    if K%2==0:
        b = (N + K//2)//K
        ans +=b**3
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()

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

if k/2==k//2:
    p=n//(k//2)

    if p==0:
        print(0)
    elif p==1:
        print(1)
    elif p==2:
        print(2)
    elif p==3:
        print(9)
    elif p==4:
        print(16)
    else:
        m=16
        for i in range(5,p+1):
            m+=1+6*((-(-i//2))-1)+6*((-(-i//2))-1)*(-(-i//2)-2)//2
        print(m)
    
else:
    p=n//k

    if p==0:
        print(0)
    elif p==1:
        print(1)
    elif p==2:
        print(8)
    else:
        m=8
        for i in range(3,p+1):
            m+=1+6*(i-1)+6*(i-1)*(i-2)//2
        print(m)

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):
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):
n, k = map(int, input().split())

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

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

print(res)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
t = [0] * K
for i in range(1, N + 1): t[i % K] += 1

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

Solution (Python):
import math

nk = input().split()
n = int(nk[0])
k = int(nk[1])
res = 0

if k % 2 == 1:
    
    res = int(math.pow(math.floor(n / k), 3))
else:
    mk0 = 0
    mkk2 = 0
    for i in range(1, n+1):
        if i % k == 0:
            mk0 += 1
        if i % k == (k / 2):
            mkk2 += 1
    res = int(math.pow(mk0, 3) + math.pow(mkk2, 3))

print(res)

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

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    ls = []
    for i in range(1, n + 1):
        ls.append(i % k)
    h = 0
    j = 0
    for v in ls:
        if v == 0:
            j += 1
        if v * 2 == k:
            h += 1
    print(j ** 3 + h ** 3)


if __name__ == '__main__':
    solve()

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

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

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

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

    print(ans)


main()

Solution (Python):
import math
N, K = map(int,input().split())
ans = 0
ans += (N//K)**3

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

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

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

Solution (Python):
n,k = map(int, input().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())
c = (n//k)**3
if k%2:
  print(c)
else:
  m = ((n-k//2)//k) + 1
  c += m**3
  print(c)

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

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline
N,K = map(int,input().split())

if K%2 != 0:
    pattern = N//K
    print(pattern ** 3)
else:
    k = K // 2
    p1 = N//K
    p2 = N//k
    p3 = p2-p1
    print(p2**3 - 3*p1*p3*p3 - 3* p1*p1*p3)

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys

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

ans = (N//K)**3

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

Solution (Python):

import sys

def solve_even(N: int, K: int):
    return pow((N - (K//2)) // K + 1, 3) + pow((N - K) // K + 1, 3)

def solve(N: int, K: int):
    return pow(N // K, 3) if K % 2 else solve_even(N, K)

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))
    print(solve(N, K))

if __name__ == '__main__':
    main()

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

cntMod = N//K


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

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

if K%2==1:
  m=N//K
  print(m**3)
else:
  m=(N//K)
  n=(N+K//2)//K
  print(m**3+n**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())

ans = (n // k)** 3
if k % 2 == 0:
  ans += ((n + k // 2) // 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 // 2) // k, 3)
print(ans)

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


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


if __name__ == '__main__':
    main()

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

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

ans = 0
for i in range(3):
    if i == 0:
        ans += count
        ans += count2
    elif i == 1:
        
        ans += 3*count*(count-1)
        ans += 3*count2*(count2-1)
    else:
        ans += count*(count-1)*(count-2)
        ans += count2*(count2-1)*(count2-2)


print(ans)

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


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

ans = 0


for a in range(K):
  b = (K-(a%K))%K
  c = (K-(a%K))%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 == 1:
    knum = n // k
    print(knum ** 3)
else:
    knum = n // k
    kodd = (n + k // 2) // k
    print(knum ** 3 + kodd ** 3)

Solution (Python):
N, K = [int(i) for i in input().split()]
cnt = 0
if K % 2 == 0:
    for i in range(1, 2*N//K+1):
        cnt += 1 + (2*N//K-i)//2 * 6 + (2*N//K-i)//2 * ((2*N//K-i)//2 - 1) * 3
else:
    for i in range(1, N//K+1):
        cnt += 1 + (N//K-i) * 6 + (N//K-i) * ((N//K-i) - 1) * 3

print(cnt)

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

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

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


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

ans = 0
for a in range(K+1):  
    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())

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())
ans = (n//k)**3
if not k % 2: ans += ((n+k//2)//k)**3
print(ans)

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

ans = 0

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

for a in range(K+1):
    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())
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 = list(map(int, input().split()))
ans = 0
a = [0]*k
for i in range(1, n+1):
  a[i%k] += 1

ans += a[0]**3
if k%2==0:
  ans += a[k//2]**3
print(ans)

Solution (Python):

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

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

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

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

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

Solution (Python):





from sys import stdin,setrecursionlimit


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

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

Solution (Python):
[n,k]=[int(x) for x in 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())
if K%2==1:
    s=N//K
    print(s**3)
    exit()
k=K//2
s=N//k
num=0
if s%2==0:
    print((s**3)//4)
    exit()
t=((s//2+1)**2)*(s//2+1)
u=((s//2)**2)*(s//2)
print(t+u)

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


if __name__ == '__main__':
    func()

Solution (Python):


import sys


tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

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

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())
if k%2!=0:
	x=n//k
	print(x**3)
else:
	x=n//k
	y=(n+(k//2))//k
	print(x**3+y**3)

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

k = []
half_k = []
for i in range(1,N+1):
    if(i%K == 0):
        k.append(i)
    elif(i%(K/2) == 0):
        half_k.append(i)

if(K%2 == 0):
    print((len(k) ** 3) + (len(half_k) ** 3))
else:
    print(len(k) ** 3)

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

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

k = []
half_k = []
for i in range(1,N+1):
    if(i%K == 0):
        k.append(i)
    elif(i%(K/2) == 0):
        half_k.append(i)

if(K%2 == 0):
    print((len(k) ** 3) + (len(half_k) ** 3))
else:
    print(len(k) ** 3)

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

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

if __name__ == "__main__":
    main()

Solution (Python):
n, k = list(map(int, input().split()))
count = 0
i = 1
zero = 0
rem = 0
if k % 2 == 0:
    while i <= n:
        if i % k == 0:
            zero += 1
        elif i % int(k/2) == 0:
            rem += 1
        i += 1
    print(zero ** 3 + rem ** 3)
else:
    while i <= n :
        if i % k == 0:
            count += 1
        i += 1
    print(count ** 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):
n, k = map(int, input().split())
tmp1 = n // k

if k % 2 == 0:
    tmp2 = (n + k//2) // k
else:
    tmp2 = 0

ans = tmp1 ** 3 + tmp2 ** 3

print(ans)

Solution (Python):
N, K = map(int, input().split())
ans = 0
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())
e = 0
h = 0
for i in range(1, n + 1):
    if k % 2 == 0 and i % k == k // 2:
        h += 1
    if i % k == 0:
        e += 1
print(h * h * h + e * e * e)

Solution (Python):

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

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

print(ans)

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

ans = 0
cnt = 0
for i in range(K, N+1, K):
    cnt += 1
ans += pow(cnt, 3)

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

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 = [int(v) for v in input().split()]

kcnt = [0] * K

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

ans = 0
for a in range(1, K + 1):  
    b = K - (a % K)
    c = K - (a % K)
    if (a + b) % K == 0 and (a + c) % K == 0 and (b + c) % K == 0:
        ans += kcnt[a%K] * kcnt[b%K] * kcnt[c%K]

print(ans)

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

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

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

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

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

if K%2 == 1:
	count3 = N//K
	ans = count3 ** 3

print(ans)

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

"""
2(a+b+c) = nK <= 6N
n=1,2,......,6N//K

a+b=iK-c<=2
2N>=iK-c

a+c=iK
a+b=jK
b-c=XK Xは整数
b+c=kK kは自然数
2b=(X+k)K 
b=X'K/2
→K=2a：bはa刻み
→K=2a-1：bはK刻み
"""

























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

"""偶数の場合
a+b=K max_kizami通り
    kizami kizami [kizami,kizami+K,...]
a+b=2K 2max_kizami　+　N//K通り
    1kizami 3kizami [kizami,kizami+K,...]
    2kizami 2kizami [2kizami,4kizami,...]
    3kizami 1kizami [kizami,kizami+K,...]


a+b=2(N//K)K
    max_kizami*kizami max_kizami*kizami [kizami,...]
"""
"""奇数の場合
K K [K,2K,...]

2K K []
K 2K []

3K K []
2K 2K []
K 3K []



max_kizami
"""

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

x, y = 0, 0

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

print(x ** 3 + y ** 3)

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)**3 + (n//k + 1)**3)
  else:
    print((n//k)**3 * 2)

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

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

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

Solution (Python):

def main():
    N, K = list(map(int, input().rstrip().split()))
    a = N // K
    if K % 2 != 0:  
        print(a ** 3)
    else:  
        b = (N + K // 2) // K
        print(a ** 3 + b ** 3)


if __name__ == "__main__":
    main()

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


cc = N//K
res = cc*cc*cc
if K%2 == 0 and N>=K/2:
    cc = (N-K/2)//K+1
    res+= cc*cc*cc

print(int(res))

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())
ans = 0
b, c = 0, 0
amari = [0] * (K+1)

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

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

print(ans)

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

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

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 + int(K / 2)) // K) ** 3)
else:
  print((N // K) ** 3)

Solution (Python):
import numpy as np

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

n_set = 0
if K % 2 == 0:
  if N >= K/2:
  	n_modhalf = (N - K/2) // K + 1
  	n_set += n_modhalf ** 3
  
n_modK = N // K
n_set += n_modK ** 3

print(int(n_set))

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

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

li=[0]*K
for i in range(1,N+1):
  if (i*2)%K==0:
    li[i%K]+=1
print ( sum( [ v**3 for v in li ] ) )

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

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

print(count)

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

Solution (Python):
N, K = map(int, input().split())
list0, list1, list2 = [],[],[]
j = 1

if K % 2 == 1:
  i = K * 1
  while i <= N:
    list0.append(int(i))
    j += 1
    i = K * j
  ans = len(list0) ** 3
else:
  i = K / 2
  while i <= N:
    if j % 2 == 0:
      list1.append(int(i))
    if j % 2 == 1:
      list2.append(int(i))
    j += 1
    i = K * j / 2
  ans = len(list1) ** 3 + len(list2) ** 3
print(ans)

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







ans = 0
cnt = N//K
ans += cnt ** 3

if K % 2 == 0:
    n = 0
    cnt = 0
    while (n + 1/2) * K <= N:
        cnt += 1
        n += 1
    ans += cnt ** 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 == 0: 
    a = N//K
    b = (N+K//2)//K
    ans = a ** 3 + b ** 3
else: 
    a = N//K
    ans = a ** 3

print (ans)

Solution (Python):
N,K = map(int,input().split())
if K%2:
    tmp = len(range(K,N+1,K))
    print(tmp**3)
else:
    tmp = len(range(K//2,N+1,K))
    tmp2 = len(range(K,N+1,K))
    print(tmp**3+tmp2**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):
a,b=map(int,input().split())
c=a//b
print((c**3)+((a-b//2)//b+1)**3*(1-b%2))

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

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

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

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

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

    print(count1 ** 3 + count2 ** 3)

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