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:
import sys
from heapq import heappush, heappop, heappushpop, heapify, heapreplace
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#ここから書き始める
n = int(input())
a = []
total = 0
for i in range(1, n + 1):
    if total >= n:
        break
    total += i
    a.append(i)
for i in a:
    if i != total - n:
        print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
now = n
for i in range(1,n+1):
  if now == i:
    key = -1
    top = i
    break
  elif now - i < 0:
    key = i - now
    top = i
    break
  else:
    now -= i
for i in range(1,top+1):
  if i != key:print(i)

Submission status: Accepted

Solution code:
n = int(input())
tmp = 0
li = []
for i in range(n):
    if i*(i+1)/2 >= n:
        tmp = i
        break
new_li = [x for x in range(1,tmp+1)]
#print(new_li)
if sum(new_li) - n > 0:
    new_li.remove(sum(new_li) - n)
if n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    for n in new_li:
        print(n)

Submission status: Accepted

Solution code:
import math

N = int(input())

x = math.ceil((math.sqrt(8 * N + 1) - 1) / 2)
S = x * (x + 1) // 2
ex = S - N
for i in range(1, x + 1):
    if i != ex:
        print(i)

Submission status: Accepted

Solution code:
from math import sqrt
n=int(input())
d=min(-(-int(sqrt(8*n+1))//2),n)
l=list(range(1,d+1))
remain=(d*(d+1))//2-n

while remain>=l[-1]:
    remain-=l[-1]
    l.pop()
print(*list(set(l)-set([remain])),sep="\n")

Submission status: Accepted

Solution code:
# CODE FESTIVAL 2016 Final
# B - Exactly N points
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b
N = int(input())
for i in range(1, N+1):
    if i*(i+1)//2 >= N:
        k = i
        break


S = k*(k+1)//2
sub = S-N
for i in range(1, k+1):
    if i == sub:
        continue
    print(i)
1

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

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

n = ni()
m = 10**7
a = 1
i = 1

while a <= m:
    if a >= n:
        break
    i+=1
    a+=i

ans = [j for j in range(1,i+1) if j != a-n]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1,N+1):
    if i*(i+1) >= 2*N:
        n = i
        break

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

Submission status: Accepted

Solution code:
N=int(input())
cnt=0
max=10**6
but=0
id=0
for i in range(1,max,1):
    cnt=cnt+i
    if cnt>=N:
        buf=cnt-N
        break
id=i
seq=[i+1 for i in range(id)]
for i in range(len(seq)):
    if seq[i]!=buf:
        print(seq[i])

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())

max_min = 0
cumsum = 0
while cumsum <= 10 ** 7:
    max_min += 1
    cumsum += max_min
    if N <= cumsum:
        break

ans = [i + 1 for i in range(max_min)]
rm_value = cumsum - N
if rm_value != 0:
    ans.remove(rm_value)

for i in ans:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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)

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
from bisect import bisect_left
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    cumsum = list()
    for i in range(n):

        if i == 0:
            cumsum.append(1)
            continue
        
        else:
            cumsum.append(cumsum[i-1]+i+1)

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

    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
ans=[]
count=[]
n=0
for i in range(1,N+1):
    n+=i
    count.append(n)
num=0
for i in range(N):
    if count[i]>N:
        num=i
        break
if N==1:
    print(1)
    exit()
sa=count[num]-N
#print(sa)
for i in range(1,num+2):
    if sa==i:
        continue
    ans.append(i)
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
s = 2
while s * (s - 1) / 2 < N:
  s += 1
for i in range(s -1 ):
  if N >= (s - i -1):
    print(s - i-1)
    N -= s - i -1

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N = int(input())
n = int((2*N)**0.5)
while n*(n+1) < 2*N:
    n += 1
for i in range(n, 0, -1):
    if N >= i:
        print(i)
        N -= i

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    for i in range(n+1):
        if n <= i * (i + 1) // 2:
            tmp = []
            for i in range(i, 0, -1):
                if n >= i:
                    n -= i
                    tmp.append(str(i))
            tmp.sort()
            print("\n".join(tmp))
            return
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
i = 1
while 1:
    if i * (i-1) // 2 < N and N <= i * (i+1) // 2:
        max_ans = i
        break
    else:
        i += 1
not_use = max_ans * (max_ans+1) // 2 - N
for i in range(1, max_ans+1, 1):
    if i != not_use:
        print(i)

Submission status: Accepted

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

def main():
    N = int(input())
    
    k = math.ceil(((1+8*N)**(1/2)-1)/2)
    
    ans = [i+1 for i in range(k)]
    
    if N != (k*(k+1))//2:
        ans.remove((k*(k+1))//2-N)
        
    print(*ans,sep="\n")
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    max_score = int(input())
    answer = []
    i = 1
    while i * i + i - 2 * max_score < 0:
        i += 1
    if i * i + i - 2 * max_score == 0:
        answer = [j for j in range(1, i + 1)]
    else:
        while max_score >= 0:
            answer.append(i)
            max_score -= i
            i -= 1
        answer.pop(-1)
        if i + max_score + 1 > 0:
            answer.append(i + max_score + 1)
    for a in answer:
        print(a)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    ans = []

    left = 0
    right = N + 1
    while right - left > 1:
        mid = (left + right) // 2
        success, elems = calcElements(mid, N)
        if success:
            ans = elems
            right = mid
        else:
            left = mid
    print(*ans,sep='\n')

def calcElements(max_value, N):
    sm = 0
    elems = []
    for k in range(max_value, 0, -1):
        if sm + k <= N:
            sm += k
            elems.append(k)
            if sm == N:
                return (True, elems)
    
    return (False, elems)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
s = lambda i: i * (i+1) // 2
ans = deque()
for i in range(1, 10**7):
    ans.append(i)
    if s(i) >= n:
        ans = list(ans)
        if s(i) > n:
            ans.pop(s(i) - n - 1)
        break
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
def accsum(n):
  return (n*(n+1))//2
N = int(input())
l = 0
r = 10**7
while N > 0:
  m = (l+r)//2
  if accsum(m-1) < N <= accsum(m):
    print(m)
    l = 0
    r = 10**7
    N -= m
  elif N <= accsum(m-1):
    r = m
  else:
    l = m

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = set()

sub = 1
cumsub = 0
while cumsub <= n:
    s.add(sub)

    cumsub += sub
    sub += 1

dif = cumsub - n
if dif > 0:
    s.remove(dif)

for i in s:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
ans=int(0)
check=int(0)
A=[]
for i in range(1,n*100):
    ans+=i
    A.append(i)
    if ans>=n:
        break

check=ans-n
for i in range(len(A)):
    if i==check-1:
        continue
    else:
        print(A[i])

Submission status: Accepted

Solution code:
N = int(input())
def sup(N):
    indexa = 1
    sum = 0
    while True:
        sum += indexa
        if sum >= N:
            return indexa
        indexa +=1
ans = []
while True:
    k = sup(N)
    ans.append(k)
    N -=k
    if N == 0:
        break
ans.reverse()
n = len(ans)
for i in range(n):
    print(ans[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
import math
max_ = math.ceil(-1/2+(1/4+2*n)**(1/2))
while True:
    if n >= max_:
        print(max_)
        n -= max_
    max_ -= 1
    if max_ == 0:
        break

Submission status: Accepted

Solution code:
N = int(input())

dp = []
score = 0
for i in range(N):
  score += i+1
  if N <= score:
    for j in range(i+1):
      if j+1 != score - N:
        print(j+1)
    break

Submission status: Accepted

Solution code:
n = int(input())
cand_judge = lambda x: (1 + x) * x / 2
cand_i = 0

for i in range(10 ** 5):
    if cand_judge(i) >= n:
        cand_i = i
        break

ans = list(range(1, cand_i + 1))
for i in ans:
    if i != abs(n - cand_judge(cand_i)):
        print(i)

Submission status: Accepted

Solution code:
N=int(input())
r=int((2*N+.25)**0.5 + 0.5)
l=r*(r+1)//2-N
[print(i) for i in list(range(1,r+1)) if i!=l]

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    # m*(m+1)/2 = n
    # 2n = m^2+m
    x = 0
    for i in range(n+1):
        if n <= i*(i+1)//2:
            x = i
            break
    for i in range(1, x+1):
        if i == x*(x+1)//2 - n:
            continue
        print(i)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
r=int((2*N+.25)**0.5 - 0.5)+1
for i in range(1,r+1):
  if i!=r*(r+1)//2-N:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
l,r=1,N
while r-l>1:
  m=(l+r)//2
  s=m*(m+1)//2
  if s>=N:
    r=m
  else:
    l=m
for i in range(1,r+1):
  if i!=r*(r+1)//2-N:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
def su(n):
    s = 0
    for i in range(1,n+1):
        s += i
    return s

if N == 1:
    print(1)

elif N == 2:
    print(2)
    
elif N == 3:
    print(2)
    print(1)

elif N == 4:
    print(3)
    print(1)
    
else:
    for i in range(N):
        if su(i) >= N:
            M = i
            break
    print(M)

    now = N-M
    
    for i in range(1,M-1):
        if now - (M-i) >=(M-i):
            now -= M-i
            print(M-i)

        else:
            print(M-i)
            if now-(M-i) != 0: 
                print(now-(M-i))
            break

Submission status: Accepted

Solution code:
N = int(input())
if N == 1 or N == 2:
    print(N)
else:
    for i in range(N+1):
        if i*(i+1)//2 > N:
            num = i-1
            break
    ans = []
    for i in range(num):
        ans.append(i+1)
    if num*(num+1)//2 != N:
        cnt = N-num*(num+1)//2
        ans.remove(num+1-cnt)
        ans.append(num+1)
    for x in ans:
        print(x)

Submission status: Accepted

Solution code:
n = int(input())
res = []
su = 0
for i in range(1, n+1):
    #print(res, i)
    res.append(i)
    if su + i > n:
        break
    su += i
sa = sum(res) - n
if sa == 0:
    print("\n".join(map(str, res)))
else:
    del res[res.index(sa)]
    print("\n".join(map(str, res)))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())

ans=[]
#print(2**0.5*10**(3.5))
#print(4472*4473/2)

for i in range(4473):
    if i*(i+1)/2>=N:
        for j in range(i)[::-1]:
            if N-j-1>=0:
                N-=j+1
                ans.append(j+1)
        for item in ans[::-1]:
            print(item)
        exit()

Submission status: Accepted

Solution code:
n=int(input())
p=0
t=0
for i in range(1,n+1):
  p+=i
  if p>=n:
    t=i
    break
l=range(1,t+1)
if p==n:
  for i in l:
    print(i)
else:
  for i in l:
    if i==p-n:
      continue
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

d = []
for i in range(1, n+1):
  d.append(i)
  sumd = sum(d)
  if sumd == n:
    break
  if sumd > n:
    v = sumd - n
    d.remove(v)
    break
  
for dv in d:
  print(dv)
    
    
#1 2 3 4 5 6 7
#1 2   4

#1 2 3 4 5 6 7 8
#1   3 4

#1 2 3 4 5 6 7 8 9
#  2 3 4

#1 2 3 4 5 6 7 8 9 10
#1 2 3 4

#1 2 3 4 5 6 7 8 9 10 11
#1 2 3   5

#1 2 3 4 5 6 7 8 9 10 11 12
#1 2   4 5

Submission status: Accepted

Solution code:
n=int(input())
count=0
ans=[]
for i in range(1,n+1):
    count+=i
    ans.append(i)
    if count==n:
        break
    elif count>n:
        x=count-n
        del ans[x-1]
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N=int(input())
s=0
A=[]
for i in range(1,N+1):
    s+=i
    A.append(i)
    if s>=N:
        l=i
        break
d=s-N
#d_=l+1-d
#print(A)
for a in A:
    if a!=d:
        print(a)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

a = tmp - N

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
if N == 1:
    print(1)
    exit()
ans = 0
for i in range(1, N+1):
    ans += i
    if ans >= N:
        end = i
        break
res = ans - N
for i in range(1, end+1):
    if i != res:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = 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:
        continue
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

M = 0
for i in range(1, N + 1):
    if i * (i + 1) // 2 >= N:
        M = i
        break

ans = []
for i in reversed(range(1, M + 1)):
    if i <= N:
        ans.append(i)
        N -= i

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import math
N=int(input())
p=math.sqrt(N*2-0.25)-0.5
q=int(p)+1
M=q*(q+1)//2
L=M-N#must0or+
for i in range(1,q+1):
    if i != L:
        print(i)

Submission status: Accepted

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

def getk(num):
    return int((1+math.sqrt(8*num-7))/2)

while(True):
    k = getk(n)
    print(k)
    n-=k
    if k == 1 or n<=0:
        break

Submission status: Accepted

Solution code:
n = int(input())
now = 1
L = []
while now*(now-1)//2 < n:
  L.append(now)
  now += 1
c = sum(L)
if c > n:
  L.remove(c-n)
print(*L, sep="\n")

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
    point += i
    if point >= n:
        sa = point-n
        for k in [j for j in range(1,i+1) if j != sa]:print(k)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = []
    ans_sum = 0
    for i in range(1, N+1):
        ans_sum += i
        ans.append(i)
        if N <= ans_sum:
            dis = ans_sum - N
            for a in ans:
                if a != dis:
                    print(a)
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    ans = set()
    for i in range(1,N+1):
        if i<=N:
            ans.add(i)
            N -= i
        elif N:
            ans.add(i)
            ans.remove(i-N)
            break
    print(*ans,sep="\n")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
lst = []

tmp = 0
x = 1
while tmp<= n:
    tmp += x
    lst.append(x)
    x += 1
if tmp==n:
    pass
else:
    dif = tmp - n
    lst.remove(dif)
for l in lst:
    print(l)

Submission status: Accepted

Solution code:
a = int(input())

t =1 
rps = 0
while a > rps:
    rps+=t
    t+=1
d = rps - a
for i in range(1,t):
    if i!=d:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

for x in ans:
    print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
a=1
cnt=1
while cnt<=N:
  a+=1
  cnt+=a
for i in range(a):
  if i+1!=cnt-N:
    print(i+1)

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    N = int(input())
    for i in range(1, N+1):
        sumn = i *(i+1)//2
        if(N <= sumn):
            for j in range(1, i+1):
                if j == sumn-N:
                    continue
                print(j)
            exit()

Submission status: Accepted

Solution code:
n = int(input())
a = 0
while a * (a+1) // 2 < n:
    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:
def main():
    N = int(input())
    ls = [0]
    ans = []

    for i in range(1,N+1):
        ls.append(ls[-1]+i)
        ans.append(i)
        if N<=ls[-1]:
            break
                
    for i in range(len(ans)):
        if ans[i]==(ls[-1]-N):
            pass
        else:
            print(ans[i])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
x,cs = 1,1
while n>=cs:
  x +=1
  cs += x
[print(i) for i in range(1,x+1) if i != cs-n]

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
tmp = 0

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

fuyou = tmp - N

for i in range(1,p+1):
	if i == fuyou:
		continue
	print(i)

Submission status: Accepted

Solution code:
N = int(input())

def solve(n):
	if (1+n)*n//2 >= N:
		return 1
	else:
		return 0

def Binary_search(s,l):
	if s == l:
		return s
	if s+1 == l:
		if solve(s):
			return s
		else:
			return l

	c = s + (l-s)//2

	if solve(c):
		return Binary_search(s,c)
	else:
		return Binary_search(c,l)

maximum = Binary_search(1,N)
fuyou = ((1+maximum) * maximum // 2) - N
for i in range(1,maximum+1):
	if i == fuyou:
		continue
	print(i)

Submission status: Accepted

Solution code:
N = int(input())

s = 0

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

l = list(range(1, i))
del l[l.index(s-N)]
print(*l)

Submission status: Accepted

Solution code:
n = int(input())

m = 1
l = 0
while l < n:
    l += m
    m += 1

ans = list(range(1, m))

if l != n:
    ans.remove(l - n)
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
from itertools import accumulate
import bisect

n = int(input())
ls = []
res = 0
for i in range(1, n+1):
    if res > n:
        break
    res += i
    ls.append(res)
while n:
    ind = bisect.bisect_left(ls, n)
    print(ind + 1)
    n -= ind + 1

Submission status: Accepted

Solution code:
n = int(input())
p = [0]*(n+1)
flag = 0
if n==1:
    print(1)
    exit()
for i in range(1,n+1):
    p[i] = i + p[i-1]
    if p[i] > n:
        flag = i
        break
r = p[flag] -n
for i in range(1,flag+1):
    if i!=r:
        print(i)
    else:
        continue

Submission status: Accepted

Solution code:
import math
import bisect
import collections
import itertools
import heapq
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
total = 0
index = 0
for i in range(1, N+1):
    total += i
    if total >= N:
        index = i
        break
diff = total-N
for i in range(1, index+1):
    if diff == i: continue
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

l = 0
r = N
s = (r * (r + 1)) // 2
while r - l > 1:
    m = (r + l) // 2
    x = (m * (m + 1)) // 2
    if x >= N:
        r = m
        s = x
    else:
        l = m

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

Submission status: Accepted

Solution code:

n = int(input())

i = int((2*n)**(1/2))

while i*(i+1)<=2*n:
    i+=1

j = (i+1)*i//2-n

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
while N>0:
    if N==1:
        A.append(1)
        break
    if N==2:
        A.append(2)
        break
    high = N
    low = 0
    while True:
        mid = (high+low)//2
        if N<=((mid-1)*mid)//2:
            high = mid
        elif N>(mid*(mid+1))//2:
            low = mid
        else:
            break
    A.append(mid)
    N -= mid
for i in range(len(A)):
    print(A[i])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=0
for i in range(n):
  s+=i+1
  if s>=n:
    k=i+1
    break
if s==n:
  for i in range(k):
    print(i+1)
else:
  if n==2:
    print(2)
  else:
    for i in range(k):
      if s-i-1!=n:
        print(i+1)

Submission status: Accepted

Solution code:
import bisect

N = int(input())
if N in [1,2]:
  print(N)
  exit()

acms = [0]
for i in range(1,N+1):
  acms.append(acms[i-1]+i)

ans = []
while 1:  
  ans1 = bisect.bisect_left(acms,N)
  if N-ans1<ans1:
    ans.append(ans1)
    ans.append(N-ans1)
    break
  else:
    ans.append(ans1)
    N = N-ans1
    
[print(val) for val in sorted(ans)]

Submission status: Accepted

Solution code:
N=int(input())
# 10
# 1 2 3 4

# 11
# 1 2 3 5

# 12
# 1 2 4 5

# 13
# 1 3 4 5

# 14
# 2 3 4 5

#15
#1 2 3 4 5

# X=5のとき
# X*(X-1)//2　と　(X+1)*X//2　の間に答えがある
# 余計な数を一つ引けばいい

# Xを二分探索で決める
def isHigh(x):
  if N<=((x+1)*x)//2:
    return True
  return False
hi=N
lo=0
while abs(hi-lo)>1:
  mid=abs(hi+lo)//2
  if isHigh(mid):
    hi=mid
  else:
    lo=mid
X=hi
sumX=(X+1)*X//2
diff=sumX-N
for i in range(1,X+1):
  if i!=diff:
    print(i)