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())
chk=0
add=1
while chk<n:
    chk+=add
    add+=1
add-=1
if n==chk:
    for i in range(add):
        print(i+1)
else:
    exc=chk-n
    for i in range(add):
        if i+1==exc:
            continue
        print(i+1)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

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

# B - Exactly N points
n = int(input())
m = 1
sum = 1

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

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

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

for a in ans:
	print(a)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
import sys

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

A = []
t = 0
i = 1
while t <= N:
    t += i
    A.append(i)
    i += 1
# print(A) 
for i in A:
    if t - N == i:
        # print("continue", i)
        continue
    else:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())

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

ans = []

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

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

if N==1:
    print(1)

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

Submission status: Accepted

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


right,diff = main(n)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

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

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


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

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

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

N = int(input())

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

z = cnt - N

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import itertools
import math

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

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

for j in ans:
    print(j)

Submission status: Accepted

Solution code:
Score = int(input())

Numero = 0

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

K = Numero

P = []

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

P = reversed(P)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys

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

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

m = 1
s = 0
while (s <= n):
    s += m
    m += 1
# print(m)
for i in range(1, m):
    if i == s - n:
        continue
    else:
        print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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


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

Submission status: Accepted

Solution code:

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

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())

memo = 0

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


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

ans = []

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

for i in ans:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

n = int(input())


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

diff = cnt -n

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

if n == 1:
  r = 1

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

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

Submission status: Accepted

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

ac=list(accumulate(a))

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

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

ans=[maxi]
n-=maxi

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

while n>0:
    n=solve(n)

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

while count<n:
    count+=i
    ans.append(i)
    i+=1
    
#print(ans,count)
if count-n!=0:
    a=ans.pop(count-n-1)
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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



if __name__=='__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem B - Exactly N points(Code Festival)

# input
N = int(input())

# initialization
ans_list = []
check_sum = 0

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

# output
for a in ans_list:
    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:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

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

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

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


resolve()

Submission status: Accepted

Solution code:
# 2020/04/25
# CODE FESTIVAL 2016 Final - B

# Input
n = int(input())

# Calc
wk_val = 0

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

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

if targ > 0: print(targ)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
n = 0
a = n ** 2 + n - 2 * N
# 上から抑える
while a < 0:
    n += 1
    a = n ** 2 + n - 2 * N

score = 0
ans = []
for i in reversed(range(1, n + 1)):
    if score + i <= N:
        score += i
        ans.append(i)
    if score == N:
        break

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0
num_list = []
for i in range(1, 10**7):
    sum += i
    num_list.append(i)
    if sum > n:
        break

for i in num_list:
    if i == (sum - n):
        continue
    else:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
a = []
cnt = 0
k = 1
while cnt < n:
    cnt += k
    a.append(cnt)
    k += 1
diff = a[-1] - n
for i in range(1, len(a)+1):
    if i == diff:
        pass
    else:
        print(i)

Submission status: Accepted

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

Submission status: Accepted

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

#%%code
def resolve():
    x=int(input())
    i=0;temp=0 
    while (1):
        i+=1
        temp+=i
        if temp > x:
            z=-x+temp
            
            for i in range(i):
                if i+1!=z:print(i+1)
            break
        if temp==x:
            for i in range(i):print(i+1)
            break
#%%submit!
resolve()

Submission status: Accepted

Solution code:
n=int(input())
flag=0
k=1
while n>k*(k+1)//2:
    k+=1
ans=[]
while n!=0:
    if n-k>=0:
        n-=k
        ans.append(k)
    k-=1
ans.sort()
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
N=int(input())

sum=0
a=[]
i=1
while sum<=N:
  sum+=i
  a.append(i)
  i=i+1
if sum>N:
  a.remove(sum-N)
#print(sum)
print(*a)

Submission status: Accepted

Solution code:
n=int(input())
ans=[1]
i=2

while n>sum(ans):
  ans.append(i)
  i+=1
if n!=sum(ans):
  ans.remove(sum(ans)-n)
[print(i) for i in ans]

Submission status: Accepted

Solution code:
import sys
input= lambda: sys.stdin.readline().rstrip()
#cythonを使うために実行
#%load_ext Cython
#%%code
def resolve():
    N=int(input())
    ans=0
    for i in range(1,N*2):
        ans+=i
        if ans >= N:
            stop=i+1
            j=ans-N
            break
    for k in range(1,stop):
        if k!=j:print(k)
        
#%%submit!
resolve()

Submission status: Accepted

Solution code:
n = int(input())
cnts = []
i = 0
while i*(i+1)//2 <= n:
    i += 1
    cnts.append(i)

rm = sum(cnts) - n
for i in cnts:
    if i == rm:continue
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
k = int((2*n)**.5)
for i in range(k, k*(k+1)+1):
    if 2*n >= i*(i+1):
        continue
    k = i
    break


def sigma(a, b):
    if a == b:
        return a
    elif b < a:
        return 0
    else:
        return (a+b)*(b-a+1)//2

excess = sigma(1, k)-n
for i in range(1, k+1):
    if i == excess:
        continue
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n=int(input())
k=(2*n+0.25)**0.5-0.5
k=math.ceil(k)
no=k*(k+1)/2-n
for i in range(1,k+1):
    if i==no:
        continue
    print(i)

Submission status: Accepted

Solution code:
N = int(input())


Sn = 1
n = 1
while Sn < N:
    n += 1
    Sn += n
    if Sn == N:
        break

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

for ans in res[::-1]:
    print(ans)

Submission status: Accepted

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

for g in range(1, i+1):
    if g != ng:
        print(g)

Submission status: Accepted

Solution code:
n = int(input())
ans = []
tmp = n
for i in range(min(n, 5000), 0, -1):
    if tmp > i * (i - 1) // 2:
        ans.append(i)
        tmp -= i
ans.sort()
print('\n'.join(map(str, ans)))

Submission status: Accepted

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

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

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

for n in s:
    print(n)

Submission status: Accepted

Solution code:
N = int(input())

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

lv = list(range(1, i + 1))
elem = sum(lv) - N

for k in lv:
    if k != elem:
        print(k)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

    def main(N):
        i = 1
        ans = 0

        while True:
            ans += i
            if ans >= N:
                print(i)
                if N - i != 0:
                    if N-i<i:
                        print(N - i)
                        return True
                    else:
                        main(N-i)
                        return True
                else:
                    return True
            else:
                i += 1

    main(N)


resolve()

Submission status: Accepted

Solution code:
N = int(input())

for k in range(0, 10 ** 7):
    if k * (k + 1) // 2 < N <= (k + 1) * (k + 2) // 2:
        break
remove = (k + 1) * (k + 2) // 2 - N
for i in range(1, k + 2):
    if i != remove:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
def ok(x):
    return x*(x+1)//2 >= n
for x in range(1,n+1):
    
    if ok(x):
        ans = []
        v = x*(x+1)//2 - n
        
        for i in range(1,x+1):
            if i == v:continue
            
            ans.append(i)
        break
            
        
        
        
    else:continue
print(*ans)

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    sum = 0
    for i in range(1, N + 2):
        if sum < N:
            sum += i
        else:
            S = i
            break
    a = sum - N
    for j in range(1, S):
        if j == a:
            continue
        else:
            print(j)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())

#bit探索
start=int((2*N+1)**0.5)

for i in range(3):
    i += start
    if i*(i+1) >= 2*N:
        ret = i
        delete=i*(i+1)/2 - N
        break

for k in range(1,ret+1):
    if k != delete:
        print(k)

Submission status: Accepted

Solution code:
N=int(input())


start=int((2*N+1)**0.5)

for i in range(3):
    i += start
    if i*(i+1) >= 2*N:
        ret = i
        delete=i*(i+1)/2 - N
        break

for k in range(1,ret+1):
    if k != delete:
        print(k)

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def dd(v):
	if v == 1:
		return 1
	ng=1
	ok=v
	while ok - ng>1:
		m=(ok+ng)//2
		if (m*(m+1))//2 >= v:
			#pa('ok',m)
			ok=m
		else:
			#pa('ng',m)
			ng=m
	return ok

def main():
	n = int(input())
	#b , c = IN()
	v=n
	while v > 0:
		r = dd(v)
		print(r)
		v -= r
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
N = int(input())

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

diff = s - N
if diff != 0:
    ans.remove(diff)
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
k = int((n * 2) ** 0.5)
while True:
  p = (k+1) * k // 2
  if p >= n: break
  k += 1
diff = abs(n - p)
for i in range(1, k+1):
  if i != diff: print(i)