Buggy python submission (verdict: Time Limit Exceeded):
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
        upper = 41
        #print("n={}, upper={}".format(n, upper))
        for x in range(1, upper):
            for y in range(1, upper):
                val_y = x**2 + x*y + y**2
                for z in range(1, upper):
                    if val_y + z**2 + x*z + y*z == n:
                        ans += 1
        print(ans)



if __name__ == "__main__":
    main()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
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
        upper = 42
        #print("n={}, upper={}".format(n, upper))
        for x in range(1, upper):
            for y in range(1, upper):
                for z in range(1, upper):
                    if (x + y + z)**2 - (x*y + y*z + z*x) == n:
                        ans += 1
        print(ans)



if __name__ == "__main__":
    main()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
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
        upper = 50
        #print("n={}, upper={}".format(n, upper))
        for x in range(1, upper):
            for y in range(1, upper):
                for z in range(1, upper):
                    if (x + y + z)**2 - (x*y + y*z + z*x) == n:
                        ans += 1
        print(ans)



if __name__ == "__main__":
    main()


Fixed submission:
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()