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: Accepted

Solution code:
N=int(input())
ans=0
mul=1
while ans<=N:
    ans=6*(mul**2)
    mul+=1
ANS={}
for i in range(1,101):
    for j in range(i,101):
        for k in range(j,101):
            if (i*i+j*j+k*k+i*j+j*k+i*k) not in ANS.keys():
                if i!=j and j!=k and k!=i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]=6
                elif i==j and j==k and k==i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]=1
                else:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]=3
            else:
                if i!=j and j!=k and k!=i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]+=6
                elif i==j and j==k and k==i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]+=1
                else:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]+=3
for Z in range(1,N+1):
    if Z in ANS.keys():
        print(ANS[Z])
    else:
        print(0)

Submission status: Accepted

Solution code:
from collections import defaultdict
def onenum2threenum(num):
  arr=[]
  for i in range(1,num-1):
    for j in range(1, num-i):
        arr.append([i,j,num-i-j])
  return arr

dic=defaultdict(int)

N = int(input())
inp=N
N = (N * 3) ** 0.5 // 1 + 1
N=int(N)

for i in range(3,N+1):
  arr=onenum2threenum(i)
  arr=[(a+b+c)**2-a*b-b*c-c*a for a,b,c in arr]
  for a in arr:
    dic[a]+=1

for i in range(1,inp+1):
  print(dic[i])

Submission status: Accepted

Solution code:
N = int(input())
result = [0] * N
for x in range(1,int((N + 1) ** (1/2))):
  for y in range(1,int((N + 1) ** (1/2))):
    if y > x:
      break
    for z in range(1,int((N + 1) ** (1/2))):
      if z > y:
        break
      a = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      if a > N:
        break
      if len({x,y,z}) == 1:
        result[a - 1] += 1
      else:
        result[a - 1] += (len({x,y,z}) - 1) * 3
for r in result:
  print(r)

Submission status: Accepted

Solution code:

N=int(input())
for n in range(1,N+1):
    ans=0
    for x in range(1,101):
        tx=x**2
        if tx>n-2*x :
            break
        for y in range(x,101-x):
            ty=tx+y**2+x*y
            if ty>n-x-y :
                break
            ss=(x+y)**2-4*(ty-n)
            if ss<0:
                break
            s=ss**0.5
            if s.is_integer():
                z=int((-1*(x+y)+s)/2)
                if z>=y:
                    
                    if len(set([x,y,z]))==1:
                        ans+=1
                    if len(set([x,y,z]))==2:
                        ans+=3
                    if len(set([x,y,z]))==3:
                        ans+=6
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())

arr=[0]*n

x=1

while 6*(x**2)<=n:
    y=x
    while (x**2)+3*(y**2)+(2*x*y)<=n:
        z=y
        while (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)<=n:
            r=(x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)-1
            if x==y and y==z:
                arr[r]+=1
            elif x==y or y==z or z==x:
                arr[r]+=3
            else:
                arr[r]+=6
            z+=1
        y+=1
    x+=1
for ans in arr:
    print(ans)

Submission status: Accepted

Solution code:
f = lambda x, y, z: (x + y + z) ** 2 - x * y - y * z - z * x - 1

n = int(input())
a = [0] * n
z = 1
while f(1, 1, z) < n:
  y = 1
  while f(1, y, z) < n:
    x = 1
    while f(x, y, z) < n:
      a[f(x, y, z)] += 1
      x += 1
    y += 1
  z += 1
print(*a, sep='\n')

Submission status: Accepted

Solution code:
## (x+y)^2+(y+z)^2+(z+x)^2==2n
## 3この平方数の和
n=int(input())
dict={}
i,j,k=1,1,1
while (i+j)**2+(j+k)**2+(k+i)**2<=2*n:
    while (i+j)**2+(j+k)**2+(k+i)**2<=2*n:
        # print('\t',i,j,k)
        while (i+j)**2+(j+k)**2+(k+i)**2<=2*n:
            tmp=(i+j)**2+(j+k)**2+(k+i)**2
            tmp//=2
            if tmp not in dict:
                dict[tmp]=0
            dict[tmp]+=1
            # print(i,j,k)
            k+=1
        k=1
        j+=1
    j=1
    i+=1
# print(dict)
for i in range(1,n+1):
    if i in dict:
        print(dict[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
import math
N=int(input())
for n in range(1,N+1):
  tmp=0
  for x in range(1,100):
    for y in range(1,100):
      if 4*n-3*x**2-2*x*y-3*y**2<0:continue
      z=0.5*(math.sqrt(4*n-3*x**2-2*x*y-3*y**2)-x-y)
      if z.is_integer() and z>=1:
        tmp+=1
      z=0.5*(math.sqrt(4*n-3*x**2-2*x*y-3*y**2)*(-1)-x-y)
      if z.is_integer() and z>=1:
        tmp+=1
  print(tmp)

Submission status: Accepted

Solution code:
N = int(input())

keys = [i for i in range(1, N+1)]
values = [0] * N
count_dict = dict(zip(keys, values))

for x in range(1, N//6+7):
    for y in range(x, N//6+7):
        for z in range(y, N//6+7):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n > N:
                break
            if x == y and y == z:
                count_dict[n] += 1
            elif x != y and x != z and y != z:
                count_dict[n] += 6
            else:
                count_dict[n] += 3

for v in count_dict.values():
    print(v)

Submission status: Accepted

Solution code:
import numpy as np
import math

n = int(input())
max = math.ceil(np.sqrt(n))
sum_list = []
for x in range(1,max):
  if x**2 + x + 4 > n:
    break
  for y in range(1,max):
    if x**2 + y**2 + x*y + x + y + 1 > n:
      break
    for z in range(1,max):
      a = x**2 + y**2 + z**2 + x*y + y*z + z*x 
      if a > n:
        break
      sum_list.append(a)
line = [0 for i in range(n+1)]
for i in sum_list:
  line[i] += 1
  
for i in range(1,n+1):
  print(line[i])

Submission status: Accepted

Solution code:
import math

n = int(input())
ans = [0] * n

for i in range(1, int(math.sqrt(n))):
    for j in range(1, i + 1):
        for k in range(1, j + 1):
            fn = i * i + j * j + k * k + i * j + j * k + k * i
            if fn > n:
                break
            if i != j and j != k and k != i:
                ans[fn - 1] += 6
            elif i == j and j == k:
                ans[fn - 1] += 1
            else:
                ans[fn - 1] += 3

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

Submission status: Accepted

Solution code:
N = int(input())
A = [0] * 10001
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[1:N+1]:
    print(a)

Submission status: Accepted

Solution code:
import sys
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

# combs = list(itertools.product(range(1,int(N**0.5)), repeat=3))
combs = list(itertools.combinations_with_replacement(range(1,int(N**0.5)), 3))
sum = [0] * (N+1)

for comb in combs:
    temp = comb[0]**2 + comb[1]**2 + comb[2]**2+ comb[0]*comb[1]+ comb[1]*comb[2] + comb[2]*comb[0]
    if temp <= N:
        if comb[0] != comb[1] and comb[1] != comb[2] and comb[2] != comb[0]:
            sum[temp] += 6
        elif comb[0] == comb[1] == comb[2]:
            sum[temp] += 1
        else:
            sum[temp] += 3


for i,s in enumerate(sum):
    if i == 0:
        continue
    print(s)

Submission status: Accepted

Solution code:

n=int(input())
N=10**4+1
lst=[0]*N
s=0
for i in range(1,10**2+1):
    for j in range(1,10**2+1):
        for k in range(1,10**2+1):
            s=i**2+j**2+k**2+i*j+j*k+k*i
            if s<10**4+1:
                lst[s]+=1
for i in range(1,n+1):
    print(lst[i])

Submission status: Accepted

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

Submission status: Accepted

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

ans = {}
for x in range(1,int(math.sqrt(n+1))+1):
    for y in range(1, x+1):
        for z in range(1, y+1):
            k = pow(x, 2) + pow(y, 2) + pow(z, 2) + x*y + x*z + y*z

            if k >n:
                break
            if len(set([x,y,z])) == 3:
                num = 6
            elif len(set([x,y,z])) == 2:
                num = 3
            else:
                num = 1
            if not k in ans:
                ans[k] = num
            else:
                ans[k] += num

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

Submission status: Accepted

Solution code:
from collections import defaultdict


n = int(input())
d = defaultdict(int)
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      fx = x ** 2 + y ** 2 + z ** 2 + x * y + x * z + y * z
      if fx > n:
        break
      d[fx] += 1
    if x ** 2 + y ** 2 >= n:
      break
  if x ** 2 >= n:
    break
for i in range(1, 1 + n):
  print(d[i])

Submission status: Accepted

Solution code:
import sys
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

# combs = list(itertools.product(range(1,int(N**0.5)), repeat=3))
combs = list(itertools.combinations_with_replacement(range(1,int(N**0.5)), 3))
sum = [0] * (N+1)

for comb in combs:
    temp = comb[0]**2 + comb[1]**2 + comb[2]**2+ comb[0]*comb[1]+ comb[1]*comb[2] + comb[2]*comb[0]
    if temp <= N:
        if comb[0] != comb[1] and comb[1] != comb[2] and comb[2] != comb[0]:
            sum[temp] += 6
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
        elif comb[0] == comb[1] == comb[2]:
            sum[temp] += 1
            # sum.append(temp)
        else:
            sum[temp] += 3
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)


for i,s in enumerate(sum):
    if i == 0:
        continue
    print(s)
# for i in range(1,N+1):
#     print(sum.count(i))

# elif (comb[0] == comb[1] and comb[1] != comb[2] and comb[2] != comb[0]) or (comb[0] != comb[1] and comb[1] == comb[2] and comb[2] != comb[0]) or (comb[0] != comb[1] and comb[1] != comb[2] and comb[2] == comb[0]):

Submission status: Accepted

Solution code:
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    min=int((nn+1)/math.sqrt(3))
    min1=int((nn+1)/math.sqrt(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==x:
                        count=count+1
                    elif x!=y and y!=z and z!=x:
                        count=count+6
                    else:
                        count=count+3
    print(count)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

N = a_int()
# 3重ループの早期終了かな
f = [0] * (N + 1)
for x in range(1, N):
    for y in range(1, N):
        if x * x + y * y + x * y >= N:
            break
        for z in range(1, N):
            n = x * x + y * y + z * z + x * y + y * z + z * x
            if n > N:
                break
            f[n] += 1
print(*f[1:], sep='\n')

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*(n+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            t=x**2+y**2+z**2+x*y+y*z+z*x
            if t<=n:
                a[t-1]+=1
print(*a[:n],sep='\n')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
import collections


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


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


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


def main():
    N = II()
    ans = 0
    list_counter = []

    for i in range(1, math.floor(N**(1/2))+1):
        for j in range(i,  math.floor(N**(1/2))+1):
            for k in range(j,  math.floor(N**(1/2))+1):
                n = str(i**2 + j**2 + k**2 + i*j + j*k + k*i)
                tmp = set([i, j, k])

                if len(tmp) == 3:
                    tmp_list = [n]*6
                if len(tmp) == 2:
                    tmp_list = [n]*3
                if len(tmp) == 1:
                    tmp_list = [n]*1
                list_counter.extend(tmp_list)

    counter = collections.Counter(list_counter)
    for n in range(1, N+1):
        print(counter[str(n)])



    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()

Submission status: Accepted

Solution code:
N=int(input())
f=[0]*(10**4+1)
for x in range(1,10**2):
    for y in range(1,10**2):
        for z in range(1,10**2):
            n=x**2+y**2+z**2+x*y+y*z+z*x
            if n<=10**4:
                f[n]+=1
for i in range(1,N+1):
    print(f[i])

Submission status: Accepted

Solution code:
from sys import stdin
data = int(stdin.readline().rstrip())

list = [0]*10000
for x in range(1,10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= 10**4:
                list[a-1] += 1

for i in range(1,data+1):
    print(list[i-1])

Submission status: Accepted

Solution code:
N=int(input())
keys=[]
for i in range(10**4):
  keys.append(str(i+1))
values=[0]*(10**4)
d=dict(zip(keys, values))
for x in range(1, 150):
  for y in range(x,150):
    tmp=(x+y)**2
    for z in range(y, 150):
      if tmp+(y+z)**2+(x+z)**2>20000:
        break
      if (tmp+(y+z)**2+(x+z)**2)%2==1:
        continue
      s=(tmp+(y+z)**2+(x+z)**2)//2
      key=str(s)
      if x==y and y==z:
        v=1
      elif (x==y and y<z) or (x<y and y==z):
        v=3
      elif x<y and y<z:
        v=6
      d[key]+=v

for i in range(N):
  print(d[str(i+1)])

Submission status: Accepted

Solution code:
import sys
from math import sqrt
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    for n in range(1, N + 1):
        ans = 0
        #print("n={}".format(n))
        for x in range(1, 41):
            # x==yの時
            if n - 2*x*x >= 0:
                z0 = round(sqrt(n - 2*x*x) - x)
                for z in range(z0 - 2, z0 + 3):
                    if (x + z)**2 + 2*x*x == n:
                        if x == z:
                            #print(x, x, x)
                            ans += 1
                        elif x < z:
                            #print(x, x, z)
                            ans += 3
            # x < y <= zの時
            if n - x**2 >= 0:
                upper = round(sqrt((n - x**2) / 3) - x / 3) + 5
                for y in range(x+1, upper):
                    val = x**2 + x*y + y**2
                    if (x + y)**2 - 4 * (val - n) >= 0:
                        z0 = round((-(x+y) + sqrt((x + y)**2 - 4 * (val - n))) / 2)
                        for z in range(z0-2, z0+3):
                            if z**2 + (x + y)*z + val == n:
                                if y == z:
                                    #print(x, y, z)
                                    ans += 3
                                elif y < z:
                                    #print(x, y, z)
                                    ans += 6
        print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def C():
    N = int(input())
    ans = [0]*N
    seen = set()
    def helper(factors):
        x, y, z = factors
        seen.add((x, y, z))
        res = x*x + y*y + z*z + x*y + y*z + z*x
        if res > N:
            return
        ans[res-1] += 1
        if (x+1, y, z) not in seen:
            helper((x+1, y, z))
        if (x, y+1, z) not in seen:
            helper((x, y+1, z))
        if (x, y, z+1) not in seen:
            helper((x, y, z+1))

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

C()

Submission status: Accepted

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

sqrt_N = int(math.sqrt(N))
count = 0
tmp = [[0] * 2 for i in range(N+1)]
for i in range(1,sqrt_N+1):
    for j in range(1,sqrt_N+1):
        for k in range(1,sqrt_N+1):
            ff = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if ff <= N:
                tmp[ff][1] += 1

for i in range(1,N+1):
    print(tmp[i][1])

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect


if __name__ == "__main__":
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5)+1):
        for j in range(1,int(n**0.5)+1):
            for k in range(1,int(n**0.5)+1):
                if i**2 + j**2 + k**2 + i*j + j*k + i*k<=n:
                    ans[i**2 + j**2 + k**2 + i*j + j*k + i*k]+=1
    for i in range(1,n+1):
        print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
ans = [0]*(N+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x+y*y+z*z+x*y+y*z+z*x
            if n <= N:
                ans[n] += 1

for out in ans[1:]:
    print(out)

Submission status: Accepted

Solution code:
import collections
n=int(input())
lis=[]
lim=int(100000**(0.5))*int(6**(0.5))//3
for x in range(1,lim+1):
    for y in range(1,lim+1):
        for z in range(1,lim+1):
            lis.append(x**2+y**2+z**2+x*y+y*z+z*x)

c=collections.Counter(lis)
for i in range(1,n+1):
    print(c[i])

Submission status: Accepted

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

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            calc = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if calc > N:
                break
            else:
                L[calc-1] += 1

for l in L:
    print(l)

Submission status: Accepted

Solution code:
import math
import numpy as np
from collections import Counter

N = int(input())

if N == 1:
    print(0)
else:
    xyz_lim = int(math.sqrt(N-2)) - 1

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

    cnt = Counter()
    for _x in range(xyz_lim):
        for _y in range(xyz_lim):
            x, y = _x+1, _y+1
            cnt.update([f(x, y, _z+1) for _z in range(xyz_lim)])

    for _n in range(N):
        n = _n + 1
        print(cnt[n])

Submission status: Accepted

Solution code:
N = int(input())

arr = [0 for _ in range(N+1)]
for x in range(1,N+1):
    F1 = True
    for y in range(x,N+1):
        F2 = True
        for z in range(y,N+1):
            n = (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)
            if n > N:
                if y == z:
                    F2 = False
                break
            else:
                if x == y and y == z:
                    arr[n] += 1
                elif (x == y) or (y == z) or (z == x):
                    arr[n] += 3
                else:
                    arr[n] += 6
        if F2 == False:
            if x == y:
                F1 = False
            break
    if F1 == False:
        break

for i in arr[1:]:
    print(i)

Submission status: Accepted

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

li = [0 for i in range(N)]

for x in range(1, 100):
    for y in range(x, 100):
        for z in range(y, 100):
            ans = x**2+y**2+z**2+x*y+y*z+x*z
            if ans <= N:
                if x < y < z:
                    li[ans-1] += 6
                elif x == y == z:
                    li[ans-1] += 1
                else:
                    li[ans-1] += 3
for l in li:
    print(l)

Submission status: Accepted

Solution code:
import math
N=int(input())
ans=[0 for i in range(N)]

nax=int(math.sqrt(N))

for x in range(1,nax):
    for y in range(1,x+1):
        for z in range(1,y+1):
            temp=x**2+y**2+z**2+x*y+y*z+z*x
            if temp<=N:
                if x==y and y!=z:
                    ans[temp-1]+=3
                elif y==z and z!=x:
                    ans[temp-1]+=3
                elif z==x and x!=y:
                    ans[temp-1]+=3
                elif x==y==z:
                    ans[temp-1]+=1
                elif x!=y and y!=z and z!=x:
                    ans[temp-1]+=6

                
                
for anss in ans:
    print(anss)

Submission status: Accepted

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


N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, int(i**0.5)+2):
        for y in range(x, int(i**0.5)+2):
            if f(x, y, y-1) >= i:
                break
            l = y - 1
            r = int(i**0.5) + 1
            while r >= l:
                z = (r+l) // 2
                if f(x, y, z) == i:
                    if x < y:
                        if x == z or y == z:
                            ans += 3
                        else:
                            ans += 6
                    else:
                        if z == y:
                            ans += 1
                        else:
                            ans += 3
                if f(x, y, z) > i:
                    r = z - 1
                else:
                    l = z + 1

    print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

r = [0] * (n + 1)

def rr(i, j, k, s):
    if i == j and j == k:
        r[s] = r[s] + 1
    elif i == j or j == k or k == i:
        r[s] = r[s] + 3
    else:
        r[s] = r[s] + 6

for i in range(1, n + 1):
    ii = i * i
    if ii > n:
        break
    for j in range(1, i + 1):
        jj = j * j
        ij = i * j
        if ii + jj + ij > n:
            break
        for k in range(1, j + 1):
            kk = k * k
            ik = i * k
            jk = j * k

            ss = ii + jj + kk + ij + jk + ik
            if ss > n:
                break

            rr(i, j, k, ss)


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

Submission status: Accepted

Solution code:
N = int(input())

from collections import deque
tmp = []
tmp = deque(tmp)
num = [0]*(10**4*7)
for i in range(1,10**2+1):
    tmp.append(i**2)

for x in tmp:
    xx = int(x**0.5)
    for y in tmp:
        yy = int(y**0.5)
        for z in tmp:
            zz = int(z**0.5)
            ans = x + y + z + xx*yy + yy*zz + zz*xx
            num[ans] += 1
            
for i in range(1,N+1):
    print(num[i])

Submission status: Accepted

Solution code:
N = int(input())

A = [0] * (10 ** 5)

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            A[i**2 + j**2 + k**2 + i*j + j*k + k*i - 1] += 1

for i in range(0, N):
    print(A[i])

Submission status: Accepted

Solution code:
from sys import stdin
import math
import itertools

N = int(stdin.readline())
max_i = int(math.sqrt(N))
count = [0]*10000

# i1=i2=i3 *1
c = itertools.combinations_with_replacement(list(range(1, max_i+1)), 3)
for v in c:
    i1 = v[0]
    i2 = v[1]
    i3 = v[2]
    if i1==i2 and i2 == i3:
        num = i1*i1*6
        if num <=N:
            count[num-1] += 1
    elif i1 != i2 and i1 != i3 and i2 != i3:
        num = i1*i1+i2*i2+i3*i3 + i1*i2+ i2*i3+ i3*i1
        if num <= N:
            count[num-1] += 6
    else:
        num = i1*i1+i2*i2+i3*i3 + i1*i2+ i2*i3+ i3*i1
        if num <= N:
            count[num-1] += 3

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

Submission status: Accepted

Solution code:
import math

N = int(input())

rs = []
ans = [0]*N

maxn = math.ceil(math.sqrt(N))

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

for i in range(1,maxn+1):
    for j in range(1,maxn+1):
        for k in range(1,maxn+1):
            result = f(i,j,k)
            if result>N:
                break
            ans[result-1]+=1
            # rs.append(i,j,k)

for a in ans:
    print(a)

Submission status: Accepted

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


def f(n):
    m = int(math.sqrt(n)+0.5)
    res = 0
    for x in range(1, m+1):
        for y in range(x, m+1):
            k = n - (x * x + y * y + x * y)
            if k < 1:
                break
            l = y
            r = m+1
            while r - l > 1:
                z = (r + l) // 2
                tmp = (x + y + z) * z
                if tmp <= k:
                    l = z
                else:
                    if r == z + 1:
                        r -= 1
                    else:
                        r = z + 1
            if (x+y+l) * l == k:
                s = set()
                s.add(x)
                s.add(y)
                s.add(l)
                if len(s) == 3:
                    res += 6
                elif len(s) == 2:
                    res += 3
                else:
                    res += 1
    return res


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

Submission status: Accepted

Solution code:
import math
    

n = int(input(''))

mx=int(math.sqrt(n))+1

fmap = {}

for x in range(1,mx):
    for y in range(1,mx):
        for z in range(1,mx):
            ans = x**2 + y**2 + z**2 + x*y + y*z + x*z
            if ans not in fmap.keys():
                fmap[ans] = 0
            fmap[ans] += 1

for i in range(1,n+1):
    if i in fmap.keys():
        print(fmap[i])
    else:
        print(0)