Santa Claus has n candies, he dreams to give them as gifts to children.

What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.


-----Input-----

The only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.


-----Output-----

Print to the first line integer number k — maximal number of kids which can get candies.

Print to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.

If there are many solutions, print any of them.


-----Examples-----
Input
5

Output
2
2 3

Input
9

Output
3
3 5 1

Input
2

Output
1
2

Difficulty: interview

Starter code:

Solutions:
n = int(input())
ans = []
nxt = 1
while n > 0:
  x = nxt
  n -= nxt
  nxt += 1
  if n < nxt:
    x += n
    n = 0
  ans.append(str(x))
print(len(ans))
print(" ".join(ans))


n = int(input())
cur = 1
ans = []
while n > cur:
    n -= cur
    ans.append(cur)
    cur += 1
if n < cur:
    ans[-1] += n
else:
    ans.append(n)
print(len(ans))
print(*ans)


n = int(input().strip())
k = int(((8 * n + 1) ** 0.5 - 1) // 2)
s = ""

a = []
for i in range(k - 1):
    s += str(i + 1) + " "
s += str(n - (k * (k - 1)) // 2)

print(k)
print(s)


n = int(input())
ans = 0
L = []
i = 1
while i <= n:
    ans += 1
    L.append(i)
    n -= i
    i += 1
L[-1] += n
print(ans)
print(*L)

n = int(input())
x = n
i = 1
while n >= i:
    n -= i
    i += 1
print(i-1)
for j in range(1,i):
    if j == i-1:
        print(x)
        break
    else:
        print(j,end= ' ')
        x -= j

q=int(input())
a=[1]
q-=1
l=1
while q>a[l-1]:
    q-=l+1
    a.append(l+1)
    l+=1
a[l-1]+=q
print(len(a))
for i in a:
    print(i,end=' ')


n = int(input()) - 1
ans = [1]
while n > ans[-1]:
    n -= ans[-1] + 1
    ans.append(ans[-1] + 1)
ans[-1] += n
print(len(ans))
print(*ans)

n = int(input())
arr = []
on = 1
while n>2*on:
  n-=on
  arr.append(on)
  on+=1
arr.append(n)
print(len(arr))
print(' '.join(map(str,arr)))

n = int(input())
k = int(-0.4999999 + (0.25 + 2*n)**0.5)
print(k)
for i in range(1,k):
    print(i, end = " ")
print(n - k*(k-1)//2)    

n = int(input())
cur = 1
while(n>=cur):
    n-=cur
    cur+=1
print(cur-1)
for i in range(1,cur-1):
    print(i,end=' ')
print(cur-1+n)



#!/usr/bin/env python3

def main():
    try:
        while True:
            t = n = int(input())
            result = 0
            i = 1
            while n >= i:
                n -= i
                i += 1
                result += 1
            print(result)
            for i in range(1, result):
                print(i, end=' ')
            print(t - sum(range(result)))

    except EOFError:
        pass

main()


n = int(input())
k = 0
size = n
for i in range(1,size+1):
	n -= i
	k += 1
	if n<=i: break

print(k)
L = size
for i in range(1,L+1):
	if size-i<=i:
		print(size)
		break
	print(i, end=" ")
	size -= i
	


n = int(input())
k = 1
while k * (k + 1) // 2 <= n:
    k += 1
k -= 1
print(k)
for i in range(1, k):
    print(i, end=' ')
print(n - k * (k - 1) // 2)


from math import *
def Main(n):
    sm = 0
    A = []
    for i in range(1,n + 1):
        sm += i
        A.append(i)
        if(sum(A) == n):
            break
        elif(sum(A) > n):
            break
    # print(A)
    rez = abs(n - sum(A))

    if rez in A:
        value_index = A.index(rez)
        A.pop(value_index)

    print(len(A))
    print(*A)


    # print(int(sqrt(n)))
    # if n%2 == 1:
    #     res = n//2
    #     print(res, end = " ")
    #     for i in range(res - 1, 1, -1):
    #         print(i, end = ' ')
    #     print()

def __starting_point():
    n = int(input())
    Main(n)
__starting_point()

candies = int(input())

def printCandies(touse):
    print(len(result))
    resultS = ""
    for child in touse:
        resultS += str(child) + " "
    print(resultS)

if candies >= 1 and candies <= 1000:
    result = []
    for i in range(1, candies + 1):
        result.append(i)
        if sum([int(i) for i in result]) > candies:
            result = result[0:-1]
            break
    sumN = sum(result)
    if sumN == candies:
        printCandies(result)
    else:
        remain = candies - sum(result)

        for i in range(remain, 0, -1):
            result[-1 - (i-1)] += 1
        
        printCandies(result)
        


max = -float('inf')
cur = []

def candies(n, arr):
	nonlocal cur, max
	if sum(arr) == n:
		if len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):
			max = len(arr)	
			cur = arr[:]				
		return 0 

	if sum(arr) > n:
		arr.pop()
		if len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):		
			max = len(arr)
			cur = arr[:]				
		return 0

	for i in range(1, n+1):
		if i not in arr:
			arr.append(i)			
			if candies(n, arr) == 0:	
				break
			if i in arr: arr.remove(i);
	#print(cur)
	return 1
		

n = int(input())


candies(n, [])
print(max)
for each in cur:
	print(each, end=" ") 



n = int(input())
ans = list()
i = 1
while 1:
	if n < i :
		break
	n-=i 
	ans.append(i)
	i +=1
ans[len(ans)-1] += n
print(len(ans))
for i in ans :
	print(i,end=' ')


n = int(input())
a = [0]

while n > 2*(a[-1]+1):
	n -= a[-1]+1
	a.append(a[-1]+1)

if n != 0:
	a.append(n)

a.remove(0)

print(len(a))
print(*a)

N = int(input())
M = 0
while (M + 1) * (M + 2) / 2 <= N :
	M += 1
print(M)
for i in range(1, M) :
	print(i, end = ' ')
	N -= i
print(N)	


n=int(input())
s=''
i=0
while True:
    i+=1
    n-=i
    if n>i:
        s+=str(i)+' '
    else:
        s+=str(n+i)
        break
print(i)
print(s)

n = int(input())
k = 1
while k * (k + 1) // 2 <= n:
    k += 1
k -= 1
print(k)
for i in range(1, k):
    print(i, end=' ')
print(n - k * (k - 1) // 2)

n=int(input())
if n==1:
    print(1)
    print(1)
elif n==2:
    print(1)
    print(2)
else:
    t=[]
    i=1
    while i<=n:
        n-=i
        t.append(i)
        i+=1
    k=len(t)
    t[k-1]+=n
    print(k)
    for i in t:
        print(i,end=" ")

#not submitted not completed
#http://codeforces.com/problemset/problem/753/A
n = int(input())
sum = 0
numbers = []
i = 1
while sum < n:
	numbers.append(i)
	sum += i
	i += 1
if sum > n:
	del numbers[sum - n - 1]
print(len(numbers))
for j in numbers:
	print(j, end=" ")
print()

n = int(input())
c=1
sol = []
while n>c:
    n = n-c
    sol.append(c)
    c=c+1
if n >= c:
    sol.append(n)
else:
    sol[-1] += n
print(len(sol))
print(*sol)