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 =[int(i) for i in input().split()]
if K % 2 == 0:
    K_unit1 = int(N//K)
    K_half = K//2
    N_khalf = N-K_half
    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))

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
if K % 2 == 0:
    K_unit1 = int(N/K)
    K_half = K/2
    N_khalf = N-K_half
    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))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


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

    if K % 2 == 0:
        count += (N//K)**3
        # a,b,c == 0 mod K//2
        count += ((N//K)+1)**3
    else:
        count += (N//K)**3
    print(count)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

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

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

N, K = s_inpl()

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

print(ans)

Submission status: Wrong Answer

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

#A
def A():
    return

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

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

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#Timeout
N, K = map(int, input().split())
ans = 0
for a in range(1, N+1):
    p = set()
    r = set()
    # p := bの候補
    for i in range(int((a + 1) / K) + 1, int((N + a) / K) + 1):
        if i * K - a >= 1:
            p |= {i * K - a}
    # pからbを1つ
    # r := cの候補
    for b in p:
        q = set()
        for i in range(int((b + 1) / K) + 1, int((N + b) / K) + 1):
            if i * K - b >= 1:
                q |= {i * K - b}
        r = p & q
        for c in r:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def triangular_relationship(N: int, K: int)->int:
    res = 0
    for g1 in range(max(2//K, 1), N+1):
        update = False
        for g3 in range(g1, N+1):
            for g2 in range(g3, g1+g3):
                if K % 2 != 0 and (g1 + g2 + g3) % 2 != 0:
                    continue
                if - g1 + g2 + g3 > (2*N) // K:
                    continue
                eq = 0
                if g1 - g2 + g3 == g1 + g2 - g3:
                    eq += 1
                if g1 + g2 - g3 == -g1 + g2 + g3:
                    eq += 1

                update = True
                res += 6 // fact(eq+1)
        if not update and res > 0:
            break
    return res


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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
n, k = [int(x) for x in input().split()]
lista = []
listb = []
for i in range(1, n):
    if k % 2 == 0:
        if i % k == 0:
            lista.append(i)
        elif i % k == int(k / 2):
            listb.append(i)
    else:
        if i % k == 0:
            lista.append(i)

a = list(itertools.product(lista, repeat=3))
b = list(itertools.product(listb, repeat=3))
print(len(a) + len(b))

Submission status: Wrong Answer

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

if k == 1:
    print(0)
    sys.exit()
if k > n:
    print(0)
    sys.exit()

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


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

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

Submission status: Wrong Answer

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

if k == 1:
    print(0)
    sys.exit()
if k > n:
    print(0)
    sys.exit()

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


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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m =  n // k

count = m ** 3

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

print(count)

Submission status: Wrong Answer

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

if K == 2:
  o = N // 2 + N % 2
  e = N // 3
  print(o ** 3 + e ** 3)
else:
  if K % 2 == 1:
    n = N // K
    print(n ** 3)
  else:
    k = K
    kk = K 
    n = N // k
    nn = N // kk + 1
    print(n ** 3 + nn ** 3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

g_count = 0
k_count = 0

for i in range(N):
    if i % K == 0:
        g_count += 1
    
    elif i % K == K/2:
        k_count += 1

print(g_count**3 + k_count**3)

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools as t
import numpy as np
N,K = map(int,input().split())
a = [i+1 for i in range(N)]
b= list(t.product(a,repeat=3))
c = [[np.sum(i[0] + i[1]),np.sum(i[1] + i[2]), np.sum(i[2] + i[1])] for i in b]
count = 0
for j in range(len(c)):
    if c[j][0] % K == 0 and c[j][1] % K == 0 and c[j][2] % K== 0:
        count +=1
print(count)

Submission status: Wrong Answer

Solution code:
from itertools import product
n, k = map(int, input().split())

zero = n // k
c = len(list(product(range(zero), repeat=3)))

if k % 2 == 0:
    c += len(list(product(range(n//k+1), repeat=3)))

print(c)

Submission status: Wrong Answer

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

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

else:
    n = N//K

count = n + n*(n-1)*3 + n*(n-1)*(n-2)

print(count)

Submission status: Wrong Answer

Solution code:
import collections
n,k=list(map(int,input().split()))
l_n=[(v+1)%k for v in range(n)]
c = collections.Counter(l_n)
m = len(c)
ret=0
if k%2==0:
    for i in range(0,m,k//2):
        for j in range(0,m,k//2):
            if (i+j)%k==0:
                for r in range(0,m,k//2):
                    if(i+r)%k==0 and(r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
else:
    for i in range(0,m,k):
        for j in range(0,m,k):
            if (i+j)%k==0:
                for r in range(0,m,k):
                    if (i+r)%k ==0 and (r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
print(ret)

Submission status: Wrong Answer

Solution code:
import collections
n,k=list(map(int,input().split()))
l_n=[(v+1)%k for v in range(n)]
c = collections.Counter(l_n)
m = len(c)
ret=0
if k%2==0:
    for i in range(0,m,(int)(k/2)):
        for j in range(0,m,(int)(k/2)):
            if (i+j)%k==0:
                for r in range(0,m,(int)(k/2)):
                    if(i+r)%k==0 and(r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
else:
    for i in range(0,m,k):
        for j in range(0,m,k):
            if (i+j)%k==0:
                for r in range(0,m,k):
                    if (i+r)%k ==0 and (r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = []

for i in range(1, n + 1):
    if k % 2 != 0:
        if i % k == 0:
            a.append(i)
    if k % 2 == 0:
        if i % int(k/2) == 0:
            a.append(i)

e = []
f = []
if k % 2 == 0:
    for j in range(len(a)):
        if a[j] % 2 != 0:
            e.append(a[j])
        if a[j] % 2 == 0:
            f.append(a[j])

if k % 2 != 0:
    print(len(a)**3)

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

Submission status: Wrong Answer

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

count = 0

for i in range(1,N):
    a = i
    for j in range(1,N):
        b = j

        div_ab = (a + b) % K
        if(div_ab !=0):
            continue

        for k in range(1,N):
            c = k

            div_bc = (b + c) % K
            div_ca = (c + a) % K

            if(div_ab ==0 and div_bc ==0 and div_ca ==0):
                count += 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def counter(N, K):
    if K % 2 == 1:
        return (int(N/K))**3
    if K % 2 == 0:
        A = (int(N/K))**3
        B = (int(2*N/K)-1)**3
        return A+B
            
print(counter(N,K))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import itertools
N, K = list(map(int, input().split()))
count = 0
poss = [n for n in range(1, N+1) if (2*n)%K==0]
print(len(poss))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import itertools
N, K = list(map(int, input().split()))
count = 0
poss = [n for n in range(1, N+1) if (2*n)%K==0]
print(len(poss))
poss2 = list(itertools.combinations_with_replacement(poss, 3))
print(poss2)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import itertools
N, K = list(map(int, input().split()))
count = 0
poss = [n for n in range(1, N+1) if (2*n)%K==0]

poss2 = list(itertools.product(poss, repeat=3))

Submission status: Wrong Answer

Solution code:
# C - Triangular Relationship
N, K = list(map(int, input().split()))

count = 0
for a in range(K-2, N-1, 1):
    for b in range(N- a -1):
        c = N - a - b
        if(a+b % K == 0 and a+c % K == 0 and b + c % K ==0):
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# C - Triangular Relationship
N, K = list(map(int, input().split()))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, k = map(int, string.split(" "))
    ans = 0
    """
    for a in range(1, n + 1):
        for b in range(1, n + 1):
            for c in range(1, n + 1):
                if (a + b) % k == 0 and (b + c) % k == 0 and (c + a) % k == 0:
                    ans.append((a, b, c))
    """
    if k % 2 == 1:
        ans = (n // k)**3
    else:
        ans = (n // k)**3 + ((n // k) + 1)**3
    return str(ans)


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

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-N//K)**3)

Submission status: Wrong Answer

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

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

    print ((int(N/K))**3 + (int(cnt))**3)

Submission status: Wrong Answer

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

else:
    tmp = (int(N/K))**3
    m = K / 2
    n = int((N+1) / 2)

    print ((int(N/K))**3 + (int(n/m))**3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ddd = list(map(int, input().split()))
n = ddd[0]
k = ddd[1]
count = 0

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

def main():
	if k % 2 == 1:
		if k > n:
			print(0)
			return
		else:
			div = n // k
			print(div * div * div)
			return
	else:
		kk = k // 2
		div1 = n // k
		div2 = int(n / k - 1 / 2) + 1
		print(div1 * div1 * div1 + div2 * div2 * div2)
		return
			
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc(N, K):
  count = 0
  for a in range(1, N + 1):
    for b in range(1, N + 1):
      for c in range(1, N + 1):
        if (a + b)*(b + c)*(a + c) % K**3 == 0:
            count += 1
  return count

if __name__ == '__main__':
  N, K = map(int, input().split())
  print(calc(N, K))

Submission status: Wrong Answer

Solution code:
def run(n, k):
    if k % 2 == 1:
        return (n//k)**3
    else:
        a = (n//k)**3
        b = (((n - k/2)//k)+1)**3
        return a + b


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


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def run(n, k):
    if k % 2 == 1:
        return (n//k)**3
    else:
        a = (n//k)**3
        b = ((n + k/2)//k)**3
        return a + b


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


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


if __name__ == '__main__':
    main()

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
else:
	cnt=(N/K)**3

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

print cnt

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# N, K = 3, 2

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

    half = []
    for i in range(int(K/2), N+1, int(K/2)):
        half.append(i)
        half = list(set(half) - set(full))
    print(half)
    ans += len(half) ** 3


print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
def main():
	n = list(map(int, input().split()))
	N = n[0]
	K = n[1]
	c = 0
	for i in range(N):
		for j in range(K-i,N):
			if (i + j + 2) % K == 0:
				for k in range(j,N):
					if (j + k + 2) % K == 0 and (k + i + 2) % K == 0:
						if i == j and j == k:
							c1 = 1
						elif i == j or j == k or k == i:
							c1 = 3
						else:
							c1 = 6 
						c += c1
						c1 = 0
	print(c)


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

#x = y = z = n
ans = 0
for a in range(1,n):
    for b in range(1,n):
        for c in range(1,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:
# coding: utf-8
# Your code here!
import copy
N,K=map(int,input().split())
lis=[]
lis2=[]
lis3=[]
ans=0
cnt=0
m=0
for i in range(1,N+1):
    now=i
    count=N-i+1
    while count!=0:
        if (i+now)%K==0:
            lis.append([i,now])
        now+=1
        count=count-1
print(lis)
for j in range(len(lis)):
    for k in range(1,N+1):
        if (lis[j][0]+k)%K==0 and (lis[j][1]+k)%K==0:
            lis2.append(copy.copy(lis[j]))
            lis2[cnt].append(k)
            cnt+=1
print(lis2)
for l in range(len(lis2)):
    lis3.append([lis2[l][0],lis2[l][1],lis2[l][2]])
    lis3.append([lis2[l][0],lis2[l][2],lis2[l][1]])
    lis3.append([lis2[l][1],lis2[l][0],lis2[l][2]])
    lis3.append([lis2[l][1],lis2[l][2],lis2[l][0]])
    lis3.append([lis2[l][2],lis2[l][0],lis2[l][1]])
    lis3.append([lis2[l][2],lis2[l][1],lis2[l][0]])
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
print(lis3)
l_2d_unique = get_unique_list(lis3)

print(len(l_2d_unique))

Submission status: Wrong Answer

Solution code:
N, K = (int(i) for i in input().split())
D = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        A = i + j
        if A % K == 0:
            for j in range(1, N + 1):
                for k in range(1, 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:
n, k = map(int, input().split())
cnt=0
ablist=[]
cl=[]
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:
            cl.append([a,b,c])
for a,b,c in cl:
    if (c+a)%k==0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

end=int(2*N/K)
A=list(it.product(range(1,end+1,1),range(1,end+1,1)))
ans=0
for i in range(len(A)):
    for a in range(max(A[i][1]*K-N,A[i][0]*K-N),min(A[i][0]*K,A[i][1]*K)+1,1):
        b=A[i][0]*K-a
        c=A[i][1]*K-b
        if (a+c)%K==0:
            ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
n_division = 0
# a=b=c
n_division += sum([1 for i in range(1, n+1) if 2 * i % k == 0])
# a=b!=c
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if 2 * i % k == 0 and (i + j) % k == 0:
            n_division += 3 # x 3 patters
# a!=b!=c
for i in range(1, n+1):
    for j in range(i+1, n+1):
        for l in range(j+1, n+1):
            if (i + j) % k == 0 and (j + l) % k == 0 and (l + i) % k == 0:
                n_division += 6 # x 6 patters
print(n_division)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = 0

for a in range(1,N+1):
    for b in range(1,N+1):
        if (a+b) % K !=0:
            continue
        else:
            for c in range(1,N+1):
                if (a+c) % K !=0 | (b+c) % K !=0:
                    continue
                cnt = cnt+1

print(cnt)

Submission status: Wrong Answer

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

for i in range(1,N+1):
    for j in range(K-i,N+1,K):
      if K-j>0:
        for k in range(j,N+1):
            """
            x = (i+j) % K
            y = (j+k) % K
            z = (k+i) % K
            #判定
            if (x+y+z) == 0:
                #重複する数字の数
                if i == j and j == k:
                    counter += 1
                elif (i == j or j == k) or k == i:
                    counter += 3
                else:
                    counter += 6
            """
            if (i+j)%K == 0:
                if (j+k)%K == 0 and (k+i)%K == 0:
                    if i == j and j == k:
                        counter += 1
                    elif (i == j or j == k) or k == i:
                        counter += 3
                    else:
                        counter += 6
print(counter)

Submission status: Wrong Answer

Solution code:
import math
N , K = (int(i) for i in input().split())
count = 0
a = 0
b = 0
c = 0
k_count = int(math.floor(N/K))
if N >= K:
    for i in range(1,K+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*k_count)

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(K%2 == 0):
    cof = 0
    if(same%2 == 0):
        for i in range(same-3, 0, -2):
            cof += 1
            bonus += 6*cof*i  
    else:
        for i in range(same-2, 0, -2):
            cof += 1
            bonus += 6*cof*i
else:
    cof = 0
    if(same%2 == 0):
        for i in range(same-2, 0, -1):
            cof += 1
            bonus += 6*cof*i  
    else:
        for i in range(same-1, 0, -1):
            cof += 1
            bonus += 6*cof*i
        
print(same + bonus)

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
if k % 2 == 0:
  nn = n + k / 2
  num_baisuu = nn // k
  res += num_baisuu ** 3
print(int(res))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
m = (2*n)//k

cnt = 0
for i in range(1, m+1):
    for a in range(1, n):
        b = i*k-a
        if b > n or b < 1:
            continue
        for j in range(1, m+1):
            c = j*k-b
            if c > n or c < 1:
                continue
            if (a+c) % k == 0:
                #print(a, b, c)
                cnt += 1
print(cnt)

Submission status: Wrong Answer

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

target_list = []
for tmp_a in range(1, N + 1):
    for tmp_b in range(1, N + 1):
        for tmp_c in range(1, N + 1):
            target_list.append([tmp_a, tmp_b, tmp_c])

#print(target_list)
#print(len(target_list))

ans_list = []
for l in target_list:
    a = l[0]
    b = l[1]
    c = l[2]

    if (a + b) % K == 0 and (b + c) % K == 0 and (c + a) % K ==0:
        ans_list.append([a, b, c])

#print(ans_list)
print(len(ans_list))

Submission status: Wrong Answer

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

ans = 0
for b in range(1, N + 1):
    if (1 + b) % K != 0: continue
    if b == 1: startC = 2
    else: startC = b
    for c in range(startC, N + 1):
        if (b + c) % K == 0 and (c + 1) % K == 0:
            ans += 3
for i in range(1, N + 1):
    if (i * 2) % K == 0:
        ans += 1
print(ans)