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):
def solve(N, K):
    n = N // K
    
    answer = n ** 3
    if K % 2 == 0:
        m = K//2
        n = (N + m) // K
        
        answer += n ** 3
    return answer
        
N, K = [int(x) for x in input().split()]
print(solve(N, K))

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

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

print(ans)

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


print(ans)

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

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

if k%2==1:
    num=0
    for i in range(1,n+1):
        if i%k==0:
            num+=1
    print(num**3)
else:
    num1=0
    num2=0
    for i in range(1,n+1):
        if i%k==0:
            num1+=1
        elif i%k==int(k/2):
            num2+=1
    print(num1**3+num2**3)

Solution (Python):
n,k = map(int, input().split())
a = n // k
if k % 2 != 0:
    print(a**3)
else:
    b = (n + k // 2) // k
    print(a**3 + b**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())

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

    print(num**3)

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

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

    print(num1**3+num2**3)

Solution (Python):
N, K = map(int, input().split())
count = 0
count2 = 0
ans = 0
f = False
if K % 2 == 0:
    f = True
for n in range(1,N+1):
    if n % K == 0:
        count += 1
    if f and n % K == K//2:
        count2 += 1 
if f:
    ans = count2 ** 3 + count ** 3
else:
    ans = count ** 3
print(ans)

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

count = 0

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

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

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

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

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

print(ans)

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

ans1 = 0
ans2 = 0
for a in range(1, n + 1):
    if a % k == 0:
        ans1 += 1
    if k % 2 == 0 and a % k == k / 2:
        ans2 += 1
ans = ans1 ** 3
if k % 2 == 0 and ans2 > 0:
    ans += ans2**3
print(ans)

Solution (Python):
N,K = [int(x) for x in input().split()]
 
result = 0
 
if (K%2) == 1:
    kouho = N//K
    result+=kouho*kouho*kouho
 
else:
    kouho1 = N//K
    kouho2 = N//(K/2) - kouho1
    result+=kouho1*kouho1*kouho1
    result+=kouho2*kouho2*kouho2
 
print(int(result))

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

if K&1:
  
  answer = (N//K) ** 3
else:
  KK = K//2
  
  even = N // K
  odd = (N//KK) - even
  answer = even ** 3 + odd ** 3

print(answer)

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):
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==int(k/2):
      b+=1
  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:
    m = N//K
    n = int(N/K + 0.5)
    print(m**3 + n**3)

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

Solution (Python):


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


answer = 0
memo = 0
only_even = 0
for i in range(1, n+1):
  if k % 2 == 0:
    if i % k == 0:
      memo += 1
    if i % k == k/2:
       only_even += 1
  else:
    if i % k == 0:
      memo += 1

answer = memo * memo * memo
answer += only_even * only_even * only_even

print(answer)

Solution (Python):
def resolve():
    (N, K) = list(map(int, input().split(" ")))
    srps = [0] * (K+1)
    
    for i in range(1, N+1):
        srps[i%K] += 1
    cnt = 0

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

        

if '__main__' == __name__:
    resolve()

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

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

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

div = N//K

if K % 2 == 1:
    ans = div**3
else:
    div2 = int(N+K/2)//K
    ans = div**3 + div2**3

print(ans)

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

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

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

Solution (Python):

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

def solve1():
    no_rem = 0
    rem_half = 0

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

        rem_half += 1 if k%2 == 0 and i%k == k//2 else 0

    print(no_rem ** 3 + rem_half**3)
    

def solve2():
    no_rem = n//k

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

solve2()

Solution (Python):

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

no_rem = 0
rem_half = 0

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

    rem_half += 1 if k%2 == 0 and i%k == k//2 else 0

print(no_rem ** 3 + rem_half**3)

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

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

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

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

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

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

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

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

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

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

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

print(res)

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

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




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

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

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()
    if k&1:
        print((n//k)**3)
    else:
        add = 1 if n%k>= (k//2) else 0
        print((n//k + add)**3  + (n//k)**3)



solve()

Solution (Python):
from sys import stdin
N,K=[int(x) for x in stdin.readline().rstrip().split()]
ans = 0
a = 0
b = 0
if K % 2 == 0:
    for i in range(1,N+1):
        if i % K == 0:
            a += 1
        if i % K == (K/2):
            b += 1
    print(a**3 + b**3)
else:
    for i in range(1,N+1):
        if i % K == 0:
            a += 1
    print(a**3)

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

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

print(ans)

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

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, K: int):
    k0 = 0
    kh = 0
    if K % 2 == 1:
        k0 = N // K
    else:
        k0 = N // K
        kh = (N+(K//2)) // K

    print(k0**3 + kh ** 3)



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 == 1:
    print((N // K) ** 3)
if K % 2 == 0:
    L = - (N // K) + (N // (int(K/2)))
    print((N//K) ** 3 + L ** 3)

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

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

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

mod_K_zero = len([i for i in range(1, N+1) if i % K == 0])
mod_K_half = len([i for i in range(1, N+1) if i % K == K/2])

print(pow(mod_K_zero, 3) + pow(mod_K_half, 3))

Solution (Python):

"""
C - Triangular Relationship
https://atcoder.jp/contests/abc108/tasks/arc102_a

"""
import sys


def solve(N, K):
    if K == 1:
        return N**3
    if K % 2:
        return (N // K)**3
    res1 = sum([i%K == 0 for i in range(1, N+1)])
    res2 = sum([i%K == K//2 for i in range(1, N+1)])
    return res1**3 + res2**3


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

ans = 0
a = N // K

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

print(ans)

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

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

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

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

count = 0
for a in range(1, N+1):
    b = K - a % K
    if (a % K) == (b % K):
        count += ((N - b) // K + 1) ** 2

print(count)

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

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





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

    ans = (n // k) ** 3

    if k & 1:
        print(ans)
        return

    ans += ((n + k // 2) // k) ** 3
    print(ans)


if __name__ == '__main__':
    main()

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

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:
    a = int(n/k)
    b = int((n+k/2)/k)
    print(a**3 + b**3)

else:
    a = int(n/k)
    print(a**3)

Solution (Python):
n,k = map(int,input().split())
ans = 0
if k%2 == 0:
    
    mod1 = (n+(k//2))//k
    
    mod2 = n//k
    
    ans += mod1**3 + mod2**3
    
else:
    
    modk = n//k
    
    ans += modk**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())




output = 0

output += int(N / K)**3

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

print (output)

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int):
    ns0 = len(range(K, N+1, K))
    ret = ns0 ** 3

    if K % 2 == 0:
        ns1 = len(range(K//2, N+1, K))
        ret += ns1 ** 3

    return ret


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

if __name__ == '__main__':
    main()

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

if K%2 == 1:
    ans = pow(int(N/K),3)
else:
    if N%K >= int(K/2):
        ans = pow(int(N/K) + 1,3)  + pow(int(N/K),3)
    else:
        ans = pow(int(N/K),3) * 2

print(ans)

Solution (Python):

import itertools

N, K = map(int, input().split())
div = []
rest = []
for n in range(1, N+1):
    if K % 2 == 1:
        if n % K  == 0:
            div.append(n)
    else:
        if n % K  == 0:
            div.append(n)
        elif n % K == K/2:
            rest.append(n)

D = len(div)**3
R = len(rest)**3

print(D+R)

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

Solution (Python):
N, K = list(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 = 0

odd = [i for i in range(k, n+1, k)] 
ans += len(odd) ** 3 

if k % 2 == 0:
  
  even = [i for i in range(k//2, n+1, k)]
  ans += len(even) ** 3
  
print(ans)

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

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

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

Solution (Python):


def main():
    num, k_num = map(int, input().split())

    count_all, count_half = 0, 0
    for i in range(1, num + 1):
        if i % k_num == 0:
            count_all += 1
        elif i % k_num == k_num // 2 and k_num % 2 == 0:
            count_half += 1

    print(int(count_all**3 + count_half**3))



if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline




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

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

	
	
if __name__ == "__main__":
	main()

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

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

        ans += base ** 3

        print(ans)

Solution (Python):

import sys


def solve(N: int, K: int):
    ret = (N // K) ** 3
    if K % 2 == 0:
        tmp = K // 2
        count = 1 + (N - tmp) // K
        ret += count ** 3
    print(ret)
    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==1:
	print((n//k)**3)
elif n//(k/2)==n//k*2:
	print((n//k)**3*2)
else:
	print((n//k)**3+(n//k+1)**3)

Solution (Python):

import sys
import math


def solve(N: int, K: int):
    candidate = 0
    if K % 2 == 0:
        candidate = math.floor(N / (K//2))
        evenCandidate = math.floor(candidate / 2)
        oddCandidate = candidate - evenCandidate
        print(evenCandidate ** 3 + oddCandidate**3)
    else:
        candidate = math.floor(N/K)
        print(candidate**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())

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

print(ans)

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

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

	print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

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

def comb(x):
    return x ** 3


if K % 2 == 0:
    n = N // K
    m = N // (K // 2) - n
    print(comb(n)+comb(m))
else:
    print(comb(N//K))

Solution (Python):
def solve(n, k):
    m = n // k
    res = m**3
    if k % 2 == 0:
        m2 = n // (k // 2) - m
        res += m2**3
    return res 

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

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

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

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

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


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

print(a+(N//K)**3)

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

Solution (Python):


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

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

def solve(n, k):
    r = (n // k) ** 3

    if k % 2 == 0:
        x = n // k
        if n % k >= k // 2:
            x += 1
        r += x ** 3

    return r

main()

Solution (Python):
n, k = map(int, input().split())
ans = 0
temp = n // k
ans += temp ** 3

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

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

Solution (Python):


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

odd = n // k
even1 = n // k
even2 = (n + int(k/2)) // k

if k % 2 == 0:
    print(even1 ** 3 + even2 ** 3)
else:
    print(odd ** 3)

Solution (Python):
n,k= map(int,input().split())
rclass = [0]*(k)
for i in range(k):
    rclass[i] = int(n/k)
if n%k  != 0:
    for i in range(1,n%k+1):
        rclass[i] += 1
import math
def Comb(a,b):
    if a>= b:
        return int(math.factorial(a)/(math.factorial(b)*math.factorial(a-b)))
    else:
        return 0
def ans(lis,inte):
    return max(0,lis[inte])*max(0,lis[inte]-1)*max(0,lis[inte]-2)+Comb(lis[inte],2)*6+lis[inte]
print(ans(rclass,0) if k%2 == 1 else ans(rclass,int(k/2))+ans(rclass,0))

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

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

Solution (Python):
from collections import Counter
N, K = map(int, input().split())
a = []
for i in range(1, N+1):
    a.append(i%K)
b = Counter(a)
ans = 0
for x in b:
    if x == 0:
        ans += b[x]**3
        continue
    if K%2 == 0 and x == K//2:
        ans += b[K//2]**3
print(ans)

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

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

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

print(counter1**3 + counter2**3)

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

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

Solution (Python):
n,k = map(int,input().split())
if k % 2 == 1:
    a = n // k
    print(a ** 3)
else:
    a = n // k
    t = a ** 3
    a1 = int(k/2)
    b1 = k - a1
    if n % k >= a1:
        s0 = (n // k) + 1
    else:
        s0 = n // k
    if n % k >= b1:
        s1 = (n // k) + 1
    else:
        s1 = n // k
    s = (s0 ** 2) * s1
    print(s + t)

Solution (Python):
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) 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 MI(): return map(int, sys.stdin.readline().split())  
def II(): return int(sys.stdin.readline())  
def IS(): return input()  
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)


N, K = MI()
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,m=map(int,input().split())
if m%2!=0:
  print((n//m)**3)
else:
  if n//(m//2)%2==0:
    print((n//m)**3+(n//(m//2)//2)**3)
  else:
    print (int((n//m)**3+((n//(m//2)//2)+1)**3))

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, factorial, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')



N, K = 0, 0


def set_inputs():
    global N, K
    N, K = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    sum_abc = itertools.dropwhile(
        lambda x: x < 3,
        itertools.takewhile(
            lambda x: x <= 3 * N,
            itertools.count(2 * K, K)
        )
    )
    ans = 0
    if K % 2 == 0:
        
        
        x = N // K
        y = N // (K // 2) - x
        ans = x ** 3 + y ** 3
    else:
        
        x = N // K
        ans = x ** 3
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


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


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

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

Solution (Python):
N,K = map(int,input().split())
if K % 2 == 0:
    K_unit1 = int(N//K)
    K_half = K//2
    N_khalf = N-K_half
    K_unit2 = 1 + int(N_khalf//K)
    K1 = K_unit1 ** 3
    K2 = K_unit2 ** 3
    out = K1 + K2
else:
    K_unit1 = int(N/K)
    out = K_unit1 ** 3

print("{0}".format(out))

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

Solution (Python):
N,K = list(map(int,input().split()))
def f(n):
    return n*(n-1)*(n-2) + n*(n-1)*3 + n
if K%2:
    n = N//K
    print(f(n))
else:
    n = N//(K//2)
    a = n//2
    b = (n+1)//2
    print(f(a)+f(b))