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:
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 * x + y * y + z * z + x * y + y * z + z * x)

    N = input_int()
    for n in range(1, N + 1):
        ans = 0
        for x in range(1, 50):
            for y in range(x, 50):
                b = x + y
                c = -n + x * x + y * y + x * y
                D = b * b - 4 * c
                if D < 0:
                    continue
                z = (-b + math.sqrt(D)) / 2
                if z.is_integer() and z >= y:
                    if x == y == z:
                        ans += 1
                        continue
                    else:
                        ans += 3
                        continue
                # # for z in range(y, 50):
                # left = L(x, y, z)
                # if left > n:
                #     break
                # elif left == n:
                #     if x == y == z:
                #         ans += 1
                #         break
                #     else:
                #         ans += 3
                #         break

        print(ans)
resolve()

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,int(i*2/3)):
   for y in range(1,int(i*2/3)):
    for z in range(1,int(i*2/3)):
     if x+y+z==math.sqrt(i+x*y+x*z+y*z):
       ans+=1
       if x==y and y==z:
        break
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

count_n = []
ans = []
for o in range(n):
  temp = 0
  for i in range(1,10):
    for j in range(1,10):
      for k in range(1,10):
        if o ==  i ** 2 + j **2 + k ** 2 + i * j + j * k + k * i:
          count_n.append(o)

for i in range(1,n+1):
  if i not in count_n:
    print(0)
  else:
    print(count_n.count(i))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1, N+1):
    # count number of sets (x, y,x)
    #assume x<y<z
    ans=0
    flag=[1,2,6, 6]
    z_low=int((n/6)**0.5)
    z_up=int(n**0.5)
    for z in range(z_low, z_up):
        if (n-3*z**2)/3 <=0:
            y_low=1
        else:
            y_low=int(((n-3*z**2)/3)**0.5)
        for y in range(y_low, z+1):
         
          if n-3*z**2-2*y**2<=0:
             x_low=1
          else:
               x_low=int((n-3*z**2-2*y**2)**0.5)
          for x in range(x_low, int((n/6)**0.5)+1):
             if n == x**2 + y**2 + z**2 + x*z + x*y + y*z:
                 f=0
                 if z==y:
                     f+=1 
                 if x==y:
                     f+=1
                 if x==z:
                    f+=1
                 ans+=int(6/flag[f])
    print(ans)

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
    a = math.sqrt(i)
    for iii in range(100):
        j += 1
        if j >= a and j != 1:
            break
        k = 0
        for jjj in range(100):
            k += 1
            if k >= a and k != 1:
                break
            l = 0
            for kkk in range(100):
                l += 1
                if l  >= a and l != 1:
                    break
                elif (j+k+l) >= a and j != 1 and k != 1 and l != 1:
                    break
                if (j**2 + k**2 + l**2 + j*k +k*l + l*j) == i:
                    sum += 1
    j = 0
    wk = 0
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

def d(x, y, n):
  return (x+y)**2 - 4*(x**2 + y**2 + x*y - n)

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 eq(i, i, i) > n:
      break
    else:
      for j in range(i, int(n/2)):
        if eq(i, j, j) > n:
          break
        elif d(i, j, n) > 0:
          k = int((-i-j+np.sqrt(d(i, j, 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())
record = [0] * 1000000

b = 1
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(b,N+1):
            sum = i**2 + j**2 + k**2 + i*j + i*k +j*k
            if sum >= N: break
            if i==j==k: record[sum] += 1
            else: record[sum] += 3
        b += 1

for num in record[1:N+1]:
    print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for i in range(1, N+1):
    count = 0
    if i < 6:
        print(count)
    else:
        for x in range (1, int(i/3)):
            for y in range(1, int(i/3)):
                for z in range(1, int(i/3)):
                    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

def calc(a, b, c):
    return a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a

N = int(input())

for i in range(1, N+1):
    ans = 0
    for x in range(1, round(math.sqrt(i))):
        if x**2 > i:
            break
        t1 = i-x**2
        for y in range(1, t1):
            if y**2 > t1:
                break
            t2 = t1-y**2
            for z in range(1, t2):
                if z**2 > t2:
                    break
                tmp = calc(x, y, z)
                if tmp > i:
                    break
                if tmp == i:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for n in range(1,N+1):
    r_n = math.floor(math.sqrt(n))
    count = 0
    if(n >= 6):
        for x in range(1,r_n):
            for y in range(1,x+1):
                for z in range(1,y+1):
                    if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
                        if (x == y and y ==z):
                            count+=1
                        elif(x == y or y==z or z == x):
                            count+=3
                        else:
                            count+=6
    print(count)

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

        zMax = int((N + 1) / 6) + 1
        for x in range(1, int((N + 1) / 6) + 1):
            tx = x ** 2
            if tx + x >= n or x >= zMax:
                break
            for y in range(x, int((N + 1) / 6) + 1):
                ty = tx + y ** 2 + x * y
                if ty + y + x >= n or y >= zMax:
                    break
                for z in range(y, int((N + 1) / 6) + 1):
                    t = ty + z ** 2 + y * z + z * x
                    if t == n:
                        if x == y and x == z:
                            ans += 1
                        elif x == y or y == z:
                            ans += 3
                        else:
                            ans += 6
                        if z <= zMax:
                            zMax = z
                        break
                    if t >= n:
                        break
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
count = [0]*n
for i 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):
            b = x + y
            c = x*x + y*y + x*y - i
            if b**2 >= 4*c:
                d = (-b + math.sqrt(b**2-4*c))/2 #zの解
                if d.is_integer() == True and d >= 1:
                    count[i-1] += 1
    print(count[i-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

count_n = []
ans = []
for o in range(n):
  temp = 0
  for i in range(1,20):
    for j in range(1,20):
      for k in range(1,20):
        if o ==  i ** 2 + j **2 + k ** 2 + i * j + j * k + k * i:
          count_n.append(o)

for i in range(1,n+1):
  if i not in count_n:
    print(0)
  else:
    print(count_n.count(i))

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
f = [0] * N
n = list(range(1,N+1))
for i in range(N):
    n[i] = math.ceil(math.sqrt(n[i]))

for i in range(1,N+1):
    for x in range(1,n[i-1]):
        if(x*x > i):
            break
        for y in range(x,n[i-1]):
            if(x*x+y*y+x*y > i):
                break
            for z in range(y,n[i-1]):
                if(x*x+y*y+z*z+x*y+y*z+z*x == i):
                    if(x == y and y == z) :
                        f[i-1] += 1
                    elif(x == y and y < z):
                        f[i-1] += 3
                    elif(x < y and y == z):
                        f[i-1] += 3
                    else:
                        f[i-1] += 6


[print(a) for a in f]

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
    a = math.sqrt(i)
    for iii in range(150):
        j += 1
        if j >= a and j != 1:
            break
        k = 0
        for jjj in range(150):
            k += 1
            if k >= a and k != 1:
                break
            l = 0
            for kkk in range(150):
                l += 1
                if l  >= a and l != 1:
                    break
                elif (j+k+l) >= a and j != 1 and k != 1 and l != 1:
                    break
                if (j**2 + k**2 + l**2 + j*k +k*l + l*j) == i:
                    sum += 1
    j = 0
    wk = 0
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = []
for i in range(n):
    ans.append(0)
m = n
n = 1
while n <= m:
    for i in range(1, n):
        if (3 *i)**2 - (3 *(i**2)) == n:
            ans[n -1] = 1
            break
        for j in range(1, n):
            if (2 *i +j)**2 - (i**2 + 2*i*j) == n:
                ans[n -1] = 3
                break
    n += 1
for i in range(len(ans)):
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
for l in range(1, n+1):
  for i in range(1, 41):
    for j in range(1, 41):
      for k in range(1, 41):
        if (i+j+k)**2-(i*j+j*k+i*k) == l:
          count +=1
  print(count)
  count = 0

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

ans=[0]*N

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 <=N:
                ans[i**2+j**2+k**2+i*j+j*k+k*i-1] +=1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = 1
for m in range(1,N+1):
  count =0
  y =1
  z =1
  for i in range(m):
    x = i+1
    if 6*x**2>=m:
      if x**2>m:
        break
      if 9*x*x >= m:
        for k in range(x):
          y = k+1
          nn = x*x+y*y+x*y
          if nn > m:
            break
          if nn >=m/2:
            xy = (x+2*y)**2-x*y
            if xy >= m:
              for j in range(y):
                z = j+1
                n = nn+z*z+y*z+z*x
                if n>m:
                  break
                if n==m:
                  if  x==y or y==z or z==x:
                    if x==y and y == z:
                      count =count+1
                    else:
                      count = count+3
                  else:
                    count =count+6
  print(count)

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:
            break

        for y in range(1,int(sqrt(k-x**2)) + 1 ):
            m=k-x**2 - y**2 -x*y
            if m<=0:
                break
            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 numpy as np
n = int(input())

my_list = np.array([i for i in range(1,10001)])

def binary_search(list, item):
    low = 1
    high = len(list)

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1

    return None
a = []
for i in range(1,n+1):
    ans = 0
    if i<=5:
        print(0)
        continue
    for x in range(1,math.floor((math.sqrt(i-3)-1)/2)+2):
        for y in range(x,math.floor((math.sqrt(i+x)-1-x)/2)+2):
            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 z>=y:
                if x==y==z:
                    ans += 1
                elif y==z or z==x:
                    ans += 3
                elif z*10000//10000==z and x==y:
                    ans += 3
                elif z*10000//10000==z:
                    ans += 6
    print(ans)

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//3):
        for j in range(i,p//3):
            for k in range(j,p//3):
                if (i+j)**2 + (j+k)**2 + (k+i)**2 == 2*p:
                    if i == j == k:
                        count += 1
                    elif i != j and j != k and k != i:
                        count += 6
                    else:
                        count += 3
                    
    A.append(count)
    
for q in range(N):
    print(A[q])

Submission status: Time Limit Exceeded

Solution code:
from math import trunc, sqrt

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

def perm(x,y,z):
    if x==y and y==z and z==x:
        return 1
    if x!=y and y!=z and z!=x:
        return 6
    return 3

def f(n):
    mn=trunc(sqrt(n//3)+1)
    k=0
    for x in range(1,mn+1):
        for y in range(x,mn+1):
            for z in range(y,mn+1):
                if p(x,y,z)==n:
                    k += perm(x,y,z)
    return k

N=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

def func(n):
    cnt = 0
    for x in range(1, int(n*.5)+1):
        if x * x > n:
            break
        for y in range(1, int(n*.5)+1):
            if y * y > n:
                break
            for z in range(1, int(n*.5)+1):
                if z * z > n:
                    break
                if x * x + y * y + z * z + x * y + y * z + z * x == n:
                    cnt += 1
                    break
    return cnt


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

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
count = [0]*n
for i 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):
            b = x + y
            c = x*x + y*y + x*y - i
            if b**2 >= 4*c:
                d = (-b + math.sqrt(b**2-4*c))/2 #zの解
                if d.is_integer() == True and d >= 1:
                    count[i-1] += 1
for i in range(n):
    print(count[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):
        for y in range(1, i):
            judge = -3*x**2 -3*y**2 - 2*x*y + 4*i
            if  judge >= 0:
                if ((-x -y)+(judge)**(1/2))%2 == 0 and ((-x -y)+(judge)**(1/2))/2 >= 1:
                    ans += 1
   
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
def f(n):
    count=0
    for x in range(1,int(math.sqrt(n))):
        for y in range(1,x+1):
            for z in range(1,y+1):
                if x*x+y*y+z*z+x*y+y*z+z*x==n:
                    if x==y and y==z:
                        count+=1
                    else:
                        count+=3
    print(count)

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

Submission status: Time Limit Exceeded

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

        
    N = int(input())
    b = []
    for i in range(1,N+1):
        if (i<6):
            print(0)
        else:
            for x in range(1,i):
                for y in range(1,i):
                    for z in range(1,i):
                        aa =local(x , y , z)
                        if aa == i:
                            b.append(i)
            print(len(b))
            b.clear()
main()

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
from math import *

N = int(input())
pro = list(product(range(1, int(sqrt(N))), repeat=3))

for i in range(1, N+1):
    ans = 0
    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:
N = int(input())

cnt = 0

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range (1,N+1):
    cnt = 0
    for x in range (1,n + 1):
        for y in range(x,n + 1):
            for z in range(y,n + 1):
                if (x + y + z) ** 2 - (x * y + y * z + z * x) == n:
                    cnt += 1
                    if x == y == z:
                        cnt += 0
                    elif x == y != z:
                        cnt += 2
                    elif x != y == z:
                        cnt += 2
                    else:
                        cnt += 5
                else:
                    cnt += 0
    print(str(cnt))

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
    a = math.sqrt(i)
    while True:
        j += 1
        if j >= a and j != 1:
            break
        k = 0
        while True:
            k += 1
            if k >= a and k != 1:
                break
            l = 0
            while True:
                l += 1
                if l  >= a and l != 1:
                    break
                elif (j+k+l) >= a and j != 1 and k != 1 and l != 1:
                    break
                if (j**2 + k**2 + l**2 + j*k +k*l + l*j) == i:
                    sum += 1
    j = 0
    wk = 0
    print(sum)

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//2):
        for j in range(i,p//2):
            for k in range(j,p//2):
                if (i+j)**2 + (j+k)**2 + (k+i)**2 == 2*p:
                    if i == j == k:
                        count += 1
                    elif i != j and j != k and k != i:
                        count += 6
                    else:
                        count += 3
                    
    A.append(count)
    
for q in range(N):
    print(A[q])

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)]
    tmp=[c for c in itertools.combinations_with_replacement(l, 3) if sum(c) <= n]
    #print(tmp)
    for c in tmp:
        if  c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[1]*c[2] + c[2]*c[0] == n:
            if c[0] == c[1] == c[2]:
                ans+=1
            elif c[0] != c[1] & c[1] != c[2] & c[2] != c[0]:
                ans+=6
            else:
                ans+=3
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
count=[0]*N
for n in range(1,N+1):
  for x in range(1,100):
    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:
            count[n-1]+=1
          elif x==y or y==z or z==x:
            count[n-1]+=3
          else:
            count[n-1]+=6
for ans in count:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

cnt = 0

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
if n<=5:
  for i in range(n):
    print(0)
else:
  for i in range(5):
    print(0)
  for i in range(6, n+1):
    count=0
    for x in range(1, int(i/3)):
      if x*x>=i:
        break
      for y in range(1, int(i/3)):
        if y*y>=i:
          break
        for z in range(1, int(i/3)):
          if z*z>=i:
            break
          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())
ans =0
L =[0]*n

for i in range(1,n+1):
    for j in range(1,int(n**0.5//6)+2):
        for k in range(j,int(n**0.5//6)+3):
            for l in range(k,int(n**0.5//6)+4):
                if j**2 + k **2 + l**2 + j*k + k*l + l*j == i:
                    if j == k == l:
                        L[i-1] += 1
                        break
                    if j < k <l:
                        L[i-1] += 6
                        break
                    else:
                        L[i-1] += 3
for m in range(n):
    print(L[m])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def count(n):
    ans=0
    for x in range(1, n):
        if 6*(x**2)>n:
            break
        for y in range(x, n):
            if 3*((x+y)**2)>2*n:
                break
            for z in range(y, n):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x > n:
                    break
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if x==y and y==z:
                        ans+=1
                    elif x!=y and y!=z and z!=x:
                        ans+=6
                    else:
                        ans+=3
    return ans

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

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(min(mark2,abs(mark-(max(x,y))))):
                if (x+y+z)**2 - (x*y + x*z + y*z) == did:
                    count += 1
    print(count)
    did += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

for i in range(n):
    s = 0
    for x in range(1, n+1):
        if x**2 + 2*x + 3 > i+1:
            print(s)
            break
        else:
            for y in range(1, x+1):
                if f(x,y,1) > i+1:
                    break
                else:
                    for z in range(1, y+1):
                        if f(x,y,z) == i+1:
                            if x == y == z:
                                s += 1
                            elif x == y or y == z:
                                s += 3
                            else:
                                s += 6

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, min(41, n+1)):
    for y in range(1, min(41, n+1)):
      for z in range(1, min(41, n+1)):
        ret = x**2 + y**2 + z**2 + x*y + y*z + z*x
        if ret > n:
          break
        if ret == n:
          ans+=1
      
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import trunc, sqrt

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

def perm(x,y,z):
    if x==y and y==z and z==x:
        return 1
    if x!=y and y!=z and z!=x:
        return 6
    return 3

def f(n):
    mn=n
    k=0
    for x in range(1,mn+1):
        for y in range(x,mn+1):
            for z in range(y,mn+1):
                if p(x,y,z)==n:
                    k += perm(x,y,z)
    return k

N=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,n+1):
    a=0
    ii=int((i**0.5)+1)
    x=1
    while(x<ii):
        y=x
        while(x+y<ii):
            z=y
            while(x+y+z<=ii):
                if((x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)==i):
                    if(x==y==z):
                        a+=1
                    elif(x<y<=z or x<=y<z):
                        a+=3
                    elif(x<y<z):
                        a+=6
                z+=1
            y+=1
        x+=1
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import math

def xyz(n):
    rng = math.floor(math.sqrt(n))
    count = 0
    for x in range(1, rng):
        for y in range(1, rng):
            for z in range(1, rng):
                if (x+y) ** 2 + (y+z) ** 2 + (z+x) ** 2 == 2 * n:
                    count += 1
    return count


N = int(input())
for i in range(1, N+1):
    print(xyz(i))

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
x = 1
for m in range(1,N+1):
  count =0
  y =1
  z =1
  for i in range(m):
    x = i+1
    if 6*x**2>=m:
      if x**2>m:
        break
      if 9*x*x >= m:
        for k in range(x):
          y = k+1
          nn = x*x+y*y+x*y
          if nn > m:
            break
          if nn >=m/2:
            xy = (x+2*y)**2-x*y
            if xy >= m:
              for j in range(y):
                z = j+1
                n = nn+z*z+y*z+z*x
                if n>m:
                  break
                if n==m:
                  if  x==y or y==z or z==x:
                    if x==y and y == z:
                      count =count+1
                    else:
                      count = count+3
                  else:
                    count =count+6
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    for n in range(1, N + 1):
        res = 0
        for x in range(1, int(pow(n, 0.5)) + 1):
            for y in range(x, int(pow(n, 0.5)) + 1):
                for z in range(y, int(pow(n, 0.5)) + 1):
                    if pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == n:
                        if x == y == z:
                            res += 1
                        elif x == y or y == z or z == z:
                            res += 3
                        elif x != y != z:
                            res += 6
        print(res)


if __name__ == '__main__':
    resolve()

# t = n - pow(x, 2) - pow(y, 2) - x * y
# if t >= 1:

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    MAX = int(N ** 0.5)

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

    res = [0] * 10008

    for n in range(1, N + 1):
        ans = 0
        li = []
        for x in range(1, MAX + 1):
            for y in range(1, MAX + 1):
                delta = (y + x) ** 2 - 4 * (x ** 2 + y ** 2 + x * y - n)
                if delta >= 0:
                    z = (-(y + x) + (delta) ** 0.5) / 2
                    if z > 0 and z % 1 == 0 and f(x, y, z, n):
                        ans += 1
                        li.append((x, y, z))

        # print(n, ans, li)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

for i in range(1,N+1):
    ans=0
    for x in range(1,33):
        x2=x*x
        for y in range(1,33):
            if x>=y:
                if x^2+y^2<1000:
                    a=-(3*(x2)+3*(y*y)+2*x*y)/4+i
                    if a>0:
                        b=(math.sqrt(a)-(x+y)/2)
                        if b>0 and b%1==0.0:
                            if x==y:
                                ans+=1
                            else:
                                ans+=2

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

for i in range(1, n + 1):
    cnt = 0
    
    n = i
    x = 1
    y = 1

    while x < n:

        while y < n:

            try:
                z = (math.sqrt(4 * i - 3 * y ** 2 - 2 * x * y - 3 * x ** 2) - x - y) / 2
            
            except:
                y += 1
                continue

            if z > 0 and z.is_integer():
                if x == y:
                    if y == z:
                        cnt += 1
                    else:
                        cnt += 3
                elif x == z:
                    cnt += 3
                elif y == z:
                    cnt += 3
                else:
                    cnt += 6

                n = max(z, x, y)           
                break

            y += 1
        x += 1

    print(cnt)