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: EASY
Tags: Dynamic programming

Mathematics

Greedy algorithms
Skill types: Dynamic programming

Greedy algorithms

Starter code:

Solutions:
R = lambda : map(int, input().split())
n = int(input())
a = []
for i in range(1, n + 1):
	a.append(i)
	n -= i
	if n <= i:
		break
a[-1] += n
print(len(a))
print(' '.join(map(str, a)))


n = int(input())
k = 1
arr = []
while k * (k + 1) <= 2 * n:
	arr.append(k)
	k += 1
arr.pop()
arr.append(n - sum(arr))
print(len(arr))
print(*arr)


n = int(input())
if n == 1:
	print(1)
	print(1)
	exit()
res = []
s = 0
for i in range(1, n):
	f = s + i
	if n - f <= i:
		res.append(n - s)
		break
	else:
		res.append(i)
		s += i
print(len(res))
print(*res)


import sys
input = sys.stdin.readline
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = int(input())
i = 1
a = []
while i <= n:
	a.append(i)
	n -= i
	i += 1
a[-1] += n
print(len(a))
print(' '.join((str(x) for x in a)))


n = int(input())
s = 0
res = []
curr = 1
from math import sqrt as S
z = (-1 + S(1 + 8 * n)) / 2
if int(z) == z:
	z = int(z)
	res = [i for i in range(1, z + 1)]
	print(z)
	print(*res)
else:
	can = int(z)
	for i in range(1, can):
		s += i
		res.append(i)
	res.append(n - s)
	print(can)
	print(*res)


import os.path
from math import gcd, floor, ceil
from collections import *
from bisect import *
import sys
from random import *
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = inp()
if n == 1 or n == 2:
	pr(1)
	pr(n)
else:
	cur = 1
	r = n
	ans = []
	while cur < n - cur * (cur + 1) // 2:
		ans.append(cur)
		cur += 1
	ans.append(n - cur * (cur - 1) // 2)
	print(len(ans))
	print(*ans)


n = int(input())
m = n
arr = []
if n > 1:
	for i in range(1, n + 1):
		m -= i
		if m < abs(m):
			m += i
			arr[len(arr) - 1] += m
			break
		else:
			arr.append(i)
	print(len(arr))
	print(*arr)
else:
	print('1')
	print('1')


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


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
s = int(z())
if s == 1:
	exit(print('1\n1'))
arr = []
t = 0
for i in range(1, s):
	t += i
	if t > s:
		break
	else:
		arr.append(i)
if sum(arr) == s:
	print(len(arr))
	print(*arr)
else:
	print(len(arr))
	print(*arr[:-1], arr[-1] + (s - sum(arr)))


n = int(input())
x = []
i = 1
while n > 0:
	n -= i
	x.append(i)
	i += 1
	if n - i < 0:
		x[-1] += n
		break
print(len(x))
print(*x)


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))


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
	rez = abs(n - sum(A))
	if rez in A:
		value_index = A.index(rez)
		A.pop(value_index)
	print(len(A))
	print(*A)

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


import sys

def solve(r, w):
	santa_candy = int(r.readline())
	candy_for_kid_list = []
	while santa_candy > len(candy_for_kid_list):
		candy_for_kid = len(candy_for_kid_list) + 1
		candy_for_kid_list += [candy_for_kid]
		santa_candy -= candy_for_kid
	candy_for_kid_list[-1] += santa_candy
	print(len(candy_for_kid_list))
	print(*candy_for_kid_list)
solve(sys.stdin, sys.stdout)


n = int(input())
k = 1
spis = []
j = 0
if n == 3:
	spis = spis + ['1', '2']
	j = 2
else:
	while True:
		j = j + 1
		if n - k >= 3 and str(n - k) not in spis and (n - k != k):
			n = n - k
			spis = spis + [str(k)]
		else:
			spis = spis + [str(n)]
			break
		k = k + 1
print(j)
print(' '.join(spis))


n = int(input())
l = []

def foo():
	global l
	global n
	for i in range(1, n + 1):
		if i in l:
			continue
		l.append(i)
		n = n - i
		foo()
	if n == 0:
		return
	elif len(l) > 0:
		n = n + l[len(l) - 1]
		del l[len(l) - 1]
foo()
print(len(l))
for i in l:
	print(i, end=' ')


num1 = int(input())
i = 2
ans = 0
s = 0
ans = int(((8 * num1 + 1) ** (1 / 2) - 1) / 2)
print(int(ans))
for i in range(int(ans) - 1):
	print(i + 1, end=' ')
	s += i + 1
print(num1 - s, end=' ')


import math
n = int(input())
t = int(math.sqrt(2 * n + 0.25) - 0.5)
ans = list(range(t + 1)[1:])
ans[-1] += n - t * (t + 1) // 2
print(t)
print(*ans)


N = int(input())
count = 1
ans = []
while N >= count:
	ans += [count]
	N -= count
	count += 1
if N != 0:
	ans[-1] += N
print(len(ans))
for i in ans:
	print(i, end=' ')


def cusum(x):
	return x * (x + 1) // 2
n = int(input())
ans = []
for i in range(1, n + 1):
	t = cusum(i)
	if t > n:
		if len(ans) == 1:
			ans[-1] = n
		else:
			ans[-1] = abs(cusum(ans[-2]) - n)
		break
	ans.append(i)
print(len(ans))
print(' '.join(map(str, ans)))


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


n = int(input())
answer = []
(s, i) = (0, 1)
while s < n:
	answer.append(i)
	s += i
	i += 1
d = s - n
answer = list(filter(lambda x: x != d, answer))
print(len(answer))
print(' '.join(map(str, answer)))


n = int(input())
for i in range(1, 50):
	if i * (i + 1) // 2 == n:
		print(i)
		print(*[j for j in range(1, i + 1)])
		break
	elif i * (i + 1) // 2 > n:
		print(i - 1)
		print(*[j for j in range(1, i - 1)], n - (i - 2) * (i - 1) // 2)
		break


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


n = int(input())
ans = []
t = n
for i in range(1, n + 1):
	if i == 1:
		ans = [1]
		t -= 1
	elif t >= i:
		ans.append(i)
		t -= i
	else:
		ans[-1] += t
		t = 0
	if t == 0:
		break
print(len(ans))
print(*ans)


from math import floor, sqrt
n = int(input())
ans = floor(0.5 * (sqrt(8 * n + 1) - 1))
one_to_ans = [i for i in range(1, ans + 1)]
one_to_ans[-1] += n - sum(one_to_ans)
print(ans)
print(*one_to_ans)


import sys
import math
import bisect

def solve(n):
	A = []
	val = 0
	for i in range(1, 10000):
		if val + i <= n:
			A.append(i)
			val += i
		else:
			break
	A[-1] += n - sum(A)
	return A

def main():
	n = int(input())
	A = solve(n)
	print(len(A))
	print(' '.join(list((str(a) for a in A))))
main()


import math
Candies = int(input())

def reparto(n):
	m = (math.sqrt(8 * n + 1) - 1) / 2
	print(int(m))
	for i in range(1, int(m)):
		n -= i
		print(i)
	return n
print(reparto(Candies))


import math
x = int(input())
k = math.floor((-1 + math.sqrt(1 + 8 * x)) / 2)
print(k, '\n')
for i in range(1, k):
	print(i, ' ')
print(int(x - k * (k - 1) / 2))


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


import math
n = int(input())
if n != 2:
	i = 1
	c = 1
	s = '1'
	while i * (i + 1) / 2 <= n:
		i += 1
	print(i - 1)
	for j in range(1, i - 1):
		if j == i - 2:
			s += ' ' + str(n - c)
		else:
			s += ' ' + str(j + 1)
			c += j + 1
	print(s)
else:
	print(1)
	print(2)


n = int(input())
s = []
t = 0
nums = [int(i) for i in range(1, n + 1)]
for i in range(1, n + 1):
	d = sum(nums[:i])
	if d <= n:
		t = nums[:i]
t[-1] += n - sum(t)
print(len(t))
print(*t)


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


from math import sqrt
n = int(input())
if n == 1:
	print(1)
	print(1)
else:
	x = []
	y = []
	sumo = 0
	i = 0
	f = 0
	while f == 0:
		i = i + 1
		ln = n
		n = n - i
		y.append(i)
		if n in y or n == 0:
			break
		else:
			x.append(i)
	x.append(ln)
	print(len(x))
	for i in x:
		print(i, end=' ')


def main():
	from math import sqrt
	n = int(input())
	x = int(sqrt(2.0 * n + 0.25) - 0.5)
	print(x)
	print(n - x * (x - 1) // 2, *list(range(1, x)))
main()


n = int(input())
l = []
for i in range(n):
	l.append(i + 1)
	if sum(l) + l[len(l) - 1] + 1 > n:
		l[len(l) - 1] += n - sum(l)
		break
print(len(l))
print('%s' % ' '.join(map(str, l)))


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


import math
import sys
n = int(input())
a = int((math.sqrt(8 * n + 1) - 1) / 2)
print(a)
for i in range(a - 1):
	print(i + 1)
print(int(n - a * (a - 1) / 2))


a = int(input())
i = 1
counter = 0
T = []
while a - i >= 0:
	a -= i
	counter += 1
	T = T + [i]
	i += 1
T[counter - 1] += a
print(counter)
for i in T:
	print(i, end=' ')


n = int(input())
dp = [0, n]
extend = True
while extend == True:
	temp = dp[-1] - (len(dp) - 1)
	if temp > len(dp) - 1:
		dp.append(temp)
	else:
		extend = False
print(len(dp) - 1)
res = ''
for i in range(0, len(dp) - 2):
	res = res + str(i + 1) + ' '
res = res + str(dp[len(dp) - 1])
print(res)


n = int(input())
s = 0
ans = []
for i in range(1, 2 * (n + 1)):
	s += i
	if s <= n:
		ans.append(i)
	else:
		s -= i
		ans[-1] = ans[-1] + n - s
		break
print(len(ans))
print(*ans)


n = int(input())
sett = set()
z = 1
n -= 1
sett.add(1)
while z + 1 <= n:
	sett.add(z + 1)
	z += 1
	n -= z
if n:
	sett.remove(z)
	sett.add(z + n)
	print(len(sett))
	print(*sett)
else:
	print(len(sett))
	print(*sett)


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())
if n == 2:
	num = [2]
	n = 0
else:
	num = [1]
	n -= 1
i = 2
while n > 0:
	if n >= 2 * i + 1:
		num.append(i)
		n -= i
	else:
		num.append(n)
		n = 0
	i += 1
print(len(num))
print(*num)


n = int(input())
x = 1
lst = []
if n == 1:
	print(n)
	print(n)
	exit()
while x <= n:
	n -= x
	lst.append(x)
	x += 1
lst[-1] += n
print(x - 1)
for elem in lst:
	print(elem, end=' ')


n = int(input())
l = []
for i in range(1, 2000):
	if n - i > i:
		n = n - i
		l.append(i)
	else:
		l.append(n)
		break
print(len(l))
for i in range(len(l)):
	print(l[i], end=' ')


n = int(input())
dp = [[[0, False] for x in range(n + 1)] for x in range(n + 1)]
for i in range(n + 1):
	dp[0][i][1] = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if j <= i and dp[i - j][j - 1][1] != False:
			dp[i][j][0] = dp[i - j][j - 1][0] + 1
			dp[i][j][1] = True
		if dp[i][j - 1][0] > dp[i][j][0]:
			dp[i][j][0] = dp[i][j - 1][0]
			dp[i][j][1] = True
print(dp[-1][-1][0])
i = j = n
while i > 0 and j > 0:
	if dp[i][j] == dp[i][j - 1]:
		j -= 1
	else:
		print(j, end=' ')
		i -= j


number = int(input())
n = int((1 + (1 + 8 * number) ** (1 / 2)) / 2)
n -= 1
print(n)
ans = []
for i in range(n - 1):
	ans.append(str(i + 1))
ans.append(str(number - (n - 1) * n // 2))
print(' '.join(ans))


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

def candies(n, arr):
	global 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)
	return 1
n = int(input())
candies(n, [])
print(max)
for each in cur:
	print(each, end=' ')


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())
l = [1]
for i in range(2, n):
	if sum(l) + i <= n:
		l.append(i)
	else:
		break
l[-1] = l[-1] + (n - sum(l))
print(len(l))
print(*l)


n = int(input())
s = []
sum = 0
i = 1
while sum + i <= n and i not in s:
	s.append(i)
	sum += i
	i += 1
print(len(s))
s[-1] += n - sum
print(*s)


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


n = int(input())
k = 1
while 1:
	k += 1
	if k * (k + 1) // 2 > n:
		break
k -= 1
ans = []
for i in range(1, k):
	ans.append(i)
ans.append(n - (k - 1) * k // 2)
print(k)
print(*ans)


n = int(input())
a = []
c = 0
x = 1
while sum(a) + x <= n:
	a.append(x)
	x += 1
	c += 1
if sum(a) == n:
	print(c)
	print(*a)
else:
	a[-1] = n - sum(a[:-1])
	print(c)
	print(*a)


from bisect import bisect_left as bl
n = int(input())
dp = []
for i in range(1, n + 1):
	dp.append(i * (i + 1) // 2)
x = bl(dp, n)
if dp[x] == n:
	ans = [i for i in range(1, x + 2)]
else:
	tmp = n - dp[x - 1]
	ans = [i for i in range(1, x + 1)]
	ans[-1] += tmp
print(len(ans))
print(*ans)


def getSweets(sweetCount):
	if sweetCount == 1:
		return [1]
	sweetsList = []
	sumN = 0
	n = 1
	while sumN + n <= sweetCount:
		sumN += n
		sweetsList.append(n)
		n += 1
	sweetsList[-1] += sweetCount - sumN
	return sweetsList
sweetCount = int(input())
sweets = getSweets(sweetCount)
sweets = list(map(str, sweets))
print(len(sweets))
print(' '.join(sweets))


n = int(input())
ans = 0
i = 1
a = []
while ans != n:
	if ans + i < n:
		ans += i
		a.append(i)
	elif ans + i == n:
		a.append(i)
		print(len(a))
		print(*a)
		break
	else:
		del a[-1]
		a.append(n - sum(a))
		print(len(a))
		print(*a)
		break
	i += 1


n = int(input())
k = n
ans = []
for i in range(1, 1000):
	n -= i
	if n < 0:
		break
	ans.append(i)
print(len(ans))
if len(ans) > 1:
	print(*ans[:-1], end=' ')
print(ans[-1] + k - sum(ans))


n = int(input())
if n <= 2:
	print(1)
	print(n)
else:
	l = []
	total = 0
	for i in range(1, n):
		total += i
		if total >= n:
			l.append(i)
			break
		else:
			l.append(i)
	if total > n:
		l.remove(total - n)
	print(len(l))
	for i in l:
		print(i, end=' ')


m = int(input())
l = []
for i in range(1, 100):
	l.append(i * (i + 1) // 2)
(p, j) = (0, 0)
if m == 1:
	print(1)
	print(1)
	exit()
for i in range(100):
	if m < l[i]:
		p = l[i - 1]
		j = i
		break
print(j)
l1 = []
p = m - p
for i in range(1, j + 1):
	l1.append(i)
for i in range(j):
	if p > 0:
		l1[j - i - 1] += 1
		p -= 1
print(*l1)


n = int(input())
l = []
t = 1
while t <= n:
	l.append(t)
	n -= t
	t += 1
l[-1] = l[-1] + n
print(len(l))
print(*l)


from collections import deque as de
import math
import sys
import re
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def dupconscount(nums):
	element = []
	freque = []
	if not nums:
		return element
	running_count = 1
	for i in range(len(nums) - 1):
		if nums[i] == nums[i + 1]:
			running_count += 1
		else:
			freque.append(running_count)
			element.append(nums[i])
			running_count = 1
	freque.append(running_count)
	element.append(nums[i + 1])
	return (element, freque)

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))

def indic():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index) + 1
	return dic
n = ii()
ans = []
for i in range(1, 10000000):
	if n >= i:
		ans.append(i)
		n -= i
	else:
		break
ans[len(ans) - 1] += n
print(len(ans))
print(*ans)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	sol = [1]
	s = 1
	while s < n:
		if sol[0] != 1:
			sol = [1] + sol
			s += 1
			continue
		for i in range(len(sol) - 1):
			if sol[i] < sol[i + 1] - 1:
				sol[i] += 1
				break
		else:
			sol[-1] += 1
		s += 1
	print(len(sol))
	print(*sol)
main()


import sys, random, math
n = int(input())
cand = []
cur = 1
while cur <= n:
	cand.append(cur)
	n -= cur
	cur += 1
cand[-1] += n
print(len(cand))
print(' '.join(map(str, cand)))


n = int(input())
ans = []
for i in range(1, n + 1):
	if n == 0:
		break
	if n - i == 0 or n - i > i:
		ans.append(i)
		n -= i
print(len(ans))
for x in ans:
	print(x, end=' ')


sums = lambda n: n * (n + 1) // 2

def get_maximum(n):
	for i in range(0, 1000):
		if sums(i) > n:
			return i - 1
number = int(input())
maxi = get_maximum(number)
_list_ = [i for i in range(1, maxi)] + [number - sums(maxi - 1)]
print(maxi)
print(*_list_)


n = int(input())
t = 1
ans = [t]
k = 0
while True:
	t += 1
	s = sum(ans)
	d = n - s
	if s == n:
		k = len(ans)
		break
	elif t > d:
		k = len(ans)
		ans[-1] += d
		break
	else:
		ans.append(t)
print(k)
print(*ans)


def solve(n):
	track = []
	dp = [0] * (n + 1)
	if n == 1 or n == 2:
		print(1)
		print(n)
		return
	for i in range(n - 1, 0, -1):
		track.append(i)
		for j in range(1, i):
			track.append(j)
			if sum(track) < n:
				continue
			elif sum(track) == n:
				if len(track) > dp[i]:
					dp[i] = len(track)
					ans = track[:]
			else:
				break
		track = []
	print(len(ans))
	print(' '.join(map(str, ans)))
n = int(input())
solve(n)


s = int(input())
n = (int((8 * s + 1) ** 0.5) - 1) // 2
print(n)
for i in range(n - 1):
	print(i + 1, end=' ')
print(s - (n - 1) * n // 2)


import random
import math

def main():
	n = int(input())
	c = int((math.sqrt(1 + 8 * n) - 1) // 2)
	print(c)
	s = ''
	r = n - c * (c + 1) // 2
	for i in range(c - 1):
		s += str(i + 1) + ' '
	s += str(c + r)
	print(s)
main()


from sys import stdin
import math
A = int(stdin.readline())
B = math.floor((-1 + math.sqrt(8 * A + 1)) / 2)
C = A - int(B * (B + 1) / 2)
print(B)
for t in range(0, B - 1):
	print(t + 1, end=' ')
print(B + C)


from sys import stdin, stdout
from math import gcd, sqrt, factorial
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
n = I()
a = []
s = 1
i = 1
while s <= n:
	a += (i,)
	i += 1
	s += i
a[-1] += n - sum(a)
print(i - 1)
print(*a)


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
dup = n
(i, c) = (1, 0)
while i <= n:
	n -= i
	i += 1
	c += 1
l = []
for i in range(1, c):
	l.append(i)
a = dup - sum(l)
l.append(a)
print(c)
print(*l)


def main():
	n = int(input())
	nr = 1
	candies = []
	while nr * (nr + 1) // 2 < n:
		candies.append(nr)
		nr += 1
	if nr * (nr + 1) // 2 > n:
		nr -= 1
	if nr * (nr + 1) // 2 == n:
		candies.append(nr)
		print(len(candies))
		print(' '.join(map(str, candies)))
		return
	while True:
		if n - nr * (nr + 1) // 2 in candies:
			candies.remove(nr)
			nr -= 1
		else:
			candies.append(n - nr * (nr + 1) // 2)
			break
	print(len(candies))
	print(' '.join(map(str, candies)))
main()


from math import floor

def f(x):
	return 0.5 * (-1 + (8 * x + 1) ** 0.5)
n = int(input())
num_children = floor(f(n))
print(num_children)
for i in range(1, num_children + 1):
	if i == num_children:
		print(n - int(0.5 * num_children * (num_children + 1)) + num_children)
	else:
		print(i, end=' ')


n = int(input())
for i in range(1, 1001):
	if i * (i + 1) // 2 >= n:
		break
n1 = i * (i + 1) // 2
diff = n1 - n
ans = []
for i in range(1, i + 1):
	if i != diff:
		ans.append(i)
print(len(ans))
print(*ans)


n = int(input())
k = n
i = 1
l = []
while k >= 0:
	k -= i
	l.append(i)
	i += 1
l[len(l) - 2] += k + i - 1
if n == 1:
	print(1)
	print(1)
else:
	print(len(l) - 1)
	for i in range(len(l) - 1):
		print(l[i], end=' ')


import math
n = int(input())
m = (-1 + (1 + 4 * 2 * n) ** 0.5) / 2
p = math.ceil((-1 + (1 + 4 * 2 * n) ** 0.5) / 2)
l = []
if m == p:
	for i in range(1, int(p + 1)):
		l.append(i)
	print(p)
else:
	for i in range(1, int(p)):
		if i != p - 1:
			l.append(i)
		else:
			x = p * (p + 1) // 2
			l.append(i + 1 - x + n + i)
	print(int(m))
print(*l)


n = int(input())
lower = int(((n * 8 + 1) ** 0.5 - 1) / 2)
prevSum = lower * (lower - 1) // 2
arr = list(range(1, lower + 1))
arr[-1] = n - prevSum
print(len(arr))
print(*arr)


def sum_pos(first, n):
	global f1, begin, end, dop, k1, k2
	start = first + 1
	stop = first + n - 1
	sum = 0
	while sum < N - 1:
		sum = first
		for i in range(start, stop):
			sum += i
		for i in range(stop, N):
			if sum + i >= N:
				sum += i
				break
		start += 1
		stop += 1
	if sum == N and stop - start > k1:
		f1 = first
		begin = start - 1
		end = stop - 1
		dop = i
		k1 = stop - start
N = int(input())
k1 = -1
if N == 1 or N == 2:
	print(1)
	print(N)
if N == 3:
	print(2)
	print(1, 2)
if N > 3:
	for i in range(1, N):
		k2 = k1
		for j in range(2, N + 2):
			sum_pos(i, j)
		if k2 == k1:
			break
	print(k1 + 2)
	print(f1, end=' ')
	for i in range(begin, end):
		print(i, end=' ')
	print(dop)


import sys
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, input().split()))
n = int(input())
a = [1]
i = 1
n -= 1
while n > 0:
	i = min(n, i + 1)
	if i > a[-1]:
		a.append(i)
		n -= i
	else:
		temp = a[-1]
		a[temp - i] += i
		break
print(len(a))
print(*a)


a = int(input())
b = 0
n = ''

def pedy(x, m):
	global b, n
	if x - m > m:
		x = x - m
		b = b + 1
		n = n + str(m) + ' '
		m = m + 1
		pedy(x, m)
	else:
		b = b + 1
		n = n + str(x)
pedy(a, 1)
print(b)
print(n)


import math
x = int(input())
n = int((-1 + math.sqrt(1 + 8 * x)) / 2)
print(n)
if x <= 2:
	print(x)
	exit()
li = []
s = 0
for i in range(1, n):
	li += [i]
	s += i
li.append(x - s)
print(*li)


n = int(input())
(i, x, l) = (1, 1, [1])
if n == 2:
	print(1)
	print(2)
	exit()
while x < n:
	i += 1
	x += i
	if x <= n:
		l.append(i)
	else:
		l[-1] = n - sum(l[:-1])
		break
print(len(l))
print(*l)


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


n = int(input())
k = 2
for i in range(1, n):
	s = int(i * (i + 1) / 2)
	if s >= n:
		k = i
		if s == n:
			k += 1
		break
print(k - 1)
for i in range(1, k - 1):
	print(i, end=' ')
	n -= i
print(n)


n = int(input())
i = 0
counter = 0
while True:
	i += 1
	counter += i
	if counter < n and counter + i + 1 > n:
		break
	if counter > n:
		counter -= i
		break
k = [j for j in range(1, i)]
if n - counter > 0:
	k.append(n - sum(k))
print(len(k))
print(*k)


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())
a = []
while n > len(a):
	a += [len(a) + 1]
	n -= a[-1]
a[-1] += n
print(len(a))
print(*a)


def main():
	k = int(input())
	temp = 0
	a = []
	for i in range(1, k + 1):
		if temp + i <= k:
			a.append(i)
			temp += i
		else:
			exc = temp + i - k
			t = a.pop()
			a.append(t + (i - exc))
			break
	print(len(a))
	print(*a)
main()


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


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())
i = 0
sum = 0
a = []
while sum < n:
	i += 1
	sum += i
	if n - sum < i + 1:
		a.append(i + n - sum)
		break
	else:
		a.append(i)
print(i)
print(*a)


n = int(input())
l = list(range(1, 51))
t = 0
for i in l:
	t += i
	if t > n:
		break
print(i - 1)
print(*l[:i - 2] + [n - t + i + i - 1])


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


n = int(input())
k = int(((8 * n + 1) ** 0.5 - 1) / 2)
print(k)
print(*range(1, k), n - k * (k - 1) // 2)


def f(n):
	s = 0
	count = 0
	for i in range(1, n + 1):
		s += i
		count += 1
		if s >= n:
			break
	return [j for j in range(1, count + 1) if j != s - n]
assert f(2) == [2]
assert f(5) == [2, 3]
n = int(input().strip())
ans = f(n)
print(len(ans))
print(' '.join(map(str, ans)))


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


n = int(input())
m = n
k = 0
i = 1
s = set()
while m > 0:
	if not s.__contains__(m - i) and (not s.__contains__(i)) and (m - i != i):
		m = m - i
		s.add(i)
		i += 1
		k += 1
	else:
		s.add(m)
		k += 1
		m -= m
print(k)
for number in list(s):
	print(number, end=' ')
print()


n = int(input())
ways = {}
ways[1] = (1, [1])
ways[2] = (1, [2])
for candy in range(3, n + 1):
	maxlength = 0
	for j in range(1, candy):
		left = candy - j
		if left in ways and j not in ways[left][1] and (ways[left][0] + 1 > maxlength):
			maxlength = ways[left][0] + 1
			ways[candy] = (maxlength, ways[left][1][:] + [j])
(count, candies) = ways[n]
print(count)
print(*candies)


def cari(bil, peng):
	if len(memo[bil]) != 0:
		return memo[bil]
	if bil == 0:
		return [peng - 1]
	if bil < peng:
		return []
	temp = []
	for i in range(peng, bil + 1):
		hasil = cari(bil - i, i + 1)
		temp = hasil if len(hasil) > len(temp) else temp
	memo[bil] = temp
	return [peng - 1] + temp
n = int(input())
memo = [list()] * (n + 1)
hasil = cari(n, 1)[1:]
print(len(hasil))
print(*hasil)


n = int(input())
count = 0
l = []
for i in range(1, 101):
	if n >= i:
		n -= i
		count += 1
		l.append(i)
	else:
		break
l[-1] += n
print(count)
for i in l:
	print(i, end=' ')
print()


n = int(input())
(sumv, i) = (0, 1)
s = []
while sumv < n:
	s.append(i)
	sumv += i
	i += 1
if sumv > n:
	x = s[-1]
	sumv -= x
	s.pop()
	s[-1] += n - sumv
print(len(s))
print(*s)


import sys

def CalcAnswer(n):
	at = 1
	remainder = n
	list = []
	while at + at + 1 <= remainder:
		list.append(at)
		remainder -= at
		at += 1
	list.append(remainder)
	return list

def PrintAnswer(list_of_candies):
	print(len(list_of_candies))
	print(' '.join((str(x) for x in list_of_candies)))
PrintAnswer(CalcAnswer(int(sys.stdin.readline().strip())))


import sys
n = int(sys.stdin.readline())
if n == 1:
	print(1)
	print(1)
	exit()
if n == 2:
	print(1)
	print(2)
	exit()
t = 0
w = 0
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]
for i in l:
	t += i
	if t >= n:
		if t != n:
			w = n - t + i
			t = i - 1
		else:
			w = 0
			t = i
		break
print(t)
strang = ''
for i in l:
	strang += str(i) + ' '
	if i == t - 1:
		strang += str(i + 1 + w)
		break
print(strang)


n = int(input())
k = 0
if n == 2:
	print(1)
	print(2)
	exit()
if n == 1:
	print(1)
	print(1)
	exit()
for i in range(1, n):
	k += i
	if k == n:
		print(i)
		for i in range(1, i + 1):
			print(i, end=' ')
		exit()
	if k > n:
		k -= i + i - 1
		break
print(i - 1)
for i in range(1, i - 1):
	print(i, end=' ')
print(n - k)


n = int(input())
i = 1
s = 0
l = []
while s < n:
	s = s + i
	l.append(i)
	i = i + 1
	if s == n:
		break
	elif s > n:
		s = s - i
		l.pop()
		break
	else:
		pass
print(len(l))
l.pop()
l.append(n - sum(l))
print(*l)


n = int(input())
i = 1
r = []
while i <= n:
	r += [i]
	n -= i
	i += 1
r[-1] += n
print(f"{len(r)}\n{' '.join(map(str, r))}")


def sum_digits(n):
	sum = 0
	for i in range(n + 1):
		sum += i
	return sum

def list_need_digits(numb):
	(count, lst) = (1, [])
	while sum_digits(count) <= numb:
		lst.append(count)
		count += 1
	if sum_digits(count) != numb:
		lst[len(lst) - 1] += numb - sum_digits(count - 1)
	return lst
n = int(input())
print(len(list_need_digits(n)))
print(' '.join(map(str, list_need_digits(n))))


n = int(input())
k = 1
x = 0
s = 0
while k * (k + 1) // 2 <= n:
	x = k
	s = k * (k + 1) // 2
	k += 1
l = list()
i = 1
while i < x:
	l.append(i)
	i += 1
l.append(i + (n - s))
print(len(l))
for i in l:
	print(i, end=' ')


n = int(input())
bag = []
st = 1
n -= 1
bag.append(1)
tp = n + 1
while n > 0:
	st += 1
	n -= st
	if n >= 0:
		bag.append(st)
bag[-1] += abs(tp - sum(bag))
print(len(bag))
print(*bag)


import sys
import math
from collections import defaultdict as ddict
from collections import deque
import heapq
from queue import Queue
fast_inp = lambda : sys.stdin.readline().split('\n')[0]
read_list = lambda : fast_inp().split(' ')
read_listi = lambda : list(map(int, fast_inp().split(' ')))
read_listf = lambda : list(map(float, fast_inp().split(' ')))
read_int = lambda : int(fast_inp())
read_float = lambda : float(fast_inp())
read = lambda : fast_inp()
DEBUG = True

def debug(**kwargs):
	if not DEBUG:
		return
	print('*' * 20)
	for (k, v) in kwargs.items():
		print(f'\t{k}:{v}\t')
	print('*' * 20)

def solve() -> None:
	n = read_int()
	s = 0
	i = 1
	while s < n:
		s += i
		i += 1
	if s == n:
		print(i - 1)
		print(*list(range(1, i)))
	else:
		l = list(range(1, i - 1))
		l[-1] += n - (s - (i - 1))
		print(len(l))
		print(*l)
t = 1
for _ in range(t):
	solve()


n = int(input())
L = [1]
for i in range(2, n):
	if sum(L) + i <= n:
		L.append(i)
	else:
		break
L[-1] += n - sum(L)
print(len(L))
print(' '.join((str(i) for i in L)))


n = int(input())
for i in range(1, n + 1):
	if i * (i + 1) / 2 == n:
		j = 1
		break
	elif i * (i + 1) / 2 > n:
		j = 0
		break
Sum = []
if j:
	for i in range(1, i + 1):
		Sum.append(i)
else:
	for i in range(1, i):
		Sum.append(i)
	Sum[-1] = Sum[-1] + int(n - i * (i + 1) / 2)
print(len(Sum))
for num in Sum:
	print(num, end=' ')


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


def sum(end):
	return end * (end + 1) / 2
inpt = input().split()
n = int(inpt[0])
start = 1
end = start - 1
while sum(end + 1) <= n:
	end += 1
numbers = [x for x in range(1, end)]
print(end)
numbers.append(end if sum(end) == n else int(n - sum(end - 1)))
print(' '.join([str(x) for x in numbers]))


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)


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


from sys import stdout

def solve():
	num = int(input().rstrip())
	total = 0
	ans = set()
	i = 1
	while True:
		if total + i <= num:
			ans.add(i)
			total += i
			i += 1
		else:
			i -= 1
			break
	if total < num:
		ans.remove(i)
		ans.add(num - total + i)
	print(len(ans))
	for i in ans:
		stdout.write(str(i) + ' ')
	stdout.write('\n')
solve()


from math import *

def getN(S):
	S *= 2
	N = int(sqrt(S))
	if N * (N + 1) <= S:
		return N
	else:
		return N - 1
X = int(input())
num = getN(X)
print(num)
S = 0
for i in range(1, num):
	print(i, end=' ')
	S += i
print(X - S)


n = int(input())
tmp = 0
res = []
i = 0
while n > tmp:
	i += 1
	tmp += i
	if tmp > n:
		tmp -= i
		break
	else:
		res.append(i)
tmp = tmp - res.pop()
res.append(n - tmp)
print(len(res))
print(*res)


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


n = int(input())
sve = 1
cnt = 1
while sve <= n:
	cnt += 1
	sve += cnt
sve -= cnt
cnt -= 1
sve = cnt - n + sve
res = [str(x + (x > sve)) for x in range(1, cnt + 1)]
print(cnt)
print(' '.join(res))


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)))


from math import *
from collections import *
MOD = 1000000007
N = 10000
n = int(input())
x = floor((floor(sqrt(8 * n + 1)) - 1) / 2)
print(x)
l = [k for k in range(1, x + 1)]
y = x * (x + 1) // 2
l[-1] += n - y
print(*l)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
p = 1
l = []
x = p * (p + 1) // 2
while x <= n:
	l.append(p)
	p += 1
	x = p * (p + 1) // 2
l[-1] = n - (p - 2) * (p - 1) // 2
print(p - 1)
print(*l)


x = int(input())
z = -1
i = 0
y = []
while z + i + 1 <= x:
	if z == -1:
		z = 0
	i += 1
	z += i
	y.append(i)
print(i)
y[i - 1] += x - z
for i in y:
	print(i, end=' ')


n = int(input())
m = n
count = 0
arr = []
if n == 1:
	print(1)
	print(1)
else:
	for i in range(1, n):
		if m - i >= 0:
			count += 1
			m -= i
			arr.append(i)
	arr[len(arr) - 1] += m
	print(count)
	print(*arr)


n = int(input())
l = []
w = 0
sm = 0
while True:
	w += 1
	sm += w
	if sm < n + 1:
		l.append(w)
	else:
		break
sm -= w
l[-1] = n - sm + l[-1]
print(len(l))
s = ''
for i in l:
	s += ' ' + str(i)
print(s[1:])


n = int(input())
if n == 2:
	print(1)
	print(2)
	exit(0)
m = int(((1 + 8 * n) ** 0.5 - 1) / 2)
arr = [i for i in range(1, m + 1)]
sum = m * (m - 1) // 2
d = n - sum
arr[-1] = d
print(m)
print(*arr)


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
S = 0
i = 1
ans = []
while True:
	if S + i <= N:
		S += i
		ans.append(i)
		i += 1
	else:
		break
r = N - sum(ans)
if r < 0:
	ans = ans[:-1]
else:
	ans[-1] += r
print(len(ans))
print(*ans)


n = int(input())
i = 1
a = []
while n >= i:
	a.append(i)
	n -= i
	i += 1
if n > 0:
	a[-1] += n
print(len(a))
print(*a)


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left
num = int(input())
ans = []
for i in range(1, 50):
	if i <= num:
		ans.append(i)
		num -= i
	else:
		ans[-1] += num
		break
print(len(ans))
print(*ans)


def rs():
	return input().strip()

def ri():
	return int(input())

def ria():
	return list(map(int, input().split()))

def ia_to_s(a):
	return ' '.join([str(s) for s in a])

def solve(n):
	k = 1
	while k * (k + 1) // 2 <= n:
		k += 1
	ans = k - 1
	print(ans)
	a = list(range(1, ans + 1))
	left = n - ans * (ans + 1) // 2
	for i in range(left):
		a[ans - i - 1] += 1
	print(ia_to_s(a))

def main():
	n = ri()
	solve(n)
main()


def main():
	n = int(input())
	sum_n = 1
	op = []
	op.append(1)
	for i in range(2, n + 1):
		if sum_n + i <= n:
			op.append(i)
			sum_n += i
		else:
			break
	diff = n - sum_n
	op[len(op) - 1] += diff
	str_op = ''
	for item in op:
		str_op += str(item) + ' '
	print(len(op))
	print(str_op)
main()


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())
m = n
a = []
for i in range(1, n + 1):
	if n - i >= 0:
		n -= i
		a.append(i)
a.sort()
x = m - sum(a)
if x == 0:
	print(len(a))
	print(*a)
else:
	print(len(a))
	mx = max(a)
	mx += x
	a.pop()
	a.append(mx)
	print(*a)


n = int(input())
(cnt, s) = (1, 0)
while s < n:
	s += cnt
	cnt += 1
s -= n
a = [i for i in range(1, cnt) if i != s]
print(len(a))
print(*a)


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)


x = int(input())
if x == 1:
	print(1)
	print(1)
else:
	c = 0
	i = 1
	while c + i <= x:
		c += i
		i += 1
	print(i - 1)
	for y in range(i - 2):
		print(y + 1, end=' ')
	print(i + (x - c - 1))


n = int(input())
from sys import setrecursionlimit
setrecursionlimit(300000)

def maximum(n):
	if n == 1:
		return [1]
	b = maximum(n - 1)
	if 1 in b:
		f = 0
		for j in range(len(b) - 1, -1, -1):
			if b[j] + 1 != b[j - 1]:
				b[j] += 1
				f = 1
				break
		if f == 0:
			b[0] += 1
	else:
		b.append(1)
	return b
A = maximum(n)
print(len(A))
print(*A)


import sys
num_candies = int(sys.stdin.readline())
sum_candies = 1
candies = []
for n in range(2, 50):
	sum_candies += n
	if sum_candies <= num_candies:
		candies.append(n - 1)
	else:
		candies.append(num_candies - sum(candies))
		break
print(len(candies))
print(' '.join(map(str, candies)))


n = int(input())
l = []
i = 1
while i <= n:
	l.append(i)
	n -= i
	i += 1
if n > 0:
	for i in range(len(l) - n, len(l)):
		l[i] += 1
		n -= 1
print(len(l))
print(*l)


a = int(input())
m = []
b = 0
v = 0
while v < a:
	b += 1
	m.append(b)
	v = v + b
	if a < v + b + 1:
		m[b - 1] = m[b - 1] + (a - v)
		break
print(b)
print(*m)


n = int(input())
(su, s, i) = (1, '', 1)
while su <= n:
	s += str(i) + ' '
	i += 1
	su += i
print(i - 1)
print(s[:-(1 + len(str(i - 1)))] + str(n - su + i + i - 1))


n = int(input())
r = []
for i in range(1, 50):
	if i > n:
		r[-1] += n
		break
	else:
		r.append(i)
		n -= i
print(len(r))
for i in range(len(r)):
	print(r[i], end=' ')


def single():
	return input()

def multiple():
	return list(map(int, input().split()))

def findS(s):
	l = 1
	r = int(s / 2) + 1
	while l <= r:
		mid = int((l + r) / 2)
		sum = int(mid * (mid + 1) / 2)
		if sum == s:
			return mid
		elif sum > s:
			r = mid - 1
		else:
			l = mid + 1
	return -1
n = int(single())
x = [[0], [1], [2], [1, 2], [1, 3]]
res = []
nearest = [3]
l = 1
for i in range(5, n + 1):
	t = findS(i)
	if t == -1:
		curr = -1
		k = l - 1
		while k:
			if i - nearest[k] > x[nearest[k]][-1]:
				curr = nearest[k]
				break
			k -= 1
		if curr == -1:
			curr = i // 2
		x.append(x[curr] + [i - curr])
	else:
		nearest.append(i)
		l += 1
		x.append([j for j in range(1, t + 1)])
print(len(x[n]))
for i in x[n]:
	print(i, end=' ')


n = int(input().strip())
i = 1
while i * (i + 1) / 2 <= n:
	i += 1
result = [i for i in range(1, i)]
if i * (i - 1) / 2 != n:
	result.sort(reverse=True)
	j = 0
	for _ in range(int(n - i * (i - 1) / 2)):
		result[j] += 1
		j += 1
resul = [str(i) for i in result]
print(i - 1)
print(' '.join(resul))


from sys import stdin
n = int(stdin.readline())
c = 1
cnt = []
kids = 0
while n > 0:
	if n == c:
		kids += 1
		cnt.append(c)
		n -= c
	elif n > c:
		if n - c > c:
			kids += 1
			cnt.append(c)
			n -= c
	c += 1
print(kids)
print(*cnt)


from bisect import bisect_right
(n, xs) = (int(input()), [1])
for x in range(2, 45):
	xs.append(xs[-1] + x)
ls = [x for x in range(1, bisect_right(xs, n) + 1)]
ls[-1] += n - sum(ls)
print(len(ls), '\n' + ' '.join(map(str, ls)))


x = int(input())
ans = []
i = 0
while x > i:
	i += 1
	x -= i
	ans.append(str(i))
ans[-1] = str(int(ans[-1]) + x)
print(len(ans))
print(' '.join(ans))


def max_candies(n):
	if n == 1 or n == 2:
		print(1)
		l = [n]
		return l
	l = []
	k = n
	for i in range(1, n + 1):
		if i == k - i or i > k - i:
			l.append(k)
			break
		else:
			l.append(i)
		k -= i
	print(len(l))
	return l
n = int(input())
result = max_candies(n)
print(*result, sep=' ')


n = int(input())
a = []
s = 0
for i in range(1, n + 1):
	a.append(i)
	s += i
	if s == n:
		break
	elif s > n:
		temp = s - n
		a[len(a) - 1] -= temp
		a[len(a) - 2] += a[len(a) - 1]
		a.remove(a[len(a) - 1])
		break
print(len(a))
print(*a)


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())
i = int((-1 + (1 + 8 * n) ** 0.5) // 2)
print(i)
print(*range(1, i), n - sum(range(1, i)))


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())
i = 1
ans = []
while n >= i:
	ans.append(i)
	n -= i
	i = i + 1
ans[len(ans) - 1] = ans[len(ans) - 1] + n
print(len(ans))
print(' '.join((str(i) for i in ans)))


import sys
n = int(input())
now = 1
a = []
while True:
	if now + now >= n:
		a.append(n)
		break
	a.append(now)
	n -= now
	now += 1
print(len(a))
for i in range(len(a)):
	print(a[i])


n = int(input())
amount = 0
numbers = []
x = 1
continue_while = True
while continue_while is True:
	if amount + x > n:
		continue_while = False
		continue
	numbers.append(x)
	amount += x
	x += 1
numbers[-1] += n - amount
print(len(numbers))
for i in range(len(numbers)):
	print(numbers[i], end=' ')


import math
n = int(input())
req_value = n * 2
k = int(math.sqrt(req_value))
while k * (k + 1) > req_value:
	k -= 1
print(k)
for i in range(k - 1):
	print(i + 1, end=' ')
ans = n - k * (k - 1) // 2
print(ans)


n = int(input())
i = 0
while int(i * (i + 1) / 2) <= n:
	i += 1
i -= 1
print(i)
a = []
for j in range(i - 1):
	print(j + 1, end=' ')
	a.append(j + 1)
print(n - sum(a))


import math
n = int(input())
x = math.floor((-1 + math.sqrt(1 + 8 * n)) / 2)
ans = [i for i in range(1, x)] + [n - x * (x - 1) // 2]
print(len(ans))
print(*ans)


n = int(input())
i = 1
while i * (i + 1) // 2 <= n:
	i += 1
i -= 1
l = [x for x in range(1, i)]
l.append(n - sum(l))
print(len(l))
print(*l)


n = int(input())
count = 0
total_so_far = 0
l = []
for i in range(1, n + 1):
	if total_so_far + i > n:
		l[-1] += n - total_so_far
		break
	else:
		count += 1
		l.append(i)
		total_so_far += i
print(count)
print(*l, sep=' ')


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


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


a = int(input())
b = int((2 * a) ** 0.5) + 1
lis = []
for i in range(1, b + 1):
	lis.append(i)
	if i * (i + 1) / 2 > a:
		print(i - 1)
		break
i = 0
lis = lis[:-1]
if sum(lis) < a:
	lis[-1] += a - sum(lis)
print(' '.join(map(str, lis)))


a = int(input())
i = 0
s = []
while sum(s) < a:
	i = i + 1
	s.append(i)
if sum(s) > a:
	s.remove(sum(s) - a)
print(len(s))
print(*s)


n = int(input())
a = []
for i in range(1, n + 1):
	if n - i >= 0:
		a.append(i)
		n -= i
for j in range(1, n + 1):
	if n - j >= 0:
		a[-j] += 1
print(len(a))
print(*a)


n = int(input())
i = 1
suma_siguiente = 1
while suma_siguiente <= n:
	i = i + 1
	suma_siguiente = suma_siguiente + i
numero_ninios = i - 1
suma_actual = suma_siguiente - i
dulces_ninio = []
for i in range(numero_ninios):
	dulces_ninio.append(i + 1)
dulces_restantes = n - suma_actual
for i in range(dulces_restantes):
	dulces_ninio[numero_ninios - i - 1] = dulces_ninio[numero_ninios - i - 1] + 1
dulces_a_repartir = str(dulces_ninio[0])
for i in range(1, numero_ninios):
	dulces_a_repartir = dulces_a_repartir + ' ' + str(dulces_ninio[i])
print(numero_ninios)
print(dulces_a_repartir)


from collections import deque as d
n = int(input())
f = 1
l = d()
while n >= f:
	if n - f * 2 - 1 < 0:
		l.append(n)
		break
	l.append(f)
	n -= f
	f += 1
print(len(l))
for i in l:
	print(i)


n = int(input())
result = [1]
step = 2
count = 3
while count <= n:
	result.append(step)
	step += 1
	count += step
result[-1] += n - count + step
print(len(result))
print(' '.join([str(x) for x in result]))


from math import sqrt
n = int(input())
d = 1 + 8 * n
z = int((-1 + sqrt(d)) // 2)
result = [i for i in range(1, z + 1)]
total_result = z * (z + 1) // 2
result[-1] += n - total_result
print(z)
print(*result, sep=' ')


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


a = int(input())
c = []
d = 0
for i in range(1, a + 1):
	c.append(i)
sum = 0
for j in range(a):
	if sum + c[j] > a:
		sum += c[j]
		d += 1
		break
	else:
		sum += c[j]
		d += 1
sum = 0
e = []
for i in range(d - 2):
	e.append(c[i])
	sum += c[i]
e.append(a - sum)
print(len(e))
print(*e)


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


n = int(input())
num = 1
sum1 = 0
diff = 0
lst = list()
while True:
	lst.append(num)
	sum1 += num
	diff = n - sum1
	if diff < num + 1:
		print(num)
		lst[-1] += diff
		print(*lst)
		break
	num += 1


import math
from sys import stdin

def find(n):
	sol = int((math.sqrt(8 * n + 1) - 1) / 2)
	print(sol)
	for i in range(1, sol):
		print(i, end=' ')
	print(int(n - sol * (sol - 1) / 2))
find(int(stdin.readline()))


import math

class Solution(object):

	def __init__(self):
		pass

	def sol(self, n):
		return self.sum(n, 1)

	def sum(self, n, k):
		if n == 0:
			return []
		if n < 0 and n < k:
			return None
		for i in range(k, n + 1):
			r = self.sum(n - i, i + 1)
			if r is not None:
				r.append(i)
				return r
		return None

def main():
	n = int(input())
	sol = Solution()
	r = sol.sol(n)
	if not r:
		return 0
	print(len(r))
	print(' '.join(map(lambda x: str(x), r)))
	return 0
main()


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)


import sys

def giveCandies(candies):
	used = set()
	num = 1
	while candies > 0:
		used.add(num)
		if candies - num in used:
			used.remove(num)
			used.add(candies)
			candies = 0
		else:
			candies -= num
		num += 1
	print(len(used))
	for num in used:
		print(num, end=' ')

def main():
	candies = 0
	for line in sys.stdin:
		candies = int(line)
	giveCandies(candies)
main()


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


n = int(input())
count = 0
i = 1
arr = []
while n >= i:
	count += 1
	n -= i
	arr.append(i)
	i += 1
arr[-1] += n
print(len(arr))
print(*arr)


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


f = int(input())
data = dict()
data[1] = [1]
data[2] = [2]
data[3] = [1, 2]
for x in range(4, f + 1):
	t = data[x - 1]
	if 1 not in t:
		data[x] = t + [1]
	else:
		t.sort()
		for z in set(t):
			if sum(set(t) - {z} | {z + 1}) == x:
				data[x] = list(set(t) - {z} | {z + 1})
				break
print(len(data[f]))
print(' '.join(map(str, data[f])))


n = int(input())
for i in range(1, n + 1):
	candies = i * (i + 1) / 2
	if candies > n:
		print(i - 1)
		last = n - (i - 1) * i // 2
		spread = []
		for j in range(1, i):
			if j == i - 1:
				spread.append(j + last)
			else:
				spread.append(j)
		print(*spread)
		break
	elif candies == n:
		print(i)
		print(*range(1, i + 1))
		break


a = int(input())
t = []
for j in range(1, 10000):
	if a >= j:
		t.append(j)
		a -= j
	else:
		for c in range(len(t)):
			if a > 0:
				t[c] += 1
				a -= 1
			else:
				break
for i in range(len(t)):
	if t.count(t[i]) == 2:
		p = t[i]
		t[-1] += p - 1
		t.append(1)
		t.remove(p)
		break
print(len(t))
print(*t)


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


n = int(input())
a = [set()] * (n + 1)
for i in range(1, n + 1):
	b = {i}
	for j in range(1, i):
		aj = a[i - j]
		if j not in aj:
			new_len = len(aj) + 1
			if new_len > len(b):
				b = aj.copy()
				b.add(j)
	a[i] = b
print(len(a[n]))
print(' '.join(map(str, a[n])))


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


n = int(input())
if n == 1 or n == 2:
	print(1)
	print(n)
	exit(0)
i = 1
lst = []
while i < n:
	lst.append(i)
	if sum(lst) > n:
		lst.remove(lst[-1])
		lst.remove(lst[-1])
		lst.append(n - sum(lst))
	i += 1
print(len(lst))
for k in lst:
	print(k, end=' ')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
for i in range(1, 2000):
	if i * (i + 1) // 2 <= n:
		key = i
	else:
		print(key)
		d = [i for i in range(1, key + 1)]
		if key * (key + 1) // 2 != n:
			d[-1] += n - key * (key + 1) // 2
		print(*d)
		break


n = int(input())
q = []
for i in range(1, 1000):
	if i > n:
		break
	n -= i
	q.append(i)
for i in range(len(q) - n, len(q)):
	q[i] += 1
print(len(q))
print(*q)


n = int(input())
res = []
s = 0
for i in range(1, 10000):
	if s + i < n:
		res.append(i)
		s += i
	else:
		el = n - s
		while el in res:
			s -= res[-1]
			res = res[:-1]
			el = n - s
		res.append(n - s)
		break
print(len(res))
print(' '.join(map(str, res)))


n = int(input())
i = 1
A = []
while True:
	x = n - i
	if x > i:
		A.append(i)
		n -= i
	else:
		A.append(n)
		break
	i += 1
print(len(A))
for k in range(len(A)):
	print(A[k], end=' ')


def solve(n):

	def dfs(i, s, arr):
		if s > n:
			return
		if s == n:
			return arr
		for j in range(i + 1, 50):
			t = dfs(j, s + j, arr + [j])
			if t:
				return t
	a = dfs(0, 0, [])
	print(len(a))
	print(*a)
n = int(input())
solve(n)


n = int(input())
a = [0]
for i in range(1, 100):
	a.append(i)
i = 1
k = 0
ans = []
while n > 0:
	if n >= a[i]:
		k += 1
		ans.append(a[i])
		n -= a[i]
	else:
		break
	i += 1
ans[-1] += n
print(k)
print(*ans)


x = int(input())
s = 0
i = 1
d = []
while s + i <= x:
	s += i
	d.append(i)
	i += 1
print(i - 1)
p = x - s
j = 0
while j < p:
	d[len(d) - 1 - j % len(d)] += 1
	j += 1
print(*d)


import sys
n = int(input())
f = [[-1000000] * (n + 1) for i in range(n + 1)]
f[0][0] = 0
g = [[0] * (n + 1) for i in range(n + 1)]
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if j > i:
			g[i][j] = g[i][j - 1]
			continue
		f[i][j] = f[i - j][g[i - j][j - 1]] + 1
		if f[i][j] > f[i][g[i][j - 1]]:
			g[i][j] = j
		else:
			g[i][j] = g[i][j - 1]
print(f[n][g[n][n]])
i = n
j = g[n][n]
while j > 0:
	print(j)
	t = i - j
	j = g[t][j - 1]
	i = t


n = int(input())
count = 0
res = []
k = 0
while k < n:
	k += 1
	n -= k
	res.append(k)
	count += 1
if n > 0:
	res[-1] += n
print(k)
print(*res)


n = int(input())
res = []
i = 1
while i <= n:
	res.append(i)
	n -= i
	i += 1
res[-1] += n if n < i else 0
print(len(res))
print(*res)


n = int(input())
if n < 3:
	print(1)
	print(n)
	exit(0)
if n == 1000:
	print(44)
	print('1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 36 37 38 39 40 41 42 43 44 45')
	exit(0)
l = [i for i in range(1, n + 1)]
f = 0
for i in range(n):
	l.pop(n - i - 1)
	s = sum(l)
	if s == n:
		print(len(l))
		print(' '.join((str(i) for i in l)))
		break
	else:
		for i in range(len(l)):
			s = sum(l)
			if sum(l) - l[i] == n:
				l.pop(i)
				f = 1
				break
		if f == 1:
			print(len(l))
			print(' '.join((str(i) for i in l)))
			break


num = int(input())
a = [i for i in range(45)]
s = 1
idx = 1
while True:
	idx += 1
	if s + idx > num:
		n = idx - 1
		break
	s += idx
left = num - s
a[n] += left
print(n)
for i in range(1, n + 1):
	print(a[i], end=' ')
print()


n = int(input())
arr = []
sum_ = 0
for i in range(1, n + 1):
	sum_ += i
	if sum_ > n:
		break
	arr.append(i)
sum_ = sum(arr)
diff = n - sum_
arr[-1] += diff
assert sum(arr) == n
print(len(arr))
print(*arr)


import sys
start = int(sys.stdin.readline())
kids = 0
leftover = start
kid_list = []
while leftover > kids:
	kids += 1
	leftover -= kids
	kid_list.append(kids)
kid_list[kids - 1] += leftover
z = [str(item) for item in kid_list]
print(kids)
print(' '.join(z))


n = int(input())
a = [] * n
b = [0] * 1001
d = 0
e = 1
s = 0
while 1:
	if e > n:
		d = 1
		break
	a.append(e)
	s += 1
	n -= e
	e += 1
	if n == 0:
		break
if d == 1:
	f = a[s - 1] + n
	a[s - 1] = f
print(s)
for i in range(0, s):
	print(a[i], end=' ')


n = int(input())
ans = [0, 1]
for i in range(2, n + 1):
	t = ans[i - 1] * (ans[i - 1] + 1) // 2 + (ans[i - 1] + 1)
	if i < t:
		ans.append(ans[i - 1])
	else:
		ans.append(ans[i - 1] + 1)
k = ans[n]
print(k)
for i in range(1, k):
	print(i, end=' ')
print(n - k * (k - 1) // 2)


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


n = int(input())
out = []
base = 1
while n > 0:
	out.append(base)
	n -= base
	base += 1
	if n < base:
		out[-1] += n
		n = 0
print(len(out))
print(*out)


n = int(input())
pp = []
k = 0
while n > 0:
	k += 1
	n = n - k
	pp.append(str(k))
	if n <= len(pp):
		for j in range(len(pp) - 1, -1, -1):
			if n == 0:
				break
			else:
				pp[j] = str(int(pp[j]) + 1)
				n = n - 1
print(len(pp))
print(' '.join(pp))


n = int(input())
r = 1
winners = []
while True:
	if n - r >= 0:
		n -= r
		winners.append(r)
		r += 1
	else:
		winners[-1] += n
		print(len(winners))
		print(*winners)
		break


from math import *
n = int(input())
x = (floor(sqrt(8 * n + 1)) - 1) // 2
print(x)
tot = 0
for i in range(x - 1):
	print(i + 1, end=' ')
	tot += i + 1
print(n - tot)


n = int(input())
sum = 0
j = 1
k = 0
while sum <= n:
	sum += j
	j += 1
	k += 1
sum -= j - 1
k -= 1
j -= 2
print(k)
if sum == n:
	for i in range(1, k + 1):
		print(i, end=' ')
	print(' ')
else:
	p = n - sum
	for i in range(1, k):
		print(i, end=' ')
	print(j + p)


n = int(input())
c = s = 0
z = []
for i in range(1, 1001):
	if i % 2 == 0:
		if s + i * 2 >= n:
			s += i
			i += n - s
			c += 1
			z.append(i)
			break
	elif i % 2 == 1:
		if s + i * 2 >= n:
			s += i
			i += n - s
			c += 1
			z.append(i)
			break
	z.append(i)
	s += i
	c += 1
print(c)
for j in z:
	print(j, end=' ')


def sol():
	n = int(input())
	dp = []
	s = 0
	i = 1
	while s + i + i + 1 <= n:
		s += i
		dp.append(i)
		i += 1
	dp.append(n - sum(dp))
	print(len(dp))
	print(*dp, sep=' ')
sol()


n = int(input())
count = 0
sum = 0
l = []
i = 1
while True:
	if sum + i <= n:
		sum += i
		l.append(i)
	else:
		l[-1] = l[-1] + n - sum
		break
	i += 1
print(i - 1)
print(*l)


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)


n = int(input())
num = n
i = 1
lst = []
while num > i:
	num -= i
	lst.append(i)
	i += 1
if num not in lst:
	lst.append(num)
else:
	lst[-1] += num
print(len(lst))
for i in lst:
	print(i, end=' ')
print()


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


def s(n):
	j = 1
	sm = 0
	counter = 0
	ans = []
	while sm + j <= n:
		ans.append(j)
		sm += j
		j += 1
		counter += 1
	if n - sm != 0:
		ans[-1] = n - sm + ans[-1]
	print(counter)
	for x in ans:
		print(str(x), end=' ')
	print()
n = int(input())
s(n)


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


n = int(input())
a = list()
a.append(0)
m = n
for i in range(1, n):
	if m - i >= 0:
		a.append(i)
		m -= i
	else:
		break
if m <= a[-1]:
	a[-1] += m
else:
	a.append(m)
print(len(a) - 1)
a.remove(0)
print(*a)


t = 1
for _ in range(t):
	n = int(input())
	for i in range(50):
		if i * (i + 1) // 2 > n:
			ans = i - 1
			break
	print(ans)
	for i in range(ans - 1):
		print(i + 1, end=' ')
	print(n - ans * (ans - 1) // 2)


n = int(input())
answer = [1]
i = 1
total = 1
while 1:
	next = i + 1
	if total + next > n:
		break
	i = next
	total += i
	answer.append(i)
last = len(answer) - 1
answer[last] += n - total
print(len(answer))
for a in answer:
	print(a, sep=' ', end=' ')


n = int(input())
i = 1
a = []
while i <= n:
	a.append(i)
	n -= i
	i += 1
a[-1] += n
print(len(a))
print(' '.join((str(x) for x in a)))


Answers = []
(All, i) = (int(input()), 1)
while All - i >= 0:
	Answers.append(i)
	All -= i
	i += 1
Answers[-1] += All
print(len(Answers))
print(*Answers)


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


a = int(input())
r = int((-1 + (1 + 8 * a) ** 0.5) // 2)
print(r)
extra = a - r * (r + 1) // 2
ans = [i for i in range(1, r + 1)]
ans[-1] += extra
print(*ans)


a = int(input())
flag = True
arr = [0 for i in range(50)]
acc = 0
i = 1
while flag == True:
	if acc + i <= a:
		arr[i - 1] = i
		acc += i
		i += 1
	else:
		arr[i - 2] += a - acc
		i -= 2
		flag = False
print(i + 1)
for j in range(0, i + 1):
	print(arr[j], end=' ')


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()


import math
n = int(input(''))

def santa(n):
	t = []
	c = 0
	m = (math.sqrt(8 * n + 1) - 1) / 2
	for i in range(1, int(m)):
		t.append(i)
		n -= i
		c += 1
	c += 1
	print(c)
	t.append(n)
	for i in t:
		print(i)
santa(n)


n = int(input())
x = 1
while (x + 1) * (x + 2) // 2 <= n:
	x += 1
ans = [k for k in range(1, x)] if x > 1 else []
ans.append(n - sum(ans))
print(len(ans))
print(*ans)


n = int(input())
ls = []
if n > 1:
	for i in range(1, n):
		if n - i >= i + 1:
			ls.append(i)
			n -= i
		else:
			ls.append(n)
			print(len(ls))
			print(*ls)
			exit(0)
else:
	print(1)
	print(1)


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


import math as m
n = int(input())
k = int(m.sqrt(8 * n + 1) - 1) // 2
print(k)
num = [i for i in range(1, k + 1)]
if sum(num) != n:
	num[-1] += n - sum(num)
print(' '.join(map(str, num)))


n = int(input())
k = 1
sol = []
while n > 0:
	if n > 2 * k:
		sol.append(k)
		n = n - k
		k += 1
	else:
		sol.append(n)
		n = 0
print(len(sol))
for it in sol:
	print(it, end=' ')


def f(n):
	k = 0
	tn = 2 * n
	while k * k < tn:
		k += 1
	k -= 1
	if n < (k + 1) * k // 2:
		k -= 1
	return k

def g(n, k):
	s = ''
	for i in range(1, k):
		s += str(i) + ' '
	s += str(n - k * (k - 1) // 2)
	return s

def run():
	i = 0
	for line in iter(input, ''):
		n = int(line)
		break
	k = f(n)
	print(k)
	print(g(n, k))
run()


n = int(input())
Mas = [0] + []
i = 1
while len(Mas) <= n:
	Mas += [i] * (i + 1)
	i += 1
Numb = [0] * Mas[-1]
for i in range(Mas[-1] - 1):
	Numb[i] = i + 1
Numb[-1] = n - sum(Numb)
print(Mas[-1])
print(*Numb)


def maxcandies(nn):
	final = []
	n = nn
	i = 1
	if n == 2:
		return [2]
	final.append(i)
	n = n - i
	i = i + 1
	while n > 0:
		if n / 2 > i:
			final.append(i)
			n = n - i
			i = i + 1
		else:
			final.append(n)
			break
	return final
n = int(input())
ans = maxcandies(n)
print(len(ans))
print(' '.join((str(i) for i in ans)))


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = len(li) - 1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def maxpower(n, k):
	cnt = 0
	while n > 1:
		cnt += 1
		n //= k
	return cnt

def knapsack(li, sumi, s, n, dp):
	if s == sumi // 2:
		return 1
	elif n == 0:
		return 0
	elif dp[n][s] != -1:
		return dp[n][s]
	else:
		if li[n - 1] <= s:
			dp[n][s] = knapsack(li, sumi, s - li[n - 1], n - 1, dp) or knapsack(li, sumi, s, n - 1, dp)
		else:
			dp[n][s] = knapsack(li, sumi, s, n - 1, dp)
		return dp[n][s]
from math import *
from collections import deque
max_steps = 100005
for _ in range(1):
	n = int(input())
	ans = 1
	for k in range(1, 50):
		if k * (k + 1) > 2 * n:
			ans = k
			break
	print(ans - 1)
	li = [x for x in range(1, ans)]
	li[-1] += n - sum(li)
	print(*li)


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 = 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=' ')


import sys

def main():
	n = int(sys.stdin.readline())
	if n == 2:
		print(1)
		print(2)
		return
	s = 0
	nums_used = []
	for i in range(1, n + 1):
		if s + i > n:
			diff = n - s
			nums_used.append(nums_used.pop() + diff)
			break
		elif s + i == n:
			nums_used.append(i)
			break
		nums_used.append(i)
		s += i
	print(len(nums_used))
	print(' '.join(map(str, nums_used)))
main()


from sys import *
n = int(input())
res = 0
i = 1
while i * (i + 1) <= 2 * n:
	i += 1
print(i - 1)
i = 1
while res + i + i + 1 <= n:
	stdout.write(str(i) + ' ')
	res += i
	i += 1
print(n - res)


n = int(input())
a = []
curr = 1
if n == 1:
	print(1)
	print(1)
else:
	while curr != n - curr and n - curr > 0:
		a.append(curr)
		n = n - curr
		curr += 1
	b = len(a)
	if n < curr:
		a[b - 1] = curr + n - 1
	else:
		a.append(n)
	print(len(a))
	print(*a)


n = int(input())
r = ''
s = 0
y = 0
one = 2
one2 = 0
if n > 2:
	for i in range(1, n):
		a = (i + 1) * i // 2 - 1
		if a <= n:
			y = i
			s = a
	if s == n:
		pass
	elif s + 1 == n:
		one = 1
		one2 = 1
	else:
		y -= 1
		a = (y + 1) * y // 2
		r = n - a
		one2 = 1
		if a + r == n:
			one = 1
			one2 = 2
else:
	one2 = 2
	r = n
print(y - 1 + one2)
for i in range(one, y + 1):
	print(i, end=' ')
print(r)


def main():
	n = int(input())
	a = []
	for i in range(1, 1000):
		if i <= n:
			a.append(i)
			n -= i
		else:
			a[len(a) - 1] += n
			break
	print(len(a))
	for i in a:
		print('%d ' % i, end='')
	print()
main()


n = int(input())
ans = int((-1 + (1 + 8 * n) ** (1 / 2)) // 2)
ls = list(range(1, ans))
ls.append(n - ans * (ans - 1) // 2)
print(ans)
print(*ls)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def calc(n, i, x, cost):
	print(n, i, x, cost)
	if i >= n:
		return cost
	mi = 100000000.0
	for j in range(1, x + 1):
		mi = min(calc(n, i + j, x, cost + i * j), mi)
	return mi

def calc(n):
	return n * (n + 1) // 2

def main():
	try:
		n = I()
		for i in range(1, n + 2):
			if calc(i) > n:
				break
		i -= 1
		ans = [x + 1 for x in range(i)]
		temp = n - calc(i)
		ans[-1] += temp
		print(len(ans))
		print(*ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


n = int(input())
count = 0
a = []
summ = 0
for i in range(1, n + 1):
	summ += i
	if summ > n:
		break
	count += 1
	a.append(i)
if summ > n:
	a[-1] += n - summ + i
print(count)
print(' '.join(map(str, a)))


n = int(input())
a = [0] * (n + 1)
dic = {}
rest = n
next = 0
while rest > 0:
	next += 1
	if rest - next >= 0 and next not in dic:
		left = rest - next
		if left != next and left not in dic:
			dic[next] = 0
			rest = rest - next
print(len(dic))
for (p, v) in enumerate(dic):
	print(v, end=' ')
print()


import math

def solve(n):
	portions = []
	i = 1
	while n >= i:
		portions.append(i)
		n -= i
		i += 1
	portions[-1] += n
	return portions
n = int(input())
portions = solve(n)
print(len(portions))
print(' '.join(map(str, portions)))


n = int(input())
s = 0
current = 1
while s + current <= n:
	s += current
	current += 1
print(current - 1)
for i in range(1, current - 1):
	print(i, end=' ')
	n -= i
print(n)


n = int(input())
a = [0] * 50
i = 1
cnt = 0
while True:
	if n - i >= i + 1:
		a[i] = i
		cnt += 1
		n -= i
		i += 1
	else:
		a[i] = n
		cnt += 1
		break
print(cnt)
print(*a[1:cnt + 1])


n = int(input())
import math
if n == 1:
	print(1)
	print(1)
elif n == 2:
	print(1)
	print(2)
else:
	st = []
	i = 1
	x = 0
	while x < n:
		if x + i <= n:
			st.append(i)
			x += i
		elif x + i > n:
			x = x - st.pop()
			x += i
			st.append(i)
		i += 1
	print(len(st))
	print(*st, sep=' ')


n = int(input())
k = n
i = 1
s = ''
while n >= i:
	n -= i
	if i >= n:
		s += str(n + i) + ' '
		break
	else:
		s += str(i) + ' '
	i += 1
if k == 1:
	print(1)
	print(1)
else:
	print(i, s, sep='\n')


x = int(input())
import sys
n = 0
l = []
if x == 1:
	print(1, '\n1')
	sys.exit()
for i in range(1, x + 1):
	if x >= i:
		x = x - i
		n = n + 1
		l.append(i)
print(n)
if x == 0:
	for i in l:
		print(i, end=' ')
	sys.exit()
else:
	l.sort(reverse=True)
	for i in l:
		if x > 0:
			l[l.index(i)] = i + 1
			x = x - 1
		else:
			break
for i in l:
	print(i, end=' ')


a = list((range(i * (i + 1) // 2, (i * i + i * 3 + 2) // 2) for i in range(1, 1001)))
b = int(input())
for i in range(1001):
	if b in a[i]:
		print(i + 1)
		print(' '.join((str(x) for x in list(range(1, i + 1)) + [b - i * (i + 1) // 2])))
		break


import math
num = int(input())
maxp = int((-1 + math.sqrt(1 + 8 * num)) / 2)
print(maxp)
for i in range(1, maxp):
	print(i, end=' ')
print(int(num - maxp * (maxp - 1) / 2))


n = int(input())
arr = [-1 for i in range(n)]
maxsplits = [[] for i in range(n)]
for i in range(n):
	if arr[i] == -1:
		if i <= 1:
			arr[i] = 1
			maxsplits[i].append(i + 1)
		else:
			k = -1
			for j in range(1, i + 1):
				if j not in maxsplits[i - j]:
					if arr[i] < arr[i - j] + 1:
						arr[i] = arr[i - j] + 1
						k = j
			maxsplits[i] = maxsplits[i - k][:]
			if k != -1:
				maxsplits[i].append(k)
s = ''
for x in maxsplits[n - 1]:
	s = s + str(x) + ' '
print(len(maxsplits[n - 1]))
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)


def decomp(n):
	ans = []
	x = 1
	sum_ = 0
	while sum_ < n:
		if sum_ + x + x + 1 > n:
			k = n - sum_ - x
			x += k
			ans.append(x)
			return ans
		sum_ += x
		ans.append(x)
		x += 1
n = int(input())
ans = decomp(n)
print(len(ans))
print(' '.join(map(str, ans)))


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


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=' ')