Problem:
 Score : 300 points    Problem Statement The problem set at CODE FESTIVAL 20XX Finals consists of N problems.  The score allocated to the i -th (1≦i≦N) problem is i points.  Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.  As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him.  Determine the set of problems that should be solved.      Constraints  1≦N≦10^7       Partial Score  200 points will be awarded for passing the test set satisfying 1≦N≦1000 .  Additional 100 points will be awarded for passing the test set without additional constraints.         Input The input is given from Standard Input in the following format:  N       Output Among the sets of problems with the total score of N , find a set in which the highest score of a problem is minimum, then print the indices of the problems in the set in any order, one per line.  If there exists more than one such set, any of them will be accepted.        Sample Input 1 4      Sample Output 1 1
3  Solving only the 4 -th problem will also result in the total score of 4 points, but solving the 1 -st and 3 -rd problems will lower the highest score of a solved problem.       Sample Input 2 7      Sample Output 2 1
2
4  The set \{3,4\} will also be accepted.       Sample Input 3 1      Sample Output 3 1

Solution (Python):
n = int(input())
num = 0
for k in range(1,n+1):
    
    if k*(k+1) >=2*n:
        break
if k*(k+1) == 2*n:
    for i in range(k):
        print(i+1)
else:
    num = k*(k+1)//2-n
    
    for i in range(k):
        if i+1 == num:
            continue
        else:
            print(i+1)

Solution (Python):
from math import ceil

N = int(input())
n = ceil((-1 + (1+8*N)**(1/2))/2)
d = n*(n+1)/2 - N
for i in range(1, n+1):
  if i != d:
    print(i)

Solution (Python):
n=int(input())
for i in range(int((2*n)**0.5-3),n+2):
  if i*(i+1)//2==n:
    for j in range(1,i+1):
      print(j)
    break
  elif i*(i+1)//2>n:
    k=i*(i+1)//2-n
    for j in range(1,i+1):
      if j!=k:
        print(j)
    break

Solution (Python):
N = int(input())

if N <= 2:
    print(N)
else:
    s = 0
    l = []
    for i in range(1, N):
        s += i
        l.append(i)
        if s > N:
            break
    

    for i in range(len(l)):
        if s-l[i] == N:
            l.pop(i)
            break

    for i in l:
        print(i)

Solution (Python):
N = int(input())

ans = []
sm = 0
for i in range(1, N+1):
    sm += i
    ans.append(i)
    if sm >= N:
        exclusion = -1
        if sm-N != 0:
            exclusion = sm-N

        for a in ans:
            if a != exclusion:
                print(a)
        break

Solution (Python):

"""
Created on Fri Jun 12 20:20:11 2020

@author: NEC-PCuser
"""


N = int(input())

i = 1
li = []
while (N >= (i * (i + 1)) // 2):
    li.append(i)
    i += 1
    

value = (i - 1) * i // 2

index = len(li) - 1
for i in range(value, N):
    li[index] += 1
    index -= 1

for i in li:
    print(i)

Solution (Python):
def solve(N):
    ans_list = []
    for n in range(1,N+1):
        ans_list.append(n)
        if n * (n+1) // 2 == N:
            return ans_list
        elif n * (n+1) // 2 > N:
            ans_list.remove(sum(ans_list) - N)
            return ans_list
        else:
            continue

def main():
    N = int(input())

    ans = solve(N)
    for i in range(len(ans)):
        print(ans[i])

if __name__ == "__main__":
    main()

Solution (Python):
n,ans,i = int(input()),0,1
while ans<n:
    ans+=i
    i+=1

if ans==n:
    for j in range(i-1):
        print(j+1)
else:
    i-=1
    while i>=1:
        if n==0:
            break
        if n>=i:
            print(i)
            n-=i
        i-=1

Solution (Python):
import math
N = int(input())
ans = int((-1+math.sqrt(1+8*N))/2)

if (ans*(ans+1))//2<N:
  ans += 1

k = (ans*(ans+1))//2-N

if k == 0:
  for i in range(ans):
    print(i+1)
else:
  for i in range(ans):
    if i+1 != k:
      print(i+1)

Solution (Python):
n = int(input())
x = 0
ans = []

for i in range(1,10000000):
    x += i
    ans.append(i)
    if x >= n:
        break

if x != n:
    ans.remove(x-n)
  
for i in ans:
    print(i)

Solution (Python):
n=int(input())
i=0
point=0
while n>point:
    i+=1
    point+=i
noneed=point-n
for j in range(1,i+1):
    if j==noneed:
        continue
    print(j)

Solution (Python):
n=int(input())
s=0
l=[]
for i in range(1,n+1):
 s+=i
 l.append(i)
 if s>=n:
  for j in l:
   if j!=s-n:
    print(j)
  break

Solution (Python):
x=int(input())
a=0
t=1
ans=0
while a<x:
	a=a+t
	t=t+1
	ans=ans+1
for i in range(1,ans+1):
	if a-i!=x:
		print(i)

Solution (Python):
n = int(input())
total = 0
problems_to_solve = []
for i in range(1,n+1):
    total += i
    problems_to_solve.append(i)
    if total >= n:
        diff =  total - n
        for problem in problems_to_solve:
            if problem != diff:
                print(problem)
        break

Solution (Python):
N = int(input())
left = 0
right = 4472
while right - left > 1:
    mid = (left + right) // 2
    if mid * (mid + 1) // 2 < N:
        left = mid
    else:
        right = mid
ans = {i for i in range(1, right + 1)}
ans -= {right * (right - 1) // 2 - N + right}
print('\n'.join(map(str, ans)))

Solution (Python):
N = int(input())
left = 0
right = 10000
while right - left > 1:
    mid = (left + right) // 2
    if mid * (mid + 1) // 2 < N:
        left = mid
    else:
        right = mid
ans = {i for i in range(1, right + 1)}
ans -= {right * (right - 1) // 2 - N + right}
print('\n'.join(map(str, ans)))

Solution (Python):
N = int(input())
left = 0
right = 10 ** 7 + 1
while right - left > 1:
    mid = (left + right) // 2
    if mid * (mid + 1) // 2 < N:
        left = mid
    else:
        right = mid
ans = {i for i in range(1, right + 1)}
rem = N - right
except_n = right * (right - 1) // 2 - N + right
ans -= {except_n}
[print(i) for i in ans]

Solution (Python):
N = int(input())

s = 0
ans = set()
for i in range(1, N+1):
    s += i
    ans.add(i)
    if s >= N:
        break

if N < s:
    ans.remove(s-N)

for a in ans:
    print(a)

Solution (Python):
N = int(input())

s = 0
for i in range(1, N + 1):
    s += i
    if s >= N:
        tmp = i
        break

n = s - N

for i in range(1, n):
    print(i)

for i in range(n + 1, tmp + 1):
    print(i)

Solution (Python):


import math

N = int(input())
L = [i for i in range((N+2)//2+2)]
num = math.floor(pow(2*(N-1),0.5))
    
for i in range(num,len(L)):
    if N == i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
    elif N < i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
Left = Max - N 





 






for i in range(1,index+1):
    if i == Left:
        continue
    print(i)

Solution (Python):
n = int(input())
k = 0
while n > k:
  if k*(k+1)//2 < n <= (k+1)*(k+2)//2:
    break
  k += 1
s = (k+1)*(k+2)//2 - n
for i in range(1,k+2):
  if i == s:
    continue
  print(i)

Solution (Python):
n=int(input())
i=1
num=0
suml=[0]
while num<=10**7+1000:
    num+=i
    suml.append(num)
    i+=1

j=1
while n>suml[j]:
    j+=1
k=suml[j]-n
for ii in range(1,j+1):
    if ii!=k:
        print(ii)

Solution (Python):
n = int(input())

s = 0
i = 0
while s < n:
    s += i
    i += 1

if i == 1:
    print(1)
else:
    ans = list(range(1,i))
    if s - n != 0: ans.remove(s-n)
    print('\n'.join(map(str,ans)))

Solution (Python):
N = int(input())
for i in range(1,N+1):
    if (i*(i+1))//2>=N:
        tmp = (i*(i+1))//2-N
        for j in range(1,i+1):
            if j != tmp:
                print(j)
        exit()

Solution (Python):
n = int(input())
i = 1
cnt = 0
while cnt < n:
    cnt += i
    i += 1

for j in range(1, i):
    if cnt - n == j:
        continue
    print(j)

Solution (Python):
n=int(input())
l=[]
ans=0
for i in range(1,n+1):
  l.append(i)
  ans+=i
  if n<=ans:
    break
if n<ans:
  l.remove(ans-n)
  print(*l)
else:
  print(*l)

Solution (Python):
n = int(input())
s = 0
i = 1
while s <= n:
    s += i
    i += 1
for j in range(1, i):
    if j == s - n:
        continue
    else:
        print(j)

Solution (Python):
import math

n = int(input())

k = math.ceil(((1 + 8 * n) ** 0.5 - 1) / 2)

tmp = k * (k + 1) / 2 - n
for i in range(1, k + 1):
    if i == tmp:
        continue
    print(i)

Solution (Python):
n = int(input())
sum = 0
skip = -1
for i in range(1,n+1):
    sum += i
    if sum >= n:
        skip = sum - n 
        last = i
        break
for i in range(1,last+1):
    if i == skip:
        continue
    else:
        print(i)

Solution (Python):
from itertools import accumulate, count

n = int(input())

cumsum_ = accumulate(count(1))
cumsum = []
for x in cumsum_:
    if x >= n:
        cumsum.append(x)
        break
    else:
        cumsum.append(x)

x = cumsum[-1] - n
for i in range(1, len(cumsum)+1):
    if i != x:
        print(i)

Solution (Python):
from itertools import accumulate

n = int(input())

cumsum_ = accumulate(range(1, 10**7+1))
cumsum = []
for x in cumsum_:
    if x >= n:
        cumsum.append(x)
        break
    else:
        cumsum.append(x)

x = cumsum[-1] - n
for i in range(1, len(cumsum)+1):
    if i != x:
        print(i)

Solution (Python):
n = int(input())
ans = 0
lst = []
for i in range(1,n+1):
  ans += i
  lst.append(i)
  if ans>=n:
    break
  
num = ans-n
if num != 0:
  lst.remove(num)

L =len(lst)
for i in range(L):
  print(lst[i])

Solution (Python):
import bisect
import numpy as np
n = int(input())


arr = np.arange(4500) + 1
arr = arr.cumsum()

div = bisect.bisect_left(arr, n) + 1

arr = np.arange(div) + 1
rem = arr.sum() - n
arr = arr[np.where(arr != rem)]

print(*arr, sep="\n")

Solution (Python):
n=int(input())
x=0
while x*(x+1)//2<n:
  x+=1
for i in range(1,x+1):
  if not x*(x+1)//2-i==n:
    print(i)

Solution (Python):
n=int(input())
k=0
i=0
while k<n:
    i+=1
    k+=i
print(*[j for j in range(1,i+1) if k-n!=j],sep='\n')

Solution (Python):
n = int(input())
l, r = 1, n
while l < r:
    m = (l+r)//2
    if (1+m)*m/2 <= n:
        l = m+1
    else:
        r = m
result = [i for i in range(r+1)]
result[(1+r)*r//2 -n] = -1
for i in result[1:]:
    if i < 0:
        continue
    print(i)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,=pin()
    temp=0
    ans=[]
    dame=0
    end=0
    for i in range(1,10**7):
        temp+=i
        if temp>=N:
            dame=temp-N
            end=i
            break
    for j in range(1,end+1):
        if j!=dame:print(j)

resolve()

Solution (Python):
N = int(input())
k = 0
ans = 0
while N >= ans:
    k += 1
    ans = k * (k+1) / 2

num = int(k * (k+1) / 2 - N)
for i in range(1,k+1):
    if i != num:
        print(i)

Solution (Python):
n = int(input())
i = 1
k = 0
ans = []
while k<n:
    k += i
    ans.append(k)
    i += 1
x = ans[-1]-n
for i in range(1,len(ans)+1):
    if i==x:continue
    print(i)

Solution (Python):
from itertools import accumulate
import bisect
n = int(input())
A = [n for n in range(1,5*10**3)]
B = list(accumulate(A))
i = bisect.bisect_right(B, n)
if B[i-1] == n:
    for j in range(i):
        print(A[j])
else:
    k = B[i] - n
    for j in range(i+1):
        if A[j] == k:
            continue
        print(A[j])

Solution (Python):
n = int(input())
cou = 0
p = set()
for i in range(n):
    cou += i+1
    p.add(i+1)
    if cou == n:
        break
    elif cou > n:
        p = p - {cou-n}
        break

for i in p:
    print(i)

Solution (Python):
n = int(input())
s = 0
for i in range(1, n+1):
    s += i
    if s >= n:
        break

k = s-n
ans = []
for j in range(1, i+1):
    if j == k:
        continue
    else:
        ans.append(j)
ans = list(map(str, ans))
print('\n'.join(ans))

Solution (Python):
n = int(input())
s = 0
for i in range(1, n+1):
    s += i
    if s >= n:
        break

k = s-n
ans = []
for j in range(1, i+1):
    if j == k:
        continue
    else:
        ans.append(j)
ans = list(map(str, ans))
print('\n'.join(ans))

Solution (Python):
n=int(input())
chk=0
add=1
while chk<n:
    chk+=add
    add+=1
add-=1
if n==chk:
    for i in range(add):
        print(i+1)
else:
    exc=chk-n
    for i in range(add):
        if i+1==exc:
            continue
        print(i+1)

Solution (Python):
n = int(input())

for i in range(1,3 * int(n ** 0.5)):
    n -= i
    if n < i + 1:
        maximum = i + 1
        no = i + 1 - n
        break

for i in range(maximum):
    if i + 1 == no:
        continue
    print(i + 1)

Solution (Python):
n = int(input())

ans=set()
for i in range(1,3 * int(n ** 0.5)):
    n -= i
    ans.add(i)
    if n < i + 1:
        ans.add(i + 1)
        no = i + 1 - n
        break

for i in ans:
    if i == no:
        continue
    print(i)

Solution (Python):
N = int(input())
k = 0
ans = 0
while N >= ans:
    k += 1
    ans = k * (k+1) / 2

exit_num = int(k * (k+1) / 2 - N)
for i in range(1,k+1):
    if i != exit_num:
        print(i)

Solution (Python):
n = int(input())
total = 0
for i in range(1, n+1):
    total += i
    if total >= n:
        for j in range(1, i+1):
            if j != total-n:
                print(j)
        exit()

Solution (Python):
n = int(input())
total = 0
for i in range(1, n+1):
    total += i
    if total >= n:
        for j in range(1, i+1):
            if j != total-n:
                print(j)
        exit()

Solution (Python):
def solve():
    N = int(input())
    score = 0
    for i in range(1, N+1):
        score += i
        if score >= N:
            break
    x = score - N
    res = list(range(1, x)) + list(range(x+1, i+1))
    return '\n'.join(map(str, res))
    
print(solve())

Solution (Python):
N = int(input())
def calc(n):
    return (n*(n+1))//2
max_n = 0
for i in range(1, N+1):
    if calc(i) >= N:
        max_n = i
        break
for i in range(1, max_n+1):
    if calc(max_n) - N == i:
        continue
    else:
        print(i)

Solution (Python):
N=int(input());n=int((2*N-1/4)**.5+.5);i=1;exec("n*-~n/2-N-i and print(i);i+=1;"*n)

Solution (Python):
N=int(input());n=int((2*N-1/4)**.5+.5)
for i in range(1,n+1):n*-~n/2-N-i and print(i)

Solution (Python):
n=int(input());c=a=0
while a<n:c+=1;a=-~c*c//2
for i in range(1,c+1):
 if i!=a-n:print(i)

Solution (Python):
n = int(input())
c = a = 0
while a < n:
    c += 1
    a = -~c*c//2
for i in range(1, c+1):
    if i != a - n:
        print(i)

Solution (Python):
N = int(input())

if N == 1:
    print(1)
    exit()

lis = []
tmp = 0
for n in range(N+1):
    tmp += n
    lis.append(tmp)
    if tmp>=N:
        break

iranaiKazu = lis[-1] - N
for i in range(1,len(lis)):
    if i == iranaiKazu:
        continue
    print(i)

Solution (Python):
import sys
input = sys.stdin.readline


n = int(input())
m = 1
sum = 1

while sum < n:
	sum = (m + 1) * m / 2 
	m += 1

if m == 1:
	ans = [1]
else:
	ans = list(range(1, m))

try:
	ans.remove(sum - n)
except Exception:
	pass

for a in ans:
	print(a)

Solution (Python):
n = int(input())

amari = 0
made = 0
cnt = 0
for i in range(1, n+1):
    cnt += i
    if cnt >= n:
        made = i
        amari = cnt - n
        break

ans = []
for i in range(1, made+1):
    if i == amari:
        continue
    ans.append(str(i))
print("\n".join(ans))

Solution (Python):
import sys

N = int(sys.stdin.readline().strip())

A = []
t = 0
i = 1
while t <= N:
    t += i
    A.append(i)
    i += 1

for i in A:
    if t - N == i:
        
        continue
    else:
        print(i)

Solution (Python):
n = int(input())

cnt = 0
pbm = 0
for i in range(1, 10**6):
    cnt += i
    if cnt >= n:
        pbm = i
        break

ans = []

for i in range(pbm, 0, -1):
    if i <= n:
        ans.append(i)
        n -= i

for i in ans:
    print(i)

Solution (Python):
n = int(input())
l = []
s = 0
for i in range(1,10**7+1):
  if n>=s:
    s += i
    l.append(i)
  else:
    break
if s-n>0:
  a = s-n
  l.remove(a)
for i in l:
  print(i)

Solution (Python):
N=int(input())
n=0
S=1
while S<N:
    n+=1
    S=n*(n+1)//2

if N==1:
    print(1)

for i in range(1,n+1):
    if i!=S-N:
        print(i)

Solution (Python):
n = int(input())
def main(n):
    if n == 1:
        return 2,0
    
    if n == 3:
        return 3,0
    m = n //2 
    for i in range(1,m+1):
        if i * (i + 1) <= 2*n < (i+1)*(i+2):
           right  = i + 1
           break
       
    diff = right * (right+1) //2 - n
       
    return right+1,diff


right,diff = main(n)

for i in range(1,right):
    if i != diff:
        print(i)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ans = []
cnt = 0
for i in range(1, n + 2):
    cnt += i
    ans.append(i)
    if cnt > n:
        ans.remove(cnt - n)
        break
print('\n'.join(map(str, ans)))

Solution (Python):
n = int(input())
for i in range(1,n+1):
    if i*(i+1)//2>=n:
        for j in range(1,i+1):
            if j!=i*(i+1)//2-n:
                print(j)
        break

Solution (Python):
n = int(input())
k = 1
while True:
  if k*(k+1)//2 >= n:
    ans = k
    break
  k += 1
if n == ans*(ans+1)//2:
  i = 1
  while i <= ans:
    print(i)
    i += 1
else:
  i = 1
  l = []
  cnt = 1
  while i < ans:
    if cnt <= (ans-1)*(ans+2)//2 - n:
      print(i)
      cnt += 1
    else:
      print(i+1)
    i += 1

Solution (Python):
n = int(input())
ans = []
Sum = 0
for i in range(1, 10**4):
    Sum += i
    ans.append(i)
    if Sum >= n:
        break

if Sum == n:
    print(*ans)
else:
    ans.remove(Sum - n)
    print(*ans)

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))



def main():
    n = ni()
    d = []
    tmp = 0
    for i in range(10 ** 7):
        tmp += i
        d.append(tmp)
        if tmp > 10 ** 7 + 1000:
            break

    l = bisect.bisect_left(d, n)
    ans = []
    tmp_n = n
    for i in range(l, 0, -1):
        if tmp_n >= i:
            ans.append(i)
            tmp_n -= i

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    n = math.ceil((-1 + math.sqrt(1+8*N))/2)
    jokyo = n*(n+1)//2 - N
    for i in range(1,n+1):
        if i == jokyo:
            continue
        else:
            print(i)
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
ps = 0
for i in range(1,10**100):
    ps += i
    if ps >= n:
        ii = i
        break

for i in range(1,ii+1):
    if i == ps-n:
        continue
    else:
        print(i)

Solution (Python):


N = int(input())

cnt = 0
for i in range(1, 10**7+1):
    cnt += i
    if cnt > N: break

z = cnt - N

for j in range(1, i+1):
    if j == z: continue
    print(j)

Solution (Python):
from sys import stdin
import sys
import itertools
import math

N = int(input())
if N == 1 or N == 2:
    print(N)
    sys.exit()
ans = 0
temp = []
if N > 1000:
    x = 2*int(math.sqrt(2*N))
    
    y=[i for i in range(1,x)]
    
else:
    x = N
for i in range(1, x):
    ans += i
    temp.append(i)
    if ans >= N:
        f = ans-N
        
        for k in range(len(temp)):
            if temp[-1] <= f:
                f = f-temp[-1]
                temp.pop()
                continue
            print(temp[-1])
            temp.pop()

Solution (Python):
n = int(input())

cnt = 0
for i in range(1, n + 1):
    cnt += i
    if n <= cnt:
        cnt -= n
        num = i
        break

for i in range(1, num + 1):
    if i == cnt:
        continue
    print(i)

Solution (Python):
import math
n = int(input())
ans = math.ceil(((1+8*n)**0.5 - 1 )/ 2)
total = ans * (1+ans) // 2
sub = total - n

for i in range(1,ans+1):
    if sub == i:
        continue
    print(i)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))


def resolve():
    N,=pin()
    temp=0
    notsolve=0
    a=0
    for i in range(1,10**7):
        temp+=i
        if temp>N:
            notsolve=temp-N
            a=i
            break
    for j in range(1,a+1):
        if j!=notsolve:print(j)
    
        

resolve()

Solution (Python):
def main():
    n=int(input())
    num=[i*(i+1)//2 for i in range(4473)]
    ans=[]
    while n>0:
        for i in range(1,4473):
            if num[i]>=n:
                ans.append(i)
                n-=i
                break
    for i in range(len(ans)):
        print(ans[len(ans)-1-i])
if __name__=="__main__":
    main()

Solution (Python):
N=int(input())

i=1
Sum=0
while Sum<N:
    Sum+=i
    i+=1

ans=[]
Top=i-1
while N:
    if N-Top>=0:
        N-=Top
        ans.append(Top)
    Top-=1

for j in ans:
    print(j)

Solution (Python):
Score = int(input())

Numero = 0

for i in range (1, 10000000):
	if i*(i+1)/2 >= Score:
		Numero = i
		break

K = Numero

P = []

for i in range (0, K):
	if Score >= (K-i):
		P.append(K-i)
		Score = Score - (K-i)

P = reversed(P)

print(*P, sep = "\n")

Solution (Python):
N=int(input())
tmp = 0
while N>0:
    for i in range(1,N+1):
        if N <= i*(i+1)//2:
            print(i)
            N -=i
            break

Solution (Python):
n=int(input())
l=[]
tmp=0
i=1
while tmp<n:
    tmp+=i
    l.append(i)
    i+=1
k=tmp-n
if k>0:
    l.remove(k)
for item in l:
    print(item)

Solution (Python):
def main():
    N = int( input())
    ANS = []
    now = 0
    for i in range(1,N+1):
        now += i
        ANS.append(i)
        if now == N:
            break
        if N < now:
            ANS.remove(now-N)
            break
    print("\n".join( map( str, ANS)))
if __name__ == '__main__':
    main()

Solution (Python):
import math
import sys

n = int(sys.stdin.readline().rstrip())

if n == 1:
    print(1)
    sys.exit()
elif n == 2:
    print(2)
    sys.exit()

m = 1
s = 0
while (s <= n):
    s += m
    m += 1

for i in range(1, m):
    if i == s - n:
        continue
    else:
        print(i)

Solution (Python):
N = int(input())
total = 0
res = []

for i in range(5000)[1:]:
  res.append(i)
  total += i
  if N <= total:
    break
if total != N:
  res.remove(total - N)
for r in res:
  print(r)

Solution (Python):
SIZE = 4500
def main():
    N = int(input())
    for n in range(SIZE+1):
        if n*(n+1) < 2 * N <= (n+1)*(n+2):
            break
    n += 1
    d = n*(n+1)//2 - N
    for i in range(1, n+1):
        if i == d: continue
        print(i)
    return

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
i = 0
while i * (i+1) <= 2 * n:
  i += 1
  
num = []

for a in range(1,i+1):
  if a != i * (i+1) / 2 - n:
    num.append(a)
    
for _ in  num:
  print(_)

Solution (Python):

import sys
import math

def main():
    N = int(input())
    T = math.ceil((2*N)**0.5)
    rem = T*(T+1)//2 - N
    if rem > T:
      rem = T*(T-1)//2 - N
      T -= 1
    
    for i in range(T):
        if i+1 != rem:
            print(i+1)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

for i in range(1,n+1):
    if i*(i+1)//2 >=n:
        k = i*(i+1)//2 - n
        for j in range(1,i+1):
            if j == k:
                continue
            else:
                print(j)
        exit()

Solution (Python):
n = int(input())

cnt = 0
for i in range(1,n+1):
    cnt += i
    if cnt >= n:
        idx = i
        break


sum = 0
for i in range(1,idx+1)[::-1]:
    if sum+i < n:
       print(i)
       sum += i
    
    else:
        print(n-sum)
        break

Solution (Python):

n = int(input())
bott = 0
rem = -1
for i in range(10000):
    bott = i*(i+1)//2
    bott2 = (i+1)*(i+2)//2
    if(bott<=n and n<bott2):
        rem = bott2-n
        bott = i
        break
ans = []
for i in range(bott+1):
    if(i+1 != rem):
        ans.append(i+1)

for i in ans:
    print(i)

Solution (Python):
n=int(input())

memo = 0

if n == 1 or n ==2:
    print(n)
    exit()


for i in range(1,n):
    memo += i
    if n <= memo:
        check = i
        break

ans = []

for i in range(check,0,-1):
    n -= i
    
    ans.append(i)
    if n < i:
        ans.append(n)
        break
ans.sort()

for i in ans:
    print(i)

Solution (Python):
N = int(input())
i = 0
total = 0
while True:
    total += i
    if total >= N:
        tmp = i
        break
    i += 1

for j in range(tmp, 0, -1):
    if N - tmp >= 0:
        N -= tmp
        print(tmp)
    if N == 0:
        break
    tmp -= 1

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())


cnt =0
i=0
while cnt<n:
    i+=1
    cnt +=i

diff = cnt -n

for num in range(1,i+1):
    if num==diff: continue
    print(num)

Solution (Python):
n = int(input())
r = 10**7+1
l = 1

def f(n):
  return (n**2+n)//2

while r-l> 1:
  if f((l+r)//2)>n:
    r = (l+r)//2
  else:
    l = (l+r)//2

l = l+1
rm = (l+1)*l//2-n
ans = list(range(1, l+1))
ans.remove(rm)
for a in ans:
  print(a)

Solution (Python):
n = int(input())

cnt = 0
for i in range(1, n + 1):
	cnt += i
	if cnt >= n:
		res = i
		break
	
remove = cnt - n
for i in range(1, res + 1):
	if i != remove:
		print(i)

Solution (Python):
n = int(input())
l, r = 0, n**2
while r-l > 1:
  k = (r+l)//2
  if k*(k+1)//2 < n:
    l = k
  else:
    r = k

if n == 1:
  r = 1

key = []
for i in range(r, 0, -1):
  if n-i >= 0:
    key.append(i)
    n -= i
    if not n:
      break

key.reverse()
for value in key:
  print(value)

Solution (Python):
n=int(input())
if n==1:
    print(1)
    exit()
from itertools import accumulate
a=[0]*(4500)
for i in range(1,4500):
    a[i-1]=i

ac=list(accumulate(a))

for i in range(n+1):
    if ac[i]+a[i+1]>=n:
        maxi=a[i+1]
        break

a=[i for i in range(1,maxi)]

ans=[maxi]
n-=maxi

def solve(n):
    if n==1:
        ans.append(1)
        return 0
    a=[0]*4500
    for i in range(1,4500):
        a[i-1]=i
    
    ac=list(accumulate(a))
    
    for i in range(n+1):
        if ac[i]+a[i+1]>=n:
            maxi=a[i+1]
            break
    ans.append(maxi)
    n-=maxi
    return n

while n>0:
    n=solve(n)

for i in ans:
    print(i)

Solution (Python):
n = int(input())
a = int((-0.5+(0.5**2+2*(n-1))**0.5)+1)
for i in range(a,0,-1):
  if n >= i:
    n-=i
    print(i)

Solution (Python):
n=int(input())
A=[[i*(i+1)//2,i] for i in range(1,4473)]

point=[]
for i in range(len(A)-1):
    if A[i][0]<=n<=A[i+1][0]:
        point=A[i+1]
        break

num=point[0]-n
for i in range(1,point[1]+1):
    if i==num:continue
    else:print(i)

Solution (Python):
n=int(input())
i=1
count=0
ans=[]
if n==1:
    print(1)
    exit()

while count<n:
    count+=i
    ans.append(i)
    i+=1
    

if count-n!=0:
    a=ans.pop(count-n-1)
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
N = int(input())

cum = 0
mx = 0
for i in range(N):
    cum += i + 1
    if cum >= N:
        mx = i + 1
        break

for i in reversed(range(1, mx+1)):
    if N - i >= 0:
        print(i)
        N -= i

Solution (Python):
n = int(input())

if n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    for x in range(1,n):
        tmp = (1+x)*x//2
        if tmp >= n:
            l = x
            break

    d = tmp - n
    for x in range(1,l+1):
        if x != d:
            print(x)

Solution (Python):
def main():
    N = int(input())

    ma = 0
    tot = 0
    while tot < N:
        ma += 1
        tot += ma

    skip = tot - N
    ans = {x for x in range(1, ma + 1) if x != skip}

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

for x in range(N+10):
    if (x*(x+1))//2 >= N:
        break

ans = list(range(1, x+1))
rem = (x*(x+1))//2 - N
for a in ans:
    if a != rem:
        print(a)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    while n>0:
        right=n+1
        left=1
        while right-left>0:
            k=(right+left)//2
            if n<k*(k-1)//2+1:
                right=k
                continue
            elif k*(k+1)//2<n:
                left=k
                continue
            break
        print(k)
        n-=k



if __name__=='__main__':
    main()

Solution (Python):
N=int(input())
def calc(n):
  return n*(n+1)//2

threshold=0
for i in range(1,N+1):
  if calc(i)>=N:
    threshold=i
    break

sub=calc(threshold)-N

for a in range(1,threshold+1):
  if a!=sub:
    print(a)

Solution (Python):
N = int(input())

s = 0
ans = []
for i in range(1, N + 1):
    s += i
    if s >= N:
        for n in range(i, 0, -1):
            if N - n >= 0:
                ans.append(n)
                N -= n
        break

for i in ans:
    print(i)

Solution (Python):
n=int(input())
c=0
for i in range(1,n+1):
  if i*(i+1)//2>=n:
    c=i
    break
for i in range(c,0,-1):
  if i<=n:
    print(i)
    n-=i

Solution (Python):
N=int(input())
for i in reversed(range(1,10001)):
	if N<=(i*(i-1)//2) and N>(i-1)*(i-2)//2:
		print(i-1)
		N-=(i-1)
	else:continue

Solution (Python):



N = int(input())


ans_list = []
check_sum = 0


for i in range(1, N+1):
    check_sum += i
    ans_list.append(i)
    if check_sum>=N:
        tmp_sum = sum(ans_list)
        remove_num = check_sum - N
        if remove_num in ans_list:
            ans_list.remove(remove_num)
        break


for a in ans_list:
    print(a)

Solution (Python):
N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i

Solution (Python):
N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())

    ans=0
    i=0
    while ans<n:
        i+=1
        ans+=i

    print(i)
    rem=n-i
    i-=1
    if rem!=0:
        while i>0:

            if rem-i>=0:
                print(i)
                rem -=i
                i-=1
            else:
                i-=1


resolve()

Solution (Python):




n = int(input())


wk_val = 0

x = 1

while (x*(x+1)) / 2 < n:
    x = x + 1

wk_ans = 0
anslist = list()
while(x > 0):
    if wk_ans + x <= n:
        wk_ans = wk_ans + x
        anslist.append(x)

    if wk_ans == n:
        break
    
    x = x - 1


for i in range(len(anslist)):
    print(anslist[i])

Solution (Python):
N = int(input())

targ = N
while targ > 1:
    l = 0
    r = targ
    
    while l < r:
        m = l + (r - l) // 2
        
        if m * (m - 1) // 2 >= targ - m:
            r = m
        else:
            l = m + 1
    
    print(l)
    targ -= l

if targ > 0: print(targ)

Solution (Python):
N = int(input())
k = 1
while (k*(k+1))//2<N:
    k += 1
A = [i for i in range(1,k+1)]
if N==(k*(k+1))//2:
    for a in A:
        print(a)
else:
    m = (k*(k+1))//2-N
    for a in A:
        if a!=m:
            print(a)

Solution (Python):
N=int(input())
k=d=0
while k<=N:
    k+=1
    d=k*(k+1)//2
    if d >= N: break
for i in range(1,k+1):
    if i==d-N: continue
    print(i)

Solution (Python):
N = int(input())
x = 1
for _ in range(100000):
    if (x + 2) * (x + 1) // 2 > N:
        break
    x += 1

H = [i for i in range(x, 0, -1)]
dif = N - sum(H)

for i in range(dif):
    H[(i) % len(H)] += 1

print(*sorted(H), sep="\n")