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 main():
        
    import math

    N = int(input())

    for n in range(1, N + 1):
        max_itr = min(101, int(math.sqrt(n)*0.8) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            # for y in range(1, x+1):
            for y in range(1, max_itr):

                # for z in range(1, x+1):
                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_list = [x, y, z]
                        ans_len = len(set(ans_list))
                        


                        ans += 1
                        
                        # if (ans_len==3):
                        #     ans += 6
                        # elif (ans_len == 2):
                        #     ans += 3
                        # else:
                        #     ans += 1

        
        
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in range(1, N+1):
    if i < 6:
        print(0)
    else:
        x, y, z = 0, 0, 0
        ans = 0
        while True:
            x += 1
            y = 0
            z = 0
            if f(x,y,z) > i:
                break
            while True:
                y += 1
                z = 1
                if f(x,y,z) > i:
                    break
                while f(x,y,z) <= i:
                    if f(x,y,z) == i:
                        ans += 1
                        break
                    z += 1
        print(ans)

Submission status: Time Limit Exceeded

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

N=int(input())
X=1
Y=1
Z=1
l=[0]*N
ans=0
for n in range(1,N+1):
    for a in range(1,int(math.sqrt(n))+1):
        for b in range(1,int(math.sqrt(n))+1):
            for c in range(1,int(math.sqrt(n))+1):
                if f(a,b,c)==n:
                    l[n-1]+=1
        

for nn in l:
    print(nn)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,8):
    for y in range(1,8):
      for x in range(1,8):
        if x**2+y**2+z**2+z*y+z*x+y*x==i:
          co+=1
  return co
for i in range(1,n+1):
  print(f(i))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools

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


def resolve():
    n = int(input().rstrip())

    for m in range(1, n+1):
        xyz_list = []
        for i in range(1, m+1):
            xyz_list.append(i)
        p = itertools.combinations_with_replacement(xyz_list, 3)
        ans_cnt = 0
        for v in p:
            x, y, z = v
            max_value = max(x, y, z)
            if max_value*max_value >= m:
                continue

            ans = x*x + y*y + z*z + x*y + y*z + z*x

            if ans == m:
                if x == y == z:
                    ans_cnt += 1
                elif x == y or y == z or x == z:
                    ans_cnt += 3
                else:
                    ans_cnt += 6

        print(ans_cnt)



if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

    return cnt
N=int(input())
for i in range(1,N+1):
    print(f(i))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


for i in range(1, N+1):
    num = 0
    sqi = int(float(i)**0.5)
    for j in range(1,sqi+1):
        sqj = int(float(i-j**2)**0.5)
        for k in range(1, sqj+1):
            c = float(i-j**2-k**2-j*k)
            if c > 0:
                c *= -1.0
                b = float(j) + float(k)
                d = b**2-4*c
                if d >=0.0:
                    z = (-b + d**0.5)/2.0
                    if z.is_integer():
                        #print(j,k,z)
                        num +=1
                    else:
                        z = (-b - d**0.5)/2.0
                        if z.is_integer():
                            #print(j,k,z)
                            num +=1
    print(num)

Submission status: Time Limit Exceeded

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

n = int(input())

ans = 0
arr = []
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans = func(x,y,z)
            arr.append(ans)
            if ans > n:
                break
for i in range(n):
    print(arr.count(i+1))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def f(n):
    flag = False
    #total = 0
    ans = 0
    i = 137
    for x in range(1,i):
        for y in range(1,i-x):
            for z in range(1,i-(x+y)):
                if (x + y + z)**2 - (x*y + y*z + x*z) == n:
                    #total += 1
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
    if x == i-1:
        ans = 0
    elif x == y and  y== z:
        ans = 1
    elif x == y or y == z or x == 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:
import math
n=int(input())
for i in range(1,n+1):
  square=[j**2 for j in range(1,(int(math.sqrt(2*i))+1))]
  cnt=0
  for x in square:
    for y in square :
      if y>x:
        for z in square:
          if x+y+z==2*i and z>y and x+y>z and y+z>x and z+x>y:
           cnt +=6
  for x in square:
    for y in square:
      if 2*x>y and x!=y:   
        if x+x+y==2*i:
          cnt +=3
  for x in square:
    if x+x+x==2*i:
      cnt+=1
  print(cnt)

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(1, s+1):
            for z in range(1, s+1):
                siki = x**2 + y**2 + z**2 + x*y + y*z + z*x

                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:
                    break
            if flag:
                break
        if flag:
            break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
f=[0]*N
for i in range(N):
    for j in range(int(math.sqrt(i+1))):
        for k in range(int(math.sqrt(i+1))):
            for l in range(int(math.sqrt(i+1))):
                if (j+1)*(j+1)+(k+1)*(k+1)+(l+1)*(l+1)+(j+1)*(k+1)+(k+1)*(l+1)+(l+1)*(j+1)==(i+1):
                    f[i]=f[i]+1

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

Submission status: Time Limit Exceeded

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
ans = [0] * N

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

for n in range(1, N + 1):
    for x in range(1, int(N ** 0.5) + 2):
        if fn(x, 1, 1) > n:
            break
        for y in range(1, int(N ** 0.5) + 2):
            if fn(x, y, 1) > n:
                break
            for z in range(1, int(N ** 0.5) + 2):
                f = fn(x, y, z)
                if f > n:
                    break
                if f == n:
                    ans[f - 1] += 1

for a in ans:
    print(a)

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)*0.8) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            # for y in range(1, x+1):
            for y in range(1, max_itr):

                # for z in range(1, x+1):
                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_list = [x, y, z]
                        ans_len = len(set(ans_list))
                        


                        ans += 1
                        
                        # if (ans_len==3):
                        #     ans += 6
                        # elif (ans_len == 2):
                        #     ans += 3
                        # else:
                        #     ans += 1

        
        
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    a=int(input())
    for w in range(1,a+1):
        if w<5:
            print(0)
        else:
            total=0
            for i in range(1,w):
                for j in range(1,w):
                    for k in range(1,w):
                        if (i**2)+(j**2)+(k**2)+i*k+i*j+k*j==w:
                            total+=1
            print(total)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def count_n(n):
    ans = 0
    for x in range(1,int(N**0.5)+1):
        if 6*x**2 == n:
            ans = 1
            return ans
        for y in range(1,int(N**0.5)+1):
                if (3*x**2 + y**2 + 2*x*y)  == n:
                    ans += 3
                    return ans
    return ans

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

Submission status: Time Limit Exceeded

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


# if a * a + b * b + c * c + ab + bc + ac == i:
    
count = 0

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

Submission status: Time Limit Exceeded

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

    return cnt
N=int(input())
for i in range(1,N+1):
    print(f(i))

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
for w in range(1,a+1):
    if w<5:
        print(0)
    else:
        total=0
        for i in range(1,w):
            for j in range(1,w):
                for k in range(1,w):
                    if (i**2)+(j**2)+(k**2)+i*k+i*j+k*j==w:
                        total+=1
        print(total)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
N = int(input())
for n in range(1, N+1):
  ans = 0
  n_max = int(math.sqrt(n))
  l = [i for i in range(1, n_max)]
  for c in itertools.combinations_with_replacement(l, 3):
    if n == c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]:
      if len(set(c)) == 1:
        ans += 1
      elif len(set(c)) == 2:
        ans += 3
      elif len(set(c)) == 3:
        ans += 6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
import math
for i in range(1,n+1):
    a=math.floor(math.sqrt(i/6))+1
    t=0
    for x in range(1,a):
        b=math.floor(math.sqrt((i-x**2)/3))+1
        for y in range(x,b):
            c=math.floor(math.sqrt(i-x**2-y**2-x*y))+1
            for z in range(y,c):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    if x==y and y==z:
                        t+=1
                    elif x!=y and y!=z and z!=x:
                        t+=6
                    else:
                        t+=3
    print(t)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
  cnt = 0
  for i in range(n):
    for j in range(n):
      for k in range(n):
        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:
n = int(input())
for l in range(n):
    c=0
    l += 1
    for i in range(n):
        i += 1
        for j in range(n):
            j += 1
            for k in range(n):
                k += 1
                m = i*i+j*j+k*k+i*j+j*k+k*i
                if m > l:
                    break
                if m == l:
                    c += 1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())

def calc(l):
    if l <= 5:
        return 0

    ans = 0
    m = math.floor(math.sqrt(n/6))
    M = math.floor(math.sqrt(n/6))
    MM = math.floor(math.sqrt(n-2))
    for i in range(1, m+2):
        for k in range(max(1, M-1), MM+2):
            for j in range(i, k+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == l:
                    d = len(set([i, j, k]))
                    if d == 3:
                        ans += 6
                    elif d == 2:
                        ans += 3
                    elif d == 1:
                        ans += 1
    
    return ans

for p in range(1, n+1):
    print(calc(p))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

N = int(input())

a = np.zeros((100, 100, 100), dtype=np.int32)


for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            n = int(i*i + j*j + k*k + i*j + j*k + k*i)
            a[i,j,k] = n

            if n > 1001:
                break
for i in range(N):

    print(np.count_nonzero(a == (i+1)))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt

n = int(input())
 
def calc(n):
    if n < 6:
        return 0
    if n == 6:
        return 1
    if 6 < n < 11:
        return 0
    if n == 11:
        return 3
    if 11 < n < 17:
        return 0
    if n == 17:
        return 3
    if n == 18:
        return 3
    ans = 0
    for x in range(1, int(sqrt(n))):
        for y in range(1, int(sqrt(n))):
            for z in range(1, int(sqrt(n))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    ans += 1
 
    return ans
 
for i in range(1, n+1):
    print(calc(i))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def f(n):
    flag = False
    #total = 0
    ans = 0
    i = 150
    for x in range(1,i):
        for y in range(1,i-x):
            for z in range(1,i-(x+y)):
                if (x + y + z)**2 - (x*y + y*z + x*z) == n:
                    #total += 1
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
    if x == i-1:
        ans = 0
    elif x == y and  y== z:
        ans = 1
    elif x == y or y == z or x == 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().strip())
s=[]
n=0
for j in range (N):
    if j**3<=N and (j+1)**3>=N:
        n=j+1
        break
t=[0]*N
for i in range(N):
    for a in range (1,n+1):
        for b in range(1,n+1):
            for c in range(1,n+1):
                if (a*a+b*b+c*c+a*b+b*c+c*a)==i+1:
                    t[i]=t[i]+1


for l in range(N):
    print(t[l])

Submission status: Time Limit Exceeded

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

    return cnt
N=int(input())
for i in range(1,N+1):
    print(f(i))

Submission status: Time Limit Exceeded

Solution code:
def sol():
    n=int(input())

    def col(n):
        ans=chk=0
        for i in range(1,n):
            if i**2>=n: break
            for j in range(1,n):
                if j**2>=n: break
                for k in range(1,n):
                    if k**2>=n: break
                    if i**2+j**2+k**2+i*j+j*k+k*i==n: ans+=1
        return ans
    for i in range(1,n+1):
        print(col(i))

if __name__=="__main__":
    sol()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

results, counts = [], []
for i in range(1, 31):
    for j in range(1, i + 1):
        for k in range(1, j + 1):
            result = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            results.append(result)
            if i == j and j == k:
                counts.append(1)
            elif i == j or j == k:
                counts.append(3)
            else:
                counts.append(6)

for n in range(1, N + 1):
    count = 0
    for i in range(len(results)):
        if results[i] == n:
            count += counts[i]
    print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def search(n):
    global N
    for x in range(1, N):
        if n - x*x <= 0:
            return None
        for y in range(1, N):
            if n - x*x - y*y - x*y <= 0:
                break
            z = binarySearch(n, x, y)
            if z:
                return (x, y, z)


def binarySearch(n, x, y):
    global N
    right = -1
    left = N + 1
    while(abs(right - left) > 1):
        z = left + (right - left) // 2
        if x*x + y*y + z*z + x*y + y*z + z*x == n:
            return z
        elif x*x + y*y + z*z + x*y + y*z + z*x < n:
            right = z
        else:
            left = z
        # print(right, left, z)
    return None

for n in range(1, N+1):
    ans = search(n)
    if ans == None:
        print(0)
        continue
    ans = len(set(ans))
    if ans == 1:
        print(1)
    elif ans == 2:
        print(3)
    else:
        print(6)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools

# 標準入力を取得
N = int(input())


def has_z(n: int, x: int, y: int, d: int) -> bool:
    if d < 0:
        return False
    z = (-(x + y) + math.sqrt(d)) / 2
    return (z.is_integer()) and (z >= 1)


# 求解処理
D = {}
for n in range(1, N + 1):
    ans = 0
    max_v = int(math.sqrt(n))
    for x in range(1, max_v + 1):
        for y in range(x, max_v + 1):
            if (n, x, y) not in D.keys():
                D[(n, x, y)] = 4 * n - 3 * x ** 2 - 3 * y ** 2 - 2 * x * y
            d = D[(n, x, y)]
            if has_z(n, x, y, d):
                ans += 1 + (x != y)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
ans=list()
for i in range(1,N+1):
    tmp=0
    tgt=int(math.sqrt(i/2)+1)
    for j in range(1,tgt):
        for k in range(j,tgt):
            for h in range(k,tgt):
                if h**2+j**2+k**2+h*j+j*k+k*h==i:
                    if j==k==h:
                        tmp+=1
                    elif j==k or k ==h:
                        tmp+=3
                    else:
                        tmp+=6
    ans.append(tmp)
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,n+1):
  ans=0
  for x in range(1,50):
    for y in range(x,50):
      for z in range(y,50):
        if (x+y)**2+(y+z)**2+(z+x)**2==2*i:
          if x==y==z:
            ans+=1
          elif (x==y and y!=z) or (x!=y and y==z):
            ans+=3
          elif x!=y and y!=z:
            ans+=6
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

def func(i):
    j = math.ceil(math.sqrt(i))
    cache = np.zeros([j, j, j], dtype=int)
    for x in range(1, (j + 1)//2+1):
        for y in range(1, max(1, j - x + 1)):
            for z in range(1, max(1, j - x - y + 1)):
                if cache[z, y, x] != 0:
                    cache[x, y, z] = cache[z, y, x]
                elif cache[z, x, y] != 0:
                    cache[x, y, z] = cache[z, x, y]
                else:
                    cache[x, y, z] = calc(x, y, z)
    return cache


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

def resolve():
    N = int(input())
    cache = func(N)
    for i in range(1, N+1):
        print(np.count_nonzero(cache == i))

resolve()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
nn = math.ceil(math.sqrt(N))

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

Submission status: Time Limit Exceeded

Solution code:
#C
N = int(input())
for a in range(1,N+1):
    counter = 0
    for i in range(1,150):
        for j in range(1,150):
            if -3*i**2-3*j**2-2*i*j+4*a>=0:
                k = (-1*(i+j)+(-3*i**2-3*j**2-2*i*j+4*a)**0.5)/2
                if k.is_integer() and 1<=k<=150:
                    counter += 1
    print(counter)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
nn=int(math.sqrt(n))
for i in range(1,n+1):
    min=int((nn+1)/3)
    min1=int((nn+1)/2)
    count=0
    for x in range(1,min+1):
        for y in range(x,min1+1):
            for z in range(y,nn+1):
                #print(x*x+y*y+z*z+x*y+y*z+z*x)
                if (x*x+y*y+z*z+x*y+y*z+z*x)==i:
                    if x==y and y==z and z==y:
                        count=count+1
                    elif x!=y and y!=z and z!=y:
                        count=count+6
                    else:
                        count=count+3
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
N = int(sys.stdin.readline())
for i in range(1,N+1):
  ans = 0
  n = math.ceil(math.sqrt(i))
  for j in range(1,n):
    wan = n - j
    for k in range(1,wan):
      n_sub = i -j*j - k*(j + k)
      if n_sub <= 0:
        break
      b = j + k
      check = ((b**2 + 4*n_sub) ** (1/2) - b)
      if check % 2 == 0:
        ans +=1
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations_with_replacement
def f(n):
    ret = 0
    for x, y, z in combinations_with_replacement(range(1, 100), 3):
        if x**2+y**2+z**2+x*y+y*z+z*x==n:
            if x==y==z:
                ret += 1
            elif x==y or y==z or z==x:
                ret += 3
            else:
                ret += 6
    return ret
N = int(input())
for n in range(1, N+1):
    print(f(n))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def count_n(n):
    ans = 0
    for x in range(1,int(N**0.5)+1):
        if 6*x**2 == n:
            ans = 1
            return ans
        for y in range(1,int(N**0.5)+1):
                if (3*x**2 + y**2 + 2*x*y)  == n:
                    ans += 3
    return ans

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
max_n = int(n ** 0.5)
memo = np.zeros((max_n, max_n, max_n))


for x in range(1, max_n):
    for y in range(1, max_n):
        for z in range(1, max_n):
            memo[x][y][z] = x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1, (n + 1)):
    print(np.count_nonzero(memo == i))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
for p in range(1,N+1):
    count = 0
    for i in range(1,p//2):
        for j in range(1,p//2):
            for k in range(1,p//2):
                if (i+j)**2 + (j+k)**2 + (k+i)**2 == 2*p:
                    count += 1
                    
    A.append(count)
    
for q in range(N):
    print(A[q])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
n=1
while n<=N:
    c=0
    for x in range(1,int(n**0.5)+1):
        for y in range(1,int(n**0.5)+1):
            for z in range(1,int(n**0.5)+1):
                if (x+y)**2+(y+z)**2+(z+x)**2==2*n:
                    c+=1
    n+=1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
def func(n):
    cnt = 0
    for x in range(1, 34):
        if(x**2+x >= n):
            break
        for y in range(1, 34):
            z = 1
            if(x**2+y**2+z**2+x*y+y*z+z*x > n):
                break
            while(x**2+y**2+z**2+x*y+y*z+z*x <= n):
                if(x**2+y**2+z**2+x*y+y*z+z*x == n):
                    cnt += 1
                    break
                z += 1
    return cnt

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
 
def eq(x, y, z):
  return x**2 + y**2 + z**2 +x*y + y*z + z*x
 
def get_score(x, y, z):
  if x == y and y == z:
    score = 1
  elif x == y or y == z or  z == x:
    score = 3
  else:
    score = 6
  return score
 
for n in range(1, N+1):
  ans = 0
  for i in range(1, int(n/2)):
    if eq(i, i, i) > n:
      break
    else:
      for j in range(i, int(n/2)):
        if eq(i, j, j) > n:
          break
        else:
          for k in range(j, int(n/2)):
            if eq(i, j, k) > n:
              break
            elif eq(i, j, k) == n:
              ans += get_score(i, j, k)
  print(ans)

Submission status: Time Limit Exceeded

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


def calc(n):
    for x in range(1, math.ceil(math.sqrt(n))):
        for y in range(1, x+1):
            for z in range(1, y+1):
                ans = x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
                # print(x, y, z, ans)
                if ans == n:
                    if len({x, y, z}) == 1:
                        return 1
                    elif len({x, y, z}) == 2:
                        return 3
                    else:
                        return 6
                if ans > n:
                    break
    return 0

# print(calc(17))
for n in range(1, N + 1):
    res = calc(n)
    print(res)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())


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


for n in range(1, N+1):
    ans = 0
    for i in range(1, N):
        if (i * i + i > N):
            break
        for j in range(1, N):
            if (j * j + j + i * i + i > N):
                break
            for k in range(1, N):
                if (k * k + k + j * j + j + i * i + i > N):
                    break
                unk = f(i, j, k)
                if (unk == n):
                    ans += 1
                    break
                elif (unk > n):
                    break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:

import math
n = int(input())

sqn = int(math.sqrt(n))+1
count = 0
aset = [0]*(n+1)
for x in range(1,sqn):
    for y in range(x,sqn):
        for z in range(y,n):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                if x == y and y ==z:
                    aset[a] +=1
                else:
                    aset[a] +=3

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for l in range(n):
    c=0
    l += 1
    for i in range(n):
        i += 1
        for j in range(n):
            j += 1
            for k in range(n):
                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:
N = int(input())
n = [0 for _ in range(N)]

def cob(m):
    if m <= 0:
        return m
    return m + cob(m-1)

# x > y > z
for x in range(1,N+1):
    for y in range(1,x+1):
        for z in range(1,y+1):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            cnt = cob(len(set([x,y,z])))
            if ans > N:
                break
            n[ans-1] += cnt

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input().strip())
s=[]
n=0
for j in range (N):
    if j**3<=N and (j+1)**3>=N:
        n=j+1
        break
t=[0]*N
for i in range(N):
    for a in range (1,n+2):
        for b in range(1,n+2):
            for c in range(1,n+2):
                if (a*a+b*b+c*c+a*b+b*c+c*a)==i+1:
                    t[i]=t[i]+1


for l in range(N):
    print(t[l])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
def main():
    n = int(input())
    ans = []
    for x in range(1, n):
        for y in range(1, n):
            for z in range(1, n):
                ans.append(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)
    counter = Counter(ans)
    for i in range(1, n+1):
        print(counter[i])
 
 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
for n in range(1, N+1):
    # count number of sets (x, y,x)
    #assume x<y<z
    ans=0
    z_low=int(np.sqrt(n/6))
    z_up=int(np.sqrt(n))
    for z in range(z_low, z_up):
        if (n-3*z**2)/3 <=0:
            y_low=1
        else:
            y_low=int(np.sqrt((n-3*z**2)/3))
        for y in range(y_low, z+1):
            if n-3*z**2-2*y**2<=0:
                x_low=1
            else:
                x_low=np.sqrt(n-3*z**2-2*y**2)
            for x in range(y_low, int(np.sqrt(n/6))+1):
                if n == x**2 + y**2 + z**2 + x*z + x*y + y*z:
                    # classify
                    if x==y and x==z:
                        #x=y=z
                        ans+=1
                    elif x==y and x!=z:
                        ans+=3
                    elif y==z and y != x:
                        ans+=3
                    elif z==x and z!=y:
                        ans+=3
                    else:
                        ans+=6
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def f(n):
  cnt = 0
  for i in range(int(n**1/2 // 1)):
    for j in range(int(((2*n)**1/2-i)//1)):
      for k in range(int(((2*n)**1/2-i)//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))