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:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def checker(n):
    ans = 0
    for a in range(1, 101):
        if a ** 2 + 2 * a > n:
            break
        for b in range(1, 101-a):
            if a * 2 + b * 2 > n:
                break
            _rest = n - a ** 2 - b ** 2
            for c in range(1, 101-a-b):
                if (c + a) * (c + b) == _rest:
                    ans += 1
                    break
                elif (c + a) * (c + b) > _rest:
                    break
    return ans


def main():
    N = int(input().strip())
    for n in range(1, N + 1):
        print(checker(n))
    return


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = []
for n in range(1,N+1):
    result = 0
    for x in range(1,int(n**(1/2))+1):
        if x**2 < n:
            for y in range(1,int(n**(1/2))+1):
                if (x+y)**2-4*((x**2+y**2+x*y) - n) >= 0:
                    z = (-(x+y)+((x+y)**2-4*((x**2+y**2+x*y) - n))**(1/2))/2
                    if (z%1)==0 and z > 0:
                        result += 1
                            
    ans += [result]

print("\n".join(map(str,ans)))

Submission status: Time Limit Exceeded

Solution code:

import math




N=int(input())

anslist=[]
for i in range(1,N+1):
    ans=0
    if i<=5:
        anslist.append(ans)
    else:
        ma=int(math.sqrt(i/2))+1
        for x in range(1,ma):
            for y in range(x,ma):
                for z in range(y,ma):
                    if (x+y+z)**2<i:
                        continue
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        if x==y and y==z:
                            ans+=1
                        elif x==y or y==z or z==x:
                            ans+=3
                        else:
                            ans+=6
                    if 6*(x**2)>i:
                        break
        anslist.append(ans)
            

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

Submission status: Time Limit Exceeded

Solution code:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main(n):
  for s in range(1, n+1):
    ans = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                if i*i + j*j + k*k + i*j + j*k + k*i == s:
                    ans += 1
    print(ans)
    ans = 0
 
if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')
 
    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)
 
    main = cc_export(main, (i8, ))
    cc.compile()
 
from my_module import main
 
N = int(read())
main(N)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt

def readinput():
    n=int(input())
    return n

def main(n):
    f=[0]*n
    for i in range(1,n+1):
        sqrt2n=int(sqrt(2*i))+1
        #print(i,sqrt2n)
        for x in range(1,sqrt2n):
            for y in range(1,sqrt2n-x+1):
                if (x+y)**2>2*i:
                    break
                for z in range(1,sqrt2n-x+1):
                    v=(x+y)**2+(y+z)**2+(z+x)**2
                    if v>2*i:
                        break
                    #print(v)
                    if v==2*i:
                        f[i-1]+=1
                        #print('found')
                        #print(x,y,z,i)
    return f

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    for f in ans:
        print(f)

Submission status: Time Limit Exceeded

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
    s = set()
    for x in range(1, range_x):
        if x in s:
            continue
        range_y = int((i-x**2-x-3)**0.5)+1 if i-x**2-2*x-2 > 0 else 0
        for y in range(1, range_y):
            if y in s:
                continue
            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 z in s:
                    continue
                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
                    s.add(x)
                    s.add(y)
                    s.add(z)
                    break

    print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
c = 0
n = 0
list = []
for l in range(1,N+1):
    list = []
    for i in range(1,N+1):
        for j in range(1,N-i):
            for k in range(1,N-j):
                #print(i,j,k,l)
                if i*i + j*j + k*k + i*j +j*k + i*k > l:
                    break;
                if i*i + j*j + k*k + i*j +j*k + i*k == l:
                    list.append(1)
                    break;
    print(sum(list))

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
n_2 = math.floor((n)**(1/2))
cnt = 0
for n in range(1,n+1):
  cnt = 0
  for x in range(1,n_2 +1):
    for y in range(1, n_2 +1):
      for z in range(1, n_2 +1):
        if x+y+z == ((n + x*y + y*z + z*x)**(1/2)):
          cnt +=1
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = [0]*N
for i in range(N):
    for j in range(N):
        for k in range(N):
            a = (i+1)**2 + (j+1)**2 + (k+1)**2 + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1)
            if a > N:
                break
            l[a-1] = l[a-1] + 1

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
from math import sqrt
for k in range(1,n+1):

    ans=0
    for x in range(1,101):
        for y in range(1,101):
            p=k-x**2 - y**2 - x*y
            if p<=0:
                break
            for z in range(1,int(sqrt(p))+1):
                if z*(z+x+y)==p:
                    ans+=1

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

for ans in range(1,N+1):
	cnt=0
	for i in range(1,(N//2)//2):
		for j in range(1,(N//2)//2):
			for k in range(1,(N//2)//2):
				if i**2+j**2+k**2+i*j+j*k+k*i == ans:
					cnt+=1
	print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
f = [0] * N
n = list(range(1,N+1))
for i in range(N):
    n[i] = math.ceil(math.sqrt(n[i]))

for i in range(1,N+1):
    for x in range(1,n[i-1]):
        if(x*x > i):
            break 
        for y in range(x,n[i-1]):
            if(x*x+y*y+x*y > i):
                break
            for z in range(y,n[i-1]):
                if(x*x+y*y+z*z+x*y+y*z+z*x == i):
                    if(x == y and y == z) :
                        f[i-1] += 1
                    elif(x == y and y < z):
                        f[i-1] += 3
                    elif(x < y and y == z):
                        f[i-1] += 3
                    else:
                        f[i-1] += 6


[print(a) for a in f]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for i in range(1,N+1):
  ans = 0
  if i < 6:
    print(0)
  else:
    total = 11
    if i > total/2:
      for a in range(2,N+1):
        for b in range(2,N+1):
          for c in range(2,N+1):
            total = a**2 + b**2 +c**2
            if total == 2*i:
              if max(a,b,c) < a+b+c-max(a,b,c):
                if len({a,b,c}) == 1:
                  ans = 1
                  continue
                elif len({a,b,c}) == 2:
                  ans = 3
                  continue
                else:
                  ans = 6
                  continue
    else:
      ans = 0

              #print(a,b,c)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
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
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

for i in range(n):
    s = 0
    for x in range(1, n+1):
        if f(x,1,1) > i+1:
            print(s)
            break
        else:
            for y in range(1, x+1):
                if f(x,y,1) > i+1:
                    break
                else:
                    for z in range(1, y+1):
                        if f(x,y,z) == i+1:
                            if x == y == z:
                                s += 1
                            elif x == y or y == z:
                                s += 3
                            else:
                                s += 6

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for i in range(1,N+1):
    count=0
    for x in range(1,int(math.sqrt(i))):
        for y in range(1,x+1):
            for z in range(1,y+1):
                if x*x+y*y+z*z+x*y+y*z+z*x==i:
                    if x==y and y==z:
                        count+=1
                    elif (x==y and x!=z) or (y==z and y!=x):
                        count+=3
                    else:
                        count+=6
    print(count)

Submission status: Time Limit Exceeded

Solution code:
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, 20):
        for y in range(1, 20):
             D = (((x+y)**2 - 4*(x**2+y**2+x*y-i)) ** (1/2))
             if ((x+y)**2 - 4*(x**2+y**2+x*y-i)) > 0 :
                 Z = (-(x+y) + D) / 2
                 if is_integer(Z) and Z>0:
                     cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
 
for i in range (1,n+1):
  ans=0
  for x in range(1,int(i*1/3)):
   for y in range(1,int(i*1/3)):
    for z in range(1,int(i*1/3)):
     if x+y+z==math.sqrt(i+x*y+x*z+y*z):
       ans+=1
       if x==y and y==z:
        break
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import numpy as np
#max=int(np.sqrt(N))

for n in range(1,N+1):
    j=0
    min = 1
    max = int(np.sqrt(abs(n-2)))
    #print(max)
    for x in range(min,max):
        #print(f'max:{max}')
        for y in range(min, max):
            for z in range(min, max):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > n:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x == y == z:
                        max=x
                        min=x
                        j += 1
                        break
                    if j==0:
                        max = z+1
                        min += 1
                        #min = x
                        #print(x, y, z)
                        #print(f'n:{n}')
                        j += 3
                    # else:
                    #     j += 3

    print(j)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

def f_count(j):
    count=0
    for x in range(1,j):
        for y in range(1,j):
            rt=(x+y)**2-4*(x**2+y**2+x*y-j)
            z=(-(x+y)+rt**0.5)/2

            if rt>=0 and (-(x+y)+rt**0.5)%2==0:
                if int(z)>=1:
                    count+=1

            
           
    return count
    
for i in range(1,n+1):
    print(f_count(i))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

N=int(input())
for i in range(1,N+1):
  cnt=0
  listx=list(range(1,i-2))
  for x in listx:
    for y in range(1,i-x+1):
      for z in range(1,i-x-y+1):
        if i==x**2+y**2+z**2+x*y+y*z+z*x:
          cnt+=1
  print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

N=int(input())

for n in range(1,N+1):#O(N^2)
    ans=0#ansを初期化
    l=[i for i in range(1,n+1)]
    tmp=[c for c in itertools.combinations_with_replacement(l, 3) if c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[1]*c[2] + c[2]*c[0] == n]
    #print(tmp)
    for c in tmp:
        if  c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[1]*c[2] + c[2]*c[0] == n:
            if c[0] == c[1] == c[2]:
                ans+=1
            elif c[0] != c[1] & c[1] != c[2] & c[2] != c[0]:
                ans+=6
            else:
                ans+=3
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

def count(n):
    ans=0
    for x in range(1, n):
        if 6*(x**2)>n:
            break
        for z in range(x, n):
            for y in range(x, z+1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x > n:
                    break
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if x==y and y==z:
                        ans+=1
                    elif x!=y and y!=z and z!=x:
                        ans+=6
                    else:
                        ans+=3
    return ans

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

Submission status: Time Limit Exceeded

Solution code:
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, 30):
        for y in range(1, 30):
             D = (((x+y)**2 - 4*(x**2+y**2+x*y-i)) ** (1/2))
             if ((x+y)**2 - 4*(x**2+y**2+x*y-i)) > 0 :
                 Z = (-(x+y) + D) / 2
                 if is_integer(Z) and Z>0:
                     cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
mylist = [int(math.sqrt(i)) for i in range(1,n+1)]

def main():
    for N in range(1,n+1):
        result = 0
        for x in range(1,mylist[N-1]+1):
            tempx = x**2
            for y in range(x, mylist[N-x**2]+1):
                tempy = y**2
                tempxy = x*y
                if N-tempx-tempy-tempxy < 0:
                    break
                else:
                    for z in range(y, mylist[N-tempx-tempy-tempxy]+1):
                        if tempx + tempy + z**2 + tempxy + y*z + z*x == N:
                            if x != y and y != z:
                                result += 6
                            elif x == y and y == z:
                                result += 1
                            else:
                                result += 3
                        elif tempx + tempy + z**2 + tempxy + y*z + z*x > N:
                            break
        print(result)
main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for n in range(1, N+1):
  for x in range(1, 10**2):
    for z in range(1, 10**2):
      answer = 0
      if 3* x**2 + z**2 + 2*x*z == n:
        num_pair = [x, z]
        if num_pair[0] == num_pair[1]:
          answer = 1
          break
        else:
          answer = 3
          break
    if answer != 0:
      break
    

  print(answer)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def fk3(k_):
    fk3=0
    x=1
    while(x<N):
        y=x+1
        while(y<N):
            z=y+1
            while(z<N):
                if(x**2+y**2+z**2+x*y+y*z+z*x==k_):
                    fk3+=1
                z+=1
            y+=1
        x+=1
    return fk3

def fk2yd(k_):
    fk2yd=0
    x=1
    while(x<N):
        y=x+1
        while(y<N):
            if(x**2+3*y**2+2*x*y==k_):
                fk2yd+=1
            y+=1
        x+=1
    return fk2yd
  
def fk2ys(k_):
    fk2ys=0
    y=1
    while(y<N):
        x=y+1
        while(x<N):
            if(x**2+3*y**2+2*x*y==k_):
                fk2ys+=1
            x+=1
        y+=1
    return fk2ys

def fk1(k_):
    fk1=0
    x=1
    while(x<N):
        if(6*x**2==k_):
            fk1+=1
            break
        x+=1
    return fk1

k=1
while(k<=N):
    fk=fk1(k)+3*(fk2yd(k)+fk2ys(k))+6*fk3(k)
    print(fk)
    k+=1

Submission status: Time Limit Exceeded

Solution code:
import math
f = int(input())
for n in range(1,f+1):
	try:
		l = int(-1+math.sqrt(-2+n)+0.999)
	except:
		print(0)
		continue
	e = 0
	p = []
	for x in range(1,l+1):
		for y in range(1,x+1):
			try:
				q = (-(x+y)+math.sqrt((x+y)**2-4*(x**2+y**2+x*y-n)))/2
				if q==int(q) and q > 0 and (x+y+q) not in p:
					if q == x and q == y:
						e += 1
						p.append(x+y+q)
					else:
						e += 3
						p.append(x+y+q)
			except:
				pass
	print(e)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for m in range(1, n+1):
    cnt = 0
    for i in range(1, int(n**0.5)+2):
        a = n - i**2
        if a >= 1:
            for j in range(1, int(a**0.5) + 2):
                b = n - i**2 - j**2
                if b >= 1:
                    for k in range(1, int(b**0.5) + 2):
                        if i**2 + j**2 + k**2 + i*j + j*k + k*i == m:
                            cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

tmp_list = [0] * (N + 1)
X = N
Y = N
Z = N
for x in range(1, X + 1):
    for y in range(1, Y + 1):
        for z in range(1, Z + 1):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if(tmp > N):
                break
            else:
                tmp_list[tmp] += 1

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

Submission status: Time Limit Exceeded

Solution code:
#C - XYZ Triplets
N = int(input())
ans = 0
for l in range(N):
    ans = 0
    for i in range(int((l+1)**0.5)):
        for j in range(i,int((l+1)**0.5)-i):
            # a = (i+1)+(j+1)
            # b = (i+1)*(j+1)
            # if (i + 1) ** 2 + (j + 1) ** 2 + (k + 1) ** 2 + (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (
            #         i + 1) == l + 1:
            for k in range(j,int((l+1)**0.5)-i-j):
                if (i+1)**2 + (j+1)**2 + (k+1)**2 +(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)== l+1:
                    if i == j == k:
                        ans = 1
                        break
                    elif (i == j and j !=k) or (k == j and i !=k):
                        ans = 3
                        break
                    else:
                        ans = 6
                        break
        if ans > 0:
            break

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())

for n_m in range(N):
    n = n_m + 1
    
    if n < 6:
        print(0)
    elif n == 6:
        print(1)
        
    elif n < 11:
        print(0)
        
    elif n == 11:
        print(3)
    
    elif n < 17:
        print(0)
    
    elif n == 17:
        print(3)
        
    elif n == 18:
        print(3)
    
    elif n <= 20:
        print(0)
    
    else:
        
        result = 0
        
        
        lim_n = int(np.sqrt(n)) + 1
        
        done_list = []
        for x in range(1, lim_n):
            
            lim_n_y = int(np.sqrt(n-x**2))+1
            for y in range(x, lim_n_y):
                lim_n_z = int(np.sqrt(n - y**2 - x ** 2))+1
                for z in range(y, lim_n):
                    
                    if x**2 + y**2 + z**2 + (x+y+z)**2 == 2*n:
                        
                        set_res = len(list(set([x,y,z])))
                        if  set_res == 1:
                            result += 1
                        elif set_res == 2:
                            result += 3
                        else:
                            result += 1
                            
                            
        print(result)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())

for i in range(1, n+1):
    if 9441 < i < 9600:
        print(0)
        continue
    if i > 9600:
        print(0)
        continue
    tmp = 0
    for j in itertools.combinations_with_replacement(range(1, 41), 3):
        x, y, z = j
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            if x == y == z:
                tmp += 1
            elif x != y != z:
                tmp += 6
            else:
                tmp += 3
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
cnt = 0
number = 1

while number <= N:
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in range(1,N+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == number:
                    cnt += 1
                else:
                    continue
    print(cnt)
    cnt = 0
    number += 1

Submission status: Time Limit Exceeded

Solution code:
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, 45):
        for y in range(1, 45):
             D = (((x+y)**2 - 4*(x**2+y**2+x*y-i)) ** (1/2))
             if ((x+y)**2 - 4*(x**2+y**2+x*y-i)) > 0 :
                 Z = (-(x+y) + D) / 2
                 if is_integer(Z) and Z>0:
                     cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

def f(n):
  count = 0
  for x, y, z in itertools.combinations_with_replacement(range(1, n), 3):
    if (x == y == z):
      if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
        count += 1
    else:
      if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
        count += 3
  return count

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
limit = int(n**0.5)
for i in range(n):
    cnt = 0
    for x in range(1,limit):
        for y in range(1,limit):
            b = x + y
            c = x**2+y**2+x*y-i-1
            buf = b**2-4*c
            if buf >= 0:
                ans = [-b + math.sqrt(buf), -b - math.sqrt(buf)]
                for z in ans:
                    if z.is_integer() and z > 0:
                        cnt += 1
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import numpy as np
#max=int(np.sqrt(N))

for n in range(1,N+1):
    j=0
    min = 1
    max = int(np.sqrt(abs(n-2)))
    #print(max)
    for x in range(min,max):
        #print(f'max:{max}')
        for y in range(min, max):
            for z in range(min, max):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > n:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x == y == z:
                        j += 1
                        break
        #     else:
        #         continue
        #     break
        # else:
        #     continue
        # break
                    if j==0:
                        max = z+1
                        min += 1
                        #min = x
                        #print(x, y, z)
                        #print(f'n:{n}')
                        j += 3
                    # else:
                    #     j += 3

    print(j)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
count = [0]*n
for i in range(1,n+1):
    for x in range(1,int(n**0.5)+1):
        for y in range(1,int(n**0.5)+1):
            b = x + y
            c = x*x + y*y + x*y - i
            if b**2 >= 4*c and ((-b + math.sqrt(b**2-4*c))/2).is_integer() == True and (-b + math.sqrt(b**2-4*c))/2 >= 1:
                    count[i-1] += 1
    print(count[i-1])

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
x = 1
y = 1
z = 1
import math
listN = []
while x<=98:
    y =1
    z =1
    while y<=-x+math.sqrt(-8*(x**2)+120000):
        if x**2+y**2+1+x+y+1<=10000:
            z =1
            while z <= -x/2-y/2+math.sqrt(-3*(x**2+y**2)-2*x*y+360000)/2:
                ans = x**2+y**2+z**2+x*y+y*z+z*x
                if ans<=10000:
                    listN.append(ans)
                    z = z+1
                else:
                    break
            y = y+1
        else:
            break
    x = x+1
n = 1
while n<=a:
    print(listN.count(n))
    n = n+1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, n+1):
    s = {}
    ans = 0
    for x in range(1, int(i/3)):
        for y in range(x, int(i/3)):
            judge = -3*x**2 -3*y**2 - 2*x*y + 4*i
            if  judge >= 0:
                if ((-x -y)+(judge)**(1/2))%2 == 0 and ((-x -y)+(judge)**(1/2))/2 >= y:
                    s = {x, y, int(((-x -y)+(judge)**(1/2))/2)}
                    if len(s) == 1:
                        ans += 1
                    elif len(s) == 2:
                        ans += 3
                    elif len(s) ==3:
                        ans += 6
   
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
def f(n):
    count=0
    for x in range(1,int(math.sqrt(n))):
        for y in range(1,x+1):
            for z in range(1,y+1):
                if x*x+y*y+z*z+x*y+y*z+z*x==n:
                    if x==y and y==z:
                        count+=1
                    elif (x==y and x!=z) or (y==z and y!=x):
                        count+=3
                    else:
                        count+=6
    print(count)

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

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


list_g_xyz = []
list_f_n = []
N2 = int(N ** (1 /2) / 2) + 1

for x in range(1, N2 + 1):
    break_flg = False
    for y in range(x, N2 + 1):
        for z in range(y, N2 + 1):
            g_xyz = g(x, y, z)
            f_n = len(set(["".join(map(str, v)) for v in itertools.permutations([x, y, z])]))
            list_g_xyz.append(g_xyz)
            list_f_n.append(f_n)
            # print(f'x, y, z = {x}, {y}, {z},  g(x, y, z) = {g_xyz},  f(n) = {f_n}')

            if g_xyz > N:
                break_flg = True
            if break_flg:
                break
        if break_flg:
            break
            
            
list_ans = []
for target in range(1, N + 1):
    list_index = [i for i, x in enumerate(list_g_xyz) if x == target]
    ans = sum([list_f_n[i] for i in list_index])
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def sqe(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)

    return x_1
  
for i in range(1,n+1):
  cnt = 0
  for x in range(1,100):
    if n-x**2<=0:
      break
    for y in range(1,int((n-x*2)**0.5)+1):
      if x**2+y**2+x*y>i:
        break
      x_1 = sqe(1,x+y,x**2+y**2+x*y-i)
      if x_1.is_integer() and x_1>0:
        cnt += 1
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    x , y , z = 1,1,1
    count = 0
    for i in range(N):
        n = i+1

        while True: # X
            while True: # Y
                while True: # Z
                    calc = x**2 +  y**2 + z**2 + x*y + y*z + z*x
                    if calc > n:
                        break
                    elif calc == n:
                        count += 1
                        break
                    elif calc < n:
                        z += 1

                y += 1
                z = 1
                if x**2 +  y**2 + z**2 + x*y + y*z + z*x > n:
                    break 

            x += 1
            y,z = 1, 1
            
            if x**2 +  y**2 + z**2 + x*y + y*z + z*x > n:
                print(count)
                x, y, z = 1,1,1
                count = 0
                break
        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    N = int(input())
    ans = [0]*(N+1)

    end = N

    for i in range(3,end+1):
        sn = i
        x = 1
        y = 1
        z = sn - 2
        zt = z
        if(cal(x,y,z) < N):
            ans[cal(x,y,z)] += func(x,y,z)
        while True:
            x = 1
            z = zt
            y += 1
            z -= 1
            zt = z
            if x > z or y > z:
                break
            if(cal(x,y,z) < N):
                ans[cal(x,y,z)] += func(x,y,z)
            for j in range(y - 1):
                if y < x + 1:
                    break
                x += 1
                z -= 1
                if x > z or y > z:
                    break
                if(cal(x,y,z) < N):
                    ans[cal(x,y,z)] += func(x,y,z)
    
    for i in range(1,N+1):
        print(ans[i])
        

def func(x,y,z):
    # print(x,y,z)
    if x == y and y == z and z == x:
        return 1
    elif x != y and y != z and z != x:
        return 6
    else:
        return 3

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

main()

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools

def get_match(n):
    a = range(1, int(math.sqrt(n)) + 1)
    combi = list(itertools.product(a, a, a))

    cnt = 0
    for x, y, z in combi:
        if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
            cnt += 1
    return cnt

in_1 = input()
N = int(in_1)

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