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

Solution (Python):
N,K = map(int,input().split())
if K % 2 != 0:
    case1 = len([n for n in range(1,N+1) if n % K ==0])
    print(case1 ** 3)
else:
    case1 = len([n for n in range(1,N+1) if n % K ==0])
    case2 = len([n for n in range(1,N+1) if n % K == K //2])
    print(case1**3 + case2**3)

Solution (Python):


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

if K % 2 != 0:
    even = len([n for n in range(1,N + 1) if n % K == 0])
    print(even ** 3)
else:
    ks = len([n for n in range(1, N + 1) if n % K == 0])
    ks_half = len([n for n in range(1, N + 1) if n % K == K // 2 ])
    print(ks_half**3 + ks ** 3)

Solution (Python):
n,k = map(int,input().split())
def search(n,k):
    buf = [[],[]]
    for i in range(1,n+1):
        if i % k == 0:
            buf[0].append(i)
        elif k % 2 == 0 and i % k == k // 2:
            buf[1].append(i)
    return buf
def countans(l):
    length = len(l)
    if length == 1:
        return 1
    elif length == 2:
        return 2 + 2*1*3
    else:
        return length + length*(length-1)*3 + length*(length-1)*(length-2)
buf = search(n,k)
print(countans(buf[0])+countans(buf[1]))

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

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

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

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

Solution (Python):

import sys
 
 
def solve(N: int, K: int):
    count = 0
 
    if K % 2 == 0:
        count += (N//K)**3
        
        count += (N//(K//2) - N//K)**3
    else:
        count += (N//K)**3
    print(count)
    return
 
 
def main():
    N,K= map(int,input().split())
    
    
    solve(N, K)
 
 
if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(N: int, K: int):
    count = 0

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

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

Solution (Python):


















import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product 
from bisect import bisect_left, bisect_right

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))

N, K = s_inpl()

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

print(ans)

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

if K%2==0: 
    rem_0=N//K
    rem_K2=(N//(K/2))-rem_0
    answer=int(rem_0**3+rem_K2**3)
else: 
    answer=int((N//K)**3)

print(answer)

Solution (Python):
a = list(map(int,input().split()))
N = a[0]
K = a[1]
cnt = (N // K) ** 3
if K % 2 == 0:
    mod = K // 2 
    cnt += ((N - mod) // K + 1) ** 3
print(str(cnt))

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    return


def B():
    x1, y1, x2, y2 = LI()
    a = x2 - x1
    b = y2 - y1
    print(x2 - b, y2 + a, x1 - b, y1 + a)
    return


def C():
    n, k = LI()
    if k % 2:
        print((n // k)** 3)
    else:
        print(int((n//k)**3 + ((n-k/2)//k+1)**3))
        
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


def A():
    n = I()
    print(n*800-200*(n//15))


def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)


def C():
    x,t = LI()
    print(max(0,x-t))


def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)


def E():
    x,y,s,t = LI()
    return


def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])


def G():
    n,m = LI()
    if m <= 2*n:print(m//2)
    else:
        ans = n
        m -= 2*n
        ans += m//4
        print(ans)


def H():
    n,k = LI()
    if k%2:
        l = n//k
        print(l**3)
    else:
        l = n//(k/2)
        m = n//k
        l -= m
        print(int(l**3+m**3))

def J():
    n = I()
    d = defaultdict(int)
    for i in range(n):
        a = I()
        if d[a]:
            d[a] -= 1
        else:
            d[a] += 1
    print(sum(d.values()))

def K():
    n,h = LI()
    v = LIR(n)
    s = 0
    i = 0
    v.sort()
    m = v[-1][0]
    v.sort(key = lambda x:-x[1])
    for a,b in v:
        if b > m:
            s += b
            i += 1
            if s >= h:break
    ans = i+(max(0,h-s)//m)
    if max(0,h-s)%m>0:
        ans += 1
    print(ans)

if __name__ == "__main__":
    H()

Solution (Python):
nk=input().split()
N=int(nk[0]);K=int(nk[1])
if (K%2)==0:
    l=[]
    l2=[]
    for i in range(1,N+1):
        if (i%K==0):
            l2.append(i)
        elif (i%K==int(K/2)):
            l.append(i)
    print(str(len(l)*len(l)*len(l)+len(l2)*len(l2)*len(l2)))
else:
    l=[]
    for i in range(1,N+1):
        if i%K==0:
            l.append(i)
    print(str(len(l)*len(l)*len(l)))

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

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())
ans=0
ans1=0
if K%2!=0:
    for i in range(1,N+1):
        if i%K==0:
            ans+=1
    print(ans**3)
else:
    for i in range(1,N+1):
        if int(i%K)==int(K/2):
            ans1+=1
        elif i%K==0:
            ans+=1
    print(ans**3+ans1**3)

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

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

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


if __name__ == '__main__':
    main()

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

def main():
    divisible = []
    indivisible = []
    for n in range(1, N + 1):
        if n % K == 0:
            divisible.append(n)
        else:
            indivisible.append(n)

    divisible_ans = len(divisible) ** 3

    passed = list(filter(lambda n: (n % K) * 2 == K, indivisible))
    indivisible_ans = len(passed) ** 3

    

    print(divisible_ans + indivisible_ans)

if __name__ == "__main__":
    main()

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

print(num)

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

Solution (Python):
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
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())
x,y=0,0

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

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

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

print(ans)

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

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

if k%2==0:
    a = n // k
    b = n // (k/2) - a
else:
    a = n //k
    b = 0

print( int(a*a*a + b*b*b) )

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

count = N // K
count2 = 0
if K % 2 == 0:
    K2 = K // 2
    count2 = (N // K2) - count
ans = count * count * count
ans += count2 * count2 * count2
print(ans)

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

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

Solution (Python):
n,k=list(map(int,input().split(" ")))
i=0
if k%2==1:
    i=1
    num1=0
    while i<=n:
        if i%k==0:
            num1+=1
        else:
            pass
        i+=1
    print(num1**3)
else:
    i=1
    num2=0
    num3=0
    while i<=n:
        if i%k==0:
            num2+=1
        elif i%k==k/2:
            num3+=1
        else:
            pass
        i+=1
    print(num2**3+num3**3)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


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


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

"""
単体のみで目的の数になる数字を数える
その数のみの組み合わせ + その数と他の数の組み合わせでできるものを求める
偶数の場合と奇数の場合で変わってくる
奇数の場合、同じ数同士での組み合わせは作れない
5,3の場合、3/3/3しかない
5,5の場合、5/5/5
10, 5の場合、5/5/5, 5/5/10, 5/10/10,など
奇数の場合、Kは作れない。
Kの倍数のみ作れる
3
"""














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

Kn = [0] * K


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

    ans = 0

    
    
    for a in range(K):

        
        b = (K - a) % K

        if 2 * b % K != 0:
            continue

        ans += Kn[a] * Kn[b] * Kn[b]

    print(ans)
    return


main()

Solution (Python):



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

    for i in range(1, n + 1):
        if i % k == 0:
            count1 += 1
        if i % k == k // 2:
            count2 += 1

    ans += count1 ** 3

    if k % 2 == 0:
        ans += count2 ** 3

    print(ans)


if __name__ == '__main__':
    main()

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):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

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

print(ans)

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())
count = 0

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

Solution (Python):
def fact(n: int)->int:
    if n == 1:
        return 1
    return n * fact(n-1)


def triangular_relationship(N: int, K: int)->int:
    res = 0
    if K % 2 == 1:
        odd, even = 0, 0
        for k in range(K, N+1, K):
            if k % 2 == 0:
                even += 1
            else:
                odd += 1

        res = sum(d*d*d for d in [odd, even])

        res += odd*odd*even
        res += odd*even*odd
        res += even*odd*odd

        res += even*even*odd
        res += even*odd*even
        res += odd*even*even
    else:
        leftK, leftK2 = 0, 0
        for k in range(K//2, N+1, K//2):
            if k % K == 0:
                leftK += 1
            else:
                leftK2 += 1

        res = sum(d*d*d for d in [leftK, leftK2])

    return res


if __name__ == "__main__":
    N, K = map(int, input().split())
    ans = triangular_relationship(N, K)
    print(ans)

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

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

sum = k_n*k_n*k_n
if K % 2 == 0:
    if K * (N // K) + K // 2 <= N:
        sum += (k_n + 1) ** 3
    else:
        sum *= 2

print(sum)

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

def comb(n,k):
    if n<k:
        return 0
    r = 1
    for i in range(k):
        r *= (n-i)
    for i in range(k):
        r //= (k+1)
    return r
def perm(n,k):
    if n<k:
        return 0
    r = 1
    for i in range(k):
        r *= (n-i)
    return r

single = n//k
if k%2 == 0:
    single =  n//(k//2)

double = perm(single,2)*3
if k%2 == 0:
    odd = perm((single+1)//2,2)*3
    even = perm(single//2,2)*3
    double = odd + even

triple = perm(single,3)
if k%2 == 0:
    odd = perm((single+1)//2,3)
    even = perm(single//2,3)
    triple = odd + even

print(single + double + triple)

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

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

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

if __name__ == '__main__':
    C()

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

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

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

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

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

Solution (Python):


"""
Created on 2019/3/2
Solved on 2019/3/
@author: shinjisu
"""



def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def probC():
    N, K = getIntList()
    dmp((N, K))
    n = N // K
    if K % 2 == 0:
        h = n + (N % K) // (K//2)
    else:
        h = 0
    dmp((n, h), 'n,h')
    cn = n**3
    ch = h**3
    dmp((cn, ch), 'n**3,h**3')
    return cn + ch


debug = False  
print(probC())

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

if k%2 != 0:
    print((n//k)**3)
    exit()
else:
    k = k//2
    n_max = n//k
    n_even = n_max//2
    n_odd = n_max-n_even
    print(n_even**3 + n_odd**3)
    exit()

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

l = []

k = 0
g1 = 0
g2 = 0

if K % 2 == 1:
	for i in range(1,N+1):
		if i % K == 0:
			k += 1
		
else:
	for i in range(1,N+1):
		if i % K == 0:
			g1 += 1
		elif i % K == K / 2:
			g2 += 1

print(k**3 + g1**3 + g2**3)

Solution (Python):

import sys


def solve(N: int, K: int):
    a = N // K
    if K % 2 == 0:
        if N%K >= K//2:
            b = a + 1
        else:
            b = a
        print(a**3+b**3)
    else:
        print(a**3)
    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())
remain = n % k
def f(x):
    if x == 0:
        return n // k
    return n // k + int(x <= remain)
ret = 0
for a in range(k):
    if (-2 * a) % k == 0:
        ret += f(a) * f(k-a) * f(k-a)
print(ret)

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

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

c = n // k if k % 2 == 1 else n // (k // 2)

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

Solution (Python):

import sys



def solve(lines):
    N, K = map(int, lines.pop(0).split(' '))

    x = y = 0

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







lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):


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

ans = 0
if K % 2 == 0:
    
    c1 = len([i for i in range(K, N + 1, K)])
    ans += c1 * c1 * c1
    c2 = len([i for i in range(K // 2, N + 1, K)])
    ans += c2 * c2 * c2
else:
    
    c1 = len([i for i in range(K, N + 1, K)])
    ans += c1 * c1 * c1

print(ans)

Solution (Python):


import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline











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

def combi_num(n):

	if n == 0:
		return 0
	elif n == 1:
		return 1
	elif n == 2:
		return 8
	else:
		return n + 3*n*(n-1) + n*(n-1)*(n-2)



num_1 = N // K


num_2 = 0
if K % 2 == 0:
	if N%K >= K//2:
		num_2 = num_1 + 1
	else:
		num_2 = num_1

print(combi_num(num_1) + combi_num(num_2))

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

def main():
    a = (N//K)**3
    if K%2!=0:
        print(a)
        return
    else:
        b = ( (N+(K//2)) // K ) **3
        print(a+b)
        return

main()

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

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

Solution (Python):

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

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

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

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

Solution (Python):
n, k = [int(x) for x in input().split()]
count = 0
a = int(n / k)
count += (a + a * (a-1) * 3 + a * (a-1) * (a-2))
if k % 2 == 0:
    b = int(n / (int(k / 2))) - a
    count += (b + b * (b-1) * 3 + b * (b-1) * (b-2))
print(count)

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N, K = map(int, input().split())
  
  if K % 2 == 1:
    ans = (N // K)**3
  else:
    ans = ((N + K//2) // K)**3 + (N // K)**3
    
  print(ans)


if __name__ == '__main__':
  main()

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
if(K%2 == 0):
  for i in range(1, N+1):
    if(i%K == K//2):
      b += 1
print(a**3 + b**3)

Solution (Python):
class Solver(object):
    def __init__(self):
        self.n, self.k = list(map(int, input().split(" ")))

    def solve(self):
        total = 0
        total += self.case_zero()
        if self.k % 2 == 0:  
            total += self.case_k2()
        print(total)

    def case_zero(self):
        multiples = self.n // self.k
        return multiples ** 3
    
    def case_k2(self):
        multiples = 0
        for i in range(1, self.n+1):  
            if i % self.k == self.k/2:
                multiples += 1
        return multiples ** 3


if __name__ == "__main__":
    s = Solver()
    s.solve()

Solution (Python):

"""
整数N,Kが与えられます。
N以下の正の整数の組(a,b,c)であって、a+b,b+c,c+aがすべてKの倍数であるようなものの個数を求めてください。
ただし、a,b,cの順番を入れ替えただけの組も異なるものとして数えます。
また、a,b,cの中に同じものがあっても構いません。
"""


def main(str):
    num = str.split()
    N = int(num[0])
    K = int(num[1])
    if(K%2 != 0):
        cnt = 0
        for a in range(1, N+1):
            if(a%K == 0):
                cnt += 1
        cnt = cnt ** 3

    else:
        cnt1 = 0
        cnt2 = 0
        for a in range(1, N+1):
            if(a%K == 0):
                cnt1 += 1
        for a in range(1, N+1):

            if(a%K == K/2):
                cnt2 += 1

        cnt = cnt1 ** 3 + cnt2 ** 3

    print(cnt)


if __name__ == "__main__":
    main(input())

Solution (Python):
def func():
    pass


def main():
    n, k = map(int, input().split())
    if k % 2 == 1:
        a_c = n // k
        print(a_c ** 3)
    else:
        p1 = (n // k) ** 3

        kh = k // 2
        p2 = ((n // kh) - (n // k)) ** 3
        print(p1 + p2)


if __name__ == '__main__':
    main()

Solution (Python):
def solve(N, K):
    ans = 0
    k = len([n for n in range(1, N + 1) if n % K == 0])
    ans += k * k * k
    if K % 2 == 0:
        k = len([n for n in range(1, N + 1) if n % K == K // 2])
        ans += k * k * k

    return ans

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

Solution (Python):

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

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

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

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(k_arr2)
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

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
if(K%2 == 0):
  for i in range(1, N+1):
    if(i%K == K//2):
      b += 1
print(a**3 + b**3)

Solution (Python):
N, K = map(int,input().split())
a, b = 0, 0
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):
      a += 1
print(a**3 + b**3)

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

m =  n // k

count = m ** 3

if k % 2 == 0:
    if m*k + k/2 <= n:
        count += (m+1) ** 3
    else:
        count += m**3

print(count)

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

Solution (Python):
n, k = map(int, input().split())
def f(n, k):
    return int(n/k)

if k%2:
    print(f(n,k)**3)
else:
    l = k//2
    p = f(n, k)
    q = f(n, l) - p
    print(p**3+q**3)

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

def f(n,k):
    return int(n/k)

if k%2:
    print(f(n,k)**3)
else:
    l=k//2
    p=f(n,k)
    q=f(n,l)-p
    print(p**3+q**3)

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

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

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) - n//k)**3 )

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

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


def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]

    d, m = int(N / K), N % K
    r = d ** 3
    if K % 2 == 0:
        if K / 2 <= m:
            r += (d + 1) ** 3
        else:
            r *= 2

    print(r)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    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)


main()

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

if k % 2 == 1:
    ans = (n // k) ** 3
else:
    x = n // k
    y = n // (k // 2) - x
    ans = x ** 3 + y ** 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 i%K==K/2:
        b+=1
print(a**3+b**3)

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

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

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

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

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

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

if K%2 == 1:
    num = N//K
    ans = num**3
else:
    k = K//2
    num = N//k
    even = num//2
    odd = (num+1)//2
    ans = even**3 + odd**3

print(ans)