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

ans = []
cnt = 0

for i in range(1, n+1):
    if cnt + i == n:
        ans.append(i)
        break
    elif cnt + i < n:
        cnt += i
        ans.append(i)
    else:
        dif = n - cnt
        ans[-dif] += dif
        break

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N = int(input())
k = 0
while k * (k+1) // 2 < N:
  k += 1
while N > 0:
  print(min(k, N))
  N -= min(k, N)
  k -= 1

Submission status: Accepted

Solution code:
n=int(input())
a=[1]
b=2
s=1
def pr(x):
  for i in range(len(x)):
    print(x[i])
while s<=n:
  a.append(b)
  s+=b
  b+=1
if s==n:
  pr(a)
else:
  c=s-n
  a.remove(c)
  pr(a)

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    p = math.ceil(n/2)
    for i in range(n):
        num = (p*(p+1))/2
        if num <= n:
            break
        else:
            p -= 1
    if num == n:
        for i in range(p):
            print(i+1)
        exit()
    else:
        p += 1
        num = (p*(p+1))/2
        dif = num-n
        for i in range(p):
            if i+1 == dif:
                pass
            else:
                print(i +1)








if __name__ == '__main__':
    solve()

Submission status: Accepted

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

# from numba import njit
import sys
sys.setrecursionlimit(10**9)
# input = stdin.readline

INF = 10**9

# @njit
def solve(n):
  s = 0
  l = []
  for i in range(n):
    s += i+1
    l += [i+1]
    if s > n:
      l.remove(s-n)
      return l
    elif s == n:
      return l

  return -1



def main():
  N = int(input())
  # N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(*solve(N),sep="\n")
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n):
    if (i + 1) * (i + 2) // 2 >= n:
        m = i + 1
        d = (i + 1) * (i + 2) // 2 - n
        break
for i in range(m):
    if i + 1 == d:
        continue
    else:
        print(i + 1)

Submission status: Accepted

Solution code:
n=int(input())
ans=[]
sm=0
for i in range(1,n+1):
    sm+=i
    ans.append(i)
    if sm==n:
        break
    if sm>n:
        p=sm-n
        ans.pop(p-1)
        break

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
m = -1
for i in range(1, n+1):
    if i * (i - 1) < 2 * n <= i * (i + 1):
        m = i
        break
top = m * (m + 1) // 2
for i in range(0, m):
    if top - i == n:
        ng = i
        break
for i in range(1, m+1):
    if i == ng:
        continue
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
m = -1
for i in range(1, n+1):
    if i * (i - 1) < 2 * n <= i * (i + 1):
        m = i
top = m * (m + 1) // 2
for i in range(0, m):
    if top - i == n:
        ng = i
        break
for i in range(1, m+1):
    if i == ng:
        continue
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
tmp=0
for i in range(1,10000000):
    tmp+=i
    if tmp>n:
        a=i-1
        tmp-=i
        break
    elif tmp==n:
        for j in range(i):
            print(j+1)
        exit()
x=n-tmp#ずらす個数
y=a-x#ずらさない個数
#print(a,tmp,x,y)
ans=[]
for i in range(1,a+1):
    if i<=y:
        ans.append(i)
    else:
        ans.append(i+1)
#print(ans)
[print(i) for i in ans]

Submission status: Accepted

Solution code:
N=int(input())
l=0
r=0
for i in range(1,N+1):
  s=i*(i+1)//2
  if s>=N:
    l=i
    r=s-N
    break
ans=list(range(1,l+1))
if r!=0:
  ans.remove(r)
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

if N in (1, 2):
    print(N)
    exit()

for i in range(2, 10 ** 4):
    x = i * (i + 1) / 2
    if x - (i - 1) <= N <= x:
        a = i
        break

ans = [i for i in range(1, a + 1)]
b = a*(a+1)/2 - N

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

Submission status: Accepted

Solution code:
n=int(input())

t=int(2*n**0.5)
ans = {i for i in range(1,t+1)}

sum=t*(t+1)//2


for i in range(t,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import math
N = int(input())
saidai = math.sqrt(2*N)
saidai = math.floor(saidai)
if saidai*saidai+saidai == 2*N:
    for i in range(1, saidai+1):
        print(i)
elif saidai*saidai+saidai < 2*N:
    saidai = saidai+1
    huyou = saidai*saidai+saidai-2*N
    if huyou % 2 == 0:
        huyou //= 2
        for i in range(1, saidai+1):
            if i == huyou:
                continue
            print(i)
    else:
        huyou = huyou//2+1
        for i in range(2, saidai+1):
            if i == huyou:
                continue
            print(i)
else:
    for i in range(saidai, 0, -1):
        if i*i+i < 2*N:
            newsaidai = i+1
            break
    saidai = newsaidai
    huyou = saidai*saidai+saidai-2*N
    if huyou % 2 == 0:
        huyou //= 2
        for i in range(1, saidai+1):
            if i == huyou:
                continue
            print(i)
    else:
        huyou = huyou//2+1
        for i in range(2, saidai+1):
            if i == huyou:
                continue
            print(i)

Submission status: Accepted

Solution code:
def solve():
  cnt = 0
  N = int(input())
  ans = []
  for i in range(1,N+2):
    cnt += i
    ans.append(i)
    if cnt>N:
      ans.remove(cnt-N)
    if cnt>=N:
      break
  return ans
print(*solve(),sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
k = 1
while (k*(k+1))//2<N:
    k += 1
if N==(k*(k+1))//2:
    for i in range(1,k+1):
        print(i)
else:
    ind = -1
    for j in range(1,k):
        tot = 0
        for i in range(1,k+1):
            if i!=j:
                tot += i
        if tot==N:
            ind = j
            break
    for i in range(1,k+1):
        if i!=ind:
            print(i)

Submission status: Accepted

Solution code:
n = int(input())
 
_sum = 0
_tmp = 0
while _sum <= n:
    _tmp += 1
    _sum += _tmp
    if _sum >= n:
        break
 
ans = []
while n:
    if n - _tmp < 0:
        _tmp -= 1
    else:
        ans.append(_tmp)
        n -= _tmp
        _tmp -= 1
 
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
#create date: 2020-08-07 07:40

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def check(k, n):
    a = k * (k + 1) // 2
    if n <= a:
        return True
    else:
        return False


def main():
    n = ni()

    # bisect
    l = 1; r = n
    while l + 1 < r:
        k = (l + r) // 2
        if check(k, n):
            r = k
        else:
            l = k
    
    no = r * (r + 1) // 2 - n
    for i in range(1, r+1):
        if i == no:
            continue
        print(i)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
x = int(n**0.5)
while x*(x+1)//2 < n:
    x += 1
skip = x*(x+1)//2 - n
for i in range(1,x+1):
    if skip != i: print(i)

Submission status: Accepted

Solution code:
N = int(input())

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

a = m*(m+1)//2-N
ans = []

for i in range(1, m+1):
    if i==a:
        continue
    
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
s = 0
ans = set()
for i in range(1,N+1):
    ans.add(i)
    s += i
    if s >= N: break
if s-N in ans:
    ans.remove(s-N)

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

Submission status: Accepted

Solution code:
n = int(input())

_sum = 0
_tmp = 0
while _sum <= n:
    _tmp += 1
    _sum += _tmp
    if _sum >= n:
        break

ans = []
while n:
    if n - _tmp < 0:
        _tmp -= 1
    else:
        ans.append(_tmp)
        n -= _tmp
        _tmp -= 1

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

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

ans = []
while n:
    if n-ret < 0:
        ret -= 1
    else:
        ans.append(ret)
        n -= ret
        ret -= 1

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
cnt = [False] * 10001
now = 0
idx = 0
for i in range(1, 10001):
    if now >= N:
        break
    now += i
    cnt[i] = True

if now != N:
    for i in range(10000, 0, -1):
        if now == N:
            break
        elif cnt[i] and now - i >= N:
            cnt[i] = False
            now -= i

for i in range(10001):
    if cnt[i]:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())

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

y = x-N

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

Submission status: Accepted

Solution code:
import math
n=int(input())
num=int(math.sqrt(n*2))
num2=(num*(num+1))//2
num3=n-num2
if num3>num:
    num+=1
    num3-=num
if num3<0:
    num-=1
    num3+=num+1
ans=list(range(1,num+1))
for i in range(num3):
    ans[-i-1]+=1
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import math
N = int(input())
while N>=1:
    max = math.ceil((-1+(1+8*N)**0.5)/2)
    print(max)
    N -= max

Submission status: Accepted

Solution code:
N=int(input())
S=0
i=0
while S<N:
    i+=1
    S+=i

T=set()
for a in range(i,0,-1):
    if N>=a:
        T.add(a)
        N-=a

print("\n".join(map(str,T)))

Submission status: Accepted

Solution code:
N = int(input())
num,a = 0,0
l = []
for i in range(N):
    num += 1
    a += num
    l += num,
    if a >= N:
        minus = a - N
        break

for i in l:
    if i != minus:
        print(i)

Submission status: Accepted

Solution code:
n=int(input())

i=0
sm=0
while sm<n:
  i+=1
  sm=i*(i+1)//2
d=sm-n
for j in range(1,i+1):
  if j !=d:
    print(j)

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
ans = []

reg = 0
i = 1
while reg <= n:
    ans.append(i)
    reg += i
    i += 1
if reg - n > 0:
    ans.remove(reg-n)
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

ans = []

def dfs(m):
    if m == 1:
        ans.append(1)
        return 0
    elif m == 2:
        ans.append(2)
        return 0
    else:
        k = ceil(sqrt(1+8*m))//2
        ans.append(k)
        dfs(m-k)

n = INT()
dfs(n)
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

ans = []

def dfs(m):
    if m == 1:
        ans.append(1)
        return 0
    elif m == 2:
        ans.append(2)
        return 0
    elif m == 3:
        ans.append(2)
        ans.append(1)
        return 0
    elif m == 4:
        ans.append(3)
        ans.append(1)
        return 0
    elif m == 5:
        ans.append(3)
        ans.append(2)
        return 0
    else:
        k = ceil(sqrt(1+8*m))//2
        ans.append(k)
        dfs(m-k)

n = INT()
dfs(n)
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from math import ceil

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

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
now = 0
while True:
    now +=1
    cnt += now
    if cnt >=N:
        break
for i in range(1,now+1):
    if i == cnt-N:
        continue
    else:
        print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import math


# In[47]:


N = int(input())


# In[48]:


x = int(-(-math.sqrt(N*2)//1))
y = x*(x+1)//2
diff = y - N
while diff > x:
    diff -= x
    x -= 1
for i in range(1,x+1):
    if i != diff:
        print(i)


# In[ ]:

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b

n = int(input())
i = 1
ans = []
while i * (i + 1) // 2 <= n:
    ans.append(i)
    i += 1
else:
    ans.append(i)
s = i * (i + 1) // 2
diff = s - n

if diff > 0:
    ans.remove(diff)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

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

Submission status: Accepted

Solution code:
n=int(input())

ans=[]
num=0

i=1
while num<n:
  num+=i
  ans.append(i)
  i+=1
else:
  sa=num-n

if sa!=0:
  ans.remove(sa)

for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())

now = 0
sum = 0
ans = []
while sum < N:
  now += 1
  ans.append(now)
  sum += now

rem = sum-N
if rem != 0:
  ans.remove(rem)
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
N=int(input())
for i in range(1000000):
  if (i*(i+1))//2>=N:
    a=i
    break
pointer=a
while N>0:
  if N>=pointer:
    print(pointer)
    N-=pointer
    pointer-=1
  else:
    print(N)
    N=0

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
cnt = 0
s = set()
for i in range(1, N+1):
    cnt += i
    s.add(i)
    if cnt>=N:
        break
if N!=cnt:
    s.remove(cnt-N)

for i in s:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
A = []
while N>0:
    k = 0
    cnt = 0
    while cnt<N:
        k += 1
        cnt += k
    A.append(k)
    N -= k
for a in A:
    print(a)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
N = int(input())

A = []
S = 0
for i in range(1, N + 1):
    if S >= N:
        break
    S += i
    A.append(i)

x = sum(A) - N
for a in A:
    if x == a:
        continue
    print(a)

Submission status: Accepted

Solution code:
N = int(input())
st = set()
s = 0
n = 1
while s < N:
    st.add(n)
    s += n
    n += 1
if s > N:
    st.remove(s-N)
print(*st, sep='\n')

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    k = 0

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

    x = k * (k + 1) // 2
    d = x - n

    for i in range(1, k + 1):
        if i == d:
            continue
        print(i)


if __name__ == '__main__':
    main()

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()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

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

#############
# Main Code #
#############

N = getN()

total = 0
cnt = 0

while total < N:
    cnt += 1
    total += cnt

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())

    delta = 0
    if N > 1:
        for i in range(1, N+1):
            if (i-1)*i < 2*N < i*(i+1):
                delta = i*(i+1)//2 - N
                res_list = list(range(1, i+1))
                break
            elif 2*N == i*(i+1):
                res_list = range(1, i+1)
    else:
        res_list = [1]

    if delta > 0:
        while delta > res_list[-1]:
            delta -= res_list[-1]
            del res_list[-1]

        res_list.remove(delta)    
    

    for item in res_list:
        print(item)



if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N=int(input())
a=0
b=0
for i in range(1,N+1):
    if (i+1)*i/2>=N:
        a=i
        b=(i+1)*i/2-N

        break

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

Submission status: Accepted

Solution code:
N = int(input())
li = [i for i in range(1, N + 1)]
acc = 0
index = 0
for i in range(N):
    acc += li[i]
    if acc >= N:
        index = i
        break
garbage = acc - N
for i in range(index + 1):
    if li[i] != garbage:
        print(li[i])

Submission status: Accepted

Solution code:
from bisect import bisect_left

N = int(input())

cum = [0]
now = 1

while cum[-1] <= N:
    cum.append(now + cum[-1])
    now += 1

# print(len(cum))
# cum[i]; cum[i]までの数はiまでの和で表せる
idx = bisect_left(cum, N)
# print(cum, idx)
# idxまでの数の中から選んで和をNにする
ans = []
tmp = 0
i = idx
while i > 0:
    # print(i, tmp)
    tmp += i
    ans.append(i)
    if tmp == N:
        print(*ans)
        exit()
    elif tmp > N:
        tmp -= i
        i -= 1
        ans.pop()
    else:
        i -= 1

Submission status: Accepted

Solution code:
N = int(input())

k = 1
while k * (k + 1) // 2 < N:
    k += 1

ans = list(range(1, k+1))
v = k * (k + 1) // 2 - N
if v > 0:
    ans.remove(v)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    k = int((2 * n) ** 0.5) - 1
    while k * (k + 1) // 2 < n:
        k += 1
    s = k * (k + 1) // 2 - n
    [print(i) for i in range(1, k + 1) if i != s]

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
N = int(input())
l = []

def main(n):
  global l
  i = 1
  while True:
    tmp = i*(i+1)//2
    if tmp >= n:
      l.append(i)
      if n-i == 0:
        return l
      else:
        return main(n-i)
    i += 1
    
sys.setrecursionlimit(10000)
li = main(N)
for n in li:
  print(n)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    for i in range(1, n+1):
        x = i * (i - 1) // 2
        if x + i >= n:
            while n:
                y = min(n, i)
                n -= y
                print(y)
                i = y - 1
            return

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    if N==1:
        print(1)
        exit()
    temp=0
    ans=[]
    for i in range(1,N+5):
        temp+=i
        ans.append(i)
        if temp>N:
            ans.remove(temp-N)
            break
        elif temp==N:
            break
    for i in range(len(ans)):
        print(ans[i])
        

main()

Submission status: Accepted

Solution code:
n = int(input())

s = 0
i = 0 
ans = []
# 値をカウントアップしていき、nを超える値になるまで繰り返す。
# 全ての値を保存する
while s < n:
  i += 1
  s += i
  ans.append(i)
  
delete = s - n # 取得した合計値からnを引き、差分を取得
if delete != 0: ans.remove(delete) # 差分を削除
  
for t in ans: print(t)

Submission status: Accepted

Solution code:
N,t = int(input()),1

while t*(t+1) < N*2:
	t += 1
for i in range(1,t+1):
	if t*(t+1)//2-i != N:
		print(i)

Submission status: Accepted

Solution code:
N = int(input())
t = 1

while t*(t+1) < N*2:
	t += 1
x = t*(t+1)//2-N

for i in range(t):
	if t-i <= x:
		x -= t-i
	else:
		print(t-i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l

n = int(input())
def f(n):
    return (n+1)*n // 2
m = BisectSearch(f, l=1, r=10**7)(n)
m += f(m) != n
A = set(range(1, m+1))
A.discard(f(m) - n)
print(*A, sep='\n')

Submission status: Accepted

Solution code:
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l

n = int(input())
def f(n):
    return (n+1)*n // 2
m = BisectSearch(f, l=1, r=10**7)(n)
m += f(m) != n
A = set()
for i in range(m, 0, -1):
  if n - i >= 0:
    A.add(i)
    n -= i
print(*A, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
ans = []
c = 1
while True:
    c+=1
    res=(1+c)*c/2
    if res>=n:
        diff=res-n
        for i in range(1,c+1):
            if i==diff:
                continue
            print(i)
        break

Submission status: Accepted

Solution code:
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()

# 数列の和
def re(x):
    return x*(x+1)//2

# 二分探索
l, r = 0, N+1
exact = -1
while abs(l - r) > 1:
    mid = (l + r) // 2
    if re(mid) > N:
        r = mid
    elif re(mid) == N:
        exact = mid
        break
    else:
        l = mid

# 途中抜けしない場合
if exact != -1:
    for i in range(1, exact + 1):
        print(i)

# する場合
else:
    temp = re(r) - N
    for i in range(1, r+1):
        if i != temp:
            print(i)

Submission status: Accepted

Solution code:
from sys import *
from itertools import *
n=int(input())
l=[i for i in range(1,10**4)]
t=list(accumulate(l))
for i in range(len(t)):
    if t[i]==n:
        ans=l[0:i+1]
        for i in ans:
            print(i)
        exit()
    if t[i]>n:
        m=t[i]-n
        ans=l[0:i+1]
        ans.remove(m)
        for i in ans:
            print(i)
        exit()