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())
ans = []

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

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

for i in range(1, n+1, 1):
    maxn = math.ceil(i**0.5)
    cnt = 0
    flag = False

    for x in range(1, maxn+1):
        if x**2 > i:
            break
        if flag:
            break
        for y in range(x, maxn+1):
            if x**2 + y**2 + x* y > i:
                break
            if flag:
                break
            for z in range(y, maxn+1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    if x == y and y == z:
                        cnt += 1
                    elif x != y and y != z:
                        cnt += 6
                    else:
                        cnt += 3
                    flag = True
                    break
                elif x**2 + y**2 + z**2 + x*y + y*z + z*x > i:
                    break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range(1, N+1):
  ans = 0
  for x in range(1, N+1):
    for y in range(x, N+1):
      for z in range(y, N+1):
        if x*x + y*y +z*z +  x*y + y*z + z*x == n:
          if x == y == z:
            ans += 1
          elif x == y or y == z:
            ans += 3
          else:
            ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
        
    import math

    N = int(input())

    for n in range(1, N + 1):
        max_itr = min(101, int(math.sqrt(n)) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            # for y in range(1, x+1):
            for y in range(1, max_itr):

                # for z in range(1, x+1):
                for z in range(1, max_itr):

                    left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    if (left_eq == n):
                        ans_list = [x, y, z]
                        ans_len = len(set(ans_list))
                        
                        ans += 1
                        
                        # if (ans_len==3):
                        #     ans += 6
                        # elif (ans_len == 2):
                        #     ans += 3
                        # else:
                        #     ans += 1

        
        
        print(ans)



if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
for i in range(1,n+1):
  max = int(math.sqrt(i))
  result = 0
  for x in range(1,max+1):
    max = int(math.sqrt(i - x * x))
    for y in range(1,max+1):
      if i - x * x - y * y - x * y < 1:
        continue
      max = int(math.sqrt(i - x * x - y * y - x * y))
      for z in range(1,max+1):
        if x * x + y * y + z * z + x * y + y * z + x * z == i:
          result += 1
  print(result)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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

        print(count)


if __name__ == "__main__":
    main_v2()

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
N = int(input())
n = int(math.sqrt(N/6))+2
atai = []
for num in range(1,n+1):
  atai += [num]
  
xyz = list(itertools.product(atai,repeat = 3))
for num in range(1,N+1):
  count = 0
  test = 0
  for i in range(len(xyz)):
    test = (xyz[i][0]*xyz[i][0]+xyz[i][1]*xyz[i][1]+xyz[i][2]*xyz[i][2]+xyz[i][0]*xyz[i][1]+xyz[i][0]*xyz[i][2]+xyz[i][1]*xyz[i][2])
    if(i==0)and(test+100<num):
      break
    if(test == num):
      count += 1
  print(count)

Submission status: Time Limit Exceeded

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

for p in range(1, n+1):
  right=math.floor(p**(5/12))+2
  cnt=0
  for i in range(1, right):
    for j in range(1, i+1):
      for k in range(1, j+1):
        if (i+j+k)**2-i*j-j*k-k*i==p:
          if i==j and j==k:
            cnt+=1
          elif i==j and j!=k:
            cnt+=3
          elif j==k and k!=i:
            cnt+=3
          elif k==i and i!=j:
            cnt+=3
          elif i!=j and j!=k and k!=i:
            cnt+=6
  print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(1,n+1):
    ans = 0
    N = int((i*2)**(1/2))+1
    for j in range(1,N+1):
        for k in range(1,j+1):
            for l in range(1, k+1):
                if (j+k)**2 + (k+l)**2 + (l+j)**2 == 2*i:
                    if j==k==l:
                        ans += 1
                    elif j > k > l:
                        ans += 6
                    else:
                        ans += 3
                if (j+k)**2 + (k+l)**2 + (l+j)**2 >= 2*i:
                    break
            if (j+k)**2 > 2*i:
                break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt, floor
from itertools import permutations
from collections import abc

N = int(input())


def f(n):
    MAX = floor(sqrt(n)) + 1
    p = []
    p_a = p.append
    for x in range(1, MAX):
        for y in range(x, MAX):
            for z in range(y, MAX):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    p_a(tuple(permutations((x, y, z))))
    return len(set(sum(p, ())))



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

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest
import numpy as np
import math


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


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


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


resolve()

Submission status: Time Limit Exceeded

Solution code:
import math
# import time

# t1 = time.time()
N = int(input())

for i in range(1,N+1):
    if i <= 10 and i != 6:
        print('0')
    elif i == 6:
        print('1')
    else:
        ans = 0
        limit = int(math.sqrt(i))
        for x in range(1,limit+1):
            if x**2 > i:
                break
            for y in range(1,limit+1):
                if x**2 + y **2 + x*y > i:
                    break
                for z in range(1,limit+1):
                    if x**2 + y ** 2 + z ** 2 + x*y + y*z + z*x == i:
                        ans += 1
        print(ans)
        # if ans != 0:
        #     print(i)
# t2 = time.time()
# print(t2-t1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = [0 for i in range(n)]

for i in range(1,n+1):
  for x in range(1,n+1):
    for y in range(1,n+1):
      for z in range(1,n+1):
        if x**2+y**2+z**2+x*y+y*z+z*x == i:
          ans[i-1]+=1
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

for n in range(1, N + 1):
    cnt = 0
    th = int(np.sqrt(n)) + 1
    for x in range(1, th):
        thy = int(np.sqrt(n - x ** 2)) + 1
        for y in range(1, thy):
            thy = int(np.sqrt(n - x ** 2 - y ** 2)) + 1
            for z in range(1, th):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

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

  for x in range(1, mx + 1):
    x2 = x ** 2
    my = math.ceil(max(0, n - x2))

    for y in range(1, my + 1):
      y2 = y ** 2
      mz = math.ceil(max(0, my - y2));

      for z in range(1, mz + 1):
        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:
n = int(input())
for m in range(n):
    count = 0
    for i in range(n):
        x = i + 1
        xx = x * x
        if  x * x >= n:
            break
        for j in range(n):
            y = j + 1
            yy = y * y
            if xx + yy >= n:
                break
            for k in range(n):
                z = k + 1
                zz = z * z
                if xx + yy + zz + x * y + y * z + z * x > m+1:
                    break
                elif xx + yy + zz + x * y + y * z + z * x == m+1:
                    count += 1
                    break
    print(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[0]*10**7
s=int(n**0.65)+1
for x in range(1,s):
    for y in range(1,s-x):
        for z in range(1,s-x-y):
            l[x*x+y*y+z*z+x*y+y*z+z*x-1]+=1
for i in range(n):
    print(l[i])

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
ans = 0
for z in range(1,n+1):
    ans = 0
    if z-5<0:
        print(0)
        continue
    ma = int(math.sqrt(z- 5))
    for i in range(1,ma+1):
        if z-i**2-2*i<0:
            
            continue
        ma1 = int(math.sqrt(z-i**2-2*i))
        # if z ==6:
        #     print("koko")
        for j in range(1,ma1+1):
            # if z == 6:
                # print(i,j,"dayp")
            if z-i**2-j**2-i-j<0:
                continue
            ma2 = int(math.sqrt(z-i**2-j**2-i-j))
            # if z == 6:
                # print("koko")
            for k in range(1,ma2+1):
                if i**2+j**2+k**2+i*j+j*k+k*i==z:
                    # print(i,j,k)
                    ans +=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def func(n):
    cnt = 0
    for x in range(1, 34):
        for y in range(1, 34):
            for z in range(1, 34):
                if(x**2+y**2+z**2+x*y+y*z+z*x > n):
                    break
                elif(x**2+y**2+z**2+x*y+y*z+z*x == n):
                    cnt += 1
                    break
    return cnt

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

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

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

for i in range(1, N + 1):
    res = 0
    for x in range(1, i):
        for y in range(1, i - x):
            for z in range(1, i - x - y):
                if (x + y + z)**2 - (x*y + z*y + x*z) == i:
                    res += 1
    print(res)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement
def f(n):
    ret = 0
    for x, y, z in combinations_with_replacement(range(1, n), 3):
        if x**2+y**2+z**2+x*y+y*z+z*x==n:
            if x==y==z:
                ret += 1
            elif x==y or y==z or z==x:
                ret += 3
            else:
                ret += 6
    return ret
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):
    cnt = 0
    for x in range(1, 71):
        for y in range(1, 71):
            for z in range(1, 71):
                n = x*x + y*y + z*z + x*y + y*z + z*x
                if i == n:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

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

for i in range(1,N+1,1):
    ans = 0
    for x in range(1,101,1):
        if x*2 >= i:
            break
        for y in range(1,101,1):
            if x**2+y**2 >= i:
                break
            for z in range(1,101,1):
                if x**2+y**2+z**2 >= i:
                    break
                if x**2+y**2+z**2+x*y+y*z+x*z ==i:
                    ans +=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
counts = [0] * N
for x in range(1, N, 1):
    # if x**2>(int(math.sqrt(N))+1):
    # break
    for y in range(1, N, 1):
        # if y**2 > (int(math.sqrt(N))+1):
        # break
        for z in range(1, N, 1):
            # if z**2 > (int(math.sqrt(N))+1):
            # break
            i = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            # print(x,y,z,i)
            if i <= N:
                counts[i - 1] += 1
for k in counts:
    print(k)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def f(num):
    ans=0
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                if x**2+y**2+z**2+x*y+y*z+z*x==num:
                    ans+=1
    return ans

N=int(input())
for i in range(N):
    print(f(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
            for z in range(1,abs(mark-(max(x,y)))):
                if x**2 + y ** 2 + z ** 2 + x*y + y*z + z*x == did:
                    count += 1
    print(count)
    did += 1

Submission status: Time Limit Exceeded

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

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

    ans = 0
    ran = int(math.sqrt(i))
    if ran < 1:
        ran = 1
    for x in range(1, ran):
        for y in range(1, ran):
            for z in range(1, ran):
                xyz = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if i == xyz:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    for i in range(1,n+1):
        cnt = 0
        for x in range(1,int(math.sqrt(i))+1):
            for y in range(1,int(math.sqrt((i-x)))+1):
                rema = i - x**2 - y**2 - x*y
                if rema > 0:
                    for z in range(1, rema):
                        if z**2 + (x+y)*z == rema:
                            cnt += 1
                            break
        print(cnt)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())
s=[]
n=int(N**(0.355))
for a in range (1,n+2):
    for b in range(1,n+2):
        for c in range(1,n+2):
            s.append(a*a+b*b+c*c+a*b+b*c+c*a)
s.sort()

for l in range(1,N+1):
    print(s.count(l))

Submission status: Time Limit Exceeded

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

N=int(input())

A=[]
for i in range(100):
    A.append(i+1)

D=list(itertools.combinations_with_replacement(A, 3))
#print(D)
for j in range(N):
    count=0
    for sa in D:
        if ((sa[0]+sa[1]+sa[2])**2)-(sa[0]*sa[1]+sa[1]*sa[2]+sa[2]*sa[0])==j+1:
            if sa[0]!=sa[1] and sa[1] !=sa[2]:
                
                count+=6
            elif sa[0]==sa[1] and sa[1]==sa[2]:
                count+=1
            else:
                count+=3

    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

for i in range(N):
  n = i+1
  pair = []
  mmax = int(math.sqrt(N)) + 1
  for x in range(1, mmax+2):
    for y in range(x, mmax-x+3):
      for z in reversed(range(y, mmax-x-y+4)):
        if x**2+y**2+z**2+x*y+y*z+z*x == n:
          pair.append((x, y, z))
          break
  ans = 0
  for x, y, z in pair:
    if x == z:
      ans += 1
    elif x == y:
      ans += 3
    elif y == z:
      ans += 3
    else:
      ans += 6
  print(ans)

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):
            fn = i * i + j * j + k * k + i * j + j * k + k * i
            if fn > n:
                break
            ans[fn - 1] += 1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
flag = 0

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

    print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

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

N2 = int(N ** (1 /2) / 2) + 1

list_ans = []

for target in range(1, N + 1):
    b = 0
    for x in range(1, N2 + 1):
        for y in range(x, N2 + 1):
            for z in range(y, N2 + 1):
            #   print("x, y, z, g(x, y, z) =", x, y, z, g(x, y, z))
              if g(x, y, z) == target:
                  tmp = ["".join(map(str, v)) for v in itertools.permutations([x, y, z])]
                  a = set(tmp)
                  b = len(a)
    list_ans.append(b)

for i in list_ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n+1):
    ans = 0
    for x in range(1, int(n ** 0.5) + 1):
        j = min(x+1, int((n-x)**0.5) + 1)
        for y in range(1, j):
            z = 4*i - 3*x**2 - 3*y**2 - 2*x*y
            if z > 0:
                z = z**0.5
                z1 = int(z) - x - y
                z2 = z1 // 2
                if int(z) == z and z1 // 2 >= 1 and z1 % 2 == 0 and z2 <= y:
                    if x != y and y != z2:
                        ans += 6
                    elif x == y and y == z2:
                        ans += 1
                    else:
                        ans += 3
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
from math import sqrt
for k in range(1,n+1):

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

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
z=0
ans=0
for N in range(1,n+1):
    ans=0
    z=0
    for x in range(1,100):
        for y in range(1,100):
            if x**2+y**2<=N:
                if (x+y)**2+4*N-4*(x**2+y**2)-4*x*y>=0:
                    z=((-x-y)+math.sqrt((x+y)**2+4*N-4*(x**2+y**2)-4*x*y))/2
                    #print(x,y,z)
                    if z>=1 and z%1==0:
                        ans+=1
                        #print(x,y,z)
    print(ans)

Submission status: Time Limit Exceeded

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

# 標準入力を取得
N = int(input())

# 求解処理


def has_z(n: int, x: int, y: int) -> bool:
    d = 4 * n - 3 * x**2 - 3 * y**2 - 2 * x * y
    if d < 0:
        return False
    z = (-(x + y) + math.sqrt(d)) / 2
    return (z.is_integer()) and (z >= 1)


for n in range(1, N + 1):
    ans = 0
    max_v = int(math.sqrt(n))
    for x, y in itertools.product(range(1, max_v + 1), repeat=2):
        ans += has_z(n, x, y)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

ans=0
for i in range(1,N+1):
    for j in range(1,N):
        if i <j:
            continue
        for k in range(1,N):
            if i <k:
                continue
            for l in range(1,N):
                if i <l:
                    continue
                if l**2+j**2+k**2+l*j+j*k+k*l==i:
                    ans+=1
    print(ans)
    ans=0

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for a in range(n):
  s=0
  for i in range(n):
    if((3*i+3)**2-(3*(i**2)+6*i+3)==a+1):
      s+=1
      continue
    for j in range(n-i):
      for k in range(n-i-j):
        if((3*i+3)**2-(3*(i**2)+6*i+3)!=a+1):
          if((i+j+k+3)**2-(i*j+j*k+k*i+2*i+2*j+2*k+3)==a+1):
            s+=1
  print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for i in range(N):
    count = 0
    for x in range(N):
        for y in range(N):
            for z in range(N):
                ans = (x+1)**2 + (y+1)**2 + (z+1)**2 + (x+1)*(y+1) + (y+1)*(z+1) + (z+1)*(x+1)
                if(i+1 == ans):
                    count += 1
                else:
                    pass
    print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())
s=[]
n=int(N**(0.36))
for a in range (1,n+2):
    for b in range(1,n+2):
        for c in range(1,n+2):
            s.append(a*a+b*b+c*c+a*b+b*c+c*a)
s.sort()

for l in range(1,N+1):
    print(s.count(l))

Submission status: Time Limit Exceeded

Solution code:
# import sys
import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    for i in range(1,n+1):
        ans = 0
        for x in range(1,int(i**0.5+1)):
            for y in range(1,int(i**0.5+1)):
                z1 = (-(x+y)+((x+y)**2-4*(x**2+y**2+x*y-i))**0.5)/2
                if not isinstance(z1,complex):
                    if int(z1)==z1 and z1>=1:
                        ans += 1
                z2 = (-(x+y)-((x+y)**2-4*(x**2+y**2+x*y-i))**0.5)/2
                if not isinstance(z2,complex):
                    if int(z2)==z2 and z2>=1:
                        ans += 1
        print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
N = int(sys.stdin.readline())

for i in range(1,N+1):
  ans = 0
  n = math.ceil(math.sqrt(i))
  for j in range(1,n):
    wan = n - j
    n_sub_j = i - j*j
    if n_sub_j <= 0:
      break
    for k in range(1,wan):
      n_sub = n_sub_j - k*(j + k)
      if n_sub <= 0:
        break
      b = j + k
      check = ((b**2 + 4*n_sub) ** (1/2) - b)
      if check % 2 == 0:
        ans +=1
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement
N = int(input())
choise = [1]
for i in range(1,N+1):
    if (i**2*6) > (choise[-1]**2*6):
        choise.append(choise[-1]+1)
    tmp = 0
    for j in combinations_with_replacement(choise,3):
        n = j[0]**2+j[1]**2+j[2]**2+j[0]*j[1]+j[1]*j[2]+j[0]*j[2]
        if n == i:
            if j[0]==j[1] and j[1]==j[2]:
                tmp+=1
            else:
                tmp+=3
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
import sys


def f(i):
    ans = 0
    for x in range(1, 33):
        for y in range(x, 33):
            if x ** 2 + y ** 2 > i:
                break
            for z in range(y, 33):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if i == n:
                    a = len(set((x, y, z)))
                    if a == 1:
                        ans += 1
                    elif a == 2:
                        ans += 3
                    elif a == 3:
                        ans += 6
                    break
                elif i < n:
                    break

    return ans

def resolve(in_):
    n = int(in_.readline())
    for i in range(1, n + 1):
        yield f(i)



def main():
    for answer in resolve(sys.stdin.buffer):
        print(answer)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def calc(n):
    if n < 6:
        return 0
    ans = 0
    for x in range(1, int(n**0.5)):
        for y in range(1, int(n**0.5)):
            for z in range(1, int(n**0.5)):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    ans += 1

    return ans

for i in range(1, n+1):
    print(calc(i))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x,y,z = [0,0,0]

for i in range(1,N+1):
    ans = 0
    if i < 6:
        print(0)
        continue
    for j in range(1,int(i**0.5)+1):
        for k in range(1,int(i**0.5)+1):
            for m in range(1,int(i**0.5)+1):
                if j**2 + k**2 + m**2 +j*k + j*m + m*k == i:
                    ans += 1
                    break
                if j**2 + k**2 + m**2 +j*k + j*m + m*k > i:
                    break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def f(x, y, z):
  return (x + y + z) ** 2 - (x * y + y * z + z * x)
cnts = []

for i in range(1, N+1):
  cnt = 0
  for j in range(1, int(i ** (1/2)) + 1):
    for k in range(1, int(i ** (1/2)) + 1):
      if ((j + k) ** 2 - j * k) > i:
        break
      for l in range(1, int(i ** (1/2)) + 1):
        if f(j, k, l) == i:
          # print(j, k, l, " ", i)
          cnt += 1
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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+1))//3+1):
        for k in range(j,int((n**0.5+1))//3+2):
            for l in range(k,int((n**0.5+1))//3+3):
                if j**2 + k **2 + l**2 + j*k + k*l + l*j == i and j == k == l:
                    L[i-1] += 1
                if j**2 + k **2 + l**2 + j*k + k*l + l*j == i and j == k and j!=l:
                    L[i-1] += 3
                if j**2 + k **2 + l**2 + j*k + k*l + l*j == i and j != k and k==l:
                    L[i-1] += 3
                if j**2 + k **2 + l**2 + j*k + k*l + l*j == i and j != k and j!=l and k!=l:
                    L[i-1] += 6
for m in range(n):
    print(L[m])

Submission status: Time Limit Exceeded

Solution code:
import math

def func(n):
    cnt = 0
    sqrtn = int(math.sqrt(n))
    for x in range(1,sqrtn+1):
        for y in range(1,sqrtn+1):
            for z in range(1,sqrtn+1):
                if x**2 + y**2 + z**2 +x*y + y*z + z*x == n:
                    cnt += 1
    return cnt
N = int(input())

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