#nullable enable using System; using System.Linq; using System.Collections; using System.IO; using System.Collections.Generic; using System.Text; using System.Numerics; using System.Runtime.Intrinsics.X86; using System.Buffers; using System.Diagnostics; using System.Runtime.CompilerServices; using static InputUtility; using System.Reflection; class Program { static void Main() { InputNewLine(); var x = NextInt32; Stopwatch sw = Stopwatch.StartNew(); var abc = Abc(); static (int v, int c)[] Abc() { Span n3 = stackalloc int[301]; for (int i = 0; i < n3.Length; i++) { n3[i] = i * i * i; } (int v, int c)[] abc = new (int v, int c)[4590551]; int index = 0; for (int a = 0; a < n3.Length; a++) { for (int b = a; b < n3.Length; b++) { for (int c = b; c < n3.Length; c++) { abc[index++] = (n3[a] + n3[b] + n3[c], c); } } } return abc; } Array.Sort(abc); var def = Def(); static (int v, int d)[] Def() { Span n3 = stackalloc int[301]; for (int i = 0; i < n3.Length; i++) { n3[i] = i * i * i; } (int v, int c)[] abc = new (int v, int c)[4590551]; int index = 0; for (int a = 0; a < n3.Length; a++) { for (int b = a; b < n3.Length; b++) { for (int c = b; c < n3.Length; c++) { abc[index++] = (n3[a] + n3[b] + n3[c], a); } } } return abc; } Array.Sort(def); int res = 0; int right = def.Length - 1; foreach (var (v, c) in abc) { var target = x - v; if (target < 0) { break; } while (right >= 0 && target < def[right].v) { right--; } for (int i = right; i >= 0; i--) { if (target != def[i].v) { break; } if (c <= def[i].d) { res++; } else { break; } } } Console.WriteLine(res); } } public static class InputUtility { private static string[]? s_inputs; private static string? s_raw; private static int s_index = 0; private static void Init() => s_index = 0; public static int NextInt32 => int.Parse(s_inputs![s_index++]!); public static uint NextUInt32 => uint.Parse(s_inputs![s_index++]!); public static long NextInt64 => long.Parse(s_inputs![s_index++]!); public static string NextString => s_inputs![s_index++]; public static char NextChar => s_inputs![s_index++][0]; public static int[] GetInt32Array() => s_inputs!.Select(int.Parse).ToArray(); public static long[] GetInt64Array() => s_inputs!.Select(long.Parse).ToArray(); public static string GetRawString() => s_raw!; #if DEBUG private static TextReader? s_textReader; public static void SetSource(string path) => s_textReader = new StringReader(File.ReadAllText(path)); #endif public static bool InputNewLine() { #if DEBUG if (s_textReader is TextReader sr) { Init(); s_raw = sr.ReadLine()!; s_inputs = s_raw.Split(' ', StringSplitOptions.RemoveEmptyEntries); return true; } #endif Init(); s_raw = Console.ReadLine()!; s_inputs = s_raw.Split(' ', StringSplitOptions.RemoveEmptyEntries); return true; } }