ListTools[Search](k, ans) looks for the first occurrence of the integer k in in the list ans, and retruns the index. So if you had some arbitryary list [1, 2 ,7, 10, 23, 8, 4],
ListTools[Search](10, ans) would return 4,
ListTools[Search](23, ans) would return 5
and so on.
There is no integer n which has 6 solutions, if all positive and negative combinations of x and y are allowed. Consider if x0>=0 and y0>=0 is a solution, then there will be three other solutions (x0, -y0), (-x0, y0), and (-x0, -y0), so solutions always come in sets of four there will be values of n with four solutions, values with 8, values with 12 etc, but none with 6.
Only way you could get 6 solutions is if you add an additional condition such as requiring x>0, y>0 - then each set of four solutions (x0, y0), (x0, -y0), (-x0, y0), and (-x0, -y0) will actually provide only one valid solution (x0, y0). Without doing any clever to the code already provided this means that you are looking for the lowest integer for which the current code provides 24 solutions - 6 sets of 4 and in each set of four, only one will have both x and y >0
You will need to execute quadsumstats(400), the ListTools[Search](24, ans) will return 325, and the six positive answers are (1, 18), (18, 1), (6, 17), (17, 6), (10, 15), (15, 10)
Of course you might not want to allow both (1,18) and (18,1) as two separate answers, in which case you will be looking for the first number for which ListTools(48, ans) returns a value of 48. This turns out to be 5525 - although this now runs so slowly that I would probably try to come up with a more efficient way to do the problem