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:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

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

def main():
    N = I()
    ans = 1
    X = 0
    Y = 0
    Z = 0
    XYZ = 0
    arr = []
    C = 6000
    dic = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 7: 0, 8: 0, 9: 0, 10: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0, 26: 0, 28: 0, 29: 0, 30: 0, 31: 0, 32: 0, 36: 0, 37: 0, 39: 0, 40: 0, 41: 0, 42: 0, 46: 0, 48: 0, 49: 0, 50: 0, 52: 0, 53: 0, 56: 0, 59: 0, 60: 0, 62: 0, 63: 0, 64: 0, 65: 0, 70: 0, 74: 0, 75: 0, 76: 0, 78: 0, 79: 0, 80: 0, 84: 0, 88: 0, 91: 0, 92: 0, 93: 0, 94: 0, 98: 0, 101: 0, 104: 0, 106: 0, 107: 0, 110: 0, 111: 0, 112: 0, 116: 0, 120: 0, 124: 0, 126: 0, 127: 0, 128: 0, 134: 0, 138: 0, 142: 0, 144: 0, 148: 0, 149: 0, 155: 0, 156: 0, 158: 0, 160: 0, 164: 0, 165: 0, 167: 0, 168: 0, 170: 0, 174: 0, 182: 0, 184: 0, 186: 0, 189: 0, 190: 0, 192: 0, 196: 0, 200: 0, 206: 0, 208: 0, 211: 0, 212: 0, 221: 0, 222: 0, 224: 0, 226: 0, 230: 0, 231: 0, 236: 0, 238: 0, 239: 0, 240: 0, 248: 0, 252: 0, 254: 0, 256: 0, 259: 0, 260: 0, 270: 0, 280: 0, 282: 0, 286: 0, 290: 0, 296: 0, 300: 0, 302: 0, 304: 0, 305: 0, 309: 0, 312: 0, 314: 0, 316: 0, 317: 0, 318: 0, 320: 0, 334: 0, 336: 0, 338: 0, 341: 0, 350: 0, 351: 0, 352: 0, 364: 0, 366: 0, 368: 0, 371: 0, 372: 0, 376: 0, 381: 0, 382: 0, 392: 0, 398: 0, 399: 0, 401: 0, 404: 0, 406: 0, 410: 0, 413: 0, 414: 0, 416: 0, 424: 0, 428: 0, 430: 0, 440: 0, 444: 0, 446: 0, 448: 0, 462: 0, 464: 0, 469: 0, 470: 0, 478: 0, 479: 0, 480: 0, 494: 0, 496: 0, 504: 0, 508: 0, 510: 0, 512: 0, 518: 0, 526: 0, 530: 0, 536: 0, 541: 0, 542: 0, 546: 0, 552: 0, 554: 0, 558: 0, 568: 0, 574: 0, 576: 0, 589: 0, 590: 0, 592: 0, 596: 0, 606: 0, 614: 0, 620: 0, 622: 0, 623: 0, 624: 0, 629: 0, 632: 0, 638: 0, 640: 0, 654: 0, 656: 0, 659: 0, 660: 0, 668: 0, 669: 0, 670: 0, 672: 0, 680: 0, 686: 0, 696: 0, 702: 0, 714: 0, 718: 0, 721: 0, 728: 0, 734: 0, 736: 0, 744: 0, 746: 0, 750: 0, 756: 0, 758: 0, 760: 0, 766: 0, 767: 0, 768: 0, 782: 0, 784: 0, 794: 0, 798: 0, 800: 0, 814: 0, 824: 0, 830: 0, 832: 0, 844: 0, 846: 0, 848: 0, 862: 0, 870: 0, 878: 0, 884: 0, 888: 0, 890: 0, 894: 0, 896: 0, 904: 0, 905: 0, 910: 0, 920: 0, 924: 0, 926: 0, 942: 0, 944: 0, 952: 0, 956: 0, 958: 0, 960: 0, 974: 0, 986: 0, 990: 0, 992: 0, 1001: 0, 1006: 0, 1008: 0, 1016: 0, 1022: 0, 1024: 0, 1031: 0, 1036: 0, 1038: 0, 1040: 0, 1047: 0, 1054: 0, 1070: 0, 1080: 0, 1082: 0, 1086: 0, 1094: 0, 1102: 0, 1106: 0, 1110: 0, 1115: 0, 1118: 0, 1120: 0, 1128: 0, 1134: 0, 1144: 0, 1150: 0, 1160: 0, 1166: 0, 1182: 0, 1184: 0, 1194: 0, 1198: 0, 1200: 0, 1208: 0, 1214: 0, 1216: 0, 1220: 0, 1230: 0, 1236: 0, 1246: 0, 1248: 0, 1256: 0, 1262: 0, 1264: 0, 1268: 0, 1272: 0, 1278: 0, 1280: 0, 1286: 0, 1294: 0, 1310: 0, 1326: 0, 1336: 0, 1342: 0, 1344: 0, 1352: 0, 1358: 0, 1364: 0, 1374: 0, 1390: 0, 1397: 0, 1400: 0, 1404: 0, 1406: 0, 1408: 0, 1409: 0, 1418: 0, 1422: 0, 1438: 0, 1439: 0, 1454: 0, 1456: 0, 1464: 0, 1470: 0, 1472: 0, 1484: 0, 1486: 0, 1488: 0, 1502: 0, 1504: 0, 1518: 0, 1524: 0, 1526: 0, 1528: 0, 1534: 0, 1550: 0, 1566: 0, 1568: 0, 1582: 0, 1586: 0, 1590: 0, 1592: 0, 1596: 0, 1598: 0, 1604: 0, 1614: 0, 1616: 0, 1624: 0, 1630: 0, 1640: 0, 1646: 0, 1652: 0, 1656: 0, 1662: 0, 1664: 0, 1678: 0, 1694: 0, 1696: 0, 1710: 0, 1712: 0, 1718: 0, 1720: 0, 1726: 0, 1742: 0, 1751: 0, 1758: 0, 1760: 0, 1774: 0, 1776: 0, 1784: 0, 1790: 0, 1792: 0, 1794: 0, 1806: 0, 1822: 0, 1838: 0, 1848: 0, 1850: 0, 1854: 0, 1856: 0, 1870: 0, 1876: 0, 1880: 0, 1886: 0, 1902: 0, 1912: 0, 1916: 0, 1918: 0, 1920: 0, 1934: 0, 1950: 0, 1966: 0, 1976: 0, 1982: 0, 1984: 0, 1991: 0, 1998: 0, 2014: 0, 2016: 0, 2030: 0, 2032: 0, 2040: 0, 2046: 0, 2048: 0, 2062: 0, 2072: 0, 2078: 0, 2094: 0, 2104: 0, 2110: 0, 2120: 0, 2126: 0, 2142: 0, 2144: 0, 2158: 0, 2164: 0, 2168: 0, 2174: 0, 2184: 0, 2190: 0, 2198: 0, 2206: 0, 2208: 0, 2210: 0, 2216: 0, 2222: 0, 2232: 0, 2238: 0, 2254: 0, 2262: 0, 2270: 0, 2272: 0, 2286: 0, 2296: 0, 2298: 0, 2302: 0, 2304: 0, 2318: 0, 2334: 0, 2350: 0, 2356: 0, 2360: 0, 2366: 0, 2368: 0, 2382: 0, 2384: 0, 2398: 0, 2414: 0, 2424: 0, 2430: 0, 2446: 0, 2456: 0, 2459: 0, 2462: 0, 2478: 0, 2480: 0, 2488: 0, 2492: 0, 2494: 0, 2496: 0, 2510: 0, 2516: 0, 2526: 0, 2528: 0, 2534: 0, 2542: 0, 2543: 0, 2552: 0, 2558: 0, 2560: 0, 2574: 0, 2590: 0, 2594: 0, 2606: 0, 2616: 0, 2622: 0, 2624: 0, 2636: 0, 2638: 0, 2640: 0, 2654: 0, 2670: 0, 2672: 0, 2676: 0, 2680: 0, 2686: 0, 2688: 0, 2702: 0, 2718: 0, 2720: 0, 2734: 0, 2744: 0, 2750: 0, 2766: 0, 2774: 0, 2782: 0, 2784: 0, 2798: 0, 2808: 0, 2814: 0, 2830: 0, 2846: 0, 2856: 0, 2862: 0, 2872: 0, 2878: 0, 2884: 0, 2894: 0, 2910: 0, 2912: 0, 2926: 0, 2936: 0, 2942: 0, 2944: 0, 2958: 0, 2974: 0, 2976: 0, 2984: 0, 2990: 0, 3000: 0, 3006: 0, 3022: 0, 3024: 0, 3032: 0, 3038: 0, 3040: 0, 3054: 0, 3064: 0, 3068: 0, 3070: 0, 3072: 0, 3086: 0, 3102: 0, 3110: 0, 3118: 0, 3128: 0, 3134: 0, 3136: 0, 3150: 0, 3166: 0, 3176: 0, 3182: 0, 3192: 0, 3198: 0, 3200: 0, 3206: 0, 3214: 0, 3230: 0, 3242: 0, 3246: 0, 3256: 0, 3262: 0, 3266: 0, 3278: 0, 3294: 0, 3296: 0, 3310: 0, 3320: 0, 3326: 0, 3328: 0, 3342: 0, 3358: 0, 3374: 0, 3376: 0, 3384: 0, 3390: 0, 3392: 0, 3406: 0, 3422: 0, 3438: 0, 3448: 0, 3454: 0, 3470: 0, 3480: 0, 3486: 0, 3502: 0, 3512: 0, 3518: 0, 3534: 0, 3536: 0, 3550: 0, 3552: 0, 3560: 0, 3566: 0, 3576: 0, 3582: 0, 3584: 0, 3598: 0, 3614: 0, 3616: 0, 3620: 0, 3630: 0, 3640: 0, 3646: 0, 3662: 0, 3678: 0, 3680: 0, 3694: 0, 3696: 0, 3704: 0, 3710: 0, 3726: 0, 3742: 0, 3758: 0, 3768: 0, 3774: 0, 3776: 0, 3790: 0, 3806: 0, 3808: 0, 3822: 0, 3824: 0, 3832: 0, 3838: 0, 3840: 0, 3854: 0, 3870: 0, 3886: 0, 3896: 0, 3902: 0, 3918: 0, 3926: 0, 3934: 0, 3944: 0, 3950: 0, 3960: 0, 3966: 0, 3968: 0, 3982: 0, 3998: 0, 4004: 0, 4014: 0, 4024: 0, 4026: 0, 4030: 0, 4032: 0, 4046: 0, 4062: 0, 4064: 0, 4078: 0, 4088: 0, 4094: 0, 4096: 0, 4110: 0, 4124: 0, 4126: 0, 4134: 0, 4142: 0, 4144: 0, 4152: 0, 4158: 0, 4160: 0, 4174: 0, 4188: 0, 4190: 0, 4206: 0, 4216: 0, 4222: 0, 4238: 0, 4254: 0, 4270: 0, 4280: 0, 4286: 0, 4302: 0, 4318: 0, 4320: 0, 4328: 0, 4334: 0, 4344: 0, 4350: 0, 4355: 0, 4366: 0, 4376: 0, 4382: 0, 4398: 0, 4408: 0, 4414: 0, 4424: 0, 4430: 0, 4440: 0, 4446: 0, 4460: 0, 4462: 0, 4472: 0, 4478: 0, 4480: 0, 4494: 0, 4510: 0, 4512: 0, 4526: 0, 4536: 0, 4542: 0, 4558: 0, 4574: 0, 4576: 0, 4590: 0, 4600: 0, 4606: 0, 4622: 0, 4638: 0, 4640: 0, 4654: 0, 4664: 0, 4670: 0, 4686: 0, 4702: 0, 4718: 0, 4728: 0, 4734: 0, 4736: 0, 4750: 0, 4766: 0, 4776: 0, 4782: 0, 4792: 0, 4798: 0, 4800: 0, 4814: 0, 4830: 0, 4832: 0, 4846: 0, 4856: 0, 4862: 0, 4864: 0, 4878: 0, 4880: 0, 4894: 0, 4910: 0, 4920: 0, 4926: 0, 4942: 0, 4944: 0, 4958: 0, 4974: 0, 4984: 0, 4990: 0, 4992: 0, 5006: 0, 5022: 0, 5024: 0, 5030: 0, 5038: 0, 5048: 0, 5054: 0, 5056: 0, 5070: 0, 5072: 0, 5086: 0, 5088: 0, 5102: 0, 5112: 0, 5118: 0, 5120: 0, 5134: 0, 5144: 0, 5150: 0, 5166: 0, 5176: 0, 5182: 0, 5198: 0, 5210: 0, 5214: 0, 5230: 0, 5240: 0, 5246: 0, 5262: 0, 5278: 0, 5294: 0, 5304: 0, 5310: 0, 5326: 0, 5342: 0, 5344: 0, 5358: 0, 5368: 0, 5374: 0, 5376: 0, 5390: 0, 5406: 0, 5408: 0, 5422: 0, 5432: 0, 5438: 0, 5454: 0, 5456: 0, 5470: 0, 5474: 0, 5486: 0, 5496: 0, 5502: 0, 5518: 0, 5534: 0, 5550: 0, 5560: 0, 5566: 0, 5582: 0, 5588: 0, 5594: 0, 5598: 0, 5600: 0, 5614: 0, 5616: 0, 5624: 0, 5630: 0, 5632: 0, 5636: 0, 5646: 0, 5662: 0, 5672: 0, 5678: 0, 5688: 0, 5694: 0, 5710: 0, 5726: 0, 5742: 0, 5752: 0, 5756: 0, 5758: 0, 5774: 0, 5790: 0, 5806: 0, 5816: 0, 5822: 0, 5824: 0, 5838: 0, 5854: 0, 5856: 0, 5870: 0, 5880: 0, 5886: 0, 5888: 0, 5894: 0, 5902: 0, 5909: 0, 5918: 0, 5934: 0, 5936: 0, 5944: 0, 5950: 0, 5952: 0, 5966: 0, 5969: 0, 5982: 0, 5998: 0, 6008: 0, 6014: 0, 6016: 0, 6030: 0, 6046: 0, 6062: 0, 6072: 0, 6078: 0, 6094: 0, 6096: 0, 6104: 0, 6110: 0, 6112: 0, 6126: 0, 6136: 0, 6142: 0, 6158: 0, 6174: 0, 6190: 0, 6200: 0, 6206: 0, 6222: 0, 6238: 0, 6254: 0, 6264: 0, 6270: 0, 6272: 0, 6286: 0, 6302: 0, 6318: 0, 6328: 0, 6334: 0, 6344: 0, 6350: 0, 6360: 0, 6366: 0, 6368: 0, 6382: 0, 6384: 0, 6392: 0, 6398: 0, 6414: 0, 6416: 0, 6430: 0, 6446: 0, 6456: 0, 6462: 0, 6464: 0, 6478: 0, 6494: 0, 6496: 0, 6510: 0, 6518: 0, 6520: 0, 6526: 0, 6542: 0, 6558: 0, 6560: 0, 6574: 0, 6584: 0, 6590: 0, 6606: 0, 6608: 0, 6622: 0, 6624: 0, 6638: 0, 6648: 0, 6654: 0, 6656: 0, 6670: 0, 6686: 0, 6702: 0, 6710: 0, 6712: 0, 6718: 0, 6734: 0, 6750: 0, 6766: 0, 6776: 0, 6782: 0, 6784: 0, 6794: 0, 6798: 0, 6814: 0, 6830: 0, 6840: 0, 6846: 0, 6848: 0, 6862: 0, 6872: 0, 6878: 0, 6880: 0, 6894: 0, 6904: 0, 6910: 0, 6926: 0, 6942: 0, 6958: 0, 6968: 0, 6974: 0, 6990: 0, 7004: 0, 7006: 0, 7022: 0, 7032: 0, 7038: 0, 7040: 0, 7054: 0, 7070: 0, 7086: 0, 7096: 0, 7102: 0, 7104: 0, 7118: 0, 7134: 0, 7136: 0, 7150: 0, 7160: 0, 7166: 0, 7168: 0, 7176: 0, 7182: 0, 7198: 0, 7214: 0, 7224: 0, 7230: 0, 7246: 0, 7262: 0, 7278: 0, 7288: 0, 7294: 0, 7310: 0, 7326: 0, 7342: 0, 7352: 0, 7358: 0, 7374: 0, 7390: 0, 7392: 0, 7400: 0, 7406: 0, 7416: 0, 7422: 0, 7424: 0, 7438: 0, 7454: 0, 7470: 0, 7480: 0, 7486: 0, 7502: 0, 7504: 0, 7518: 0, 7520: 0, 7526: 0, 7534: 0, 7544: 0, 7550: 0, 7566: 0, 7582: 0, 7598: 0, 7608: 0, 7614: 0, 7630: 0, 7646: 0, 7648: 0, 7662: 0, 7664: 0, 7672: 0, 7678: 0, 7680: 0, 7694: 0, 7710: 0, 7726: 0, 7736: 0, 7742: 0, 7758: 0, 7774: 0, 7790: 0, 7800: 0, 7806: 0, 7822: 0, 7838: 0, 7854: 0, 7864: 0, 7870: 0, 7886: 0, 7902: 0, 7904: 0, 7918: 0, 7928: 0, 7934: 0, 7936: 0, 7950: 0, 7964: 0, 7966: 0, 7982: 0, 7992: 0, 7998: 0, 8014: 0, 8030: 0, 8046: 0, 8056: 0, 8062: 0, 8064: 0, 8078: 0, 8094: 0, 8110: 0, 8120: 0, 8126: 0, 8128: 0, 8142: 0, 8158: 0, 8160: 0, 8174: 0, 8184: 0, 8190: 0, 8192: 0, 8206: 0, 8222: 0, 8238: 0, 8248: 0, 8254: 0, 8270: 0, 8286: 0, 8288: 0, 8302: 0, 8312: 0, 8318: 0, 8334: 0, 8350: 0, 8366: 0, 8376: 0, 8382: 0, 8398: 0, 8414: 0, 8416: 0, 8430: 0, 8440: 0, 8446: 0, 8462: 0, 8478: 0, 8480: 0, 8494: 0, 8504: 0, 8510: 0, 8526: 0, 8542: 0, 8558: 0, 8568: 0, 8574: 0, 8576: 0, 8590: 0, 8606: 0, 8622: 0, 8632: 0, 8638: 0, 8654: 0, 8656: 0, 8670: 0, 8672: 0, 8686: 0, 8696: 0, 8702: 0, 8718: 0, 8734: 0, 8736: 0, 8750: 0, 8760: 0, 8766: 0, 8782: 0, 8792: 0, 8798: 0, 8814: 0, 8824: 0, 8830: 0, 8832: 0, 8840: 0, 8846: 0, 8862: 0, 8864: 0, 8878: 0, 8888: 0, 8894: 0, 8910: 0, 8926: 0, 8928: 0, 8942: 0, 8952: 0, 8958: 0, 8974: 0, 8990: 0, 9006: 0, 9016: 0, 9022: 0, 9038: 0, 9048: 0, 9054: 0, 9070: 0, 9080: 0, 9086: 0, 9088: 0, 9102: 0, 9118: 0, 9134: 0, 9144: 0, 9150: 0, 9166: 0, 9182: 0, 9184: 0, 9192: 0, 9198: 0, 9208: 0, 9214: 0, 9216: 0, 9230: 0, 9246: 0, 9262: 0, 9272: 0, 9278: 0, 9294: 0, 9310: 0, 9326: 0, 9336: 0, 9342: 0, 9358: 0, 9374: 0, 9390: 0, 9400: 0, 9406: 0, 9422: 0, 9424: 0, 9438: 0, 9440: 0, 9454: 0, 9464: 0, 9470: 0, 9472: 0, 9486: 0, 9502: 0, 9518: 0, 9528: 0, 9534: 0, 9536: 0, 9550: 0, 9566: 0, 9582: 0, 9592: 0, 9598: 0, 9614: 0, 9630: 0, 9646: 0, 9656: 0, 9662: 0, 9678: 0, 9694: 0, 9696: 0, 9710: 0, 9720: 0, 9726: 0, 9742: 0, 9758: 0, 9774: 0, 9784: 0, 9790: 0, 9806: 0, 9822: 0, 9824: 0, 9836: 0, 9838: 0, 9848: 0, 9854: 0, 9870: 0, 9886: 0, 9902: 0, 9912: 0, 9918: 0, 9920: 0, 9934: 0, 9950: 0, 9952: 0, 9966: 0, 9968: 0, 9976: 0, 9982: 0, 9984: 0, 9998: 0}

    for n in range(1, N+1):
        flag = False
        if n in dic:
            print(0)
            continue

        for x in range(1, min(40+1, int(n ** 0.5))):
            for y in range(1, min(57+1, int(n ** 0.5))):
                for z in range(1, min(int(n ** 0.5), 98+1)):
                    if f(x, y, z) == n:
                        flag = True
                        X = max(X, x)
                        Y = max(Y, y)
                        Z = max(X, z)
                        # print(n, x, y, z, x + y + z)
                        XYZ = max(XYZ, x + y + z)
                        # if x + y + z >= 100:
                        #     arr.append([n, x, y, z])
                        c = len(set([x, y, z]))
                        if c == 1:
                            print(1)
                            # if n >= C:
                            #     dic[n] = 1
                        elif c == 2:
                            print(3)
                            # if n >= C:
                            #     dic[n] = 3
                        else:
                            print(6)
                            # if n >= C:
                            #     dic[n] = 6
                        # print(n, x, y, z, c)
                    if flag:
                        break
                if flag:
                    break
            if flag:
                break
        if flag == False:
            dic[n] = 0
            print(0)

    # print(X, Y, Z)
    # print(arr)
    # print(dic)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def f(n):
    pairs = set()
    for x in range(1, 45):
        for y in range(x, 45):
            temp = - 3 * (x + y) ** 2 + 4 * n + 4 * x * y
            if (x + y) % 2:
                continue
            elif temp < 0:
                continue
            temp2 = int(temp ** .5)
            if temp2 * temp2 != temp:
                continue
            elif temp2 % 2:
                continue
            z1 = - (x + y) // 2 + temp2 // 2
            z2 = - (x + y) // 2 - temp2 // 2
            if z1 >= 1:
                key = tuple(sorted((x, y, z1)))
                if key in pairs:
                    continue
                pairs.add(key)
            if z2 >= 1:
                key = tuple(sorted((x, y, z2)))
                if key in pairs:
                    continue
                pairs.add(key)
    res = 0
    for x, y, z in pairs:
        if x == y == z:
            res += 1
        elif x == y or y == z or z == x:
            res += 3
        else:
            res += 6
    print(pairs)
    return res


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

Submission status: Wrong Answer

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zer
    ans = [0]*N
    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):
                a = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if a > N:
                    break
                s = set([x,y,z])
                if len(s) == 1:
                    ans[a-1] = 1
                elif len(s) == 2:
                    ans[a-1] = 3
                else:
                    ans[a-1] = 6

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



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
count = 0

for i in range (1,n):
    for x in range (1,n):
        for y in range (1,n):
            for z in range (1,n):
                if x*x + y*y + z*z + x*y + y*z + z*x == i:
                    count = count + 1
                    count = 0
    print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
L=[0]*N
for x in range(1,1000):
    for y in range(x,1000):
        for z in range(y,1000):
            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 f(n):
    if n < 2:
        return 0
    lim1 = int((n - 2) ** 0.5 - 1) + 1
    lim2 = int((-2 + (4 - 12 * (1 - n)) ** 0.5) / 6) + 1
    lim3 = int(n / 6) + 1

    result = set()
    for x in range(1, lim1):
        for y in range(x, lim2):
            for z in range(y, lim3):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    tmp = set([x, y, z])
                    if tmp not in result:
                        result.add(tuple(tmp))
    count = 0
    for s in result:
        if len(s) == 1:
            count += 1
        elif len(s) == 2:
            count += 3
        else:
            count += 6
    return count


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

Submission status: Wrong Answer

Solution code:
from math import trunc, sqrt

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

def perm(x,y,z):
    if x==y and y==z and z==x:
        return 1
    if x!=y and y!=z and z!=x:
        return 6
    return 3

def f(n):
    mn=trunc(sqrt(n // 3))+1
    k=0
    for x in range(1,mn+1):
        for y in range(x,mn+1):
            for z in range(y,mn+1):
                if p(x,y,z)==n:
                    k += perm(x,y,z)
    return k

N=int(input())

for n in range(1,N):
    print(f(n))

Submission status: Wrong Answer

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

ans = [0]*n
for i in range(n):
	for x in range(1,math.floor(math.sqrt(i))):
		for y in range(x,math.floor(math.sqrt(i))):
			for z in range(y,math.floor(math.sqrt(i))):
				if pow(x,2) + pow(y,2) + pow(z,2) + x*y + y*z + z*x == i:
					if len(set([x,y,z])) == 3:
						ans[i] += 6
					if len(set([x,y,z])) == 2:
						ans[i] += 3
					if len(set([x,y,z])) == 1:
						ans[i] += 1
for i in range(n):
	print(ans[i])

Submission status: Wrong Answer

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
n = int(input())
arr = set()
ans = []
temp1 = 0
for i in range(1,n+1):
	temp2 = 0
	for j in range(1,n+1):
		temp3 = 0
		for k in range(1,n+1):
			arr.add(i*i + j*j + k*k + i*j + j*k + k*i)
			temp3 = i*i + j*j + k*k + i*j + j*k + k*i
			#print(temp3, i+j+k)
			if temp3 > n:break
		temp2 = i*i + j*j + 1 + i*j + j + i
		if temp2 > n: break
	temp1 = i*i + 1 + 1 + i + 1 + i
	if temp1 > n:
		break
	


#print(arr)
for i in range(1,n+1):
	if i in arr:
		if i%6==0 and math.floor((i//6)**0.5) == math.ceil((i//6)**0.5):
			ans.append(1)
		else:
			ans.append(3)
	else:
		ans.append(0)
for i in ans:
	print(i)

Submission status: Wrong Answer

Solution code:
from math import trunc, sqrt

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

def perm(x,y,z):
    if x==y and y==z and z==x:
        return 1
    if x!=y and y!=z and z!=x:
        return 6
    return 3

def f(n):
    mn=trunc(sqrt(n // 3))+1
    k=0
    for x in range(1,mn+1):
        for y in range(x,mn+1):
            for z in range(y,mn+1):
                if p(x,y,z)==n:
                    k += perm(x,y,z)
    return k

N=int(input())

for n in range(1,N):
    print(n, f(n))

Submission status: Wrong Answer

Solution code:
input_number = input()
for n in range(int(input_number)):
	n += 1
	count = 0
	for x in range(1,101):
		for y in range(101):
			for z in range(101):
				function = x*x+y*y+z*z+x*y+y*z+x*z
				if n == function:
					count += 1
	print(count)

Submission status: Wrong Answer

Solution code:
ans = [
    0,
    0,
    0,
    0,
    0,
    1,
    0,
    0,
    0,
    0,
    3,
    0,
    0,
    0,
    0,
    0,
    3,
    3,
    0,
    0,
    0,
    0,
    0,
    1,
    6,
    0,
    3,
    0,
    0,
    0,
    0,
    0,
    3,
    3,
    6,
    0,
    0,
    3,
    0,
    0,
    0,
    0,
    3,
    3,
    6,
    0,
    6,
    0,
    0,
    0,
    3,
    0,
    0,
    1,
    6,
    0,
    6,
    6,
    0,
    0,
    6,
    0,
    0,
    0,
    0,
    3,
    3,
    3,
    6,
    0,
    6,
    3,
    6,
    0,
    0,
    0,
    6,
    0,
    0,
    0,
    3,
    3,
    9,
    0,
    6,
    3,
    6,
    0,
    3,
    6,
    0,
    0,
    0,
    0,
    6,
    1,
    6,
    0,
    6,
    6,
    0,
    3,
    12,
    0,
    6,
    0,
    0,
    3,
    6,
    0,
    0,
    0,
    3,
    3,
    12,
    0,
    6,
    3,
    6,
    0,
    3,
    6,
    9,
    0,
    6,
    0,
    0,
    0,
    3,
    6,
    3,
    3,
    6,
    0,
    6,
    3,
    12,
    0,
    3,
    6,
    6,
    0,
    6,
    0,
    6,
    3,
    6,
    0,
    0,
    1,
    6,
    3,
    12,
    6,
    0,
    0,
    12,
    0,
    6,
    0,
    6,
    6,
    12,
    0,
    0,
    6,
    0,
    0,
    6,
    0,
    12,
    3,
    6,
    0,
    6,
    3,
    9,
    6,
    3,
    6,
    6,
    0,
    6,
    0,
    6,
    0,
    15,
    6,
    0,
    0,
    6,
    0,
    3,
    3,
    12,
    0,
    12,
    6,
    6,
    0,
    3,
    6,
    6,
    3,
    12,
    0,
    6,
    0,
    9,
    6,
    0,
    0,
    6,
    3,
    12,
    1,
    6,
    6,
    6,
    6,
    0,
    0,
    18,
    0,
    12,
    0,
    3,
    6,
    12,
    0,
    0,
    6,
    3,
    6,
    12,
    0,
    12,
    0,
    0,
    0,
    9,
    3,
    9,
    6,
    12,
    3,
    12,
    0,
    3,
    6,
    6,
    0,
    12,
    0,
    12,
    0,
    9,
    9,
    0,
    0,
    6,
    3,
    6,
    3,
    12,
    6,
    9,
    3,
    6,
    0,
    12,
    3,
    6,
    3,
    9,
    6,
    12,
    6,
    6,
    0,
    6,
    0,
    9,
    6,
    6,
    0,
    12,
    3,
    6,
    0,
    9,
    6,
    6,
    1,
    6,
    0,
    21,
    12,
    6,
    0,
    12,
    0,
    12,
    0,
    0,
    6,
    15,
    6,
    0,
    6,
    12,
    0,
    12,
    0,
    12,
    0,
    0,
    0,
    12,
    0,
    12,
    12,
    3,
    3,
    18,
    3,
    6,
    3,
    6,
    6,
    9,
    9,
    18,
    0,
    6,
    0,
    12,
    0,
    9,
    6,
    0,
    3,
    12,
    3,
    6,
    6,
    12,
    6,
    6,
    0,
    0,
    0,
    15,
    3,
    18,
    3,
    18,
    3,
    12,
    6,
    3,
    6,
    9,
    0,
    12,
    0,
    12,
    0,
    18,
    12,
    0,
    0,
    12,
    3,
    6,
    0,
    6,
    6,
    9,
    6,
    0,
    0,
    18,
    1,
    18,
    3,
    12,
    6,
    6,
    6,
    12,
    0,
    15,
    6,
    12,
    6,
    18,
    0,
    0,
    6,
    0,
    9,
    12,
    0,
    18,
    0,
    6,
    3,
    12,
    0,
    12,
    12,
    0,
    0,
    12,
    0,
    3,
    6,
    12,
    6,
    18,
    9,
    18,
    0,
    9,
    6,
    18,
    0,
    6,
    0,
    6,
    3,
    27,
    6,
    6,
    6,
    6,
    3,
    6,
    0,
    12,
    6,
    9,
    0,
    6,
    0,
    18,
    0,
    9,
    9,
    15,
    3,
    12,
    6,
    6,
    3,
    9,
    6,
    12,
    12,
    18,
    0,
    18,
    0,
    6,
    6,
    21,
    6,
    0,
    0,
    6,
    3,
    15,
    6,
    12,
    6,
    18,
    0,
    0,
    0,
    12,
    6,
    6,
    3,
    6,
    4,
    18,
    6,
    12,
    6,
    3,
    9,
    30,
    0,
    18,
    0,
    6,
    6,
    12,
    6,
    6,
    9,
    12,
    0,
    18,
    6,
    18,
    0,
    6,
    0,
    12,
    0,
    6,
    12,
    6,
    3,
    18,
    0,
    6,
    6,
    6,
    6,
    15,
    3,
    24,
    0,
    6,
    3,
    18,
    0,
    12,
    6,
    12,
    6,
    24,
    0,
    15,
    18,
    9,
    6,
    0,
    0,
    18,
    3,
    6,
    0,
    15,
    12,
    12,
    6,
    6,
    0,
    18,
    0,
    6,
    3,
    12,
    0,
    12,
    6,
    6,
    9,
    9,
    6,
    24,
    3,
    24,
    0,
    9,
    12,
    6,
    6,
    12,
    0,
    12,
    0,
    21,
    9,
    15,
    6,
    12,
    3,
    18,
    3,
    12,
    6,
    12,
    6,
    0,
    0,
    12,
    0,
    12,
    6,
    24,
    0,
    6,
    12,
    6,
    1,
    9,
    6,
    12,
    6,
    24,
    0,
    18,
    3,
    12,
    6,
    6,
    12,
    24,
    0,
    12,
    6,
    15,
    6,
    18,
    0,
    18,
    0,
    0,
    0,
    18,
    9,
    21,
    12,
    0,
    6,
    18,
    0,
    9,
    6,
    6,
    6,
    12,
    0,
    12,
    0,
    9,
    9,
    27,
    6,
    6,
    3,
    18,
    6,
    21,
    6,
    6,
    12,
    12,
    0,
    12,
    0,
    24,
    12,
    0,
    0,
    24,
    3,
    24,
    6,
    12,
    12,
    18,
    0,
    0,
    0,
    12,
    0,
    18,
    3,
    15,
    6,
    12,
    9,
    6,
    0,
    15,
    6,
    9,
    12,
    24,
    0,
    12,
    3,
    6,
    6,
    21,
    6,
    18,
    3,
    18,
    0,
    21,
    12,
    15,
    6,
    6,
    0,
    12,
    3,
    12,
    9,
    18,
    9,
    12,
    6,
    6,
    6,
    24,
    0,
    18,
    3,
    24,
    0,
    6,
    6,
    0,
    6,
    9,
    6,
    6,
    4,
    30,
    0,
    18,
    12,
    9,
    6,
    24,
    0,
    18,
    0,
    9,
    12,
    21,
    6,
    6,
    12,
    12,
    0,
    18,
    0,
    21,
    15,
    12,
    0,
    12,
    6,
    12,
    12,
    18,
    0,
    18,
    0,
    6,
    0,
    9,
    12,
    18,
    6,
    30,
    0,
    0,
    0,
    24,
    6,
    9,
    3,
    12,
    6,
    30,
    3,
    6,
    12,
    6,
    12,
    12,
    0,
    36,
    0,
    6,
    3,
    27,
    12,
    12,
    6,
    6,
    6,
    24,
    0,
    12,
    6,
    12,
    0,
    18,
    0,
    18,
    15,
    18,
    3,
    18,
    6,
    12,
    6,
    6,
    12,
    3,
    6,
    6,
    0,
    12,
    3,
    39,
    3,
    12,
    12,
    12,
    3,
    18,
    0,
    21,
    12,
    21,
    6,
    18,
    0,
    12,
    0,
    9,
    9,
    12,
    9,
    24,
    9,
    12,
    6,
    12,
    6,
    33,
    0,
    6,
    0,
    18,
    0,
    9,
    15,
    12,
    6,
    24,
    6,
    6,
    3,
    15,
    6,
    15,
    12,
    18,
    0,
    18,
    1,
    18,
    6,
    12,
    6,
    6,
    0,
    24,
    6,
    24,
    12,
    18,
    6,
    24,
    0,
    6,
    6,
    12,
    15,
    24,
    0,
    24,
    6,
    6,
    0,
    18,
    0,
    15,
    18,
    12,
    0,
    24,
    0,
    12,
    6,
    12,
    12,
    18,
    6,
    24,
    0,
    0,
    6,
    24,
    3,
    12,
    0,
    12,
    6,
    30,
    9,
    6,
    12,
    24,
    12,
    12,
    0,
    15,
    18,
    12,
    0,
    18,
    0,
    24,
    6,
    15,
    6,
    18,
    3,
    18,
    3,
    12,
    6,
    24,
    12,
    12,
    12,
    6,
    0,
    36,
    0,
    18,
    3,
    6,
    12,
    6,
    9,
    12,
    0,
    3,
    12,
    36,
    0,
    30,
    0,
    12,
    0,
    18,
    6,
    12,
    9,
    12,
    6,
    24,
    3,
    18,
    12,
    15,
    9,
    24,
    0,
    18,
    6,
    18,
    9,
    18,
    12,
    6,
    6,
    24,
    3,
    24,
    0,
    12,
    12,
    12,
    0,
    6,
    0,
    27,
    12,
    18,
    3,
    30,
    3,
    18,
    6,
]

i = int(input())
[print(x) for x in ans[:i]]

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N = int(input())
#L, R, d=map(int,input().split())
#C = []
# for i in range(N):
#    C.append((input().replace(".","0").replace("#","1")))
# S=list(map(int,input().split()))
# B=list(map(int,input().split()))
def calc1(x,y,z):
    return x*x+y*y+z*z+x*y+y*z+z*x
def calc2(x,y):
    return x*x+y*y+1*1+x*y+y*1+1*x
def calc3(x):
    return x*x+1*1+1*1+x*1+1*1+1*x

count = []
for n in range(1,N+1):
    count2 = 0
    l = []
    for i in range(1,n):
        if calc3(i) > n:
            break
        for j in range(i,n):
            if calc2(i,j) > n:
                break
            for k in range(j,n):
                h = calc1(i,j,k)
                o = [i,j,k].sort
                if h > n:
                    break
                elif o in l:
                    count2+=1
                elif h == n:
                    count2+=1
                    l.append(o)
    count.append(count2)

print('\n'.join(map(str, count)))

Submission status: Wrong Answer

Solution code:
import time
import itertools

N = int(input())
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,25),repeat=3))
a = []

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

for n in range(1,N + 1):
    print(a.count(n))

Submission status: Wrong Answer

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
        try:
            ans[cal(x,y,z)] += func(i,x,y,z)
        except IndexError:
            pass
        while z >= math.ceil(sn / 2):
            y += 1
            z -= 1
            if x > z or y > z:
                break
            try:
                ans[cal(x,y,z)] += func(i,x,y,z)
            except IndexError:
                pass
            for j in range(y):
                x += 1
                z -= 1
                if x > z or y > z:
                    break
                try:
                    ans[cal(x,y,z)] += func(i,x,y,z)
                except IndexError:
                    pass
    
    for i in range(1,N+1):
        print(ans[i])
        

def func(n,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()