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:
# -*- coding: utf-8 -*-
import math

N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, int(math.sqrt(i+1))):
    for y in range(x, i):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n <= N:
        if x == y and x == z:
          f[n-1] += 1
        elif x == y or y == z:
          f[n-1] += 3
        elif x != y and x != z and y != z:
          f[n-1] += 6
for i in f:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
if N > 3:
    print(0)
    print(0)
    for i in range(3, N+1):
        ra = math.sqrt(i - 2) - 1
        ran = math.floor(ra)
        ans = 0
        for x in range(1, ran+1):
            for y in range(1, ran+1):
                for z in range(1, ran+1):
                    f = x**2 + y**2 + z**2 + x*y + y*z + z*x
                    if i == f:
                        ans += 1
        print(ans)
else:
    for i in range(1, N+1):
        print(0)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
n = int(input())
a = []
for i in range(1, int(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:
#-*-coding:utf-8-*-
 
import sys
import math
 
def main():
    n = int(input())
    root_n=math.ceil(math.sqrt(n))
    ans=[0]*n
    count=0
    for i in range(1,n+1):
        for x in range(1,root_n):
            if x**2 >= i:
                break
            for y in range(1,root_n):
                for z in range(1,root_n):
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        count+=1
        print(count)
        count=0
 
if __name__ == "__main__":
    main()

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):
    if x**2 > i:
      break
    else:
      for y in range(1,xyzMax+1):
        if x**2 + y**2 > i:
          break
        else:
          for z in range(1,xyzMax+1):
            if x**2 + y**2 + z**2 > i:
              break
            else:
              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:
#-*-coding:utf-8-*-

import sys
import math

def main():
    n = int(input())
    root_n=math.ceil(math.sqrt(n))
    ans=[0]*n
    count=0
    for i in range(1,n+1):
        for x in range(1,root_n):
            if x**2 >= i:
                break
            for y in range(1,root_n):
                for z in range(1,root_n):
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        count+=1
        print(count)
        count=0

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

while number <= N:
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in range(1,N+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == number:
                    cnt += 1
                else:
                    continue
    print(cnt)
    cnt = 0
    number += 1

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, i):
    for y in range(x, i):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n <= N:
        if x == y and x == z:
          f[n-1] += 1
        elif x == y or y == z:
          f[n-1] += 3
        elif x != y and x != z and y != z:
          f[n-1] += 6
for i in f:
  print(i)

Submission status: Time Limit Exceeded

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

  
N = int(input())
pattern = []

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            pattern.append(f(x, y, z))

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

Submission status: Time Limit Exceeded

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

# def f2(x, y, z, n):
#     return x*x+y*y+z*z+x*y+y*z+z*x

def f(x, y, z, n):
    if x*x+y*y+z*z+x*y+y*z+z*x == n:
        return True
    else:
        return False
def main():
    N = int(input())
    for n in range(1, N + 1):
        cnt = 0
        for x in range(1, 100):
            if x * x > n:
                break
            for y in range(x, 100):
                if x*x + y*y > n:
                    break
                for z in range(y, 100):
                    if x*x + y*y + z*z > n:
                        break
                    if f(x, y, z, n):
                        # print(x, end=' ')
                        # print(y, end=' ')
                        # print(z)
                        if x == y == z:
                            cnt += 1
                        elif x != y and y != z and z != x:
                            cnt += 6
                        else:
                            cnt += 3
        # print(n, end=': ')
        print(cnt)
    return
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    ans = [0]*(n+1)
    for p in range(1,n+1):
        for i in range(1,p):
            for j in range(1,p):
                if (i+j)**2-4*(i**2+j**2+i*j-p)<0:
                    continue
                k = (((i+j)**2-4*(i**2+j**2+i*j-p))**0.5-i-j)/2
                if k.is_integer() and k>0:
                    ans[p] +=1

    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

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-(i+1)**2):
            # 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-(i+1)**2-(j+1)**2-(i+1)*(j+1)):
                if (i + 1) ** 2 + (j + 1) ** 2 + (k + 1) ** 2 + (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (
                        i + 1) == l + 1:
                    if i == j == k:
                        ans = 1
                        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:
if __name__ == "__main__":
    
    n = int(input())

    for o in range(1, n+1):
        s = 1
        if o > 6:
            s = -1 + int((o-2)**0.5)
        for x in range(s, 100):
            isFound = 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:
                        break
                if isFound: break
            if isFound: break
        if not isFound: print(0)

Submission status: Time Limit Exceeded

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

for i in range(1, n+1):
  count = 0
  upper = int(math.sqrt(i))
  lower = int(math.sqrt(i/6))
  for x in range(lower, upper):
    for y in range(lower, x+1):
      for z in range(lower, 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:
N = int(input())

list = []
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            list.append(i**2 + j**2 + k**2 +i*j + j*k + k*i)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

# (x + y) ** 2 = x2 + 2xy + y2
# (y + z) ** 2 = y2 + 2yz + z2
# (z + x) ** 2 = z2 + 2zx + x2
# 右辺 2(x2 + y2 + z2 + xy + yz + zx)
# よって (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 = 2 * n

# x**2 + y**2 + z**2 + xy + yz + zx = n

# x = y = 1, N = 10**4の時のZは大きくて100なので100まで回せばよい
# 4 + 2(z**2 + 2z + 1) = 2 * 10**4
# 2 + z ** 2 + 2z + 1 = 10**4
# z(z + 2) = 10 ** 4 - 3
# 時間がかかりすぎるからx,y,zの値によって+1, +3, +6する 3C3, 3C2, 3C1


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


# F = [0] * (10**4 + 1)
# F = [0] * (N + 1)
# for i in range(1, 10**4 + 1):
for i in range(1, N + 1):
    f = 0
    # for i in range(83, N + 1):
    right = 2 * i
    # print(f'{i=}')
    for x in range(1, 101):
        if f1(x, 1, 1) > right:
            break
        for y in range(x, 101):
            if f1(x, y, 1) > right:
                break

            for z in range(y, 101):
                # print(f'{i=}, {x=}, {y=}, {z=}')
                left = f1(x, y, z)
                if left > right:
                    break
                if left == right:
                    # print(f'{i=}, {x=}, {y=}, {z=}')
                    if x == y == z:
                        # F[i] += 1
                        f += 1
                    elif x == y or y == z or z == x:
                        # F[i] += 3
                        f += 3
                    else:
                        # F[i] += 6
                        f += 6
    print(f)
# print(f'{F=}')

Submission status: Time Limit Exceeded

Solution code:
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
#INF = float('inf')
mod = int(1e9)+7

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

n=int(data())
for l in range(1,n+1):
    cnt=0
    for i in range(1,int(l**0.5)):
        for j in range(1,int(l**0.5)):
            if cal(i,j,1)>l:
                break
            for k in range(1,int(l**0.5)):
                a= cal(i,j,k)
                if a==l:
                    cnt+=1
                elif a>l:
                    break
    out(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, ), cache=True)
def main(n):
    for s in range(1, n+1):
        ans = 0
        for i in range(1, 101):
            for j in range(1, 101):
                for k in range(1, 101):
                    if i*i + j*j + k*k + i*j + j*k + k*i == s:
                        ans += 1
        print(ans)
        ans = 0


n = int(read())
main(n)

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-(i+1)**2):
            # 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-(i+1)**2-(j+1)**2):
                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())

list = []
for i in range(1, 50):
    for j in range(1, 50):
        for k in range(1, 50):
            list.append(i**2 + j**2 + k**2 +i*j + j*k + k*i)

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

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

rtn = int(math.sqrt(N))

used = [[0]*3]*N

count = [0] * N


if N <= 5:
    for x in range(N):
        print(count[x])
else:
    for n in range(6,N):
        #print(n)
        for x in range(1,rtn):
            #print(x)
            xx = x**2
            if xx <= n - 5:
                #print("xpath")
                for y in range(1,rtn):
                    #print(x,y)
                    xy = x*y
                    yy = y**2
                    ysum = xx+yy+xy
                    if ysum <= n-3:
                        #print("ypath")
                        for z in range(1,rtn):
                            #print(x,y,z)
                            zz = z**2
                            xz = x*z
                            yz = y*z
                            result = ysum+zz+xz+yz
                            if result > n:
                                break
                            if result == n:
                                count[n-1] += 1
                                #print("zpath")
                                used.append
    for x in range(N):
        print(count[x])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
f = lambda x,y,z:x**2+y**2+z**2+x*y+y*z+z*x

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

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])
    ans = com[i][0]**2+com[i][1]**2+com[i][2]**2+com[i][0]*com[i][1]+com[i][1]*com[i][2]+com[i][0]*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):
    cnt = 0
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                if x**2 + y**2 + z**2 +x*y + y*z + z*x == i:
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

L=input()
L=int(L)
for b in range(1,80):
    i=0
    a=math.sqrt(b)
    a=int(a)
    for x in range(1,80):
        for y in range(1,80):
        
            for z in range(1,80):

                if x**2+y**2+z**2+x*y+y*z+z*x==b:
                    i+=1
                    
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement

N = int(input())

a = [0] * N


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


for i in combinations_with_replacement(range(1, N), 3):
    tmp = f(*i)
    if tmp >= N:
        continue
    plus = 1 if len(set(i)) == 1 else 3
    a[tmp - 1] += plus

print("\n".join(map(str, a)))

Submission status: Time Limit Exceeded

Solution code:
### Problem C
import math

N = int(input())

for x in range(1,N+1):
    cnt = 0

    for i in range(1,101):
        for j in range(1,101-(i-1)):
            for k in range(1,101-(i-1)-(j-1)):
                if (i + j + k)**2 == x + (i*j + j*k + k*i):
                    cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, i):
    for y in range(x, i):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n > N:
        continue
      if x == y and x == z:
        f[n-1] += 1
      elif x == y or y == z:
        f[n-1] += 3
      elif x != y and x != z and y != z:
        f[n-1] += 6
for i in f:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
import math

def run():
    N = int(input())
    for n in range(1, N+1):
        ret = 0
        val = int(math.sqrt(2 * n))
        for X in range(-val, val+1):
            for Y in range(-val, val+1):
                tmp1 = 2 * n - X ** 2 - Y ** 2
                if tmp1 >= 0 and math.sqrt(tmp1) == int(math.sqrt(tmp1)):
                    Z_ = int(math.sqrt(tmp1))
                    if Z_ != 0:
                        for k in [-1, 1]:
                            Z = Z_ * k
                            if not (X + Y + Z) % 2:
                                xyz = (X + Y + Z) // 2
                                x = xyz - Y
                                y = xyz - Z
                                z = xyz - X
                                if x >= 1 and y >= 1 and z >= 1:
                                    ret += 1
                                    #print(x, y,z)


        print(ret)



if __name__ == "__main__":
    run()

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/4)):
        if x*x > t:
            break
        for y in range(1,int(N/4)):
            if y*y > t or x*y > t:
                break
            for z in range(1,int(N/4)):
                if z*z > t or y*z > t or z*x > t:
                    break
                if f(x,y,z,t):
                    cnt = cnt + 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
dp = [[[0 for x in range(n + 2)] for y in range(n + 2)] for z in range(n + 2)]

for i in range(1, n + 1):
    cnt = 0
    f = int(math.sqrt(n)) + 1
    for x in range(1, f):
        for y in range(1, f):
            for z in range(1, f):
                if dp[x][y][z] > 0:
                    if dp[x][y][z] == i:
                        cnt += 1
                else:
                    dp[x][y][z] = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
                    if dp[x][y][z] == i:
                        cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
### Problem C
import math

N = int(input())

for x in range(1,N+1):
    cnt = 0

    for i in range(1,101):
        for j in range(1,101):
            for k in range(1,101):
                if (i + j + k)**2 == x + (i*j + j*k + k*i):
                    cnt += 1
    print(cnt)

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):
        
        if right - x**2 < 1:
            continue
        
        for y in range(1, int(np.ceil(np.sqrt(right - x**2))) + 1):
          
            if right - x**2 - y**2 < 1:
                continue
          
            for z in range(1,int(np.ceil(np.sqrt(right - x**2 - y**2))) + 1):
                if (x + y + z) % 2 != 0:
                    continue
                  
                elif (x ** 2 + y ** 2 + z ** 2 == 2 * i) & (x + y > z) & (y + z > x) & (z + x > y):
                    count += 1
            
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

rtn = int(math.sqrt(N)) + 1 

used = []

count = [0] * N


if N <= 5:
    for x in range(N):
        print(count[x])
else:
    for n in range(6,N):
        #print(n)
        for x in range(1,rtn):
            #print(x)
            xx = x**2
            if xx <= n - 5:
                #print("xpath")
                for y in range(1,rtn):
                    #print(x,y)
                    xy = x*y
                    yy = y**2
                    ysum = xx+yy+xy
                    if ysum <= n-3:
                        #print("ypath")
                        for z in range(1,rtn):
                            #print(x,y,z)
                            zz = z**2
                            xz = x*z
                            yz = y*z
                            result = ysum+zz+xz+yz
                            if result > n:
                                break
                            if result == n:
                                count[n-1] += 1
                                #print("zpath")
    for x in range(N):
        print(count[x])

Submission status: Time Limit Exceeded

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

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 + l + r > N // 2:
                    continue
                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,int(N/2)):
        if x*x > t:
            break
        for y in range(1,int(N/2)):
            if y*y > t or x*y > t:
                break
            for z in range(1,int(N/2)):
                if z*z > t or y*z > t or z*x > t:
                    break
                if f(x,y,z,t):
                    cnt = cnt + 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

for i in range(1, N+1):
    ans = 0
    for x in range(1, 41):
        for y in range(1, 41):
            for z in range(1, 41):
                tmp = count(x, y, z)
                if tmp > N:
                    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('0')
  elif i == 6:
    print('1')
  else:
    for j in range(1,101):
      for k in range(1,101):
        for l in range(1,101):
          if (j**2+k**2+l**2+j*k+k*l+l*j)==i:
            count += 1
        
    print(count)

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
            if num > N:
                continue
            tmp.append(num)
            num = 0



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

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:
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(120)
    # elapsed_time = time.time() - start
    # print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

    s = ""
    for i in range(1, N+1):
        s += str(res.count(i)) + "\n"

    print(s)

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 + l + r) * 2 > N:
                    continue
                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
for n in range(1, int(input())+1):
    b=0
    a=[0]*103
    l=int(math.sqrt(n)) + 1
    for i in range(1, l + 1):
        if a[i]: continue
        for j in range(1, l + 1):
            if a[j]: continue
            # we know z at this point
            d = i + j
            c = n - i**2 - j**2 - i*j
            try:
                k = int(math.sqrt(d**2 + 4*c) - d - 1)
                if k < 1: continue
                if n == (i**2 + j**2 + k**2 + i*j + j*k + i*k):
                    a[i] = True
                    a[j] = True
                    a[k] = True
                    if i == j and i == k and j == k:
                        b+= 1
                    elif i != j and i != k and j !=k:
                        b+=6
                    else:
                        b+=3
            except:
                pass
    print(b)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

for i in range(1,N+1):
  answer_set=set()
  for x in range(int(i**0.5)+1):
    for y in range(1,x+1):
      if func(x,y,1)>i:
        break
      for z in range(1,y+1):
        if func(x,y,z)==i:
          answer_set.add((x,y,z))
          answer_set.add((x,z,y))
          answer_set.add((y,x,z))
          answer_set.add((y,z,x))
          answer_set.add((z,y,x))
          answer_set.add((z,x,y))
        elif func(x,y,z)>i:
          break
          
  print(len(answer_set))