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



Sample input:
3 2


Sample output:
9

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n, k = LI()
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import math

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

if k%2 == 1:
    ans = (n//k)**3
else:
    ans = (n//k)**3 + math.ceil(n/k)**3

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    ans = pow(N // K, 3)
    if K % 2 == 0:
        if N > K // 2:
            ans += pow((N - K // 2) // K + 1, 3)

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
K_=K//2

k_=0
k=0
for i in range(1,N+1):
    if i%K==0:
        k+=1
        continue
    if i%K_==0:
        k_+=1

print(k**3+k_**3)

Submission status: Wrong Answer

Solution code:

n, k = 5,  2

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

Submission status: Wrong Answer

Solution code:
n,k = map(int, raw_input().split(' '))

left = n % k
cc = [0] * k
for ii in range(k):
	cc[ii] += n / k
	if 0<ii <= left: cc[ii] += 1

jj = (k - 0) % k
print cc[0] * cc[0] * cc[0]

Submission status: Wrong Answer

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

amari_0 = [] 
amari_Kw2 = []

for i in range(1,N+1,1):
    if i%K == 0:
        amari_0.append(i)
    if i%K == 2//K:
        amari_Kw2.append(i)

if K%2 == 0:
    ans = pow(len(amari_0),3)
    ans += pow(len(amari_Kw2),3)
else:
    ans = pow(len(amari_0),3)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
n0 = n//k
ans = pow(n0, 3)

if k%2 == 0:
    # 全ての余りがk/2のパターン
    r = n%k
    ans += pow(n0+1 if n%k>=k//2 else 0, 3)
print(ans)

Submission status: Wrong Answer

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

from collections import Counter
res = [x%K for x in range(1, N+1)]
res_sort = sorted(zip(Counter(res).keys(), Counter(res).values()))

if N < K:
    ans = 0
else:
    if K%2==0:
        ans = res_sort[0][1]**3
        if K//2 < N:
            ans += res_sort[K//2][1]**3
    else:
        ans = res_sort[0][1]**3

print(ans)

Submission status: Wrong Answer

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

from collections import Counter
res = [x%K for x in range(1, N+1)]
res_sort = sorted(zip(Counter(res).keys(), Counter(res).values()))

if K%2==0:
    ans = res_sort[0][1]**3
    if K//2 < N:
        ans += res_sort[K//2][1]**3
else:
    if N < K:
        ans = 0
    else:
        ans = res_sort[0][1]**3

print(ans)

Submission status: Wrong Answer

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

from collections import Counter
res = [x%K for x in range(1, N+1)]
res_sort = sorted(zip(Counter(res).keys(), Counter(res).values()))

if K%2==0:
    ans = res_sort[0][1]**3
    if K//2 < N:
        ans += res_sort[K//2][1]**3
else:
    ans = res_sort[0][1]**3

print(ans)

Submission status: Wrong Answer

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

"""
a+b = K i
b+c = K j
c+a = K k
2(a+b+c) = K(i+j+k)

k%2=0ならば,
a+b+cはk//2の倍数でなければならない、かつ、差を取ると結局a,b,cがそれぞれk//2の倍数
でなければならい。それでa+b,b+c,c+dはｋの倍数だから、a,b,cはすべて偶数またはすべて奇数
でなければならない。

それ以外の場合、
a+b+cがkの倍数である必要があり、かつ差を取ると結局a,b,cがすべてkの倍数でなければ
ならない。
"""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
j=0
m=0
ans = 0
if k % 2 == 1:
    j= n//k
    print('j',j)
    ans=j*j*j

else:
    j=n//k
    m=(n-k//2)//k+1
    print('j',j,'m',m)
    ans=m*m*m+j*j*j
 
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
ans = 0

def c(p):
  return((n-p)//k + 1)

ans = 0
for a in range(1,k+1):
  if (2*a)%k != 0:
    pass
  else:
    print(a)
    print(c(a)*c(a)*c(k-a))
    
print(ans*6)

Submission status: Wrong Answer

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

ans = 0

ans += (N // K) ** 3

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


print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
count = 0
mod = 10**9 + 7


def comb(n, r):
    res = 1
    for i in range(1, r+1):
        res = res*(n-i+1) % mod
        res = res*pow(i, mod-2, mod) % mod
    return res


for i in range(1, n+1):
    if i*2 % k == 0:
        count += 1
        x = (n-i) // k
        count += x*6
        if x >= 2:
            count += 6*comb(x, 2)

print(count)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, k = Is()
if k > n:
    print(0)
    exit()
a = n//k
ans = a**3
if k % 2 != 0:
    print(ans)
    exit()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# ABC108C

n, k = map(int, input().split())
count = 0
for a in range(1, n + 1):
    for b in range(1, n + 1):
        if (a + b) % k == 0:
            for c in range(1, n + 1):
                if (b + c) % k == 0 and (c + a) % k == 0:
                    print(a, b, c)
                    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    N, K = MI()

    ans = 0
    for a in range(1, N+1):
        b = K - a if K - a > 0 else K
        c = b
        # print(a, b, c)
        if (b + c) % K == 0:
            cnt_b = (N - b) // K + 1
            ans += cnt_b ** 2
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')
from math import ceil

def solve():
    N, K = MI()

    NmodK = max(N % K, 1)
    times = ceil(N / K)
    ans = 0
    for a in range(1, K+1):
        b = K - a if K - a > 0 else K
        c = b
        # print(a, b, c)
        if (b + c) % K == 0:
            cnt_b = (N - b) // K + 1
            # print('bbb', cnt_b)
            if a <= NmodK:
                t = times
            else:
                t = times - 1
            # print(cnt_b ** 2, t)
            ans += cnt_b ** 2 * t
    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')
from math import ceil

def solve():
    N, K = MI()

    NmodK = N % K
    times = ceil(N / K)
    ans = 0
    for a in range(1, K+1):
        b = K - a if K - a > 0 else K
        c = b
        # print(a, b, c)
        if (b + c) % K == 0:
            cnt_b = (N - b) // K + 1
            # print('bbb', cnt_b)
            if a <= NmodK:
                t = times
            else:
                t = times - 1
            ans += cnt_b ** 2 * t
    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
 
n, k =  map(int, input().split())

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

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
if K % 2 == 1:
    print((N // K )**3)

Submission status: Wrong Answer

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

# num[x]:kで割ってxあまる数が1以上N以下に何個あるか
num = [0 for _ in range(k)]
for i in range(1, n + 1):
    num[i % k] += 1
print(num)
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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#108c
import math
N,K = map(int, input().split())

#a,b,cが全て
# = K/2*(2n+1) …(1) 0 <= n , K/2*(2n+1) <= N
# = K*n  　　　…(2) 0 < n  , K*n <=N
#ならOK。ただし、a,b,cは整数なのでK/2が整数でなければ(1)はNG

if K == 1:
    #すべてのa,b,cがOK
    print(pow(N,3))
else:
    #(2)はKに関わらずOK
    #K*n <= N
    #n <= N/K
    #print("(2)K*n")
    print([i*K for i in range(1,1+int(N/K))])
    ans = pow(int(N/K),3)
    
    if K%2 == 0:
        #(1)も考えてやる
        #K/2*(2n+1) <= N
        #K*(2n+1) <= 2N
        #2n+1 <= 2N/K
        #2n <= 2N/K - 1
        #n <= N/K - 1/2
        n_limit = int(N/K - 1/2)
        #print("(1)K/2*(2n+1)")
        if K/2 <= N:
            print([int((K/2)*(1+(2*i))) for i in range(0,n_limit + 1)])
            ans += pow(n_limit + 1,3) #n = 0の時もOKなので+1
    
    print(ans)

Submission status: Wrong Answer

Solution code:
#108c
import math
N,K = map(int, input().split())

#a,b,cが全て
# = K/2*(2n+1) …(1) 0 <= n , K/2*(2n+1) <= N
# = K*n  　　　…(2) 0 < n  , K*n <=N
#ならOK。ただし、a,b,cは整数なのでK/2が整数でなければ(1)はNG

if K == 1:
    #すべてのa,b,cがOK
    print(pow(N,3))
else:
    #(2)はKに関わらずOK
    #K*n <= N
    #n <= N/K
    #print("(2)K*n")
    #print([i*K for i in range(1,1+int(N/K))])
    ans = pow(int(N/K),3)
    
    if K%2 == 0:
        #(1)も考えてやる
        #K/2*(2n+1) <= N
        #K*(2n+1) <= 2N
        #2n+1 <= 2N/K
        #2n <= 2N/K - 1
        #n <= N/K - 1/2
        n_limit = int(N/K - 1/2)
        #print("(1)K/2*(2n+1)")
        #print([int((K/2)*(1+(2*i))) for i in range(0,n_limit + 1)])
        ans += pow(n_limit + 1,3) #n = 0の時もOKなので+1
    
    print(ans)

Submission status: Wrong Answer

Solution code:
#108c
import math
N,K = map(int, input().split())

#a+b,b+c,c+a がすべて K の倍数

#TLEする。
#ans = 0
#
#for a in range(1,N+1):
#    if K>a:
#        base = K-a
#    else:
#        base = K*int(1+a/K)-a
#    
#    b_list = [base+i*K for i in range(0,1+math.floor((N-base)/K))]
#   
#    for b in b_list:
#        if K > b:
#            base = K-b
#        else:
#            base = K*int(1+b/K)-b
#
#        c_list = [base+i*K for i in range(0,1+math.floor((N-base)/K))]
#        
#        for c in c_list:
#            if (a+c)%K == 0:
#                ans += 1
#                print(a,b,c,":",a/K,b/K,c/K)
#                
#print(ans)

#上ので試してみた結果
#…K%2 = 0なら a,b,cは全てが K/2の奇数の倍数(1,3,5...) or Kの整数倍
#ex
#31415 9266
#4633 4633 4633 : 0.5 0.5 0.5
#4633 4633 13899 : 0.5 0.5 1.5
#9266 9266 9266 : 1.0 1.0 1.0
#9266 9266 18532 : 1.0 1.0 2.0
#9266 9266 27798 : 1.0 1.0 3.0

#…K%2 = 1なら Kの整数倍

if K==1:
    #すべてのa,b,cがOK
    print(N*N*N)
    
elif K%2 == 0:
    #K/2の奇数の倍数(1,3,5...) と Kの整数倍
    print([int(i*K/2) for i in range(1,1+2*math.floor(N/K)) if i%2 == 1])
    ans = len([int(i*K/2) for i in range(1,1+2*math.floor(N/K)) if i%2 == 1]) **3
    print([i*K for i in range(1,1+math.floor(N/K))])
    ans += math.floor(N/K)**3
    print(ans)
elif K%2 == 1:
    print([i*K for i in range(1,1+math.floor(N/K))])
    print((math.floor(N/K)**3))

Submission status: Wrong Answer

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

if K % 2 == 0:
    ans = (N // K)**3 + ((N - K // 2) // (K // 2))**3
else:
    ans = (N // K)**3
print(ans)
# a + b = K * i
# b + c = K * j
# c + a = K * k

# 2 * (a + b + c) = K * (i + j + k)

# a + b + c = K * (i + j + k) / 2
# よってKが２の倍数でないなら i + j + k は偶数でないといけない

# aを固定したときを考える
# b = K * i - a
# c = K * k - a

# b + c = K * j = K * (i + k) - 2 * a

# 2 * aもKの倍数出ないといけない
# 同じように考えると 2 * b, 2 * cもKの倍数でないといけない

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
s=n//k
t=0
if k%2==0:
  t=(n+k//2)//2
print(s*s*s+t*t*t)

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
# 2 * (a+b+c) がKの倍数
# Kが2の時は全て偶数か、全て奇数
# Kが2ではない時、全てKの倍数
if K == 2:
    odd = (N+1) // 2
    even = N // 2
    answer = odd ** 3 + even ** 3
else:
    num = N // K
    answer = num ** 3

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    array = [i*k for i in range(1, int(n/k)+1)]
    ans = 0
    if k%2 == 0:
        array.extend([int(i*k+k/2) for i in range(0, int(n/k-1/2)+1)])
    for i in array:
        for j in array:
            for l in array:
                if (i+j)%k==0 and (j+l)%k==0 and (i+l)%k==0:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd
import itertools 

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


num = [0]*k

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

ans = 0

for a in range(k):
    b = (k-a)%k
    c = (k-a)%k
    if (b+c)%k != 0:
        continue
    ans = ans + num[a]*num[b]*num[c]


print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, K = (int(_) for _ in input().split())
    ans = 0
    if K%2 ==0:
        d = N // K
        cnt = 0
        for i in range(1,N):
            if K % i == K/2: cnt+=1
        ans = d ** 3 + cnt ** 3
    else:
        d = N // K     
        ans = d ** 3
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#108_C
N,K=map(int,input().split())
Ans=0
if K%2==1:
    x=N//K
    Ans=x**3
else:
    x=N//K
    y=(2*N-1)//(2*K)+1
    Ans=x**3+y**3
    
print(Ans)

Submission status: Wrong Answer

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

x, y = 0, 0
for i in range(1, n+1):
    if i % k == k//2:
        x += 1
    elif i % k == 0:
        y += 1

if k % 2 == 0:
    print(x**3 + y**3)
else:
    print(y**3)

Submission status: Wrong Answer

Solution code:
# 以下のいずれか
# :3つともKの倍数である
# :3つともKで割った余りがKの1/2である(Kが偶数)
n,k=map(int,input().split())
ans=n//k
if k%2==0:
  if n>=k//2:
    c=(n-k//2)//k+1
    ans+=c**3
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

ans = a ** 3
if K % 2 == 0:
  ans += b ** 3

print(ans)

Submission status: Wrong Answer

Solution code:
n,k =map(int, input().split())
#連立方程式を解く
#m*k/2がn以下のkの倍数となる値を数える
#kが偶数の時、a,b,cをkで割った余りは0かk/2
#kが奇数の時、a,b,cをkで割った余りは0
ans=0
odd=0
even=0

#奇数の数
odd=n//k

#偶数の数
even=n//(k/2)-odd

if k%2==0:
  ans+=odd**3+even**3
else:
  ans+=odd**3

print(int(ans),even,odd)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
odd_flag = K % 2

count = 0
for n in range(1,(2 * N) // K + 1):
  if odd_flag:
    if n %2:
      continue
  for m in range(n,(2 * N) // K + 1):
    if odd_flag:
      if m%2:
        continue
    for l in range(m,(2 * N) // K + 1):
      if odd_flag:
        if l %2:
          continue
      #print(n,m,l)
      
      nums = (n,m,l)
      if (sum(nums)- 2 * min(nums)) * K > 2 * N:
        #print('error a')
        break
      if n+m-l >0 and n+l-m >0 and m+l-n>0:
        if n == m == l:
          count +=  1
        elif n in (m,l) or m==l:
          count += 3
        else:
          count += 6
        #print('a:{} b{} c{}'.format((n+m-l)*K/2, (n-m+l)*K/2, (-n+m+l)*K/2))
      #print('error b')
      #print('a:{} b{} c{}'.format((n+m-l)*K/2, (n-m+l)*K/2, (-n+m+l)*K/2))
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# a + b = kx
# b + c = ky
# c + a = kz
# a = k(x-y+z)/2

div = n // k
# kが奇数のとき,(a,b,c)はそれぞれkで割った余りは0になる
if k % 2 == 1:
    print(div ** 3)
# kが偶数のとき,(1) + (2)を足したもの
# (1) (a,b,c)それぞれkで割った余りが0
# (2) k/2余る
else:
    if div * k + k/2 <= n:
        print(div**3 + (div+1)**3)
    else:
        print(div**3)

Submission status: Wrong Answer

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

ans = 0

if K % 2 == 0:
    # a, b, c が全て K の倍数
    cnt = N // K 
    ans = cnt ** 3
    K //= 2
    k = K
    # a, b, c が K//2 の奇数倍
    tmp = 1
    while 1:
        K += 2 * k
        if N < K:
            break
        tmp += 1
    ##print(cnt, tmp)
    ans += (tmp) ** 3
else:
    cnt = N // K
    ans = cnt ** 3

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

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

print(mm**3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
if K % 2 == 1:
  print((N//K)*(N//K)*(N//K))
else:
  C = (N//K)*(N//K)*(N//K)
  Kp = K // 2
  C2 = (N//K + 1)*(N//K + 1)*(N//K + 1)
  print(C + C2)

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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

if k % 2 != 0:
    w = n // k
    print(w**3)
else:
    w1 = n // k
    w2 = (n + (k//2)) // k
    print(w1,w2)
    print((w1 ** 3) + (w2 ** 3) )

Submission status: Wrong Answer

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

if k % 2 != 0:
    w = n // k
    print(w**3)
else:
    w1 = n // k
    w2 = round(n/k)
    print(w1,w2)
    print((w1 ** 3) + (w2 ** 3) )

Submission status: Wrong Answer

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

num = 6*n // k
count = 0
for i in range(1, n+1):
    for j in range(1, num-1):
        b = j * k - i
        if b > n:
            break
        for l in range(1, num-1-j):         
            c = l*k - i
            if c > n or b < 0 and c < 0:
                break
            if 0 < b and 0 < c and (b+c) % k == 0:
                count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
num=[0]*k
for i in range(n):
    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)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
ans = [int(x) for x in range(2,1+2*N,2) if x % K ==0]
print(len(ans) ** 2)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
n = (2 * N) // K
A = []
for i in range(n + 1):
    A.append(K * i)
A = np.array(A)
A = A[A >= 2]
ans = 0
for i in A:
    if i % 2 == 0:
        ans += 1
    for j in range(1, i//2):
        if j <= N and i - j <= N:
            if 2 * j % K ==0 and 2 * (i-j) % K == 0:
                ans += 6
            elif 2 * j % K ==0:
                ans += 3
            elif 2 * (i-j) % K == 0:
                ans += 3
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
n = (2 * N) // K
A = []
for i in range(n + 1):
    A.append(K * i)
A = np.array(A)
A = A[A >= 2]
ans = 0
for i in A:
    for j in range(1,min(i,N+1)):
        if i - j <= N and 2 * j % K == 0:
            a = j
            b = i - j
            if a == b:
                ans += 1
            else:
                ans += 2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
n = (2 * N) // K
A = []
for i in range(n + 1):
    A.append(K * i)
A = np.array(A)
A = A[A >= 2]
ans = 0
for i in A:
    for j in range(1,min(i,K+1)):
        if i - j <= K and 2 * j % K == 0:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
from itertools import permutations
input = sys.stdin.readline

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

if K == 1:
    print(0)
    exit()

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

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

print(ans)

Submission status: Wrong Answer

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

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

if K % 2 != 0:
    ans = (len(Xn)**len(Xn))
else:
    ans = (len(Xn2)**len(Xn2))
print(ans)

Submission status: Wrong Answer

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

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

if K % 2 != 0:
    ans = (len(Xn)**2)
else:
    ans = (len(Xn2)**2)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
num=n//k
last=n%k
if last==0:
  x=(k+1)*num
  print(x**3)
else:
  x=(k+1)*num
  y=x**3
  for i in range(1,last+1):
    y+=(2*num)**3
  print(y)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
num=n//k
last=n%k
if last==0:
  x=(num**2)*k
  print(x**3)
else:
  x=(num**2)*k
  y=x**3
  for i in range(1,last+1):
    y+=(2*num)**3
  print(y)