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

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

for i in range(1,n+1):
    ans=0
    for x in range(1,i+1):
        for y in range(1,i+1):
            if x*y >= i:
                break
            else:
                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:
n=int(input())
from math import sqrt
for k in range(1,n+1):

    ans=0
    p=int(sqrt(k))
    for x in range(1,p+1):
        l=k-x**2
        if l<=0:
            continue

        for y in range(1,int(sqrt(k-x**2)) + 1 ):
            m=k-x**2 - y**2 -x*y
            if m<=0:
                continue
            for z in range(1,int(sqrt(m))+1):
                if z*(z+x+y)==m:
                    ans+=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools

N=int(input())

n=math.floor(math.sqrt(N))
l=list(itertools.product(range(n+1),repeat=3))

for n in range(1,N+1):
    ans=0
    for i in range(len(l)):
        x=int(l[i][0])+1
        y=int(l[i][1])+1
        z=int(l[i][2])+1
        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 n in range(1,N+1):
  count = 0
  for x in range(1,int(n**.5)):
    for y in range(1,int(n**.5)-x+1):
      for z in range(1,int(n**.5)-x-y+2):
        if (x**2+y**2+z**2+x*y+y*z+z*x)/n == 1:
          count += 1
          #print("x,y,z:{0},{1},{2}".format(x,y,z))
  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 z in range(1, int(sqrt(n))):
        for y in range(1,z+1):
            for x in range(1, y+1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if len(set([x, y, z])) == 3:
                        count += 6
                    elif len(set([x, y, z])) == 2:
                        count += 3
                    elif len(set([x, y, z])) == 1:
                        count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
ans=list()
for i in range(1,N+1):
    tmp=0
    tgt=int(math.sqrt(i/2)+1)
    ##print('a',tgt)
    for j in range(1,tgt):
        for k in range(j,tgt):
            for h in range(k,tgt):
                if h**2+j**2+k**2+h*j+j*k+k*h==i:
                    if j==k==h:
                        tmp+=1
                    elif j==k or k ==h:
                        tmp+=3
                    else:
                        tmp+=6
    ans.append(tmp)
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for n_ in range(1,n+1):
  c=0
  for x in range(1,41):
    if n_-x**2>=0:
      y_=(n_-x**2)**(1/2)
      y_=int(y_)
    else:
      break
    for y in range(x,y_+1):
      if n_-x**2-y**2>=0:
         z_=(n_-x**2-y**2)**(1/2)
         z_=int(z_)
      else:
        break
      for z in range(y,z_+1):
        if (x+y)**2+(y+z)**2+(z+x)**2==2*n_:
          if x==y and y==z:
            c+=1	
          elif len({x,y,z})==2:
            c+=3
          else:
            c+=6
  print(c)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

def func(i):
    j = math.ceil(math.sqrt(i))
    cache = np.zeros([j, j, j], dtype=int)
    for x in range(1, j + 1):
        for y in range(1, max(1, j - x + 1)):
            for z in range(1, max(1, j - x - y + 1)):
                if cache[z, y, x] != 0:
                    cache[x, y, z] = cache[z, y, x]
                if cache[z, x, y] != 0:
                    cache[x, y, z] = cache[z, x, y]
                else:
                    cache[x, y, z] = calc(x, y, z)
    return cache


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

def resolve():
    N = int(input())
    cache = func(N)
    for i in range(1, N+1):
        print(np.count_nonzero(cache == i))

resolve()

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools

n = int(input())
for i in range(n):
  high_lim = int(math.sqrt(i+1)//1) + 1

  l1 = [i for i in range(1, high_lim)]
  l2 = [i for i in range(1, high_lim)]
  l3 = [i for i in range(1, high_lim)]

  p = itertools.product(l1, l2, l3)

  result = 0
  for pair in [pair for pair in p]:
    if pair[0]**2 + pair[1]**2 + pair[2]**2 + pair[0]*pair[1] + pair[1]*pair[2] + pair[0]*pair[2] == i + 1:
      result += 1
  print(result)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())

    for i in range(N):
        result = []
        for x in range(i):
            for y in range(i - x):
                for z in range(i - x - y):
                    value = func(x + 1, y + 1, z + 1)
                    if (value == (i + 1)):
                        result.append(value)

        print(len(result))



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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def f(n):
    flag = False
    #total = 0
    ans = 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
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
    if x == 99:
        ans = 0
    elif x == y and  y== z:
        ans = 1
    elif x == y or y == z or x == z:
        ans = 3
    else:
        ans = 6
    return ans

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

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt

def func(num):
    if num < 6:
        return 0
    for i in range(2, lim_n+1):
        for j in range(2, i+1):
            for k in range(2, j+1):
                p = i**2 + j ** 2 + k ** 2
                if p > 2 * num:
                    break
                elif p == 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:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n = int(input())

    l = []
    for i in range(1, math.floor(math.sqrt(n))):
        l.append(i)

    l_list = list(itertools.combinations_with_replacement(l, 3))

    ans_list = []
    for j in range(len(l_list)):
        x = l_list[j][0]
        y = l_list[j][1]
        z = l_list[j][2]
        ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
        ans_list.append((ans, [x, y, z]))

    for i in range(1, n+1):
        count = 0
        for j in range(len(ans_list)):
            if ans_list[j][0] == i and ans_list[j][1][0] == ans_list[j][1][1]and ans_list[j][1][2] == ans_list[j][1][1]:
                count += 1
            elif ans_list[j][0] == i:
                count += 3

        print(count)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

# In[68]:


n = int(input())


# In[69]:


import math
import numpy
import itertools


# In[70]:


count = 0


# In[71]:


li=[]


# In[72]:


for num in range(1,n+1):
    nnew = math.sqrt(num)
    nnew = math.floor(nnew)
    for x, y,z in itertools.product(range(1,nnew+1), range(1,nnew+1), range(1,nnew+1)):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == num:
            count+=1
    """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[73]:


for i in li:
    print(i)


# In[ ]:





# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

x,y,z = 1,1,1

ans = [0] * n

for z in range(1,n+1):
    pp = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                if ((i**2)+(j**2)+(k**2)+(i*j)+(j*k)+(k*i)) == z:
                    pp += 1
    ans[z-1] = pp         
    
print(*ans, sep = "\n")

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
nn = math.ceil(math.sqrt(N))

for n in range(1, N+1):
    c = 0
    for x in range(1, nn):
        for y in range(1, nn):
            for z in range(1, nn):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    c = c+1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
""" C
    https://atcoder.jp/contests/aising2020/tasks/aising2020_c
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N):
    for n in range(1, N+1):
        count = 0
        maxi = int(math.sqrt(N))
        x = 1
        for x in range(1, maxi):
            for y in range(1, maxi):
                # z^2 + (x + y) * z = n - pow(x, 2) - pow(y, 2) - x * y
                # z^2 + 2 * z = 3
                a = n - pow(x, 2) - pow(y, 2) - x * y
                z = 0
                for z in range(1, maxi):
                    if pow(z, 2) + (x+y)*z == a:
                        count += 1
                    z += 1
                y += 1
            x += 1
        print(count)

if __name__ == "__main__":
    _N = readInteger()

    main(_N)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,10):
    for y in range(1,10):
      for x in range(1,10):
        if x**2+y**2+z**2+z*y+z*x+y*x==i:
          co+=1
  return co
for i in range(1,n+1):
  co=f(i)
  print(co)

Submission status: Time Limit Exceeded

Solution code:
x,y,z = 1,1,1
import math
import itertools
lar_num = int(input())
answer = 0
linum = 0
#最小でn=6で存在
for i in range(1,lar_num + 1):
    if i < 6:
        answer = 0
        print(answer)
    else:
        maxnum = math.ceil(-1+(i-2)**0.5)
        for x in range(1,maxnum+1):
            for y in range(1,x+1):
                for z in range(1,y+1):
                    if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                        if x == y:
                            if x == z:
                                linum = 1
                            else:
                                linum = 3
                        elif y == z:
                            linum = 3
                        elif z == x:
                            linum = 3
                        else:
                            linum = 6
                        answer += linum
        linum = 0
        print(answer)
        answer = 0

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(1, n+1):
    count = 0
    x = 1
    while (x+1)**2 <= i-2:
        y = 1
        while x**2 + y**2 + x*y + x + y <= i-1:
            z = 1
            while x**2 + y**2 + z**2 +x*y + y*z + z*x <= i:
                if x**2 + y**2 + z**2 +x*y + y*z + z*x == i:
                    count += 1
                    break
                else:
                    z += 1
            y += 1
        x += 1
    print(count)

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

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

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

list_ans = []

for target in range(1, N + 1):
    # print(f"\n---- target = {target} ----")
    N2 = int(target ** (1 /2) / 2) + 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:
                #   print("  -> OK!")
                  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())
comb=[]
ans=[]


for k in range(1, n+1):
    flag=False
    for x in range(1, k+1):
        if 6*x**2 >k:
            break
        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:
import math as m
N=int(input())
for n in range(1,N+1):
    if n>5:
        xmax=int(m.sqrt(n-5))
        ans=0
        for x in range(1,xmax+1):
            for y in range(1,x+1):
                D=4*n-3*(x**2+y**2)-2*x*y
                if D>=0 and m.sqrt(D)-(x+y)>1 and m.sqrt(D).is_integer():
                    z=int((-(x+y)+m.sqrt(D))/2)
                    if z<=y:
                        #if x**2+y**2+z**2+x*y+y*z+z*y==n:
                        #print('n=',n,[x,y,z])
                        if len(list(set([x,y,z])))==3:
                            ans+=6
                        elif len(list(set([x,y,z])))==2:
                            ans+=3
                        elif len(list(set([x,y,z])))==1:
                            ans+=1
    else:
        ans=0
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
def sq(n):
    c=0
    A=[0 for j in range(n+1)]
    for i in range(n//2):
        p=(i+1)**2
        if p>n:
            for j in range(i**2,n+1):
                A[j]=i
            break
        else:
            for j in range(i**2,p):
                A[j]=i
    return A
A=sq(N)[0:N+1]
for n in range(1,N+1):
    c=0
    for x in range(1,A[n]):
        p=n-x**2
        if p<0:
            break
        else:
            for y in range(1,A[p]):
                q=n-x**2-y**2
                if q<0:
                    break
                else:
                    for z in range(1,A[n-x**2-y**2]):
                        if n==x**2+y**2+z**2+x*y+y*z+z*x:
                            c=c+1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
def  XYZTriplets():

    num = int(input())
    
    for i in range(num):
        count = 0

        x = 1
        y = 1
        z = 1

        flag = True
        
        while flag == True:
            
            function = 0.5*( (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x) ) - i
                        
            if function == 0:
                if x == y and y == z and z == x:
                    count = count + 1
                
                else:
                    count = count + 3
            
                list_xyz = [x, y, z]
            
                if list_xyz.index(max(list_xyz)) == 0:
                    x = x + 1
                elif list_xyz.index(max(list_xyz)) == 1:
                    y = y + 1
                else:
                    z = z + 1
            
            if function > 0:
                print(count)
        
                break



if __name__ == '__main__':
    XYZTriplets()

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations, combinations_with_replacement
from math import sqrt


n = int(input())
ans = [0] * (n + 1)
for x, y, z in combinations_with_replacement(range(1, int(sqrt(n)) + n // 10), 3):
    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if i <= n:
        if x == y == z:
            ans[i] += 1
        elif all([not(s != t) for s, t in combinations([x, y, z], 2)]):
            ans[i] += 6
        else:
            ans[i] += 3

for i in range(1, n + 1):
    print(ans[i])

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+100):
      break
    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:
N=int(input())

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*x,1) for z in range(1,i-x*x-y*y-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())
l=[]
for i in range(500):
  l.append(i**2)
l=set(l)
for i in range(1,n+1):
  ct=0
  for j1 in range(1,int(n**0.5)+2):
    for j2 in range(1,int(n**0.5)+2):
      a=j1+j2
      b=i-j1**2-j2**2-j1*j2
      for k in range(len(l)):
        if a**2+4*b in l:
          k=int((a**2+4*b)**0.5)
          if (a+k)%2==0:
            j3=(-a+k)//2
            if j3>0:
              ct+=1
              break
  print(ct)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range(1,N+1,1):
  flag = False
  count=0
  for x in range(1,10**2+1,1):
    for y in range(1,n//x,1):
      for z in range(1,n-x**2-y**2,1):
        if n == x**2+y**2+z**2+x*y+y*z+z*x:
          count+=1
        if n<x**2+y**2+z**2+x*y+y*z+z*x:
          flag = True
          continue
      if flag:
        continue
    if flag:
      continue
  print(count)

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
            break
            
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

memo = {}
for i in range(1,n//4+1):
  for j in range(1,n//4+1-i):
    for k in range(1,n//4+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:
# 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):
        if x + y > 100:
            break
        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())
ans=list()
for i in range(1,N+1):
    tmp=0
    tgt=int(math.sqrt(i)+1)
    ##print('a',tgt)
    for j in range(1,tgt):
        for k in range(j,tgt):
            for h in range(k,tgt):
                if h**2+j**2+k**2+h*j+j*k+k*h==i:
                    if j==k==h:
                        tmp+=1
                    elif j==k or k ==h:
                        tmp+=3
                    else:
                        tmp+=6
    ans.append(tmp)
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())

last = 1

for i in range(1, n+1):
    tmp = 0
    for j in itertools.combinations_with_replacement(range(1, max(last, 3)), 3):
        x, y, z = j
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            if x == y == z:
                tmp += 1
            elif x != y != z:
                tmp += 6
            else:
                tmp += 3
    print(tmp)
    if tmp != 0:
        last += 1

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 - x * y)) + 1
            except ValueError:
                break
            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())
for i in range(1,N+1):
  count=0
  k=i//5+1
  for x in range(k):
    if(x==0):
      continue
    for y in range(k):
      if(y==0):
        continue
      for z in range(k):
        if(z==0):
          continue
        if((x+y)**2+(y+z)**2+(z+x)**2)//2==i:
          #print(x,y,z)
          #print(i)
          count+=1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def has_z(n: int, x: int, y: int) -> bool:
    """
    条件を満たすzが存在するかどうか確認する.

    Args:\n
        n (int): 整数
        x (int): 整数
        y (int): 整数

    Returns:\n
        bool: 条件を満たすzが存在すれば真、しなければ偽
    """
    d = 4 * n - 3 * x**2 - 3 * y**2 - 2 * x * y
    if d < 0:
        return False
    z = (-(x + y) + math.sqrt(d)) / 2
    return (z.is_integer()) and (z >= 1)


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数（1 <= N <= 10^4）
    """
    for n in range(1, N + 1):
        ans = 0
        max_v = int(math.sqrt(n))
        for x in range(1, max_v + 1):
            for y in range(x, max_v + 1):
                if has_z(n, x, y):
                    ans += 1 + (x != y)
        print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)

Submission status: Time Limit Exceeded

Solution code:
import math



N=int(input())

anslist=[]
for i in range(1,N+1):
    ans=0
    if i<=5:
        print(ans)
    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:
                        continue
                    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:
def func(n):
    cnt = 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 == n:
                    cnt += 1
    return(cnt)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n=int(input())
    for i in range(n):
        i+=1
        cnt=0
        x=1
        y=1
        z=1
        while x<=i:
            if x > i: break
            while y<=i:
                if y > i: break
                while z<=i:
                    v=x**2+y**2+z**2+x*y+y*z+x*z
                    if v < i:
                        z+=1
                        continue
                    elif v == i:
                        cnt+=1
                        break
                    else:
                        break
                y+=1
                z=1
            x+=1
            y=1
            z=1
        print(cnt)
    return

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(1, n+1):
    cnt = 0
    for x in range(1, 35):
        for y in range(1, 35):
            for z in range(1, 35):
                n = x*x + y*y + z*z + x*y + y*z + z*x
                if i == n:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())

def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    D = b**2 - 4*a*c
    if D < 0:
        return 0, 0
    x_1 = (-b + D**(1/2)) / (2 * a)
    x_2 = (-b - D**(1/2)) / (2 * a)
    if D == 0:
        return x_1, 0
    if D > 0:
        return x_1, x_2

for i in range(1,n+1): #Nを繰り返す
    ans = 0
    for j in range(1,i): # x
        for k in range(1,i): # y → 決め打ち
            x1, x2 = solv_quadratic_equation(1, j+k, j**2 + k**2 + j*k -i) #2次方程式を解く
            if x1 > 0 and math.isclose(x1, Decimal(str(x1)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)):
                ans += 1
                #print(i,j,k,x1)
            if x2 > 0 and math.isclose(x2, Decimal(str(x2)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)):
                ans += 1
                #print(i,j,k,x2)
    print(ans)

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):
                p = i**2 + j ** 2 + k ** 2
                if p > 2 * num:
                    break
                elif p == 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())

def calc(n):
  ret = 0
  if n < 6:
    return 0
  else:
    for x in range(1,n):
      for y in range(1,n):
        for z in range(1,n):
          if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
            ret += 1
    
    return ret

for i in range(N):
  print(calc(i+1))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

lis = []

for k in range(1,101):
    for l in range(1,101):
        for m in range(1,101):
            lis.append(k ** 2 + l ** 2 + m ** 2 + k * l + l * m + m * k)

for p in range(1, n + 1):
    print(lis.count(p))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(1, n+1):
    cnt = 0
    for x in range(1, n+1):
        if x**2 >= i:
            break
        for y in range(1, n+1):
            if y**2 >= i:
                break
            for z in range(1, n+1):
                if z**2 >= i:
                    break
                elif x**2 + y**2 + 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())
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:
a = int(input())
x = 1
y = 1
z = 1
listN = []
while x<=98:
    y =1
    z =1
    while y<=98:
        z = 1
        while z<=98:
            ans = x**2+y**2+z**2+x*y+y*z+z*x
            if ans<=10000:
                listN.append(ans)
                z = z+1
            else:
                break
        y = y+1
    x = x+1
n = 1
while n<=a:
    print(listN.count(n))
    n = n+1

Submission status: Time Limit Exceeded

Solution code:
for i in range(1, 1 + int(input())):

  result = 0

  for x in range(1, 32):
    for y in range(1, 32):
      for z in range(1, 32):

        if i < z ** 2 or i < y ** 2 or i < x ** 2:
          break

        subtotal = (x**2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

        if i == subtotal:
          result += 1
        
        elif i  < subtotal:
          break

  print(result)