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 .

Solution (Python):
import numpy as np

N = int(input())

ans = np.zeros(int(N))

if N<10001 and N>3:
    maxa = int(np.sqrt(N-2))
    for x in range(1,maxa):
        for y in range(1,x):
            for z in range(1,y):
                p = x*x+y*y+z*z+x*y+y*z+z*x
                if p<N+1:
                    ans[p-1] += 6


    for x in range(1,maxa):
        for y in range(1,x):
            p = x*x*3+y*y+x*y*2
            if p<N+1:
                ans[p-1] += 3
            p = y*y*3+x*x+x*y*2
            if p<N+1:
                ans[p-1] += 3

    for x in range(1,maxa):
        p = x*x*6
        if p<N+1:
            ans[p-1] += 1

for x in range(0,N):
    print(int(ans[x]))

Solution (Python):
n = int(input())
ans = [0 for _ in range(10**5)]
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            p = x**2 + y**2 + z**2 + x * y + y * z + z * x
            if p <= 10**4:
                ans[p] += 1
for i in range(1, n + 1):
    print(ans[i])

Solution (Python):

import itertools

N = int(input())

ans = [0]*N

x = []


i=1
while 1:
    if (i+1)*(i+1)+2>=N:
        break
    i+=1
i+=1

for inputI in range(i):
    x.append(inputI+1)


S = list(itertools.combinations_with_replacement(x, 3))


for s in S:
    sum = (s[0]+s[1])*(s[0]+s[2])+pow(s[1],2)+pow(s[2],2)

    if sum <= N:
        if s.count(s[0])==3:
            ans[sum-1]+=1
        elif s.count(s[0])==2 or s.count(s[1])==2:
            ans[sum-1]+=3
        else:
            ans[sum-1]+=6


for a in ans:
    print(a)

Solution (Python):
import math
import collections
n=int(input())
m=int(math.sqrt(n)+1)
a=[]
for x in range(1,m):
  for y in range(1,m):
    for z in range(1,m):
      if x**2+y**2+z**2+x*y+y*z+z*x<=n:
        a.append(x**2+y**2+z**2+x*y+y*z+z*x)
c=collections.Counter(a)
for i in range(1,n+1):
  print(c[i])

Solution (Python):









import os
import sys


from itertools import combinations_with_replacement as nCr
from collections import Counter


def main():
    S = list(map(list, nCr(range(1, 100), 3)))
    sum_list = []
    cnt = 0
    for s in S:

        total = s[0]**2+s[1]**2+s[2]**2+s[0]*s[1]+s[1]*s[2]+s[2]*s[0]
        loop_cnt = 1
        if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
            loop_cnt = 6
        elif (s[0] == s[1] and s[1] != s[2]) or (s[1] == s[2] and s[2] != s[0]) or (s[2] == s[0] and s[0] != s[1]):
            loop_cnt = 3
        if total < 10001:
            for _ in range(loop_cnt):
                sum_list.append(total)
        cnt+=1

    
    
    
    c = Counter(sum_list)
    key = c.keys()
    n = int(input())
    for i in range(1, n+1):
        if not i in key:
            print(0)
        else:
            print(c[i])

if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
a=[]
for i in range(N):
  a.append(0)
for x in range(1,N+1):
  if x**2>=N:
    break
  for y in range(1,N+1):
    if x**2 + y**2 >= N:
      break
    for z in range(1,N+1):
      if x**2+y**2+z**2>=N:
        break
      t=x**2+y**2+z**2+x*y+y*z+z*x
      if t<=N:
        a[t-1] += 1
for m in range(N):
  print(a[m])

Solution (Python):
import itertools
import math
import numpy as np

N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
score = np.zeros([10000]).astype(np.uint8)
for c in itertools.combinations_with_replacement(l, 3):
  sum = c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]
  if sum <= 10000:
    if len(set(c)) == 3:
      score[sum-1] += 6
    elif len(set(c)) == 2:
      score[sum-1] += 3
    else:
      score[sum-1] += 1
    
for n in range(1, N+1):
  ans = 0
  print(score[n-1])

Solution (Python):
import math

n = int(input())
a = [0]*100001
b = math.ceil(math.sqrt(n)) + 1
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

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

Solution (Python):
a = int(input())
b = round(a**0.5) + 1

x = []
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            l = i**2 + j**2 + k**2 + i*j + j*k + k*i
            x.append(l)

t = [0] * a
for i in range(0,len(x)):
    if x[i] <= a:
        t[x[i]-1] = t[x[i]-1] + 1

for i in t:
    print(i)

Solution (Python):
n = int(input())
a = [0 for i in range(n)]
c = 0
total = n
for x in range(1, n//2):
    for y in range(x, n//2):
        for z in range(y, n//2):
            total = int(((x+y)**2 + (z+y)**2 + (x+z)**2) / 2)
            try:
                if x == y == z:
                    a[total-1] += 1
                elif x == y or y == z:
                    a[total-1] += 3
                else:
                    a[total-1] += 6
            except:
                break
for i in a:
    print(i)

Solution (Python):
import math

def resolve():
    cnt = 0
    n = int(input())
    ans = [0] * n
    m = math.ceil(math.sqrt(n))
    for x in range(1, m):
        for y in range(1, m):
            for z in range(1, m):
                a = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if a <= n:
                    ans[a-1] += 1
                else:
                    break
    
    for a in ans:
        print(a)

resolve()

Solution (Python):
import time
import itertools
import collections

N = int(input())
start = time.time()
def function(x,y,z):
    return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)

p = list(itertools.product(range(1,100),repeat=3))
a = []

for p_in in p:
    a.append(function(p_in[0],p_in[1],p_in[2]))

dict = collections.Counter(a)

for n in range(1,N + 1):
    print(dict[n])

Solution (Python):
n = int(input())
c = [0]*10001

for x in range(1,101):
    if(x > n):
        break
    for y in range(1,101):
        for z in range(1,101):
            p = int(((x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x))/2)
            if(n >= p):
                c[p] += 1

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

Solution (Python):
import math
N=int(input())
ans=[0]*(N+1)
tempn=0
xmax=int(math.sqrt(N)+1)
for x in range(1,xmax+1):
    ymax=xmax-x
    for y in range(1,xmax+1):    
        zmax=ymax-y
        for z in range(1,xmax+1):
            tempn=((x+y+z)**2-(x*y+y*z+z*x))
            if tempn <= N:
                ans[tempn]+=1
for i in range(1,(N+1)):
    print(ans[i])

Solution (Python):

import collections
import sys
import math


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())


def main():
    N = I()
    if N <= 5:
        for i in range(N):
            print(0)
        return

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

    for i in range(5):
        print(0)

    for i in range(6, N+1):
        cn = 0
        n = math.floor(math.sqrt(i)+1)
        start = math.floor(math.sqrt(i/6))
        for j in range(start, n):
            if j**2 >= i-4:
                break
            for k in range(1, j+1):
                if j**2+k**2+j*k >= i-2:
                    break
                for l in range(1, k+1):
                    y = yy(j, k, l)
                    if y > i:
                        break
                    if y == i:
                        if j == k == l:
                            cn += 1
                        elif j != k != l:
                            cn += 6
                        else:
                            cn += 3
        print(cn)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter

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()

count = Counter()
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            n = (x**2) + (y**2) + (z**2) + (x*y) + (y*z) + (z*x)
            count[n] += 1


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

Solution (Python):

import math

n = int(input())
dic = {}

for x in range(1,int(math.sqrt(n/6)+1)):
  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:
      if x**2+y**2+z**2+x*y+y*z+z*x not in dic:
        dic[x**2+y**2+z**2+x*y+y*z+z*x] = [[x,y,z]]
      else:
        dic[x**2+y**2+z**2+x*y+y*z+z*x].append([x,y,z])
      z += 1
      
    y += 1
    
for i in range(1,n+1):
  if i not in dic:
    print(0)
  else:
    count = 0
    for xyz in dic[i]:
      if xyz[0] == xyz[1] and xyz[1] == xyz[2]:
        count += 1
      elif xyz[0] == xyz[1] or xyz[1] == xyz[2]:
        count += 3
      else:
        count += 6
    print(count)