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

def count(a):
  bias = a % k
  if (bias + a) % k:
    return 0
  num = (n - bias) // k 
  if bias > 0:
    num += 1
  return num ** 2

a = 1
res = 0

while(a <= n):
  res += count(a)
  a += 1

print(res)

Solution (Python):
N, K = map(int, (input().split()))
ans_zero = set()
ans_notzero = set()
for i in range(1, N+1):
    if i % K == 0:
        ans_zero.add(i)

    elif i % K == K / 2:
        ans_notzero.add(i)

print(len(ans_zero) ** 3 + len(ans_notzero) ** 3)

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

Solution (Python):


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

    
    

    
    
    if K%2 != 0:
        
        kinds = (N//K)  
        
        
        print(kinds**3)
        return
    K //= 2
    m = N // K
    ans = (m//2) ** 3 + (m - m//2) ** 3
    print(ans)
    return           


if __name__ == "__main__":
    solve()

Solution (Python):


import math
N,K = list(map(int,input().split(" ")))
nums = (K) * [0]
for i in range(1,N+1):
    nums[i%K] += 1
ans = 0
for a in range(K):
    b = (K-a) % K 
    c = (K-a) % K
    if (2 * K - 2 * a) % K != 0:
        continue
    
    
    ans += nums[a] * nums[b] * nums[c]

print(ans)

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

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

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

ans = (n // k) ** 3

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


print(int(ans))

Solution (Python):
n, k = list(map(int, input().split()))
s = n // k
ans = s ** 3

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

print(ans)

Solution (Python):
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
num = [0]*K
for i in range(1, N+1):
    num[i%K]+=1
res = 0
for a in range(K):
    b = (K-a) % K
    c = (K-a) % K
    if ((b+c) % K != 0):
        continue
    res += num[a] * num[b] * num[c]
print(res)

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

if K==1:
    print(N**3)
    exit()



if not K%2 == 0:
    print((N//K)**3)
    exit()


print((N//K)**3 +(int(N/K + 1/2)**3))

Solution (Python):
import math
import sys


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    if k % 2 == 1:
        return math.floor(n / k) ** 3
    else:
        return math.floor(n / k) ** 3 + math.floor((n + k/2) / k) ** 3


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

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

Solution (Python):
N,K = map(int,input().split(" "))
sum = (N//K) ** 3

if K % 2 == 0:
    k = K // 2
    sum += ((N+k)//K) * (((N+K-k)//K)**2)

print(sum)

Solution (Python):
N,K = map(int,input().split())
N = N+1
setK = set()
setK2 = set()
for i in range(1,N):
    if i%K == 0:
        setK.add(i)
    elif K%2 == 0 and i%K == K/2:
        setK2.add(i)
        
ans = (len(setK)) ** 3 + (len(setK2)) ** 3
print(ans)

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

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

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

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

count = 0

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

print(count)

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

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

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

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

Solution (Python):

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




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

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

	
	
if __name__ == "__main__":
	main()

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

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

        ans += base ** 3

        print(ans)

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

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

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

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

Solution (Python):



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

hk = 0

ans = (n//k)**3

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

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

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


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

    x,y = 0, 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:
        print(x ** 3)
    else:
        print(x ** 3 + y ** 3)





main()

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

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

Solution (Python):

import sys
INF = float("inf")


def cmb(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n

    numer = [n - r + k + 1 for k in range(r)]
    denom = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denom[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numer[k - offset] /= pivot
                denom[k] /= pivot

    result = 1
    for k in range(r):
        if numer[k] > 1:
            result *= int(numer[k])

    return result


def solve(N: int, K: int):

    
    ans = (N//K)**3
    

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

    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    solve(N, K)


if __name__ == '__main__':
    main()

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

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

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

print(result)

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

total = 0
total += (N // K)**3

if K % 2 == 0:
    K //= 2
    n = N // K
    n = n // 2 + n % 2
    total += n**3

print(total)

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









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

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

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

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

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

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

mult = N//K
if K % 2 == 1:
    halfmult = 0
elif N % K < K//2:
    halfmult = mult
else:
    halfmult = mult + 1

print(mult**3 + halfmult**3)

Solution (Python):
N,K=[int(x) for x in input().split()]
if K%2:
  mod0=N//K
  print(mod0**3)
else:
  mod0,MODN=divmod(N,K)
  if MODN>=K//2:
    print(mod0**3+(mod0+1)**3)
  else:
    print((mod0**3)*2)

Solution (Python):
""" AtCoder """

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

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

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

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

Solution (Python):
from decimal import Decimal, ROUND_HALF_UP
n,k = map(int,input().split())
ans = 0
if k % 2 ==0:
    p = Decimal(n/k).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
    ans = p**3 +(n//k)**3
else:
    ans = (n // k)**3
print(ans)

Solution (Python):
n,k = map(int,input().split())
ans1 = 0
ans2 = 0
ans = 0
for x in range(1,n+1):
    if x % k ==0:
        ans1 +=1
if k % 2 == 0:
    for y in range(1,n+1):
        if y % k == k/2:
            ans2 +=1
print(ans1**3+ans2**3)

Solution (Python):
import sys,math

A = [int(i) for i in input().split(' ')]
N,K = A[0], A[1]

ans = math.floor(N/K) ** 3

if (K%2 == 1):
  print(ans)
  sys.exit()

res = 0
half = math.floor(K/2)
cnt = (math.floor((N - half)/K)+1)** 3
print(cnt+ans)

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

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

if K % 2 != 0:
    print(res1**3)
    exit()

res2 = 0

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


print(res1**3+res2**3)

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

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

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

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

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

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

    print(a**3 + count**3)

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

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

Solution (Python):
from sys import stdin
N, K = map(int, stdin.readline().split())
pos_a = []
for i in range(1, K+1):
    if (-2*i) % K == 0:
        pos_a.append(i)
ans = 0
for a in pos_a:
    tmp = (-a) % K
    count = len(range(a, N+1, K))
    ans += count * len([i for i in range(tmp, N+1, K) if i > 0])**2
print(ans)

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

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

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

c = 0
d = 0

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

if K%2==0:
	print(c*c*c+d*d*d)
else:
	print(c*c*c)

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

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

Solution (Python):
N, K = map(int, input().split(' '))
count1 = 0
if K % 2 == 0:
    half = K//2
    a = half
    while a <= N:
        count1 += 1
        a += K
b = 0
count2 = -1
while b <= N:
    b += K
    count2 += 1
ans = count1 ** 3 + count2 ** 3
print(ans)

Solution (Python):
def kumiawase(num):
    return num + 3*num*(num-1) + num*(num-1)*(num-2)

n, k = list(map(int, input().split()))
if k%2 == 1:
    ans = kumiawase(n//k)
else:
    m = k//2
    ans = kumiawase(n//k) + kumiawase(n//m - n//k)
print(ans)

Solution (Python):
def kumiawase(num):
    return num + 3*num*(num-1) + num*(num-1)*(num-2)

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

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

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

Solution (Python):
def inpl(): return [int(i) for i in input().split()]

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

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

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


mod_0_num=N//K
mod_K_num=0
if(K%2==0):
    mod_K_num=(N-K//2)//K +1

print(mod_0_num**3+mod_K_num**3)

Solution (Python):
N,K=map(int,input().split())
cnt=N // K
ch=N % K

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

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

if b%2 != 0:
  print(pow(a//b,3))
else:
  print(pow(a//b,3)+pow(((a+b//2)//b),3))

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

Solution (Python):
from collections import defaultdict
def main():
    n,k = [int(i) for i in input().split()]
    group = defaultdict(list)
    ans = 0
    for i in range(1,n+1):
        group[i%k].append(i)
    ans += len(group[0])**3
    if k%2==0:
        ans += len(group[k//2])**3
    print(ans)


if __name__ == '__main__':
    main()

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

res = 0

if K % 2 == 0:
  count = 0
  n = K//2
  while n <= N:
    count += 1
    n += K
  res += count**3

count = 0
n = K
while n <= N:
  count += 1
  n += K

res += count**3
print(res)

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

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

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

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

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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  cnt += len(range(k-(a%k), n+1, k)) ** 2
        
print(cnt)

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

l1 = list(range(K, N + 1, K))
l2 = list(range(K//2, N + 1, K))

s1 = len(l1)
s2 = len(l2)

rev = int(s1**3)
if K % 2 == 0:
    rev += int(s2**3)
print(rev)

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 math


def main():
    N, K = [int(a) for a in input().split()]

    b = int(math.pow(N // K, 3))

    if K % 2 != 0:
        print(b)
        return

    b2 = math.pow(((N - K // 2) // K) + 1, 3)
    print(int(b + b2))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
def read():
    return raw_input().strip()
 
def read_ints():
    return map(int,read().split())
 
n,k = read_ints()
ans = 0
for x in range(1,n+1):
    if (2*x)%k == 0:
        m = (k-x) % k 
        ways = (n-m)/k + 1 
        if m == 0:
            ways -= 1 
        ans += ways*ways 
        
print ans

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

ans = 0
for a in range(1,n+1,1):
    m = (k - a % k) % k
    if (m+m) % k == 0 and n >= m:
        x = (n - m) // k + 1
        if m == 0: x -= 1
        ans += x*x
print(ans)

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

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

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

x = N//K
y = N%K

ans = x**3

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

print(ans)

Solution (Python):
from collections import defaultdict

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

cand_dict = defaultdict(list)
for i in range(1, n + 1):
    if ((i % k) * 2) % k == 0:
        cand_dict[i % k].append(i)

ans = 0
for i in cand_dict.values():
    ans += len(i) ** 3
print(ans)

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

Solution (Python):
a, b=map(int, input().split())
try:
    c = a // (b // 2)
    c = c //2 + c%2
except Exception as  e:
    c = 0
if b % 2 == 1:
    c = 0
try:
    d = a // b
except Exception as e:
    d = 0
print(c**3 + d**3)

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

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

Solution (Python):
from math import floor
from math import ceil

N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    if (i*2) % K == 0:
        m = floor((N+i)/K) - ceil((1+i)/K) + 1
        n = floor((N-i)/K) - ceil((1-i)/K) + 1
        ans += m*n
print(ans)

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    n, k = f.read_int_list()

    c1 = n / k
    c2 = (n+k/2) / k if k % 2 == 0 else 0

    return c1**3 + c2**3


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

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

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

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

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

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,k]=i2()
if k%2==1:
 print(int(n/k)**3)
else:
 print(int(n/k)**3+(int(n/(k/2))-int(n/k))**3)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

main()

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

ans = 0
for a in range(1, n + 1):
        q = a % k
        if (2 * q % k != 0):
            continue
        ans += ((n + q) // k) ** 2

print(ans)

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

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

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


s=N//K
res += s**3

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

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

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

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

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

    print((cnt**3)+(cnt2**3))

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

    print(cnt**3)

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

Solution (Python):

n,k = [int(x) for x in input().split()]

ret = 0
for b in range(1,n+1):
    r = k - b%k
    
    if r==k:
        
        ret += (n//k)**2
    elif (2*r)%k==0:
        if r<=n%k:
            
            ret += (n//k+1)**2
        else:
            
            ret += (n//k)**2
print(ret)

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

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

Solution (Python):
from math import floor, ceil

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

ans = 0
for a in range(1, N + 1):
    if 2 * a % K != 0:
        continue
    ans += (floor((N + a) / K) - ceil((a + 1) / K) + 1) ** 2
print(ans)

Solution (Python):
from math import ceil, floor

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

if K % 2:
    Ms = range(K, N + 1, K)
else:
    Ms = range(K // 2, N + 1, K // 2)

ans = 0
for a in Ms:
    nMin = ceil((1 + a) / K)
    nMax = floor((N + a) / K)
    ans += (nMax - nMin + 1) ** 2

print(ans)

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

Solution (Python):

import math
 
n, k = map(int, input().split())
c = 0
 
if k%2==0:
    if math.floor(2*n/k)%2==0:
        d=math.floor(2*n/k)/2
        c=2*d*d*d
    else:
        d=(math.floor(2*n/k)+1)/2
        c=d*d*d+(d-1)*(d-1)*(d-1)
    print(int(c))
else:
    d=math.floor(n/k)
    c=d*d*d
    print(int(c))

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

Solution (Python):
from collections import defaultdict
n, k = map(int, input().split())
rec = defaultdict(int)
num = 0
for i in range(1, n + 1):
    if (2 * i) % k == 0:
        num += 1
    rec[i % k] += 1

for i, v in rec.items():
    if (2 * i) % k == 0:
        if v >= 1:
            num += v * (v - 1) * 3
        if v >= 2:
            num += v * (v - 1) * (v - 2)

print(num)

Solution (Python):
def main():
    n, k = map(int, raw_input().split())
    s = 0
    aa = k / 2 if k % 2 == 0 else k
    for a in xrange(aa, n + 1, aa):
        b_min = (a / k + 1) * k - a
        if b_min < a:
            s += ((n - (a / k + 1) * k + a) / k + 1) * ((a - b_min) / k) * 2
        s += (n - ((a / k + 1) * k - a)) / k + 1
    print s


main()

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