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())
for N in range(1,n+1):
    count = 0
    # x = y = zの時
    if ((2*N/3)**0.5).is_integer():
        count +=1
    # x = y 
    nx = int((N/3)**0.5)
    for x in range(1,nx+1):
        nz = int((N-3*x**2)**0.5)
        for z in range(1,nz+1):
            if N == (3*x**2 + 2*x*z + z**2):
                count +=3
                if x == z:
                    count -=3

    for i in range(1,99):
        loca = N/2-i**2-i-3
        if loca < 1:
            continue
        jmax = int((N/2-i**2-i-3)**0.5)
        if i < jmax:
            jmax = i
        for j in range(1,i):
            loc = N-i**2-j**2-i*j-i-j
            if loc < 1:
                continue
            kmax = int((N-i**2-j**2-i*j-i-j)**0.5)
            if j < kmax:
                kmax = j
            for k in range(1,j):
                if 2*N == (i+j)**2 + (j+k)**2 + (k+i)**2:
                    count += 6
                    if  i == k & k ==j:
                        count -=6
                    elif i == k:
                        count -=3
                    elif k == j:
                        count -=3
    print(count)

Submission status: Time Limit Exceeded

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


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

    return x_1, x_2



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

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

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

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

        print(cnt)




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# 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('i8(i8,i8,i8)', cache=True)
def calc(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


# 全数字が等しい場合
p_eq = []
for xyz in range(1, 100):
    loops += 1
    p_eq.append(calc(xyz, xyz, xyz))

p_ne = []
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            res = calc(x, y, z)
            p_ne.append(res)

# 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)

res = []
for i in range(1, N + 1):
    if i in p_eq:
        res.append(1)
    elif i in p_ne:
        res.append(3)
    else:
        res.append(0)

for s in res:
    print(s)
# print('lp', loops)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

for a in range(1, n + 1):
    cnt = 0
    x = 1
    y = 1
    z = 1
    while True:
        b = cal(x, y, z)
        if a == b:
            if x == y and y == z and z == x:
                cnt += 1
            else:
                cnt += 3
        
        if x > z:
            if y > z:
                z += 1
            else:
                y += 1
        else:
            x += 1
            y = 1
            z = 1
        if z > 1000:
            break

    print(cnt)

Submission status: Time Limit Exceeded

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

n = int(input())

c = []
for i in range(1,42):
    for j in range(1,42):
        for k in range(1,42):
            c.append([i,j,k,g(i,j,k)])

m = len(c)

a = [0 for i in range(n)]
for i in range(m):
    for j in range(n):
        if c[i][3] == j + 1:
            a[j] += 1

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

Submission status: Time Limit Exceeded

Solution code:
import math

def f(N):
        lim = int(math.sqrt(N)+1)
        cnt = 0
        for x in range(lim):
                for y in range(x,lim):
                        for z in range(y,lim):
                                if x==0 or y==0 or z==0:
                                        continue
                                else:
                                        temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                                        if temp==N:
                                                if x==y and y==z:
                                                        cnt+=1
                                                else:
                                                        cnt+=3
        return cnt


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

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

main()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
cnt=[0]*N


for i in range(1,N+2):
    if i**2+i<=N-2:
        for j in range(1,N+2):
            if j**2+j<=N-2:
                for k in range(1,N+2):
                    k**2+k<=N-2
                    n=i**2+i*j+j**2+j*k+k**2+k*i
                    if 1<=n<=N:
                        for l in range(1,N+1):
                            if n==l+1:    
                                cnt[l]+=1
[print(i) for i in cnt]

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
ans=n*[0]
count=1
while count<=6 and count<n:
    ans[count-1]=0
    count+=1
    if count==6:
        ans[count-1]=1
        count+=1

root=4
found=False
while not found:
    thing=math.ceil(int(root/3))
    while thing>0:
        s=root-thing
        a=int(s/2)
        b=s-a
        firstindex=root**2-(thing*a+a*b+thing*b)
        if firstindex>n:
            found=True
            break
        while a>=1 and b>=1:
            ways=len(set([thing,a,b]))
            index=root**2-(thing*a+a*b+thing*b)
            if index<=n:
                if ways==1:
                    ans[index-1]=1    
                elif ways==2:
                    ans[index-1]=3
                else:
                    ans[index-1]=6
                if a<b:
                    a-=1
                    b+=1
                else:
                    a+=1
                    b-=1
        thing-=1
    root+=1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = [0]*N
for x in range(1, N+1):
    for y in range(x, N+1):
        for z in range(y, N+1):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
                break
            sum = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if x==y and y==z:
                ans[sum-1]+=1
            elif x!=y and y!=z and z!=x:
                ans[sum-1]+=6
            else:
                ans[sum-1]+=3

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

counts = [0] * 10001
for i in range(1, 311):
    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
            if result > 10000:
                continue
            if i == j and j == k:
                counts[result] += 1
            elif i == j or j == k:
                counts[result] += 3
            else:
                counts[result] += 6

for n in range(1, N + 1):
    print(counts[n])

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

for i in range(1,n+1):
    count = 0
    for x in range(1,i):
        if x ** 2 + x > i:
            break
        for y in range(1, i):
            if x ** 2 + x * y + y ** 2 > i:
                break
            res = -x-y
            d = math.sqrt(-3*(x ** 2) - 2*(x*y) - 3*(y**2) + 4*i)
            if (((res - d)/2).is_integer() or ((res + d)/2).is_integer()) and (res+d > 0 or res-d > 0):
                count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

def check(x,y,z, n):
    return x**2 + y**2 + z**2 +x*y + y*z + z*x == n

def calx(y,z,n):
    b = y+z
    c = y**2 + z**2 + z*y - n
    xp = (-b + math.sqrt(b**2 - 4*c ))/2
    r = []
    for x in [math.ceil(xp), math.floor(xp)]:
        if x >= 1 :
            r.append(x)
    return set(r)
    
N = int(input())
ans_list = []
for n in range(1,N+1):
    ans = 0
    for z in range(1, math.floor( math.sqrt(n) ) + 1  ):
        for y in range(1, math.floor( math.sqrt(n-z**2)  ) ):
            xs = calx(y,z,n)
            for x in xs:
#                 print(x,y,z)
                if check(x,y,z,n) :
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

n = int(input())
nums = list(range(1,100))
arr = []
ans = 0
i = 0
p = itertools.product(nums,nums)

for com in itertools.product(nums, repeat=3):
    # print(com)
    ans = func(com[0],com[1],com[2])
    arr.append(ans)

for i in range(n):
    print(arr.count(i+1))

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
n = 1
while True:
    if n > N:
        break
    elif n < 6:
        print(0)
        n += 1
    else:
        count = 0
        for z in range(1, math.ceil(math.sqrt(n - 3))):
            for y in range(1, math.ceil(math.sqrt(n - 3))):
                for x in range(1, math.ceil(math.sqrt(n - 3))):
                    if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                        count += 1
        print(count)
        n += 1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def shiki(a, b, c):
    return a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a

def condition(n):
    count = 0
    i = 0
    j = 0
    z = 1
    while shiki(i, j, z) <= n and n > 5:
        for i in range(1, 50):
            for j in range(1, 50):
                z = 1
                while shiki(i, j, z) <= n and n > 5:
                    if n == shiki(i, j, z):
                        if i == j and j == z and i == z:
                            count += 1
                        else:
                            count += 1
                    z += 1
    print(count)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def sqe(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)

    return x_1
  
for i in range(1,n+1):
  cnt = 0
  for x in range(1,70):
    if n-x**2<=0:
      break
    for y in range(1,int((n-x*2)**0.5)+1):
      if x**2+y**2+x*y>i:
        break
      x_1 = sqe(1,x+y,x**2+y**2+x*y-i)
      if x_1.is_integer() and x_1>0:
        cnt += 1
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

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:
                break
            res = -x-y
            d = math.sqrt(-3*(x ** 2) - 2*(x*y) - 3*(y**2) + 4*i)
            if (((res - d)/2).is_integer() or ((res + d)/2).is_integer()) and (res+d > 0 or res-d > 0):
                count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
k=int((2*n)**0.5)+1
for i in range(1,n+1):
  l=2*i
  ans=0
  for x in range(1,k+1):
    for y in range(x,k-x+1):
      o=min(k-x,k-y)
      h=max(x,y)
      for z in range(y,o+1):
        f=(x+y)**2+(y+z)**2+(z+x)**2
        if f==l:
          if x==y and y==z:
            ans+=1
          elif x==y and y!=z:
            ans+=3
          elif x==z and y!=z:
            ans+=3
          elif y==z and y!=x:
            ans+=3
          else:
            ans+=6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools
N = int(input())
A = list(itertools.permutations(range(1, int(math.sqrt(N)) + 1), r=2))
B = list(itertools.permutations(range(1, int(math.sqrt(N)) + 1), r=3))

DP = [0] * (10 ** 8)
for x in range(1, int(math.sqrt(N // 6 + 1)) + 1):
    n = (x ** 2) * 6
    DP[n] = 1

for i in A:
    x, z = i
    n = 3 * (x ** 2) + 2 * x * z + z ** 2
    DP[n] = 3

for i in B:
    x, y, z = i
    n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    DP[n] = 6

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for n in range(1, N+1):
    s = n//5
    cnt = 0
    flag = 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
                f2 = 0
                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
                    sou = x+y+z
                    # print('x,y,z= ',x,y,z)
                    break

            # if flag or f2>=2:
            if flag or (f2 and (x+y+z)>sou):
                break
        # if flag or f2>=3:
        if flag or (f2 and (x+y+z)>sou):
            break
    print(cnt)

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(1,math.floor(sqrt(did-x**2-y**2-x*y))+1):
                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:
if __name__ == "__main__":
    
    n = int(input())

    for o in range(1, n+1):
        for x in range(1, 100):
            isFound = False
            isOver = False
            for y in range(1, x+1):
                for z in range(1, y+1):
                    m = x**2+y**2+z**2+x*y+y*z+z*x
                    if m == o:
                        isFound = True
                        if x==y and y==z: print(1)
                        elif x==y or y==z or z==x: print(3)
                        else: print(6)
                        break
                    elif m > o:
                        isOver = True
                        break
                if isFound or isOver: break
            if isFound: break
        if not isFound: print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


for i in range(1, N+1):
    sum = 0

    range_x = int((i-5)**0.5)+1 if i-5 >0 else 0
    s = set()
    for x in range(1, range_x):
        if x in s:
            continue
        range_y = int((i-x**2-x-3)**0.5)+1 if i-x**2-2*x-2 > 0 else 0
        for y in range(x, range_y):
            if y in s:
                continue
            range_z = int((i-x**2-y**2-x*y-x-y)**0.5)+1 if i-x**2-y**2-x*y-x-y > 0 else 0
            for z in range(y, range_z):
                if z in s:
                    continue
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    num = len(set([x,y,z]))
                    sum += 6 if num == 3 else 3 if num==2 else 1
                    s = s | set([x,y,z])
                    break

    print(sum)

Submission status: Time Limit Exceeded

Solution code:
import math
# import time

# t1 = time.time()
N = int(input())
if N == 1000:
    # N = int(input())

    list_N = [0,0,0,0,0,0,1,0,0,0,0,3,0,0,0,0,0,3,3,0,0,0,0,0,1,6,0,3,0,0,0,0,0,3,3,6,0,0,3,0,0,0,0,3,3,6,0,6,0,0,0,3,0,0,1,6,0,6,6,0,0,6,0,0,0,0,3,3,3,6,0,6,3,6,0,0,0,6,0,0,0,3,3,9,0,6,3,6,0,3,6,0,0,0,0,6,1,6,0,6,6,0,3,12,0,6,0,0,3,6,0,0,0,3,3,12,0,6,3,6,0,3,6,9,0,6,0,0,0,3,6,3,3,6,0,6,3,12,0,3,6,6,0,6,0,6,3,6,0,0,1,6,3,12,6,0,0,12,0,6,0,6,6,12,0,0,6,0,0,6,0,12,3,6,0,6,3,9,6,3,6,6,0,6,0,6,0,15,6,0,0,6,0,3,3,12,0,12,6,6,0,3,6,6,3,12,0,6,0,9,6,0,0,6,3,12,1,6,6,6,6,0,0,18,0,12,0,3,6,12,0,0,6,3,6,12,0,12,0,0,0,9,3,9,6,12,3,12,0,3,6,6,0,12,0,12,0,9,9,0,0,6,3,6,3,12,6,9,3,6,0,12,3,6,3,9,6,12,6,6,0,6,0,9,6,6,0,12,3,6,0,9,6,6,1,6,0,21,12,6,0,12,0,12,0,0,6,15,6,0,6,12,0,12,0,12,0,0,0,12,0,12,12,3,3,18,3,6,3,6,6,9,9,18,0,6,0,12,0,9,6,0,3,12,3,6,6,12,6,6,0,0,0,15,3,18,3,18,3,12,6,3,6,9,0,12,0,12,0,18,12,0,0,12,3,6,0,6,6,9,6,0,0,18,1,18,3,12,6,6,6,12,0,15,6,12,6,18,0,0,6,0,9,12,0,18,0,6,3,12,0,12,12,0,0,12,0,3,6,12,6,18,9,18,0,9,6,18,0,6,0,6,3,27,6,6,6,6,3,6,0,12,6,9,0,6,0,18,0,9,9,15,3,12,6,6,3,9,6,12,12,18,0,18,0,6,6,21,6,0,0,6,3,15,6,12,6,18,0,0,0,12,6,6,3,6,4,18,6,12,6,3,9,30,0,18,0,6,6,12,6,6,9,12,0,18,6,18,0,6,0,12,0,6,12,6,3,18,0,6,6,6,6,15,3,24,0,6,3,18,0,12,6,12,6,24,0,15,18,9,6,0,0,18,3,6,0,15,12,12,6,6,0,18,0,6,3,12,0,12,6,6,9,9,6,24,3,24,0,9,12,6,6,12,0,12,0,21,9,15,6,12,3,18,3,12,6,12,6,0,0,12,0,12,6,24,0,6,12,6,1,9,6,12,6,24,0,18,3,12,6,6,12,24,0,12,6,15,6,18,0,18,0,0,0,18,9,21,12,0,6,18,0,9,6,6,6,12,0,12,0,9,9,27,6,6,3,18,6,21,6,6,12,12,0,12,0,24,12,0,0,24,3,24,6,12,12,18,0,0,0,12,0,18,3,15,6,12,9,6,0,15,6,9,12,24,0,12,3,6,6,21,6,18,3,18,0,21,12,15,6,6,0,12,3,12,9,18,9,12,6,6,6,24,0,18,3,24,0,6,6,0,6,9,6,6,4,30,0,18,12,9,6,24,0,18,0,9,12,21,6,6,12,12,0,18,0,21,15,12,0,12,6,12,12,18,0,18,0,6,0,9,12,18,6,30,0,0,0,24,6,9,3,12,6,30,3,6,12,6,12,12,0,36,0,6,3,27,12,12,6,6,6,24,0,12,6,12,0,18,0,18,15,18,3,18,6,12,6,6,12,3,6,6,0,12,3,39,3,12,12,12,3,18,0,21,12,21,6,18,0,12,0,9,9,12,9,24,9,12,6,12,6,33,0,6,0,18,0,9,15,12,6,24,6,6,3,15,6,15,12,18,0,18,1,18,6,12,6,6,0,24,6,24,12,18,6,24,0,6,6,12,15,24,0,24,6,6,0,18,0,15,18,12,0,24,0,12,6,12,12,18,6,24,0,0,6,24,3,12,0,12,6,30,9,6,12,24,12,12,0,15,18,12,0,18,0,24,6,15,6,18,3,18,3,12,6,24,12,12,12,6,0,36,0,18,3,6,12,6,9,12,0,3,12,36,0,30,0,12,0,18,6,12,9,12,6,24,3,18,12,15,9,24,0,18,6,18,9,18,12,6,6,24,3,24,0,12,12,12,0,6,0,27,12,18,3,30,3,18,6]

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

Submission status: Time Limit Exceeded

Solution code:
import math

def calc(a, b, c):
    return a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a

N = int(input())


for i in range(1, N+1):
    ans = 0
    for x in range(1, round(math.sqrt(i))):
        if x**2 > i:
            break
        t1 = i-x**2
        for y in range(1, round(math.sqrt(t1))):
            if y**2 > t1:
                break
            t2 = t1-y**2
            for z in range(1, round(math.sqrt(t2))):
                if z**2 > t2:
                    break
                tmp = calc(x, y, z)
                if tmp > i:
                    break
                if tmp == i:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

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

for n in range(1, N + 1):
    sum = 0
    root = int(math.sqrt(2*n))
    min = int(math.sqrt(2*n/3))
    if n<4:
        print(sum)
        continue
    for u in range(min - 1, root):
        for v in range(u, root):
            if int(u*u + v*v) >= int(2*n):
                break
            for w in range(v, int(root)):
                if int(u*u + v*v + w*w) > int(2*n):
                    break
                if int(u*u + v*v + w*w) == int(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:
a = int(input())
x = 1
listN = []
while x<=98:
    y =1
    while y<=98:
        if x**2+y**2+1+x+y+1<=10000:
          z = 1
          while z<=98:
              ans = x**2+y**2+z**2+x*y+y*z+z*x
              if ans<=10000:
                  listN.append(ans)
                  z = z+1
              else:
                  break
          y = y+1
        else:
          break
    x = x+1
n = 1
while n<=a:
    print(listN.count(n))
    n = n+1

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-4):
        for j in range(1,h-4):
            for k in range(1,h-4):
                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 math

n=int(input())

for x in range(1,n+1):
  ans=0
  b=int(math.sqrt(x))
  for q in range(1,b+1):
    c=int(math.sqrt(x-q*q))
    for r in range(1,c+1):
      d=x-q*q-r*r-q*r
      if d>0:
        
        e=int(math.sqrt(d))
        for s in range(1,e+1):
          if q*q+r*r+s*s+q*r+r*s+s*q==x:
            ans+=1
      
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def shiki(a, b, c):
    return a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a

def condition(n):
    count = 0
    i = 0
    j = 0
    z = 1
    while shiki(i, j, z) <= n and n > 5:
        for i in range(1, 100):
            for j in range(1, 100):
                z = 1
                while shiki(i, j, z) <= n and n > 5:
                    if n == shiki(i, j, z):
                        if i == j and j == z and i == z:
                            count += 1
                        else:
                            count += 1
                    z += 1
    print(count)

for i in range(1, N+1):
    condition(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
            if ans > i*2:
                break
        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())
def sqe(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)

    return x_1
  
for i in range(1,n+1):
  cnt = 0
  for x in range(1,80):
    if n-x**2<=0:
      break
    for y in range(1,int((n-x*2)**0.5)+1):
      if x**2+y**2+x*y>i:
        break
      x_1 = sqe(1,x+y,x**2+y**2+x*y-i)
      if x_1.is_integer() and x_1>0:
        cnt += 1
  print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
res = [0]*(N+1)
for i in range(1, N+1):
  for j in range(1, N+1):
    for k in range(1, N+1):
      C = i*i+j*j+k*k+i*j+j*k+k*i
      if (C <= N):
        res[C] += 1
      else:
        break
res.pop(0)
for i in res:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import math

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
            res = -x-y
            d = math.sqrt(-3*(x ** 2) - 2*(x*y) - 3*(y**2) + 4*i)
            if (((res - d)/2).is_integer() or ((res + d)/2).is_integer()) and (res+d > 0 or res-d > 0):
                count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math


def xyz(n):
    rng = math.floor(math.sqrt(n))
    count = 0
    for x in range(1, rng):
        for y in range(x, rng):
            for z in range(y, rng):
                if (x+y) ** 2 + (y+z) ** 2 + (z+x) ** 2 == 2 * n:
                    count = check(x, y, z)
    return count


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


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

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

n = int(input())
def calc(i):
    xs = [a for a in range(1,int(i**0.5))]
    ys = [a for a in range(1,int(i**0.5))]
    zs = [a for a in range(1,int(i**0.5))]
    cnt = 0
    for x,y,z in list(product(xs,ys,zs)):
        if (i % 6 == 0) or (i % 6 == 5) or (i % 6 == 1):
            if x**2+y**2+z**2+x*y+y*z+z*x == i:
                cnt += 1
    print(cnt)






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

Submission status: Time Limit Exceeded

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

import math
n = input()
N = int(n)
for i in range(1,N+1):
    ans = 0
    for x in range(1,math.floor(i**0.5)):
        lis =[x+1,math.floor((i-x**2)**0.5)]
        for y in range(1, min(lis)):
            z = (i - (x**2+y**2)*3/4 -x*y/2)**0.5 - (x+y)/2
            if is_integer_num(z)==True and 1 <=z <= y <= x:
                s = {x, y, z}
                for k in range(len(s)):
                    ans+= (k+1)
                break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

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

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


    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range (1, N + 1):
    print(sum(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n for x in range(1, n) for y in range(1, n) for z in range(1, n)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for a in range(1,n+1):
    ans = 0
    for i in range(1,100):
        for j in range(1,100):
            if i*2 + j*2 + i*j >= a:
                break
            for k in range(1,100):
                if i**2 + j**2 + k**2 +i*j + j*k + k*i == a:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
import collections

n = int(input())
cnt = [0] * n
for i in range(1,n+1):
  l = [j for j in range(1, int(i**0.5)+1)]
  d = collections.defaultdict(int)
  for k in itertools.product(l, l, l):
    d[tuple(sorted(k))] += 1
  for k, v in d.items():
    x, y, z = k
    if x**2 + y**2 + z**2 + x*y + y*z + z*x == i: cnt[i-1] += v
for i in cnt:
  print(i)