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

Submission status: Wrong Answer

Solution code:
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 and (a + a) % k == 0:
            count += 1
print(count * 2 - 1)

Submission status: Wrong Answer

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

pair = []
single = [i for i in range(1, N+1) if 2*i % K == 0]
comb = list(itertools.combinations(range(1,N+1), 2))
for a, b in comb:
  if (a + b) % K == 0:
    pair.append((a, b))

print(len(single)  + len(pair) * (len(single) - 2) * 6)

Submission status: Wrong Answer

Solution code:
import math
 
s = input().split()
 
n = int(s[0])
k = int(s[1])

if k > n*3:
  print(0)
elif k%2 != 0:
  print(int(n/k)*int(n/k)*int(n/k))
else:
  a = int(n/k)
  h = k/2
  b = math.ceil(math.ceil(n/h)/2)
  print(a*a*a+b*b*b)

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
N=a[0]
K=a[1]
l=[]
n=0
L=[i for i in range(1,N+1)]
for i in range(N):
    if (2*i)%K==0:
        l.append(i)
for j in range(len(l)):
    m=[]
    for k in L:
        if k%K==l[j]:
            m.append(k)
            L.remove(k)
    if len(m)>=2:
        n += len(m)**3
    elif l[j]==0:
        n+=len(m)**3
print(n)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
cnt=0
ablist=[]
for a in range(n):
    for b in range(n):
        if (a+b)%k==0:
            ablist.append([a,b])
for a, b in ablist:
    for c in range(n):
        if (b+c)%k==0 and (c+a)%k==0:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N , K = (int(i) for i in input().split())
count = 0
a = 0
b = 0
c_h = 0
c_l = 0
if N >= K:
    for i in range(1,N+1):
        a = i
        b = a*(-1)
        while b <= N-K:
            b += K
            c = a*(-1)
            if b > 0:
                while c <= N-K:
                    c += K
                    if c > 0:
                        if (b+c)%K==0:
                            count += 1
print(count)

Submission status: Wrong Answer

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

else:
    result=(int(N/K))**3+(int(N/K)+1)**3
    if N>=K:
        print(result)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import math
 
s = input().split()
 
n = int(s[0])
k = int(s[1])
 
if k%2 != 0:
  print(int(n/k)*int(n/k)*int(n/k))
else:
  a = int(n/k)
  h = k/2
  b = math.ceil(math.ceil(n/h)/2)
  print(a*a*a+b*b*b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = (int(i) for i in input().split())
D = 0
for i in range(N + 1):
    for j in range(N + 1):
        A = i + j
        if A % K == 0:
            for j in range(N + 1):
                for k in range(N + 1):
                    B = j + k
                    C = i + k
                    if B % K == 0 and C % K == 0:
                        D += 1
print(D)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
a = int(n/k)
if(a < 2):
    b = 0
else:
    b = math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))
if(a < 3):
    c = 0
else:
    c = math.factorial(a) // (math.factorial(a - 3) * math.factorial(3))
ans = a + b * 6 + c * 6
if(k % 2 == 0):
    d = 1
    t = int(k / 2)
    while True:
        t += k
        if(t > n):
            break
        else:
            d += 1
    if(d < 2):
        e = 0
    else:
        e = math.factorial(d) // (math.factorial(d - 2) * math.factorial(2))
    if(d < 3):
        f = 0
    else:
        f = math.factorial(d) // (math.factorial(d - 3) * math.factorial(3))
    ans += (d + e * 6 + f * 6)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
 
s = input().split()
 
n = int(s[0])
k = int(s[1])
 
if k%2 != 0:
  print(int(n/k)*int(n/k)*int(n/k))
else:
  a = int(n/k)
  print(a*a*a+(a+1)*(a+1)*(a+1))

Submission status: Wrong Answer

Solution code:
N,K = (int(i) for i in input().split())
ans=0
a=(N*2)//K
for n in range(1,a+1):
    if (n*K)%2 == 0:
        ans +=1
        for i in range(1,(int((n*K)/2)+1)):
            if ((n*K/2)-K*i)>=1 and ((n*K/2)+K*i) <=N :
                ans +=6
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
a = 1
t = k
while True:
    t += k
    if(t > n):
        break
    else:
        a += 1
if(a < 2):
    b = 0
else:
    b = math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))
if(a < 3):
    c = 0
else:
    c = math.factorial(a) // (math.factorial(a - 3) * math.factorial(3))
ans = a + b * 6 + c * 6
if(k % 2 == 0):
    d = 1
    t = int(k / 2)
    while True:
        t += k
        if(t > n):
            break
        else:
            d += 1
    if(d < 2):
        e = 0
    else:
        e = math.factorial(d) // (math.factorial(d - 2) * math.factorial(2))
    if(d < 3):
        f = 0
    else:
        f = math.factorial(d) // (math.factorial(d - 3) * math.factorial(3))
    ans += (d + e * 6 + f * 6)
print(ans)

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
N=a[0]
K=a[1]
l=[]
n=0
L=[i for i in range(1,N+1)]
if 2*N<K:
    n=0
else:
    for i in range(N):
        if (2*i)%K==0:
            l.append(i)
    for j in range(len(l)):
        m=[]
        for k in L:
            if k%K==l[j]:
                m.append(k)
                L.remove(k)
        if len(m)>=2:
            n += len(m)**3
        elif l[j]==0:
            n+=len(m)**3
print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

s = input().split()

n = int(s[0])
k = int(s[1])

if k%2 != 0:
  print(int(n/k)*int(n/k)*int(n/k))
else:
  print(int(n/k)*int(n/k)*int(n/k)+int(n/k/4)*int(n/k/4)*int(n/k/4))

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
N=a[0]
K=a[1]
l=[]
n=0
L=[i for i in range(1,N+1)]
if 2*N<K:
    n=0
else:
    for i in range(N):
        if (2*i)%K==0:
            l.append(i)
    for j in range(len(l)):
        m=[]
        for k in range(1,N+1):
            if k%K==l[j]:
                m.append(k)
                L.remove(k)
        if len(m)>=2:
            n += len(m)**3
        elif l[j]==0:
            n+=len(m)**3
print(n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,K = (int(i) for i in input().split())
ans=0
a=(N*2)//K
for n in range(1,a+1):
    if (n*K)%2 == 0:
        ans +=1
        for i in range(1,(int((n*K)/2)+1)):
            if ((n*K/2)-i)>=1 and ((n*K/2)+i) <=N :
                ans +=6
print(ans)

Submission status: Wrong Answer

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

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

print(sum)

Submission status: Wrong Answer

Solution code:
N, K  = (int(i) for i in input().split())
for i in range(N + 1):
    for j in range(N + 1):
        for k in range(N + 1):
            A = i + j
            B = j + k
            C = i + k
            D = 0
            if A % K == 0 and B % K == 0 and C % K == 0:
                D += 1
print(D)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
same = 0
bonus = 0
for i in range(K, N*2+1, K):
    if(i%2 == 0):
        same += 1
if(same%2 == 0):
    for i in range(same-3, 0, -2):
        bonus += 6*i   
else:
    cof = 0
    for i in range(same-2, 0, -2):
        cof += 1
        bonus += 6*cof*i
print(same + bonus)

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
N=a[0]
K=a[1]
l=[]
n=0
for i in range(N):
    if (2*i)%K==0:
        l.append(i)
for j in range(len(l)):
    m=[]
    for k in range(1,N+1):
        if k%K==l[j]:
            m.append(k)
    if len(m)>=2:
        n += len(m)**3
    elif l[j]==0:
        n+=len(m)**3
print(n)

Submission status: Wrong Answer

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

p = 0

for a in range(1, n+1):
    for b in range(a, n+1):
        for c in range(b, n+1):
            if not ((a+b+c)*2)%k == 0:
                pass
            elif (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
                if a == b and b == c:
                    p += 1
                elif a == b and not b == c:
                    p += 3
                else:
                    p += 6
              
print( p )

Submission status: Wrong Answer

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

count = 0

R = N % K
if R == 0:
	R += K

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for a in range(1,N+1):
        for b in range(1,N+1):
            if b >= K and(a+b) % K == 0:
                for c in range(1,N+1):
                    if c >=(b+c) % K ==0 and (a+c) % K ==0:
                        total += 1

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p = 0

for a in range(1, n+1):
    for b in range(a, n+1):
        for c in range(b, n+1):
            if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
                if a == b and b == c:
                    p += 1
                elif a == b and not b == c:
                    p += 3
                else:
                    p += 6
              
print( p )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ct = 0
 
if K%2 != 0:
  ct = int(N/K)*int(N/K)*int(N/K)
else:
  ct = int(N/K)*int(N/K)*int(N/K) + (math.ceil(N/(K/2))/2)*(math.ceil(N/(K/2))/2)*(math.ceil(N/(K/2))/2)
  
print(str(ct))

Submission status: Wrong Answer

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

count = 0

R = N % K
if R == 0:
	R += K

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

print(count)

Submission status: Wrong Answer

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

ct = 0
 
if K%2 != 0:
  ct = int(N/K)*int(N/K)*int(N/K)
else:
  ct = int(N/K)*int(N/K)*int(N/K) + math.ceil(math.ceil(N/(K/2))/2)*math.ceil(math.ceil(N/(K/2))/2)*math.ceil(math.ceil(N/(K/2))/2)
  
print(str(ct))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil

a = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
numbers = [x for x in range(1,N+1)]
a = 0
for i in numbers:
    yaba = []
    for j in range((N+i)//K):
        yaba.append((j*K)-i)
    for j in yaba:
        for k in yaba:
            if j+k % K == 0:
                a += 1
            else:
                pass
print(a)

Submission status: Wrong Answer

Solution code:
l = input().split()
l[0]= int(l[0])
l[1]= int(l[1])
c1  = 0
c2=0
c3=0
for i in range(1,l[0]+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i+j % l[1] ==0 and i+k % l[1]==0 and j + k  %l[1]== 0:
                if i == j ==k:
                    c1 = c1+1
                elif i==j >k or i> j==k:
                    c2 = c2 + 1
                else:
                    c3 = c3 + 1
print(c1+c2*3+c3*6)

Submission status: Wrong Answer

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

count = (N // K)**3

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

print(count)

Submission status: Wrong Answer

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

li = []
ans = []
k = K
while k <= N**2:
	max = min(k, N+1)
	for i in range(k+1-max,max):
		li.append((i, k-i))

	k += K

for i in li:
	x1 = i[0]
	x2 = i[1]
	for j in [x for x in li if x[0] == x2]:
		if (j[1], x1) in li:
			ans.append((x1, x2, j[1]))

print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
lmnk=(6*N//K)
ans=0
for h in range(1,lmnk):
    a=h*K//2
    if 1<=a<=N:
        for i in range(1,lmnk-h):
            b=i*K-a
            if 1<=b<=N:
                for j in range(1,lmnk-i):
                    c=j*K-b
                    if 1<=c<=N:
                        if (a+b)%K==0 and (b+c)%K==0 and (c+a)%K==0:
                            ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0

R = N % K

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

print(count)

Submission status: Wrong Answer

Solution code:
from math import ceil

a = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
from math import ceil

a = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
lmnk=(6*N//K)
ans=0
for h in range(lmnk):
    a=h*K//2
    if 1<=a<=N:
        for i in range(1,lmnk):
            b=i*K-a
            if 1<=b<=N:
                for j in range(1,lmnk-i):
                    c=j*K-b
                    if 1<=c<=N:
                        if (a+b)%K==0 and (b+c)%K==0 and (c+a)%K==0:
                            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
l = input().split()
l[0]= int(l[0])
l[1]= int(l[1])
c = 0
for i in range(l[0]):
    for j in range(l[0]):
        for k in range(l[0]):
            if (i+1)+(j+1) % l[1] == 0 and (i+1)+(k+1)%l[1]==0 and (j+1)+(k+1) %l[1]==0:
                c = c + 1
print(c)

Submission status: Wrong Answer

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

else:
    print(int(N/K)**3+(int(N/K)+1)**3)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

ct = 0

u = math.ceil(2*N/K)

def cond_e(a, b, c):
  if a+b-c > 0 and a-b+c > 0 and -a+b+c > 0 and a+b-c <= 2*N/K and a-b+c <= 2*N/K and -a+b+c <= 2*N/K:
    return True
  else:
    return False
  
def cond_o(a, b, c):
  if a+b-c > 0 and a-b+c > 0 and -a+b+c > 0 and a+b-c <= 2*N/K and a-b+c <= 2*N/K and -a+b+c <= 2*N/K and (a+b-c)%2 == 0 and (a-b+c)%2 == 0 and (-a+b+c)%2 == 0:
    return True
  else:
    return False

  
print(u)
for a in range(1,u+1):
  for b in range(1,u+1):
    for c in range(1,u+1):
      if K%2 == 0 and cond_e(a, b, c):
        ct += 1
      elif K%2 != 0 and cond_o(a, b, c):
        ct += 1

print(str(ct))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil

a = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
c = 0
for i in range(1,n+1):
    for j in range(K-2,n+1):
        for k in range(K-2,n+1):
            if (i+j)%K == 0 and (j+k)%K == 0 and (k+i)%K == 0:
                c += 1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nk=input().split()
n=int(nk[0])
k=int(nk[1])
if k==1:
    print(n**3)
elif k==2:
    if n%2==1:
        e=k//2
        o=e+1
        print(e**3+o**3)
    else:
        print(n**3)
else:
    x=n//k
    print(x**3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

q = N // K

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n = N // K
if K % 2 == 0:
    if N % K >= K/2:
        # print("A")
        print((n+1)**3 + n**3)
    else:
        # print("B")
        print((n+1)**3 + n**3)
else:
    # print("C")
    print(n**3)

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

def main():
    N, K = map(int, input().split())
    ans = 0
    for a in range(1, N + 1):
        vals = []
        for i in range(a//K + 1, (a + N)//K + 1):
            vals.append(K * i - a)
        ans += len([1 for comb in itertools.product(vals, repeat=2) if (comb[0] + comb[1]) % K == 0])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    ans = 0
    for a in range(1, N + 1):
        i = (a // K) - 1
        while True:
            i += 1
            b = K * i - a
            if b < a:
                continue
            elif b > N:
                break
            else:
                j = (b // K) - 1
                while True:
                    j += 1
                    c = K * j - b
                    if c < b:
                        continue
                    elif c > N:
                        break
                    elif (a + c) % K == 0:
                        if len(set([a, b, c])) == 1:
                            ans += 1
                        elif len(set([a, b, c])) == 3:
                            ans += 6
                        else:
                            ans += 3
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    ans = 0
    for a in range(1, N + 1):
        i = 0
        while True:
            i += 1
            b = K * i - a
            if b < a:
                continue
            elif b > N:
                break
            else:
                j = 0
                while True:
                    j += 1
                    c = K * j - b
                    if c < b:
                        continue
                    elif c > N:
                        break
                    elif (a + c) % K == 0:
                        if len(set([a, b, c])) == 1:
                            ans += 1
                        elif len(set([a, b, c])) == 3:
                            ans += 6
                        else:
                            ans += 3
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import itertools

N,K = map(int,input().split())
a=[]
b=[]
ans = 0
for i in range(1,N+1):
    a.append(i)
b += itertools.product(a,repeat = 3)

for i in b:
    #print(i[0],i[1],i[2])
    if (i[0]+i[1])%K==0 and (i[1]+i[2])%K==0 and (i[0]+i[2])%K==0:
        ans+=1
#print(a)
#print(b)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N,K = [int(i) for i in input().split()]
N = [i for i in range(1, N + 1)]
X = itertools.combinations_with_replacement(N, 3)

count = 0
for x in X:
    if (x[0] + x[1]) % K == 0:
        if (x[1] + x[2]) % K == 0:
            if (x[2] + x[0]) % K == 0:
                
                if (x[0] == x[1] and x[2] == x[1]):
                    count += 1
                else:
                    count += 3
print(count)