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())
cnt=[0]*k
for i in range(1,n+1):
    cnt[i%k]+=1
ans=0
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k==0:
        ans+=cnt[a]*cnt[b]*cnt[c]
print(ans)

Solution (Python):

 
 
def main():
    n, k = map(int, input().split())
 
    div_k = n // k  
 
    
    if k % 2 == 0:
        div_k_harf = n // (k // 2) - div_k
    else:
        div_k_harf = 0
 
    print(div_k ** 3 + div_k_harf ** 3)
 
 
if __name__ == '__main__':
    main()

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

def main():
	if k % 2 == 1:
		if k > n:
			print(0)
			return
		else:
			div = n // k
			print(div * div * div)
			return
	else:
		kk = k / 2
		div1 = n // k
		j = 0
		for i in range(1, n + 1):
			if i % k == kk:
				j += 1
		print(div1 * div1 * div1 + j * j * j)
		return
			
main()

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

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:
	num=int(N/K)
	print(num**3)
	
else:
	K2=K/2
	num1=int(N/K)
	num2=int(N/K2)-num1
	print(num1**3+num2**3)

Solution (Python):
s = input().split()
N = int(s[0])
K = int(s[1])

ans = N // K 
ans = ans ** 3

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

print(ans+ ans_ev )

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

ks = [i for i in range(k, n + 1, k)] 

count = len(ks) ** 3 

if k % 2 == 0:
  khalfs = [i for i in range(k // 2, n + 1, k)] 
  count += len(khalfs) ** 3 

print(count)

Solution (Python):


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

sum = 0
for i in range(1,n+1):
    if 2*i%k == 0:
        
        sum += 1

        max = int((n-i)/k)
        
        if max == 1:
            sum += 6
        elif max>1:
            sum += max*(1+max)/2*6

print(int(sum))

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

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

N, K = ln()

tmp = 0
tmp2 = 0
for a in range(1,N+1):
    if a%K == 0:
        tmp += 1
if K%2 == 0:
    for a in range(1,N+1):
        if a%K == K//2:
            tmp2 += 1
ans = tmp**3 + tmp2**3
print(ans)

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

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

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

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

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

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

p = N//K

cnt = 0

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

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

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

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

print(ans)

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

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

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


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

Solution (Python):



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

    div_k = n // k  

    
    if k % 2 == 0:
        div_k_harf = n // (k // 2) - div_k
    else:
        div_k_harf = 0

    print(div_k ** 3 + div_k_harf ** 3)


if __name__ == '__main__':
    main()

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

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

Solution (Python):

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

if K%2 == 0:
    s = 0
    t = 0
    for k in range(1,N+1):
        if k%K == 0:
            s += 1
        elif k%K == K//2:
            t += 1
    print(s**3+t**3)
else:
    s = 0
    for k in range(1,N+1):
        if k%K == 0:
            s += 1
    print(s**3)

Solution (Python):
def run(n, k):
    a = 0
    b = 0
    for i in range(n):
        if (i+1) % k == 0:
            a += 1
        elif (i+1) % k == k/2:
            b += 1
    if k % 2 == 1:
        
        return a**3
    else:
        
        
        
        return (a**3) + (b**3)


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


def main():
    n, k = read_line()
    print(run(n, k))


if __name__ == '__main__':
    main()

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

ans=0

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

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

r = 0


k  = N // K
r += k * k * k


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

print(r)

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

Solution (Python):
N,K = map(int,raw_input().split())
if K%2 == 0:
  a = N//K
  b = a**3
  c = N//(K/2)-a
  d = c**3
  e = b+d
else:
  e = (N//K)**3
print e

Solution (Python):



N, K = map(int,input().split())
if K % 2 == 0:
    a = K/2
    moto = 0
    while a <= N:
        a += K
        moto += 1
    ans = moto**3
    b = N // K
    ans += b**3
    print(ans)
else:
    b = N // K
    print(b**3)

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

Solution (Python):
import os

def main():
    n, k = map(int, input().split())
    res = 0
    if k % 2 == 0 :
        kk = k // 2
        knum = n // k
        kknum = n // kk - knum
        res = knum ** 3 + kknum ** 3
    else:
        knum = n // k
        res = knum ** 3
    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
import math

N,K=map(int,input().split())
ans=0
ans2=0
if K%2==1:
    for i in range(1,N+1):
        if i%K==0:
            ans+=1


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


print(ans**3+ans2**3)

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

f = n // k
g = 0 if k%2 != 0 else (n-k//2)//k + 1
print(f**3+g**3)

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

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

Solution (Python):


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

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

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

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

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

if K % 2 != 0:
    num = [i for i in range(1, N+1) if i % K ==0]
    print(len(num)**3)
else:
    num = [i for i in range(1, N+1) if i % K == 0]
    half_num = [i for i in range(1, N+1) if i % K == (K/2)]
    print((len(num))**3 + len(half_num)**3)

Solution (Python):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

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

    '''
    for i in range(k, n+1, k):
        for j in range(k, n+1, k):
            if (i + j) % k == 0:
                for m in range(k, n+1, k):
                    if (i+m) % k == 0 and (j+m) % k == 0:
                        print(i, j, m)
    '''
    
    if k % 2 == 1:
        print((n // k) ** 3)
        return
    '''
    c = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            if (i + j) % k == 0:
                for m in range(1, n+1):
                    if (i+m) % k == 0 and (j+m) % k == 0:
                        print(i, j, m)
                        c += 1
    '''
    
    c = (n//k) ** 3 + (n//(k//2) - n//k)  ** 3
    print(c)

main()

Solution (Python):


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

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

if __name__ == '__main__':
    main()

Solution (Python):
l = list(map(int, input().split()))
N = int(l[0])
K = int(l[1])
R1 = N // K
R2 = (N - (K // 2))// K + 1
if K % 2 == 1:
  print(R1**3)
else:
  print(R1**3 + R2**3)

Solution (Python):
n,k = map(int,input().split())
list_0 = []
list_k = []
for a in range(1,n+1):
  if k % 2 == 1:
    if a % k == 0:
      list_0.append(a)
  else:
    if a % k == 0:
      list_0.append(a)
    elif a % k == (k/2):
      list_k.append(a)
ans = len(list_0)**3 + len(list_k)**3
print(ans)

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

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

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):
def c_triangular_relationship(N, K):
    
    reminder_K = N // K
    
    reminder_halfK = 0 if K % 2 == 1 else N // (K // 2) - reminder_K
    ans = reminder_K**3 + reminder_halfK**3  
    return ans

N, K = [int(i) for i in input().split()]
print(c_triangular_relationship(N, K))

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

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

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

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

    ans += cnt ** 3

print(ans)

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

ans = 0
t = 0

for i in range(k, n + 1, k):
    ans += 1

ans **= 3

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

print(ans)

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

print(ans)

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

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

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

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

result = 0

if K % 2 == 1:
    c = N // K
    result = c ** 3
else:
    K2 = K // 2
    c1 = N // K
    c2 = N // K2 - c1
    result = c1 ** 3 + c2 ** 3

print(result)

Solution (Python):
n,k=map(int,input().split())
*a,=filter(lambda x:x%k==0,range(1,n+1))
if k%2:
  print(len(a)**3)
else:
  *b,=filter(lambda x:x%k==k//2,range(1,n+1))
  print((len(a)**3)+(len(b)**3))

Solution (Python):
N,K= list(map(int,input().split()))
import math
if K %2 ==0:
    std = K/2
else:
    std =K
M = N//std
M1 = N//K
if K%2==0:
    print(int((M-M1)**3+M1**3))
else:
    print(M1**3)

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

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

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

Solution (Python):
from math import *
n,k=map(int,input().split())
dict1={}
flag=0
ans=0
if(k%3==0):
    flag=1
for i in range(1,n+1):
    try:
        dict1[i%k]+=1
    except:
        KeyError
        dict1[i%k]=1
for i in dict1.keys():
    if((i+i)%k==0):
        ans+=dict1[i]*dict1[i]*dict1[i]

print(ans)

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



if K % 2 != 0:
    ans = (N // K)**3
else:
    full = []
    half = []
    for i in range(int(K/2), N+1, int(K/2)):
        if i % K == 0:
            full.append(i)
        else:
            half.append(i)

    ans = len(half) ** 3 + len(full) ** 3

print(ans)

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

Solution (Python):
from math import *
n,k=map(int,input().split())
dict1={}
flag=0
ans=0
if(k%3==0):
    flag=1
for i in range(1,n+1):
    try:
        dict1[i%k]+=1
    except:
        KeyError
        dict1[i%k]=1
dict2={}
for i in dict1.keys():
    try:
        if(dict2[i]==1):
            a=1
    except:
        KeyError
        if((i+i)%k==0):
            ans+=dict1[i]*dict1[i]*dict1[i]
            dict2[i]=1
            dict2[k-i]=1
print(ans)

Solution (Python):
n, k = list(map(int, input().split()))
res = 0
if k == 1:
  print(n ** 3)
  exit()
num_baisuu = n // k
res += num_baisuu ** 3
if k % 2 == 0:
  nn = n + k / 2
  num_baisuu = nn // k
  res += num_baisuu ** 3
print(int(res))

Solution (Python):
n,k = map(int,input().split())
import math
if k%2!=0:
    count = 0
    i = 1
    check = True
    while check:
        if n < k * i:
            check = False
        else:
            count += 1
            i += 1
    print(int(count**2*count))
elif k%2==0:
    count = 0
    i = 1
    check = True
    while check:
        if n < (k/2) * i:
            check = False
        else:
            count += 1
            i += 1
    if count%2!=0:
        ans_1 = math.ceil(count/2)
        ans_2 = math.ceil(count/2)-1
        print(int(ans_1**2*ans_1+ans_2**2*ans_2))
    elif count%2==0:
        ans = count/2
        print(int(ans**2*ans)*2)

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

Solution (Python):
inputs = raw_input().replace("\n", "").split(" ")
N, K = map(int, inputs)
r = N // K 
q = N % K 

n_0_a = r

if K % 2 == 0:
    half_K = K / 2
    hasuu = 1 if half_K <= q else 0
    n_k_2_a = r + hasuu
else:
    n_k_2_a = 0

out = (n_0_a ** 3) + (n_k_2_a ** 3)
print out

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

print(ans)

Solution (Python):
import math
def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = tuple(int(i) for i in input().split())

n = int(N/K)
c1 = n**3

k_2 = K/2

if N < k_2:
    print(0)
elif K%2 != 0:
    print(c1)
else:

    if N < n*K + k_2:
        c2 = n**3
    else:
        c2 = (n+1)**3
    print(c1 + c2)

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

arr = [0]*(k);

for i in range(1,n+1):

	arr[i%k] += 1;


counter = 0;

for i in range(k):

	if 2*i % k == 0:

		if i==0:
			counter += pow(arr[0],3);

		else:
			if i!=k-i:
				counter += pow(arr[i],3)
				counter += 3*( pow(arr[i],2) * arr[k-i] )
			else:
				counter += pow(arr[i],3)
	

print(counter)

Solution (Python):
n, k = list(map(int, input().split()))
q, m = divmod(n, k)
a = 0
b = 0
lst = list(range(1, k)[::-1]) + [k]
for i in lst:
    if (i*2)%k != 0:
        a_ = 0
    else:
        a_ = q+1 if i<=m else q
        a_ *= a_
    a += a_
    if i == k-m and i != k:
        b = a
print(a*q+b)

Solution (Python):
n, k = map(int, input().split())
d = n // k
q = n % k

M = [0 for i in range(k)]
if not q == 0:
    for i in range(1, q+1):
        M[i] = d + 1
    for i in range(q+1, k):
        M[i] = d
    M[0] = d
else:
    for i in range(k):
        M[i] = d

cnt = 0
cnt += M[0] ** 3
if k % 2 == 0:
    cnt += M[k//2] ** 3

print(cnt)

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

num = N // K
re = num ** 3
if K % 2 == 0:
    num2 = 1 + (N - K // 2) // K
    re += num2 ** 3
print(re)

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

count = 0

R = N % K

for a in range(1, N + 1):
	r = a % K
	if 2 * r % K == 0:
		if r == 0:
			count += (N // K) ** 2
		elif R >= r:
			count += (N // K + 1) ** 2
		else:
			count += (N // K) ** 2


print(count)

Solution (Python):
import sys
fin = sys.stdin.readline
from math import ceil

N, K = [int(elem) for elem in fin().split(' ')]

""" if K % 2 != 0:
    quotient = N // K
    print(quotient**3)
elif K % 4 == 0:
    pass    
 """

count = 0
for a in range(1, N + 1):
    if (2 * a) % K == 0:
        q_max = (N + a) // K
        q_min = ceil((a + 1) / K)
        q_num = (q_max - q_min) + 1
        count += q_num**2
    else:
        continue
print(count)

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

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



count = 0
for i in range(k):
    if (i*2) % k == 0:
        count += divList[i] ** 3
print(count)

Solution (Python):
import math
N, K = map(int, input().split())
count = 0
for i in range(1, N+1):
    if K % 2 == 0:
        a = i * K/2
        if a >= N+1:
            break
        maxn = int((N + a) // K)
        minn = math.ceil(( a + 1) / K)
        maxln = int((N - a) // K)
        minln = max(math.ceil((1 - a) / K), 1- i)
        
        
        
        
        
        count += (maxn - minn + 1) * (maxln - minln + 1)
    else:
        a = i * K
        if a >= N + 1:
            break
        maxn = int((N + a) // K)
        minn = math.ceil((a + 1) / K)
        maxln = int((N - a) // K)
        minln = max(math.ceil((1 - a) / K), 1 - i)
        
        
        
        
        
        count += (maxn - minn + 1) * (maxln - minln + 1)


print(int(count))

Solution (Python):
a = [int(i) for i in input().split()]
 
if a[1]%2 == 1:
	print ((a[0]//a[1])**3)
else:
	if a[0]%a[1] < a[1] // 2:
		print ((a[0]//a[1])**3 + ((a[0]//a[1])**3))
	else:
		print ((1 + a[0]//a[1])**3 + ((a[0]//a[1])**3))

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

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

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

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

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

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

Solution (Python):

def solve():
    N, K = map(int, input().split())
    if K&1:
        return str((N//K)**3)
    else:
        i = K//2
        a, b = N//K, N%K
        c = a+(b>=i)-(i==0)
        return str(c**3+a**3)
    return str(m)

if __name__ == '__main__':
    print(solve())

Solution (Python):
def calc(n, k, x):
    c = 0

    while x <= n:
        a  = (x - 1) // k
        c += 1 + 6 * (1 + a) * a // 2
        x += k

    return c

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

if k % 2 == 0:
    print(calc(n, k, k) + calc(n, k, k // 2))
else:
    print(calc(n, k, k))

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


n, k = LI()

print((n//k)**3 + (1-k%2)*((n - k//2)//k+1)**3)

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

list = []
p = 0

for a in range(1,n+1):
    x = int(a/k)
    y = int((n+a)/k)
    if  2*a % k ==0:
        p = p + (y-x)**2
    else:
        pass

print(p)

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

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

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

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

Solution (Python):
nk=input().split()
n=int(nk[0])
k=int(nk[1])
if k==1:
    print(n**3)
elif k%2==0:
    
    h=int(k/2)
    x=(n-h)//k
    
    y=n//k
    print((x+1)**3+y**3)
else:
    x=n//k
    print(x**3)

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

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

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

  A1 = (N - K2)//K
  A2 = N//K

  print((A1 + 1)**3 + (A2)**3)

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

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

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

Solution (Python):
n,k=map(int,input().split())
b=1
sum=0
while 1:
	if b*k>n*2:
		break
	if b*k%2==0:
		a=b*k/2
		sum+=((n-a)//k-(-a//k+1)+1)*((n+a)//k-a//k)
	b+=1
print(int(sum))

Solution (Python):

N,K = (int(i) for i in input().split())

count = 0
minus = []
for i in range(1,N+1):
    
    a = i
    b = i
    c = i
    if (a + b) % K == 0:
        count += 1
        count += len(minus) * (3*2)
        if len(minus) >= 2:
            
            kazu = len(minus)
            kumiawase = kazu * (kazu - 1) / 2
            count += kumiawase * (3*2)
    if i % K == 0:
        minus.append(i)

print(int(count))

Solution (Python):
def inpl(): return list(map(int, input().split()))
N,K = inpl()
co, ce = [],[]
odd,even,heven = 0,0,0
for i in range(1, N+1):
    if i % K == 0:
        if i%2==0:
            even+=1
            
            ce.append(i)
        else:
            odd+=1
            
            co.append(i)
    elif 2 * i % K == 0:
        heven += 1
if K%2 == 1:
    print((even+odd+heven)**3)
else:
    print(even**3+odd**3+heven**3)

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

Solution (Python):
import numpy as np
n, k = list(map(int,input().split()))

ans = 0
mut_ori = n//k
for a in range(1, k + 1):
    b_cand = list(range(k - a%k,k+1,k))
    for b in b_cand:
        c_cand = list(range(k - b%k,n+1,k))
        for c in c_cand:
            if a <= n%k:
                mut = mut_ori + 1
            else:
                mut = mut_ori
            if b <= n%k:
                mut *= (mut_ori + 1)
            else:
                mut *= mut
            if (a + c) % k == 0:
                ans += mut

print(ans)

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

count = (N // K)**3

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

print(count)

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

ans=0
one = 0
three = 0
six = 0

th = n%k
roop = (n//k)
if k%2==0:
    semiroop = roop +(1 if th>=k/2 else 0)
else:
    semiroop = 0
rp=roop
one = rp
three = rp*(rp-1)
six = rp*(rp-1)*(rp-2)

ans += rp**3
rp = semiroop
one = rp
three = rp*(rp-1)
six = rp*(rp-1)*(rp-2)

ans+=rp**3
print(ans)

Solution (Python):
import math

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

d = math.floor(N/K)

ans = d ** 3

if K%2 == 0:
	ans += (d + math.floor((N - d*K)/(K/2))) ** 3

print(ans)

Solution (Python):
a,b = map(int, input().split())
ans = 0
if b % 2 == 0:
    half = b // 2
    ex_half = a - half
    
    n_half = ex_half // b + 1
    
    ans = ans + n_half
    if n_half >= 2:
        ans = ans + 3 * n_half * (n_half-1)
    if n_half >= 3:
        ans = ans + 6 * n_half * (n_half-1) * (n_half-2) // 6
else:
    pass
n_baisuu = a // b

ans = ans + n_baisuu
if n_baisuu >= 2:
    ans = ans + 3 * n_baisuu * (n_baisuu-1) // 2 * 2
if n_baisuu >= 3:
    ans = ans + 6 * n_baisuu * (n_baisuu-1) * (n_baisuu-2) // 6
print(ans)

Solution (Python):
inputs = raw_input().replace("\n", "").split(" ")
N, K = map(int, inputs)
r = N // K 
q = N % K 

n_0_a = r

if K % 2 == 0:
    half_K = K / 2
    hasuu = 1 if half_K <= q else 0
    n_k_2_a = r + hasuu
else:
    n_k_2_a = 0

out = (n_0_a ** 3) + (n_k_2_a ** 3)
print out

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

Solution (Python):

"""
Created on Sat Sep  1 18:57:18 2018
ABC108C
@author: maezawa
"""

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

if k % 2 != 0:
    r = n // k
    print(r**3)
else:
    r1 = n // k
    r2 = n // (k//2) - r1
    print(r1**3+r2**3)

Solution (Python):


import sys

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

pos=n%k;
left=int(n/k+1);

ans=0;
p=0;

if k%2==0:
    if k/2<=pos:p=left;
    else: p=left-1;
    ans+= p**3;
if k<=pos:p=left;
else:p=left-1;
ans+= p**3;
print(int(ans));

Solution (Python):


def com(a):
    return a**3

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

sho = n/k

if k%2 == 0:
    amari = n%k
    if amari >= (k>>1):
        print com(sho) + com(sho + 1)
    else:
        print com(sho) * 2
else:
    print com(sho)

Solution (Python):
def numMod(x):
    global N, K
    return N // K + 1 if N % K >= x else N // K

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

Solution (Python):
n,k = map(int,input().split())
d = [0]*k
sum = 0

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

for a in range(k) :
   if (2*a)%k == 0 :
      sum = sum + d[a]**3

print(sum)

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

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

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

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

if K % 2 == 0:
	ans1 = N // K
	if (N % K) >= (K // 2):
		ans2 = ans1 + 1
	else:
		ans2 = ans1
	ans = (ans1 ** 3) + (ans2 ** 3)
else:
	ans = (N // K)**3

print(ans)

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

if n<k:
    if 2*n>=k:
        if k%2==0:
            print(1)
        else:
            print(0)
    else:
        print(0)
else:
    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())

count = 0
for a in range(1, N+1):
    
    
    

    if (2 * a) % K != 0:
        continue

    min_b = K - (a % K)
    n_b   = (N + K - min_b) // K
    count += n_b ** 2

print(count)

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

print(ans)

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

if k>n:
    if k%2==0 and 2*n>=k:
        print(1)
    else:
        print(0)
elif k%2==1:
    k2 = n//k
    print(k2**3)
else:
    n2 = n-k//2
    k3 = n2//k
    k2 = n//k
    print((k3+1)**3+k2**3)

Solution (Python):


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

if k % 2 == 1:
    h = int(n / k)
    print(h ** 3)
else:
    h = int(n / k)
    he = h
    if (h + 0.5) * k <= n:
        he += 1
    print(h ** 3 + he ** 3)