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:
#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(i,int((l+1)**0.5)-i):
            # 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(j,int((l+1)**0.5)-i-j):
                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
                        break
                    elif (i == j and j !=k) or (k == j and i !=k):
                        ans = 3
                        break
                    else:
                        ans = 6
                        break

    print(ans)

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
        xr = int(n**(1/2))
        for x in range(1, xr):
            for y in range(1, xr):
                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 h in range(1,N+1):
    num=0
    for i in range(1,h-3):
        for j in range(1,h-3):
            for k in range(1,h-3):
                if i**2+j**2+k**2+i*j+j*k+k*i==h:
                    num+=1
    print(num)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
n = int(input())
a = []
for i in range(1, n+1):
  a += [i]*3
xyz_list = list(set(list(itertools.combinations(a, 3))))
xyz_list.sort()
nn = int(math.sqrt(n/6))
dic = {}
for i in range(1, n+1):
  dic[i] = 0
for xyz in xyz_list:
  x, y, z = xyz[0], xyz[1],xyz[2]
  if x > nn and y > nn and z > nn:
    break
  sum1 = x**2 + y**2 + z**2 + x*y + y*z + z*x
  if sum1 in dic:
    if len(set(xyz)) == 1:
      dic[sum1] += 1
    elif len(set(xyz)) == 2:
      dic[sum1] += 3
    else:
      dic[sum1] += 6
for i in range(1, n+1):
  print(dic[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for m in range(1, n+1):
    cnt = 0
    for i in range(1, int(n**0.5)+2):
        a = n - i**2
        if a >= 1:
            for j in range(1, int(a**0.5) + 2):
                b = n - i**2 - j**2
                if b >= 1:
                    for k in range(1, int(b**0.5) + 2):
                        if i**2 + j**2 + k**2 + i*j + j*k + k*i == m:
                            cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
for i in range(1, N+1):
    count = 0
    for j in range(1, int(np.sqrt(i)//6)+10):
        for k in range(j, int(np.sqrt(i)//6)+10):
            for l in range(k, int(np.sqrt(i)//6)+10):
                n = j*j + k*k + l*l + j*k + k*l + l*j
                if n == i:
                    if j == k == l:
                        count += 1
                    elif j==k or k==l or l==j:
                        count += 3
                    else:
                        count += 6
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for n in range(1, N + 1):
    ans = 0
    x = math.ceil(n ** (1/2))
    for i in range(1, x):
        for j in range(1, x):
            for k in range(1, x):
                if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i == n:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n+1):
    cnt = 0
    j = int(i**0.5)

    for x in reversed(range(1, j)):
        for y in reversed(range(1, x+1)):
            for z in reversed(range(1, y+1)):
                if i == x**2 + y**2 + z**2 + x*y + y*z + z*x:
                    if x==y==z:
                        cnt += 1
                    elif x==y or y==z or z==x:
                        cnt += 3
                    else:
                        cnt += 6
                    break

    print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
for i in range(n):
    cnt = 0
    for x in range(1,n):
        for y in range(1,n):
            b = x + y
            c = x**2+y**2+x*y-i-1
            buf = b**2-4*c
            if buf >= 0:
                ans = [-b + math.sqrt(buf), -b - math.sqrt(buf)]
                for z in ans:
                    if z.is_integer() and z > 0:
                        cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
input_number = input()
for n in range(int(input_number)):
	n += 1
	count = 0
	for x in range(1,101):
		function_x = x*x
		if function_x > n:
			break
		for y in range(1,101):
			function_xy = x*x+y*y+x*y
			if function_xy > n:
				break
			for z in range(1,101):
				function = x*x+y*y+z*z+x*y+y*z+x*z
				if function > n:
					break
				if n == function:
					count += 1
	print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np
n = int(input())

for i in range(1,n+1):
    ans = 0
    if i<=5:
        print(0)
        continue
    for x in range(1,math.floor((math.sqrt(i)))):
        for y in range(1,math.floor((math.sqrt(i)))):
            if 4*(x*y+i)-3*(x+y)**2<=0:
                continue
            z = (math.sqrt(4*(x*y+i)-3*(x+y)**2)-x-y)/2
            if z*100//100==z and z>=1:
                ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())

for i in range(1,n+1):
    cnt=0
    for j in range(1,42):
        for k in range(1,42):
            for l in range(1,42):
                if j**2+k**2+l**2+j*k+k*l+l*j==i:
                    cnt+=1
                    break
                elif j**2+k**2+l**2+j*k+k*l+l*j>i:
                    break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

def f(n):
    a = 0
    b = 0
    c = 0
    d = 0
    for i in range(1,42):
        if g(i,i,i) == n:
            a += 1
    for i in range(1,42):
        for j in range(i + 1,42):
            if g(i,j,j) == n:
                b += 1
    for i in range(1,42):
        for j in range(i + 1,42):
            if g(i,i,j) == n:
                c += 1
    for i in range(1,42):
        for j in range(i + 1,42):
            for k in range(j + 1,42):
                if g(i,j,k) == n:
                    d += 1
    return a + 3 *(b + c) + 6 * d

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

Submission status: Time Limit Exceeded

Solution code:
n=1000
for i in range(1,n+1):
    cnt=0
    if i<6:
        pass
    for x in range(1,101):
        if x**2>i:
            break
        for y in range(1,101):
            if y**2>i:
                break
            elif x**2+y**2>i:
                break
            for z in range(1,101):
                if z**2>i:
                    break
                elif x**2+y**2+z**2>i:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    cnt+=1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#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)-i):
            # 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(int((l+1)**0.5)-i-j):
                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
                        break
                    elif (i == j and j !=k) or (k == j and i !=k):
                        ans = 3
                        break
                    else:
                        ans = 6
                        break

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
m=int(math.sqrt(n)+1)
a=[]
for x in range(1,m):
  for y in range(1,m):
    for z in range(1,m):
      a.append(int(x**2+y**2+z**2+x*y+y*z+z*x))
for i in range(1,1+n):
  print(a.count(i))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

import numpy as np

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

    right = 2 * i


    er = int(np.ceil(np.sqrt(right)))

    count = 0

    for x in range(1,er):
        for y in range(1,er):
    
            if x + y > np.sqrt(right):
                continue
      
            else:
                for z in range(1,er):
            
                    if (x + y > np.sqrt(right)) | (y + z > np.sqrt(right)) | (x + z > np.sqrt(right)):
                        continue
                    
                    else:
                        if (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 == 2*i:
                            count += 1
            
    print(count)

Submission status: Time Limit Exceeded

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

for n in range(1, N + 1):
    sum = 0
    root = math.sqrt(2*n)
    if n<4:
        print(sum)
        continue
    for u in range(2, int(root)):
        for v in range(u, int(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())
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
ansadd = [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]
if N <= 9000:
  for i in range(1,N+1):
    print(func(i))
else:
  for i in range(1,9000):
    print(func(i))
  for i in range(9001,N):
    print(ansadd[i-9001])

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 or (x+abs(mark-x) + abs(mark-max(x,abs(mark-x))))**2 < did:
            break
        for y in range(1,abs(mark-x)):
            if x ** 2 + y ** 2 + x*y >= did:
                break
            mark2 = math.ceil(sqrt(did-x**2 - y**2 - x*y))
            for z in range(min(mark2,abs(mark-(max(x,y))))):
                if (x+y+z)**2 - (x*y + x*z + y*z) == did:
                    count += 1
    print(count)
    did += 1

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

import sys
import math

def main():
    input = sys.stdin.readline
    N = int(input())

    result = 0
    ok_flag = False
    for n in range(1,N+1):
        root_n = int(math.sqrt(n)) + 1
        if n < 3:
            print(0) 
            continue
        for i in range(1,root_n):
            for j in range(1,root_n):
                for k in range(i,root_n):
                    if i*i + j*j + k*k + i*j + i*k + j*k == n:
                        if i == j and j == k:
                            result += 1
                        elif i == j or j == k or i == k:
                            result += 3
                        else:
                            result += 6
                        print(result)
                        result = 0
                        ok_flag = True
                        break
                if ok_flag:
                    break
            if ok_flag:
                break

        if not ok_flag:
            print(0)
        ok_flag = False
        
                        

    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math




N=int(input())

anslist=[]
for i in range(1,N+1):
    ans=0
    if i<=5:
        anslist.append(ans)
    else:
        ma=int(math.sqrt(i))
        for x in range(1,ma):
            for y in range(x,ma):
                for z in range(y,ma):
                    if (x+y+z)**2<i:
                        continue
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        if x==y and y==z:
                            ans+=1
                        elif x==y or y==z or z==x:
                            ans+=3
                        else:
                            ans+=6
                    if 6*(x**2)>i:
                        break
        anslist.append(ans)
            

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
MOD = (10 ** 9) + 7  # operować sobie na typie int32_t


def 関数(n):
    res = 0
    for x in range(1,n+1):
        for y in range(1, n+1):
            for z in range(1, n+1):
                if x*x + y*y + z*z + x*y + y*z + z*x == n:
                    res += 1
    return res

def çözmek():
    N = int(sys.stdin.readline())
    for i in range(1, N+1):
        print(関数(i))

if __name__ == "__main__":
    çözmek()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    x , y , z = 1,1,1
    anwlist = []
    for i in range(N):
        n = i+1

        while True: # X
            while True: # Y
                while True: # Z
                    calc = x**2 +  y**2 + z**2 + x*y + y*z + z*x
                    if calc > n:
                        break
                    elif calc == n:
                        anwlist.append([x,y,z])
                        break
                    elif calc < n:
                        z += 1

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

            x += 1
            y,z = 1, 1
            
            if x**2 +  y**2 + z**2 + x*y + y*z + z*x > n:
                print(len(anwlist))
                x, y, z = 1,1,1
                anwlist = []
                break
        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
count = 0
M = N//5
LiST = []
for k in range(1,N+1):
    count= 0
    if (k<42) and (k!=6 and k!=11 and k!=17 and k!=18 and k!=24 and k!=25 and k!=33 and k!=35 and k!=35 and k!=38):
        LiST.append(0)
        continue
    for x in range(1,M):
        for y in range(1,M):
            for z in range(1,M):
                if ((x*(x+y))+(y*(y+z))+(z*(z+x))) == k:
                    count +=1
    LiST.append(count)
for i in LiST:
    print(i)

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
    start = math.floor(r_n/3)
    if(n >= 6):
        for x in range(start,r_n):
            for y in range(1,x+1):
                for z in range(1,y+1):
                    if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
                        if (x == y and y ==z):
                            count+=1
                        elif(x == y or y==z or z == x):
                            count+=3
                        else:
                            count+=6
    print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

for h in range(1,N+1):
    num=0
    for i in range(1,h):
        for j in range(1,h):
            for k in range(1,h):
                if i**2+j**2+k**2+i*j+j*k+k*i==h:
                    num+=1
    print(num)

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 = (-x-y + ((x+y)**2-4*(x**2+y**2+x*y-n))**(0.5))/2
            if z.is_integer() and z >= 1:
                count += 1
                #print([x, y])
            y += 1
        x += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:

n=int(input())

def number(i):
   for j in range(1,41):
      for k in range(j,58):
         for u in range(k,101):
            a=j*j+k*k+u*u+j*k+k*u+u*j
            if a > 10**4:
               break
            if i==a:
               if j==k and k==u:
                  print(1)
                  return
               elif j==k or k==u:
                  print(3)
                  return
               else:
                  print(6)
                  return
         

   print(0)
   return

for h in range(1,n+1):
   number(h)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for n in range(1, N+1):
    s = n//5
    cnt = 0
    flag = 0
    f2 = 0
    for x in range(1, s+1):
        for y in range(x, s+1):
            for z in range(y, s+1):
                siki = x**2 + y**2 + z**2 + x*y + y*z + z*x

                if siki == n:
                    # print('ans = ', siki)
                    if (x==y)and(y==z):
                        cnt += 1
                    elif (x!=y)and(y!=z):
                        cnt += 6
                    else:
                        cnt += 3
                # elif siki > n:
                    flag = 1
                    break
                elif siki > n:
                    f2 += 1
                    # print('fs= ', f2)
                    # print('x,y,z= ',x,y,z)
                    break

            if flag or f2==2:
                break
        if flag or f2==3:
            break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = 10**4
k = [0]*10**4
for x in range(1,10):
    for y in range(1,10):
        for z in range(1,10):
            for i in range(n+1):
                if x**2 + y** 2 + z**2 + x*y + y*z + z*x == i:
                    k[i-1] += 1
for i in range(int(input())):
    print(k[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

for h in range(1,N+1):
    num=0
    for i in range(1,N):
        for j in range(1,N):
            for k in range(1,N):
                if i**2+j**2+k**2+i*j+j*k+k*i==h:
                    num+=1
    print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def func(N_max):
#     print(f'N_max:{N_max}')
    cnt = 0
#     flag = False
    ans = []
    
    total = 0

    for x in range(1, N_max):
        x_total = x**2
        if N_max < x_total:
            break
        for y in range(x, N_max):
            y_total = x_total + y**2 + x*y
            if N_max < y_total:
                break

            for z in range(y, N_max):
                total = y_total + z**2+y*z+z*x
                if N_max < total:
                    break
                ans.append((total, change(len(set((x,y,z))))))

    return ans

def change(length):
    if length < 1:
        return 0
    elif length == 1:
        return 1
    elif length == 2:
        return 3
    elif length == 3:
        return 6

data = func(N)
for i in range(1, N+1):
    ans = 0
    for d in data:
        if d[0] == i:
            ans = d[1]
    print(ans)

Submission status: Time Limit Exceeded

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

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

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1,N+1):
  count = 0
  aa = math.ceil(i**0.5)
  for j in range(1,aa+1):
    for k in range(1,j+1):
      if j**2+k**2+j*k > N:
        continue
      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:
N=int(input())
mat={6:1,11:3,17:3,18:3}
 
def xyz(x,y,z):
  return (x+y+z)**2 - (x*y+y*z+z*x)
 
def fn(n):
  count=0
  for x in range(1,50):
    for y in range(1,50):
      for z in range(1,50):
        if xyz(x,y,z)==n:
          count+=1
  return count
 
for i in range(1,N+1):
  if i not in mat.keys():
     mat[i]=fn(i)
  print(mat[i])

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


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


    def f(i):
        l = []
        for a in range(1, math.floor(math.sqrt(i))):
            l.append(a)
        l_list = list(itertools.combinations_with_replacement(l, 3))
        count = 0
        for j in range(len(l_list)):
            x = l_list[j][0]
            y = l_list[j][1]
            z = l_list[j][2]
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ans == i and x == y and y == z:
                count += 1
            elif ans == i:
                count += 3
        return count

    for i in range(1, n+1):
        count = f(i)
        if count != 0:
            print(count)
        else:
            print(0)


if __name__ == '__main__':
    main()

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)//3):
    for y in range(1, x+1):
      for z in range(1, y+1):
        if x*x + y*y +z*z +  x*y + y*z + z*x == n:
          if x == y == z:
            ans += 1
          elif x == y or y == z:
            ans += 3
          else:
            ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
s1 = input().split()
intN = int(s1[0])

i = 1
while i <= intN :
    cnt = 0
    wkX = 1
    while wkX <= i -5 :
        if (wkX * wkX > i -5) : 
            break
        wkY = 1
        while wkY <= i - 5 -wkX -wkX*wkX +1 +1:
            if (wkY * wkY > i -5 -wkX +1) : 
                break
            if (wkX * wkY > i -5 -wkX +1) : 
               break
            wkZ = 1
            while wkZ <= i - 5 -wkX -wkY -wkX*wkX -wkY*wkY - wkX*wkY + 1 +1 +1 + 2 :
                if (wkZ * wkZ > i -5 -wkX -wkY + 2) : 
                   break
                if (wkY * wkZ > i -5 -wkX -wkY + 2) : 
                    break
                if (wkZ * wkX > i -5 -wkX -wkY + 2) : 
                    break
                intFn = wkX * wkX + wkY * wkY + wkZ * wkZ + wkX * wkY + wkY * wkZ + wkZ * wkX
                if (intFn == i) :
                    cnt += 1
                wkZ += 1
            wkY += 1
        wkX += 1
    print(cnt)
    i += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
if n<=5:
  for i in range(n):
    print(0)
else:
  for i in range(5):
    print(0)
  for i in range(6, n+1):
    count=0
    for x in range(1, int(i/3)):
      if x*x>i-(3+2*x):
        break
      for y in range(1, int(i/3)):
        if y*y>i-(3+2*y):
          break
        for z in range(1, int(i/3)):
          if z*z>i-(3+2*z):
            break
          if x*x + y*y + z*z + x*y + y*z + z*x == i:
            count+=1
        
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())

a=[0]*(n+1)
for i in range(1,n+1):
    for j in range(1,42):
        for k in range(1,42):
            for l in range(1,42):
                if j**2+k**2+l**2+j*k+k*l+l*j==i:
                    a[i]+=1
                    break
                elif j**2+k**2+l**2+j*k+k*l+l*j>i:
                    break
for x in range(1,n+1):
    print(a[x])