TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
n,k=map(int,input().split())

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


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

if k%2==1:
    print((n//k)**3)
    exit()
ans=0



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

count=0
for i in range(1,n+1):
    if i%k==k//2:
        count+=1
ans+=count**3

print(ans)



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def is calc(N, K):
  count = 0
  for a in range(1, N):
    for b in range(1, N):
      c = N - a - b
      if c > 0:
        if a + b % N == 0 and b + c % N == 0 and a + c % N == 0:
          count += 1
  return count

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

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

N, K = map(int,input().split())
print(int(N/K)**3+[int((N+K/2)/K)**3,0][K%2])

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#!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()


#!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(int((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()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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 == (K/2)]
    print((len(num))**3 + len(half_num)**3)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,k=map(int, input().split())
if k%2==0:
  cnt1=n//k
  cnt2=(n-k//2)//k
  print(cnt1**3+cnt2**3)
else:
  print((n//k)**3)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, K = map(int, input().split())

a = 0
for i in range(1, N):
  if i % K == 0:
    a += 1

b = 0
for i in range(1, N):
  if i % K == K / 2:
    b += 1

ans = a ** 3
if K % 2 == 0:
  ans += b ** 3

print(ans)

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

a = 0
for i in range(1, N):
  if i % K == 0:
    a += 1

b = 0
for i in range(1, N):
  if i % K == K / 2:
    b += 1

ans = a ** 3
if K % 2 == 0:
  ans += b ** 3

print(ans)

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

a = 0
for i in range(1, N+1):
  if i % K == 0:
    a += 1

b = 0
for i in range(1, N+1):
  if i % K == K / 2:
    b += 1

ans = a ** 3
if K % 2 == 0:
  ans += b ** 3

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, K = map(int,input().split())
ans = 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

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

print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

N,K=map(int,input().split())
print((N//K)**3+int(K%2==0)*(N//K+int(N%K>=K/2))**3)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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
		elif R >= r:
			count += (N // K + 1) ** 2
		else:
			count += (N // K) ** 2


print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, k = map(int, input().split())


num = [0 for _ in range(k)]
for i in range(1, n + 1):
    num[i % k] += 1
print(num)
res = 0
for a in range(k):
    b = (k - a) % k
    c = (k - a) % k
    if (b + c) % k != 0:
        continue
    res += num[a] * num[b] * num[c]

print(res)


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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=10**6
def comb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r]
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,k=map(int,input().split())
if k==2:
  print((comb(n//2,3)+comb(n-n//2,3))*6)
else:
  print(comb(n//k,3)*6)

n,k=map(int,input().split())
s=n//k
t=0
if k%2==0:
  t=(n+k//2)//k
print(s*s*s+t*t*t)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    N, K = MI()

    ans = 0
    for a in range(1, N+1):
        b = K - a if K - a > 0 else K
        c = b
        # print(a, b, c)
        if (b + c) % K == 0:
            cnt_b = (N - b) // K + 1
            ans += cnt_b ** 2
    print(ans)

if __name__ == '__main__':
    solve()


import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')
from math import ceil

def solve():
    N, K = MI()

    NmodK = N % K if N % K != 0 else K
    times = ceil(N / K)
    ans = 0
    for a in range(1, K+1):
        b = K - a if K - a > 0 else K
        c = b
        # print(a, b, c)
        if (b + c) % K == 0:
            cnt_b = (N - b) // K + 1
            # print('bbb', cnt_b)
            if a <= NmodK:
                t = times
            else:
                t = times - 1
            # print(cnt_b ** 2, t)
            ans += cnt_b ** 2 * t
    print(ans)



if __name__ == '__main__':
    solve()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
%%test_input https://abc108.contest.atcoder.jp/tasks/abc108_c
N, K = map(int, input().split())
ans = sum(((N + a % K) // K)**2 for a in range(1, N + 1) if (2 * a) % K == 0)
print(ans)

from math import ceil, floor
N, K = map(int, input().split())
r = floor((2 * N) / K)
ans = floor(N / K)**3 if K % 2 == 1 \
    else ceil(r / 2) * (floor((2 * N - K) / (2 * K)) + 1)**2 + floor(r / 2) * floor(N / K)**2
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def d(n,r):
  return factorial(n)//factorial(r)//factorial(n-r)

if N<K:
  print(0)
else:  
  a=N//K
  ans=a
  if K%2==1:
    if a>=2:
      ans+=d(a,2)*6
    if a>=3:
      ans+=a*(a-1)*(a-2)
    print(ans)
  else:    
    if K*a+K//2<=N:
      b=a+1
    if a>=2:
      ans+=d(a,2)*6
      print(ans)
    if a>=3:
      ans+=a*(a-1)*(a-2)
    if b>=2:
      ans+=b+d(b,2)*6
    if b>=3:
      ans+=b*(b-1)*(b-2)

    print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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))



n, k = [int(x) for x in input().split()]
count = 0
a = int(n / k)
count += (a + a * (a-1) * 3 + a * (a-1) * (a-2))
if k % 2 == 0:
    b = int(n / (int(k / 2))) - a
    count += (b + b * (b-1) * 3 + b * (b-1) * (b-2))
print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
31415 9265

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

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

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, K = map(int, input().split())





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

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))




N, K = lr()
exact = N // K
answer = pow(exact, 3)
if K%2 == 0:
    half = N // (K//2) - exact
    answer += pow(half, 3)
print(answer)
# 29

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
n = (2 * N) // K
A = []
for i in range(n + 1):
    A.append(K * i)
A = np.array(A)
A = A[A >= 2]
ans = 0
for i in A:
    for j in range(1,min(i,K+1)):
        if i - j <= K and 2 * j % K == 0:
            ans += 1
print(ans)

import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
n = (2 * N) // K
A = []
for i in range(n + 1):
    A.append(K * i)
A = np.array(A)
A = A[A >= 2]
ans = 0
for i in A:
    for j in range(1,min(i,N+1)):
        if i - j <= N and 2 * j % K == 0:
            a = j
            b = i - j
            if a == b:
                ans += 1
            else:
                ans += 2
print(ans)

import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
ans = 0
def A(x,N,K):
    p = N // K
    q = N % K
    if x == 0:
        x += K
    if x <= q:
        return p + 1
    else:
        return p
for a_mod in range(K):
    b_mod = (K - a_mod) % K
    c_mod = b_mod
    if (b_mod + c_mod) % K == 0:
        ans += A(a_mod,N,K) * A(b_mod,N,K) * A(c_mod,N,K)

print(ans) 

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,k = map(int,input().split())

mm=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)


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

mm=0
for i in range(1,n+1):
    if i%k==0:
        mm+=1
    if i%k==k//2 and k%2==0:
        mm+=1

print(mm**3)


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

mm1=0
mm2=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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()


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


def run(n, k):
    a = 0
    b = 0
    for i in range(n):
        if (i+1) % k == 0:
            a += 1
        elif (i+1) % k == k/2:
            b += 1
    if k % 2 == 1:
        # return (n//k)**3
        return a**3
    else:
        # a = (n//k)**3
        # b = (((n - k/2)//k)+1)**3
        # return a + b
        return (a**3) + (b**3)


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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,K = map(int,input().split())
if K%2==0:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

N,K = map(int,input().split())
if K%2==1:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

N,K = map(int,input().split())
ans = 0
if K%2==1:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

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

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)
    

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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 )

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 )


n, k = map( int, input().split() )
ans = int((n//k)**3)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

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

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

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

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

from collections import Counter

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

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s = input().split()
N = int(s[0])
K = int(s[1])

ans = N // K 

if K % 2 == 0:
  ans = ans + N//(K%2)

print(ans**3 ) 

s = input().split()
N = int(s[0])
K = int(s[1])

ans = N // K 
ans = ans ** 3

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

print(ans+ ans_ev ) 

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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


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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, k = map(int, input().split())


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


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

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

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


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(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))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, k = map(int, input().split())
mod0 = []
mod2 = []
for i in range(1, n + 1):
    if i % k == 0:d i % k == k // 2:
        mod2.append(i)
print(len(mod0) * len(mod0) * len(mod0) + len(mod2) * len(mod2) * len(mod2))


n, k = map(int, input().split())
mod0 = []
mod2 = []
for i in range(1, n + 1):
    if i % k == 0:
        mod0.append(i)
    elif k % 2 == 0 and i % k == k // 2:
        mod2.append(i)
print(len(mod0) * len(mod0) * len(mod0) + len(mod2) * len(mod2) * len(mod2))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math

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

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

import math

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

import math

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

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,k = map(int,input().split())
j=0
m=0
ans = 0
if k % 2 == 1:
    j= n//k
    print('j',j)
    ans=j*j*j

else:
    j=n//k
    m=(n-k//2)//k+1
    print('j',j,'m',m)
    ans=m*m*m+j*j*j
 
print(ans)

n,k = map(int,input().split())
j=0
m=0
ans = 0
if k % 2 == 1:
    j= n//k
    #print('j',j)
    ans=j*j*j

else:
    j=n//k
    m=(n-k//2)//k+1
    #print('j',j,'m',m)
    ans=m*m*m+j*j*j
 
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a,b  = ma()
x = lma()
ans = 10 **18
for i in range(a-b+1):
    a0 = x[i]
    ab = x[i+b-1]
    if ab< 0 :
        ans = min(ans,ab)
    elif a0 <=0 and 0 <= ab:
        ans = min(ans, ab-2*a0, 2*ab-a0)
    else:
        ans = min(ans,ab)
print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

mod = [i for i in range(K, N+1, K)]
ans += len(mod) ** 3

if K % 2 == 0:
    items = [i for i in range(K//2, N+1, K)]
    ans += len(items)

print(ans)


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

mod = [i for i in range(K, N+1, K)]
ans = len(mod) ** 3

if K % 2 == 0:
    items = [i for i in range(K//2, N+1, K)]
    ans += len(items) ** 3

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,k =map(int, input().split())




ans=0
odd=0
even=0


odd=n//k


even=n//(k/2)-odd

if k%2==0:
  ans+=odd**3+even**3
else:
  ans+=odd**3

print(int(ans),even,odd)

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




ans=0
odd=0
even=0


odd=n//k


even=n//(k/2)-odd

if k%2==0:
  ans+=odd**3+even**3
else:
  ans+=odd**3

print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,K = map(int,input().split())
if k % 2 == 1:
    print((n // k) ** 3)
else:
    print((n // k) ** 3 + ((n + k // 2) // k) ** 3)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

print(res)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

import itertools
N,K=map(int,input().split())
L=range(1,N+1)
T=0
for i in itertools.permutations(L, r=3):
  int(a,b,c) for a,b,c in i:
    if a+b%K==0 and b+c%K==0 and c+a%K==0:
      T+=1
print(T) 

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


n,k=map(int,input().split());print((n//k)**3+(k+1)%2*((n-k//2)//k+1)**3)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

count = (N // K)**3

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

print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,K=map(int,input().split())

num=[0]*(N)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)

for a in range(K):
    b=(K-a)%K
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        print(a,b,c)
print(ans)

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

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

for a in range(K):
    b=(K-a)%K
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
        ans=num[a]*num[b]*num[c]
print(ans)

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

num=[0]*(max(N+1,K)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

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

num=[0]*(max(N+1,K))
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, k = map(int, input().split())

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

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

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

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


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

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))



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)



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


N, K = map(int, input().split())
num = {i%K:N//K for i in range(1, K+1)}
mod = N % K
for i in range(1, mod+1):
    num[i] += 1

ans = 0
for i in range(K):
    if (2*i) % K == 0:
        cnt = num[i]
        cnt *= num[(K-i)%K] * num[(K-i)%K]
        ans += cnt
print(ans) 

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,k=map(int,input().split())
print((n//k)**3 if k%2==1 else (n//k)**3+((n-k/2)//k+1)**3)

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,k = map(int,input().split())

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

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

print(count)  

from math import ceil 

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

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

if k % 2 == 0:    
  bb=[]
  tmp = k//2  
  while tmp <= n:
    bb.append(tmp)
    tmp += k      
  s = len(bb)
  count += s + 3*s*(s-1) + s*(s-1)*(s-2)

print(count)  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,K=map(int,input().split())
ans=0
if K%2==1:
  print((N//K)**3)
else:
  ans=(N//K)**3
  k=K//2
  j=0
  for i in range(1,N):
    if i%K==k:
      j+=1
  print(j**3+ans)

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

Verdicts: Wrong Answer

Accepted