Under construction

Still being built. Things may change

Sum of Cubes

Time limit0.5sMemory limit256 MB

Summary
Write N as a sum of as few positive cubes as possible, and among the shortest sums output the one that is lexicographically largest.
Level

Medium7 of 10

Topics
Dynamic programming, Brute force, Math, Implementation
Solved
No attempts yet

Problem

You are given a natural number NN. Write NN as a sum of cubes of natural numbers using as few terms as possible. That is, find natural numbers m1,m2,…,mkm_1, m_2, \ldots, m_k with

m13+m23+⋯+mk3=Nm_1^3 + m_2^3 + \cdots + m_k^3 = N

where kk is as small as possible. The same number may be used more than once.

Input

The first and only line contains the natural number NN (1≤N≤44,777,4441 \le N \le 44{,}777{,}444).

Output

Print two lines. The first line contains kk, the minimum number of cubes. The second line contains kk natural numbers whose cubes add up to NN, separated by single spaces and sorted so that no number is smaller than the number after it.

If several sets of kk numbers work, print the one that comes first in lexicographic order. Compare two sets at the first position where they differ, and the set with the smaller number there comes first. For N=1729N = 1729 both 123+1312^3 + 1^3 and 103+9310^3 + 9^3 use two cubes, so the answer is 10 9.

Examples2

  1. Example 1

    Input
    42
    
    Expected output
    7
    2 2 2 2 2 1 1
    
  2. Example 2

    Input
    43
    
    Expected output
    3
    3 2 2