Problem:


Score : 300 points

Problem Statement

Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:

1 \leq x,y,z

x^2 + y^2 + z^2 + xy + yz + zx = n

Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Constraints

All values in input are integers.

1 \leq N \leq 10^4

Input

Input is given from Standard Input in the following format:

N

Output

Print N lines. The i-th line should contain the value f(i).

Sample Input 1

20

Sample Output 1

0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.

For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.

For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.

For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.



Sample input:
20


Sample output:
0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())
s=[]
n=int(N**(0.37))
for a in range (1,n+2):
    for b in range(1,n+2):
        for c in range(1,n+2):
            s.append(a*a+b*b+c*c+a*b+b*c+c*a)
s.sort()

for l in range(1,N+1):
    print(s.count(l))

Submission status: Time Limit Exceeded

Solution code:
# vim: fileencoding=utf-8


def main():
    N = int(input())
    for n in range(1, N + 1):
        ans = 0
        if n <= 5:
            print(ans)
            continue
        for x in range(1, int((N + 1) / 6) + 1):
            tx = x ** 2
            if tx >= n:
                break
            for y in range(1, int((N + 1) / 6) + 1):
                ty = tx + y ** 2 + x * y
                if ty >= n:
                    break
                for z in range(1, int((N + 1) / 6) + 1):
                    t = ty + z ** 2 + y * z + z * x
                    if t == n:
                        ans += 1
                    if t >= n:
                        break
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
from math import *

N = int(input())

for i in range(1, N+1):
    ans = 0
    pro = list(product(range(1, int(sqrt(N))), repeat=3))
    for j in range(len(pro)):
        x = pro[j][0]; y = pro[j][1]; z = pro[j][2]
        if x*x + y*y + z*z + x*y + y*z + z*x == i:
            ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int():
        return int(input())

    def map_int_input():
        return map(int, input())

    MII = map_int_input

    def MII_split():
        return map(int, input().split())

    def MII_to_index():
        return map(to_index, input())

    def MII_split_to_index():
        return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs():
        return list(map(int, input()))

    LII = list_int_inputs

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

    # 2次元リスト化
    def LII_2D(rows_number):
        return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number):
        return [LII_split() for _ in range(rows_number)]

    import math
    def L(x, y, z):
        return int(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

    N = input_int()
    for n in range(1, N + 1):
        ans = 0
        for x in range(1, 100):
            for y in range(x, 100):
                for z in range(y, 100):
                    left = L(x, y, z)
                    if left > n:
                        break
                    elif left == n:
                        if x == y == z:
                            ans += 1
                            break
                        else:
                            ans += 3

                # c = (n - (x * x + y * y + x * y)) / (x + y)
                # b = x + y
                # D = b ** 2 - 4 * c
                # if D >= 0:
                #     z1 = (-b + math.sqrt(D)) / 2
                #     z2 = (-b - math.sqrt(D)) / 2
                #     if z1.is_integer() and z1 >= 1:
                #         ans += 1
                #     if z2.is_integer() and z2 >= 1:
                #         ans += 1

        print(ans)
resolve()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for x in range(1,n+1):
    ans = 0
    found = []
    for i in range(1,33):
        if i in found:
            break
        for j in range(i,33):
            for k in range(j,33):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == x:
                    ans += 3**(len(set([i,j,k]))-1)
                    found.append(i)
                    found.append(j)
                    found.append(k)

                elif x < i**2 + j**2 + k**2 + i*j + j*k + k*i:
                    break
                else:
                    pass
    print (ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
import math
n1=int(math.sqrt(N))
for i in range(1,N+1) :
  count=0
  n1 = int(math.sqrt(i))
  for x in range(1,n1+1) :
    n2 = int(math.sqrt(i-x*x))
    for y in range(1,n2+1) :
      n3 = int(math.sqrt(i - y*y-x*x))
      for z in range(1,n3) :
        if x*x+y*y+z*z+x*y+y*z+z*x==i :
          count+=1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
N = int(input())
 
for n in range(1, N+1):
    count = 0
    for x in range(1, int(sqrt(n))):
        for y in range(1,int(sqrt(n))):
            for z in range(1, int(sqrt(n))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

for i in range(1,n+1):
    ans = 0
    for x in range(1,math.floor(math.sqrt(i))):
        for y in range(x,math.floor(math.sqrt(i))):
            if 4*(x*y+i)-3*(x+y)**2<0:
                continue
            z = (math.sqrt(4*(x*y+i)-3*(x+y)**2)-x-y)/2
            if float.is_integer(z) and z>=y:
                if x==y==z:
                    ans += 1
                elif x==y or y==z or z==x:
                    ans += 3
                else:
                    ans += 6
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
  cnt = 0
  for i in range(int(n**1/2 // 1)):
    for j in range(int((n-i**2)**1/2 // 1)):
      for k in range(int((n-i**2-j**2)**1/2 // 1)):
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n:
          cnt += 1
  return cnt
      
  
N = int(input())
for i in range(N):
  print(f(i+1))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for a in range(n):
  s=0
  for i in range(n):
    if((3*i+3)**2-(3*(i**2)+6*i+3)==a+1):
      s+=1
    for j in range(n-i):
      for k in range(n-i-j):
        if((3*i+3)**2-(3*(i**2)+6*i+3)!=a+1):
          if((i+j+k+3)**2-(i*j+j*k+k*i+2*i+2*j+2*k+3)==a+1):
            s+=1
  print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

nums = [0]*n
m = n//6
for i in range(1,m+1):
  for j in range(i, m+1):
    for k in range(j, m+1):
      t = i**2 + j**2 + k**2 + i*j + j*k + i*k
      if t <= n:
        if i == j and i == k: nums[t-1] += 1
        else: nums[t-1] += 3

print(*nums, sep="\n")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
f = [ i for i in range(1, N + 1)]
for i in f:
  ans = 0
  for x in range(1, i + 1):
    for y in range(1, i + 1):
      for z in range(1, i + 1):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == i:
          ans += 1
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()

    for i in range(1,N+1):
        if i < 3:
            print(0)
        else:
            ans = 0
            x_max = int((i-2)**0.5-1)
            for x in range(1, x_max+1):
                for y in range(x, x_max+2):
                    for z in range(y, i-2):
                        if x*x+y*y+z*z+x*y+y*z+z*x == i:
                            setnum = len(set([x,y,z]))
                            if setnum == 1:
                                ans += 1
                            elif setnum == 2:
                                ans += 3
                            elif setnum == 3:
                                ans += 6
            
            print(ans)


if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())

# 入りうる整数
enter = int(math.sqrt(N))
value_array = []
for x in range(1, enter):
  for y in range(1, enter):
    for z in range(1, enter):
      value_array.append(x**2 + y **2 + z ** 2 + x*y + y*z + z*x)

for i in range(1, N+1):
  print(value_array.count(i))

Submission status: Time Limit Exceeded

Solution code:
#coding: UTF-8
import math
N = int(input())
#print(N)



for i in range(1,N+1):
  if i <=5:
    print(0)
    continue
  cnt = 0
  m = int(math.sqrt(i))
  #平方根までやればよい
  for x in range(1,m):
    for y in range(x,m):
      for z in range(y,m):
        a = (x+y+z)**2 -x*y -y*z - z*x
        if a == i:
          if x==y==z:
            cnt += 1
          elif x==y or y==z:
            cnt += 3
          else:
            cnt += 6
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


for i in range(1,N+1):
  count = 0
  if i < 6:
    print('0')
  elif i == 6:
    print('1')
  else:
    for j in range(1,i):
      for k in range(1,i):
        for l in range(1,i):
          if (j**2+k**2+l**2+j*k+k*l+l*j)==i:
            count+=1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
comb=[]
ans=[]


for k in range(1, n+1):
    flag=False
    for x in range(1, k+1):
        for y in range(x, k+1):
            for z in range(y, k+1):
                if (x+y+z)**2 - x*y-y*z-z*x==k:
                    comb.append((x,y,z))
                    flag=True
                    break
    
    if flag:
        pass
    else:
        comb.append((0, 0, 0))


l=len(comb)

for s in range(l):
    if comb[s][0]==comb[s][1]==comb[s][2]==0:
        ans.append(0)
    elif comb[s][0]==comb[s][1]==comb[s][2]!=0:
        ans.append(1)
    elif comb[s][0]!=comb[s][1] and comb[s][1]!=comb[s][2] and comb[s][2]!=comb[s][0]:
        ans.append(6)
    else:
        ans.append(3)

for i in range(l):
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt as r
from math import ceil
from itertools import combinations as C

N = int(input())

def f(n):
	ans = 0
	for x in range(1, 1+ceil(r(c/3))):
		for y in range(1, 1+ceil(r(c/3))):
			for z in range(1, 1+ceil(r(c/3))):
				if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
					ans += 1
	print(ans)

for c in range(1, N + 1, 1):
	f(c)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
output = []

for n in range(1,N+1):
    cnt = 0
    for x in range(1,45):
        if x**2+2*x+1 > n: break
        for y in range(1,45):
            if x**2+y**2+x*y+y+x > n: break
            for z in range(1,45):
                tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
                if tmp > n: break
                if tmp == n: cnt += 1
    output.append(cnt)

print(*output, sep = "\n")

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1,N+1):
    cnt=0
    t=math.sqrt(i)
    i=int(i)
    for x in range(1,i+1):
        for y in range(1,i+1):
            for z in range(1,i+1):
                if x*x+y*y+z*z+x*y+y*z+z*x==i:
                    cnt+=1
                if x*x+y*y>i:
                    break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

for i in range(N):
  n = i+1
  pair = []
  for x in range(1, int(math.sqrt(N)+1)):
    for y in range(x, int(math.sqrt(N-x**2)+1)):
      for z in reversed(range(y, int(math.sqrt(N-y**2-x**2)+1))):
        if x**2+y**2+z**2+x*y+y*z+z*x == n:
          pair.append((x, y, z))
          break
  ans = 0
  for x, y, z in pair:
    if x == z:
      ans += 1
    elif x == y:
      ans += 3
    elif y == z:
      ans += 3
    else:
      ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())
s=[]
n=int(N**(0.4))
for a in range (1,n+2):
    for b in range(1,n+2):
        for c in range(1,n+2):
            s.append(a*a+b*b+c*c+a*b+b*c+c*a)
s.sort()

for l in range(1,N+1):
    print(s.count(l))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1,n+1):
    ans = 0
    for x in range(1,int(i**0.5+1)):
        for y in range(1,int((i-x**2)**0.5+1)):
            a = (x+y)**2 - 4*(x**2 + y**2 + x*y - i)
            if a >= 0:
                z1 = (a**0.5) -(x+y)
                z2 = -(a**0.5) -(x+y)
                if z1//1 == z1 and z1 > 0:
                    ans += 1
                if z2//1 == z2 and z2 > 0:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(n):
    num = 0
    for x in range(10000):
        for y in range(10000):
            for z in range(10000):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i + 1:
                    num += 1
    print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for i in range(1,N+1):
  count = 0
  if i>5:
    for x in range(1,int((i-2)**0.5-1)+1):
      for y in range(1,int((i-2)**0.5-1)+1):
        for z in range(1,int((i-2)**0.5-1)+1):
          if x**2+y**2+z**2+x*y+y*z+z*x == i:
            count = count+1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
cnt = [0] * n
for i in range(1,n+1):
  l = [i for i in range(1, int(i**0.5)+1)]
  for x, y, z in itertools.product(l, l, l):
    if x**2 + y**2 + z**2 + x*y + y*z + z*x == i: cnt[i-1] += 1
for i in cnt:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[32]:


n = int(input())


# In[33]:


import math
import numpy


# In[35]:


count = 0


# In[36]:


li=[]


# In[37]:


for num in range(1,n+1):
    nnew = math.sqrt(num)
    nnew = math.floor(nnew)
    
    for i in range(1,nnew+1):
        for j in range(1,nnew+1):
            for k in range(1,nnew+1):
                if (i**2 + j**2 + k**2 + i*j + j*k + k*i) == num:
                    count+=1
    li.append(count)
    count = 0


# In[39]:


for i in li:
    print(i)


# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for n in range(1,N+1):
  ans = 0
  check = False
  for x in range(1,n):
    for y in range(x,n):
      for z in range(y,n):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == n:
          if x == y and y == x and z == x:
            ans += 1
          elif x == y  or z == x or y == z:
            ans += 3
          elif x != y and y != z and z != x:
            ans += 6
          check = True
          break
      if check:
        break
    if check:
      break
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
for i in range(1,n+1):
  max = int(math.sqrt(i))
  result = 0
  for x in range(1,max+1):
    max = int(math.sqrt(i - x * x))
    for y in range(1,max+1):
      max = int(math.sqrt(i - x * x - y * y))
      for z in range(1,max+1):
        if x * x + y * y + z * z + x * y + y * z + x * z == i:
          result += 1
  print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())

def func(n):
    if n <= 5:
        return 0
    else:
        cnt = 0
        max = int(math.sqrt(2*n-8))
        for x in range(1, max):
            if x**2 >= n:
                break
            for y in range(1, max):
                if x**2 + y**2 >= n:
                    break
                for z in range(1, max):
                    if x**2 + y**2 + z**2 >= n:
                        break
                    elif (x+y)**2 + (y+z)**2 + (z+x)**2 == 2*n:
                        cnt += 1
        return cnt

for i in range(1, N+1):
    print(func(i))

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

def g(x, y, z):
    g_xyz = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    return g_xyz

N2 = int(N ** (1 /2)) + 1

list_ans = []

for target in range(1, N + 1):
    b = 0
    for x in range(1, N2 + 1):
        for y in range(x, N2 + 1):
            for z in range(y, N2 + 1):
            #   print("x, y, z, g(x, y, z) =", x, y, z, g(x, y, z))
              if g(x, y, z) == target:
                  tmp = ["".join(map(str, v)) for v in itertools.permutations([x, y, z])]
                  a = set(tmp)
                  b = len(a)
    list_ans.append(b)

for i in list_ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range(1, N + 1):
    ans = 0
    for x in range(1, int(pow(n, 0.5))):
        for y in range(1, int(pow(n - x ** 2, 0.5))):
            for z in range(1, int(pow(n - x ** 2 - y ** 2, 0.5))):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for p in range(1,N+1) :
    cnt = 0
    for i in range(1,N) :
        for j in range(1,N) :
            for k in range(1,N) :
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == p  :
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
N = int(sys.stdin.readline())

for i in range(1,N+1):
  ans = 0
  n = math.ceil(math.sqrt(i))
  for j in range(1,n):
    n_sub_j = i - j*j
    if n_sub_j <= 0:
      break
    for k in range(1,n):
      n_sub = n_sub_j - k*(j + k)
      if n_sub <= 0:
        break
      b = j + k
      check = ((b**2 + 4*n_sub) ** (1/2) - b)
      if check % 2 == 0:
        ans +=1
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())

def func_count(i):
    end = int(math.sqrt(i) + 1)
    ans = 0
    for x in range(1, end):
        end2 = int(math.sqrt(i-x*x) + 1)
        for y in range(1, end2):
            end3 = int(math.sqrt(i-x*x-y*y) + 1)
            for z in range(1, end3):
                if i == x*x + y*y + z*z + x*y + y*z + z*x:
                    ans += 1
    return ans

for i in range(1, N+1):
    print(func_count(i))

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
c = 0

for i in range(1,n+1):
    u_limit = math.ceil(math.sqrt(i))
    for j in range(1,u_limit+1):
        for k in range(1,u_limit+1):
            for l in range(1,u_limit+1):
                if (j+k)**2+(k+l)**2+(l+j)**2 == 2*i:
                    c += 1
    print(c)
    c = 0

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    a=n/6

    saidai=int(a**0.5)+20
    answer=0
    for z in range(1,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def eq(x, y, z):
  return x**2 + y**2 + z**2 +x*y + y*z + z*x

def get_score(x, y, z):
  if x == y and y == z:
    score = 1
  elif x == y or y == z or  z == x:
    score = 3
  else:
    score = 6
  return score

for n in range(1, N+1):
  ans = 0
  for i in range(1, int(n/2)):
    if 3*(i**2) <= n:
      for j in range(i, int(n/2)):
        for k in range(j, int(n/2)):
          if eq(i, j, k) == n:
            ans += get_score(i, j, k)
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for m in range(n):
    count = 0
    for i in range(n):
        x = i + 1
        if x * x >= n:
            break
        for j in range(n):
            y = j + 1
            if x * x + y * y >= n:
                break
            for k in range(n):
                z = k + 1
                if x * x + y * y + z * z + x * y + y * z + z * x > m+1:
                    break
                elif x * x + y * y + z * z + x * y + y * z + z * x == m+1:
                    count += 1
                    break
    print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def f(n):
    total = 0
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                if (x + y + z)**2 - (x*y + y*z + x*z) == n:
                    total += 1
    return total

for i in range(1,N+1):
    print(f(i))

Submission status: Time Limit Exceeded

Solution code:
l=[]
n=int(input())
for x in range(1,10**2+1):
    if x**2>n:continue
    for y in range(1,10**2+1):
        if x**2+y**2>n:continue
        for z in range(1,10**2+1):
            if x**2+y**2+z**2>n:continue
            l.append(x**2+y**2+z**2+x*y+y*z+z*x)

for x in range(1,n+1):
    print(l.count(x))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())


for n in range(1, N + 1):
    cnt = 0
    th = int(np.sqrt(n))+1
    for x in range(1, th):
        for y in range(1, th):
            for z in range(1, th):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()

    for i in range(1,N+1):
        if i < 3:
            print(0)
        else:
            ans = 0
            x_max = int((i-2)**0.5-1)
            for x in range(1, x_max+1):
                for y in range(x, i-3):
                    for z in range(y, x_max+2):
                        if x*x+y*y+z*z+x*y+y*z+z*x == i:
                            setnum = len(set([x,y,z]))
                            if setnum == 1:
                                ans += 1
                            elif setnum == 2:
                                ans += 3
                            elif setnum == 3:
                                ans += 6
            
            print(ans)


if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import math



N=int(input())

for i in range(1,N+1):
    ans=0
    if i<=5:
        print(0)
    else:
        ma=int(math.sqrt(i))
        mi=max(1,int(math.sqrt(i)/6))
        for x in range(mi,ma):
            for y in range(x,ma):
                for z in range(y,ma):
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        if x==y and y==z:
                            ans+=1
                        elif x==y or y==z or z==x:
                            ans+=3
                        else:
                            ans+=6
            
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
N = int(input())
n = int(math.sqrt(N/6))+2
atai = []
for num in range(1,n+1):
  atai += [num]
  
xyz = list(itertools.product(atai,repeat = 3))
for num in range(1,N+1):
  count = 0
  test = 0
  for i in range(len(xyz)):
    test = (xyz[i][0]*xyz[i][0]+xyz[i][1]*xyz[i][1]+xyz[i][2]*xyz[i][2]+xyz[i][0]*xyz[i][1]+xyz[i][0]*xyz[i][2]+xyz[i][1]*xyz[i][2])
    if(test == num):
      count += 1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
def main(n):
  x=y=z=1
  ans=0
  
  for _ in range(1, n+1):
    if n>5:
      for i in range(1, int(_**0.5)):
        x=i
        for j in range(1, int(_**0.5)):
          y=j
          for h in range(1, int(_**0.5)):
            z=h
            if x**2+y**2+z**2+x*y+y*z+x*z==_:
              ans += 1
    print(ans)
    ans=0
  
  
n=int(input())
main(n)

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
from math import *

N = int(input())

# print(list(product(range(1,100+1), repeat=3)))

for i in range(1, N+1):
    ans = 0
    pro = list(product(range(1, int(sqrt(N))), repeat=3))
    for j in range(len(pro)):
        # print(pro[j])
        x = pro[j][0]; y = pro[j][1]; z = pro[j][2]
        if x*x + y*y + z*z + x*y + y*z + z*x == i:
            ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n+1):
    ans = 0
    for x in range(1, int(n ** 0.5) + 1):
        for y in range(1, x + 1):
            z = 4*i - 3*x**2 - 3*y**2 - 2*x*y
            if z > 0:
                z = z**0.5
                z1 = int(z) - x - y
                z2 = z1 // 2
                
             
                if int(z) == z and z1 // 2 >= 1 and z1 % 2 == 0 and z2 <= y:
                    if x != y and y != z2:
                        ans += 6
                    elif x == y and y == z2:
                        ans += 1
                    else:
                        ans += 3
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, 41):
        for y in range(1, 41):
            for z in range(1, 41):
                if (x+y+z)**2-x*y-y*z-z*x == i:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

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

N = int(input())

import math
for a in range(1, N+1):
    n = 0
    top = int(math.sqrt(a))+1
    for b in range(1, top):
        for c in range(1, top):
            for d in range(1, top):
                if (b**2) + (c**2) + (d**2) + (b*c) + (c*d) + (d*b) == a:
                    n += 1
    print(n)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1,N+1):
  count = 0
  aa = math.ceil(i**0.5)
  for j in range(1,aa+1):
    for k in range(1,aa+1):
      for l in range(1,aa+1):
        if j**2+k**2+l**2+j*k+j*l+k*l == i:
          count += 1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for p in range(1,N+1) :
    cnt = 0
    for i in range(1,N +1) :
        for j in range(1,N) :
            for k in range(1,N) :
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == p  :
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

cnt = 0
k = []
for i in range(1, n + 1):
    x = 1
    while x ** 2 < n:
        y = 1
        while x ** 2 + y ** 2 < n:
            z = 1
            while x ** 2 + y ** 2 + z ** 2 < n:
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
                    p = [x, y, z]
                    p = sorted(p)
                    s = set(p)

                    if p in k:
                        z += 1
                        continue
                    # print(x, y, z)
                    k.append(p)
                    if len(s) == 1:
                        cnt += 1
                    elif len(s) == 2:
                        cnt += 3
                    else:
                        cnt += 6

                z += 1
            y += 1
        x += 1
    print(cnt)
    cnt = 0
# print(k)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(1, n+1):
    a = 0
    for x in range(1, int(i**(1/2))):
        for y in range(x, int((i-x**2)**(1/2))):
            for z in range(y, int((i-x**2-y**2)**(1/2))):
                if x**2+y**2+z**2+x*y+y*z+z*x == i:
                    if x == y and y == z and z == y:
                        a += 1
                    elif x ==y or y == z or z == y:
                        a += 3
                    else:
                        a += 6
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

initial = (1,1,1)
queue = []
queue.append(initial)
pointer = 0
answers = [0] * (N + 1)
while pointer < len(queue):
    x, y, z = queue[pointer]
    # print(x, y, z)
    q = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if q < N + 1:
        answers[q] += 1
        if x >= y and x >= z:
            queue.append((x + 1, y, z))
        if y >= z:
            queue.append((x, y + 1, z))
        queue.append((x, y, z + 1))
    pointer += 1

        
for a in answers[1:N + 1]:
    print(a)