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:
# from pprint import pprint
# import math
# import collections
from numba import jit

N = int(input())


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

@jit(cache=True)
def calc(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


p = []
p_equal = []
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            if x + y + z > 100:
                break
            #         p.append((x, y, z))
            if x == y == z:
                p_equal.append(calc(x, y, z))
            else:
                p.append(calc(x, y, z))

# print(p)

for i in range(1, N + 1):
    if i in p_equal:
        print(1)
    elif i in p:
        print(3)
    else:
        print(0)

Submission status: Time Limit Exceeded

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

for N in range(1,n+1):
    result = 0
    for x in range(1,int(math.sqrt(N))+1):
        for y in range(1, int(math.sqrt(N-x**2))+1):
            if N-x**2-y**2-x*y < 0:
                break
            else:
                for z in range(1, int(math.sqrt(N-x**2-y**2-x*y))+1):
                    if x**2 + y**2 + z**2 + x*y + y*z + z*x == N:
                        result += 1
                    elif x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
                        break
    print(result)

Submission status: Time Limit Exceeded

Solution code:
#c
import numpy
N = int(input())
cou = 0

for i in range(1,N+1):
    cou = 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:
                    cou += 1
    print(cou)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
import math
def main():
    N = int(input())
    max_x = 100
    max_y = 100
    ans = [0] * N
    for x in range(1, max_x+1):
        for y in range(1, max_y+1):
            for i in range(N):
                a, b = divmod(x**2 + y**2 + x*y - (i+1), -1 * (x+y))
                a = 1
                b = x + y
                c = x**2 + y**2 + x*y - (i+1)
                d = b**2 - 4 * a * c
                if d < 0:
                    continue
                z1 = -1 * (a+b) + math.sqrt(d)
                z2 = -1 * (a+b) - math.sqrt(d)
                if (z1.is_integer() and z1 > 0) or (z2.is_integer() and z2 > 0):
                    ans[i] += 1
    for ni in ans:
        print(ni)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N = ii()
did = 1
while did != N+1:
    mark = math.ceil(sqrt(did))
    count = 0
    for x in range(1,mark):
        if x ** 2 >= did:
            break
        for y in range(1,abs(mark-x)):
            if x ** 2 + y ** 2 + x*y >= did:
                break
            mark2 = math.ceil(sqrt(did-x**2 - y**2 - x*y))
            for z in range(1,min(mark2,abs(mark-(max(x,y))))):
                if x**2 + y ** 2 + z ** 2 + x*y + y*z + z*x == did:
                    count += 1
    print(count)
    did += 1

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
for n in range(1, N+1):
    ans=0
    z_low=int(np.sqrt(n/6))
    z_up=int(np.sqrt(n))
    for z in range(z_low, z_up):
        for y in range(1, z+1):
            for x in range(1, int(np.sqrt(n/6))+1):
                if n == x**2 + y**2 + z**2 + x*z + x*y + y*z:
                    if x==y and x==z:
                        ans+=1
                    elif x==y and x!=z:
                        ans+=3
                    elif y==z and y != x:
                        ans+=3
                    elif z==x and z!=y:
                        ans+=3
                    else:
                        ans+=6
    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,101):
    for y in range(1,101):
      for z in range(1,101):
        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:
N=int(input())
x=y=z=1

for i in range(1, N+1, 1):
    print(len([[x,y,z] for x in range(1,i+1,1) for y in range(1,i-x,1) for z in range(1,i-x-y,1) if x*x+y*y+z*z+x*y+y*z+z*x == i]))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
mat={6:1,11:3,17:3,18:3}

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

def fn(n):
  count=0
  for x in range(1,101):
    for y in range(1,101):
      for z in range(1,101):
        if xyz(x,y,z)==n:
          count+=1
  return count

for i in range(1,N+1):
  mat[i]=fn(i)
  print (mat[i])

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input()) + 1
Nroot = int(math.sqrt(N))
for n in range(1,N):
    count = 0
    if n >= 6:
        for x in range(Nroot-1, int(math.pow(n,1/3))-1 , -1):
            for y in range(x,0,-1):
                for z in range(y,0,-1):
#                    print((x + y + z)**2 - (x*y + y*z + z*x), n,x,y,z)
#                    print(x,y,z)
                    formula = (x + y + z)**2 - (x*y + y*z + z*x)
                    if formula == n:
                        if x == y and y == z:
                            count += 1
                        else:
                            count += 3

        print(count)
    else:
        print("0")

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):
        if 6*x**2 >k:
            continue
        else:
            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:
n=int(input())

for p in range(1, n+1):
  right=45
  cnt=0
  for i in range(1, right):
    for j in range(1, i+1):
      for k in range(1, j+1):
        if (i+j+k)**2-i*j-j*k-k*i==p:
          if i==j and j==k:
            cnt+=1
          elif i==j and j!=k:
            cnt+=3
          elif j==k and k!=i:
            cnt+=3
          elif k==i and i!=j:
            cnt+=3
          elif i!=j and j!=k and k!=i:
            cnt+=6
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
for p in range(1,N+1):
    count = 0
    for i in range(1,p):
        for j in range(1,p):
            for k in range(1,p):
                if (i+j)**2 + (j+k)**2 + (k+i)**2 == 2*p:
                    count += 1
                    
    A.append(count)
    
for q in range(N):
    print(A[q])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def fk(k_):
  fk=0
  x=1
  for x_ in range(N):
    y=1
    for y_ in range(N):
      z=1
      for z_ in range(N):
        if(x**2+y**2+z**2+x*y+y*z+z*x==k_):
          fk+=1
          break
        z+=1
      y+=1
    x+=1
  return fk

k=1
for k_ in range(N):
  print(fk(k))
  k+=1

Submission status: Time Limit Exceeded

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

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,j+1):
      for l in range(1,k+1):
        if j**2+k**2+l**2+j*k+j*l+k*l == i:
          if j == k == l:
            count += 1
          elif j != k != l:
            count += 6
          else:
            count += 3
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

def f(x0,y0,z0):
  return x0**2 + y0**2 + z0**2 + x0*y0 + y0*z0 + z0*x0

n=int(input())

for i in range(1,n+1):
  c=0
  lim=int(math.sqrt(i))
  for x in range(1,lim+1):
    for y in range(1,lim-x+1+1):
      for z in range(1,lim-x-y+1+1):
        ans=f(x,y,z)
        #print(i,x,y,z,ans)
        if ans==i:
          if x==y and y==z:
            c+=1
          elif x==y or y==z or z==x:
            c+=1
          else:
            c+=1
  print(c)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement

n = int(input())

for i in range(1, n+1):
    ans = 0
    for v in combinations_with_replacement(range(1, 60), 3):        
        x, y, z = v
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            if x == y == z:
                ans = 1
            else:
                ans = 3
    print(ans)

Submission status: Time Limit Exceeded

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

# In[23]:


import math
import itertools


# In[25]:


N = int(input())


# In[26]:


for i in range(1,N+1):
#     print("f(%s)"%i)
    ans = 0
    for x in range(1,int(math.sqrt(i))+1):
        if i - x**2 - x > 0:
            for y in range(x,int(math.sqrt(i-x**2-x))+1):
                if i - x**2 - x - y**2 - y - x*y > 0:
                    for z in range(y,int(math.sqrt(i-x**2-x-y**2-y-x*y)+1)):
                        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:
                                ans += 3
                            elif y==z:
                                ans += 3
                            else:
                                ans += 6
    print(ans)


# In[ ]:

Submission status: Time Limit Exceeded

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

j, k, l, wk = 0,0,0,0
for i in range(1, N+1):
    sum = 0
    while True:
        j += 1
        if j >= math.sqrt(i) and j != 1:
            break
        k = 0
        while True:
            k += 1
            if k >= math.sqrt(i) and k != 1:
                break
            l = 0
            while True:
                l += 1
                if l >= math.sqrt(i) and l != 1:
                    break
                if (j**2 + k**2 + l**2 + j*k +k*l + l*j) == i:
                    sum += 1
    j = 0
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
ans = 0
for z in range(1,n+1):
    ans = 0
    if z-5<0:
        print(0)
        continue
    ma = int(math.sqrt(z- 5))
    for i in range(1,ma+1):
        if z-i**2-2*i<0:
            
            break
        ma1 = int(math.sqrt(z-i**2-2*i))
        # if z ==6:
        #     print("koko")
        for j in range(i,ma1+1):
            # if z == 6:
                # print(i,j,"dayp")
            if z-i**2-j**2-i-j<0:
                break
            ma2 = int(math.sqrt(z-i**2-j**2-i-j))
            # if z == 6:
                # print("koko")
            for k in range(j,ma2+1):
                if i**2+j**2+k**2+i*j+j*k+k*i==z:
                    if i==j==k:
                        ans +=1
                    elif  (i==j and j!=k) or (i!=j and j==k):
                        ans +=3
                    elif  (i!=j) and (j!=k):
                        ans +=6
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

memo = {}
for i in range(1,n//3+1):
  for j in range(1,n//3+1-i):
    for k in range(1,n//3+1-i-j):
      key = str(i)+str(j)+str(k)
      memo[key] = i**2+j**2+k**2+i*j+j*k+k*i

val = [num for num in memo.values()]

for i in range(1,n+1):
  print(val.count(i))

Submission status: Time Limit Exceeded

Solution code:
def f(x, y, z):
    return (x+y+z)**2 - x*y - y*z - z*x


N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, int(i**0.5)+2):
        for y in range(1, int(i**0.5)+2):
            if x**2 + y**2 + x*y >= i:
                break
            l = 0
            r = int(i**0.5) + 1
            while r >= l:
                z = (r+l) // 2
                if f(x, y, z) == i:
                    ans += 1
                if f(x, y, z) > i:
                    r = z - 1
                else:
                    l = z + 1

    print(ans)

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):
        thy = int(np.sqrt(n - x ** 2)) + 1
        for y in range(1, thy):
            try:
                thz = int(np.sqrt(n - x ** 2 - y ** 2)) + 1
            except ValueError:
                continue
            for z in range(1, thz):
                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:
n=int(input())

def col(n):
    ans=chk=0
    for i in range(1,n):
        if i**2>=n: break
        for j in range(1,n):
            if j**2>=n: break
            for k in range(1,n):
                if k**2>=n: break
                if i**2+j**2+k**2+i*j+j*k+k*i==n: ans+=1
    return ans
for i in range(1,n+1):
    print(col(i))

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())
s=[]
n=int(N**(0.35399))
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:
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.combinations_with_replacement(atai,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):
      if(xyz[i][0]==xyz[i][1]==xyz[i][2]):
        count += 1
      elif(xyz[i][0]==xyz[i][1]) or (xyz[i][0]==xyz[i][2]) or (xyz[i][1]==xyz[i][2]):
        count += 3
      else:
        count += 6
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
import copy
import itertools
input = sys.stdin.readline

N=int(input())

A=[]
for i in range(70):
    A.append(i+1)

D=list(itertools.combinations_with_replacement(A, 3))
#print(len(D))
for j in range(N):
    count=0
    for sa in D:
    
        if ((sa[0]+sa[1]+sa[2])**2)-(sa[0]*sa[1]+sa[1]*sa[2]+sa[2]*sa[0])==j+1:
            if sa[0]!=sa[1] and sa[1] !=sa[2]:
                
                count+=6
            elif sa[0]==sa[1] and sa[1]==sa[2]:
                count+=1
            else:
                count+=3

    print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

from collections import defaultdict
d = defaultdict(int)

for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      d[i**2+j**2+k**2+i*j+j*k+k*i]+=1

for j in range(1,n+1):
  if d[j]:
    print(d[j])
  else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
#C - XYZ Triplets
N = int(input())
ans = 0
for l in range(N):
    ans = 0
    for i in range(int((l+1)**0.5)):
        for j in range(int((l+1)**0.5)):
            for k in range(int((l+1)**0.5)):
                if (i+1)**2 + (j+1)**2 + (k+1)**2 +(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)== l+1:
                    ans += 1
                    break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = input()


for i in range(1,int(N)+1):
    count = 0
    if i > 3:
        maxa = int(np.sqrt(i-2))
        for x in range(1,maxa):
            for y in range(1,maxa):
                for z in range(1,maxa):
                    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:
N = int(input())

for i in range(1, N+1):
    count = 0
    for x in range (1, i):
        for y in range(1, i):
            for z in range(1, i):
                if x**2 + y**2 + z**2 +x*y + y*z + z*x == i:
                    count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
x=y=z=1

for i in range(1, N+1, 1):
    ans = [[x,y,z] for x in range(1,i+1,1) for y in range(1,i-x,1) for z in range(1,i-x-y,1) if x*x+y*y+z*z+x*y+y*z+z*x == i]
    print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline

def ff(N):
#     print("call ff{0}".format(N))
    if N > 100:
        n = int(np.sqrt(20))+1
    else:
        n = N
    cnt = 0
    for x in range(1, n+1):
        x2 = x**2
        for y in range(1, n+1):
            y2 = y**2
            xy = x * y
            for z in range(1, n+1):
#                 if (N == 6):
#                     print(N, x2, y2, z**2, xy, x*y, y*z)
#                     print(x2 + y2 + z**2 + xy + x*z + y*z)
#                 print(N)
#                 print(x2 + y2 + z**2 + xy + x*z + y*z)
                if N == x2 + y2 + z**2 + xy + x*z + y*z:
                    cnt += 1
#                 if (N == 6):
#                     print(cnt)
#     print(cnt)
    return(cnt)    

N = int(input())    
n = int(np.sqrt(20))+1
for i in range(1, N+1):
#     ff(i)
     print(ff(i))

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
c=[]
for i in range(1,a//2):
    for j in range(1,a//2):
        for k in range(1,a//2):
            c.append((i**2)+(j**2)+(k**2)+i*k+i*j+k*j)
for w in range(1,a+1):
    total=0
    for i in c:
        if i==w:
            total+=1
    print(total)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def triplets(n):
    ans=0
    for x in range(1,n//3):
        for y in range(1,n//3):
            for z in range(1,n//3):
                if x**2 + y**2 + z**2 + x*y + y*z + x*z == i:
                    ans+=1
    print(ans)
for i in range(1,n+1):
    triplets(i)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt

def func(num):
    for i in range(2, lim_n+1):
        for j in range(2, i+1):
            for k in range(2, j+1):
                if i**2 + j ** 2 + k ** 2 == 2 * num:
                    if (j + k) - i != 0 and ((j + k) - i) % 2 == 0:
                        if i == j and j == k:
                            if i  % 2 ==1:
                                break
                            return 1
                        elif i != j and j != k:
                            return 6
                        else:
                            return 3
    return 0

n = int(input())
lim_n = int(sqrt(n))
for i in range(1, n+1):
    print(func(i))

Submission status: Time Limit Exceeded

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

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):
        if 6*x**2 >n:
            continue
        else:
            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:
#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):
    if i - x**2 <= 4:
      continue
    for y in range(x,m):
      if i - x**2 -y**2 <= 3:
        continue
      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:
import math
n=int(input())
z=0
ans=0
for N in range(1,n+1):
    ans=0
    z=0
    for x in range(1,100):
        if x**2+x+x>=N:
            break
        for y in range(1,100):
            if x**2+y**2+x*y+x+y>=N:
                break
            if (x+y)**2+4*N-4*(x**2+y**2)-4*x*y>=0:
                z=((-x-y)+math.sqrt((x+y)**2+4*N-4*(x**2+y**2)-4*x*y))/2
                #print(x,y,z)
                if z>=1 and z%1==0:
                    ans+=1
                    #print(x,y,z)
    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(i+1):
      for k in range(j+1):
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n and i==j==k:
          cnt += 1
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n and i==j and i!=k:
          cnt += 3
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n and j==k and j!=i:
          cnt += 3
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n and k==i and k!=j:
          cnt += 3
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n and i!=j!=k:
          cnt += 6
  return cnt
      
  
N = int(input())
for i in range(N):
  print(f(i+1))

Submission status: Time Limit Exceeded

Solution code:
def INT():
    return int(input())

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

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

N = INT()
ans = [0] * N

def fn(x, y, z):
    f = x**2 + y**2 + z**2 + x * y + y * z + z * x
    return f

for n in range(1, N + 1):
    for x in range(1, int(N ** 0.5) + 1):
        for y in range(1, int(N ** 0.5) + 1):
            if fn(x, y, 1) > n:
                continue
            for z in range(1, int(N ** 0.5) + 1):
                f = fn(x, y, z)
                if f == n:
                    ans[f - 1] += 1

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement
N = int(input())
choise = [1]
for i in range(1,N+1):
    if i > (choise[-1]*6):
        choise.append(choise[-1]+1)
    tmp = 0
    for j in combinations_with_replacement(choise,3):
        n = j[0]**2+j[1]**2+j[2]**2+j[0]*j[1]+j[1]*j[2]+j[0]*j[2]
        if n == i:
            if j[0]==j[1] and j[1]==j[2]:
                tmp+=1
            else:
                tmp+=3
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import numpy as np
#max=int(np.sqrt(N))
for n in range(1,N+1):
    j=0
    max = int(np.sqrt(n))
    for x in range(1,max):
        for y in range(1, max):
            for z in range(1, max):
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    #print(x, y, z)
                    #print(f'n:{n}')
                    j+=1
    print(j)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def fk(k_):
  fk=0
  x=1
  for x_ in range(N):
    y=1
    for y_ in range(N):
      z=1
      for z_ in range(N):
        if(x**2+y**2+z**2+x*y+y*z+z*x==k_):
          fk+=1
        z+=1
      y+=1
    x+=1
  return fk

k=1
for k_ in range(N):
  print(fk(k))
  k+=1

Submission status: Time Limit Exceeded

Solution code:
def function(N):
    for n in range(1, N+1):
        if n < 6:
            print(0)
        else:
            number = 0
            for x in range(1, n-4):
                for y in range(x, n-4):
                    for z in range(y, n-4):
                        if int((x+y)**2+(y+z)**2+(z+x)**2) == 2*n:
                            if x == y & y == z:
                                number += 1
                            else:
                                number += 3

            print(number)


if __name__ == '__main__':
    N = int(input())
    function(N)