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

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
ans = 0
def A(x,N,K):
    p = N // K
    q = N % K
    if x == 0:
        x += K
    if x <= q:
        return p + 1
    else:
        return p
for a_mod in range(K):
    b_mod = (K - a_mod) % K
    c_mod = b_mod
    if (b_mod + c_mod) % K == 0:
        ans += A(a_mod,N,K) * A(b_mod,N,K) * A(c_mod,N,K)

print(ans)

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

ans = 0
for a in range(1, n+1):
    b = a % k
    c = a % k
    if (b + c) % k != 0:
        continue

    count = (n-b)//k
    if b != 0:
        count += 1
    ans += count**2

print(ans)

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

Solution (Python):

import sys
input = sys.stdin.readline

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



quotient = n//k
modk_cnt = [quotient for i in range(k)]
for i in range(n%k):
    modk_cnt[i+1]+=1

ret = modk_cnt[0]**3
if k%2==0:
    ret += modk_cnt[k//2]**3

print(ret)

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

cnt=0
ans=0

for a_mod in range(k):
  if a_mod==0:
    b_mod,c_mod=0,0
  else:
    b_mod=k-a_mod
    c_mod=k-b_mod
    if c_mod!=k-a_mod:
      continue

  cnt_a=0
  for a in range(a_mod,n+1,k):
    if a!=0:
      cnt_a+=1
  ans+=cnt_a**3
print(ans)

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

list1 = []
listeven = []

for i in range(1,n+1):
    if i%k == 0: list1.append(i)
    elif i%k == k/2: listeven.append(i)

if k%2 != 0:
    print(len(list1)**3)

else:
    print(len(list1)**3 + len(listeven)**3)

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

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

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

print(c_triangular_relationship())

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

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

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

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

x=n//k

if k%2==0:
    y=(n+k//2)//k
else:
    y=0
if x>=2:
    x=x+x*(x-1)*(x-2)+x*(x-1)*3
elif x==1:
    x=x+x*(x-1)*3
if y>=2:
    y=y+y*(y-1)*(y-2)+y*(y-1)*3
elif y==1:
    y=y+y*(y-1)*3
print(x+y)

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

print(ans)

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

Solution (Python):
from sys import stdin
from math import factorial

n,k = [int(x) for x in stdin.readline().rstrip().split()]
point = 0
point2 = 0
if k % 2 == 1:
    for i in range(1,n+1):
        if i%k == 0:
            point += 1
else:
    for i in range(1,n+1):
        if i % k == 0:
            point += 1
        elif i%k == k//2:
            point2 += 1

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

print(point**3+point2**3)

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

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

x_1=N//K
if (N//K)*K+K//2>N:
  x_2=N//K
else:
  x_2=N//K+1
if K%2==0:
  answer=x_1**3+x_2**3
else:
  answer=x_1**3
print(answer)

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

if k % 2 == 0:
    
    x1 = int(n // k)
    
    x2 = int((n + k/2) // k)

    print(x1 ** 3 + x2 ** 3)

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()


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


else:
    n1 = n2 = 0
    for i in range(1,N+1):
        if i%K == 0:
            n1 += 1
    print(n1**3)

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

Solution (Python):



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

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

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

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

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

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

ans += syo**3
print(ans)

Solution (Python):
import sys
n, k = [int(i) for i in sys.stdin.readline().split()]
res = (n // k) ** 3
if k % 2 == 0:
    res += ((n % k >= k // 2) + (n // k)) ** 3
print(res)

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

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

Solution (Python):

n,k=list(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().split())

num_mod0 = n // k
num_modk2 = (n + k//2) // k

if k % 2 == 0:
  total = num_mod0**3 + num_modk2 ** 3
else:
  total = num_mod0**3
print(total)

'''
Pairs_mod = []
for moda in range(0, k // 2 + 1):
  modb = (k - moda) % k
  for modc in range(k):
    
    if (modc + moda) % k == 0 and (modc + modb) % k == 0:
      Pairs_mod.append([moda, modb, modc])
print(Pairs_mod)
'''

Solution (Python):
import sys
from collections import deque
from itertools import permutations
input = sys.stdin.readline

N, K = [int(x) for x in input().strip().split()]
l1 = deque([])
l2 = deque([])
ans = deque([])
c = K

while c <= N:
    l1.append(c)
    c += K
ans = len(l1) ** 3

if K % 2 == 0:
    c = K / 2
    while c <= N:
        l2.append(c)
        c += K
ans += len(l2) ** 3

print(ans)

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

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

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

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

Solution (Python):
n,k = (int(x) for x in input().split())
"""cnt=0
for a in range(1,n+1):
	for b in range(1,n+1):
		for c in range(1,n+1):
			if a<= b & b<=c:
				
				if (a+b)%k is 0 and (b+c)%k is 0 and (c+a)%k is 0:
					if a is b and b is c and c is a:
						cnt += 1
					elif a is b or b is c or c is a:
						cnt += 3
					elif a is not b and b is not c and c is not a:
						cnt += 6
					else: 
						print(f**k)

print(cnt)
"""
cnt=0
cnt2=0
for i in range(1,n+1):
  if k % 2 is 1:
  	if i % k is 0:
  		cnt += 1
  else:
  	if i % k is 0:
  		cnt += 1
  	elif i % k == int(k/2):
  		cnt2 += 1


tmp = cnt*cnt*cnt +cnt2*cnt2*cnt2
print(tmp)

Solution (Python):
N,K = map(int,input().split())
ans = 0
count_0 = 0
count_K_2 = 0
for i in range(1,N+1):
    if K % 2 != 0:
        if i % K == 0:
            count_0 += 1
        else:
            pass
    else:
        if i % K == 0:
            count_0 += 1
        elif i % K == K / 2:
            count_K_2 += 1

ans = pow(count_0,3) + pow(count_K_2,3)

print(ans)

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

half = 0
zero = 0


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

    if K % 2 == 0 and i % K == int(K/2):
        half += 1


print(half**3 + zero**3)

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

print(ans)

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

X = [x for x in range(1,N+1)]
Xn = [x for x in X if x % K == 0]

c_odd = 0
c_even1 = 0
c_even2 = 0

for x in X:
    if x % K == 0:
        c_odd += 1
        c_even1 += 1
    elif x % K == K/2:
        c_even2 += 1

if K % 2 != 0:
    ans = c_odd ** 3
else:
    ans = c_even1 ** 3 + c_even2 ** 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+1)**3)

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

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

print(int(ans))

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    if K & 1:
        print((N//K)**3)
    else:
        print((N//K)**3 + ((N//(K//2) - (N//K))**3))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    if(k&1):
        s=n//k
        print(s**3)
    else:
        s=n//k
        t=(n+k//2)//k
        print(s**3+t**3)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    if(k&1):
        s=n//k
        print(s**3)
    else:
        s=n//k
        t=(n//(k//2)+1)//2
        print(s**3+t**3)
resolve()

Solution (Python):
import sys
from functools import reduce
from operator import mul
import math

def nCr(n, r):
    r = min(r, n-r)
    upper = reduce(mul, range(n, n-r, -1), 1)
    lower = reduce(mul, range(r, 0, -1), 1)
    return upper // lower


def oddCaseK(n, k):
    cand = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand += 1
    
    number_of_possibles = 0
    if cand >= 1:
        number_of_possibles += cand
    if cand >= 2:
        number_of_possibles += nCr(cand, 2) * nCr(2, 1) * 3
    if cand >= 3:
        number_of_possibles += nCr(cand, 3) * math.factorial(3)
    
    return number_of_possibles



def evenCaseK(n, k):
    cand1 = 0
    cand2 = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand1 += 1
        elif x % k == k // 2:
            cand2 += 1
    
    number_of_possibles = 0
    for cand in [cand1, cand2]:
        if cand >= 1:
            number_of_possibles += cand
        if cand >= 2:
            number_of_possibles += nCr(cand, 2) * nCr(2, 1) * 3
        if cand >= 3:
            number_of_possibles += nCr(cand, 3) * math.factorial(3)

    return number_of_possibles


def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    if k % 2 == 0:
        ans = evenCaseK(n, k)
    else:
        ans = oddCaseK(n, k)
    
    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):
import sys
from functools import reduce
from operator import mul
import math

def nCr(n, r):
    r = min(r, n-r)
    upper = reduce(mul, range(n, n-r, -1), 1)
    lower = reduce(mul, range(r, 0, -1), 1)
    return upper // lower


def oddCaseK(n, k):
    cand = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand += 1
    
    number_of_possibles = 0
    if cand >= 1:
        number_of_possibles += cand
    if cand >= 2:
        number_of_possibles += nCr(cand, 2) * nCr(2, 1) * 3
    if cand >= 3:
        number_of_possibles += nCr(cand, 3) * math.factorial(3)
    
    return number_of_possibles

    

def evenCaseK(n, k):
    cand1 = 0
    cand2 = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand1 += 1
        elif x % k == k // 2:
            cand2 += 1
    
    number_of_possibles = 0
    number_of_possibles = 0
    if cand1 >= 1:
        number_of_possibles += cand1
    if cand1 >= 2:
        number_of_possibles += nCr(cand1, 2) * nCr(2, 1) * 3
    if cand1 >= 3:
        number_of_possibles += nCr(cand1, 3) * math.factorial(3)

    if cand2 >= 1:
        number_of_possibles += cand2
    if cand2 >= 2:
        number_of_possibles += nCr(cand2, 2) * nCr(2, 1) * 3
    if cand2 >= 3:
        number_of_possibles += nCr(cand2, 3) * math.factorial(3)

    return number_of_possibles


def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    if k % 2 == 0:
        ans = evenCaseK(n, k)
    else:
        ans = oddCaseK(n, k)
    
    print(ans)



if __name__ == "__main__":
    main()

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

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


mod_lst = [N // K for _ in range(K)]
for i in range(N % K):
	mod_lst[-(i + 1)] += 1
ans = 0

ans += mod_lst[0] ** 3

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

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

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

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

Solution (Python):
N, K = [int(x) for x in input().split()]
ans = (N//K) ** 3
if K % 2 == 0:
    half = K//2
    ans += ((N-half)//K +1) ** 3
print(ans)

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

N, K = map(int, input().split())
mod = [0] * K
for i in range(1, N + 1):
  mod[i % K] += 1
res = 0

for x in range(K):
  t = mod[x] * mod[(K - x) % K]
  y = (-x) % K
  z = (-((K - x) % K)) % K
  if y == z:
    t *= mod[y]
    res += t
print(res)

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

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 K % 2 == 0 and i % (K/2) == 0:
        b += 1

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

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

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

x = n//k
y = x if k%2 else n//(k//2)

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

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

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

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

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

ans = cnt_k**3
if K % 2 == 0:
    ans += cnt_k_half**3

print(ans)

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

Solution (Python):


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

l=[N//K+1 if i<N%K else N//K for i in range(K)]

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

print(ans)

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

candidates = []
even = []
odd = []
for i in range(1, N+1):
    if i % K == 0:
        even.append(i)
        continue
    
    if K % 2 == 0 and i % (K // 2) == 0:
        odd.append(i)
        continue
    
count = len(even) ** 3

if K % 2 == 0:
    count += len(odd) ** 3
    
print(count)

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

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





if K == 2:
    print((N//2)**3 + ((N+1)//2)**3)
elif K % 2 != 0:
    a = N//K
    print(a**3)
else:
    a = N//K
    b = N//(K//2) - N//K
    print(a**3 + b**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)//K+1) ** 3)

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

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

c = N//K
ans = c**3
if K % 2 == 0:
    K2 = K//2
    m = 0
    while (2*m+1)*K2 <= N:
        m+=1
    ans += m**3

print(ans)

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

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

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

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



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

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

Solution (Python):
N,K = map(int,input().split())
odd = []
even1 = []
even2 = []
if K % 2 == 1:
    for i in range(1,N+1):
        if i % K == 0:
            odd += [i]
    ans = len(odd) ** 3
else:
    for i in range(1,N+1):
        if i % K == 0:
            even1 += [i]
        elif i % (K/2) == 0:
            even2 += [i]
    ans = len(even1) ** 3 + len(even2) ** 3
print(ans)

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

Solution (Python):
from collections import defaultdict
N, K = map(int, input().split())
dic = defaultdict(int)
m = 0

for i in range(1, N+1):
  if i%K==0:
    dic[0] += 1
  elif (2*i)%K==0:
    dic[i%K] += 1
    if m==0:
      m = i

ans = 0
for k in dic.keys():
  ans += dic[k]**3
print(ans)

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

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

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

a=[]
for i in range(K):
    if (K-i)*3%K==i and (K-i)*2%K==0:
        a.append(i)

b=[]
for i in range(len(a)):
    b.append((N-a[i])//K+1)
b[0]-=1

print(sum([i**3 for i in b]))

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

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

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

ev = 0
ev2 = 0
od = 0
if K % 2 == 1:
    print((N//K)**3)
else:
    ans = N//K
    for i in range(1,N+1):
        if i % K == (K//2):
            ev += 1
    print(ans**3 + ev**3)

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

Solution (Python):
n,k=map(int,input().split())
check=n*2//k


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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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

    if k & 1:
        ans = (n//k) ** 3
    else:
        kk = k // 2
        even = n // k
        odd = (n//kk) - even
        ans = even ** 3 + odd ** 3
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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

    if k & 1:
        ans = (n//k) ** 3
    else:
        kk = k // 2
        even = n // k
        odd = (n//kk) - even
        ans = even ** 3 + odd ** 3
    print(ans)


if __name__ == '__main__':
    main()

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

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

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





abc_list_even = []
abc_list_odd = []

for a in range(1, N+1):
    if (2*a)%K == 0:
        if ((2*a)//K)%2 == 0:
            abc_list_even.append(a)
        else:
            abc_list_odd.append(a)

print(len(abc_list_even)**3 + len(abc_list_odd)**3)

Solution (Python):
import itertools

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





abc_list_even = []
abc_list_odd = []

for a in range(1, N+1):
    if (2*a)%K == 0:
        if ((2*a)//K)%2 == 0:
            abc_list_even.append(a)
        else:
            abc_list_odd.append(a)

print(len(abc_list_even)**3 + len(abc_list_odd)**3)

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

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

Solution (Python):
from itertools import combinations_with_replacement

def calc_cases(num):
  cases = num
  if num == 2: cases += num*(num-1)*3
  elif num >= 3: cases += num*(num-1)*3 + num*(num-1)*(num-2)
  return int(cases)

N,K = map(int,input().split())
num, num2 = 0, 0
if K%2 ==1:
  for i in range(1,N+1):
    if i%K == 0: num +=1
else:
  for i in range(1,N+1):
    if i%K == 0:
      num +=1
    elif i%K == K//2:
      num2 += 1

print(calc_cases(num)+calc_cases(num2))

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

Solution (Python):
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

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

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

if k % 2 == 1:
    L = [i for i in range(k, n+1, k)]
    num = len(L)
    print(num**3)
else:
    L1 = [i for i in range(k, n+1, k)]
    L2 = [i for i in range(k//2, n+1, k)]
    num1 = len(L1)
    num2 = len(L2)
    print(num1**3 + num2**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):
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce



def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



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

ans = 0

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

    tmp = int((n+k/2)//k)
    ans += tmp*tmp*tmp
else:
    tmp = int(n//k)
    ans += tmp*tmp*tmp

print(ans)

Solution (Python):
n,k = map(int,input().split())
mod_count = {}
a = n//k
b = n%k
for i in range(k):
    count = a
    if (1<=i<=b):
        count +=1
    mod_count[i]=count
ans = 0
for ai in mod_count.keys():
    bi = (k - ai)%k
    ci = (k - ai)%k
    if (bi+ci)%k ==0:
        ans += mod_count[ai]*mod_count[bi]*mod_count[ci]
    else:
        continue
print(ans)

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

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

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

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

a = n//k
b = (n+k//2)//k
print(a**3+b**3)

Solution (Python):

def solve(N, K):
    M = N//K
    rem = 0

    ans = M ** 3

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

    return ans


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

Solution (Python):
import itertools

def test():
    a = 0
    b = 0
    c = 0
    n,k = map(int,input().split())
    if k % 2 == 0:
        for i in range(1,n+1):
            if i % k == 0:
                a += 1
            elif i % k == k//2:
                b += 1
    else:
        for i in range(1,n+1):
            if i % k == 0:
                c += 1
    print(a**3+b**3+c**3)


if __name__ == "__main__":
    test()

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

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

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

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

Solution (Python):
import math
N, K = map(int, input().split())
if K%2 == 1:
    n = math.floor(N/K)
    print(n**3)
else:
    n1 = math.floor(N/K)
    k = K/2
    n2 = (math.floor(N/k)+1)//2
    print(n1**3 + n2**3)

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

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) ** 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) ** 3

print(ans)

Solution (Python):
a,b = list(map(int, input().split()))

if b%2 == 1:
    c = a//b
    ans = c**3
else:
    c = a//b
    ans = c**3

    d = b//2
    e = (a-d)//b
    ans += (e+1)**3

print(ans)

Solution (Python):
import os, sys, re, math

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

ret = 0

memo = [0 for _ in range(K)]

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


ret += memo[0] ** 3


if K % 2 == 0:
    ret += memo[K // 2] ** 3

print(ret)

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

Solution (Python):
import math

n,k=map(int,input().split())
if k%2!=0:
    nums=math.floor(n/k)
    print(nums**3)
 
else:
    nums1=math.floor(2*n/k)

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

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