output_description: 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.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
attempt: # 108c
  import math
  
  N, K = map(int, input().split())
  
  # a+b,b+c,c+a がすべて K の倍数
  
  # TLEする。
  # ans = 0
  #
  # for a in range(1,N+1):
  #    if K>a:
  #        base = K-a
  #    else:
  #        base = K*int(1+a/K)-a
  #
  #    b_list = [base+i*K for i in range(0,1+math.floor((N-base)/K))]
  #
  #    for b in b_list:
  #        if K > b:
  #            base = K-b
  #        else:
  #            base = K*int(1+b/K)-b
  #
  #        c_list = [base+i*K for i in range(0,1+math.floor((N-base)/K))]
  #
  #        for c in c_list:
  #            if (a+c)%K == 0:
  #                ans += 1
  #                print(a,b,c,":",a/K,b/K,c/K)
  #
  # print(ans)
  
  # 上ので試してみた結果
  # …K%2 = 0なら a,b,cは全てが K/2の奇数の倍数(1,3,5...) or Kの整数倍
  # ex
  # 31415 9266
  # 4633 4633 4633 : 0.5 0.5 0.5
  # 4633 4633 13899 : 0.5 0.5 1.5
  # 9266 9266 9266 : 1.0 1.0 1.0
  # 9266 9266 18532 : 1.0 1.0 2.0
  # 9266 9266 27798 : 1.0 1.0 3.0
  
  # …K%2 = 1なら Kの整数倍
  
  if K == 1:
      # すべてのa,b,cがOK
      print(N * N * N)
  
  elif K % 2 == 0:
      # K/2の奇数の倍数(1,3,5...) と Kの整数倍
      print([int(i * K / 2) for i in range(1, 1 + 2 * math.floor(N / K)) if i % 2 == 1])
      ans = (
          len([int(i * K / 2) for i in range(1, 1 + 2 * math.floor(N / K)) if i % 2 == 1])
          ** 3
      )
      print([i * K for i in range(1, 1 + math.floor(N / K))])
      ans += math.floor(N / K) ** 3
      print(ans)
  elif K % 2 == 1:
      print([i * K for i in range(1, 1 + math.floor(N / K))])
      print((math.floor(N / K) ** 3))
  
problem_description: 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.
samples: [{"input": "3 2", "output": "9\n    \n\n(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)\nsatisfy the condition.\n\n* * *"}, {"input": "5 3", "output": "1\n    \n\n* * *"}, {"input": "31415 9265", "output": "27\n    \n\n* * *"}, {"input": "35897 932", "output": "114191"}]