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: Wrong Answer

Solution code:
import math

def main():
    N = int(input())
    x = 1
    y = 1
    z = 0

    for i in range(1,N+1):
        ans = 0
        sn = math.ceil(math.sqrt(i))
        x = 1
        y = 1
        z = sn - 2
        # print(x,y,z)
        if z <= 0:
            print(ans)
            continue
        ans += func(i,x,y,z)
        while z >= math.ceil(sn / 2):
            y += 1
            z -= 1
            # print(x,y,z)
            if x > z or y > z:
                break
            ans += func(i,x,y,z)
            for j in range(y):
                x += 1
                z -= 1
                if x > z or y > z:
                    break
                # print(x,y,z)
                ans += func(i,x,y,z)
        print(ans)
            
def func(n,x,y,z):
    if x**2+y**2+z**2+x*y+y*z+z*x == n:
        if x == y and y == z and z == x:
            return 1
        else:
            return 3
    else:
        return 0

main()

Submission status: Wrong Answer

Solution code:
N = int(input())

n = N ** (1/2)
n = int(n)


for nn in range(N):
    ans = 0
    for x in range(1, n + 1):
        for y in range(1, n + 1):
            a = x + y
            b = x*x + y*y + x*y - nn
            if a*a -4*b >= 0:
                c = ((a*a-4*b)**(1/2)-a)/2
                if c.is_integer() and c > 0:
                    ans += 1

    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 幅優先探索（行きがけ）
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
        for j in range(1, math.floor(math.sqrt(i)+1)):
            if j**2 >= i-5:
                break
            for k in range(1, j+1):
                if j**2+k**2+j*k >= i-3:
                    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()

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N=int(input())
ans=[0]*(10**6)
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
            else:
                kari=[x,y,z]
                #print(kari)
                if x**2+y**2+z**2+x*y+y*z+z*x<=10**5:
                    if len(set(kari))==1:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=1
                    else:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=3
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())

ans = {}
for v in itertools.combinations_with_replacement(range(1,N//6+1), 3):
    x,y,z = v
    fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if fn > N:
        break
    if fn in ans.keys():
        ans[fn].append([x,y,z])
    else:
        ans[fn] = [[x,y,z]]

for i in range(1,N+1):
    if i in ans.keys():
        count = 0
        for j in ans[i]:
            x,y,z = j
            if x == y == z:
                count += 1
            else:
                count += 3
        print(count)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import math
N = int(input()) + 1
Nroot = int(math.pow(N,1/3))
for n in range(1,N):
    count = 0
    if n >= 6:
#        print(Nroot, int(math.pow(n,1/3))-1)
        for x in range(Nroot, int(math.pow(n,1/3))-1 , -1):
            for y in range(x,0,-1):
                if (x+2*y)**2 < n:
                    break
                for z in range(1,y+1):
#                    print((x + y + z)**2 - (x*y + y*z + z*x), n,x,y,z)
#                    print(x,y,z)
                    formula = (x + y + z)**2 - (x*y + y*z + z*x)
                    if formula == n:
                        if x == y and y == z:
                            count += 1
                        else:
                            count += 3
                        break

        print(count)
    else:
        print("0")

Submission status: Wrong Answer

Solution code:
N = int(input())
def f(n):
    for x in range(1,int(N**0.5)+1):
        for y in range(x,int(N**0.5)+1):
            if n - (3/4)*(x*x + y*y) - 0.5*x*y >= 0:
                d = (n - (3/4)*(x*x + y*y) - 0.5*x*y)**0.5
                zp = (x+y)*(-0.5) + d
                zm = (x+y)*(-0.5) - d
                if (zp == int(zp) and zp >= 1) or (zm == int(zm) and zm >= 1):
                    if zp == int(zp):
                        z = zp
                    elif zm == int(zm):
                        z = zm
                    if x == y and y == z and z == x:
                        return 1
                    elif x == y or y == z or z == x:
                        return 3
                    else:
                        return 6
for i in range(1,N+1):
    ans = f(i)
    if ans == None:
        print(0)
    else:
        print(ans)

Submission status: Wrong Answer

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)%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: Wrong Answer

Solution code:
"""
x, y, z: 正数
x^2+y^2+z^2+xy+yz+zx = n
f(n): 以上の2つの条件を満たす正数の組（x, y, z）の個数
"""

import itertools
import math
import time
def f(X, Y, Z):
    temp = (X**2 + Y**2 + Z**2)/2
    return temp

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

start = time.time()

N  = int(input())

X = range(1, int(math.sqrt(N)))
Y = X
Z = X

for i in range(1, N+1):
    count = 0
    for v in itertools.product(X, Y, Z):
        if(g(v[0], v[1], v[2]) > i):
            continue
        elif(g(v[0], v[1], v[2]) == i):
            count += 1
    print(count)

end = time.time()
print(end-start)

Submission status: Wrong Answer

Solution code:
import itertools

def calculateFunction(x, y, z):
    triplePattern = 1
    doublePattern = 3
    notEqualPattern = 6

    tmp = x + y + z
    returnValue = tmp * tmp - (x*y + y*z + z*x)
    if (x == y):
        if (y == z):
            return triplePattern, returnValue
        else:
            return doublePattern, returnValue
    elif (y == z):
        return doublePattern, returnValue
    else:
        return notEqualPattern, returnValue

lis = []
for i in range(42):
    lis.append(i+1)

fullset = [0] * 10000
for team in itertools.product(lis, repeat = 3):
    targetValue, ans = calculateFunction(team[0], team[1], team[2])
    if (ans <= 10000):
        fullset[ans - 1] += 1

X = int(input())

for i in range(X):
    print(fullset[i])

Submission status: Wrong Answer

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

highest = int(math.sqrt(n))
print(highest)
l = [0]*n
cal = 0

for x in range(1, highest+1):
  for y in range(1, highest+1):
    for z in range(1, highest+1):
      cal = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if cal > n:
        continue
      else:
        l[cal-1] += 1
        
for i in range(len(l)):
  print(l[i])

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    ans = [0] * 6 * (10 ** 6)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if ans[n - 1] == 0:
                    ans[n - 1] = 6
                elif ans[n - 1] == 6:
                    ans[n - 1] = 3
                elif ans[n - 1] == 3:
                    ans[n - 1] = 1
                

    squares = [print(i) for i in ans[0 : N]]

                    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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:
                z = round(sqrt(n - 2*x*x) - x)
                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) + 1
                for y in range(x+1, upper):
                    val = x**2 + x*y + y**2
                    if (x + y)**2 - 4 * (val - n) >= 0:
                        z = round((-(x+y) + sqrt((x + y)**2 - 4 * (val - n))) / 2)
                        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: Wrong Answer

Solution code:
import math

n = int(input())

for i in range(6, n + 1):
    cnt = 0
    f = int(math.sqrt(n)) + 1
    for x in range(1, f):
        for y in range(1, f):
            for z in range(1, f):
#                 print(i, x, y, z)
                if (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x) == i:
                    cnt += 1

    print(cnt)

Submission status: Wrong Answer

Solution code:
import math


def pattern(x, y, z):
    if x == y == z:
        return 1
    elif x != y != z:
        return 6
    else:
        return 3


def check(upper_value, ans):
    cnt = 0
    for x in range(1, ans):
        if pow(x, 2) > ans:
            break
        for y in range(x, ans):
            if pow(x+y, 2) > ans:
                continue
            for z in range(y, ans):
                tmp = x*(x+y+z) + y*(y+z) + z*z
                if tmp == ans:
                    cnt += pattern(x, y, z)
                elif tmp > ans:
                    continue
    print(cnt)


N = int(input())
# x^2 + y^2 + z^2 + x*y + y*z + z*x = n

for i in range(N+1):
    #upper_value = int(math.sqrt(i))
    check(0, i)

Submission status: Wrong Answer

Solution code:
n=int(input())
d={}
sm=3
a=1
brk=0
ll=[]

while 1:  
  we=sm-a
  for i in range(1,we):
    c=we-i
    b=i
    temp=pow((a+b+c),2)-(a*b+a*c+b*c)
    if temp not in d:
      d[temp]=1
      ll.append(temp)
    else:
      d[temp]+=1
    brk=max(brk,temp)
  if we==2:
    sm+=1
    a=1
  else:
    a+=1
  if brk>n:
    break
#print(d)
l=[0]*n
ll.sort()
for i in ll:
  if i>n:
    break
  else:
    l[i-1]=d[i]
for i in l:
  print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,200):
  sqset.add(i**2)
print(sqset)
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      a=x+y
      b=x**2+y**2+x*y-m
      d=a**2-4*b
      if d in sqset:
        if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(5):
  print(0)
for i in range(6, n+1):
  count=0
  for x in range(1, i):
    for y in range(1, i):
      for z in range(1, i):
        """print(x,y,z)
        print(x*x + y*y + z*z+ x*y + y*z + z*x)
        print(i)"""
        if x*x + y*y + z*z + x*y + y*z + z*x == i:
          count+=1
  print(count)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
ans=list()
for i in range(1,N+1):
    tmp=0
    tgt=int(math.sqrt(i/3)+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: Wrong Answer

Solution code:
def main():
    n = int(input())
    f = [0 for i in range(n+1)]
    Max = n**0.5
    Max = int(Max//1) 
    for x in range(1,Max):
        for y in range(1,Max):
            for z in range(1,Max):
                tmp = x**2+y**2+z**2+x*y+y*z+x*z
                if tmp<n:
                    f[tmp] += 1
    for i in range(1,n+1):
        print(f[i])

main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N = int(input())
    x = 1
    y = 1
    z = 0

    for i in range(1,N+1):
        ans = 0
        sn = math.ceil(math.sqrt(i))
        # print(i,sn)
        x = 1
        y = 1
        z = sn - 2
        # print(x,y,z)
        if z <= 0:
            continue
        ans += func(i,x,y,z)
        while z >= math.ceil(sn / 2):
            y += 1
            z -= 1
            # print(x,y,z)
            if x > z or y > z:
                break
            ans += func(i,x,y,z)
            for j in range(y):
                x += 1
                z -= 1
                if x > z or y > z:
                    break
                # print(x,y,z)
                ans += func(i,x,y,z)
        print(ans)
            
def func(n,x,y,z):
    if x**2+y**2+z**2+x*y+y*z+z*x == n:
        if x == y and y == z and z == x:
            return 1
        else:
            return 3
    else:
        return 0

main()

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    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: Wrong Answer

Solution code:
import collections
n=int(input())
lis=[]
lim=int(10000**(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: Wrong Answer

Solution code:
from itertools import combinations_with_replacement

n = int(input())

for i in range(1, n+1):
    ans = 0
    for v in combinations_with_replacement(range(1, 35), 3):        
        x, y, z = v

        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            if x == y == z:
                ans = 1
            else:
                ans = 3
            break

    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N=int(input())
ans=[0]*(10**6)
for x in range(1,N+1):
    if x**2>N:
        break
    for y in range(x,N+1):
        if x**2+y**2>N:
            break
        for z in range(y,N+1):
            if x**2+y**2+z**2>N:
                break
            else:
                kari=[x,y,z]
                #print(kari)
                if x**2+y**2+z**2+x*y+y*z+z*x<=10**5:
                    if len(set(kari))==1:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=1
                    elif len(set(kari))==2:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=3
                    else:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=len(list(permutations(kari,2)))
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())

ans = {}
for v in itertools.combinations_with_replacement(range(1,N//6+1), 3):
    x,y,z = v
    fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if fn > N:
        break
    if fn in ans.keys():
        ans[fn].append([x,y,z])
    else:
        ans[fn] = [[x,y,z]]

for i in range(1,N+1):
    if i in ans.keys():
        x,y,z = ans[i][0]
        if x == y == z:
            print(1)
        else:
            print(len(ans[i]) * 3)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
def func(n):
    cnt = 0
    for x in range(1, 34):
        if(x**2+2*x+3 >= n):
            break
        for y in range(1, int((n-(x**2+x))**0.5)+1):
            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: Wrong Answer

Solution code:
# 幅優先探索（行きがけ）
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
        for j in range(1, math.floor(math.sqrt(i)+1)):
            if j**2 >= i-5:
                break
            for k in range(1, i-j**2+1):
                if j**2+k**2+j*k >= i-3:
                    break
                for l in range(1, i-k**2+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()

Submission status: Wrong Answer

Solution code:
N = int(input())
L=[0]*N
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            f=x**2+y**2+z**2+x*y+y*z+z*x
            if f<=N:
                if x==y==z:
                    L[f-1]=1
                else:
                    L[f-1]=3
for i in range(N):
    print(L[i])

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    f = [0 for i in range(n+1)]
    Max = n**0.5
    Max = int(Max//1) +1 
    for x in range(1,Max):
        for y in range(1,Max):
            for z in range(1,Max):
                tmp = x**2+y**2+z**2+x*y+y*z+x*z
                if tmp<n:
                    f[tmp] += 1
    for i in range(1,n+1):
        print(f[i])

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
if N <= 10**3:
    for i in range(1, N+1):
        ans = 0
        for x in range(1, 13):
            for y in range(1, 13):
                for z in range(1, 13):
                    if (x+y+z)**2-x*y-y*z-z*x == i:
                        ans += 1
        print(ans)
    exit()
else:
    table = [0] * N
    for i in range(1, 10**3):
        ans = 0
        for x in range(1, 14):
            for y in range(1, 14):
                for z in range(1, 14):
                    if (x+y+z)**2-x*y-y*z-z*x == i:
                        ans += 1
        table[i-1] += ans
    print(*table, sep="\n")
    for j in range(10**3, N+1):
        print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,7):
    for y in range(1,7):
      for x in range(1,7):
        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: Wrong Answer

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

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

for l in L:
    print(l)

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())

for i in range(n):
    l = [i+1 for i in range(10)]
    ans = 0
    for v in itertools.combinations_with_replacement(l, 3):
        if v[0]**2 + v[1]**2 + v[2]**2 + v[0]*v[1] + v[1]*v[2] + v[2]*v[0] == i+1:
            if v[0] == v[1] == v[2]:
                ans = 1
            else:
                ans = 3
    print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())

for i in range(1, N+1, 1):
    print(len([[x,y,z] for x in range(1,(i+1)%6,1) for y in range(1,i-x*x,1) for z in range(1,i-x*x-y*y-x*y,1) if x*x+y*y+z*z+x*y+y*z+z*x == i]))

Submission status: Wrong Answer

Solution code:
def f(n):
    cnt = 0
    for x in range(1,6):
        for y in range(1,6):
            for z in range(1,6):
                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: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    ans = [0] * 10 ** 6
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if ans[n - 1] == 0:
                    ans[n - 1] = 6
                elif ans[n - 1] == 6:
                    ans[n - 1] = 3
                elif ans[n - 1] == 3:
                    ans[n - 1] = 1

    squares = [print(i) for i in ans[0 : N]]

                    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
import math
for a in range(1, N+1):
    n = 0
    top = int(math.sqrt(a)/1.15)
    for b in range(1, top):
        for c in range(1, b+1):
            for d in range(1, c+1):
                if (b**2) + (c**2) + (d**2) + (b*c) + (c*d) + (d*b) == a:
                    n += 1
    print(n)

Submission status: Wrong Answer

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

def solve(n):
    ret = {i:[] for i in range(n+1)}
    X=int(n**(1/2) +0.5)+1
    Y=int(n**(1/2) +0.5)+1 
    Z=int(n**(1/2) +0.5)+1
    for x in range(1,X):
        for y in range(1,Y):
            d = x**2+y**2+x*y
            for z in range(1,Z):
                if n <= d+z**2 + y*z + z*x:
                    continue
                ret[d+z**2 + y*z + z*x].append((x,y,z))
    return ret

ret = solve(N)
for i in range(1,N+1):
    print(len(set(ret[i])))

Submission status: Wrong Answer

Solution code:
N = int(input())

def f(n):
    flag = False
    #total = 0
    ans = 0
    i = 131
    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: Wrong Answer

Solution code:
N = int(input())
k = 1
for i in range(1,N+1):
    if i == 6*(k**2):
        print(1)
    elif i == (k+1)**2 + 3 * (k**2) + 2*(k*(k+1)):
        print(3)
    elif i == 3*((k+1)**2) + 2*k*(k+1) + k**2:
        print(3)
        if 3*((k+1)**2) + 2*k*(k+1) + k**2 > (k+2)**2 + 3*k**2 + 2*k*(k+2):
            k += 1
    elif i == (k+2)**2 + 3*k**2 + 2*k*(k+2):
        print(3)
        if 3*((k+1)**2) + 2*k*(k+1) + k**2 < (k+2)**2 + 3*k**2 + 2*k*(k+2):
            k +=1
    else:
        print(0)

Submission status: Wrong Answer

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!=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: Wrong Answer

Solution code:
import math
N=int(input())
for n in range(1,N+1):
    a=n//6+1

    saidai=math.ceil(a**0.5)
    answer=0
    for z in range(1,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement

n = int(input())

for i in range(1, n+1):
    ans = 0
    for v in combinations_with_replacement(range(1, 30), 3):        
        x, y, z = v

        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            if x == y == z:
                ans = 1
            else:
                ans = 3
            break

    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())


for i in range(1, N+1):
    sum = 0

    range_x = int((i-5)**0.5)+1 if i-5 >0 else 0
    flag = False
    for x in range(1, range_x):
        range_y = int((i-x**2-x-3)**0.5)+1 if i-x**2-x-3 > 0 else 0
        for y in range(1, range_y):
            range_z = int((i-x**2-y**2-x*y-x-y)**0.5)+1 if i-x**2-y**2-x*y-x-y > 0 else 0
            for z in range(1, range_z):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    num = len(set([x,y,z]))
                    sum = 6 if num ==3 else 3 if num==2 else 1
                    flag = True
                    break
            if flag:
                break
        if flag:
            break

    print(sum)