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())
b = []
for i in range(1,N+1):
    if (i<6):
        print(0)
    else:
        for x in range(1,i):
            for y in range(1,i):
                for z in range(1,i):
                    aa = (x+y+z)**2 -(x*y+y*z+z*x)
                    if aa == i:
                        b.append(i)
        print(len(b))
        b.clear()

Submission status: Time Limit Exceeded

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

N=int(input())
for i in range(1,N+1):
  cnt=0
  listx=list(range(1,i-2))
  for x in listx:
    for y in range(1,i-x+1):
      for z in range(1,i-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:
from itertools import product
n = int(input())

nums = [0]*(n+1)
for i in product(range(1, n//6+1),repeat=3):
  t = i[0]**2 + i[1]**2 + i[2]**2 + i[0]*i[1] + i[1]*i[2] + i[0]*i[2]
  if t <= n: nums[t] += 1

for i in range(1,n+1): print(nums[i])

Submission status: Time Limit Exceeded

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

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


[print(a) for a in f]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
import math

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


def resolve():
    n = int(input().rstrip())
    for m in range(1, n+1):

        max_n = math.sqrt(m)
        max_n = math.ceil(max_n)
        p = itertools.combinations_with_replacement(range(1,max_n+1), 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())

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

Submission status: Time Limit Exceeded

Solution code:
import math


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


def check(ans):
    cnt = 0
    upper = int(math.sqrt(ans))
    for x in range(1, upper):
        if pow(x, 2) > ans:
            break
        for y in range(x, upper):
            if pow(x+y, 2) > ans:
                break
            for z in range(y, upper):
                tmp = x*(x+y+z) + y*(y+z) + z*z
                #tmp = pow(x+y+z, 2) - x*(y+z) - y*z
                if tmp == ans:
                    cnt += pattern(x, y, z)
                elif tmp > ans:
                    break
    print(cnt)


N = int(input())
# x^2 + y^2 + z^2 + x*y + y*z + z*x = n

for i in range(1, N+1):
    #upper_value = int(math.sqrt(i))
    check(i)

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(1, int((2*N)**(1/2)+1)):
    for k in range(1, int((2*N)**(1/2)+1)):
      matched = i**2 + j**2 + k**2 + i*j + j*k + k*i
      match.append(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())
for i in range(1,n+1):
	cnt = 0
	for x in range(1,14):
		for y in range(1,14):
			for z in range(1,14):
				if x**2 + y**2 + z**2 + (x*(y+z)) + (y*z) == i:
					cnt += 1
	print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

for i in range(1, n + 1):
    cnt = 0
    t = math.floor(i - (i ** 0.5)) + 1
    for j in range(1, t):
        for k in range(1, t):
            for l in range(1, t):
                if ((j ** 2) + (k ** 2) + (l ** 2) + (j * k) + (k * l) + (l * j)) == i:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

Submission status: Time Limit Exceeded

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

n=math.floor(math.sqrt(N))

for n in range(1,N+1):
    ans=0
    flag=False
    for x in range(1,n ):
        for y in range(1, n):
            for z in range(1, n):
                a=x**2+y**2+z**2+x*y+y*z+z*x
                if a==n:
                    ans+=1
                if a>n:
                    break
            if x**2+y**2+1+x*y+y+x>n:
                break
  
                    
    print(ans)

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>=21):
      break
    for y in range(x,k):
      if(y==0):
        continue
      if(y>=21 or x+y>=30):
        break
      for z in range(y,k):
        if(z==0):
          continue
        if(z>=21 or y+z>=30 or z+x>=30):
          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:
N = int(input())

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

for n in range(1, N+1):
    if n < 6:
        print(0)
    else:
        cnt = 0
        for x in range(1, 32):
            for y in range(1, 32 - x):
                zl = int(n**(1/2))-x-y
                if zl < 1:
                    zl = 1
                for z in range(zl, 32-x-y):
                    if f2(x,y,z) == n:
                        cnt += 1
                        # print(x,y,z)
        print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(1,n+1):
    c = 0
    total = n
    while 1:
        for x in range(1, i//2):
            for y in range(x, i//2):
                for z in range(y, i//2):
                    total = ((x+y)**2 + (z+y)**2 + (x+z)**2) / 2
                    if total == i:
                        if x == y == z:
                            c += 1
                            # print("b")
                        elif x == y or y == z:
                            c += 3
                        else:
                            c += 6
                        break
                    elif total>i:
                        # print("a")
                        break
                if total == i:
                    break
        if total>i:
            break
    print(c)

Submission status: Time Limit Exceeded

Solution code:
# from pprint import pprint
# import math
# import collections
from numba import jit

N = int(input())

loops = 0


# 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


p_ne = []
# p_equal = []
for x in range(1, 100):
    for y in range(x, 100 - x):
        for z in range(y, 100 - (x + y)):
            loops += 1
            p_ne.append(calc(x, y, z))
            # p_ne_set.append((x, y, z))

p_eq = []
for xyz in range(1, 100):
    loops += 1
    p_eq.append(calc(xyz, xyz, xyz))

# p_set = p

# p_equal = []
# p_nonequal = []
# for _p in p_set:
#     loops += 1
#     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):
    loops += 1
    if i in p_eq:
        print(1)
    elif i in p_ne:
        print(3)
    else:
        print(0)

# print('lp', loops)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

ans = {}
for v in itertools.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 fn in ans.keys():
        ans[fn] += count
    else:
        ans[fn] = count

for i in range(1,N+1):
    if i in ans.keys():
        print(ans[i])
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for s in range(1, n+1):
    ans = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                if i*i + j*j + k*k + i*j + j*k + k*i == s:
                    if i == j == k:
                        ans += 1
                    elif i == j != k or j == k != i or k == i != j:
                        ans += 3
                    elif i != j != k:
                        ans += 6
                    break
            else:
                continue
            break
        else:
            continue
        break
    print(ans)
    ans = 0

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def func(n):
    cnt = 0
    a = int(n**0.5)
    for x in range(1, a+1):
        if(x**2+3+2*x > n):
            break
        for y in range(x, a+1):
            if(x**2+y**2+x*y+x+y+1 > n):
                break
            for z in range(y, a+1):
                if(x**2+y**2+z**2+x*y+y*z+z*x == n):
                    if(x == y == z):
                        cnt += 1
                    elif(x != y and y != z and z != x):
                        cnt += 6
                    else:
                        cnt += 3
                    break
                elif(x**2+y**2+z**2+x*y+y*z+z*x > n):
                    break
        
    return cnt

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

Submission status: Time Limit Exceeded

Solution code:
def main(n):
  ans=0
  
  for _ in range(1, n+1):
    a=int(_**0.5)
    ans=[[x,y,z]for z in range(1,a) for y in range(1,a) for x in range(1,a) if x**2+y**2+z**2+x*y+y*z+x*z==_]
    print(len(ans))
    
n=int(input())
main(n)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
tmp = []
for i in range(1,58):
    for j in range(1,58):
        for h in range(1,58):
            num = i*i + j*j + h*h + i*j + j*h +h*i
            tmp.append(num)
            num = 0

tmp.sort()


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

Submission status: Time Limit Exceeded

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

for n in range(1, N + 1):
    sum = 0
    if n<4:
        print(sum)
        continue
    for u in range(2, int(math.sqrt(2*n))):
        for v in range(u, int(math.sqrt(2*n))):
            if u*u + v*v >= 2*n:
                continue
            for w in range(v, int(math.sqrt(2*n))):
                if u*u + v*v + w*w > 2*n:
                    continue
                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())

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for i in range(1,N+1):
  ans = 0
  if i < 6:
    print(ans)
  else:
    for a in range(2,int((2*i)**0.5+1)):
      for b in range(a,int((2*i-a**2)**0.5+1)):
        for c in range(b,int((2*i-a**2-b**2)**0.5+1)):
          #print(a,b,c)
          if a**2 + b**2 + c**2 == 2*i:
            if max(a,b,c) < a+b+c-max(a,b,c):
              if len({a,b,c}) == 1:
                ans = 1
              elif len({a,b,c}) == 2:
                ans = 3
              else:
                ans = 6
              #print(a,b,c)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for n in range(1,N+1):
    r_n = math.floor(math.sqrt(n))
    count = 0
    for x in range(1,r_n):
        for y in range(1,r_n):
            for z in range(1,r_n):
                if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
                    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)]
    #zer
    ans = [0]*N
    x,y,z = 1,1,1
    a = x**2 + y**2 + z**2 +x*y + y*z + z*x

    for x in range(1,N):
        for y in range(1,N):
            for z in range(1,N):
                a = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if a > N:
                    break
                s = set([x,y,z])
                if len(s) == 1:
                    ans[a-1] = 1
                elif len(s) == 2:
                    ans[a-1] = 3
                else:
                    ans[a-1] = 6

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



if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def checker(n):
    ans = 0
    for a in range(1, 101):
        if a ** 2 + 2 * a > n:
            continue
        for b in range(1, 101-a):
            if a * 2 + b * 2 > n:
                continue
            for c in range(1, 101-a-b):
                if a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a == n:
                    ans += 1
                elif a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a > n:
                    break
    return ans


def main():
    N = int(input().strip())
    for n in range(1, N+1):
        print(checker(n))
    return


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    if b**2 - 4*a*c>=0:
        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
    else:
        return 0,0

def f(n):
    count = 0
    x_max = int(np.sqrt(n/6)//1)
    for x in range(1,x_max+1):
        y_max = int(np.sqrt((n-x**2-2*x)/3)//1)
        for y in range(x,y_max+1):
            z_1,z_2 = solv_quadratic_equation(1,x+y,x**2+y**2+x*y-n)
            zs = [int(z_1),int(z_2)]
            if zs[0] == zs[1]:
                if zs[0]>=y and x**2+y**2+zs[0]**2+x*y+y*zs[0]+zs[0]*x == n:
                    if x==y and y==zs[0]:
                        count += 1
                    elif x==y and y<zs[0]:
                        count += 3
                    elif x<y and y==zs[0]:
                        count += 3
                    elif x<y and y<zs[0]:
                        count += 6
            else:
                for z in zs:
                    if z>=y and x**2+y**2+z**2+x*y+y*z+z*x == n:
                        if x==y and y==z:
                            count += 1
                        elif x==y and y<z:
                            count += 3
                        elif x<y and y==z:
                            count += 3
                        elif x<y and y<z:
                            count += 6

            '''
            z_max = int(np.sqrt(n-x**2-y**2-x*y-x-y)//1)
            for z in range(y,z_max+1):
                if x**2+y**2+z**2+x*y+y*z+z*x == n:
            
                    if x==y and y==z:
                        count += 1
                    elif x==y and y<z:
                        count += 3
                    elif x<y and y==z:
                        count += 3
                    elif x<y and y<z:
                        count += 6
            '''

    return count

N = int(input())
if N >=6:
    for i in range(5):
        print(0)
    for i in range(5,N):
        print(f(i+1))
else:
    for i in range(N):
        print(0)

Submission status: Time Limit Exceeded

Solution code:
#C - XYZ Triplets
N = int(input())
ans = 0
for l in range(N):
    ans = 0
    for i in range(int((l+1)**0.5)):
        for j in range(int((l+1)**0.5)):
            # a = (i+1)+(j+1)
            # b = (i+1)*(j+1)
            # if (i + 1) ** 2 + (j + 1) ** 2 + (k + 1) ** 2 + (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (
            #         i + 1) == l + 1:
            for k in range(max((i+1),(j+1))):
                if (i+1)**2 + (j+1)**2 + (k+1)**2 +(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)== l+1:
                    if i == j == k:
                        ans = 1

                    elif (i == j and j !=k) or (k == j and i !=k):
                        ans = 3
                    else:
                        ans = 6

                break
    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:
            break
        for k in range(1,N):
            if i <=k or i<= k+j:
                break
            for l in range(1,N):
                if i <=l or i < k+j+l:
                    break
                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:
import math

def  XYZTriplets():

    num = int(input())
    
    for i in range(1, num+1):
        count = 0

        x = 1
        y = 1
        z = 1

        for x in range(1, int(math.sqrt(num))):
            for y in range(1, int(math.sqrt(num))):
                for z in range(1, int(math.sqrt(num))):
            
                    function = 0.5*( (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x) ) - i
                                
                    if function == 0:
                        count = count + 1
                        
                    
        print(count)
        

if __name__ == '__main__':
    XYZTriplets()

Submission status: Time Limit Exceeded

Solution code:
import math


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


def check(ans):
    cnt = 0
    for x in range(1, ans):
        # if pow(x, 2) > ans:
        # break
        for y in range(x, ans):
            # if pow(x+y, 2) > ans:
            # break
            for z in range(y, ans):
                tmp = x*(x+y+z) + y*(y+z) + z*z
                #tmp = pow(x+y+z, 2) - x*(y+z) - y*z
                if tmp == ans:
                    cnt += pattern(x, y, z)
                elif tmp > ans:
                    break
    print(cnt)


N = int(input())
# x^2 + y^2 + z^2 + x*y + y*z + z*x = n

for i in range(1, N+1):
    #upper_value = int(math.sqrt(i))
    check(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
b = []
for i in range(1,N+1):
    for x in range(1,i):
        for y in range(1,i):
            for z in range(1,i):
                aa = (x+y+z)**2 -(x*y+y*z+z*x)
                if aa == i:
                    b.append(i)
    
    print(len(b))
    b.clear()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
import itertools
import math
l = []
for i in range(1,n+1):
    cnt = 0
    p = int(math.sqrt(i))
    for x in range(1,p+2):
        for y in range(1,p+2):
            for z in range(1,p+2):
                if x*x + y*y + z*z + x*z + x*y + y*z == i:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d=dict({i:0 for i in range(1,n+1)})
for s in range(3,501):
    for x in range(1,s+1-2):
        for y in range(1,s+1-x-1):
            z=s-x-y
            if x<y or y<z:
                continue
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if not v in d:
                continue
            if x==y==z:
                d[v]+=1
            else:
                d[v]+=3
for k in d.keys():
    print(d[k])

Submission status: Time Limit Exceeded

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


def calc(n):
    for x in range(1, math.ceil(math.sqrt(n))):
        if x ** 2 > n:
            return 0
        for y in range(1, x+1):
            if y ** 2 + x * y > n:
                break
            for z in range(1, y+1):
                ans = x ** 2 + y ** 2 + z ** 2 + x * y + y*z + z*x
                # print(x, y, z, ans)
                if ans == n:
                    set_num = len({x, y, z})
                    if set_num == 1:
                        return 1
                    elif set_num == 2:
                        return 3
                    else:
                        return 6
                if ans > n:
                    break
    return 0

# print(calc(17))
for n in range(1, N + 1):
    res = calc(n)
    print(res)

Submission status: Time Limit Exceeded

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

n=math.floor(math.sqrt(N))

for n in range(1,N+1):
    ans=0
    flag=False
    for x in range(1,n ):
        for y in range(1, n):
            for z in range(1, n):
                a=x**2+y**2+z**2+x*y+y*z+z*x
                if a==n:
                    ans+=1
                if a>n:
                    break
  
                    
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

results, counts = [], []
for i in range(1, 31):
    for j in range(1, i + 1):
        for k in range(1, j + 1):
            result = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            results.append(result)
            if i == j and j == k:
                counts.append(1)
            elif i == j or j == k:
                counts.append(3)
            else:
                counts.append(6)

combined = zip(results, counts)
combined = sorted(combined)


for n in range(1, N + 1):
    total = 0
    for result, count in combined:
        if result > n:
            break
        elif result == n:
            total += count
    print(total)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = [v for v in range(1,14)]

for i in range(1,n+1):
	cnt = 0
	for x in range(1,14):
		for y in range(1,14):
			for z in range(1,14):
				if x**2 + y**2 + z**2 + (x*(y+z)) + (y*z) == i:
					cnt += 1
	print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement
N = int(input())
n = int(N**(0.5))+1 
l = [i for i in range(1,n+1)]

for i in range(1,N+1):
    c = 0
    for tup in combinations_with_replacement(l,3):
        x = tup[0]
        y = tup[1]
        z = tup[2]
        if (x+y+z)**2-x*y-y*z-z*x == i:
            if len(set(tup)) == 1:
                c+=1
            elif len(set(tup)) == 2:
                c+=3
            else:
                c+=6 
    print(c)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
 
def resolve():
    import math
 
    readline = sys.stdin.readline
 
    N = int(readline())
 
    for i in range(1, N + 1):
        ans = 0
        li = int(math.sqrt(i) // 1)
        for x in range(1, li):
            for y in range(1, li):
                xx = x * x
                yy = y * y
                xy = x * y
                value = (x + y) ** 2 - 4 * (xx + yy + xy - i)
                if value <= 0:
                    continue
                cal = math.sqrt(value)
                z1 = (-(x + y) + cal) / 2
                z2 = (-(x + y) - cal) / 2
                if (1
                        and 1 <= z1
                        and z1 % 1 == 0):
                    ans += 1
                if (1
                        and 1 <= z2
                        and z2 % 1 == 0):
                    ans += 1
        print(ans)
 
 
resolve()

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))
  #平方根までやれば十分
  for x in range(1,m):
    if i - x**2 <= 4:
      break
    for y in range(x,m):
      if i - x**2 -y**2 <= 3:
        break
      for z in range(y,m):
        a = (x+y+z)**2 -x*y -y*z - z*x
        if a == i:
          if x==y==z:
            cnt += 1
            break
          elif x==y or y==z:
            cnt += 3
            break
          else:
            cnt += 6
            break
        elif a > i: break
  ans[i-1] = cnt
print('\n'.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
import itertools

def calc(x, y, z):
  return (x*x + y*y + z*z + x*y + y*z + z*x)
  
N = int(input())

for i in range(1,N+1):
  output = []
  for x in range(1,i):
    for y in range(1,i):
      for z in range(1,i):
        tmp = calc(x,y,z)
        if tmp==i:
          output.append(tmp)
  print(len(output))

Submission status: Time Limit Exceeded

Solution code:
def dfs(lis,cnt,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:
import itertools

N = int(input())

def f(n):
  combs = tuple(itertools.product(range(1, n), repeat=3))
  ans = [ 1 for x,y,z in combs if (x*x + y*y + z*z + x*y + y*z + z*x) == n]
  return len(ans)

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

Submission status: Time Limit Exceeded

Solution code:
import math

def  XYZTriplets():

    num = int(input())
    
    for i in range(1, num+1):
        count = 0

        x = 1
        y = 1
        z = 1

        for x in range(1, int(math.sqrt(num))+1):
            for y in range(1, int(math.sqrt(num))+1):
                for z in range(1, int(math.sqrt(num))+1):
            
                    function = 0.5*( (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x) ) - i
                                
                    if function == 0:
                        count = count + 1
                        
                    
        print(count)
        




if __name__ == '__main__':
    XYZTriplets()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1,N+1):
    cnt=0
    t=math.sqrt(i)
    t=int(t)
    for x in range(1,t+1):
        for y in range(1,t+1):
            for z in range(1,t+1):
                if x*x+y*y+z*z+x*y+y*z+z*x==i:
                    cnt+=1
                if x*x+y*y>i:
                    break
    print(cnt)