ns = $<.map(&:to_i)[0..-2]
squares = (0..Math.sqrt(ns.max).to_i).map {|x| x * x}
m = squares.size-1

ns.each do |n| 
    count = 0 
    (0..m).each do |i| 
        x = squares[i]
        break if 4 * x > n 
        (i..m).each do |j| 
            y = squares[j]
            break if x + y * 3 > n 
            l = m 
            (j..m).each do |k| 
                z = squares[k]
                s = x + y + z 
                l -= 1 while s + squares[l] > n 
                break if l < k 
                count += 1 if s + squares[l] == n
            end
        end
    end 
    p count
end