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.

Solution in Rust (1.42.0) (judge verdict: Accepted)

use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::{Itertools, enumerate};
use std::ops::{Add, AddAssign};
use num_integer::{Integer, gcd, lcm};
use std::collections::VecDeque;
use smallvec::alloc::collections::LinkedList;
use regex::internal::Char;
use std::iter::once;

fn read<T: FromStr>(stdin: &mut StdinLock) -> T {
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>(stdin: &mut StdinLock) -> (T, S) {
    let a = read(stdin);
    let b = read(stdin);
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>(stdin: &mut StdinLock) -> (T, S, R) {
    let a = read(stdin);
    let b = read(stdin);
    let c = read(stdin);
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}


fn main() {
    // template
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    // template ends
    let n:u32 = read(&mut stdin);
    let xyz_max = (n as f32).sqrt() as u32;
    let mut counter = HashMap::new();
    for x in 1..xyz_max {
        let x_pow = x.pow(2);
        for y in 1..xyz_max {
            let y_pow = y.pow(2);
            for z in 1..xyz_max {
                let num = x_pow + y_pow + z.pow(2) + x * y + y * z + z * x;
                let mut ent = counter.entry(num).or_insert(0);
                *ent += 1;
            }
        }
    }
    for i in 1..n+1 {
        let num = counter.get(&i).unwrap_or(&0);
        writeln!(out, "{}", num);
    }
}