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:
n,k=map(int,input().split())
num=n//k
last=n%k
if last==0:
  x=2*(num**2)*(k+2)*(k+1)
  print(x*(x-1)*(x-2)//6)
else:
  y=2*(num**2)*(k+2)*(k+1)
  for i in range(1,last+1):
    y+=(2*num)*((2*num)-1)*((2*num)-2)//6
  print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    if(k&1):
        s=n//k
        print(s**3)
    else:
        s=n//k
        print(s**3+(s+1)**3)
resolve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import product

n,k = [int(x) for x in stdin.readline().rstrip().split()]

f = n//k

li = [0]*f

#重複あり順列
from itertools import product
lin = list(product(li, repeat=3))

print(len(lin))

Submission status: Wrong Answer

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

ans = 0

for a in range(1,n+1):
    b = k-a%k
    c = k-a%k

    if (b+c)%k == 0:
        b_memo = n//k - b//k +1
        c_memo = n//k - c//k +1
        ans += b_memo*c_memo
        

print(ans)

Submission status: Wrong Answer

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

# mod で分類
mod_lst = [N // K for _ in range(K)]
for i in range(N % K):
	mod_lst[-(i + 1)] += 1

ans = 0	

for i in range(K):
	for j in range(i, K):
		for k in range(j, K):
			if (i + j + k) % K == 0:
				print(i, j, k)
				if i == j and j == k:
					doub_1 = 1
					doub_2 = 2
				elif i == j:
					doub_1 = 1
					doub_2 = 0
				elif j == k:
					doub_1 = 0
					doub_2 = 1
				elif k == i:
					doub_1 = 0
					doub_2 = 1
				else:
					doub_1 = 0
					doub_2 = 0
					
				ans += mod_lst[i] * (mod_lst[j] - doub_1) * (mod_lst[k] - doub_2)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = [int(x) for x in input().split()]
ans = (N//K) ** 3
if K % 2 == 0:
    ans += (N//K + 1) ** 3
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = [int(x) for x in input().split()]
if K % 2 == 0:
    cnt = N//K + 1
    ans = cnt ** 3
    ans += N//K 
else:
    ans = (N//K) ** 3
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
# 2(a+b+c) はKの倍数
# Kが２でない時、
# Kが奇数ならa,b,cは全てKの倍数
# Kが偶数ならa,b,cは全てKの倍数か、全てK//2の倍数
# Kが２の時
if K == 2:
    print((N//2)**3 + (N+1//2)**3)
elif K % 2 != 0:
    a = N//K
    print(a**3)
else:
    a = N//K
    b = N//(K//2) - N//K
    print(a**3 + b**3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
ary = []
even1 = []
even2 = []
ans = 0
if K % 2 == 1:
    for i in range(1,N+1):
        if i % K == 0:
            ary += [i]
    if len(ary) >= 2:
        ans += len(ary) ** 3
    else:
        ans = 1
else:
    for i in range(1,N+1):
        if i % K == 0:
            even1 += [i]
        elif i % (K/2) == 0:
            even2 += [i]
    if len(even1) >= 2:
        ans += len(even1) ** 3
    else:ans += 1
    if len(even2) >= 2:
        ans += len(even2) ** 3
    else:ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ev = 0
ev2 = 0
od = 0
if K % 2 == 1:
    for i in range(N):
        if i % K == 0:
            od += 1

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

Submission status: Wrong Answer

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

ev = 0
ev2 = 0
od = 0
if K % 2 == 1:
    for i in range(N):
        if i % K == 0:
            od += 1

    print(od**3)
else:
    for i in range(N):
        if i % K == 0:
            ev += 1
        if i % (K/2) == 0:
            ev2 += 1
        if i % K == 0 and i % (K/2) == 0:
            od += 1
    ans = ev**3 + ev2**3 - od**3
    print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
ans = 0
if k % 2:
    ans += (len(list(range(k,n,k))))**3
else:
    ans += (len(list(range(k,n,k))))**3
    count = 0
    for i in range(1,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())
s=K**3
for i in range(1,N+1):
  for j in range(1,N+1):
    if (i+j)%K!=0:
      s-=1
    else:
      for k in range(1,N+1):
        if (j+k)%K!=0:
          s-=1
        else:
          if (k+i)%K!=0:
            s-=1
print(s)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
s=0
for i in range(1,N+1):
  for j in range(1,N+1):
    for k in range(1,N+1):
      if (i+j+k)%K==0:
        s+=1
print(s)

Submission status: Wrong Answer

Solution code:
import math

n,k=map(int,input().split())
if k%2!=0:
    nums=math.ceil(n/k)
    print(nums*3)
 
else:
    nums1=math.floor(2*n/k)


    if nums1%2==0:
        a=int(nums1/2)
        b=nums1-a
        print(a**3+b**3)
    
    
    if nums1%2!=0:
        a=int((nums1+1)/2)
        b=nums1-a
        print(a**3+b**3)

Submission status: Wrong Answer

Solution code:
import math

n,k=map(int,input().split())
if k%2!=0:
    nums=math.ceil(n/k)
    print(nums*3)
 
else:
    nums1=math.floor(2*n/k)
    print(nums1)

    if nums1%2==0:
        a=int(nums1/2)
        b=nums1-a
        print(a**3+b**3)
    
    
    if nums1%2!=0:
        a=int((nums1+1)/2)
        b=nums1-a
        print(a**3+b**3)

Submission status: Wrong Answer

Solution code:
import math

n,k=map(int,input().split())
if k%2!=0:
  nums=math.ceil(n/k)
  print(nums*3)
 
else:
  nums1=math.ceil(2*n/k)
  if nums1%2==0:
    a=int(nums1/2)
    b=nums1-a
    print(a**3+b**3)
    
    
  elif nums1%2!=0:
    a=int((nums1+1)/2)
    b=nums1-a
    print(a**3+b**3)

Submission status: Wrong Answer

Solution code:
import math

n,k=map(int,input().split())
if k%2!=0:
  nums=math.ceil(n/k)
  print(nums*3)
 
else:
  nums1=math.ceil(2*n/k)
  if nums1%2==0:
    a=int(nums1/2)
    b=nums1-a
    print(a**3+b**3)
    
    
  elif nums1%2!=0:
    a=int((nums1-1)/2)
    b=nums1-a
    print(a**3+b**3)

Submission status: Wrong Answer

Solution code:
from collections import Counter

print('input >>')
N, K = map(int, (input().split()))

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

Acount = Counter(A)
# print('ACount %s' % Acount)
ans = 0
for mod, times in Acount.items():
    mod_anti = K - mod
    if (K - mod) * 2 % K == 0:
        ans += Acount[mod] ** 3

# print('----------output----------')
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mx = n*2
ans = 0
numl = []
for i in range(k,mx+1,k):
  numl.append(i//2)

for i in numl:
  for j in numl:
    for l in numl:
      if ((i+j)%k ==0)&((j+l)%k ==0)&((l+i)%k ==0):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
if K % 2 != 0:
    ans = (N // K) ** 3
else:
    tmp1 = K // 2
    tmp2 = N // tmp1 - (N // K)
    ans = tmp1 ** 3 + tmp2 ** 3

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil 

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

count = 0
num = n // k
bb = [(i+1)*k for i in range(num) ]
s = len(bb) 
count += s + 3*s*(s-1) + s*(s-1)*(s-2)  

if k % 2 == 0:  
  num = ceil(n / k)
  bb = [i*k + k//2 for i in range(num) ]
  s = len(bb)
  count += s + 3*s*(s-1) + s*(s-1)*(s-2)
  
print(count)

Submission status: Wrong Answer

Solution code:
from math import ceil 

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

count = 0
num = ceil(n // k)
bb = [(i+1)*k for i in range(num) ]
s = len(bb) 
count += s + 3*s*(s-1) + s*(s-1)*(s-2)  

if k % 2 == 0:  
  num = ceil(n / k)
  bb = [i*k + 2//k for i in range(num) ]
  s = len(bb)
  count += s + 3*s*(s-1) + s*(s-1)*(s-2)
  
print(count)

Submission status: Wrong Answer

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

count = 0
num = n // k 
bb = [i*k for i in range(1,num+1)]
s = len(bb) 
count += s + 3*s*(s-1) + s*(s-1)*(s-2)  

if k % 2 == 0:  
  bb = [i*k + int(2/k) for i in range(num) ]
  s = len(bb)
  count += s + 3*s*(s-1) + s*(s-1)*(s-2)

print(count)

Submission status: Wrong Answer

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

count = 0
num = n // k + 1
bb = [i*k for i in range(1,num)]
s = len(bb) 
count += s + 3*s*(s-1) + s*(s-1)*(s-2)  

if k % 2 == 0:  
  bb = [i*k + int(2/k) for i in range(num) ]
  s = len(bb)
  count += s + 3*s*(s-1) + s*(s-1)*(s-2)

print(count)

Submission status: Wrong Answer

Solution code:
def check():
    a = []
    bDict2 = {}
    count = 0
    removeList = []
    N, K = [int(i) for i in input().split(' ')]
    for i in range(1,N+1):
        if (2*i)%K == 0:
            a.append(i)


    while a != []:
        temp = a[0]
        for i in a:
            if (temp+i)%K == 0:
                removeList.append(i)
                if str(temp) not in bDict2:
                    bDict2[str(temp)] = 1
                else:
                    bDict2[str(temp)] += 1  
                    
        for i in removeList:
            a.remove(i)
        removeList.clear()
    print(bDict2)
            
    for i in bDict2:
        count += bDict2[i]**3

    print(count)
    
check()

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

Submission status: Wrong Answer

Solution code:
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

def check():
    a = []
    b = []
    count = 0
    bDict = {}
    bDict2 = {}
    removeList = []
    N, K = [int(i) for i in input().split(' ')]
    for i in range(1,N+1):
        if (2*i)%K == 0:
            a.append(i)
    count += len(a)
    
    while a != []:
        temp = a[0]
        for i in a:
            #print(i)
            if (temp+i)%K == 0:
                removeList.append(i)
                if str(temp) not in bDict2:
                    bDict2[str(temp)] = 1
                else:
                    bDict2[str(temp)] += 1  
                    
        for i in removeList:
            a.remove(i)
        removeList.clear()
    #print(bDict2)
            
    for i in bDict2:
        if bDict2[i] == 2:
            print(bDict2[i])
            count += 3*permutations_count(bDict2[i], 2)
        if bDict2[i] > 2:
            count += permutations_count(bDict2[i], 3)

    print(count)
check()

Submission status: Wrong Answer

Solution code:
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

def check():
    a = []
    b = []
    count = 0
    bDict = {}
    bDict2 = {}
    removeList = []
    N, K = [int(i) for i in input().split(' ')]
    for i in range(1,N+1):
        if (2*i)%K == 0:
            a.append(i)
    count += len(a)

    while a != []:
        temp = a[0]
        for i in a:
            #print(i)
            if (temp+i)%K == 0:
                removeList.append(i)
                if str(temp) not in bDict2:
                    bDict2[str(temp)] = 1
                else:
                    bDict2[str(temp)] += 1  
                    
        for i in removeList:
            a.remove(i)
        removeList.clear()
    #print(bDict2)
            
    for i in bDict2:
        if bDict2[i] > 1:
            print(bDict2[i])
            count += 3*permutations_count(bDict2[i], 2)
        if bDict2[i] > 2:
            count += permutations_count(bDict2[i], 3)

    print(count)
check()

Submission status: Wrong Answer

Solution code:
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

def check():
    a = []
    b = []
    count = 0
    bDict = {}
    N, K = [int(i) for i in input().split(' ')]
    for i in range(1,N+1):
        if (2*i)%K == 0:
            a.append(i)
    #print(a)
    for i in a:
        for j in range(1,N+1):
            if (i + j)%K == 0 and i != j:
                b.append((i,j))
                if str(i) not in bDict:
                    bDict[str(i)] = 1
                else:
                    bDict[str(i)] += 1
    
    for i in bDict:
        if bDict[i] > 1:
            count += permutations_count(bDict[i]+1, 3)

    #print(b)
    print(3*len(b)+len(a)+count//3)
check()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
N,K = map(int,input().split())
ans = int(N/K)**3
if K%2==0:
    ans += (int(N/K)+1)**3
print (ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

if K%2 == 0:  # K が偶数
	if N - K//2 <= 0:
		print((N//K)**3)
	else:
		print((N//K)**3+((N-K//2)//K+1)**3)
else:  # K が奇数
	print((N//K)**3)

Submission status: Wrong Answer

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

for j in range(1,n+1):
    for l in range(1,n+1):
        for m in range(1,n+1):
            if ((j+l)+(l+m)+(m+j))%k == 0:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = list(map(int, input().split()))
    if k % 2 == 0:
        if n- (n//k) * k >= k/2:
            num = (n//k) ** 3 + ((n//k + 1) ** 3)
        else:
            num = ((n//k) * 2) ** 3
    else:
        num = (n//k) ** 3
    print(num)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

i = 1
lim = int(2*N/K)
ans = 0

while i <= lim:
    j = 1
    while j < lim/2 + i:
        if lim-abs(i-j) < i+j:
            up = lim-abs(i-j)
        else:
            up = i+j-1
        if abs(i-j) < i+j-lim:
            down = i+j-lim
        else:
            down = abs(i-j)+1
        if up-down+1>0:
            ans += up-down+1
        j += 1
    i += 1

print(ans)

Submission status: Wrong Answer

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

i = 1
lim = int(2*N/K)
ans = 0

while i <= lim:
    j = 1
    while j <= lim:
        if lim-abs(i-j) < i+j:
            up = lim-abs(i-j)
        else:
            up = i+j-1
        if abs(i-j) < i+j-lim:
            down = i+j-lim
        else:
            down = abs(i-j)+1
        if up-down+1>0:
            ans += up-down+1
        j += 1
    i += 1

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
for a in range(1, N):
    for b in range(1, N):
        if a + b % K == 0:
           for c in range(1, N):
               if b + c % K == 0 and c + a % K == 0:
                   ans += 1
print(ans)

Submission status: Wrong Answer

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

count = 0
for a in range(N):
    for b in range(N):
        if (a+b) % K != 0:
            continue
        else:
            for c in range(N):
                if (b+c) % K == 0 and (c+a) % K == 0:
                    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def solve(N, K):
    n = N // K
    answer = n ** 3
    if K % 2 == 0:
        m = K//2
        n = (N - m) // K
        answer += n ** 3
    return answer
        
N, K = [int(x) for x in input().split()]
print(solve(N, K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K%2==1:
    s=K
else:
    s=K//2

ans=[]

for i in range((N-s)//s+1):
    for j in range(i,(N-s)//s+1):
        for k in range(j,N-s//s+1):
            if s+max(i,j,k)*s <= N and (2+i+j)*s%K==0 and (2+j+k)*s%K==0 and (2+k+i)*s%K==0:
                ans.append((s+i*s,s+j*s,s+k*s))

print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
def resolve():
    (N, K) = list(map(int, input().split(" ")))
    srps = [0] * (K+1)
    # srps[n]: Kで割った余りがnである数が1~Nの間にいくつ存在するか
    for i in range(1, N+1):
        srps[i%K] += 1
    cnt = 0

    for a in range(K):
        b = (K-a) % K
        c = (K-a) % K
        if (b+c)%K != 0:
            continue
        print(a, b, c)
        cnt += (srps[a] * srps[b] * srps[c])
    
    print(cnt)

        

if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
 
 
def solve(K: int):
    if K % 2 == 0:
        print((K//2)**2)
    else:
        print((K+1)//2 * (K-1)//2)
    return
 
 
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

div = N//K

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = [int(i) for i in input().split()]
cnt = 0
for i in range(max(2//K,1), (2*N)//K+1):
    for j in range(max(2//K, 1), (2*N)//K+1):
        for m in range(max(2 // K, 1), (2 * N) // K+1):
            if 2/K<=i-j+m<=2*N/K and 2/K<=j-m+i<=2*N/K and 2/K<=m-i+j<=2*N/K:
                if K%2 == 0:
                    cnt+=1
                    print((i-j+m)*K//2, (j-m+i)*K//2, (m-i+j)*K//2)
                elif (i+j+m)%2==0:
                    cnt+=1
                    print((i-j+m)*K//2, (j-m+i)*K//2, (m-i+j)*K//2)

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print((n // k) ** 3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = 35897, 932
print('ans: 114191')

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import product
N, K = map(int, input().split())
x = list(product(range(1, N + 1), repeat=3))
print(0)

Submission status: Wrong Answer

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

if N < K:
    print(1)

# Kが奇数の場合
elif K % 2:
    print((N // K) ** 3)

else:
    import math
    step = (math.ceil(N / K), N // K)
    print(step[0] ** 3 + step[1] ** 3)

Submission status: Wrong Answer

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

# Kが奇数の場合
if K % 2:
    print((N // K) ** 3)

else:
    import math
    step = (math.ceil(N / K), N // K)
    print(step[0] ** 3 + step[1] ** 3)

Submission status: Wrong Answer

Solution code:
import itertools

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

E = []
O = []

ans = 0
for i in range(1, N+1):
    if K % 2 == 1:
        if i % K == 0:
            O.append(i)
    else:
        if i % K == 0 or i % K == K/2:
            E.append(i)

if K % 2 == 1:
    print(len(O)**3)
else:
    print(len(E)*3)

Submission status: Wrong Answer

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

mod_K = len([i for i in range(1, N) if i % K == 0])
mod_half_K = len([i for i in range(1, N) if i % (K/2) == 0])

print(mod_K*mod_K*mod_K + mod_half_K * mod_half_K * mod_half_K)

Submission status: Wrong Answer

Solution code:
import itertools

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

comb = []
if K % 2 != 0:
    tail = N//K+1
    for a in range(1, tail):
        for b in range(1, tail):
            for c in range(1, tail):
                # print('odd:', a*K, b*K, c*K)
                comb.append((a, b, c))
else:
    tail = N//K+1
    tail_plus_half = (tail+1)*K <= N
    # print('tail', tail, ', plus_half', tail_plus_half)
    for a in range(0, tail):
        for b in range(0, tail):
            for c in range(0, tail):
                if a != 0 and b != 0 and c!= 0:
                    # print('even_1:', a*K, b*K, c*K)
                    comb.append((a*K, b*K, c*K))
                
                # print('even_2:', a*K+K//2, b*K+K//2, c*K+K//2)
                comb.append((a*K+K//2, b*K+K//2, c*K+K//2))
                if tail_plus_half and (a == tail-1 or b == tail-1 or c == tail-1):
                    # print('even_3:', a, b, c)
                    comb.append((a, K, 2, b, K, 2, c, K, 2))

# print(*comb, sep='\n')
print(len(set(comb)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
a = N // K

if K % 2 != 0:
    ans = a**3
else:
    if round(N / K) == a:
        ans = 2 * a**3
    else:
        ans = a**3 + (a+1)**3

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

#Kの偶奇で場合分け
#Kが偶数なら(x,y,z) x, y, z = K/2, 0 (mod K) でKが奇数なら(x,y,z) x, y, z = 0 (mod K)

output = 0

output += int(N / K)**3

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

print (output)

Submission status: Wrong Answer

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

ans = 0
if k % 2 == 0:
  ans = int(math.floor(n/k)) ** 3 + int(math.ceil(n/k)) ** 3
else:
  ans =  int(math.floor(n/k)) ** 3
  
print(ans)

Submission status: Wrong Answer

Solution code:
# a<=b<=cとして、後から種類数に応じてx1,x3,x6をする
N,K = map(int, input().strip().split(' '))
count = 0
for i in range(1,N+1):
  a = i
  cand_b = [b for b in range(a, N+1) if (a+b)%K == 0]
  for i,b in enumerate(cand_b):
    cand_c = [c for c in cand_b[i:] if (b+c)%K == 0]
    for c in cand_c:
      count += [1,3,6][len({a,b,c})-1]
      print(a,b,c)
print(count)

Submission status: Wrong Answer

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

def comb(x):
    return x ** 3


if K % 2 == 0:
    n = N // K
    m = N // K if N % K < K % 2 else N // K + 1
    print(comb(n)+comb(m))
else:
    print(comb(N//K))

Submission status: Wrong Answer

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


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

print(a+(N//K)**3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K =[int(i) for i in input().split()]
if K % 2 == 0:
    K_unit1 = int(N//K)
    K_half = K//2
    N_khalf = N
    K_unit2 = 1 + int(N_khalf//K)
    K1 = K_unit1 ** 3
    K2 = K_unit2 ** 3
    out = K1 + K2
else:
    K_unit1 = int(N//K)
    out = K_unit1 ** 3
 
print("{0}".format(out))