Problem:
 Score : 300 points    Problem Statement You are given integers N and K . Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K .
The order of a,b,c does matter, and some of them can be the same.      Constraints  1 \leq N,K \leq 2\times 10^5  N and K are integers.         Input Input is given from Standard Input in the following format:  N  K       Output Print the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K .        Sample Input 1 3 2      Sample Output 1 9  (1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.       Sample Input 2 5 3      Sample Output 2 1       Sample Input 3 31415 9265      Sample Output 3 27       Sample Input 4 35897 932      Sample Output 4 114191

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

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

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

Solution (Python):
a = list(map(int,input().split()))
b = a[0]//a[1]
if a[1] % 2 != 0:
  print(b**3)
else:
  if a[0]%a[1] >= a[1]//2:
    print(b**3 + (b+1)**3)
  else:
    print(2*b**3)

Solution (Python):








def solve(N, K):
    div0 = N // K
    divh = (N + (K // 2)) // K if K % 2 == 0 else 0
    import math
    print(div0 ** 3 + divh ** 3)


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

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

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

from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


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





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




def I(): return int(sys.stdin.buffer.readline())





def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()




def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')







def IR(n): return [I() for i in range(n)]







def LIR(n): return [LI() for i in range(n)]







def SR(n): return [S() for i in range(n)]







def LSR(n): return [LS() for i in range(n)]







def SRL(n): return [list(S()) for i in range(n)]


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

    else:
        print((n // k) ** 3 + (n // k) ** 3)

Solution (Python):
N,K=map(int,input().split())
if K%2==0:
    x=N//(K//2)
    print((x-x//2)**3+(x//2)**3)
else:
    print((N//K)**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(1, n+1):
    mod = a % k
    temp_mod = (k-mod)%k
    
    if (temp_mod*2) % k != 0:
        continue
    ans += num[temp_mod]**2
print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    ans = 0
    for a in range(K):
        if 2 * (K - a) % K == 0:
            ans += R[a] * R[(K - a) % K] ** 2

    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

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

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

    ans = 0
    for a in range(k):
        b = (k-a)%k
        if 2*b%k == 0: 
            ans += R[a] * R[b] * R[b]

    print(ans)

if __name__=="__main__":
    main()

Solution (Python):
def main():
    N, K = map(int, input().split())
    ans = 0
    if K % 2 == 1:
        ans = (N // K) ** 3
    else:
        ans = (N // K) ** 3
        r = K // 2
        ans += len([1 for v in range(1, N+1) if v % K == r]) ** 3
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    ans = 0
    step = K if K % 2 else K // 2

    for a in range(step, N + 1, step):
        l = a // K + 1
        r = (N + a) // K
        if r >= l:
            ans += (r - l + 1) ** 2

    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

print(ans)

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

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

Solution (Python):
N, K = list(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 == 0:
  print((N//K)**3 + ((N-(K//2))//K+1)**3)
else:
  print((N//K)**3)

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

Solution (Python):

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

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

Solution (Python):


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


ans = 0 
for a in range(1, n+1):
    ra = a%k 
    rbc = k-ra
    if (2*rbc) % k == 0:
        ans += ((n-rbc)//k + 1)**2

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):
import sys 

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

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

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

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

if k%2==1:
  a=n//k
  print(a**3)
  
else:
  half=k//2
  if half>k:
    print(0)
  else:
    ans=0
    while half<=n:
      ans+=1
      half+=k
      
    a=n//k
    print(a**3+ans**3)

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

Solution (Python):
import sys









MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n, k = read_ints()
    if k % 2:
        print((n // k)** 3)
    else:
        print((n // k)** 3 + ((n + k // 2) // k)** 3)     

if __name__ == '__main__':
    Main()

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

if k ==1:
    print(n**3)

elif k ==2:
    m = n % 2
    o = n//2
    print((o+m)**3+o**3)

elif k % 2==1:
    x = n//k
    print(x**3)

else:
    x = n//k
    y = n//(k//2)
    print(x**3+(y-x)**3)

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

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

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial  
from bisect import bisect_left, bisect_right  

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7


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


pl = lambda x: print(*x, sep="\n")

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

com = combinations

res = 0
if K % 2 == 0:
    res += len(range(0 + K // 2, N + 1, K)) ** 3
    res += len(range(K, N + 1, K)) ** 3
else:
    res += len(range(K, N + 1, K)) ** 3
print(res)

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

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

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

am = [0]*k
for i in range(1, n+1):
  res = i%k
  if (res+res)%k==0:
    am[res]+=1



ans = 0
for i in am:
  ans += i**3 
  
print(ans)

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

if k%2==1:
    cnt0=n//k

    print(cnt0**3)
else:
    cnt0=n//k
    cnt1=(n-k//2)//k+1 if n>=k//2 else 0
    ans=cnt0**3+cnt1**3
    print(ans)

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

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

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

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

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

ans = 0
for am in range(0, k):
    bm = (k - am) % k
    cm = (k - am) % k
    if (bm + cm) % k == 0:
        ans += modk[am] * modk[bm] * modk[cm]
print(ans)

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

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

from collections import Counter
dic=Counter(s)

ans=0
for a in dic:
  if (2*a)%k==0:
    ans=ans+dic[a]*dic[(k-a)%k]*dic[(k-a)%k]
    
print(ans)

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

if k%2==0:
  for i in range(1,n+1):
    if i%k==0:
      am_0.append(i)
    
    elif i%k==(k//2):
      am_k2.append(i)
  print(len(am_0)**3+len(am_k2)**3)
  
else:
  print(pow((n//k),3))

Solution (Python):
def main():
  N, K = [int(n) for n in input().split(" ")]

  mul_K = int(N/K)

  if K % 2 == 1:
    print(mul_K ** 3)
    return 0
  
  mul_K_half = int(2 * N/K)
  mul_K_half_but_K = mul_K_half - mul_K
  print(mul_K ** 3 + mul_K_half_but_K ** 3)
  return 0

main()

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

Solution (Python):
n,k=map(int,input().split())
l=[0]*k
ans=0
for i in range(1,n+1):
    l[i%k]+=1
for j in range(k):
    bj=(-j)%k
    cj=(-j)%k 
    if (bj+cj)%k==0:
        ans+=(l[j]*l[bj]*l[cj])
        
print(ans)

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

s = 0

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

print(s)

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

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

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

Solution (Python):
import sys


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


def main():
    N, K = map(int, input().split())
    if K % 2 == 1:
        a = N // K
        print(a * a * a)
        exit()
    else:
        a = N // K
        count = a * a * a
        b = (N+K//2)//K
        count+=b*b*b
        print(count)



if __name__ == "__main__":
    main()

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

for i in range(1, n + 1):
    if i % k == 0:
        mod_0 += 1
    elif i % k == (-i) % k:
        mod_harf += 1

res = mod_0 ** 3 + mod_harf ** 3
print(res)

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

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    ans = pow(N // K, 3)
    if K % 2 == 0 and N >= K // 2:
        ans += pow((N - K // 2) // K + 1, 3)

    print(ans)
    return


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()

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

print(ans)

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):
N,K=map(int,input().strip().split())

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

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

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


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

print(ans)

Solution (Python):
N, K = map(int, input().split())
ans = 0
extra = [0]*K
for i in range(1, N+1): extra[i%K] += 1 

for a in range(K):
    b = (K-a) % K
    c = (K-a) % K

    if (b + c) % K == 0:
        ans += extra[a] * extra[b] * extra[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 ai in range(K):
    
    
    bi = (K - ai) % K
    ci = (K - ai) % K
    
    if (bi + ci) % K == 0:
        ans += l[ai] * l[bi] * l[ci]
print(ans)

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

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

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

Solution (Python):
N,K = (int(T) for T in input().split())
Reminder = [0]*K
for NT in range(1,N+1):
    Reminder[NT%K] += 1
Count = 0
for RA in range(0,K):
    RB = (K-RA)%K
    RC = (K-RA)%K
    if (RB+RC)%K==0:
        Count += Reminder[RA]*Reminder[RB]*Reminder[RC]
print(Count)

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

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

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

if __name__ == "__main__":
    main()

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

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

n = N // (K//2)
n_odd, n_even = (n+1)//2,n//2
print(n_odd**3+n_even**3)

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

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

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

Solution (Python):
N,K = list(map(int,input().split()))
modZeroCount = N // K
modHalfCount = 0
if K % 2 == 0:
    modHalf = K // 2
    if N % K < modHalf:
        modHalfCount = modZeroCount
    else:
        modHalfCount = modZeroCount + 1
answer = modZeroCount ** 3 + modHalfCount ** 3
print(answer)

Solution (Python):


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

ans = 0

num_multiple = n//k

ans += num_multiple**3

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



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



multip_K =[i for i in range(K,N+1,K)]


le =len(multip_K)
ans_mod_0 =le **3



ans_mod_haf =0
if K%2 ==0:
    multip_haf =[i for i in range(1,N+1) if i %K ==K//2 ]
    le_haf =len(multip_haf)
    ans_mod_haf =le_haf **3

ans =ans_mod_0 +ans_mod_haf
print(ans)

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

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

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

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    
    num_0 = N // K
    if K % 2 == 0:
        num_K_half = N // K + (1 if N % K >= K // 2 else 0)
    else:
        num_K_half = 0

    ans = num_0 ** 3 + num_K_half ** 3
    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):

import sys


def solve(N: int, K: int):
    e = sum(i%K!=0 and i*2%K==0 for i in range(1, N+1))
    z = sum(i%K==0 for i in range(1, N+1))
    return pow(e, 3) + pow(z, 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))  
    print(solve(N, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

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

Solution (Python):
def main():
    n,k=map(int,input().split())
    ans=0
    baisuu=n//k
    ans+=baisuu**3
    if k%2==0:
        if baisuu*k+k//2<=n:
            hanbun=baisuu+1
        else:
            hanbun=baisuu
        ans+=hanbun**3
    print(ans)
if __name__=="__main__":
    main()

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

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

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  if k%2==0:
    return (n//(k//2)-(n//k))**3+(n//k)**3
  return (n//k)**3


print(main())

Solution (Python):
n,k=map(int,input().split())
ans=0
if k>2*n:
  print(ans)
else:
  r=k
  for i in range(1,k):
    if 2*i%k==0:
      r=i
  amari=set()
  for i in range(1,(n-r)//r+1+1):
    if r*i%k in amari:
      continue
    else:
      amari.add(r*i%k)
      q=(n-r*i)//k+1
      ans+=q**3
  print(ans)

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


kcd=0
kcd_half=0
for i in range(1,n+1):
    if k&1 and i%k==0:
        kcd+=1
    elif not k&1:
        if i%k==0:
            kcd+=1
        if i%k==k//2:
            kcd_half+=1

print(kcd*kcd*kcd+kcd_half*kcd_half*kcd_half)

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

Solution (Python):
import itertools
ans = 0
N, K = [int(i) for i in input().split()]
x = 0
y = 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):
import sys
input = sys.stdin.readline
N,K=list(map(int,input().split()))
if K%2 == 0:
    A = list(range(K//2,N+1,K))
    B = list(range(K,N+1,K))
else:
    A = list(range(K,N+1,K))
    B = []
print(len(A)**3+len(B)**3)

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

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

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

left = n % k
cc = [0] * k
for ii in range(k):
	cc[ii] += n / k
	if 0<ii <= left: cc[ii] += 1


r = 0
for ii,vv in enumerate(cc):
	if (2*ii) % k == 0:
		jj = (k - ii) % k
		r += vv * ((cc[jj]) ** 2) 
print r

Solution (Python):

import collections 
n,k = map(int, raw_input().split(' '))

left = n % k
cc = [0] * k
for ii in range(k):
	cc[ii] += n / k
	if 0<ii <= left:
		cc[ii] += 1


r = 0
for ii in range(len(cc)):
	if (- 2*ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 

print r

Solution (Python):

import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
left = n % k
for ii in range(k):
	cc[ii] += n / k
	if 0<ii <= left:
		cc[ii] += 1


r = 0
for ii in cc:
	if (- 2*ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 

print r

Solution (Python):
import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if (- 2*ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 
		
print r

Solution (Python):

import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if 2*(k - ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 
		
print r

Solution (Python):

import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if 2*(k - ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 
		
print r

Solution (Python):

import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if ((k - ii) % k + (k - ii) % k) % k == 0:
		r += cc[ii] * cc[(k - ii) % k ] * cc[(k - ii) % k] 
print r