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

def judge(n, x=1, y=1, z=1, l=[]):
    result = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if result < n:
        return judge(n, x+1, y, z) + judge(n, x, y+1, z) + judge(n, x, y, z+1)
    elif result > n:
        return []
    elif result == n:
        return [[x,y,z]]

for i in range(1, n+1):
    li = judge(i, l=[])
    fn = len(set(tuple(a) for a in li))
    print(fn)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

def func(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
 
n = int(input())
s = int(math.sqrt(n))
nums = list(range(1,s))
arr = []
com = list(itertools.product(nums, repeat=3))
for i in range(len(com)):
    # print(com)
    ans = func(com[i][0],com[i][1],com[i][2])
    arr.append(ans)
 
for i in range(n):
    print(arr.count(i+1))

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):
    for y in range(1, x+1):
      for z in range(1, y+1):
        if (x+y)**2 + (y+z)**2 + (z+x)**2 == 2*i:
          if x == y and y == z and z == x:
          	count += 1
          else:
            count += 3
            
  print(count)

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 = [0] * (100 + 1)
for xyz in range(1, 100 + 1):
    p_eq[xyz] = calc(xyz, xyz, xyz)

p_ne = []
for x in range(1, 100):
    for y in range(1, 100):
        if x + y > 100:
            break
        for z in range(1, 100):
            if x + y + z > 100:
                break
            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 = [None] * (N+1)
for i in range(1, N+1):
    if i in p_eq:
        res[i] = 1
    elif i in p_ne:
        res[i] = 3
    else:
        res[i] = 0

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

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

n = int(math.sqrt(N))
l = []
for x in range(1, n):
    for y in range(1, n):
      for z in range(1, n):
        l.append(x**2 + y**2 + z**2 + x*y + y*z + z*x)

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

Submission status: Time Limit Exceeded

Solution code:
def solve():
    dp = [0]*(n+2)
    for x in range(1,151):
        for y in range(1,151):
            for z in range(1,151):
                a = x**2+y**2+z**2+x*y+y*z+z*x
                if a<=n:
                    dp[a] += 1
    for i in range(1,n+1):
        print(dp[i])                

if __name__=="__main__":
    n = int(input())
    solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range (1,N+1):
    cnt = 0
    for x in range (1,100):
        for y in range(x,100):
            for z in range(y,100):
                if (x + y + z) ** 2 - (x * y + y * z + z * x) == n:
                    cnt += 1
                    if x == y == z:
                        cnt += 0
                    elif x == y != z:
                        cnt += 2
                    elif x != y == z:
                        cnt += 2
                    else:
                        cnt += 5
                else:
                    cnt += 0
    print(str(cnt))

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 = []
com = list(itertools.product(nums, repeat=3))
for i in range(len(com)):
    # print(com)
    ans = func(com[i][0],com[i][1],com[i][2])
    arr.append(ans)
 
for i in range(n):
    print(arr.count(i+1))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N = int(input())

if int(float(N)**0.5) <= 1:
  xyzMax = 1
else:
  xyzMax = int(float(N)**0.5)

Ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range(1, N+1):
    ans = 0
    for x in range(1, int(n**0.5)+1):
        for y in range(1, int(n**0.5)+1):
            v = x**2+y**2+1+x*y+y*1+1*x
            if v>n:
                break
            for z in range(1, int(n**0.5)+1):
                v = x**2+y**2+z**2+x*y+y*z+z*x
                if v>n:
                    break
                elif v==n:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
for i in range(1,n+1):
    ans=0
    for x in range(1, math.floor(math.sqrt(i))+1):
        for y in range(1, math.floor(math.sqrt(i-x*x))+1):
            if x*x-y*y-x*y>i:
                break;
            for z in range(1, math.floor(math.sqrt(abs(i-x*x-y*y-x*y)))+1):
                if x*x + y*y + z*z + x*y + y*z + z*x > i:
                    break
                if x*x + y*y + z*z + x*y + y*z + z*x == i:
                    ans += 1
    print(ans)

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

    if N < 4:
        print(count)
        continue
    imax = int((N-4)**0.5)
    for i in range(1,imax):
        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:
N = int(input())
ls = [0]*(N+2)

for i in range(1,151):
    for j in range(1,151):
        for k in range(1,151):
            t = i**2 + j**2 + k**2 + i*j + j*k + k*i 
            if t <= N :
                ls[t] += 1

for p in range(1,N+1):
    print(ls[p])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
for l in range(1, n+1):
  for i in range(1, 41):
    for j in range(1, 41):
      if (i+j+i)**2-(i*j+j*i+i*i) == l:
        if i == j:   
          count += 1
        else:
          count += 3  
  print(count)
  count = 0

Submission status: Time Limit Exceeded

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



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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
 
N = int(input())
for n_m in range(N):
    n = n_m + 1
 
    result = 0
 
 
    lim_n = int(np.sqrt(n)) +1
 
    done_list = []
    for x in range(1, lim_n):
 
        if (n-x**2 - 2*x) <= 0:
            continue
        lim_n_y = int(np.sqrt(n-x**2 - 2*x)) +1 
        for y in range(x, lim_n_y):
            
            if (n - y**2 - x ** 2 -x * y) <= 0:
                continue
            lim_n_z = int(np.sqrt(n - y**2 - x ** 2 -x * y ))+1
            
            for z in range(y, lim_n_z):
 
                if x**2 + y**2 + z**2 + (x+y+z)**2 == 2*n:
 
                    set_res = len(list(set([x,y,z])))
                    if  set_res == 1:
                        result += 1
                    elif set_res == 2:
                        result += 3
                    else:
                        result += 1
                            
                            
    print(result)

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(100):
        for j in range(100):
            # 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(100):
                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
                break
    print(ans)

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-4:
        for j in range(1,N-4):
            if j**2+j<=N-4:
                for k in range(1,N-4):
                    k**2+k<=N-4
                    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:
N = int(input())
cnt = 0

def f(x,y,z,n):
    r = x*x + y*y + z*z + x*y + y*z + z*x
    if r == n:
        return True

for t in range(1,N+1):
    cnt = 0
    for x in range(1,int(N/2)):
        if x*x > t:
            break
        for y in range(1,int(N/2)):
            if y*y > t:
                break
            for z in range(1,int(N/2)):
                if z*z > t:
                    break
                if f(x,y,z,t):
                    cnt = cnt + 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from math import trunc, sqrt

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

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

def eqn(n,x,y):
    s=4*n-3*x**2-2*x*y-3*y**2
    if s<0:
        return (False,0,0)

    t=sqrt(s)
    z1=(-t-x-y)/2
    z2=(t-x-y)/2
    return (True,z1,z2)
    

def is_int(x):
    return trunc(x)==x

def f(n):
    #print("==",n)
    mn=trunc(sqrt(n//3)+1)
    k=[]
    for x in range(1,mn+1):
        for y in range(1,mn+1):
            
            (f,z1,z2)=eqn(n,x,y)
            #print(f,z1,z2)
            
            if not f:
                continue

            if z1>0 and is_int(z1):
                k+=[(x,y,z1)]

            if z2!=z1:
                if z2>0 and is_int(z2):
                    k+=[(x,y,z2)]
            
    return len(k)

N=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(n):
    ans = 0
    for x in range(100 ):
        for y in range(100):
            for z in range(100):
                if ((x+1)**2 + (y+1)**2 + (z+1)**2 + (x+1)*(y+1) + (y+1)*(z+1) + (z+1)*(x+1)) == i+1:
                    ans += 1
                #print(((x+1)**2 + (y+1)**2 + (z+1)**2 + (x+1)*(y+1) + (y+1)*(z+1) + (z+1)*(x+1)))
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
count = 0
flag = False
# n = int(math.sqrt(N))
n = N // 5

for i in range(1, N + 1):
    
    for j in range(1, n):
        for l in range(1, n):
            for r in range(1, n):
                if j ** 2 + l ** 2 + r ** 2 + j * l + j * r + l * r == i:
                    if j == l == r:
                        flag = True
                        count = 1
                        break
                    else:
                        flag = True
                        count = 3
                        break
            if flag:
                break
        if flag:
            break            
    print(count)
    count = 0
    flag = False

Submission status: Time Limit Exceeded

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

for i in range(1, n+1):
  count = 0
  rout = int(math.sqrt(i))
  for x in range(1, rout+1):
    for y in range(1, x+1):
      for z in range(1, y+1):
        if (x+y)**2 + (y+z)**2 + (z+x)**2 == 2*i:
          if x == y and y == z and z == x:
          	count += 1
          else:
            count += 3
            
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools
N=int(input())
for n in range(1,N+1):
    ans=0
    if n<=5:
        print(ans)
        continue
    X=math.floor(n**0.5)
    com=itertools.combinations_with_replacement(range(1,X+1),3)
    for x,y,z in com:
                if x**2 + y**2 + z**2 + x*y + y*z + x*z==n:
                    if (x==y and y!=z and z!=x) or (x!=y and y==z and z!=x) or (x!=y and y!=z and z==x): 
                        ans+=3
                    elif x==y and y==z and z==x:
                        ans+=1
                    else:
                        ans+=6
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(sys.stdin.readline())
for n in range(1,N+1):
  if n < 6:
    x,y,z = 0,0,0
  else:
    x = int((n / 6)**0.5)
    y = int(round((((n -1)/3) - 1/9)**0.5 - 1/3 + 0.5,0))
    z = int((n - 5)**0.5 + 1)
  ans = 0
  for i in range(1,x+1):
    for j in range(i,y+1):
      if i % 2 == j % 2:
        d = 2
        if n % 2 == 0:
          c = 0
        else:
          c = 1
      else:
        d = 1
        if n % 2 == 0:
          c = 10000
        else:
          c = 0    
      for k in range(j + c, z+1, d):
        p = (i + j + k)**2 - i*(j + k) - j*k
        if n < p:
          break
        if n == p:
          if i == j:
            if j == k:
              ans += 1
            else:
              ans += 3
          else:
            if i == k:
              ans += 3
            else:
              if j == k:
                ans += 3
              else:
                ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

D = defaultdict(int)

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

N=int(input())
for i in range(1,N+1):
    ans=0
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                ret = f(x,y,z)
                if ret==N:
                    ans+=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
count = 0
flag = False
n = int(math.sqrt(N)) 
for i in range(1, N + 1):
    
    for j in range(1, n):
        for l in range(1, n):
            for r in range(1, n):
                if j ** 2 + l ** 2 + r ** 2 + j * l + j * r + l * r == i:
                    if j == l == r:
                        flag = True
                        count = 1
                        break
                    else:
                        flag = True
                        count = 3
                        break
            if flag:
                break
        if flag:
            break            
    print(count)
    count = 0
    flag = False

Submission status: Time Limit Exceeded

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

def f(x,y,z,n):
    r = x*x + y*y + z*z + x*y + y*z + z*x
    if r == n:
        return True

for t in range(1,N+1):
    cnt = 0
    for x in range(1,N):
        if x*x > t:
            break
        for y in range(1,N):
            if y*y > t:
                break
            for z in range(1,N):
                if z*z > t:
                    break
                if f(x,y,z,t):
                    cnt = cnt + 1
    print(cnt)

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, 10):
            for j in range(1, 10):
                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())
arr = [False]*(N+1)

for i in range(1, N+1):
    num = 0
    sqi = int(float(i)**0.5)
    sec = arr.copy()
    for j in range(1,sqi+1):
        sqj = int(float(i-j**2)**0.5)
        if not(sec[j]):
            #print(sec[j])
            #print("num"+str(j))
            for k in range(1, sqj+1):
                c = float(i-j**2-k**2-j*k)
                if c > 0:
                    c *= -1.0
                    b = float(j) + float(k)
                    d = b**2-4*c
                    if d >=0.0:
                        z = (-b + d**0.5)/2.0
                        if z.is_integer():
                            #print(j,k,z)
                            z = int(z)
                            sec[j]=True
                            sec[k]=True
                            sec[z]=True
                            if j==k and k == z:
                                num += 1
                            elif j == k or k == z or j ==z:
                                num += 3
                            else:
                                num +=6
                            #print(sec)
                            break
                else:
                    break

    print(num)

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):
        flag = False
        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])
                    flag = True
                    break
            if flag:
                break

    print(sum)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
tot=[]
for a in range(1,N+1):
    count=0
    n=int(a**(1/2))+1
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i**2+j**2+k**2+i*j+j*k+k*i==a:
                    count+=6
                    
    for i in range(1,10**2):
        for j in range(1,i):
            if 3*i**2+j**2+2*i*j==a:
                count+=3
    for j in range(1,10**2):
        for i in range(1,j):
            if 3*i**2+j**2+2*i*j==a:
                count+=3

    for i in range(1,10**2):
        if 6*i**2==a:
            count+=1
    print(count)

Submission status: Time Limit Exceeded

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

n=int(input())
an = []
for i in range(1,50):
    for j in range(1,50):
        for k in range(1,50):
            wk=ff(i,j,k)
            if wk<=n:
                an.append(wk)
            else:
                break

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip



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

def calc2(x, y, z):
    return x*x + y*y + z*z + x*y + x*z + y*z


def f(n):
    res = []
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                # res.append((i,j,k,calc(i, j, k)))
                res.append(calc(i, j, k))
                # pass
    return res

if __name__ == '__main__':
    N = int(input())

    import time

    # start = time.time()
    res = f(200)
    # elapsed_time = time.time() - start
    # print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

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

Submission status: Time Limit Exceeded

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

def comb(x):
    if x<6:
        return 0
    count=0
    for i in range(1,int(math.sqrt(x-2))):
        if i**2+2*i>x-3:
            break
        for j in range(i,int(math.sqrt(x-2))):
            if i**2+j**2+(i+1)*(j+1)>x+1:
                break
#            if 3*(i**2+j**2)+2*i*j-4*x>0:
#                break
            k=(-i-j+math.sqrt((i+j)**2-4*(i**2+j**2+i*j-x)))/2
            if k<j:
                break
            elif k.is_integer() and k>0:
                if len(set([i,j,k]))==3:
                    count+=6
                elif len(set([i,j,k]))==2:
                    count+=3
                else:
                    count+=1
    
                
            """
            for k in range(j,int(math.sqrt(x-2))):
                if i**2+j**2+k**2+i*j+j*k+k*i>x:
                    break
                if i**2+j**2+k**2+i*j+j*k+k*i==x:
                    if len(set([i,j,k]))==3:
                        count+=6
                    elif len(set([i,j,k]))==2:
                        count+=3
                    else:
                        count+=1
            """
    return count

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
n=1
while n<=N:
    check=[]*100
    c=0
    for x in range(1,int(n**0.5)+1):
        for y in range(1,x+1):
            for z in range(1,y+1):
                if (x+y)**2+(y+z)**2+(z+x)**2==2*n:
                    if x==y and y==z:
                        c+=1
                    elif x==y or y==z or z==x:
                        c+=3
                    else:
                        c+=6
    print(c)
    n+=1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
 
for n in range(1,N+1):
    cnt = 0
    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                a = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if a == n:
                    cnt += 1
    
    print(cnt)

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 > 20:
            break

    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline

def calc(n):
    for i in range(1,n):
        for j in range(1,n):
            for k in range(1,n):
                if (i+j+k)**2 - i*j - j*k - k*i == n:
                    if i == j == k:
                        return 1
                    else:
                        return 3
    return 0    

def main():
    ans = 0
    n = int(input())
    for i in range(1,n):
        print(calc(i))

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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 > 50:
            break

    print(cnt)

Submission status: Time Limit Exceeded

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

def f(x,y,z,n):
    r = x*x + y*y + z*z + x*y + y*z + z*x
    if r == n:
        return True

for t in range(1,N+1):
    cnt = 0
    for x in range(1,N):
        for y in range(1,N):
            for z in range(1,N):
                if f(x,y,z,t):
                    cnt = cnt + 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(sys.stdin.readline())
for n in range(1,N+1):
  if n < 6:
    x,y,z = 0,0,0
  else:
    x = int((n / 6)**0.5)
    y = int((((n -1)/3) - 1/9)**0.5 - 1/3 + 1)
    z = int((n - 5)**0.5 + 1)
  ans = 0
  for i in range(1,x+1):
    for j in range(i,y+1):
      if i % 2 == j % 2:
        d = 2
        if n % 2 == 0:
          c = 0
        else:
          c = 1
      else:
        d = 1
        if n % 2 == 0:
          c = 10000
        else:
          c = 0    
      for k in range(j + c, z+1, d):
        p = (i + j + k)**2 - i*(j + k) - j*k
        if n < p:
          break
        if n == p:
          if i == j:
            if j == k:
              ans += 1
            else:
              ans += 3
          else:
            if i == k:
              ans += 3
            else:
              if j == k:
                ans += 3
              else:
                ans += 6
  print(ans)

Submission status: Time Limit Exceeded

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

N = int(input())
for n in range(1 , N + 1):
    ans = 0
    for x in range(1, 101):
        xxx = ans_xyz(x, x, x)
        if xxx > n:
            break
        elif xxx == n:
            ans += 1
            break
        for y in range(x + 1, 101):
            xxy = ans_xyz(x, x, y)
            if xxy > n:
                break
            elif xxy == n:
                ans += 3
                break
            xyy = ans_xyz(x, y, y)
            if xyy > n:
                continue
            elif xyy == n:
                ans += 3
                continue
            for z in range(y + 1, 101):
                if ans_xyz(x, y, z) > n:
                    break
                elif ans_xyz(x, y, z) == n:
                    ans += 6
                    break
    print(ans)

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:
n=int(input())
r=range(1,int(2*n**.5)+1)
l=[0]*-~n
for i in r:
  for j in r:
    for k in r:
      t=(j+k)**2+(k+i)**2+(i+j)**2
      if t<=n*2 and t%2<1: l[t//2]+=1
for i in range(n): print(l[i+1])

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 > 100:
            break

    print(cnt)

Submission status: Time Limit Exceeded

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