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 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(x,int(sqrt(n))):
            for z in range(y, int(sqrt(n))):
                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())

def judge(n, x=1, y=1, z=1, l=[]):
    num = 0
    result = x**2 + y**2 + z**2 + x*y + y*z + z*x
    x_th = int(math.sqrt(n))+1
    for x_i in range(x, x_th+1):
        #print('x_i: ', x_i)
        for y_i in range(y, x_th+1):
            y_th = n - x_i**2 + y_i**2 + x_i*y_i
            #print('y_i: ', y_i)
            #print('y_th: ', y_th)
            if y_th < 0:
                break
            for z_i in range(z, x_th):
                #print('z_i: ', z_i)
                result = x_i**2 + y_i**2 + z_i**2 + x_i*y_i + y_i*z_i + z_i*x_i
                #print('result: ', result)
                if result > n:
                    break
                elif result == n:
                    num += 1
    return num

#fn = judge(6, l=[])
#print(fn)
for i in range(1, n+1):
    fn = judge(i, l=[])
    print(fn)

Submission status: Time Limit Exceeded

Solution code:
import math


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

    for n in range(1, N + 1):
        count = 0

        for x in range(1, int(math.sqrt(2 * n)) + 1):
            for y in range(1, int(math.sqrt(2 * n)) + 1):
                for z in range(1, int(math.sqrt(2 * n)) + 1):
                    if (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 == 2 * n:
                        count += 1
                        break

        print(count)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for n in range(1, N+1):
    s = n//5
    cnt = 0
    flag = 0
    for x in range(1, s+1):
        for y in range(1, s+1):
            for z in range(1, s+1):
                siki = x**2 + y**2 + z**2 + x*y + y*z + z*x

                if siki == n:
                    # print('ans = ', siki)
                    if (x==y)and(y==z):
                        cnt += 1
                    elif (x!=y)and(y!=z):
                        cnt += 6
                    else:
                        cnt += 3
                # elif siki > n:
                    flag = 1
                    break
            if flag:
                break
        if flag:
            break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
n = input()
N = int(n)
for i in range(1,N+1):
    ans = 0
    for x in range(1,math.floor(i**0.5)):
        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:
                    s = {x, y, z}
                    for k in range(len(s)):
                        ans+= (k+1)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

def f(n):
  max_loop = math.ceil(math.sqrt(n))
  ans = 0

  for x in range(1, max_loop):
    x2 = x ** 2

    for y in range(1, max_loop):
      y2 = y ** 2

      for z in range(1, max_loop):
        z2 = z ** 2

        if x2 + y2 + z2 + x * y + y * z + z * x == n:
          ans += 1

  return ans

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

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

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
Ni=math.floor(math.sqrt(N))
for i in range(1,N+1):
	count=0
	for x in range(1,Ni):
		for y in range(1,Ni):
			for z in range(1,Ni):
				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:
import math
N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, round(math.sqrt(i))):
        for y in range(1, round(math.sqrt(i))):
            for z in range(1, round(math.sqrt(i))):
                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:
s1 = input().split()
intN = int(s1[0])

i = 1
while i <= intN :
    cnt = 0
    wkX = 1
    while wkX <= i -2 :
        if (wkX * wkX > i -2) : 
            break
        wkY = 1
        while wkY <= i - 2 :
            if (wkY * wkY > i -2) : 
                break
            if (wkX * wkY > i -2) : 
               break
            wkZ = 1
            while wkZ <= i - 2 :
                if (wkZ * wkZ > i -2) : 
                   break
                if (wkY * wkZ > i -2) : 
                    break
                if (wkZ * wkX > i -2) : 
                    break
                intFn = wkX * wkX + wkY * wkY + wkZ * wkZ + wkX * wkY + wkY * wkZ + wkZ * wkX
                if (intFn == i) :
                    cnt += 1
                wkZ += 1
            wkY += 1
        wkX += 1
    print(cnt)
    i += 1

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 set([tuple(sorted(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:
      if len(set([pair[0],pair[1],pair[2]])) == 1:
        result += 1
      elif len(set([pair[0],pair[1],pair[2]])) == 2:
        result += 3
      else:
        result += 6

  print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import Counter
N = int(input())

for i in range(N):
    x_flg = False
    y_flg = False
    count = 0
    if i < 5:
        print(count)
    else:
        x_min = 1
        x_max = int(math.sqrt(i + 1))
        for x in range(x_min, x_max + 1):
            for y in range(x, x_max + 1):
                for z in range(y, x_max + 1):
                    #print(i, x, y, z)
                    if x * x + y * y + z * z + x * y + y * z + z * x == i + 1:
                        numbers = Counter([x, y, z]).values()
                        count += math.factorial(3)
                        for number in numbers:
                            count /= math.factorial(number)
                    elif x * x + y * y + z * z + x * y + y * z + z * x > i + 1:
                        break
        print(int(count))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,9):
    for y in range(1,9):
      for x in range(1,9):
        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):
  print(f(i))

Submission status: Time Limit Exceeded

Solution code:
import itertools

N=int(input())

for n in range(1,N+1):#O(N^2)
    ans=0#ansを初期化
    l=[i for i in range(1,n+1)]
    for c  in itertools.product(l, repeat=3):#l配列の中から3つを選ぶ　c ⇒(a,b,c)
        if  c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[1]*c[2] + c[2]*c[0] == n:
            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):
                    if i-x*x-y*y-x*y>0:
                        z_max = int((i-x*x-y*y-x*y)**0.5)
                        for z in range(y, z_max+1):
                            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())

nn = int(math.sqrt(N))+1

for i in range(2,N+2):
    count = 0
    for x in range(1,nn-1):
        for y in range(x,nn-x):
            for z in range(y,nn-x-y+1):
                if x**2+y**2+z**2+x*y+y*z+z+x == i:
                    if x == y:
                        if y == z:
                            count += 1
                        else:
                            count += 3
                    elif y == z:
                        count += 3
                    else:
                        count += 6
    print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, int(math.pow(i, 1.0/2.6)+1)):
        for y in range(1, int(math.pow(i, 1.0/2.6)+1)):
            for z in range(1, int(math.pow(i, 1.0/2.6)+1)):
                if ((x+y+z)**2)-x*y-y*z-z*x == i:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

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

  result = 0

  for x in range(1, 32):

    if i < x ** 2:
      break

    for y in range(1, 32):

      if i < y ** 2:
        break

      for z in range(1, 32):

        if i < z ** 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)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
"""
yとzで残り
"""
from math import sqrt
for n in range(1,N+1):
    cnt = 0
    for x in range(1,int(sqrt(n))+1):
        for y in range(1,int(sqrt(n))+1):
            for z in range(1,int(sqrt(n))+1):
                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())
limit = int(n**0.5)
for i in range(n):
    cnt = 0
    for x in range(1,limit):
        for y in range(1,limit):
            for z in range(1,limit):
                if x**2+y**2+z**2+x*y+y*z+z*x == i+1:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Heihou_1 = [(3*i)**2-(3*i) for i in range(1,N+1)]
#Heihou_3 = [i**2 for i in range(4,N+1) if i%3 != 0]
n_list = []
for i in range(1,N+1):
    for j in range(1,N+1):
        n_list.append(3*(i)**2 + 2*i*j + j**2)
#print(Heihou_1)
#print(n_list)

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

Submission status: Time Limit Exceeded

Solution code:

N=int(input())
for n in range(1,N+1):
    ans=0
    for x in range(1,101):
        tx=x**2
        if tx>n :
            break
        for y in range(1,101-x):
            ty=tx+y**2+x*y
            if ty>n :
                break
            if (x+y)**2-4*(ty-n)<0:
                break
            s=((x+y)**2-4*(ty-n))**0.5
            if s.is_integer():
                z=-1*(x+y)+s
                if z>0:
                    ans+=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


def solve(n):
    ans = 0
    for x in range(1, n + 1):
        for y in range(1, n + 1):
            z1, z2 = 0, 0
            try:
                z1 = -(y + x) + math.sqrt(-3 * x ** 2 -
                                        3 * y ** 2 - 2 * x * y + 4 * n)
                z2 = -(y + x) - math.sqrt(-3 * x ** 2 -
                                        3 * y ** 2 - 2 * x * y + 4 * n)
            except:
                pass

            if z1 >= 1 and is_integer_num(z1):
                ans += 1
                continue
            if z2 >= 1 and is_integer_num(z2):
                ans += 1
                continue

    return ans


def resolve():
    N = int(input())
    for n in range(1, N + 1):
        print(solve(n))

    return

resolve()

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):
        u_limit = math.ceil(math.sqrt(max(0,2*i-j**2)))
        for k in range(1,u_limit+1):
            u_limit = math.ceil(math.sqrt(max(0,2*i-j**2-k**2)))
            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:
import math

n = int(input())

for i in range(1, n + 1):
    cnt = 0
    
    for x in range(1, i+1):
        if x ** 2 > i:
            break
        for y in range(1, i+1):
            if y ** 2 > i:
                break
            
            try:
                z = (math.sqrt(4 * i - 3 * y ** 2 - 2 * x * y - 3 * x ** 2) - x - y) / 2
            
            except:
                continue

            if z > 0 and z.is_integer():
                cnt += 1

    print(cnt)

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, x + 1):
            for z in range(1, y + 1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if x == y and y == z:
                        cnt += 1
                    elif x == y or y == z or z == x:
                        cnt += 3
                    else:
                        cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

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


def f(n):
    m = int(math.sqrt(n)+0.5)
    res = 0
    for x in range(1, m+1):
        for y in range(1, m+1):
            k = n - (x * x + y * y + x * y)
            if k < 1:
                break
            l = 1
            r = m+1
            while r - l > 1:
                z = (r + l) // 2
                tmp = (x + y + z) * z
                if tmp <= k:
                    l = z
                else:
                    if r == z + 1:
                        r -= 1
                    else:
                        r = z + 1
            if (x+y+l) * l == k:
                res += 1
    return res


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

Submission status: Time Limit Exceeded

Solution code:
# C

from math import ceil
N=int(input())

for i in range(1,N+1):
    ans=0
    p=ceil(i**0.5+1)
    for x in range(1,p+1):
        for y in range(1,p+1):
            s = x**2+y**2+x*y
            t = x+y
            if t**2-4*(s-i)>0:
                k=(t**2-4*(s-i))**0.5
                #print(x,y,k)
                if k-t >0 and (k-t)%2==0:
                    ans +=1
                    #print(x,y,k,(k-t)//2)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
from itertools import product

N=int(input()) # 入力の整数

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

maxv=math.ceil(math.sqrt(N)) # 探索するのはせいぜいこの数まで

for n in range(1,N+1): # 入力の数
    count=0 # カウンタ

    # for x in range(1,maxv): # x
    #     for y in range(1,maxv): # y
    #         for z in range(1,maxv): # z
    #             r=func(x,y,z) # 式を計算する
    #             # print("r = ",r)

    #             if r==n: # もし計算の結果が狙ったものだったら
    #                 count+=1 # カウンタをインクリメント

    for x,y,z in product(range(1,maxv),range(1,maxv),range(1,maxv)): # x,y,zの組み合わせ
        # print(x,y,z)
        r=func(x,y,z) # 式を計算する

        if r==n: # もし計算の結果が狙ったものだったら
            count+=1 # カウンタをインクリメント


    print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = [int(i) for i in range(1,n//3)]
import itertools
p_list = list(itertools.combinations_with_replacement(l, 3))
p=[]
s=[0]*100000000
for i in p_list:
    x=i[0]
    y=i[1]
    z=i[2]
    p.append((x+y+z)**2-x*y-y*z-z*x)

    if x==y and y==z and z==x:
        s[p[-1]]=1
    elif x==y or y==z or z==x:
        s[p[-1]]=3
    else:
        s[p[-1]]=6

for i in range(1,n+1):
    if i in p:
        print(s[i])

    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
"""
x, y, z: 正数
x^2+y^2+z^2+xy+yz+zx = n
f(n): 以上の2つの条件を満たす正数の組（x, y, z）の個数
"""

import itertools
import math

def f(X, Y, Z):
    temp = (X**2 + Y**2 + Z**2)/2
    return temp

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

N  = int(input())

X = range(1, int(math.sqrt(N)))
Y = X
Z = X

for i in range(1, N+1):
    count = 0
    for v in itertools.product(X, Y, Z):
        if(g(v[0], v[1], v[2]) > i):
            continue
        elif(g(v[0], v[1], v[2]) == i):
            count += 1
    print(count)

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[74]:


for num in range(1,n+1):
    nnew = math.sqrt(num)
    nnew = math.floor(nnew)+1
    for x, y,z in itertools.product(range(1,nnew), range(1,nnew), range(1,nnew)):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == num:
            count+=1
    
    print(count)
    count = 0


# In[75]:


for i in li:
    print(i)


# In[ ]:





# In[ ]:

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):
  for y in range(1,i):
   for z in range(1,i):
    if i==x*x+y*y+z*z+x*y+x*z+y*z:
      ans+=1
 print(ans)

Submission status: Time Limit Exceeded

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

    for i in range(N):
        result = []
        for x in range(int(i/2)):
            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:
import itertools
import math
N = int(input())
for n in range(1, N+1):
  ans = 0
  if n > 5:
    n_max = int(math.sqrt(n))
    l = [i for i in range(1, n_max)]
    for c in itertools.combinations_with_replacement(l, 3):
      if n == c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]:
        if len(set(c)) == 1:
          ans += 1
        elif len(set(c)) == 2:
          ans += 3
        elif len(set(c)) == 3:
          ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
"""
yとzで残り
"""
from math import sqrt
for n in range(1,N+1):
    cnt = 0
    for x in range(1,n+1):
        for y in range(1,n+1):
            for z in range(1,n+1):
                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 math
import itertools
N = int(input())

def func_count(i):
    end = int(math.sqrt(i) + 1)
    num = [i for i in range(1, end)]
    ans = 0
    for x, y, z in itertools.product(num, num, num):
        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:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
o = n // 3
a = [0]* n * 2
for i in range(1,o):
    for j in range(1,o):
        for k in range(1,o):
            num = i * i + j * j + k * k + i * j + j * k + k * i
            if  num > n:
                break
            a[num-1] +=1
            #print("#" + str(num)+" "+str(i) + " " + str(j) + " "+ str(k))
for  i in range(n*2):
    if i >= n:
        break
    print(a[i])

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

limit = int(math.sqrt(N))+1

for n in range(1,N+1):
    count = 0
    for x in range(1,limit):
        if x**2 >= N:
            continue
        for y in range(1,limit):
            if y**2 >= N:
                continue
            try:
                z = int((-(x+y)+math.sqrt(((x+y)**2)-4*(x*x+y*y+x*y-n)))/2)
                if x**2+y**2+z**2+x*y+y*z+z*x-n == 0 and z >= 1:
                    count+=1
            except:
                None
            try:
                z = int((-(x+y)-math.sqrt(((x+y)**2)-4*(x*x+y*y+x*y-n)))/2)
                if x**2+y**2+z**2+x*y+y*z+z*x-n == 0 and z >= 1:
                    count+=1
            except:
                None       
    print(count)

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]
                elif 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:
N = int(input())
flag_1 = 0
flag_2 = 0

for n in range(N):
    count = 0
    for x in range(1,100):
        if flag_1 == 1:
            flag_1 = 0
            break
        for y in range(1,100):
            if flag_2 == 1:
                flag_2 =0
                break
            for z in range(1,100):
                culc = x**2 + y**2 + z**2 + x*y + y*z + z*x - (n + 1)
                if culc == 0:
                    count += 1
                elif culc > 0:
                    if z == 1:
                        flag_2 += 1
                        if y == 1:
                            flag_1 += 1

                    break
                elif culc < 0:
                    continue

    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

if __name__ == '__main__':
    n = int(input().strip())


    def f(x, y, z):
        return int(x * x + y * y + z * z + x * y + y * z + z * x)

    for i in range(1, n + 1):
        count = 0
        if not i < 6:
            limit = int(math.sqrt(i))
            for x in range(1, limit + 1):
                if i == f(x, x, x):
                    count += 1
            tmp_count = 0
            for x in range(1, limit+1):
                for z in range(1, limit+1):
                    if not x == z and i == f(x, x, z):
                        tmp_count += 1
            count += tmp_count * 3

            tmp_count = 0
            for x in range(1, limit+1):
                for y in range(1, x):
                    for z in range(1, y):
                        if i == f(x, y, z):
                            tmp_count += 1
            count += tmp_count * 6

        print(count)

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):
        tempx = x**2
        for y in range(1, int(math.sqrt(N-x**2))+1):
            tempy = y**2
            tempxy = x*y
            if N-tempx-tempy-tempxy < 0:
                break
            else:
                for z in range(1, int(math.sqrt(N-tempx-tempy-tempxy))+1):
                    if tempx + tempy + z**2 + tempxy + y*z + z*x == N:
                        result += 1
                    elif tempx + tempy + z**2 + tempxy + y*z + z*x > N:
                        break
    print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[]
for i in range(300):
  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())
l = int(n**(0.5))
for a in range(n):
  s=0
  for i in range(l):
    if((3*i+3)**2-(3*(i**2)+6*i+3)==a+1):
      s+=1
      continue
    for j in range(l-i):
      for k in range(l-i-j):
        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:
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):
                    if i-x*x-y*y-x*y>0:
                        z_max = int((i-x*x-y*y-x*y)**0.5)
                    else:
                        z_max = i-2
                    for z in range(y, z_max+1):
                        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:
N=int(input())
f=[0]*N
for i in range(N):
    for j in range(i+1):
        for k in range(i+1):
            for l in range(i+1):
                if (j+1)*(j+1)+(k+1)*(k+1)+(l+1)*(l+1)+(j+1)*(k+1)+(k+1)*(l+1)+(l+1)*(j+1)==(i+1):
                    f[i]=f[i]+1

for i in range(N):
    print(f[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


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


for n in range(1, N+1):
    ans = 0
    for i in range(1, N):
        if (i * i + i > N):
            break
        for j in range(1, N):
            if (j * j + j > N):
                break
            for k in range(1, N):
                if (k * k+k > N):
                    break
                unk = f(i, j, k)
                if (unk == n):
                    ans += 1
                    break
                elif (unk > n):
                    break
    print(ans)

Submission status: Time Limit Exceeded

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

n = int(input())

ans = 0
arr = []
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            arr.append(func(x,y,z))
for i in range(n):
    print(arr.count(i+1))

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):
      check = i**2+j**2+k**2+i*j+j*k+k*i
      if (check <= n):
        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:
n = int(input())

for num in range(n):
    count = 0
    checked_num = num+1
    half = int(num/2)

    for x in range(1, half):
        for y in range(1, half):
            for z in range(1, half):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == checked_num:
                    count += 1


    print(count)

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) + 2):
        for y in range(1, int(N ** 0.5) + 2):
            if fn(x, y, 1) > n:
                break
            for z in range(1, int(N ** 0.5) + 2):
                f = fn(x, y, z)
                if f > n:
                    break
                if f == n:
                    ans[f - 1] += 1

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


for n in range(1,N+1,1):
    cnt = 0
    for x in range(1,N+1,1):
        for y in range(1, N+1,1):
            for z in range(1, N+1,1):
                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:
a=int(input())

def siki(x,y,z):
	return x*x+y*y+z*z+x*y+y*z+z*x

for n in range(1,a+1):
	count=0
	for x in range(1,42):
		for y in range(1,42):
			for z in range(1,42):
				if siki(x,y,z)>n:
					break
				#print(x,y,z, siki(x,y,z))
				if siki(x,y,z)==n:
					count+=1

	print(count)