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 numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from itertools import accumulate
import copy


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline()[:-1] for _ in range(line)]


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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


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

# for x,y,z in itertools.product()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    for n in range(1, N + 1):
        max_itr = min(101, int(math.sqrt(n)) + 1)
        ans = 0

        for x in range(1, max_itr):
            for y in range(1, max_itr):
                for z in range(1, max_itr):

                    # left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    left_eq=x**2+y**2+z**2+x*y+y*z+z*x
                    if (left_eq == n):
                        ans += 1
        
        
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
        
    import math

    N = int(input())

    for n in range(1, N + 1):
        max_itr = min(100, int(math.sqrt(n)) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            for y in range(1, max_itr):
                for z in range(1, max_itr):
                    left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    if (left_eq == n):
                        ans += 1
        
        
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

def test(n):
    cnt = 0
    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                if (i+j+k)**2 == n + (i*j + j*k + k*i):
                    cnt += 1 
                if (i+j+k)**2 - (i*j + j*k + k*i) > n:
                    break
    return cnt

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

def test(n):
    cnt = 0
    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                if (i+j+k)**2 == n + (i*j + j*k + k*i):
                    cnt += 1 
                if (i+j+k)**2 - (i*j + j*k + k*i) > n*2:
                    break
    return cnt

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

def test(n):
    cnt = 0
    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                if (i+j+k)**2 == n + (i*j + j*k + k*i):
                    cnt += 1 
    return cnt

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,41):  
        for y in range(x,41):
            for z in range(y,41):
                fn=(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)
                if fn==2*n:
                    if x==y:
                        if x==z:
                            s=s+1
                        else:
                            s=s+3
                    else:
                        if y==z:
                            s=s+3
                        else:
                            s=s+6    
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,41):  
        for y in range(x,41):
            for z in range(y,41):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n:
                    if x==y:
                        if x==z:
                            s=s+1
                        else:
                            s=s+3
                    else:
                        if y==z:
                            s=s+3
                        else:
                            s=s+6    
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,41):  
        for y in range(x,41):
            for z in range(y,41):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n:
                    if x==y and x==z:
                        s=s+1
                    if x<y and y==z:
                        s=s+3
                    if x==y and y<z:
                        s=s+3              
                    if x<y and y<z:
                        s=s+6    
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,50):  
        for y in range(x,50):
            for z in range(y,50):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n:
                    if x==y and x==z:
                        s=s+1
                    if x<y and y==z:
                        s=s+3
                    if x==y and y<z:
                        s=s+3              
                    if x<y and y<z:
                        s=s+6    
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,50):  
        for y in range(x,50):
            for z in range(y,50):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n and x==y and x==z:
                    s=s+1
                if fn==n and x<y and y==z:
                    s=s+3
                if fn==n and x==y and y<z:
                    s=s+3              
                if fn==n and x<y and y<z:
                    s=s+6    
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,101):
        for y in range(x,101):
            for z in range(y,101):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n and x==y and x==z:
                    s=s+1
                if fn==n and x<y and y==z:
                    s=s+3
                if fn==n and x==y and y<z:
                    s=s+3              
                if fn==n and x<y and y<z:
                    s=s+6    
    print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def main():
    ans = [0]*(n+1)
    for x in range(1, n+1):
        for y in range(1, n+1):
            for z in range(1, n+1):
                fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if fn > n:
                    break
                else:
                    ans[fn] += 1

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def cal(i):
    count = 0
    x=1
    y=1
    z=1
    tmpx=1
    tmpy=1
    tmpz=1
    while(True):
        ycount=0
        while(True):
            zcount=0
            while(True):
                ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if (ans == i):
                    if ((100*x +10*y + z) % 111 == 0):
                        count+=1
                    else:
                        count+=3
                elif (ans > i):
                    break
                z += 1
                zcount+=1

            tmpz+=1
            z=tmpz
            if (zcount == 0):
                break
            y += 1
            ycount+=1

        tmpy+=1
        y = tmpy
        tmpz = tmpy
        z = tmpz
        if (ycount == 0):
            break
        x += 1

    return count

def main():
    for i in range(1, N+1):
        print(cal(i))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def cal(i):
    flagx = True
    count = 0
    x=1
    y=1
    z=1
    while(flagx):
        flagy = True
        while(flagy):
            flagz = True
            while(flagz):
                ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if (ans == i):
                    count+=1
                elif (ans > i):
                    flagz = False
                    z -= 1
                z += 1
            y += 1
            if (z == 1):
                flagy = False
            else:
                z = 1
        x += 1
        if (y == 2):
            flagx = False
        else:
            y = 1

    return count

def main():
    for i in range(1, N+1):
        print(cal(i))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

count = 0

i = 1

while(i <= n):
    count = 0
    limit = int(i / 2)
    for x in range(limit):
        for y in range(limit):
            for z in range(limit):
                cal = (x + 1) ** 2 + (y + 1) ** 2 + (z + 1) ** 2 + (x + 1) * (y + 1) + (y + 1) * (z + 1) + (z + 1) * (x + 1)
                if(cal == i):
                    count += 1
    print(count)
    i += 1

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
myans = [ 0 for n in range(N+1)]
upper = int(N**(2/3))
#print(upper)
for x in range(1, upper):
    for y in range(1, upper):
        for z in range(1, upper):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v < N+1:
                myans[v] += 1
#print(myans)
for a,b in enumerate(myans):
    if a != 0:
        print(b)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
upper = int(math.sqrt(N))
#print(upper)

for n in range(1,N+1):
    myans = 0
    for x in range(1, upper):
        remain = n - x**2
        if remain >= 1:
            y_upper = int(math.sqrt(remain))
            for y in range(1, y_upper+1):
                remain2 = remain - (y**2 + x*y)
                if remain2 >= 1:
                    z_upper = int(math.sqrt(remain2))
                    for z in range(1, z_upper+1):
                        if  z**2 + y*z + z*x == remain2:
                            myans += 1
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
upper = int(math.sqrt(N))
#print(upper)

for n in range(1,N+1):
    myans = 0
    for x in range(1, upper):
        remain = n - x**2
        if remain >= 1:
            y_upper = int(math.sqrt(remain))
            for y in range(1, y_upper):
                if x**2 + y**2 + x*y < n:
                    for z in range(1, upper):
                        if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    #print(x,y,z,x**2 + y**2 + z**2 + x*y + y*z + z*x)
                            myans += 1
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
upper = int(math.sqrt(N)) + 1
#print(upper)

for n in range(1,N+1):
    myans = 0
    for x in range(1, upper):
        for y in range(1, upper):
            if x**2 + y**2 + x*y < n:
                for z in range(1, upper):
                    if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    #print(x,y,z,x**2 + y**2 + z**2 + x*y + y*z + z*x)
                        myans += 1
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
upper = int(math.sqrt(N)) + 1
#print(upper)

for n in range(1,N+1):
    myans = 0
    for x in range(1, upper):
        for y in range(1, upper):
            for z in range(1, upper):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    #print(x,y,z,x**2 + y**2 + z**2 + x*y + y*z + z*x)
                    myans += 1
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())
    lis = []
    for i in range(1, 100):
        for p in range(1, 100):
            for q in range(1, 100):
                if i**2+p**2+q**2+i*p+p*q+q*i <= N:
                    lis.append(i**2+p**2+q**2+i*p+p*q+q*i)
    for i in range(1, N+1):
        print(lis.count(i))
resolve()

Submission status: Time Limit Exceeded

Solution code:
iteration_count = int(input())
for my_target in range(1,iteration_count+1):
  guess_max_range = int((my_target + 2) ** 0.5)
  number_of_match = 0
  for xx in range(1,guess_max_range):
    xxxx = xx**2
    for yy in range(1,guess_max_range):
      yyyy = yy**2
      xxyy = xx*yy
      for zz in range(1,guess_max_range):
        result = xxxx + yyyy + (zz)**2 + xxyy + (yy)*(zz) + (zz)*(xx)
        if result == my_target:
          number_of_match = number_of_match + 1
  print(number_of_match)

Submission status: Time Limit Exceeded

Solution code:
iteration_count = int(input())
for my_target in range(1,iteration_count+1):
  guess_max_range = int((my_target + 50) ** 0.5)
  number_of_match = 0
  for xx in range(1,guess_max_range):
    xxxx = xx**2
    for yy in range(1,guess_max_range):
      yyyy = yy**2
      xxyy = xx*yy
      for zz in range(1,guess_max_range):
        result = xxxx + yyyy + (zz)**2 + xxyy + (yy)*(zz) + (zz)*(xx)
        if result == my_target:
          number_of_match = number_of_match + 1
  print(number_of_match)

Submission status: Time Limit Exceeded

Solution code:
iteration_count = int(input())
for my_target in range(1,iteration_count+1):
  guess_max_range = int((my_target + 50) ** 0.5)
  number_of_match = 0
  for xx in range(1,guess_max_range):
    for yy in range(1,guess_max_range):
      for zz in range(1,guess_max_range):
        result = (xx)**2 + (yy)**2 + (zz)**2 + (xx)*(yy) + (yy)*(zz) + (zz)*(xx)
        if result == my_target:
          number_of_match = number_of_match + 1
  print(number_of_match)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
    for x in range(1,n):
        for y in range(1,n-x):
            for z in range(1,n-x-y):
                if x**2 + y ** 2 + z**2 + x*y + y*z + z*x == n:
                    if x == y and y == z:
                        return 1
                    elif x != y and y != z and x != z:
                        return 6
                    else:
                        return 3
                    break



N = int(input())
for x in range(0,N):
    z = f(x+1)
    if z is None:
        z = 0
    print(z)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
    count = 0
    for x in range(1,n):
        for y in range(1,n-x):
            for z in range(1,n-x-y):
                if x**2 + y ** 2 + z**2 + x*y + y*z + z*x == n:
                    count = count + 1
    return count

N = int(input())
for x in range(0,N):
    print(f(x+1))

Submission status: Time Limit Exceeded

Solution code:

import itertools
import math

def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    xyz_max = 100
    
    for i in range(1, n+1):
        ans = 0
        cnt = 0
        for x, y, z in itertools.product(range(xyz_max), range(xyz_max), range(xyz_max)):
            if x > 0 and y > 0 and z > 0:
                #ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                ans = (x + y + z)**2 - (x*y + y*z + z*x)
                if ans == i:
                    cnt = cnt + 1
        
        print(cnt)
                    
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

import itertools
import math

def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    xyz_max = int(math.sqrt(n))
    
    for i in range(1, n+1):
        ans = 0
        cnt = 0
        for x, y, z in itertools.product(range(xyz_max), range(xyz_max), range(xyz_max)):
            if x > 0 and y > 0 and z > 0:
                #ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                ans = (x + y + z)**2 - (x*y + y*z + z*x)
                if ans == i:
                    cnt = cnt + 1
        
        print(cnt)
                    
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

import itertools

def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    
    for i in range(1, n+1):
        ans = 0
        cnt = 0
        for x, y, z in itertools.product(range(n), range(n), range(n)):
            if x > 0 and y > 0 and z > 0:
                #ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                ans = (x + y + z)**2 - (x*y + y*z + z*x)
                if ans == i:
                    cnt = cnt + 1
        
        print(cnt)
                    
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

import itertools

def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    
    for i in range(1, n+1):
        ans = 0
        cnt = 0
        for x, y, z in itertools.product(range(n), range(n), range(n)):
            if x > 0 and y > 0 and z > 0:
                ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if ans == i:
                    cnt = cnt + 1
        
        print(cnt)
                    
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:


def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    
    for i in range(1, n+1):
        ans = 0
        cnt = 0

        for x in range(1, n+1):
            for y in range(1, n+1):
                for z in range(1, n+1):
                    ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                    if ans == i:
                        cnt = cnt + 1
        print(cnt)
                    
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

N=int(input())
ARRAY=[[[-1] * (N+1) for i in range(N+1)] for j in range(N+1)]

for i in range(1,N+1):
    count=0
    for x in range(1,int(math.sqrt(i))+1):
        for y in range(1,int(math.sqrt(i-x))+1):
            for z in range(1,int(math.sqrt(i-x-y))+1):

                if ARRAY[x][y][z]==-1:
                    res=x**2+y**2+z**2+x*y+y*z+z*x
                    ARRAY[x][y][z]=res
                    if res==i:
                        count+=1
                else:
                    res=ARRAY[x][y][z]
                    if res==i:
                        count+=1

    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

N=int(input())


for i in range(1,N+1):
    count=0
    for x in range(1,int(math.sqrt(i))+2):
        for y in range(1,N-x+1):
            for z in range(1,i-x-y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    count+=1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n + 1):
  count = 0
  # x <= y <= zとして考える
  if i >= 6:
    for x in range(1, i + 1):
      if 6 * x ** 2 > i:
        break
      a = i - x ** 2
      for y in range(x, i + 1):
        if 3 * y ** 2 + 2 * x * y > a:
          break
        for z in range(y , i + 1):
          if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
            if x == y:
              if y == z:
                count += 1
              else:
                count += 3
            else:
              if y == z:
                count += 3
              else:
                count += 6
            break
          if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > i:
            break
  print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n + 1):
  count = 0
  # x <= y <= zとして考える
  if i >= 6:
    for x in range(1, i // 6 + 1):
      for y in range(x, i + 1):
        for z in range(y , i + 1):
          if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
            if x == y:
              if y == z:
                count += 1
              else:
                count += 3
            else:
              if y == z:
                count += 3
              else:
                count += 6
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
N = int(input())
l = []
num = int(N**0.5)+1

# for x in range(1,num+1):
#     for y in range(1,num+1):
#         for z in range(1,num+1):

for x,y,z in itertools.product(range(1, num+1), repeat=3):
    fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
    l.append(fn)

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
l = []
num = int(N**0.5)+1

for x in range(1,num+1):
    for y in range(1,num+1):
        for z in range(1,num+1):
            fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
            l.append(fn)

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

def getMaxX(n):
    maxX = int(math.sqrt(n))
    while True:
        if g(maxX,1,1) <= n:
            break
        maxX -= 1
        if maxX == 0:
            break
    return maxX

def getMaxY(n,x):
    maxY = x
    while True:
        if g(x,maxY,1) <= n:
            break
        maxY = maxY - 1
        if maxY == 0:
            break
    return maxY

def getXYZ(n,x,y):
    ret = []
    z = 1
    while True:
        r = g(x,y,z)
        #print("g({},{},{}) = {}, n = {}".format(x,y,z,r,n))
        if r == n:
            ret.append((x,y,z))
        elif r > n:
            break
        z += 1
        if z > y:
            break
    #print(ret)
    return ret
            
def count(ret):
    count = 0
    for r in ret:
        x = r[0]
        y = r[1]
        z = r[2]
        #print("(x,y,z) = ({},{},{})".format(x,y,z))
        if x==y and y==z:
            count += 1
        elif x==y or y==z or z==x:
            count += 3
        else:
            count += 6
    return count

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

    for n in range(1,N+1):
        ret = []
        maxX = getMaxX(n)
        if maxX <= 0:
            print(0)
            continue
        for x in range(maxX,0,-1):
            maxY = getMaxY(n,x)
            if maxY <= 0:
                continue
            for y in range(maxY,0,-1):
                ret.extend(getXYZ(n,x,y))
        print(count(ret))

    
if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

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

def getMaxX(n):
    maxX = 1
    while g(maxX,1,1) <= n:
        maxX += 1
    if maxX==1 and g(maxX,1,1) > n:
        return -1
    else:
        return maxX

def getMaxY(n,x):
    maxY = 1
    while g(x,maxY,1) <= n:
        maxY += 1
    if maxY==1 and g(x,maxY,1) > n:
        return -1
    else:
        return maxY

def getZ(n,x,y):
    z = 1
    count = 0
    while True:
        r = g(x,y,z)
        #print("g({},{},{}) = {}".format(x,y,z,r))
        if r==n:
            count += 1
        elif r > n:
            break
        z += 1
    return count
        
def main():
    N = int(input())

    for n in range(1,N+1):
        count = 0
        maxX = getMaxX(n)
        #print("maxX is {}".format(maxX))
        if maxX < 0:
            print(count)
            continue
        for x in range(maxX,0,-1):
            maxY = getMaxY(n,x)
            #print("x is {}, maxY is {}".format(x,maxY))
            if maxY < 0:
                continue
            for y in range(maxY,0,-1):
                count += getZ(n,x,y)
        print(count)
    
if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
nums = [int(x+1) for x in range(n)]

cnd = int(math.sqrt(n))
 
def cnd_check(ans,cnd,cnt=0):
      for x in range(1,cnd+1):
            for y in range(1,cnd+1):
                  for z in range(1,cnd+1):
                        if x**2+y**2+z**2+x*y+y*z+z*x == ans:
                              cnt += 1
      return cnt
  
for i in range(n):
      print(cnd_check(nums[i],cnd))

Submission status: Time Limit Exceeded

Solution code:
import sys
print = sys.stdout.write

N = int(input())


for n in range(1, N+1):
    ans = 0
    for x in range(1, int(n**0.5 +1)):
        if x ** 2 >= n-4:
            break
        for y in range(x, int(n**0.5+1)):
            if x**2 + y**2 + x*y >= n-2:
                break
            for z in range(y, int(n**0.5+1)):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if x == y == z:
                        ans += 1
                    elif x == y or y == z:
                        ans += 3
                    else:
                        ans += 6
    print(str(ans) + '\n')

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
nums = [int(x+1) for x in range(n)]

cnd = int(math.sqrt(n)+1)
      # x**2+y**2+z**2+x*y+y*z+z*x = n を満たすとき、x,y,zの範囲は
      # 仮定より 1<=x,y,z かつ x**2,y**2,z**2<nなので、
      # √n に小数点以下切り上げ処理を施したものが条件値となる1
 

def cnd_check(ans,cnd,cnt=0):
      for x in range(1,cnd+1):
            for y in range(1,cnd+1):
                  for z in range(1,cnd+1):
                        if x**2+y**2+z**2+x*y+y*z+z*x == ans:
                              cnt += 1
      return cnt
  
for i in range(n):
      print(cnd_check(nums[i],cnd))

Submission status: Time Limit Exceeded

Solution code:
import sys,math
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/C_input.txt")
else:
    f=sys.stdin
# Find the number of triples of integers (x,y,z) such that
# (x+y)**2 + (y+z)**2 + (x+z)**2 = 2*N
N=int(f.readline().strip())
for _ in range(N):
    A=(_+1)*2
    I=int(math.sqrt(A))
    cnt=0
    for __ in range(I):
        A2=A-((__+1)**2)
        if A2<=0:
            break
        I2=int(math.sqrt(A2))
        for ___ in range(I2):
            A3=A2-((___+1)**2)
            if A3<=0:
                break
            I3=int(math.sqrt(A3))
            for ____ in range(I3):
                if ((__+___+2)**2)+((___+____+2)**2)+((__+____+2)**2)==A:
                    cnt+=1
                    break
    print(cnt)
f.close()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
# num = []
# for e in sys.stdin:
#     num.append(map(int, e.split()))

N = int(input())

for n in range(1, N+1):
    count = 0;
    max = min(int(math.sqrt(n)), int(n/2))
    l = []

    for i in range(1, max+1):
        l.append(i)

    h = itertools.combinations_with_replacement(l, 3)

    for i,j,k in h:
        if n == (i+j+k)**2 - i*j - j*k - k*i:
            if(i==j==k):
                count+=1
            elif(i==j or j==k or i == k):
                count+=3
            else:
                count+=6

    # for i in range(1, max+1):
    #     for j in range(1, max+1):
    #         for k in range(1, max+1):
    #             num = i**2 + j**2 + k**2 + i*j + j*k + k*i
    #             if n == num:
    #                 count+=1
    print(count)


    # print(max)


    # l = []
    #
    # for i in range(1, max+1):
    #     l.append(i)
    #
    # # h = itertools.combinations_with_replacement(l, 3)
    #
    # for i,j,k in h:
    #     if n == i**2 + j**2 + k**2 + i*j + j*k + k*i:
    #         if(i==j==k):
    #             count+=1
    #         elif(i==j or j==k or i == k):
    #             count+=3
    #         else:
    #             count+=6
    # print(count)