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:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    for n in range(1,N+1):
        ans = 0
        for x in range(1,int((n//3)**0.5)+1):
            for y in range(1,int((n//3)**0.5)+1):
                pre = x**2 + y**2 + x*y
                uu = n-pre
                if uu<0:
                    break
                for z in range(1,int(uu**0.5)+1):
                    if z*(z+x+y)==uu:
                        if len(set([x,y,z])) == 1:
                            ans = 1
                            break
                        elif len(set([x,y,z])) == 2:
                            ans = 3
                            break
                        else:
                            ans = 6
                            break
            else:
                continue
            break
        print(ans)



if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
if N <= 10**3:
    for i in range(1, N+1):
        ans = 0
        for x in range(1, 13):
            for y in range(1, 13):
                for z in range(1, 13):
                    if (x+y+z)**2-x*y-y*z-z*x == i:
                        ans += 1
        print(ans)
    exit()
else:
    table = [0] * N
    for i in range(1, 10**3):
        ans = 0
        for x in range(1, 41):
            for y in range(1, 41):
                for z in range(1, 41):
                    if (x+y+z)**2-x*y-y*z-z*x == i:
                        ans += 1
        table[i-1] += ans
    for j in range(10**3, N+1):
        ans = 0
        for x in range(1, 41):
            for y in range(1, 41):
                for z in range(1, 41):
                    if (x+y+z)**2-x*y-y*z-z*x == j:
                        ans += 1
        table[j-1] += ans
    print(*table, sep="\n")

Submission status: Time Limit Exceeded

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


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


N = int(input())
NL = []

for n in range(1, N+1):
    lim = int(math.sqrt(n)) + 1
    ans = 0
    for x in range(1, lim):
        for y in range(x, lim):
            for z in range(y, lim):
                if f(x, y, z) == n:
                    if len(set([x, y, z])) == 1:
                        ans += 1
                    elif len(set([x, y, z])) == 2:
                        ans += 3
                    else:
                        ans += 6
    print(ans)
# for i in range(1, N):
#     print(NL.count(i))

Submission status: Time Limit Exceeded

Solution code:
import itertools as it
N=int(input())
for i in range(1,N+1):
  cnt=0
  for c in list(it.product(range(1,i),repeat=3)):
    if sum(c)<=i:
      x=c[0]
      y=c[1]
      z=c[2]
      if i==x**2+y**2+z**2+x*y+y*z+z*x:
        cnt+=1
  print(cnt)

Submission status: Time Limit Exceeded

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

for n in range(1,N+1):
    ans4n=0
    xmax=int(math.sqrt(n))
    for x in range(1,xmax+1):
        ymax=xmax+1-x
        for y in range(1,ymax+1):    
            zmax=ymax+1-y
            for z in range(1,zmax+1):
                if n==(x+y+z)**2-(x*y+y*z+z*x):
                    ans4n+=1

    print(ans4n)

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

Submission status: Time Limit Exceeded

Solution code:
key = int(input())
for n in range(1, key+1):
    ans = 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+z*y+z*x == n:
                    ans += 1
    print(ans)

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(n,42)):
    for y in range(x,min(n,42)):
      for z in range(y,min(n,42)):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == n:
          if x == y and y == x and z == x:
            ans += 1
          elif x == y  or z == x or y == z:
            ans += 3
          elif x != y and y != z and z != x:
            ans += 6
          check = True
          break
      if check:
        break
    if check:
      break
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
import numpy as np
import math
rn=n**0.5
rn=math.ceil(rn)

a=[[[0]*rn for ii in range(rn)] for jj in range(rn)]
for xx in np.arange(1,rn+1):
  xx2=xx**2
  for yy in np.arange(1,rn+1):
    xx2yy2xxyy=xx2+yy**2+xx*yy
    xxpyy=xx+yy
    tempr=xx2yy2xxyy+1+xxpyy
    if tempr>n: 
      break
    for zz in np.arange(1,rn+1):
      tempr=xx2yy2xxyy+zz**2+xxpyy*zz
      if tempr>n: 
        break
      else:
        a[xx-1][yy-1][zz-1]=tempr

for ii in range(n):
  r=0
  for xx in np.arange(1,rn+1):
    if a[xx-1][0][0]>ii+1: 
      break
    for yy in np.arange(1,rn+1):
      if a[xx-1][yy-1][0]>ii+1: 
        break
      for zz in np.arange(1,rn+1):
        if a[xx-1][yy-1][zz-1]>ii+1: 
          break
        elif a[xx-1][yy-1][zz-1]==ii+1:
          r+=1
  print(r)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
x = 0
y =0 
z =0
for m in range(1,N+1):
  l = math.sqrt(m)
  li = int(l)
  count =0
  for i in range(li):
    x = i+1
    for k in range(x):
      y = k+1
      nn = x*x+y*y+x*y
      if nn > m:
        break
      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:
#!/usr/bin/env python3

def func(n):
    cnt = 0
    for x in range(1, 13):
        if x * x > n:
            break
        for y in range(1, 13):
            if y * y > n:
                break
            for z in range(1, 13):
                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:
N = int(input())

def F(n):
    ans = 0
    if n < 6:
        return 0
    else:
        for x in range(1,int((n-2)**0.5)):
            for y in range(1,int((n-2)**0.5)):
                z = (n - 3/4*(x**2+y**2) - 1/2*x*y)**0.5 - (x+y)/2
                if isinstance(z,complex):
                    continue
                if z.is_integer() and z>=1:
                    ans += 1
    return ans
for i in range(1,N+1):
    print(F(i))

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
N = int(input())
#L, R, d=map(int,input().split())
#C = []
# for i in range(N):
#    C.append((input().replace(".","0").replace("#","1")))
# S=list(map(int,input().split()))
# B=list(map(int,input().split()))
def calc1(x,y,z):
    return x*x+y*y+z*z+x*y+y*z+z*x
def calc2(x,y):
    return x*x+y*y+1*1+x*y+y*1+1*x
def calc3(x):
    return x*x+1*1+1*1+x*1+1*1+1*x

count = []
for n in range(1,N+1):
    count2 = 0
    l = []
    for i in range(1,n):
        if calc3(i) > n:
            break
        for j in range(1,n):
            if calc2(i,j) > n:
                break
            for k in range(1,n):
                h = calc1(i,j,k)
                o = [i,j,k].sort
                if h > n:
                    break
                elif o in l:
                    count2+=1
                elif h == n:
                    count2+=1
                    l.append(o)
    count.append(count2)

for p in count:
    print(p)

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


from pprint import pprint

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

p_set = set(p)

p_equal = []
p_nonequal = []
for _p in p_set:
    x, y, z = _p[0], _p[1], _p[2]

    if x == y == z:
        p_equal.append(calc(x, y, z))
    else:
        p_nonequal.append(calc(x, y, z))

# print(p_equal)
# print(p_nonequal)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def dfs(lis,cnt,n):
    # 数列の長さが N に達したら打ち切り

    if sum(lis)>100:
        return cnt

    if(len(lis)==3):
        ans=lis[0]**2+lis[1]**2+lis[2]**2+lis[0]*lis[1]+lis[1]*lis[2]+lis[2]*lis[0]
        if(ans==n):
            cnt+=1
        return cnt
    
    for v in range(1,100):
        lis.append(v)
        cnt=dfs(lis,cnt,n)
        lis.pop()
    
    return cnt


n= int(input())
for i in range(1,n+1):
    cnt = 0
    print(dfs([],cnt,i))

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
    if(x>=32):
      break
    for y in range(x,k):
      if(y==0):
        continue
      if(y>=32):
        break
      for z in range(y,k):
        if(z==0):
          continue
        if(z>=32):
          break
        if((x+y)**2+(y+z)**2+(z+x)**2)//2==i:
          #print(x,y,z)
          #print(i)
          if (x==y and y==z and z==x):
            count+=1
          elif (x!=y and y!=z and z!=x):
            count+=6
          else:
            count+=3
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

for i in range(1,n+1):
    ans = 0
    if i<=5:
        print(0)
        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 float.is_integer(z) and z>=y:
                if x==y==z:
                    ans += 1
                elif x==y or y==z or z==x:
                    ans += 3
                else:
                    ans += 6
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,n+1):
    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==i:
                    cnt+=1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

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

anss = [0 for _ in range(n)]
visited = []

def dfs(x, y, z): 
    if x+y+z > m or (x, y, z) in visited:
        return
    if p(x, y, z)-1 <= n-1:
        anss[p(x, y, z)-1] += 1
        visited.append((x, y, z)) 
        dfs(x+1, y, z)
        dfs(x, y+1, z)
        dfs(x, y, z+1)

# output
dfs(1,1,1)
for i in range(n):
    print(anss[i])

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

def f(n):
  count = 0
  combs = list(itertools.product(range(1, n), repeat=3))
  for x,y,z in combs:
    
    if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
      count += 1

  return count

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = [0] * (N+1)

for a in range(1, N+1):
    for i in range(1, int(N**0.5)):
        for j in range(1, i+1):
            tmp = a-i**2-j**2-i*j
            if tmp > 0:
                for k in range(1, int(tmp**0.5)+1):
                    tmp2 = k**2+k*(i+j)
                    if tmp == tmp2 and (i==j and j==k and k==i):
                        ans[a] += 1
                    elif tmp == tmp2 and (i != j and j != k and k != i):
                        ans[a] += 6
                    elif tmp == tmp2 and (i==j and j!=k):
                        ans[a] += 3

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from itertools import permutations
N = int(input())


for n in range(1, N+1):
    count = 0
    for i in range(1, 58):
        for j in range(i, 100):
            t = (i+j)**2 - 4 * (i * j + i**2 + j**2 - n)
            if t < 0:
                continue
            k = 0.5 * (-(i + j) + np.sqrt(t))
            if k < j:
                break
            if i**2 + j**2 + k**2 + i * j + j * k + i * k > n:
                break
            if int(k) == k:
                count += len(set(permutations([i, j, int(k)])))
    print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())

x, y, z = 1, 1, 1

f = []
for i in range(N+1):
    f.append(set())

# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f, a=0, b=0, c=0, axis=""):
    # print(x, y, z)
    if axis == "":
        ns = [x**2, y**2, z**2, x*y, y*z, x*z]
    elif axis == "x":
        ns = [x**2, a, b, x*y, c, x*z]
    elif axis == "y":
        ns = [a, y**2, b, x*y, y*z, c]
    elif axis == "z":
        ns = [a, b, z**2, c, y*z, x*z]
    else:
        ns = []
    # n = (x+y+z) ** 2 - (x*y + y*z + x*z)
    n = 0
    for i in range(6):
        n += ns[i]

    if n <= N:
        f[n].add("%d-%d-%d" % (x, y, z))
        # print(n, x, y, z)
        f = calc(x+1, y, z, f, a=ns[1], b=ns[2], c=ns[4], axis="x")
        f = calc(x, y+1, z, f, a=ns[0], b=ns[2], c=ns[5], axis="y")
        f = calc(x, y, z+1, f, a=ns[0], b=ns[1], c=ns[3], axis="z")
        return f
    else:
        return f

f = calc(x, y, z, f)
# while True:
#     f = calc(x, y, z, f)
#     f = calc(x+1, y, z, f)
#     f = calc(x, y+1, z, f)
#     f = calc(x, y, z+1, f)
#     f = calc(x+1, y+1, z, f)
#     f = calc(x, y+1, z+1, f)
#     f = calc(x+1, y, z+1, f)
#
#     x += 1
#     y += 1
#     z += 1
#
#     if x**2 + y**2 + z**2 + x*y + y*z + x*z > N:
#         break

for i in range(1, N+1):
    print(f[i].__len__())

Submission status: Time Limit Exceeded

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

N=int(input())
X=1
Y=1
Z=1
l=[0]*N
ans=0
for n in range(1,N+1):
    for a in range(1,int(math.sqrt(n)-1)+1):
        for b in range(1,int(math.sqrt(n)-1)+1):
            for c in range(1,int(math.sqrt(n)-1)+1):
                if f(a,b,c)==n:
                    l[n-1]+=1
        

for nn in l:
    print(nn)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def F(n):
    ans = 0
    if n < 6:
        return 0
    else:
        for x in range(1,int((n-2)**0.5)+1):
            for y in range(1,int((n-2)**0.5)+1):
                z = (n - 3/4*(x**2+y**2) - 1/2*x*y)**0.5 - (x+y)/2
                if isinstance(z,complex):
                    continue
                if z.is_integer() and z>=1:
                    ans += 1
    return ans
for i in range(1,N+1):
    print(F(i))

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 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:
import math

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

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

    ly = math.ceil(math.sqrt(max(1, n - x2)))

    for y in range(1, ly):
      y2 = y ** 2
      lz = math.ceil(math.sqrt(max(1, n - x2 - y2 - (x * y))))

      for z in range(1, lz):
        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())
result = [0 for x in range(int(math.sqrt(N)**3))]

l = 0
p=0
q=0
t=0
for i in range(1,100):
    p = i*i
    if p>N:
        break
    for j in range(1,100):
        q = p + j*j + j*i
        if q>N:
            break
        for k in range(1,100):
            t  = q + i*k + j*k + k*k
            if t>N:
                break
            result[l] = t
            l+=1
for i in range(1,N+1):
    print(result.count(i))

Submission status: Time Limit Exceeded

Solution code:
import math
 
n = int(input())
li = [0]*n
s = int(math.sqrt(2*n)) - 2
for i in range(1,s):
  for j in range(1,s):
    for k in range(1,s):
      if (i**2+j**2+k**2+i*j+i*k+j*k)<=n:
        if k == j and k == i:
          li[(i**2+j**2+k**2+i*j+i*k+j*k)-1] = 1
        elif k>j and j == i:
          li[(i**2+j**2+k**2+i*j+i*k+j*k)-1] = 3
        elif k>j and j>i:
          li[(i**2+j**2+k**2+i*j+i*k+j*k)-1] = 6
        elif k == j and j>i:
          li[(i**2+j**2+k**2+i*j+i*k+j*k)-1] = 3
for i in li:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
f = [0] * n
sqrt_n = int(math.sqrt(n)) +1
for i in range(n) :
    for x in range(1,sqrt_n) :
        for y in range(1,sqrt_n) :
            for z in range(1,sqrt_n) :
                if x*x+y*y+z*z+x*y+y*z+z*x == i+1 :
                    f[i] += 1
for _ in range(n) :
    print(f[_])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

for i in range(1,n+1):
  count=0
  for x in range(1,101):
    for y in range(1,101):
      for z in range(1,101):
        a=x**2+z**2+(x+y)*(y+z)
        if i<a:
          break
        if i==a:
          count+=1
          
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    for n in range(1,N+1):
        ans = 0
        for x in range(1,int((n//3)**0.5)+1):
            for y in range(1,int((n//3)**0.5)+1):
                pre = x**2 + y**2 + x*y
                uu = n-pre
                if uu<0:
                    break
                for z in range(1,int(uu**0.5)+1):
                    if z*(z+x+y)==uu:
                        if len(set([x,y,z])) == 1:
                            ans = 1
                            break
                        elif len(set([x,y,z])) == 2:
                            ans = 3
                            break
                        else:
                            ans = 6
                            break
        print(ans)



if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
for n in range(1,N+1):
  if n<6:
    print(0)
  else:
    la=np.arange(2,10**4)
    l=la*la
    c=0
    for x in range(len(l)):
      if l[x]*3>2*n:
        break
      else:
        for y in range(x,len(l)):
          if l[x]+2*l[y]>2*n:
            break
          else:
            for z in range(y,len(l)):
              if l[x]+l[y]+l[z]>2*n:
                break
              else:
                
                if l[x]+l[y]+l[z]==2*n:
                  
                  if (x+y+z)%2==0 and x+y+2>z:
                      if l[x]==l[y] and l[y]==l[z]:
                        c+=1
                      elif l[x]==l[y] or l[y]==l[z]:
                        c+=3
                      else:
                        c+=6
                   
    print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

import math

for i in range(1, n+1):
  ans = 0
  if i >= 6:
    for x in range(int(math.sqrt(i//6)), i):
      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) == i:
            if x != y and y != z and z!=x:
              ans += 6
            elif x == y and y == z:
              ans += 1
            else:
              ans += 3
  print(ans)

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


from pprint import pprint

p = []
p_equal = []
for x in range(1, 100):
    for y in range(x, 100):
        for z in range(y, 100):
            p.append((x, y, z))
p_set = set(p)

p_equal = []
p_nonequal = []
for _p in p_set:
    x, y, z = _p[0], _p[1], _p[2]

    if x == y == z:
        p_equal.append(calc(x, y, z))
    else:
        p_nonequal.append(calc(x, y, z))

# print(p_equal)
# print(p_nonequal)

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

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
f = [0] * N
n = math.ceil(math.sqrt(N))

for i in range(1,N+1):
    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 == i):
                    f[i-1] = f[i-1] + 1
                else:
                    continue

[print(a) for a in f]

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

a = list(range(N))[1:]
b = list(itertools.combinations_with_replacement(a, 3))
c = [0] * 1001

count = 0

for i in range(len(b)):
    f = b[i][0] ** 2 + b[i][1] ** 2 + b[i][2] ** 2 + b[i][0] * b[i][1] + b[i][1] * b[i][2] + b[i][2] * b[i][0]
    if f <= 1000:
        c[f] += len(sorted(set(itertools.permutations(b[i]))))

for i in range(1, N + 1):
    print(c[i])

Submission status: Time Limit Exceeded

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

import math

def is_natural(x):
    if x % 1 == 0 and x >= 1:
        return True
    else:
        return False



n = int(input())


for i in range(1, n + 1):
    result = 0
    if i >= 6:
        for j in range(2, int(math.sqrt(2 * i - 8)) + 1):
            for k in range(2, int(math.sqrt(2 * i - 8)) + 1 ):
                if 2 * i - j ** 2 - k ** 2 < 2:
                    break
                else:
                    r = math.sqrt(2 * i - j ** 2 - k ** 2)

                    if r >= 2 and r % 1 == 0:
                        a = j
                        b = k
                        c = r
                        x = (c + a - b) / 2
                        y = (a + b - c) / 2
                        z = (b + c - a) / 2
                        if is_natural(x) and is_natural(y) and is_natural(z):
                            result += 1

    print(result)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
c = 0

for i in range(1,n+1):
    if i % 4 == 0 or i % 8 ==7:
        print(0)
    else:
        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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools

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


def resolve():
    n = int(input().rstrip())

    for m in range(1, n+1):
        xyz_list = []
        for i in range(1, m+1):
            xyz_list.append(i)
        p = itertools.combinations_with_replacement(xyz_list, 3)
        ans_cnt = 0
        for v in p:
            #print(v)
            x, y, z = v
            max_value = max(x, y, z)
            min_value = min(x, y, z)
            if min_value*min_value >= m:
                break
            if max_value*max_value >= m:
                continue

            ans = x*x + y*y + z*z + x*y + y*z + z*x

            if ans == m:
                if x == y == z:
                    ans_cnt += 1
                elif x == y or y == z or x == z:
                    ans_cnt += 3
                else:
                    ans_cnt += 6

        print(ans_cnt)



if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = [(1,1,1)]

def h(w):
    x,y,z = w
    x+=1
    y+=1
    z+=1
    return x**2+y**2+z**2+x*y+x*z+z*y

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

for w in range(1,n+1):
    a = list(filter(lambda b:h(b)>= w,a))
    b = []
    for x,y,z in a:
        if g(x,y,z,w):
            b.append((x,y,z))
        if g(x,y,z+1,w):
            b.append((x,y,z+1))
        if g(x,y+1,z,w):
            b.append((x,y+1,z))
        if g(x+1,y,z,w):
            b.append((x+1,y,z))
    b = list(set(b))
    a += b
    
    print(len(b))

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

n = int(input())

for num in range(1, n+1):
    count = 0
    prod = product(list(range(1, n//4)), repeat=3)
    for i in prod:
        x = i[0]
        y = i[1]
        z = i[2]

        if x**2 + y**2 + z**2 +x*y + y*z + z*x == num:
            count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
x = 0
y =0 
z =0
for m in range(1,N+1):
  l = math.sqrt(m)
  li = int(l)
  count =0
  for i in range(li):
    x = i+1
    for k in range(x):
      y = k+1
      for j in range(y):
        z = j+1
        n = x*x+y*y+z*z+x*y+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())
def f(i):
  co=0
  for z in range(1,7):
    for y in range(1,7):
      for x in range(1,7):
        if x**2+y**2+z**2+z*y+z*x+y*x==i:
          co+=1
        if x**2+y**2+z**2+z*y+z*x+y*x>i:
          break
  return co
for i in range(1,n+1):
  print(f(i))

Submission status: Time Limit Exceeded

Solution code:
#C
N = int(input())
for a in range(1,N+1):
    counter = 0
    for i in range(1,150):
        for j in range(1,150):
            #zについて解いたときの判別式
            k = -3*i**2-3*j**2-2*i*j+4*a
            if k>=0:
                kai = (-1*(i+j)+ k**0.5)/2
                if kai.is_integer() and 1<=kai<=150:
                    counter += 1
    print(counter)

Submission status: Time Limit Exceeded

Solution code:
def tri(n):
    ans = 0
    for i in range(1,int(n**0.5)+1):
        for j in range(1,int(n**0.5)+1):
            for k in range(1,int(n**0.5)+1):
                if i*i + k*k + j*j + i*k + i*j + j*k == n:
                    ans += 1
    return ans

N = int(input())

for i in range(1,N+1):
    if i < 6:
        print(0)
        continue
    print(tri(i))

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
f = [0] * N
n = math.ceil(math.sqrt(2*N))

for i in range(1,N+1):
    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 == i):
                    f[i-1] = f[i-1] + 1
                else:
                    continue

[print(a) for a in f]