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:
from sys import stdin
import sys
import math
import random
from decimal import Decimal
import itertools as it

N = int(input())
# for i in range(1,N+1):
f = [0 for i in range(N)]
# print(f)
for x in range(1, 101):
    x2 = x**2
    for y in range(1, 101):
        y2 = y**2
        for z in range(1, 101):
            a = x2+y2+z**2+x*y+y*z+x*z
            if a <= N:
                f[a-1] += 1
            else:
                break
for i in f:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
r=range(1,int((2*10**4)**.5)+1)
l=[0]*-~n
for i in r:
  for j in r:
    for k in r:
      t=(j+k)**2+(k+i)**2+(i+j)**2
      if t<=n*2 and t%2<1:
        l[t//2]+=1
for i in range(n): print(l[i+1])

Submission status: Accepted

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

for i in range(1, N):
  a = i**2
  if 6*a > N:
    break
  for j in range(i, N):
    b = j**2
    d = i*j
    if a+2*b+2*i+j**2 > N:
      break
    for k in range(j, N):
      c = k**2
      e = i*k
      f = j*k
      s = a+b+c+d+e+f
      if s <= N:
        if (a==b) and (b==c):
          l[s-1] += 1
        elif (a==b) or (b==c):
          l[s-1] += 3
        else:
          l[s-1] += 6
      else:
        break
        
for num in l:
  print(num)

Submission status: Accepted

Solution code:
N  = int(input())

from collections import defaultdict
ansd = defaultdict(int)

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

for x in range(1,100):
    for y in range(1, 100):
        for z in range(1,100):
            ansd[calc(x,y,z)] += 1

for k in range(1, N+1):
    print(ansd[k])

Submission status: Accepted

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

for y in range(1, n-1):
    for x in range(1, n-1):
        for z in range(1, n-1):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                ans[x**2 + y**2 + z**2 + x*y + y*z + z*x]+=1
            elif x**2 + y**2 + z**2 + x*y + y*z + z*x > n:
                break
for i in range(1, n+1):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
ans = [0 for _ in range(N)]
for z in range(1, 101):
  for y in range(1, 101):
    for x in range(1, 101):
      i = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if i <= N:
        ans[i-1] += 1
        
for j in ans:
  print(j)

Submission status: Accepted

Solution code:
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                val = x ** 2 + y ** 2 + z ** 2 + x * y + z * y + x * z
                #print(x, y, z, ":", val)
                if val <= n:
                    res[val - 1] += 1
    for r in res:
        print(r)
    return




n = RN()
res = [0] * n
solve()

Submission status: Accepted

Solution code:
from math import sqrt
inpl = lambda: list(map(int,input().split()))
N = int(input())
ans = [0]*(N+1)
M = int(sqrt(N-1))
for x in range(1,M):
    for y in range(x,M):
        n = x*x + y*y + 1 + x*y + y + x
        if n > N:
            break
        for z in range(y,M):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n > N:
                break
            elif x==y==z:
                ans[n] += 1
            elif x==y or y==z:
                ans[n] += 3
            else:
                ans[n] += 6
for n in range(1,N+1):
    print(ans[n])

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
L = [0]*(10**4)
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            ans = i**2+j**2+k**2+i*j+j*k+i*k
            if ans <= 10**4:
                L[ans-1] += 1
for i in range(N):
    print(L[i])

Submission status: Accepted

Solution code:

N = int(input())
a = []
for n in range(1, N+1):
    ans = 0
    for x in range(1, int(n**(1/2))+1):
        for y in range(x, int(n**(1/2))+1):
            c = x**2 + y**2 + x*y - n
            b = x+y
            if b**2 - 4*c >= 0:
                d = (-b+(b**2-4*c)**(1/2))/2
                if int(d) == d and d >= 1:
                    if x != y:
                        ans += 2
                    else:
                        ans += 1
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            a.append(i**2 + j**2 + k**2 + i*j + j*k + k*i)
a.sort()
ix = 0
for i in range(1, n+1):
    res = 0
    while(a[ix] == i):
        res+=1
        ix+=1
    print(res)

Submission status: Accepted

Solution code:
N=int(input())
ans=[0]*(N+1)
for x in range(1,int(N**0.5)+2):
  for y in range(1,int(N**0.5)+2):
    for z in range(1,int(N**0.5)+2):
      if x**2+y**2+z**2+x*y+x*z+y*z<=N:
        ans[x**2+y**2+z**2+x*y+x*z+y*z]+=1

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

Submission status: Accepted

Solution code:
n=int(input())
l=[0]*10000000
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            k1=((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k))
            l[k1]+=1
for i in range(1,n+1):
    print(l[i])

Submission status: Accepted

Solution code:
N = int(input())
n = int(N**(1/2))

ans_list = [0]*(N)

for i in range(1,n):
    for j in range(1,n):
        for k in range(1,n):
            index = i**2+j**2+k**2+i*j+j*k+k*i

            if index>N:
                break

            ans_list[index-1] += 1

for i in ans_list:
    print(i)

Submission status: Accepted

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

ans=[0]*(10**4+1)

x,y,z=1,1,1
while True:
  if(x*x+y*y+z*z+x*y+y*z+z*x)<=N:
    ans[x*x+y*y+z*z+x*y+y*z+z*x]+=1
    z+=1
  else:
    z=1
    y+=1
    if not (x*x+y*y+z*z+x*y+y*z+z*x)<=N:
      y=1
      x+=1
      if x==N+1:break
for i in range(1,N+1):
  print(ans[i])

Submission status: Accepted

Solution code:
n=int(input())
ans=[0]*(6*(10**4)+1)
for i in range(1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      ans[i**2+j**2+k**2+i*j+j*k+k*i]+=1

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

Submission status: Accepted

Solution code:
n = int(input())
import math
res = 0
arr = [0]*(n+1)
for i in range(1,int(math.sqrt(n)+2)):
    for j in range(1,int(math.sqrt(n)+2)):
        for k in range(1,int(math.sqrt(n)+2)):
            tmp = int(pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i)
            if tmp <= n:
                arr[tmp] += 1
for i in range(1,n+1):
    print(arr[i])

Submission status: Accepted

Solution code:
n = int(input())
dp = [0 for i in range(n+1)]
maxn = n**0.5
maxn = int(maxn)+1
for x in range(1,maxn):
    for y in range(1,maxn):
        for z in range(1,maxn):
            p = x*x + y*y + z*z + x*y + y*z +z*x
            if p<=n:
                dp[p]+=1
for i in dp[1::]:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
rt_n=int(n**0.5)
ans=[0]*n
for x in range(1,rt_n):
    for y in range(1,rt_n):
        for z in range(1,rt_n):
            t= x*x + y*y + z*z + x*y + y*z + z*x
            if t<=n:
                ans[t-1]+=1
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
from itertools import combinations_with_replacement
from collections import Counter

N = int(input())
ans = [0] * (N+1)
for x in combinations_with_replacement(range(1,99),3):
    temp = x[0] ** 2 + x[1] ** 2 + x[2] ** 2 + x[0] * x[1] + x[1] * x[2] + x[2] * x[0]
    if temp <= N:
        tc = Counter(x)
        if len(tc) == 1:
            ans[temp] += 1
        elif len(tc) == 2:
            ans[temp] += 3
        else:
            ans[temp] += 6
for x in ans[1:]:
    print(x)

Submission status: Accepted

Solution code:
n = int(input())

from collections import defaultdict
d = defaultdict(int)

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


for x in range(1, 100):
    for y in range(x, 100):
        for z in range(y, 100):
            tmp = f(x, y, z)
            if x == y == z:
                d[tmp] += 1
            elif x == y or y == z or z == x:
                d[tmp] += 3
            else:
                d[tmp] += 6

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

Submission status: Accepted

Solution code:
N = int(input())
a = [0]*60001
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      a[i**2+j**2+k**2+i*j+j*k+k*i]+=1
for i in a[1:N+1]:
  print(i)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = [0]*10**5
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      a = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if a > 10**4 + 10:
          continue
      li[a-1] += 1
for ans in li[0:n]:
  print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
from itertools import combinations_with_replacement
from collections import defaultdict

N=int(input())
MAX=int(sqrt(N))
num=[i for i in range(1,MAX+1)]
d=defaultdict(int)
for x,y,z in list(combinations_with_replacement(num,3)):
    val=x**2+y**2+z**2+x*y+y*z+z*x
    if x==y and y==z and z==x:
        d[val]+=1
    elif x==y or y==z or z==x:
        d[val]+=3
    else:
        d[val]+=6

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

Submission status: Accepted

Solution code:
n = int(input())
ans = [0]*(10**5)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            a = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ans[a] += 1
for i in range(n):
    print(ans[i+1])

Submission status: Accepted

Solution code:
import math
N=int(input())
K=int(math.sqrt(N/6))+1
L=int(math.sqrt(N/3))+1
M=int(math.sqrt(N))+1


ls=[0 for i in range(M**3+1)]

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

for i in range(1,K):
  ls[f(i,i,i)]+=1

for i in range(1,K):
  for j in range(i+1,M):
    ls[f(i,i,j)]+=3
    ls[f(i,j,j)]+=3
    
for i in range(1,K):
  for j in range(i+1,L):
    for k in range(j+1,M):
      ls[f(i,j,k)]+=6
      
for i in range(1,N+1):
  print(ls[i])

Submission status: Accepted

Solution code:
n=int(input())
import math
nn=int(math.sqrt(n))+1
a=[0]*(100*n)
for x in range(1,nn+1):
    for y in range(1,nn+1):
        for z in range(1,nn+1):
            a[(x+y+z)**2-x*y-x*z-y*z]+=1
for i in range(1,n+1):
    print(a[i])

Submission status: Accepted

Solution code:
N = int(input())

ans = [0]*(10**5)
for x in range(1,110):
    for y in range(1,110):
        for z in range(1,110):
            cnt = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ans[cnt] += 1
        
for i in range(1,N+1):
    print(ans[i])

Submission status: Accepted

Solution code:
f=[0 for i in range(10**4 + 1)]



for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if (x**2 + y**2 + z**2 + x*y+y*z+x*z) < len(f):
                f[x**2 + y**2 + z**2 + x*y+y*z+x*z]+=1

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

Submission status: Accepted

Solution code:
n=int(input())
ans=[0]*10000
for x in range(1,101):
    for y in range(x,101):
        for z in range(y,101):
            k=x**2+y**2+z**2+x*y+y*z+z*x
            if k<=10**4:
                if x==y and x==z:
                    ans[k-1]+=1
                elif x==y and x!=z:
                    ans[k-1]+=3
                elif x!=y and y==z:
                    ans[k-1]+=3
                elif x!=y and x!=z:
                    ans[k-1]+=6
for x in range(n):
    print(ans[x])

Submission status: Accepted

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

if N <= 3:
  for i in range(N):
    print(0)
  exit()

M = int((N-2)**0.5)
 
for x in range(1, M+1):
  for y in range(1, M+1):
    for z in range(1, M+1):
      a = (x+y+z)**2 - (x*y + y*z + z*x)
      if a <= N:
      	ans[a-1] += 1
 
for i in range(N):
  print(ans[i])

Submission status: Accepted

Solution code:
from math import sqrt
N=int(input())
cnt=[0]*(N+1)
sn=int(sqrt(N))+1
for i in range(1,sn+1):
  for j in range(1,sn+1):
    for k in range(1,sn+1):
      l=i**2+j**2+k**2+i*j+j*k+k*i
      if l<N+1:
        cnt[l]+=1

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

Submission status: Accepted

Solution code:
def f(x,y,z):
  return x**2+y**2+z**2+x*y+y*z+z*x
# n=int(input())
# c=[0]*n
# # for i in range(n):

# for i in range(1,10**4):
#   for j in range(1,10**4):
#     k=(n-i**2-j**2-i*j)/()
n=int(input())
a=[0]*n
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      t=f(i,j,k)
      if t<=n:
        a[t-1]+=1
# print(a)
for aa in a:
  print(aa)

Submission status: Accepted

Solution code:
N = int(input())

memo = [0]*(N+1)
for i in range(1,150):
  for j in range(1,150):
    for k in range(1,150):
      n = (i+j)**2 + (j+k)**2 + (k+i)**2
      if n <= 2*N and n%2 == 0:
        memo[n//2] += 1
        
for i in memo[1:]:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
ans = [0]*(10**5)
a = 0
for x in range(1,10**2):
  for y in range(1,10**2):
    for z in range(1,10**2):
      ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
for i in range(1,N+1):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import defaultdict

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

N = int(input())

i = 1
dic = defaultdict(lambda: set())
dic[6].add((1,1,1))

while i <= N:
  if i in dic:
    print(len(dic[i]))
    for trio in dic[i]:
      x,y,z = trio
      dic[f(x,y,z+1)].add((x,y,z+1))
      dic[f(x,y+1,z)].add((x,y+1,z))
      dic[f(x+1,y,z)].add((x+1,y,z))
  else:
    print(0)
  i += 1

Submission status: Accepted

Solution code:
n = int(input())

a = int(n ** 0.5) + 1

m = {}
for x in range(1, a):
    for y in range(1, a):
        for z in range(1, a):
            v = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            m[v] = m.get(v, 0) + 1
for i in range(1, n + 1):
    print(m.get(i, 0))

Submission status: Accepted

Solution code:
print_cnt = int(input())

result = [0] * 10000

for x in range(100):
  for y in range(100):
    for z in range(100):
      if x*y*z == 0:
        continue
      tmp = x*x + y*y + z*z + x*y + y*z + z*x
      if tmp <= 10000:
        result[tmp-1] += 1

for i in range(print_cnt):
  print(result[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

n=int(input())
ans=[0]*n
tmp=[]
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):
            tmp.append(x**2+y**2+z**2+x*y+y*z+z*x)

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

Submission status: Accepted

Solution code:
n=int(input())

n2=int(n**(0.5)+0.5)+1+1
f=[0]*(n+1)

for x in range(1,n2):
    for y in range(1,n2):
        for z in range(1,n2):
            v=x*x+y*y+z*z+x*y+y*z+z*x
            if v<=n:
                f[v]+=1
                
for v in range(1,n+1):
    print(f[v])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

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

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

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

Submission status: Accepted

Solution code:
import math
con = 0;
n = int(input())
a = [0]*n

m = int(math.sqrt(n) // 1);
for x in range(1,m+1):
    for y in range(1,m+1):
        for z in range(1,m+1):
            s = x**2 + y**2 + z**2 + x*y + y*z + z*x;
            if s <= n:
                a[s-1] += 1;


for v in range(n):
    print(a[v]);

Submission status: Accepted

Solution code:
import itertools
import collections
n=int(input())
Lst=list(range(1,101))
lst=list(itertools.combinations_with_replacement(Lst,3))
a=[]
for i in range(len(lst)):
  x=lst[i][0]
  y=lst[i][1]
  z=lst[i][2]
  if x==y==z:
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
  elif x!=y and y!=z and z!=x:
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)    
  else:
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)    
    
b=collections.Counter(a)
for i in range(1,n+1):
  print(b[i])