Problem:


Score : 300 points

Problem Statement

Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:

1 \leq x,y,z

x^2 + y^2 + z^2 + xy + yz + zx = n

Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Constraints

All values in input are integers.

1 \leq N \leq 10^4

Input

Input is given from Standard Input in the following format:

N

Output

Print N lines. The i-th line should contain the value f(i).

Sample Input 1

20

Sample Output 1

0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.

For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.

For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.

For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.



Sample input:
20


Sample output:
0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = n//3
for l in range(n):
    c = 0
    l += 1
    for i in range(x):
        i += 1
        for j in range(x):
            j += 1
            for k in range(x):
                k += 1
                m = i*i+j*j+k*k+i*j+j*k+k*i
                if m == l:
                    c += 1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
ans = 0

for i in range(1, n+1):
  for x in range(1, math.ceil(math.sqrt(n))):
    for y in range(1, math.ceil(math.sqrt(n-x**2))):
      for z in range(1, math.ceil(math.sqrt(n-x**2-y**2))):
        if x**2 + y **2 + z**2 + x*y + y*z + z*x == i:
          ans += 1
  print(ans)
  ans = 0

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
rn = int(math.sqrt(n))
for i in range(1, n+1):
  count = 0
  for x in range(1, rn):
    for y in range(1, rn):
      for z in range(1, rn):
        if x*x + y*y + z*z + x*z + x*y + y*z == i:
          count += 1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
match = []

for i in range(1, int((2*N)**(1/2)+1)):
  for j in range(i, int((2*N)**(1/2)+1)):
    for k in range(j, int((2*N)**(1/2)+1)):
      matched = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if i==j==k:
        count = 1
      elif i==j or j==k:
        count = 3
      else:
        count = 6
      for l in range(count):
        match.append(int(matched))

match.sort()

for i in range(1,N+1):
  num = 0
  while i == match[0]:
    match = match[1:]
    num += 1
  print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import numpy as np
#max=int(np.sqrt(N))

for n in range(1,N+1):
    j=0
    min = 1
    max = int(np.sqrt(n/3))+2
    #print(f'max:{max}')
    for x in range(min,max):
        #print(f'max:{max}')
        for y in range(min, max):
            for z in range(min, max):
                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:
                    #print(f'n!!:{n}')
                    if x == y == z:
                        max=x
                        min=x
                        j += 1
                        #print(x, y, z)
                        #print(f'n:{n}')
                        break
                    if j==0:
                        max = z+1
                        min += 1
                        #min = x
                        #print(x, y, z)
                        #print(f'n:{n}')
                        j += 3
                    # else:
                    #     j += 3

    print(j)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

a = int(input())
cnt = 0
ans = []
l = list(range(1,int(math.sqrt(a))))

for x,y,z in itertools.product(l, repeat=3):
	ans.append(x*x+y*y+z*z+x*y+y*z+z*x)

for i in range(1,a+1):
    print(ans.count(i))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
comb=[]
ans=[]


for k in range(1, n+1):
    flag=False
    for x in range(1, 80):
        if 6*x**2 > k:
            break
        else:
            for y in range(x, 80):
                for z in range(y, 80):
                    if (x+y+z)**2 - x*y-y*z-z*x==k:
                        comb.append((x,y,z))
                        flag=True
                        break
    
    if flag:
        pass
    else:
        comb.append((0, 0, 0))


for s in range(n):
    if comb[s][0]==comb[s][1]==comb[s][2]==0:
        ans.append(0)
    elif comb[s][0]==comb[s][1]==comb[s][2]!=0:
        ans.append(1)
    elif comb[s][0]!=comb[s][1] and comb[s][1]!=comb[s][2] and comb[s][2]!=comb[s][0]:
        ans.append(6)
    else:
        ans.append(3)

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

Submission status: Time Limit Exceeded

Solution code:
import math
def equation(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)

    return x_1, x_2



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

    for n in range(1, N+1):
        cnt = 0
        for y in range(1, int(math.sqrt(n))):
            for z in range(1, int(math.sqrt(n))):
                x_1, x_2 = equation(1, y+z, y**2 + y*z + z**2 - n)

                if isinstance(x_1, float):
                    x_1 = round(x_1, 5)
                    if x_1.is_integer() == True and x_1 >= 1:
                        cnt += 1

                if isinstance(x_2, float):
                    x_2 = round(x_2, 5)
                    if x_2.is_integer() == True and x_2 >= 1:
                        cnt += 1

        print(cnt)




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#coding: UTF-8
import math
N = int(input())
#print(N)

ans = [0]*N

for i in range(1,N+1):
  if i <=5:
    ans[i-1] = 0
    continue
  cnt = 0
  m = int(math.sqrt(i))
  #print(i,m)
  #平方根までやれば十分
  for x in range(1,m+1):
    if x >= int(math.sqrt(i/6))+1:
      break
    for y in range(x,m+1):
      if y >= int(math.sqrt(i/2))+1:
        break
      if i - x**2 -y**2 -x*y < 1+x+y:
        break
      for z in range(y,m+1):
        a = (x+y+z)**2 -x*y -y*z - z*x
        if a < i:
          continue
        if a == i:
          if x==y==z:
            cnt += 1
            break
          elif x==y or y==z:
            cnt += 3
            break
          else:
            cnt += 6
            break
        else: break
  ans[i-1] = cnt
print('\n'.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

"""
xx = []
xy = []
xyz = []

for i in range(1, N + 1):
    xxl.append(i ** 2)

for i in range(1, N + 1):
    for j in range(1, N + 1):
        xyl.append(i * j)

xyl = set(xyl)
xyl = list(xyl)
"""


for n in range(1, N + 1):
    count = 0
    for x in range(1, 100):
        if x > n:
            break

        for y in range(1, 100):
            if y > n:
                break

            for z in range(1, 100):
                if z > n:
                    break

                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    count = count + 1
                elif x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > n:
                    break

    print(count)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement


n = int(input())

for i in range(1, n+1):
    count = 0
    n_list = list(combinations_with_replacement([j for j in range(1, i//6+2)], 3))
    for x in n_list:

        if x[0]**2 + x[1]**2 + x[2]**2 + x[0]*x[1] + x[1]*x[2] + x[2]*x[0] == i:
            if x.count(x[0]) == 2 or (x.count(x[0]) == 1 and x.count(x[1]) == 2):
                count += 3
            elif x.count(x[0]) == 1 and x.count(x[1]) == 1 and x.count(x[2]) == 1:
                count += 6
            else:
                count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1,N+1):
  count = 0
  aa = math.ceil(i**0.3)
  for j in range(1,aa+1):
    for k in range(1,j+1):
      for l in range(1,k+1):
        if j**2+k**2+l**2+j*k+j*l+k*l == i:
          if j == k == l:
            count += 1
          elif j != k != l:
            count += 6
          else:
            count += 3
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
last = 0
#3つバラバラ
count = [0]*(n+1)
for n in range(1,n+1):
  for x in range(1,n+1):
    if x**2 > n:
      break
    for y in range(x+1,34):
      if (x**2 + y**2) > n:
        continue
      for z in range(y+1,34):
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
          count[n] += 6
        if x**2 + y**2 + z**2 + x*y + y*z + z*x >= n:
          break
  for x in range(1,n+1):
    if 6*(x**2) == n:
      count[n] += 1
    if 6*(x**2) >= n:
      break
  for y in range(1,n+1):
    for z in range(y+1,34):
      if y**2 + y**2 + z**2 + y*y + y*z + z*y == n:
        count[n] += 3
      elif y**2 + z**2 + z**2 + z*y + y*z + z*z == n:
        count[n] += 3
      if y**2 + y**2 + z**2 + y*y + y*z + z*y > n:
        break
        
      
          
[print(count[i]) for i in range(1,n+1)]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
c = 0
n = 0
list = []
for l in range(1,N+1):
    list = []
    for i in range(1,l+1):
        if i*i > l:
            break;       
        for j in range(1,l+1):
            if i*i + j*j + i*j > l:
                break;
            for k in range(1,l+1):
                #print(i,j,k,l)
                if i*i + j*j + k*k + i*j +j*k + i*k == l:
                    list.append(1)
                    break;
    print(sum(list))

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
ans = []
for i in range(1,N+1):
    s = 0
    t = math.sqrt(i)
    t1 = int(t)
    for x in range(1,t1):
        for y in range(1,t1):
            for z in range(1,t1):
                if x**2+y**2+z**2+x*y+y*z+z*x == i:
                    s += 1
    ans.append(s)
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
def g(x,y,z):
    t = x**2 + y**2 + z**2 + x*y + y*z + z*x
    #print(x,y,z,t)
    return t
ans = []
def f(n):
    #sum = 0
    rn = int(math.sqrt(n))
    for i in range(1,rn+1):
        #print(i,end='')
        for j in range(1,rn+1):
            for k in range(1,rn+1):
                #print(i,j,k)
                t = g(i,j,k)
                if t == n:
                    if (i == j and j==k):
                        #sum += 1
                        ans.append(str(1))
                        return
                    elif (i == j and j != k and i != k) or (i == k and j != k and i != j) or (i != j and j == k and i != k):
                        #sum += 3
                        ans.append(str(3))
                        return
                    else:#elif i != j and i != k and j != k:
                        #sum += 6
                        ans.append(str(6))
                        return
                elif t > n:
                    break
    ans.append(str(0))
                

    

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


print('\n'.join(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,42):
    for y in range(x,60):
      for z in range(y,100):
        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
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
r = int( math.sqrt(2 * 10000))
n = int(input())
point_dict = {}
for x in range(2, r+1):
  for y in range(2, r+1):
    for z in range(2, r+1):
      point_dict[x**2 + y**2 + z**2] = point_dict[x**2 + y**2 + z**2] + 1 if point_dict.get(x**2 + y**2 + z**2) else 1

for i in range (1, n+1):
  if point_dict.get(2 * i):
    print(point_dict[2 * i])
  else:
    print(0)

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(x, rng):
            for z in range(y, rng):
                if (x+y) ** 2 + (y+z) ** 2 + (z+x) ** 2 == 2 * n:
                    count = check([x, y, z])
    return count


def check(A):
    a, b, c = A[0], A[1], A[2]
    count = 0
    if a == b and b == c:
        count = 1
    elif a == b:
        count = 3
    elif b == c:
        count = 3
    else:
        count = 6
    return count


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

Submission status: Time Limit Exceeded

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

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

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):
                    break
                elif(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 numpy as np
n = int(input())
last = 0
#3つバラバラ
count = [0]*(n+1)
for n in range(1,n+1):
  for x in range(1,n+1):
    if x**2 > n:
      continue
    for y in range(x+1,34):
      if (x**2 + y**2) > n:
        continue
      for z in range(y+1,34):
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
          count[n] += 6
        if x**2 + y**2 + z**2 + x*y + y*z + z*x >= n:
          break
  for x in range(1,n+1):
    if 6*(x**2) == n:
      count[n] += 1
    if 6*(x**2) >= n:
      break
  for y in range(1,n+1):
    for z in range(y+1,34):
      if y**2 + y**2 + z**2 + y*y + y*z + z*y == n:
        count[n] += 3
      elif y**2 + z**2 + z**2 + z*y + y*z + z*z == n:
        count[n] += 3
      if y**2 + y**2 + z**2 + y*y + y*z + z*y > n:
        break
        
      
          
[print(count[i]) for i in range(1,n+1)]

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))
    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 math
N = int(input()) 

for n in range(1, N + 1):
    sum = 0
    root = int(math.sqrt(2*n))
    min = int(math.sqrt(2*n/3))
    if n<4:
        print(sum)
        continue
    for u in range(min - 1, root):
        for v in range(u, root):
            #if u*u + v*v >= 2*n:
                #break
            for w in range(v, int(root)):
                if u*u + v*v + w*w > 2*n:
                    break
                if u*u + v*v + w*w == 2*n:
                    x = int((u - v + w)/2)
                    y = int((u + v - w)/2)
                    z = int((-u + v + w)/2)
                    if (x > 0 and y > 0 and z > 0):
                        if x == y and y == z:
                            sum += 1
                        elif x == y or y == z or z == x:
                            sum += 3
                        else:
                            sum += 6
                        
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
def f(n,N):
    cnt = 0
    for x in range(1,N):
        for y in range(1, N):
            for z in range(1,N):
                if (((x**2 )+(y**2) +(z**2) +x*y +y*z+ z*x)) == n:
                    cnt += 1

    return cnt
N=int(input())
for i in range(1,N+1):
    print(f(i,N))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
count = 0
for i in range(1, N + 1):
    
    for j in range(1, N // 2):
        for l in range(1, N // 2):
            for r in range(1, N // 2):
                if j ** 2 + l ** 2 + r ** 2 + j * l + j * r + l * r == i:
                    if j == l == r:
                        count = 1
                        break
                    else:
                        count = 3
                        break
                    
    print(count)
    count = 0

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

for k in range(1,n+1):

    ans=0
    for x in range(1,51):
        if k-x**2<=0:
            break
        for y in range(1,51):
            if k-x**2- y**2<=0:
                break

            for z in range(1,51):
                if x**2 + y**2 + z**2 +x*y + y*z + z*x ==k:
                    ans+=1
                    break


    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
import math

if __name__ == "__main__":
    N = int(sys.stdin.readline())

    for i in range(1, N+1):
        ans = 0
        ls = range(1, int(math.sqrt(i)))
        # ls = range(1, int(math.sqrt(i))-2*i)
        # print(ls)
        for (x,y,z) in sorted(itertools.combinations_with_replacement(ls, 3), key=lambda x: (sum(x), max(x))):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if tmp > i:
                break
            elif i == tmp:
                ans += 1
                if x == y and y == z:
                    continue
                elif x == y or y == z or z == x:
                    ans += 3-1
                else:
                    ans += 6-1
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
comb=[]
ans=[]


for k in range(1, n+1):
    flag=False
    for x in range(1, 100):
        if 6*x**2 > k:
            break
        else:
            for y in range(x, 100):
                for z in range(y, 100):
                    if (x+y+z)**2 - x*y-y*z-z*x==k:
                        comb.append((x,y,z))
                        flag=True
                        break
    
    if flag:
        pass
    else:
        comb.append((0, 0, 0))


for s in range(n):
    if comb[s][0]==comb[s][1]==comb[s][2]==0:
        ans.append(0)
    elif comb[s][0]==comb[s][1]==comb[s][2]!=0:
        ans.append(1)
    elif comb[s][0]!=comb[s][1] and comb[s][1]!=comb[s][2] and comb[s][2]!=comb[s][0]:
        ans.append(6)
    else:
        ans.append(3)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = []

for i in range(1, n + 1):
  cnt = 0
  for x in range(1, 41):
    for y in range(x, 41):
      for z in range(y, 100):
        if (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 == i * 2:
          if x != y and y != z and z != x:
            cnt += 6
          elif x == y == z:
            cnt += 1
          else:
            cnt += 3
  ans.append(cnt)
for j in range(n):
  print(ans[j])

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)
    b = []   
    N = int(input())
    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:
N = int(input())
c = 0
n = 0
list = []
for l in range(1,N+1):
    list = []
    for i in range(1,l+1):
        if i*i > l:
            break;       
        for j in range(1,l+1):
            if i*i + j*j + i*j > l:
                break;
            for k in range(1,l+1):
                #print(i,j,k,l)
                if i*i + j*j + k*k + i*j +j*k + i*k > l:
                    break;
                if i*i + j*j + k*k + i*j +j*k + i*k == l:
                    list.append(1)
                    break;
    print(sum(list))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

result_list = [0] * n

half = int(n/2)

for x in range(1, half):
    for y in range(1, half):
        for z in range(1, half):
            calculated_n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if calculated_n <= n+1:
                result_list[calculated_n-1] += 1



for n in result_list:
    print(n)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def func(n):
  ret = 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+j)**2+(j+k)**2+(k+i)**2 == 2*n:
          ret += 1
  return ret
ansadd1 = [30,18,66,0,60,30,48,36,48,0,24,6,39,24,96,12,90,33,36,6,39,6,90,27,36,0,60,12,45,42,30,30,72,12,36,9,39,36,69,24,48,0,36,6,66,15,72,39,36,27,54,18,57,30,42,12,60,0,84,24,36,27,72,12,48,21,60,0,51,30,27,30,90,0,78,0,42,57,12,30,48,18,42,6,48,24,90,15,42,0,12,15,84,24,72,18,48,21,66,3,54,42,30,24,48,0,36,18,27,12,42,9,108,18,36,12,96,24,21,30,24,0,96,9,54,18,75,30,54,18,36,0,39,18,84,18,42,0,24,6,54,18,57,42,24,9,84,18,48,42,27,30,78,0,60,0,30,48,36,6,30,36,6,10,78,12,51,48,48,0,90,0,75,9,42,24,48,15,72,12,33,42,108,12,54,0,54,18,51,42,36,48,48,12,72,0,42,18,45,30,66,0,78,3,36,15,78,30,30,30,30,15,102,12,54,18,30,0,36,6,81,48,12,24,108,6,78,18,24,36,33,18,30,0,30,0,108,21,54,42,18,18,90,6,30,48,69,36,48,0,24,15,24,15,84,24,114,6,30,0,48,6,60,42,24,0,102,12,42,42,27,21,78,9,42,24,51,24,42,12,48,0,60,12,66,6,42,24,30,24,42,0,78,24,54,12,66,0,30,6,24,51,99,18,60,24,42,18,54,6,45,60,36,0,54,6,39,39,39,30,66,18,72,0,51,24,102,12,54,0,24,0,102,12,48,24,42,36,60,0,12,48,18,12,54,0,84,18,39,9,84,30,66,18,48,15,72,48,39,42,48,0,60,0,84,30,45,33,54,6,54,30,33,30,90,6,54,0,24,6,72,27,78,12,24,15,66,0,54,36,21,42,114,0,60,3,30,33,54,27,30,33,60,6,54,12,48,33,36,0,42,12,45,39,24,36,96,18,24,12,33,18,99,18,66,0,36,0,51,24,30,30,36,15,84,6,102,48,48,18,60,0,72,12,36,42,60,12,24,21,30,0,54,18,60,18,42,0,66,6,24,24,54,15,78,12,42,27,27,30,51,27,78,0,48,6,120,27,48,42,24,12,54,6,54,24,48,36,66,0,78,9,57,21,48,18,54,33,24,30]
ansadd2 = [84,18,45,33,30,0,126,9,36,30,27,30,66,18,54,0,36,42,48,6,42,0,54,6,57,12,84,54,48,6,60,6,63,18,42,36,78,0,24,24,33,24,105,24,66,27,48,0,48,30,60,30,54,0,42,3,75,48,24,12,66,12,96,6,30,12,87,21,36,0,30,24,69,12,57,30,48,24,54,0,42,54,24,24,72,0,60,0,48,24,69,24,42,18,36,12,66,24,36,42,18,0,78,9,48,36,42,42,36,12,36,21,78,18,48,12,102,0,18,12,54,24,45,27,42,13,108,12,39,24,42,27,102,0,60,6,39,24,54,12,54,24,24,0,114,24,63,48,30,0,48,6,69,36,18,12,72,6,48,18,33,54,117,12,42,0,66,12,48,6,54,36,42,21,102,6,48,54,33,30,48,0,72,0,30,24,75,24,84,30,30,0,72,18,30,42,54,0,60,12,36,45,42,12,96,6,66,0,12,36,78,36,42,0,36,0,78,24,48,24,18,30,90,15,96,18,27,21,54,0,24,21,48,27,84,18,48,42,36,6,66,12,108,12,42,0,48,9,27,60,21,36,84,6,36,18,42,18,54,18,60,0,60,15,72,9,99,42,12,12,60,0,57,42,18,18,78,0,42,6,36,36,63,9,42,15,30,18,78,6,24,48,42,0,102,12,75,45,42,30,84,24,66,9,24,30,90,24,42,0,24,3,84,21,84,33,66,24,36,6,36,48,51,18,72,0,66,18,54,30,24,18,48,18,30,0,102,12,45,36,24,0,102,3,42,15,42,54,54,21,66,24,66,30,102,3,66,0,48,12,24,30,45,36,54,6,78,9,48,24,39,36,96,0,66,6,27,27,60,30,18,30,48,12,90,24,60,36,6,0,42,12,78,36,36,24,114,6,60,0,18,6,69,18,84,0,36,6,48,6,39,24,42,24,54,6,72,48,36,42,60,0,48,0,36,18,138,24,30,30,42,18,75,18,48,18,24,0,78,0,78,57,60,9,48,9,36,30,30,42,42,39,84,0,24,12,87,27,30,42,24,24,90,0,36,24,60,36,84,0,42,0,30,21,87,12,72,24,42,12,60,30,72,21,60,0,96,12,30,42,39,18,66,12,84,12,63,42,42,24,42,0,18,6,78,15,75,45,54,12,54,6,84,30,30,18,54,0,42,24,39,27,96,18,42,21,48,0,54,18,33,36,66,0,84,0,75,48,30,42,54,12,54,15,42,30,96,18,42,0,18,6,123,15,48,24,48,39,42,6,21,54,45,12,60,0,90,12,30,36,45,18,72,21,78,12,30,12,60,30,18,0,78,6,60,36,33,18,60,12,30,0,60,18,90,30,54,0,36,1,78,27,84,30,18,15,102,9,27,30,24,57,90,0,42,9,48,42,42,12,72,27,48,9,108,18,48,48,18,0,84,6,66,24,48,21,114,6,78,24,30,30,42,18,60,0,18,12,63,9,51,66,48,15,54,0,66,60,36,18,48,0,66,6,36,30,96,9,36,30,30,24,93,24,72,24,66,0,60,24,48,30,24,30,72,6,60,12,30,12,93,18,72,0,30,0,81,30,36,48,36,30,90,6,54,24,57,24,36,0,54,18,36,24,78,18,72,33,12,0,51,30,48,24,42,0,90,3,78,30,30,27,138,6,30,18,36,24,75,24,12,0,54,12,42,18,84,36,30,18,66,6,45,36,36,48,114,0,24,6,30,21,108,15,48,18,36,18,57,24,63,42,54,0,78,6,81,36,18,24,42,18,120,0,24,24,66,12,54,0,48,12,66,18,42,36,48,18,72,6,48,48,33,6,102,0,54,24,39,54,60,12,90,18,36,3,111,24,51,48,42,0,90,0,45,36,54,48,54,24,18,18,51,18,72,0,54,0,18,12,54,36,57,18,42,18,120,0,63,42,27,36,48,0,54,6,39,30,81,18,72,33,54,9,72,12,54,54,24,0,54,15,75,24,60,12,78,6,30,12,39,54,72,6,54,0,72,6,78,12,54,39,30,15,48,6,57,48,18,24,90,0,90,18,42,24,39,42,24,30,42,0,84,6,66,30,30,0,30,0,27,42,39,33,90,24,84,18,51,36,69,24,54,0,42,18,87,33,51,18,42,9,126,9,84,36,66,18,54,0,36,0,66,12,48,15,54,30,18,18,60,18,96,54,42,0,102,0,27,36,30,36,108,15,54,0,24,36,60,24,66,0,30,0,54,15,75,48,36,18,48,24,36,36,54,15,108,0,84,18]
annsadd = ansadd1 + ansadd2
if N <= 9000:
  for i in range(1,N+1):
    print(func(i))
else:
  for i in range(1,8500):
    print(func(i))
  for i in range(8501,N):
    print(ansadd[i-8501])

Submission status: Time Limit Exceeded

Solution code:
import math
for n in range(1, int(input())+1):
    b=0
    a=[0]*(n+2)
    for i in range(1, n+1):
        if a[i]: continue
        for j in range(1, n+1):
            if a[j]: continue
            # we know z at this point
            d = i + j
            c = n - i**2 - j**2 - i*j
            try:
                k = int(math.sqrt(d**2 + 4*c) - d - 1)
                if k < 1: continue
                if n == (i**2 + j**2 + k**2 + i*j + j*k + i*k):
                    a[i] = True
                    a[j] = True
                    a[k] = True
                    if i == j and i == k and j == k:
                        b+= 1
                    elif i != j and i != k and j !=k:
                        b+=6
                    else:
                        b+=3
            except:
                pass
    print(b)

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
    
    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):
          #z>y
          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)):
             if n == x**2 + y**2 + z**2 + x*z + x*y + y*z:
                ans+=6
          if n == y**2 + y**2 + z**2 + y*z + y*y + y*z   :
              ans+=3
        #y=z !=z
        if n-5*z**2<=0:
            x_low=1
        else:
            x_low=int((n-5*z**2)**0.5)
        for x in range (x_low, z):
             if n == x**2 + z**2 + z**2 + x*z + x*z + z*z:
                ans+=3
        #x=y=z
        if 6*z**2==n:
            ans+=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement

N = int(input())

ans = [0 for _ in range(1,N+1)]

for v in combinations_with_replacement(range(1,(N//6)+1), 3):
    x,y,z = v
    count = 0
    if x == y == z:
        fn = 6 * x * x
        count = 1
    else:
        fn = x*x + y*y + z*z + x*y + y*z + z*x
        count = 3
    if N >= fn:
        ans[fn-1] += count

print(*ans, sep='\n')

Submission status: Time Limit Exceeded

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

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):
            z = (i - (x**2+y**2)*3/4 -x*y/2)**0.5 - (x+y)/2
            if is_integer_num(z)==True and 1<=z <= y <= x:
                s = {x, y, z}
                for k in range(len(s)):
                    ans+= (k+1)
                break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
import functools

N =  int(input().strip())

@functools.lru_cache
def calc(x, y, z):
    return x * x + y * y + z * z + x* y + y * z + z * x


def func(n):
    # print(f"{n} ===")
    cnt = 0
    k = math.floor(math.sqrt(n))
    for v in itertools.product(range(1, k+1), repeat=3):
        # print(v)
        if calc(*sorted(v)) == n:
            cnt += 1
    return cnt


for k in range(1, N+1):
    cnt = func(k)
    print(cnt)

Submission status: Time Limit Exceeded

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

for n in range(1, N + 1):
    sum = 0
    root = int(math.sqrt(2*n))
    min = int(math.sqrt(2*n/3))
    if n<4:
        print(sum)
        continue
    for u in range(min - 1, root):
        for v in range(u, root):
            #if u*u + v*v >= 2*n:
                #break
            for w in range(v, int(root)):
                #if u*u + v*v + w*w > 2*n:
                    #break
                if u*u + v*v + w*w == 2*n:
                    x = int((u - v + w)/2)
                    y = int((u + v - w)/2)
                    z = int((-u + v + w)/2)
                    if (x > 0 and y > 0 and z > 0):
                        if x == y and y == z:
                            sum += 1
                        elif x == y or y == z or z == x:
                            sum += 3
                        else:
                            sum += 6
                        
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


for n in range(1, N+1):
  answer = 0
  for x in range(1, 50):
    for z in range(1, 50):
      if 3* x**2 + z**2 + 2*x*z == n:
        num_pair = [x, z]
        if num_pair[0] == num_pair[1]:
          answer = 1
          break
        else:
          answer = 3
          break
    if answer != 0:
      break
    

  print(answer)