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:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, k = input_int_list()
    ans = 0
    if k > n:
        print(0)
        return

    if k % 2 == 0:
        # a,b,c == k//2 + p*k を満たすとき
        cnt = ((n - (k // 2)) // k) + 1
        ans += pow(cnt, 3)
    # a,b,c == p*k を満たすとき
    ans += pow(n // k, 3)

    print(ans)

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = pow(n // k, 3, mod)
if k % 2 == 0:
    ans += pow(n // k + (n % k >= k // 2), 3, mod)
print(ans % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = [0] * (n + 1)

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

if k % 2 == 0:
    ans = 0
    ans += cnt[0] * cnt[0] * cnt[0]
    if k // 2 < n:
        ans += cnt[k // 2] * cnt[k // 2] * cnt[k // 2]
    print(ans)
else:
    print(cnt[0] * cnt[0] * cnt[0])

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
if n == 1:
    print(1*(k==3))
    exit()
if k == 1:
    print(n**3)
    exit()

ans = 0
for i in range(n):
    a = i+1
    if 2*(i+1) % k == 0:
        lb = math.floor((a%k)/k)
        if a%k == 0:
            lb = 1
        ub = math.floor((n-a%k)/k)
        # print(a, (a%k)/k, (n-a%k)/k)
        ans += (ub-lb+1)**2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

result=0

if K%2==1:
    #全てKの倍数でないといけない
    result=(N//K)**3
else:
    #全てKの倍数
    result=(N//K)**3

    #またはすべて余りがk/2でなければならない
    if (N//K)*K+2/K<=N:
        result+=(N//K+1)**3
    else:
        result+=(N//K)**3

print(result)

Submission status: Wrong Answer

Solution code:
# 奇数の時
# a，b，cはkの倍数
# kが偶数
# a, b, cがkの倍数
#　もしくは，全てk/2の倍数

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

if K % 2 != 0:
    n = N // K 
    print(n ** 3)

else:
    n = N // K
    half_n = N // (K//2)
    print(half_n)
    print(n ** 3 + (half_n - n)** 3)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    if K == 2:
        odd = 0--N//K
        even = N - odd
        print(odd**3+even**3)
        return
    cnt = 0
    for i in range(1, 2*10**5+1):
        if K*i <= N:
            cnt += 1
        else:
            break
    ans = cnt**3
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if K == 1:
    print(N**3)
    exit()

ans = 0
for k in range(K):
    if (k * 2) % K != 0:
        continue
    M = -(-N // K) - (1 if k == 0 else 0)
    ans += M**3
print(ans)

Submission status: Wrong Answer

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

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

a = n//k
ans += max(0, a*(a-1)*(a-2))
ans += a*(a-1)*3
ans += a


print(ans)

Submission status: Wrong Answer

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

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

ans += (n//k) ** 3
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
c = 0
for i in range(1,K+1):
  for j in range(0,N+1):
    b = i*K + j*K
    if b <= N and (i*K+b)%K == (b+b)%K == 0:
      c = i
      print(c, i*K)
    elif b != 0:
      break
print(c**3)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


def main():
    N, K = MI()
    num_factor_K = N // K
    ret = num_factor_K ** 3
    print(ret)
    
    if K % 2 == 0:
        num_factor_half_K = N // K
        if N % K >= K // 2:
            num_factor_half_K += 1
        ret += num_factor_half_K ** 3
        
    print(ret)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
count=0
num=N//K
count+= num + num*(num-1)*(num-2) + num*(num-1)*3
if K%2==0:
    K=K//2
    num=(N//K)//2+1

    count+= num + num*(num-1)*(num-2) + num*(num-1)*3
print(count)

Submission status: Wrong Answer

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

    if K % 2 != 0:
        ans = (N // K)**3
    else:
        n = N // K
        if (n + 0.5) * K >= N:
            ans = (n + 1)**3 + n**3
        else:
            ans = 2 * n**3

    print(ans)


main()

Submission status: Wrong Answer

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

    if K == 1:
        ans = N**3
    elif K == 2:
        a, b = divmod(N, 2)
        ans = a**3 + (a + b)**3
    else:
        if K % 2 != 0:
            ans = (N // K)**3
        else:
            n = N // K
            if (n + 0.5) * K < N:
                ans = (n + 1)**3 + n**3
            else:
                ans = 2 * n**3

    print(ans)


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int,input().split())
ans = 0
ans += (N//2)**3
if K%2 == 0:
    ans += (math.ceil(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:
    kk=k//2
    cnt=0
    for i in range(1,n+1):
        if i//k==kk:
            cnt+=1
    print((n//k)**3+cnt**3)

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def solve_even(N: int, K: int):
    t = N // (K // 2) // 2
    return pow(t+1, 3) + pow(t, 3)

def solve(N: int, K: int):
    return pow(N // K, 3) if K % 2 else solve_even(N, K)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
#N以下の数でKの倍数の個数
cntMod = N//K
#Kが偶数の時は3つ組としてKで割ったときのあまりが
#(K/2,K/2,0)をとれる
if K%2==0:
    if K*cntMod+(N/(K//2)) <= N:
        cntMid = cntMod + 1
    else:
        cntMid = cntMod
else:
    cntMid = 0
print(cntMid**3+cntMod**3)

Submission status: Wrong Answer

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

ans = pow(n // k, 3)
if k % 2 == 0:
  ans += pow((n + n // 2) // k, 3)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(d,N+1,d):
    for j in range(d,N+1,d):
        for k in range(d,N+1,d):
            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%2==1:
  print((N//K)**3)
else:
  print((N//K)**3 + (((N//2)//K) - (N//K))**3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

cnt = 0
for i in range(1,2*n//k+1):
    if i*k%2 ==1 and k%2 == 1:
        for j in range((i-1)//2):
            a = i*k//2 - (k+2*k*j-1)//2
            if i * k - a <= n:
                cnt += ((a+n)//k - a//k)*2
    elif i*k%2 == 0:
        if k%2 == 0:
            for j in range(i-1):
                a = i * k // 2 - (k + k * j) // 2
                if i*k-a <= n:
                    cnt += ((a + n) // k - a // k) * 2
        cnt += ((i*k//2 + n) // k - (i*k//2) // k)
print(cnt)

Submission status: Wrong Answer

Solution code:

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

cnt = 0
for i in range(1,2*n//k+1):
    if (i*k)%2 == 0:
        x = i*k//2
        cnt += 1  # (x, x, x)
        cnt += ((x+n)//k - x//k -1)*3  # (x, x, y)

print(cnt)

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
abc = [1] * 3
ans = 0

for i in range(N**3):
    if abc[0] != N:
        if (abc[0] + abc[1]) % K == 0 and (abc[1] + abc[2]) % K == 0 and (abc[2] + abc[0]) % K == 0:
            ans += 1
            abc[0] += 1
        else:
            abc[0] += 1
            
    elif abc[0] == N and abc[1] != N:
        if (abc[0] + abc[1]) % K == 0 and (abc[1] + abc[2]) % K == 0 and (abc[2] + abc[0]) % K == 0:
            ans += 1
            abc[1] += 1
        else:
            abc[1] += 1
            
    elif abc[1] == N and abc[2] != N:
        if (abc[0] + abc[1]) % K == 0 and (abc[1] + abc[2]) % K == 0 and (abc[2] + abc[0] )% K == 0:
            ans += 1
            abc[2] += 1
        else:
            abc[2] += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K % 2 != 0:
  a = N // K
  print(a ** 3)
else:
  a = 2 * N // K
  print(math.ceil(N/K) ** 3 + (N//K) ** 3)

Submission status: Wrong Answer

Solution code:
import math
import sys


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    if n % 2 == 1:
        return math.floor(n / k) ** 3
    else:
        return math.floor(n/k) ** 3 + math.floor(n * 3 / 2 / k) ** 3


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

hk = 0

ans = (n//k)**3


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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

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

count=0

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

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(func(N, K))

Submission status: Wrong Answer

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

a = 0
b = 0
c = 0
cnt = 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 & (c + a) % K == 0:
                cnt += 1
            else:
                pass
            

print(cnt)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if b%2 != 0:
  print(pow(a//b,3))
else:
  print(pow(a//b,3)+pow(((a+b//2)//a),3))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if b%2 != 0:
  print(pow(a//b,3))
else:
  print((a//b)**3 + +((a+b//2)//a)**3)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if b%2 != 0:
  print(pow(a//b,3))
else:
  print(pow(a,2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N < K:
    print 0
elif K % 2 == 1:
    print (N / K) ** 3
else:
    x = N / K
    y = (N - 1) / K + (N % K >= K / 2)
    print x ** 3 + y ** 3

Submission status: Wrong Answer

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

if K < 3:
    print 0
elif K % 2 == 1:
    print (N / K) ** 3
else:
    x = N / K
    y = (N - 1) / K + (N % K >= K / 2)
    print x ** 3 + y ** 3

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a=input()
a=a.split(" ")
i=0
w=[x*int(a[1]) for x in range(int(a[0])*2)]
n=int(a[0])

for x in range(1,n+1):
    for y in range(1,n+1):
        for z in range(1,n+1):
            if x+y in w and y+z in w and z+x in w:
                i=i+1
print(i)

Submission status: Wrong Answer

Solution code:
large_n,large_k = [int(x) for x in input().split()]
res_sum = 0
for num_a in range(1, large_n + 1):
	for num_b in range(1, large_n + 1):
		tmp_ab = num_a + num_b
		if large_k > tmp_ab:
			if large_k % tmp_ab != 0:
				continue
		elif tmp_ab % large_k != 0:
			continue

		for num_c in range(1, large_n + 1):
			tmp_bc = num_b + num_c
			if large_k > tmp_bc:
				if large_k % tmp_bc != 0:
					continue
			elif tmp_bc % large_k != 0:
				continue
			
			tmp_ca = num_c + num_a
			if large_k > tmp_ca:
				if large_k % tmp_ca != 0:
					continue
			elif tmp_ca % large_k != 0:
				continue

			res_sum += 1

print(res_sum)

Submission status: Wrong Answer

Solution code:
K,N = list(map(int, input().split()))
MAX = K+N+3
mod = 998244353

fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

rev_m = [1]*(MAX+1)
rev_m[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	rev_m[i-1] = (rev_m[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*rev_m[k]*rev_m[n-k])%mod


def f(n,k,i):
	if i == 2:
		if n < 0 or (k==1 and n>=2): #例外処理
			return 0
		elif n == 0:
			return 1
		else:
			return (Comb(k-2+n,n)+Comb(k-2+n-1,n-1)) % mod
	else: #i>2
		Sp = i//2-1
		ans = 0
		for p in range(Sp+1):
			ans += g(n,k,i,p)
		return ans % mod

def g(n,k,i,p):
	Sp = i//2-1
	if p == 0:
		return f(n-Sp,k-Sp,2) * pow(2,Sp,mod) % mod
	else: #p>0
		return g(n,k-2*p,i-2*p,0) * Comb(Sp,p)

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		tmp = f(N,K,i)
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])

Submission status: Wrong Answer

Solution code:
a, b=map(int, input().split())
try:
    c = a // (b // 2)
    c = c //2 + c% 2
except Exception as  e:
    c = 0
try:
    d = a // b
except Exception as e:
    d = 0
print(c**3 + d**3)

Submission status: Wrong Answer

Solution code:
a, b=map(int, input().split())
try:
    c = a // (b // 2)
    c = c //2 + c% 2
except Exception as  e:
    c = 0
try:
    d = a // b
except Exception as e:
    d = 0
    print(c**3 + d **3)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,N = inpl()
MAX = K+N+10
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

#K=k,N=n,0pair = 0
def calc(k,n,i):
	#i=2に帰着させる
	pairs = (i-2)//2
	k -= pairs
	n -= pairs

	#色々と例外処理
	if n < 0 or k <= 0:
		return 0
	elif k == 1 and n >= 2:
		return 0

	if n == 0: 	 #球が0個なら1通り
		ans = 1
	else:
		ans = 0
		#i=2の時の数え上げ
		for x in range(2):
			ball = n-x	#球
			box = k-1	#箱
			ans += Comb(box-1+ball,ball)%mod

	ans *= pow(2,pairs,mod)	#0pairの選び方
	return ans % mod

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		pairs = (i-2)//2
		tmp = 0
		for p0 in range(pairs+1): #p0 = 0pairの数
			tmp1 = calc(K-p0*2 , N , i-p0*2) %mod #k-2,i-2で0pairが0組
			tmp2 = Comb(pairs,p0) %mod #0pairの選び方
			tmp += tmp1 * tmp2
			tmp %= mod
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,N = inpl()
MAX = K+N+10
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

#K=k,N=n,0pair = 0
def calc(k,n,i):
	#i=2に帰着させる
	pairs = (i-2)//2
	k -= pairs
	n -= pairs

	#色々と例外処理
	if n < 0 or k <= 0:
		return 0
	elif k == 1 and n >= 2:
		return 0

	if n == 0: 	 #球が0個なら1通り
		ans = 1
	else:
		ans = 0
		#i=2の時の数え上げ
		for x in range(2):
			ball = n-x	#球
			box = k-1	#箱
			ans += Comb(box-1+ball,ball)%mod

	ans *= pow(2,pairs,mod)	#0pairの選び方
	return ans % mod

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		pairs = (i-2)//2
		tmp = 0
		for p0 in range(pairs+1): #p0 = 0pairの数
			tmp += calc(K-p0*2 , N , i-p0*2) * Comb(pairs,p0)%mod
			tmp %= mod
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
k = 0
su = 0
for i in range(1,a+1):
	p = b - i
	k = i%b
	if k == 0:
		k = b
	for j in range(k,a+1,b):
		l = a//b
		if a%b <= b-k:
			l += 1
		su += l
print(su)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,k = [int(x) for x in input().split()]

ret = 0
for b in range(1,n+1):
    r = k - b%k
    # print(b,r)
    if r==k:
        # print("|",(n//k)**2)
        ret += (n//k)**2
    elif (2*r)%k==0:
        # print("*", ((n+k-1)//k)**2)
        ret += ((n+k-1)//k)**2
print(ret)

Submission status: Wrong Answer

Solution code:

import math
 
n, k = map(int, input().split())
c = 0
 
if k%2==0:
    if math.floor(2*n/k)%2==0:
        d=math.floor(2*n/k)
        c=2*d*d*d
    else:
        d=(math.floor(2*n/k)+1)
        c=d*d*d+(d-1)*(d-1)*(d-1)
    print(int(c))
else:
    d=math.floor(n/k)
    c=d*d*d
    print(int(c))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,k = [int(x) for x in input().split()]

ret = 0
for b in range(1,n+1):
    r = k - b%k
    # print(b,r)
    if r==k:
        ret += (n//k)**2
    elif (2*r)%k==0:
        # print("*", ((n+k)//k)**2)
        ret += ((n+k)//k)**2
print(ret)

Submission status: Wrong Answer

Solution code:


import math

n, k = map(int, input().split())
c = 0
if (n < k)&(k!=2):
    print(c)
    
elif k%2==0:
    if math.floor(2*n/k)%2==0:
        d=math.floor(2*n/k)
        c=2*d*d*d
    else:
        d=(math.floor(2*n/k)+1)/2
        c=d*d*d+(d-1)*(d-1)*(d-1)
    print(int(c))
else:
    d=math.floor(n/k)
    c=d*d*d
    print(int(c))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

if k%2==0:
    if math.floor(2*n/k)%2==0:
        d=math.floor(2*n/k)
        c=2*d*d*d
    else:
        d=(math.floor(2*n/k)+1)/2
        c=d*d*d+(d-1)*(d-1)*(d-1)
    print(int(c))
else:
    d=math.floor(n/k)
    c=d*d*d
    print(int(c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


nbc=[0]

nbk=[0]*k

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

res=0
for i in range(k):
    if (i+i)%k==0:
        res+=nbk[i]**3

print res

Submission status: Wrong Answer

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

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

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


def main():
    n,k = LI()
    t = n // k
    r = t ** 3
    if k % 2 == 0:
        k //= 2
        tt = n // k
        if tt % 2 == 1:
            r += (t+1) ** 3

    return r


print(main())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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) % k == 0 and (b + c) % k == 0 and (c + a) % k == 0:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import fractions
N,K=map(int,input().split())
def f(x):
  import math
  if x==1:
    if 2%K==0:
      return 1
    else:
      return 0
  elif x==2:
    m=0
    if 4%K==0:
      m+=1
    if K==1:
      m+=6
    return m+f(1)
  else:
    n=0
    if (2*x)%K==0:
      n+=1
    for i in range(1,x):
      if (i+x)%K==0:
        if (2*i)%K==0:
          n+=3
        if (2*x)%K==0:
          n+=3
    for j in range(1,x-1):
      for k in range(j+1,x):
        m=fractions.gcd(j+x,k+x)
        if m%K==0:
          if (fractions.gcd(m,j+k))%K==0:
            n+=6
    return n+f(x-1)
print(f(N))