Under construction

Still being built. Things may change

Selling pills

Time limit1sMemory limit512 MB

Summary
Given N, build the fixed canonical pouch layout of (b-1) ones followed by c copies of b, where b^2 >= N and c = ceil(N/b).
Level

Easy3 of 10

Topics
Math, Greedy, Implementation
Solved
No attempts yet

Problem

Kanguk sells pills, and he talks his customers into a purchase every time. One thing still bothers him.

Donggyu, a regular customer, orders some number of pills every day, anywhere from 11 to NN. Kanguk counted the pills out of the box one at a time, which took a while, and Donggyu lost his temper over the wait every time.

Kanguk worked out a faster way to hand the pills over. He splits the pills among several pouches and lines the pouches up in a row. When Donggyu asks for kk pills, Kanguk picks up one contiguous run of pouches whose pills add up to exactly kk.

The counter holds at most 20002000 pouches in a row. Arrange the pouches so that Kanguk can serve any number from 11 to NN that Donggyu calls out.

Input

The first line contains NN (1≤N≤1061 \le N \le 10^6), the largest number of pills Donggyu orders at once.

Output

Print the number of pouches KK (1≤K≤20001 \le K \le 2000) on the first line. On the second line print the number of pills in each pouch from left to right, separated by single spaces. Every pouch holds between 11 and 10610^6 pills, and every number from 11 to NN is the sum of some contiguous run of pouches.

Many arrangements satisfy those conditions, so the judge accepts only the arrangement built by the following rule.

  • Let bb be the smallest positive integer with b2≥Nb^2 \ge N.
  • Let c=⌈N/b⌉c = \lceil N / b \rceil.
  • Then K=(b−1)+cK = (b - 1) + c. Starting from the left, place b−1b - 1 pouches holding 11 pill each, then cc pouches holding bb pills each.

Examples2

  1. Example 1

    Input
    6
    
    Expected output
    4
    1 1 3 3
    
  2. Example 2

    Input
    1
    
    Expected output
    1
    1