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



Sample input:
4


Sample output:
1
3

Submission status: Accepted

Solution code:
N = int(input())

a = 0
n = 1
for n in range(1, N+1):
    a += n
    if a >= N:
        break
b = a - N
for i in range(1, n+1):
    if i != b:
        print(i)

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    s = 0
    anslist = []
    for i in range(1,10000000):
        s+=i
        if s > n:
            s-=i
            break
        anslist.append(i)

    
    dif = n - s

    ans = list(reversed(anslist))
    for i in range(dif):
        ans[i] += 1

    for i in ans:
        print(i)

main()

Submission status: Accepted

Solution code:
n=int(input())
i=1
while True:
    n-=i
    i+=1
    if n<=0:
        break
if n==0:
    for j in range(1,i):
        print(j)
else:
    for j in range(1,i):
        if j!=-n:
            print(j)

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n+1):
    if i*(i+1)//2 >= n:
        s = i
        d = i*(i+1)//2-n
        break

for i in range(1,s+1):
    if i != d:
        print(i)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    ans = 0
    for i in range(101):
        if i%3 and i%5:
            ans += i
    print(ans)
    return

#B
def B():
    a,b,n = LI()
    x = input()
    for i in x:
        if i == "S":
            a = max(0,a-1)
        elif i == "C":
            b = max(0,b-1)
        else:
            if a >= b:
                a = max(0,a-1)
            else:
                b = max(0,b-1)
    print(a)
    print(b)
    return

#C
def C():
    n = I()
    d = LI()
    m = I()
    t = LI()
    dic = defaultdict(lambda : 0)
    for i in d:
        dic[i] += 1
    for i in t:
        if not dic[i]:
            print("NO")
            return
        dic[i] -= 1
    print("YES")
    return

#D
def D():
    n,m = LI()
    v = []
    f = [defaultdict(list) for i in range(2001)]
    for i in range(m):
        a,b,l = LI()
        v.append((a,b,l))
        v.append((b,a,l))
        f[l][a].append(b)
        f[l][b].append(a)
    ans = 0
    for a,b,l in v:
        rest = 2540-l
        for c in f[rest][b]:
            if a < c:
                ans += 1
    print(ans)
    return

#E
def E():
    def sum(n):
        return n*(n+1)//2
    n = I()
    l = 0
    r = n+1
    while r-l > 1:
        m = (l+r)//2
        if sum(m) < n:
            l = m
        else:
            r = m
    ans = list(range(1,r+1))
    s = sum(r)
    for i in ans:
        if i != s-n:
            print(i)
    return

#F
def F():

    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    E()

Submission status: Accepted

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

N = int(input())
se = set()

x = 0
for i in range(1,N+1):
    se.add(i)
    x += i
    if x >= N:
        break

se.discard(x-N)
print(*se, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

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

skip = s-N
for i in range(1, i):
    if i != skip:
        print(i)

Submission status: Accepted

Solution code:
n,c=int(input()),0
for j in range(n+1):
  if c<n:c+=j+1
  else:break	
for i in range(j,0,-1):
  if i<=n:print(i);n-=i

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for j in range(n+1):
	if cnt<n:
		cnt+=j+1
	else:
		break

	
for i in range(j,0,-1):
	if i<=n:
		print(i)
		n-=i

Submission status: Accepted

Solution code:
n = int(input())

a = 0
b = 0
while a<n:
    b+=1
    a += b

while n>0:
    if b<=n:
        print(b,end=' ')
        n-=b
    b-=1

Submission status: Accepted

Solution code:
n = float(input())

import math

if  math.floor(math.sqrt(2*n+0.25)-0.5)==math.sqrt(2*n+0.25)-0.5:
    for i in range(math.floor(math.sqrt(2*n+0.25)-0.5)):
        print(i+1)
elif n!=4:
    while n>0:
        x = math.floor(math.sqrt(2*n+0.25)-0.5)
        print(x+1)
        n -= x+1
else:
  print(3)
  print(1)

Submission status: Accepted

Solution code:
import math

N = int(input())

while N > 0:
    X = math.ceil((-1+(1+8*N)**(0.5))/2)
    print(X)
    N -= X

Submission status: Accepted

Solution code:
N = int(input())
ans = []
S = 0
i = 1
while S < N:
    ans += [i]
    S += i
    i += 1
diff = S - N
print(*[a for a in ans if a != diff], sep='\n')

Submission status: Accepted

Solution code:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
k,c = 0,0
for i in range(int(ceil(2*N))+1):
    if i*(i+1)//2>=N:
        k = i
        c = k*(k+1)//2-N
        break

for i in range(1,k+1):
    if i != c:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
s = 0
ans = []
d = 0
for i in range(1, N + 1):
    s += i
    ans.append(i)
    if s == N:
        break
    elif s > N:
        d = s - N
        break


for a in ans:
    if a != d:
        print(a)

Submission status: Accepted

Solution code:
import bisect
l,i,x=[],0,0
while i<10**7:
    i+=x
    x+=1
    l.append(i)
n=int(input())
x=bisect.bisect_left(l,n)
y=l[x]-n
for i in range(1,x+1):
    if i!=y:print(i)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
ex=0
for i in range(1,10000):
  tmp=i*(i+1)//2
  if tmp>=n:
    ans=i
    ex=tmp-n
    break
for i in range(1,ans+1):
  if i!=ex:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
d=0
maxk=0
for k in range(N+1): 
	d_temp = N - (k*(k+1))//2
	if d_temp < 0:
		break
	else:
		maxk = k
		d = d_temp
if d==0:
	for i in range(maxk):
		print(i+1)
else:
	to_print = [i+1 for i in range(maxk)]
	del to_print[-d]
	to_print.append(maxk+1)
	for x in to_print:
		print(x)

Submission status: Accepted

Solution code:
import bisect

n = int(input())
a = [i*(i+1)//2 for i in range(1,5000)]
number = bisect.bisect(a,n)
diff = n - a[number-1]
plus = number - diff
for i in range(number):
  if i < plus:
    print(i+1)
  else:
    print(i+2)

Submission status: Accepted

Solution code:
N = int(input())
n = N
now = 0
count = 0
while n > 0:
  n -= count
  now += count
  count += 1
ignore = now - N
for i in range(1, count):
  if i == ignore:
    continue
  print(i)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
k = int((n*2)**.5)
while k*(k+1)//2 < n:
  k += 1
l = list(range(1,k+1))
if k*(k+1)//2-n:
  l.remove(k*(k+1)//2-n)
for i in l:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
m = 0
while True:
    if m*(m+1) >= 2*n:
        break
    else:
        m += 1

l = m*(m+1)//2 - n

for i in range(1,m+1):
    if i != l:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
maximum = 1
for k in range(1,N+1):
  if k*(k-1)//2 < N <= k*(k+1)//2:
    maximum = k
    break
while N > 0:
  for j in range(maximum,0,-1):
    if N-j >= 0:
      print(j)
      N = N-j

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for i in range(1, N+1):
    count += i
    if count >= N:
        lim = i
        break
        
for i in range(1, lim+1):
    if count - N == i:
        pass
    else:
        print(i)

Submission status: Accepted

Solution code:
import math
n=int(input())
x=math.ceil(math.sqrt(n*2))
if n==2:
    print(2)
    exit()
for i in range(x+1,0,-1):
    y=sum(range(i))
    if y<=n:
        s=list(range(1,i))
        t=n%y
        break
s=s[::-1]
for r in range(t):
    s[r]+=1
for h in s[::-1]:
    print(h)

Submission status: Accepted

Solution code:
n=int(input())
x=1
res=[x]
while(x*(x+1)//2<n):
    x+=1
    res.append(x)
if x*(x+1)//2!=n:
    del res[x*(x+1)//2-n-1]
for t in res:
    print(t)

Submission status: Accepted

Solution code:
N = int(input())

score = 0
for i in range(1, N+1):
    score += i
    if score >= N:
        for j in range(1, i+1):
            if j != score-N:
                print(j)
        break

Submission status: Accepted

Solution code:
def solve(N):
    d = 10 ** 7
    index = d // 2
    while True:
        k1 = index * (index - 1) // 2
        k2 = index * (index + 1) // 2
        if k1 < N <= k2:
            break
        elif k1 <= N:
            index = (index + d) // 2
        else:
            d = index
            index = index // 2

    d = k2 - N
    return "\n".join([str(i) for i in range(1, index + 1) if i != d])


if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Submission status: Accepted

Solution code:
def solve(N):
    d = 10 ** 7
    index = d // 2
    while True:
        k1 = index * (index - 1) // 2
        k2 = index * (index + 1) // 2
        if k1 <= N < k2:
            break
        elif k1 < N:
            index = (index + d) // 2
        else:
            d = index
            index = index // 2

    d = k2 - N
    return "\n".join([str(i) for i in range(1, index + 1) if i != d])


if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Submission status: Accepted

Solution code:
n=int(input())
p=int(n**0.5)
t=0
for i in range(10**5):
    if i*(i+1)//2>n:
        t=i
        l=t*(t+1)//2-n
        break
for i in range(1,t+1):
    if i!=l:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, N + 1):
    tmp = i * (i + 1) // 2
    if tmp >= N:
        margin = tmp - N
        for j in range(1, i+1):
            if margin == j:
                continue
            print(j)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sigma(N):
    return N*(N+1)//2


def find_max(N):
    for i in range(N):
        if sigma(i) > N:
            return i
    return N


def solve(N):
    Y = find_max(N)
    rem = sigma(Y)-N
    for i in range(1, Y+1):
        if i != rem:
            print(i)


N = int(input())
solve(N)

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
    print(1)
    exit()
s = 0
cnt = 1
while True:
    s += cnt
    if s < n <= s+cnt+1:
        use = cnt+1
        sub = use*(use+1)//2 - n
        for i in range(use):
            if i+1 == sub:
                continue
            print(i+1)
        exit()
    else:
        cnt += 1

Submission status: Accepted

Solution code:
from math import ceil
N = int(input())

if N == 1:
  print(1)
  exit(0)
  
#1,2,3,4 = 10 = (4)(4+1)//2
for i in range(10001):
  if N <= i * (i+1) // 2:
    break

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

Submission status: Accepted

Solution code:
n=int(input())
s=0
for i in range(1,n+1):
  s+=i
  t=s-n
  if t>=0:
    print(*[j for j in range(1,i+1)if j!=t],sep='\n')
    break

Submission status: Accepted

Solution code:
n = int(input())
ans = []
for i in range(10**7):
  ans.append(i+1)
  su = (i+1)*(i+2)//2
  if su > n:
   ans.remove(su-n)
   break
  elif su == n:
    break
for i in ans:
 print(i)

Submission status: Accepted

Solution code:
N=int(input())

for i in range(1,10**6):
    if i*(i+1)/2>=N:
        break
P=i*(i+1)/2-N

for j in range(1,i+1):
    if j==P:
        pass
    else:
        print(j)

Submission status: Accepted

Solution code:
import sys
import bisect

sys.setrecursionlimit(10**9)

N = int(input())

L = [0]
l = 0
for i in range(1,10**6) :
    l += i
    L.append(l+1)
ans = []
while N > 0 :
    tmp = bisect.bisect(L,N)
    
    ans.append(tmp)
    N -= tmp
    
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
m = s = 1
while s < N:
    m += 1
    s += m

ans = [m]
rem = N-m
if rem:
    for n in range(m-1,0,-1):
        if n <= rem:
            ans.append(n)
            rem -= n
            if rem==0: break

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_left
from itertools import accumulate

n = ni()
oneton = [i for i in range(10**4)]
acc = list(accumulate(oneton))

maxp = bisect_left(acc, n)
for p in range(1,maxp+1):
    if p == acc[maxp] - n:
        continue
    print(p)

Submission status: Accepted

Solution code:
import sys
N=int(input())
num=0
L=[]
for i in range(1,N+1):
    num+=i
    L.append(i)
    if num>=N:
        break
if num!=N:
    a=num-N
    L.remove(a)
print('\n'.join(map(str,L)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())

for k in range(1,n+1):
    s = k*(k+1)//2
    if s==n:
        res = set(range(1,k+1))
        break
    if s>=n and (s-n)<=k:
        res = set(range(1,k+1))
        res.remove(s-n)
        break

for r in res:
    print(r)

Submission status: Accepted

Solution code:
N = int(input())

n = 1
while True:
	if n * (n + 1) / 2 >= N:
		break
	else:
		n += 1
n = n - 1
if N == int(n * (n + 1) / 2):
	for i in range(1, n + 1):
		print(i)

else:
	s = int(N - n * (n + 1) / 2)
	for i in range(1,n - s + 1):
		print(i)
	for i in range(n - s + 1, n + 1):
		print(i + 1)

Submission status: Accepted

Solution code:
import math
N = int(input())
i = math.ceil(((8 * N + 1)**(1 / 2) - 1) / 2)
for j in range(1, i + 1):
    if j != i * (i + 1) // 2 - N:
        print(j)

Submission status: Accepted

Solution code:
N = int(input())
j = int(-(-((8*N-1)**0.5-1)//2))
print('\n'.join([str(i) for i in range(1,j+1) if not i == j*(j+1)//2-N]))

Submission status: Accepted

Solution code:
import math
N = int(input())

sum, ulim = 1, 1
while sum < N:
    ulim += 1
    sum += ulim
Ans = [int(i) for i in range(1, ulim + 1)]
diff = sum - N
if diff > 0:
    Ans.remove(diff)
for a in Ans:
    print(a)

Submission status: Accepted

Solution code:
N=int(input())
a=0
d=0
for i in range(1,N+1):
    a=i*(i+1)/2
    if a==N:
        for j in range(1,i+1):
            print(j)
        break
    if a>N:
        c=a-N
        for k in range(1,i+1):
            if k!=c:
                print(k)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
m = 0
tmp = 0
while m < n:
    tmp += 1
    m += tmp
for i in range(1,tmp+1):
    if m-n != i:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N + 1):
    ans += i
    if ans >= N:
        key = ans - N
        for j in range(1, i + 1):
            if j != key:
                print(j)
        break

Submission status: Accepted

Solution code:
n=int(input())
v=0
for i in range(1,n+1):
  v+=i
  if v>=n:break
for j in range(1,i+1):
  if j!=v-n:print(j)

Submission status: Accepted

Solution code:
n=int(input())
v=0
for i in range(1,n+1):
  v+=i
  if v>=n:break
for j in range(1,i+1):
  if not j==v-n:print(j)

Submission status: Accepted

Solution code:
N = int(input())
s = 0
x = 0
for i in range(1, N + 1):
    s += i
    if s >= N:
        x = i
        break
for i in range(1, x + 1):
    if i != s - N:
        print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    from math import ceil
    from math import sqrt

    n = int(input())
    point_min = ceil((-1 + sqrt(1 + 8 * n)) / 2)
    diff = point_min * (point_min + 1) // 2 - n

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def b_exactly_n_points(N):
    tmp = 0
    k = 1
    while tmp < N:
        tmp += k
        k += 1
    ans = list(range(1, k))
    if tmp - N > 0:
        ans.remove(tmp - N)
    ans = '\n'.join(map(str, ans))
    return ans

N = int(input())
print(b_exactly_n_points(N))

Submission status: Accepted

Solution code:
from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 7)

n = int(input())
triangle = []
i = 1
while True:
	triangle.append(i * (i + 1) // 2)
	if triangle[-1] > n:
		break
	i += 1

ans = []

def search(i):
	global ans
	if i == 0:
		return ans
	else:
		ind = bisect_left(triangle, i)
		if i == triangle[ind]:
			ans += list(range(1, ind + 2))
			return ans
		else:
			ans.append(ind + 1)
			return search(i - (ind + 1))

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = inp()

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

x = tmp-N
for i in range(1,i):
	if i == x:
		continue
	print(i)

Submission status: Accepted

Solution code:
from bisect import bisect_right

sum_list = []
nm = 1
sm = 1
while sm <= 10**8:
    sum_list.append(sm)
    nm += 1
    sm += nm
    
n = int(input())

k = bisect_right(sum_list, n)

ans_set = set([i for i in range(1,k+2)])
ans_set.remove(sum_list[k] - n)
ans = list(ans_set)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
'''
Pythonの知っておくと良い細かい処理速度の違い8個
https://www.kumilog.net/entry/python-speed-comp
'''

# sys.stdin.readline()
import sys
input = sys.stdin.readline

n = int(input())

csum = [0]#0を入れておくとcsum[i] = iまでの総和になる
i = 1
b = 0
while b < n:
    b += i
    csum.append(b)
    i += 1

while n > 0:
    for i in range(n + 1):
        if csum[i] >= n:
            print(i)
            n -= i
            break

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
i = 1

while n > ans:
	ans += i
	i += 1

sums = sum(range(i))
diff = sums - n

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

Submission status: Accepted

Solution code:
N = int(input())

l, r = -1, N
while r - l > 1:
    m = (l + r) // 2
    S = m*(1 + m) // 2

    if S >= N:
        r = m
    else:
        l = m

X = r * (1 + r) // 2 - N
if X == 0:
    print(*list(range(1, r+1)), sep="\n")
else:
    print(*list(range(1, X)) + list(range(X+1, r+1)), sep="\n")

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

N = getN()
for i in range(10**4):
    if i*(i+1)/2 >= N:
        M = i
        upper =int(M*(M+1)/2)
        break
tar = []
diff = upper-N
for i in range(M):
    j = i+1
    if j != diff:
        #tar.append(j)
        print(j)
"""
print(sum(tar),M,upper,diff)
if 1628 in tar:
    print("TRue")
"""

Submission status: Accepted

Solution code:
from math import sqrt, floor
N = int(input())
t = 0
p = 0
for k in range(floor(sqrt(2*N))-2,floor(sqrt(2*N))+2):
    if ((k-1)*k)/2 <= N < (k*(k+1))/2:
        t = k
        p = (k*(k+1))//2 - N
        break

for k in range(1,t+1):
    if k!=p:
        print(k)

Submission status: Accepted

Solution code:
n = int(input())
anses = []
ans = 0
if n == 1:
    print(1)
    exit()
elif n == 2:
    print(2)
    exit()

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

if ans > n:
    anses.remove(ans-n)

for i in anses:
    print(i)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    s, cnt = 0, 0
    while s < n:
        cnt += 1
        s += cnt

    for i in range(cnt, -1, -1):
        if n - i >= 0:
            print(i)
            n -= i

        if n == 0:
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

i=1
max_i=0
now_N=0
while(True):
    now_N+=i
    if N<=now_N:
        max_i = i
        break
    i+=1
    
output=[]
    
for i in range(1,max_i+1)[::-1]:
    if N-i>=0:
        N -= i
        output.append(str(i))
    if N==0:
        break
        
print("\n".join(output[::-1]))

Submission status: Accepted

Solution code:
import math
N=int(input())
upperA = int(math.sqrt(2*N))
ceilA = 0
for i in range(upperA,-1,-1):
  if (i*(i+1) <= 2*N) and (2*N < (i+1)*(i+2)):
    ceilA = i+1
    break
nums = [x for x in range(1,ceilA+1)]
nums.remove(sum(nums)-N)
for num in nums:
  print(num)

Submission status: Accepted

Solution code:
N=int(input())
K=0
L=[0 for i in range(N)]
if N==1:
	print(1)
	exit()
for i in range(1,N+1):
	K+=i
	L[i-1]=1
	if K>=N:
		break
L[K-N-1]=0
for i in range(N):
	if L[i]==1:
		print(i+1)

Submission status: Accepted

Solution code:
n = int(input())
a = 0
for i in range(n+1):
    if i*(i+1)//2 >= n:
        a = i
        break

b=[]
c = a*(a+1)//2
for i in range(1,a+1):
    b.append(i)


if c > n:
    b.pop(c-n-1)

for i in b:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
x = [0]
for i in range(1,4500): x.append(x[-1]+i)
from bisect import bisect_left
while n!=0:
	print(bisect_left(x,n))
	n -= bisect_left(x,n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n = tri = 1
while tri < N:
    n += 1
    tri += n
for i in range(1,n+1):
    if i == tri - N: continue
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())

sum = 0
m = 0
for i in range(1, 10**5 + 1):
    sum += i
    if sum >= N:
        m = i
        break

sum = N
for i in range(1, m + 1)[::-1]:
    if sum - i >= 0:
        sum -= i
        print(i)

Submission status: Accepted

Solution code:
n=int(input())
a=5000000
delt=5000000
while not ((a+1)*a//2<n and (a+2)*(a+1)//2>=n):
  delt=max(delt//2,1)
  if (a+2)*(a+1)//2<n:
    a+=delt
  else:
    a-=delt
a=a+1
joker=a*(a+1)//2-n

for i in range(1,a+1):
  if i != joker:
    print(i)

Submission status: Accepted

Solution code:
from math import ceil, sqrt

N = int(input())

k = ceil(0.5 * (-1 + sqrt(1 + 8 * N)))

ans = set()
for i in range(1, k + 1)[::-1]:
    if i <= N:
        N -= i
        ans.add(i)

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = int(input())
ans = 0
before = 1
factor = 0
for tmp in range(1,N+1):
    ans += tmp
    factor = tmp
    if before < N and N <= ans:
        break
    before = ans
difference = ans - N
if difference != 0:
    for tmp in range(1,factor+1):
        if difference != tmp:
            print(tmp)
        else:
            pass
else:
    for tmp in range(1,factor+1):
        print(tmp)

Submission status: Accepted

Solution code:
import sys


def calc(n):
    i = 1
    sm = 0
    st = set()
    if n <= 2:
        st.add(n)
        return st
    while sm < n:
        st.add(i)
        sm += i
        i += 1
    st = st - calc(sm - n)
    return st


sys.setrecursionlimit(10000000)
n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

if N <= 2:
    print(N)
else:

    for i in range(1, N):
        sum += i
        if sum >= N:
            break

    for j in range(1, i + 1):
        if j == sum - N:
            continue
        print(j)

Submission status: Accepted

Solution code:
a = int(raw_input())

_sum = 0
i = 1
while _sum <= a:
    _sum += i
    i += 1
odd = _sum - a
for b in range(i - 1):
    if b + 1 == odd:
        continue
    print b + 1

Submission status: Accepted

Solution code:
N = int(input())
t = 0
m = 0
while m < N:
	t += 1
	m += t
for i in range(1,t+1):
	if i != m - N:
		print(i)

Submission status: Accepted

Solution code:
import sys

N = long(raw_input())

def bin_search(l, r):
	if (r - l) <= 1: return r
	m = (l + r) / 2
	if (((m + 1) * m) / 2) > N:
		return bin_search(l, m)
	else:
		return bin_search(m, r)

x = bin_search(1, 10**7)
d = (x * (x + 1)) / 2 - N
for y in range(1, x+1, 1):
	if y == d: continue
	print str(y)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    n = int(input())
    s = int(math.sqrt(n))
    while (s+1)*s/2 < n:
        s += 1
    sa = (s+1)*s/2 - n
    for i in range(1,s+1):
        if i == sa:
            continue
        print(i)


f()

Submission status: Accepted

Solution code:
from math import ceil
N = int(input())
ans = int(ceil((-1 + (1 + 4 * 2 * N) ** 0.5) / 2))
for i in reversed(range(1, ans+1)):
    if i <= N:
        print(i)
        N -= i
assert(not N)

Submission status: Accepted

Solution code:
import math
n = int(input())
nn = (int(math.sqrt(n)) + 1) * 2
s = [i * (i + 1) // 2 for i in range(nn)]

for i in range(nn):
    if n <= s[i]:
        mx = i
        break

for i in range(mx, 0, -1):
    f = True

    if (s[mx] - i) == n:
        f = False

    if f:
        print(i)
    else:
        pass

Submission status: Accepted

Solution code:
import math
n = int(input())
nn = (int(math.sqrt(n)) + 2) * 2
s = [i * (i + 1) // 2 for i in range(nn)]

for i in range(nn):
    if n <= s[i]:
        mx = i
        break

for i in range(mx, 0, -1):
    f = True

    if (s[mx] - i) == n:
        f = False

    if f:
        print(i)
    else:
        pass

Submission status: Accepted

Solution code:
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

l=[]
for i in range(1,5001):
    if i%2==0:
        l.append((1+i)*(i/2))
    else:
        l.append((1+i)*(i/2)+(i+1)/2)
n=int(raw_input())
#if n in l:
#    for i in range(1,l.index(n)+2):
#        print i
#        exit()
chk=bisect.bisect_right(l,n)
tmp=l[chk]
for i in range(1,chk+2):
    if i!=tmp-n:
        print i

Submission status: Accepted

Solution code:
N=int(input())
x=int((-1+(1+8*N)**0.5)/2)


if x*(x+1)/2==N:

    for i in range(x):
        print(i+1)
    exit()
else:
    print(x+1)
    N -= (x+1)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import bisect


M = 4472


def generate_triangle_numbers(max_idx=M):
    assert max_idx >= 0
    for i in range(max_idx + 1):
        yield i * (i + 1) // 2


def decompose(n):
    tris = list(generate_triangle_numbers())
    # T[i - 1] < n <= T[i]
    i = bisect.bisect_left(tris, n)
    t = tris[i]
    if t == n:
        return list(range(1, i + 1))
    else:
        for j in range(1, i):
            if t - j == n:
                return list(range(1, j)) + list(range(j + 1, i + 1))


def main():
    xs = decompose(int(input()))
    print(*xs, sep="\n")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
import sys

N = int(input())

m = int(math.sqrt(N))
while m*(m+1) < 2*N:
	m += 1
	
list = [m]
sum = m
for n0 in range(m-1):
	n = m-1 -n0
	if sum == N:
		for num in list:
			print(num)
		sys.exit()
	elif sum + n == N:
		list.append(n)
		for num in list:
			print(num)
		sys.exit()
	elif sum + n < N:
		list.append(n)
		sum += n
if m == 1:
	print(1)

Submission status: Accepted

Solution code:
a = int(input().strip())
import sys
sys.setrecursionlimit(1000000)
tmp = []
res = []
ind = 1

def bar(foo,hoge):
    if(foo == 0):
        return
    if foo == 1:
        res.append(1)
        return
    elif foo == 2:
        res.append(2)
        return
    for i in reversed(range(hoge)):
        if (tmp[i] <= foo):
            res.append(i + 1)
            bar(foo - (i + 1) , i)
            return
        
        
    
for i in range(10000000):
    ind = ind + i
    tmp.append(ind)
    if ind >= a :
        bar(a, i + 1 )
        break
for i in res:
    print(i)

Submission status: Accepted

Solution code:
n = int( raw_input() )

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

while n > 0:
    if i <= n:
        print i
        n -= i
    i -= 1

Submission status: Accepted

Solution code:
import sys

# f = open('input.txt')
f = input()

N = int(f)


out = []
sum = 0
for i in range(0, N+1):
    sum = sum + i
    out.append(i)
    if sum > N:
        r = sum - N
        out.remove(r)
        break
    
out.remove(0)

for n in out:
    print(n)

# print(' '.join(map(str, out)))