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

amari_0 = [] 
amari_Kw2 = []

for i in range(1,N+1,1):
    if i%K == 0:
        amari_0.append(i)
    if i%K == K//2:
        amari_Kw2.append(i)

if K%2 == 0:
    ans = pow(len(amari_0),3)
    ans += pow(len(amari_Kw2),3)
else:
    ans = pow(len(amari_0),3)

print(ans)

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

Solution (Python):
import math
N, K = list(map(int,input().split()))
if K % 2:  ans = (N // K) ** 3
else:
    ans = (N // K) ** 3
    cnt = 0
    temp = K // 2
    while(1):
        if temp > N:  break
        cnt += 1
        temp += K
    ans += cnt ** 3
print(ans)

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

if K%2==0:
    k=K//2
    k_1_list = list(range(k,N+1,k*2))
    k_2_list = list(range(K,N+1,K))
else:
    k=K
    k_1_list = []
    k_2_list = list(range(K,N+1,K))
    


print(len(k_1_list)**3+len(k_2_list)**3)

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

Solution (Python):
def main():
    n,k = map(int,input().split())
    ans = 0
    if k%2==0:
        kouho1 = []
        kouho2 = []
        for i in range(1,n+1):
            if i%k==0:
                kouho1.append(i)
            elif i%k == k/2:
                kouho2.append(i)
        ans += len(kouho1)**3
        ans+= len(kouho2)**3
    else:
        kouho = []
        for i in range(1,n+1):
            if i%k==0:
                kouho.append(i)
        ans += len(kouho)**3

    print(ans)
main()

Solution (Python):
n, k = map(int, input().split())
n0 = n//k
ans = pow(n0, 3)
if k%2 == 0:
    
    r = n%k
    ans += pow(n0+int(n%k>=k//2), 3)
print(ans)

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

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)
def zz():
    return list(map(int, sys.stdin.readline().split()))


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


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]

def nck(n, k, mod=10**9+7):
    bunbo = bunshi = 1
    for i in range(k):
        bunshi = (bunshi * (n-i)) % mod
        bunbo = (bunbo * (i+1)) % mod
    return (bunshi * pow(bunbo, mod-2, mod)) % mod

N,K=zz()
ans = 0
modK = 0
if (K % 2 == 0):
    mod0 = N//K
    ans += mod0**3
    a = (N + K//2)//K
    
    ans+=a**3
else:
    mod0 = N // K
    ans=mod0**3
print(ans)

Solution (Python):


def solve():
    cnt1 = 0
    cnt2 = 0
    for i in range(1,N+1):
        if i % K == 0:
            cnt1 += 1
        elif i % K == K/2:
            cnt2 += 1
    if K%2==1:
        ans = cnt1**3
    else:
        ans = cnt1**3+cnt2**3
    print(ans)

if __name__=="__main__":
    N,K = list(map(int, input().split()))
    solve()

Solution (Python):
n,k = map(int,input().split())
cnt1 = 0
cnt2 = 0
for i in range(1,n+1):
    if i%k == 0: cnt1 += 1
    if i%k == k//2: cnt2 += 1
ans = cnt1**3 if k%2 == 1 else cnt1**3+cnt2**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):
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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

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

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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


if __name__ == '__main__':
    solve()

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

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

if k%2 == 0:
    half_cnt = (n+k//2)//k
    ans += pow(half_cnt,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
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,K = I()
if K%2 == 0:
    num = N//(K//2)     
    if num%2 == 0:
        num1 = num//2
        num2 = num//2
    else:
        num1 = num//2+1
        num2 = num//2
    print(num1**3+num2**3)
else:
    num = N//K
    print(num**3)

Solution (Python):
from collections import Counter

import numpy as np

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

mods = np.arange(1, N + 1) % K
counter = Counter(mods)

ans = 0
for a in counter.keys():
    if (a + a) % K == 0:
        ans += counter[a] ** 3

print(ans)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,k = MI()

if k%2!=0:
    count = 0
    for i in range(1,n+1):
        if (i%k)==0:
            count += 1
    ans = count ** 3
    print(ans)
    exit()
else:
    count_1 = 0
    count_2 = 0
    for i in range(1,n+1):
        if (i%k)==0:
            count_1 += 1
        elif (i%k)==(k//2):
            count_2 += 1
    ans = count_1**3 + count_2**3
    print(ans)
    exit()

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

Solution (Python):
n,k = map(int,input().split())
R = []
Ro = []

if k%2 != 0:
  for i in range(1,n+1):
    if i%k == 0:
      R.append(i)
   
  print(len(R)**3)
else:
  for i in range(1,n+1):
    if i%k == 0:
      R.append(i)
    if i%k == k//2:
      Ro.append(i)
  print(len(R)**3 + len(Ro)**3)

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

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

print(ans)

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

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

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

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

else:
    j=n//k
    m=(n-k//2)//k+1
    
    ans=m*m*m+j*j*j
 
print(ans)

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

Solution (Python):
n,k = map(int,input().split())
a = 0
a2 = 0
for i in range(1,n+1):
    if i % k == 0:
        a += 1
    elif 2*i % k == 0:
        a2 += 1
print(a**3 + a2**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):
n,k=map(int,input().split())
s=0
if k%2==0:
    s0=0
    for i in range(1,n+1):
        if i%k==0:
            s0+=1
    s1=0
    for i in range(1,n+1):
        if i%k==k//2:
            s1+=1
    s=s0**3+s1**3
else:
    s0=0
    for i in range(1,n+1):
        if i%k==0:
            s0+=1
    s=s0**3
print(s)

Solution (Python):
def main():
    n, k = list(map(int, input().split()))
    if k % 2 == 0:
        n_k = sum([1 for i in range(1, n + 1) if i % k == 0])
        n_k2 = sum([1 for i in range(1, n + 1) if i % k == k // 2])
        print(n_k ** 3 + n_k2 ** 3)
    else:
        n_k = sum([1 for i in range(1, n + 1) if i % k == 0])
        print(n_k ** 3)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, K = MAP()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, K = MAP()

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
if k%2==0:
    l=k//2
    x=n//l
    if x%2==0:
        ans=2*(x//2)**3
    else:
        ans=(x//2)**3+(x//2+1)**3
else:
    ans=(n//k)**3
print(ans)

Solution (Python):
def solve(N,K):
    
    
    
    
    
    if K % 2 != 0:
        return (N // K) ** 3
    else:
        return (N // K) ** 3 + ((N + K // 2) // K) ** 3

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

    print(solve(N,K))

if __name__ == "__main__":
    main()

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

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

ans = 0

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

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


print(ans)

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





dic=[0]*k

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

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

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

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


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


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

print(res)

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

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

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

if K%2 == 1:
  print(amaris[0]**3)
else:
  print(amaris[0]**3 + amaris[K//2]**3)

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

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

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


def combination(n, r):
    ans = 1
    for i in range(r):
        ans *= n - i
    for i in range(r):
        ans //= i + 1
    return ans






















num_double = N//K
if K % 2 == 1:
    
    
    print(num_double ** 3)
else:
    
    
    
    s = K // 2
    nums = [a for a in range(s, N+1, K)]
    n = len(nums)
    count = 0
    count += 6 * combination(n, 3)  
    count += 3 * n * (n-1)   
    count += n  
    print(num_double ** 3 + count)

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

Solution (Python):


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


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



ans = 0
for a in range(K):
    b = -a % K
    c = -a % K
    if (b+c)%K == 0:
        ans += arr[a] * arr[b] * arr[c]
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):
n, k = list(map(int, input().split()))
if k % 2 == 1:
  num = n // k
  print(num**3)
else:
  num = n // k
  num2 = (n+ int(k/2))//k
  print(num**3+num2**3)

Solution (Python):
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    """
    変数変換して格子点を数え上げようとして爆死。。。
    素直に問題文からa, b. cは2Kの倍数と分かるので、
    K:odd　→　a, b, cはKの倍数であり、かつこれは必要十分
    K:even →　a, b, cはK//2の倍数であり、必要十分にするには
    　　　　　 a, b, c = 0 (mod K) or a, b, c = K//2 (mod K)
    """
    if K % 2 != 0:
        val1 = (N // K) * (N // K - 1) * (N // K - 2)
        val2 = (N // K) * (N // K - 1) * 3
        val3 = N // K
        print(val1 + val2 + val3)
    else:
        val1 = (N // K) * (N // K - 1) * (N // K - 2) 
        val2 = (N // K) * (N // K - 1) * 3
        val3 = N // K
        
        
        N -= K // 2
        val4 = (N // K + 1) * (N // K) * (N // K - 1)
        val5 = (N // K + 1) * (N // K) * 3
        val6 = N // K + 1
        print(val1 + val2 + val3 + val4 + val5 + val6)


if __name__ == "__main__":
    main()

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

L1 = 0
L2 = 0
for i in range(1,N+1):
    if i%K==0:
        L1+=1
    elif K%2==0:
        if i%(K//2)==0:
            L2+=1
print(L1**3 + L2**3)

Solution (Python):
N, K = map(int, input().split())
num = {i%K:N//K for i in range(1, K+1)}
mod = N % K
for i in range(1, mod+1):
    num[i] += 1

ans = 0
for i in range(K):
    if (2*i) % K == 0:
        cnt = num[i]
        cnt *= num[(K-i)%K] * num[(K-i)%K]
        ans += cnt
print(ans)

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

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

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

Solution (Python):

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


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

Solution (Python):
N,K = (int(x) for x in input().split())
ans = 0
for a in range(1,N+1):
    am = a % K
    if (2*(K-am)) % K != 0:
        continue
    else:
        ans += ((N-(K-am))//K+1) ** 2
print(ans)

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

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

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

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

Solution (Python):
n, k = map(int,input().split())
ans = 0
q, r = divmod(n, k)
for a in range(1, n+1):
    b = k - a%k
    c = k - b%k
    if (c + a)%k == 0:
        now = 1
        if 1 <= b%k <= r: now *= q+1
        else: now *= q
        if 1 <= c%k <= r: now *= q+1
        else: now *= q
        ans += now
print(ans)

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


ans = 0
q,r = divmod(n,k)

for a in range(1, n+1):
    b = k - a%k
    c = k - b%k
    if (c+a)%k == 0:
        
        now = 1
        if 1 <= b%k <= r: now *= q+1
        else: now *= q
        if 1 <= c%k <= r: now *= q+1
        else: now *= q
        ans += now


print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






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






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N,K = IL()



if K%2==0:
  n = N // (K//2)
  k = N // K
  n -= k
else:
  k = 0
  n = N // K

print(n**3+k**3)

Solution (Python):





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

    rests = [x % K for x in range(1, N+1)]
    n_rests = [0 for _ in range(K)]
    
    for r in rests:
        n_rests[r] += 1
    
    ans = 0
    ans += n_rests[0]**3
    for r in range(1, K):
        ans += n_rests[r]**3 if r == K-r else 0
    
    return ans


print(main())

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

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

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

for i in range(1, n+1):
    if i*2 % k == 0:
        count += 1
        x = (n-i) // k
        count += x*6
        if x >= 2:
            count += 6 * (x*(x-1)//2)

print(count)

Solution (Python):

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


if __name__ == "__main__":
    main()

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

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


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

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

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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


N, K = getNM()

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

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

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

L = [0]*(K)

for i in range(1, N+1):
    L[i%K] += 1
ans = 0
for a in range(K):
    b = (K-a)%K
    c = (K-a)%K
    if (b+c)%K==0:
        ans = ans + L[a]*L[b]*L[c]
print(ans)

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

ans = (N//K) ** 3

if not K&1:
    ans += ( (N-K//2) // K + 1) ** 3
print(ans)

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


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
div, rem = divmod(N, K)
print(div ** 3 + (not K & 1) * (div + (0 < K <= (rem << 1))) ** 3)

Solution (Python):
N, K = map(int, input().split())
div, rem = divmod(N, K)
total = div ** 3
if not K & 1:
    total += (div + (0 < K <= (rem << 1))) ** 3
print(total)

Solution (Python):
N, K = map(int, input().split())
div, rem = divmod(N, K)
mods = [div + (0 < i <= rem) for i in range(K)]
total = mods[0] ** 3
if not K & 1:
    total += mods[K >> 1] ** 3
print(total)

Solution (Python):
N, K = map(int, input().split())
div, rem = divmod(N, K)
mods = [div + (0 < i <= rem) for i in range(K)]
total = 0
for mod_a in range(K):
    mod_b = (K - mod_a) % K
    mod_c = (K - mod_b) % K
    if mod_b == mod_c:
        total += mods[mod_a] * mods[mod_b] * mods[mod_c]
print(total)

Solution (Python):

inf = 10 ** 15
mod = 10 ** 9 + 7
n,k = map(int, input().split())
tmp = n//k
ans = (tmp*tmp*tmp)
if k % 2 == 1:
    print(ans)
if k % 2 == 0:
    tmp = (2*n+k)//(2*k)
    ans += (tmp*tmp*tmp)
    print(ans)

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

if k%2 == 1:
    cnts = []
    for i in range(1,n+1):
        if i % k == 0:
            cnts.append(i)
    print(len(cnts)**3)
else:
    k0 = 0
    k1 = 0
    for i in range(1,n+1):
        if i % k == 0:
            k0 += 1
        elif i %k == k//2:
            k1 += 1
    print(k0**3 + k1**3)

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

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

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

ans = 0

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


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

print(ans)