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 = [int(i) for i in input().split()]

def cnt_mod(i):
    if n % k >= i:
        cnt_i = n // k + 1
    else:
        cnt_i = n // k

    a = pow(cnt_i, 3)
    return a

def cnt_mode_zero():
    cnt_zero = n // k
    a = pow(cnt_zero, 3)
    return a


cnt = 0
cnt += cnt_mode_zero()
if k % 2 == 0:
    ans = cnt_mod(k/2)
    cnt += ans
print(cnt)

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

ans = [0, 0]
d = k // 2

for i in range(1, n+1):
    if k % 2 == 0 and i % k == d:
        ans[0] += 1
    if i % k == 0:
        ans[1] += 1

print(ans[0] ** 3 + ans[1] ** 3)

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

Solution (Python):


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

result = 0

if (K%2) == 1:
    kouho = N//K
    result+=kouho*kouho*kouho

else:
    kouho1 = N//K
    kouho2 = N//(K/2) - kouho1
    result+=kouho1*kouho1*kouho1
    result+=kouho2*kouho2*kouho2

print(int(result))

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

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

    if k % 2 == 0:
        print(num ** 3 + num2 ** 3)
    else:
        print(num ** 3)

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

Solution (Python):

N, K = map(int, input().split());
answer = 0;

margin = N//K;
answer += int(margin)**3;

if(K%2==0):
    N-=(K/2);
    margin = N//K;
    answer += int(margin+1)**3;

print(answer);

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

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

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

elif k % 2 != 0:
  num = int(n / k)
  print(num ** 3)
  
else:
  num = int(n / k)
  num2 = int(int((n - k / 2)) / k + 1)
  print(num ** 3 + num2 ** 3)

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

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

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

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

q = N // K

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

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

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

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

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

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

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

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

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

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

else:
    num_mod_0 = n // k
    a = num_mod_0 ** 3

    num_mod_1 = n // (k/2) - n // k
    b = num_mod_1 ** 3

    print(int(a+b))

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

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

ans = (N // K)**3

if K % 2 == 0:
    q, r = divmod(N, K)
    if r >= K // 2:
        q += 1
    ans += q**3

print(ans)

Solution (Python):


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

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

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

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

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

Solution (Python):
n, k = map(int, input().split())
f = lambda x: n//k + (x <= (n % k)) if x != 0 else n // k
res = 0
for a in range(k // 2 + 1):
    if (2 * (k - a)) % k == 0:
        res += f(a) * (f(((k - a)) % k) ** 2)
print(res)

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

r0 = int(N/K) 

r2 = 0
if K%2==0: 
    K2 = int(K/2) 
    r2 = int(N/K2)
    r2 -= r0

result = r0*r0*r0 + r2*r2*r2
print(result)

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

zero=0
half=0


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

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

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

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

Solution (Python):




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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):


import math

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

evens = n // k
k_halfs = (n + (k // 2)) // k

sum_a_even = evens * evens * evens

sum_a_odd = 0
if k % 2 == 0:
    sum_a_odd = k_halfs * k_halfs * k_halfs

print(sum_a_even + sum_a_odd)

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

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

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

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

Solution (Python):

import sys
import math
import numpy as np
import itertools



n,k = (int(i) for i in input().split())  
answer = 0
answer += (n//k)**3
if k % 2 == 0:
    answer += ( (n + (k//2) ) // k )**3

print(answer)

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

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

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

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

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


ans = 0
if K % 2 == 0:
  ans += mods[K//2 -1] ** 3

ans += mods[K-1] ** 3

print(ans)

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

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

co=0
a0=n//k
co+=a0**3

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

print(co)

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

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

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

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

f = n // k
ans = f**3

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

print(ans)

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

ans = 0

temp = n // k

ans += temp ** 3

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

print(ans)

Solution (Python):
def iin(): return int(input())
def nl(): return list(map(int, input().split()))
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)]

n, k = nl()

d = dict()
for i in range(1, n + 1):
    t = i % k
    d[t] = d.get(t, 0) + 1

ans = 0
if k % 2 == 0:
    ans += d.get(k // 2, 0) ** 3
ans += d.get(0, 0) ** 3
print(ans)

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

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