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:
def f(n):
  cnt = 0
  for i in range(int((n-3)**1/2 //1)):
    for j in range(int((n-i**2)**1/2 //1)):
      for k in range(int((n-i**2-j**2)**1/2 //1)):
        if (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1) == n:
          cnt += 1
  return cnt
    
N = int(input())
for i in range(N):
  print(f(i+1))

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools


def f(n):
    squares = [i for i in range(4, 2 * n + 1) if (int(math.sqrt(i))**2) == i]

    square_combs = itertools.combinations_with_replacement(squares, 3)
    square_combs = [comb for comb in square_combs if (comb[0] + comb[1] + comb[2]) == (2 * n)]

    num_combs_satisfy_cond = 0

    for comb in square_combs:
        if len(set(comb)) == 1:
            num_combs_satisfy_cond += 1
        else:
            sorted_comb = sorted(comb)

            if (math.sqrt(sorted_comb[0]) + math.sqrt(sorted_comb[1])) != math.sqrt(sorted_comb[2]):
                num_combs_satisfy_cond += 3

    return num_combs_satisfy_cond


n = int(input())

for i in range(1, n + 1):
    ans = f(i)

    print(ans)

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.add(x)
                    s.add(y)
                    s.add(z)
                    break

    print(sum)

Submission status: Time Limit Exceeded

Solution code:

from collections import defaultdict
import math
n=int(input())
d=defaultdict(int)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = []
for x in range(1, 50):
    for y in range(1, 50):
      for z in range(1, 50):
        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:
# 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)

for i in range(1, N + 1):
    loops += 1
    if i in p_eq:
        print(1)
    elif i in p_ne:
        print(3)
    else:
        print(0)

# print('lp', loops)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
 
for n in range(1,N+1):
  ans = 0
  check = False
  for x in range(1,42):
    for y in range(x,64):
      for z in range(y,100):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == n:
          if x == y and y == x and z == x:
            ans += 1
          elif x == y  or z == x or y == z:
            ans += 3
          elif x != y and y != z and z != x:
            ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

N = int(input())

for i in range(N):
    count = 0
    a = list(range(1, int(math.sqrt(i) + 1)))
    b = list(itertools.combinations_with_replacement(a, 3))
    for k in range(len(b)):
        f = b[k][0] ** 2 + b[k][1] ** 2 + b[k][2] ** 2 + b[k][0] * b[k][1] + b[k][1] * b[k][2] + b[k][2] * b[k][0]
        if f == i + 1:
            count += len(sorted(set(itertools.permutations(b[k]))))
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
def f(n):
  ans=0
  K=int(math.sqrt(n))
  K2=int(math.sqrt(n/6))
  for x in range(K2,K+1):
    L=min(x,int(math.sqrt(n-x**2)))
    L2=int(math.sqrt((n-x**2)/5))
    for y in range(L2,L+1):
      z=min(y,round(math.sqrt(n-x**2-y**2-x*y+(x+y)**2/4)-(x+y)/2))
      if x**2+y**2+z**2+x*y+y*z+z*x==n and z>=1:
        if x==z:
          ans+=1
        elif x==y or y==z:
          ans+=3
        else:
          ans+=6
  return ans

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

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

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

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):
    a,b,c = A[0],A[1],A[2]
    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:
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):
    for y in range(x+1,34):
      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):
    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())
n_2 = math.floor((n)**(1/2))
cnt = 0
for n in range(1,n+1):
  cnt = 0
  for x in range(1,n_2 +1):
    for y in range(1, n_2 +1):
      for z in range(1, n_2 +1):
        if (x+y+z)**2 == (n + x*y + y*z + z*x):
          cnt +=1
  print(cnt)

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

import sys
import math

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

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

        if not ok_flag:
            print(0)
        ok_flag = False
        
                        

    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import sys
    import math

    readline = sys.stdin.readline

    N = int(readline())

    for i in range(1, N + 1):
        ans = 0
        li = int(math.sqrt(i))
        for x in range(1, li):
            xx = x * x
            for y in range(1, li):
                yy = y * y
                xy = x * y
                x_y = x + y
                value = (x_y) ** 2 - 4 * (xx + yy + xy - i)
                if value <= 0:
                    continue
                cal = math.sqrt(value)
                z1 = (-(x_y) + cal) * 0.5
                z2 = (-(x_y) - cal) * 0.5
                if (1
                        and 1 <= z1
                        and z1 % 1 == 0):
                    ans += 1
                if (1
                        and 1 <= z2
                        and z2 % 1 == 0):
                    ans += 1
        print(ans)


resolve()

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

N =  int(input().strip())


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


def func(n):
    # print(f"{n} ===")
    cnt = 0
    k = math.floor(math.sqrt(n))
    for v in itertools.product(range(1, k+1), repeat=3):
        # print(v)
        if calc(*v) == n:
            cnt += 1
    return cnt


for k in range(1, N+1):
    cnt = func(k)
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque 

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

def bfs (n,x,y,z):
    queue = deque([[x,y,z]])
    count = 0
    while queue:
        x,y,z = queue.popleft()
        for dx, dy, dz in ([1,0,0],[0,1,0],[0,0,1]):
            newx, newy, newz = x + dx, y + dy, z + dz
            ans = calculate(newx,newy,newz)
            if ans == n and [newx, newy, newz] not in queue:
                count+= 1
            
            if ans > (n + 1):
                queue = []
                break
            else:
                queue.append([newx,newy,newz])
    return count

N = int(input())
list_xyz = (1,1,1)
n = list_xyz[0]**2 + list_xyz[1]**2 + list_xyz[2]**2 + list_xyz[0]*list_xyz[1] + list_xyz[1]*list_xyz[2] + list_xyz[2]*list_xyz[0] 

for i in range(1,N+1):
  count = 0
  n = calculate(list_xyz[0], list_xyz[1], list_xyz[2])
  if n == i:
      count +=1
  count += bfs(i, list_xyz[0], list_xyz[1], list_xyz[2])
  print(count)

Submission status: Time Limit Exceeded

Solution code:
from copy import deepcopy
import collections
import sys
n = int(input())

x = 1
y = 1
z = 1
l = [1,1,1]

if n < 6:
	for i in range(n):
		print(0)
	sys.exit()

ans = [0 for _ in range(n)]
ans[5] = 1
s = set()
t = set()
t.add((1,1,1))
i = 0
flag = False
while i < 10**7:
	i += 1
	for j in range(len(t)):
		l = list(t.pop())
		for k in range(3):
			l[k] += 1
			tmp = tuple(sorted(l))
			if tmp not in s:
				s.add(tmp)
			l[k] -= 1
		t = deepcopy(s)
		for k in range(len(s)):
			l = s.pop()
			count = len(collections.Counter(l))
			num = sum(l)**2 - l[0]*l[1] - l[1]*l[2] - l[2]*l[0] - 1
			if num >= n:
				continue
			#print(l,count,num)
			if count == 1:
				ans[num] += 1
			elif count == 2:
				ans[num] += 3
			else:
				ans[num] += 6
	if flag:
		break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = 4
_S = S -2
O = 16
I = 9

for i in range(min(I, N)):
  if (i == 5):
    print(1)
  else:
    print(0)
    
for i in range(I+1,N+1):
  if i >= O:
    S += 1
    _S += 1
    O = S**2
  for x in range(1, _S): 
    for y in range(1,_S-x+1):
      for z in range(1,S-x-y+2):
        if (x+y+z)**2 - (x*y + y*z + z*x) == i:
          print(3)
          break
      else:
        continue
      break
    else:
      continue
    break
  else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for h in range(1,N+1):
    num=0
    for i in range(1,h-3):
        for j in range(1,h-3):
            for k in range(1,h-3):
                if i**2+j**2+k**2+i*j+j*k+k*i==h:
                    num+=1
    print(num)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
from math import floor
n = int(input())

for i in range(1, n + 1):
    n2 = floor(sqrt(i))
    ans = 0
    for x in range(1, n2):
        for y in range(1, n2):
            for z in range(1, n2):
                if i == pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x:
                    ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
c = 0
n = 0
list = []
for l in range(1,N+1):
    list = []
    for i in range(1,l+1):       
        for j in range(1,l+1):
            if i*i + j*j + i*j > l:
                break;
            for k in range(1,l+1):
                #print(i,j,k,l)
                if i*i + j*j + k*k + i*j +j*k + i*k > l:
                    break;
                if i*i + j*j + k*k + i*j +j*k + i*k == l:
                    list.append(1)
                    break;
    print(sum(list))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for n in range(1, N+1):
    ans = 0
    for x in range(1, 15):
        for y in range(x, 20):
            for z in range(y, 35):
                f = x**2 + y**2 + z**2 + x*y + x*z + y*z
                if f == n:
                    if x == y == z:
                        ans = 1
                    elif (x == y) or (y == z):
                        ans = 3
                    else:
                        ans = 6
    print(ans)

Submission status: Time Limit Exceeded

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

for n in range(1, N+1):
    count = 0
    for x in range(1, int(sqrt(n / 3)) + 2):
        for y in range(x,int(sqrt(n * 2 / 3)) + 2):
            for z in range(y, int(sqrt(n))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if len(set([x, y, z])) == 3:
                        count += 6
                    elif len(set([x, y, z])) == 2:
                        count += 3
                    elif len(set([x, y, z])) == 1:
                        count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N = ii()
did = 1
while did != N+1:
    mark = math.ceil(sqrt(did))
    count = 0
    for x in range(1,mark):
        if x ** 2 >= did or (x+abs(mark-x) + abs(mark-max(x,abs(mark-x))))**2 < did:
            break
        for y in range(1,abs(mark-x)):
            if x ** 2 + y ** 2 + x*y >= did:
                break
            mark2 = math.ceil(sqrt(did-x**2 - y**2 - x*y))
            for z in range(min(x,y)-1,min(mark2,abs(mark-(max(x,y))))):
                if (x+y+z)**2 - (x*y + x*z + y*z) == did:
                    count += 1
    print(count)
    did += 1

Submission status: Time Limit Exceeded

Solution code:
import itertools

N=int(input())

for n in range(1,N+1):#O(N^2)
    ans=0#ansを初期化
    l=[i for i in range(1,n+1)]
    tmp=[c for c in itertools.product(l, repeat=3) if c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[1]*c[2] + c[2]*c[0] == n]
    #print(tmp)
    for c in tmp:
        ans+=1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n+1):
    s = {}
    ans = 0
    for x in range(1, int(i**(1/2))):
        for y in range(x, int(i**(1/2))):
            judge = -3*x**2 -3*y**2 - 2*x*y + 4*i
            if  judge >= 0:
                if ((-x -y)+(judge)**(1/2))%2 == 0 and ((-x -y)+(judge)**(1/2))/2 >= y:
                    s = {x, y, int(((-x -y)+(judge)**(1/2))/2)}
                    if len(s) == 1:
                        ans += 1
                    elif len(s) == 2:
                        ans += 3
                    elif len(s) ==3:
                        ans += 6
   
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(1,N+1):
    n = int(sqrt(i))
    ans = 0
    for x in range(1,n+1):
        if 6*x*x == i:
            ans +=1
    m = int(sqrt(i/3))
    for x in range(1,m+1):
        for y in range(1,n+1):
            if x!=y:
                if 3*x*x + y*y + 2*x*y == i:
                    ans +=3
    l = int(sqrt(i/6))
    for x in range(1,l+1):
        for y in range(1,x):
            for z in range(1,y):
                if (x+y+z)**2 - x*y - x*z - y*z == i:
                    ans +=6
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c=0
from itertools import combinations 
def rSubset(arr, r): 
  
    # return list of all subsets of length r 
    # to deal with duplicate subsets use  
    # set(list(combinations(arr, r))) 
    return list(combinations(arr, r)) 
for y in range(1,n+1):
    t=[]
    x=[]
    for i in range(1,int(y**0.5)):
        t.append(y)
    x=rSubset(t,3)
    for i in range(len(x)):
        if(x[i][0]**2+x[i][1]**2+x[i][2]**2+x[i][0]*x[i][1]+x[i][0]*x[i][2]+x[i][1]*x[i][2]==n):
           c=c+6
    for i in range(1,int(y**0.5)):
        for j in range(1,int(y**0.5)):
            if(3*i*i+j*j+2*i*j==y):
                if(i==j):
                  c=c+1
                else:
                   c=c+3
    print(c)
    c=0

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 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:
N = int(input())
for n in range(1, N+1):
  sum = 0
  for x in range(1, 50):
    for y in range(1, 50):
      for z in range(1, 50):
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
          sum += 1
  print(sum)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

ans = [0 for _ in range(1,N+1)]

for v in itertools.combinations_with_replacement(range(1,(N//6)+1), 3):
    x,y,z = v
    count = 0
    if x == y == z:
        fn = 6 * x * x
        count = 1
    else:
        fn = x*x + y*y + z*z + x*y + y*z + z*x
        count = 3
    if N >= fn:
        ans[fn-1] += count

print(*ans, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
from sys import setrecursionlimit
setrecursionlimit(1000000)
n = int(input())
x = n//2
for l in range(n):
    c = 0
    l += 1
    for i in range(x):
        i += 1
        for j in range(x):
            j += 1
            for k in range(x):
                k += 1
                m = i*i+j*j+k*k+i*j+j*k+k*i
                if m == l:
                    c += 1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
import itertools
N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
  lst.append(i)
result=list(itertools.product(lst,repeat=3))
#print(result)
for n in range(1,N+1):
  count=0
  for j in result:
    if (j[0]**2+j[1]**2+j[2]**2+j[0]*j[1]+j[1]*j[2]+j[0]*j[2])/n == 1:
      count += 1
  print(count)

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,x+1):
                if (x+y)**2+(y+z)**2+(z+x)**2==2*n:
                    if str(x)+str(y)+str(z) in check or str(z)+str(x)+str(y) in check or str(y)+str(z)+str(x) in check or str(y)+str(x)+str(z) in check or str(x)+str(z)+str(y) in check or str(z)+str(y)+str(x) in check:
                        continue
                    if x==y and y==z:
                        c+=1
                        check.append(str(x)+str(y)+str(z))
                    elif x==y or y==z or z==x:
                        c+=3
                        check.append(str(x)+str(y)+str(z))
                    else:
                        check.append(str(x)+str(y)+str(z))
                        c+=6
    print(c)
    n+=1

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
        for y in range(x + 1, 101):
            xxy = ans_xyz(x, x, y)
            if xxy > n:
                break
            elif xxy == n:
                ans += 3
            for z in range(y + 1, 101):
                if ans_xyz(x, y, z) > n:
                    break
                elif ans_xyz(x, y, z) == n:
                    ans += 6
            xyy = ans_xyz(x, y, y)
            if xyy > n:
                break
            elif xyy == n:
                ans += 3
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
c = 0
n = 0
list = []
for l in range(1,N+1):
    list = []
    for i in range(1,N+1):
        if i*i > l:
            break;        
        for j in range(1,N-i):
            if i*i + j*j + i*j > l:
                break;
            for k in range(1,N-j):
                #print(i,j,k,l)
                if i*i + j*j + k*k + i*j +j*k + i*k > l:
                    break;
                if i*i + j*j + k*k + i*j +j*k + i*k == l:
                    list.append(1)
                    break;
    print(sum(list))

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:
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
                    # print('f2= ', f2)
                    # print('x,y,z= ',x,y,z)
                    break

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

Submission status: Time Limit Exceeded

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

import sys
import math

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

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

        if not ok_flag:
            print(0)
        ok_flag = False
        
                        

    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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


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

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

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

Submission status: Time Limit Exceeded

Solution code:
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
res.pop(0)
for i in res:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys

import itertools
input = sys.stdin.readline
 
N=int(input())
 
A=[]
for i in range(55):
    A.append(i+1)
 
D=list(itertools.combinations_with_replacement(A, 3))
#print(len(D))
for j in range(N):
    count=0
    for sa in D:
        if ((sa[0]+sa[1]+sa[2])**2)-(sa[0]*sa[1]+sa[1]*sa[2]+sa[2]*sa[0])==j+1:
            if sa[0]!=sa[1] and sa[1] !=sa[2]:
                
                count+=6
            elif sa[0]==sa[1] and sa[1]==sa[2]:
                count+=1
            else:
                count+=3
 
    print(count)

Submission status: Time Limit Exceeded

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

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

for n in range(1, N+1):
  for x in range(1, 50):
    for z in range(1, 50):
      answer = 0
      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:
n = int(input())
for i in range(1,n+1):
	cnt = 0
	for x in range(1,14):
		for y in range(1,14):
			for z in range(1,14):
				if (x**2 + y**2 + z**2 + (x*(y+z)) + (y*z)) == i:
					cnt += 1
	print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
ans = [0] * n
for x,y,z in itertools.combinations_with_replacement(list(range(1,n+1)),3):
    a = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if a > n: continue
    if x==y==z: b = 1
    elif x==y or x==z or y==z: b = 3
    else: b = 6
    ans[a-1] = b
for i in ans: print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

ans=[0]*N

for i in range(1,N):
    if i**2 >=N:
        break
    for j in range(1,N):
            if i**2+j**2+i*j>=N:
                break
            for k in range(1,N):
                    if i**2+j**2+k**2+i*j+j*k+k*i <=N:
                        ans[i**2+j**2+k**2+i*j+j*k+k*i-1] +=1

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