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:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
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 make_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)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
if int(math.sqrt(1+8*n))**2 == 1+8*n:
    for num in [i+1 for i in range(int(-1+math.sqrt(1+8*n))//2)]:
        print(num)
else:
    k = int((-1+math.sqrt(1+8*n))/2)
    tmp = k*(k+1)//2
    jud = n-tmp
    rem = k-jud+1
    ans = []
    for i in range(1,k+2):
        if i != rem:
            ans.append(i)
    for num in ans:
        print(num)

Submission status: Accepted

Solution code:
n=int(input())
temp=0
i=1
ans=[]
while True:
  temp=temp+i
  ans.append(i)
  if temp>=n:
    break
  i=i+1
t=temp-n
for i in range(len(ans)):
  if ans[i]!=t:
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())

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

A = [0] * (n + 1)
A[1] = 1 
for i in range(1, n):
    A[i + 1] = A[i] + i

from bisect import bisect_left

idx = bisect_left(A, n)

if n == A[idx]:
    for i in range(1, idx + 1):
        if i == idx - 1: continue
        print(i)
else:
    for i in range(1, idx):
        if i == idx - 1 - (n - A[idx - 1] + 1): continue
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 1
while cnt*(cnt+1)//2 < n:
    cnt+=1
if cnt*(cnt+1)//2 == n:
    for i in range(cnt):
        print(i+1)
else:
    bad = -1
    total = cnt*(cnt+1)//2
    for i in range(1, cnt+1):
        if total-i == n:
            bad = i
            break
    for i in range(1, cnt+1):
        if i == bad:
            continue
        print(i)

Submission status: Accepted

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

li = [False] * (n + 1)

s = 0
for i in range(1, n+1):
    s += i
    li[i] = True

    if s == n:
        break
    if n - s < i + 1:
        li[i+1-(n-s)] = False
        s -= i+1-(n-s)

# print(li)
for j in range(1, i+1):
    if li[j]:
        print(j)

Submission status: Accepted

Solution code:
n = int(input())
if n == 1 or n == 2:
    print(n)
    exit()

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

amari = now - n

for i in ans:
    if i == amari:
        continue
    else:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())

ans = []
check = 0

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

if check - n != 0:
    del ans[check - n - 1]
    
for i in ans:
    print(i)

Submission status: Accepted

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

#temp_n=int(math.sqrt(2*n)//1)-1
temp_n=int((-1+math.sqrt(1+8*n))//2)
#print(n,temp_n)

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

#print(n,temp_n)
ans=[]
while(n>0):
#    print(n,temp_n,ans)
    if(n>=temp_n):
        n-=temp_n
        ans.append(temp_n)
        temp_n-=1
    else:
        temp_n=n
        ans.append(temp_n)
        n-=temp_n
ans.sort()

for ai in ans:
    print(ai)

Submission status: Accepted

Solution code:
N = int(input())
ans = [0]
rui = 0
for i in range(1,N+1):
    ans.append(i)
    rui += i
    if rui >= N:
        break
for i in range(1,len(ans)):
    if i == (rui-N):
        continue
    print(ans[i])

Submission status: Accepted

Solution code:
def f(x):
    return x * (x + 1) // 2


if __name__ == "__main__":
    N = int(input())
    for i in range(0, N + 1):
        if f(i) >= N:
            x, sum_ = i, f(i)
            break

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

Submission status: Accepted

Solution code:
n=int(input())

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

if s==n:
    for a in ans:
        print(a)
else:
    ans.remove((s-n))
    for a in ans:
        print(a)

Submission status: Accepted

Solution code:
n = int(input())
ans = set([0])
for i in range(1, n+1):
    ans.add(i)
    n -= i
    if n<=0:
        break

ans = list(ans)
ans.remove(0)
if n!=0:
    ans.remove(-n)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
ans = []
cnt = 0
for i in range(1, int(n**0.7)+3):
    if n > cnt:
        ans.append(i)
        cnt += i
    else:
        if cnt - n in ans:
            ans.remove(cnt - n)
        break
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

i = 0
while True:
    if i*(i+1)//2 >= n:
        break
    i += 1

while True:
    print(i)
    n -= i
    i -= 1
    if n == 0:
        break
    if n - i <= 0:
        print(n)
        break

Submission status: Accepted

Solution code:
N = int(input())

checkpoint = 0
summation = 0

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

unn = summation - N
for a in range(1, checkpoint+1):
    if a != unn:
        print(a)

Submission status: Accepted

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

if s != N:
    Ans.remove(s-N)
for a in Ans:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())

def search_ans(max,min):
    if max - min <= 4:
        for i in range(min,max+1):
            if (1+i)*i/2 >= N: #n問目まで全てOKだったときの合計得点… (1+n)*n/2 
                return i
                
    else:
        mid = int((max+min)//2)

        if (1+mid)*mid/2 < N:
            min = mid
        else:
            max = mid
            
        return search_ans(max,min)
    
ans_max = search_ans(N,1) #最大値を探す

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

Submission status: Accepted

Solution code:
N = int(input())

import math

ans = []

def calc(N):
  ans_q = math.ceil((2*N+1/4)**(1/2)-1/2)
  ans.append(ans_q)
  return N-ans_q

while N != 0:
  N = calc(N)

[print(x) for x in sorted(ans)]

Submission status: Accepted

Solution code:
import math

N = int(input())

K = math.ceil((-1 + math.sqrt(1 + 8 * N))/2)

L = int((1 + K) * K //2 - N)

while K:
  if K != L:
    print(K)
  K -= 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

i=1
sum=1
ans=[1]
while sum<n:
  i+=1
  sum+=i
  ans.append(i)

sa=sum-n
if sa!=0:
  ans.remove(sa)

for i in ans:
  print(i)

Submission status: Accepted

Solution code:
from math import sqrt

def readinput():
    n=int(input())
    return n

def main(n):
    k=int((-1+sqrt(1+8*n))/2)
    while(k*(k+1)//2<n):
        k+=1
    dif=k*(k+1)//2 - n
    for i in range(1,dif):
        print(i)
    for i in range(dif+1,k+1):
        print(i)

if __name__=='__main__':
    n=readinput()
    main(n)

Submission status: Accepted

Solution code:
n = int(input())

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

l.remove((i+1)*i//2-n)

for j in l:
    print(j)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
Y = 0
su = 0
i = 1
while su < N:
    su += i
    i += 1
    Y = i
i = 0
sa = su - N
for i in range(1, Y):
    if i == sa:
        continue
    print(i)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
m=math.ceil(pow(2*n+1/4,0.5)-1/2)
s=m*(m+1)//2
for i in range(1,m+1):
  if i!=s-n:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

s = 0
i = 0
ans = []
while s < N:
  i += 1
  s += i
  ans.append(i)
dele = s - N
if dele != 0:
  ans.remove(dele)

for t in ans:
  print(t)

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
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    for i in range(1, 10000):
        if i * (i + 1) / 2 >= n:
            mx = i
            break
    # print(mx)
    ans = []
    for i in ([i for i in range(1, mx+1)[::-1]]):
        if n >= i:
            ans.append(i)
            n -= i


    if n != 0:
        sys.exit(1)

    for an in ans:
        print(an)


def main():
    n = getN()
    for _ in range(n):
        solve()


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

Submission status: Accepted

Solution code:
n=int(input())
s=set()
current=1
cusum=0
while cusum<n:
  cusum+=current
  s.add(current)
  current+=1
if cusum-n in s:
  s.remove(cusum-n)
for i in s:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
sum_i = 0  # 問題のインデックスの合計
i = 0
while sum_i < n:
    i += 1
    sum_i += i
for ans in range(1, i+1):
    if ans == sum_i - n:
        continue
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

for j in range(1, ans + 1):
    if exc != j:
        print(j)

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

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

# print(cnt)

while n:
    if n>=cnt:
        n-=cnt
        print(cnt)
        cnt-=1
    else:
        print(n)
        n=0

Submission status: Accepted

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

N = int(input())

# [1,N]の部分集合で合計がちょうどNになる.最大値が最小
# 合計が初めてNを超えるときまでの集合を使って作ることができる
# そして差の数字は必ずその集合の中に含まれる

su = 0
for i in range(N + 1):
    su += i
    if su >= N:
        break
# iまでの数字で必ずNは作れる
ans = list(range(1, i + 1))
if su - N != 0:
    ans.remove(su - N)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    max, dif = 0, 0
    for i in range(1, 10000):
        s = i * (i + 1) // 2
        if s >= n:
            max = i
            dif = s - n
            break
    [print(i) for i in range(1, max + 1) if i != dif]

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

n = int(input())
end = math.ceil((-1 + (1 + 8 * n)**(0.5)) / 2)
ans = [j for j in range(1,end+1)]
sum_to_end = ( end ** 2 + end ) // 2

if sum_to_end != n:
    ans.remove(sum_to_end - n)

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

Submission status: Accepted

Solution code:
import math

n = int(input())
end = math.ceil((-1 + (1 + 8 * n)**(0.5)) / 2)

ans = [j for j in range(1, end+1)]

sum_to_end = ( end ** 2 + end ) // 2

if sum_to_end != n:
    ans.remove(sum_to_end - n)

print('\n'.join(map(str, ans)))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()

K = ceil((-1+sqrt(1+8*N))/2)
tmp = K*(K+1)//2 - N

for i in range(K, 0, -1):
	if tmp < i:
		print(i)
	else:
		tmp -= i

Submission status: Accepted

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

N = int(readline())

p = 0
ans = set()
for i in range(1,N + 1):
  p += i
  ans.add(i)
  if p >= N:
    break
    
if p == N:
  for a in ans:
    print(a)
  exit(0)
ans.remove(p - N)
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n = int(input())
i = 1
s = 1
ss = set([1])
while s<n:
    i += 1
    s += i
    ss.add(i)
    
if s>n:
    ss.remove(s-n)
write("\n".join(map(str, ss)))

Submission status: Accepted

Solution code:
n=int(input())
a=[1]
while sum(a) < n:
  a.append(a[-1]+1)
if sum(a) != n:
  b=sum(a)-n
  a[b-1:b]=[]
print(*a,sep="\n")

Submission status: Accepted

Solution code:
n = int(input())
"""
全探索→200点
"""
cnt = 1
while True:
	t = cnt*(cnt-1)//2
	if n < t:
		break
	cnt += 1
s = cnt*(cnt-1)//2-n
for i in range(1, cnt):
	if i != s:
		print(i)

Submission status: Accepted

Solution code:
N = int(input())
l = [int(x) for x in range(1,N+1)]

total_num,max_num = 0,0

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

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

if total_num == N:
  for i in range(max_num):
    print(i+1)
else:
  ng_num = total_num - N
  for j in range(max_num):
    if j+1 != ng_num:
      print(j+1)

Submission status: Accepted

Solution code:
n=int(input())

ans=[1]
i=1
s=1
while True:
    if s>=n:
        break
    i+=1
    s+=i
    ans.append(i)

dif = s-n
if dif==0:
    for i in range(len(ans)):
        print(ans[i])
    exit(0)

for i in range(len(ans)):
    if ans[i]==dif:
        continue
    print(ans[i])

Submission status: Accepted

Solution code:
n=int(input())

import bisect

ans=[1]
i=1
s=1
while True:
    if s>=n:
        break
    i+=1
    s+=i
    ans.append(i)

dif = s-n
if dif==0:
    for i in range(len(ans)):
        print(ans[i])
    exit(0)
    
index = bisect.bisect_left(ans,dif)

for i in range(len(ans)):
    if i==index:
        continue
    print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

    for i in l:
        print(i)

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:
        exclusion = -1
        if sm-N != 0:
            exclusion = sm-N

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 12 20:20:11 2020

@author: NEC-PCuser
"""


N = int(input())

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

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

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

for i in li:
    print(i)

Submission status: Accepted

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

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,ans,i = int(input()),0,1
while ans<n:
    ans+=i
    i+=1
#print("{},{}".format(ans,i))
if ans==n:
    for j in range(i-1):
        print(j+1)
else:
    i-=1
    while i>=1:
        if n==0:
            break
        if n>=i:
            print(i)
            n-=i
        i-=1

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())

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

n = s - N

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

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

Submission status: Accepted

Solution code:
#import itertools
#import bisect
import math

N = int(input())
L = [i for i in range((N+2)//2+2)]
num = math.floor(pow(2*(N-1),0.5))
    
for i in range(num,len(L)):
    if N == i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
    elif N < i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
Left = Max - N 
#print(num,Left,Max,index,L)
#acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))
#print(acu) 
#index = bisect.bisect_left(acu,N)
#print(index)
 
#if acu[index] == N:
#    Max = acu[index-1]
#else:
#    Max = acu[index]
#Left = Max - N

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
skip = -1
for i in range(1,n+1):
    sum += i
    if sum >= n:
        skip = sum - n # 超過分 skip <= n
        last = i
        break
for i in range(1,last+1):
    if i == skip:
        continue
    else:
        print(i)

Submission status: Accepted

Solution code:
from itertools import accumulate, count

n = int(input())

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

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

Submission status: Accepted

Solution code:
from itertools import accumulate

n = int(input())

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    temp=0
    ans=[]
    dame=0
    end=0
    for i in range(1,10**7):
        temp+=i
        if temp>=N:
            dame=temp-N
            end=i
            break
    for j in range(1,end+1):
        if j!=dame:print(j)
#%%submit!
resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in p:
    print(i)

Submission status: Accepted

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

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