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())
for i in range(1,n+2):
  if i*(i+1)//2 > n:
    x = i
    y = i*(i+1)//2 - n
    break
for i in range(1,x+1):
  if i != y:
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int):
    c = 0
    i = 1
    ans = []
    while c <= N:
        c += i
        ans.append(i)
        i += 1
    
    t = c-N

    if c == N:
        print(ans)

    else:
        for i in ans:
            if i != t:
                print(i)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def main():
    N = int(input())
    ans = set()
    for i in range(1, N+1):
        ans.add(i)
        if sum(ans) >= N:
            break
    m = sum(ans) - N
    if m in ans:
        ans.remove(m)
    for i in ans:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def main():
    N = int(input())
    import math
    while N > 0:
        n = (-1 + math.sqrt(1 + 8*N)) / 2
        n = int(-(-n//1))
        print(n)
        N -= n


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def examA():
    H, W = LI()
    S = [LSI() for _ in range(H)]
    Alpha = [chr(ord('A') + i) for i in range(26)]
    for i in range(H):
        for j in range(W):
            if S[i][j]=="snuke":
                ans = str(Alpha[j]) + str(i+1)
    print(ans)
    return

def examB():
    N = I()
    ans = []
    cur = int((N*2-1)**0.5)+1
    ansC = (cur+1)*cur//2
    neg = ansC-N
    if neg>cur:
        cur -=1
        ansC = (cur + 1) * cur // 2
        neg = ansC - N
    for i in range(1,cur+1):
        if i!=neg:
            ans.append(i)
    for v in ans:
        print(v)
#    print(cur,neg)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()

Submission status: Accepted

Solution code:
n = int(input())
ans = set()
limit_num = float('inf')
total = 0
for i in range(1, n + 1):
    total += i
    if total >= n:
        limit_num = i
        break
remove_num = total - n
for i in range(1, limit_num + 1):
    if i != remove_num:
        ans.add(i)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
ans = set()
num = float('inf')
total = 0
for i in range(1, n + 1):
    total += i
    if total >= n:
        num = i
        break
remove_num = total - n
for i in range(1, num + 1):
    if i != remove_num:
        ans.add(i)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
x = int((2*N) ** .5)
if x * (x+1) < 2 * N:
    x += 1
diff = x * (x+1) * .5 - N
for i in range(x, 0, -1):
    if i <= diff:
        diff -= i
    else:
        print(i)
# 57

Submission status: Accepted

Solution code:
N = int(input())
for i in range(10000):
    if i * (i+1) // 2 >= N:
        k = i
        break

while N:
    if N <= k:
        print(N)
        break
    N -= k
    print(k)
    k -= 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
tmp = 0
right = 1
for i in range(1, N+1):
    tmp += i
    if tmp >= N:
        right = i
        break
forbidden = tmp - N
for i in range(1, right+1):
    if i == forbidden:
        continue
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
m = 0
l = 0
while l < n:
    m += 1
    l = (1 + m) * m // 2
ans = list(range(1, m + 1))
if l != n:
    ans.remove(l - n)
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
def biserch(ok,ng):
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        if judge(mid):
            ok = mid
        else:
            ng = mid
    return ok

def judge(x):
    if x * (x + 1) // 2 >= N:
        return True
    else:
        return False

N = int(input())
K = biserch(10 ** 7, 0)
d = K * (K + 1) // 2 - N
for i in range(1, K + 1):
    if i == d:
        continue
    print(i)

Submission status: Accepted

Solution code:
def solve(n):
    score = 0
    for p in range(1, n+1):
        score += p
        if score >= n:
            break
    x = score - n
    res = list(range(1,x)) + list(range(x+1,p+1))
    return "\n".join(map(str, res))

n = int(input())
print(solve(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans.discard(s - n)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

ret = []

for i in range(10000) :
    if i * (i + 1) // 2 >= N :
        break
        
for j in range(i, 0, -1) :
    if j <= N :
        ret.append(j)
        N -= j
        
for r in ret[::-1] :
    print(r)

Submission status: Accepted

Solution code:
from itertools import accumulate
import bisect
n = int(input())
l = list(range(1,int((2*n)**0.5)+2))
l = list(accumulate(l))
a = []
while n:
  i = bisect.bisect_left(l,n)
  a.append(i+1)
  n-=i+1
print(*a,sep='\n')

Submission status: Accepted

Solution code:
n = int(input())


def calc(n):
    mx = 1
    while True:
        if n <= mx * (mx + 1) // 2:
            break
        mx += 1
    return mx


ans = []
while n > 0:
    x = calc(n)
    ans.append(x)
    n -= x

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

Submission status: Accepted

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

if N < 3:
    print(N)
    exit()

for i in range(1, N + 1):
    tmp = (i * (i - 1)) //  2
    if tmp >= N:
        ans = i - 1
        break

anslst = [i for i in range(ans, 0, -1)]
tmp = N - anslst[0]
print(anslst[0])
for i in anslst[1:]:
    if tmp - i < 0:
        continue
    if tmp == 0:
        break
    print(i)
    tmp -= i

Submission status: Accepted

Solution code:
n=int(input())
b=True
now=1
score=0
ans=[]
while b:
  if n-score>now:
    score+=now
    ans.append(now)
    now+=1
  else:
    ans.append(now)
    score+=now
    key=score-n
    b=False
for i in ans:
  if i!=key:
    print(i)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    i = 1
    sm = 1
    while sm < N:
        i += 1 
        sm += i

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    i = 1
    sm = 1
    while sm < N:
        i += 1 
        sm += i

    a = [i]
    n = N - i
    i -= 1
    while n != 0:
        if n - i >= 0:
            n = n - i
            a.append(i)
        i -= 1
    # print(a)
    for i in a:
        print(i)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import accumulate
from math import sqrt, ceil
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(ceil(sqrt(2 * N)) + 1)))

r = bisect_left(n, N)
answer = list(map(str, range(1, r + 1)))

if n[r] != N:
    d = n[r] - N
    answer.remove(str(d))

print('\n'.join(answer))

Submission status: Accepted

Solution code:
from itertools import accumulate
from math import sqrt, ceil
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(ceil(sqrt(2 * N)) + 1)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Submission status: Accepted

Solution code:
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(2 * N)) + 2)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())

i = 1
q = []

while True:
    q.append(i)
    a = i * (i+1) // 2
    if N <= a:
        break
    i += 1

b = a % N
for j in range(len(q)):
    if q[j] != b:
        print(q[j])

Submission status: Accepted

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

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

    if n >= N:
        break

# print(ans)

m = n - N
if m > 0:
    ans.pop(m-1)

# print(n)
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N=int(input())
S=[1]
for i in range(1,N):
  S.append(S[i-1]+i+1)
p=0
j=0
if N==1:
  print(1)
else:
  while N>=S[j]:
    j += 1
  p=S[j]-N
  for i in range(1,j+2):
    if i!=p:
      print(i)

Submission status: Accepted

Solution code:
import math
a,n=[],int(input())
b=n
while n>1:
    a.append(math.floor((2*n)**0.5+1/2))
    n-=a[-1]
for i in range(len(a)):
    print(a[i])
if sum(a)!=b:
    print(1)

Submission status: Accepted

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

m=math.floor(math.sqrt(2*n))
if m*(m+1)//2<n:
  m+=1
needless=(m+1)*m//2-n
ans=sorted(set(range(1,m+1)) - set([needless]))
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
import sys
from math import floor, sqrt

def main():
    n = int(sys.stdin.readline().rstrip())
    m = floor(sqrt(2 * n))
    if m * (m + 1) // 2 < n:
        m += 1

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

    res = sorted(set(range(1, m + 1)) - set([needless]))
    print(*res, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from math import floor, sqrt

def main():
    n = int(sys.stdin.readline().rstrip())
    m = floor(sqrt(2 * n))
    if m * (m + 1) // 2 < n:
        m += 1
    M = m + 1

    needless = M * (M - 1) // 2 - n

    res = sorted(set(range(1, m + 1)) - set([needless]))
    print(*res, sep='\n')

if __name__ == '__main__':
    main()

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
  elif s > N:
    ans.pop(s-N-1)
    break
  
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N=int(input())
for m in range(1,5*10**3):
    if m*(m+1)//2>=N:
        break

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

Submission status: Accepted

Solution code:
N=int(input())
for m in range(1,10**9):
    if m*(m+1)//2>=N:
        break

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

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
  elif s > N:
    ans.pop(s-N-1)
    break
  
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
import itertools as it

import bisect

N=int(input())

lists = list(it.accumulate(range(1,N+1)))

output=[]
while N!=0:
    index = bisect.bisect_left(lists,N)+1
    N-=index
    output.append(index)

for i in output:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

l = 0
r = 10**7+1
while(l<r-1):
  m = (l+r)//2
  if m*(m+1)//2 <= N:
    l = m
  else:
    r = m
#print(l,m,r)
if N == l*(l+1)//2:
  ans = list(range(1,l+1))
else:
  ans = list(range(2,r+1))
  for i in range((r-1)*(r+2)//2-N):
    ans[i] -= 1
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
# 解説を観たのでそれをやってみるバージョン
# （最初に解いたやつは愚直に毎回最大値を求めていた（なんかしらんけど通った））
n = int(input())
cur = 0
target = 0
for i in range(1, n + 1):
    if i + cur >= n:
        target = i
        break
    cur += i

remove_num = sum([i for i in range(1, target + 1)]) - n
for i in range(1, target + 1):
    if i != remove_num:
        print(i)

Submission status: Accepted

Solution code:
# 最大値の最小値、ちょうどn/2臭い
# あとは帳尻合わせが効きそう
# 14とかだと7+4+2+1 （7+5+2でも7+4+3でもいい
# かと思いきや 1+2+3+4+5で15いくので, 5+4+3+2でよかった
# 10^7なので毎回足してもどうせ間に合う。これで答えの集合のうち最大値は確定
# あとはそれでnを引いて0になるまで -> これだと間に合わない

n = int(input())
ans = []
cur = 0

while cur != n:
    tmp = 0
    for i in range(1, n + 1 - cur):
        if i + tmp >= n - cur:
            tmp = i
            break
        tmp += i
    ans.append(tmp)
    cur += tmp
    # print("tmp = {}, cur = {}".format(tmp, cur))
# print(ans)
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N=int(input())

for i in range(1,N+1):
    if(N<=(i*(i+1)//2)):
        print(i)
        if(N==1 or N==2):
            exit()
        M=N-i
        j=i-1
        while(M>0):
            if(M>=j):
                M-=j
                print(j)
            j-=1
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from bisect import bisect_left, bisect_right

N=input()
L=[]
for i in range(1,N+1):
    if i==1:
        L.append(i)
    else:
        L.append(L[-1]+i)

max_n=bisect_left(L,N)+1

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

Submission status: Accepted

Solution code:
N = int(input())
K = 1
while (K * (K + 1) // 2) < N:
    K += 1
ans = []
for k in range(1, K + 1)[:: -1]:
    if N >= k:
        ans.append(k)
        N -= k
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
t = 1
while ans < n:
    ans += t
    t += 1
a_list = list(range(1, t))
a_list = list(set(a_list) - set([ans - n]))
for aa in a_list:
    print(aa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = int((-1 + (1+8*n)**(1/2) ) /2)
if s*(s+1)/2 == n:
    ans = [i  for i in range(1,s+1)]
elif s*(s+1)/2 < n:
    tmpans = [i for i in range(1,s+2)]
    #print(tmpans)
    #print(sum(tmpans) - n + 1)
    del tmpans[sum(tmpans) - n - 1]
    ans = tmpans
else:
    tpmans = [i for i in range(1,s+1)]
    #print(tmpans)
    #print(sum(tmpans) - n + 1)
    del tmpans[sum(tmpans) - n - 1]
    ans = tmpans
    
for i in ans:
    print(i)

Submission status: Accepted

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

N = int(input())
cs = 0
x = 0
for i in range(1, N + 1):
  x = i
  cs += x
  if cs >= N:
    break
for i in range(1, x + 1):
  if i == cs - N:
    continue
  print(i)

Submission status: Accepted

Solution code:

N = int(input())

now = 0
s = 0

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

for i in range(now):

    i += 1
    if i != s-N:
        print (i)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
use=0
for i in range(10000):
    if i*(i+1)>=2*n:
        use=i
        break
      
lists=[ i for i in range(1,use+1)]
distance=sum(lists)-n
while distance>0:
    for j in lists:
        if distance==j:
            lists.remove(j)
            distance-=j
for some in lists:
  print(some)

Submission status: Accepted

Solution code:
n = int(input())
total = 0
ng_number = -1
end_number = -1
for i in range(1, n + 1):
    total += i
    if total == n:
        end_number = i
        break
    elif total > n:
        ng_number = total - n
        end_number = i
        break
for i in range(1, n+1):
    if end_number < i:
        break
    if not ng_number == i:
        print(i)

Submission status: Accepted

Solution code:
n=int(input())
A=[]
cnt=0
add=0
for i in range(4472):
    cnt +=i+1
    A.append((cnt,i+1))
for i in range(len(A)-1):
    if A[i][0]<=n<=A[i+1][0]:
        add=(A[i+1][1],A[i+1][0]-n)
        break
for i in range(add[0]):
    if i+1==add[1]:continue
    print(i+1)

Submission status: Accepted

Solution code:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n=int(input())
    m=0
    while n>(m*(m+1))//2:
        m+=1
    for i in range(m):
        i+=1
        if not i == (m*(m+1))//2 - n:
            print(i)

main()

Submission status: Accepted

Solution code:
n=int(input())
k=1
i=1

while k<=n:
    i+=1
    k+=i
for j in range(1,i+1):
    if j==k-n:
        continue
    else:
        print(j)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
cnt = 0
accumlation = 0
for i in range(1, N+1):
    accumlation += i
    cnt += 1
    if accumlation > N:
        break
for j in range(1, cnt+1):
    if j != (accumlation - N):
        print(j)

Submission status: Accepted

Solution code:
n = int(input())

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

for ai in (a for a in range(1, a) if a != s - n):
    print(ai)

Submission status: Accepted

Solution code:
n=int(input())
A=[]
cnt=0
add=0
for i in range(4472):
    cnt +=i+1
    A.append((cnt,i+1))
for i in range(len(A)-1):
    if A[i][0]<=n<=A[i+1][0]:
        add=(A[i+1][1],A[i+1][0]-n)
        break

for i in range(add[0]):
    if i+1==add[1]:
        continue
    print(i+1)

Submission status: Accepted

Solution code:
'''
CODE FESTIVAL 2016 Final
B - Exactly N points
'''

if __name__ == "__main__":
    N = int(input())
    ans = list()
    res = N
    tmp = 1
    while True:
        if res <= 0:
            if res == 0:
                break
            else:
                ans.pop(ans.index(abs(res)))
                break
        ans.append(tmp)
        res -= tmp
        tmp += 1

    for a in ans:
        print(a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000)

def nat_sum(n):
  if n==0:
    pass
  else:
    k = 0
    for i in range(n):
      if i*(i+1)//2 < n <= (i+1)*(i+2)//2:
        k = i+1
        break
    print(k)
    nat_sum(n-k)
    
n = int(input())
nat_sum(n)

Submission status: Accepted

Solution code:
n=int(input())


if n==1:
    print(1)
    exit()
    
if n==2:
    print(2)
    exit()
    
for i in range(n):
    if i+i**2>=2*n:
        check=i

        break

total=(1+check)*check//2
out=total-n

for i in range(1,check+1):
    if i!=out:
        print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(10**4):
  if i * (i + 1) > 2 * N:
    a = i
    s = (a * (a + 1)) // 2
    break

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

Submission status: Accepted

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

#(方針) (k-1)k/2 <= N <k(k+1)/2 をみたすk　がイイ感じ
#→ (-1+sqrt(1+8N))//2 < k <= (1+sqrt(1+8N))//2 らへん
#k整数/区間の幅 1より k = int((-1+sqrt(1+8N))//2) or int((-1+sqrt(1+8N))//2) + 1
#丸め誤差あるかもしれないので,少し多めに


about_k = int((-1+math.sqrt(1+8*N))//2)
k = about_k
#print(k)
for i in range(about_k-10,(about_k+10)+1):
 if((i-1)*i < 2*N <= i*(i+1)): 
  #print('a; ',(i-1)*i,2*N)
  k = i
  break

ans = []
sum_p = N
for i in range(k):
  tmp = k-i #tmp = k,k-1,...,1
  if(sum_p-tmp >= 0):
   sum_p -= tmp
   ans.append(tmp)
  if(sum_p == 0): break
    
for i in range(len(ans)):
  print(ans[i])
#print('...',sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

m = int((n*2) ** 0.5)
if m*(m-1) >= n*2:
    m -= 1
elif m*(m+1) < n*2:
    m += 1

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

Submission status: Accepted

Solution code:
#%%
n = int(input())

i = 0
s = 0

while True:
    s += i
    if s > n:
        key = s - i
        key2 = n - key
        key3 = i - 1
        break
    else:
        i += 1

#print(key, key2, key3)

ans = []
j = 1
for i in range(key3):
    if i >= key3-key2:
        ans.append(j+1)
    else:
        ans.append(j)
    j += 1


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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(1, N+1):
    total = (i * (i + 1)) // 2
    if N <= total:
        for x in range(1, i+1):
            if total - N == x:
                continue
            print(x)
        break

Submission status: Accepted

Solution code:
N = int(input())

for i in range(10000):
    if i * (i + 1) / 2 == N:
        for i in range(1, i + 1):
            print(i)
        break
    elif i * (i + 1) / 2 > N:
        remove = i * (i + 1) / 2 - N
        for i in range(1, i + 1):
            if i != remove:
                print(i)
        break

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
cnt = 0
i = 1
while True:
    cnt += i
    if cnt >= n:
        break
    i += 1
for j in range(1,i+1):
    if j == cnt-n:
        continue
    print(j)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
cnt = 0
i = 1
if n == 1:
    print(1)
    quit()
elif n == 2:
    print(2)
    quit()
while True:
    cnt += i
    if cnt >= n:
        break
    i += 1
res = []
while n > 0:
    res.append(i)
    n -= i
    i -= 1
    if n > i:
        continue
    res.append(n)
    break
for i in range(len(res))[::-1]:
    print(res[i])

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    ans = []
    i = 1
    while i * (i + 1) // 2 < n:
        ans.append(i)
        i += 1
    ans.append(i)
    d = i * (i + 1) // 2 - n
    # print(ans)
    if d != 0:
        ans.remove(d)
    print("\n".join([str(i) for i in ans]))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans_sum = 0
max_num = 1
while True:
    if ans_sum + max_num >= n:
        break
    ans_sum += max_num
    max_num += 1

for i in range(1, max_num + 1)[::-1]:
    if i <= n:
        n = n - i
        print(i)

Submission status: Accepted

Solution code:
N=int(input())
M=[]
s=0

for i in range(5000):
  s+=i+1
  M.append(i+1)
  if s>=N:
    break
    
M=M[::-1]
for i in range(len(M)):
  if s-M[i]>N:
    M[i]=0
    s-=M[i]
  elif s-M[i]==N:
    M[i]=0
    break

for i in M:
  if i:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
for n in range(1, N+1):
  if n*(n+1)//2 >= N:
    break
d = n*(n+1)//2-N
s = set(range(1, n+1))
s.discard(d)
for i in s:
  print(i)
#print(sum(s))

Submission status: Accepted

Solution code:
import math
N = int(input())
M = (math.ceil((math.sqrt(1+8*N)-1)/2))
for m in range(0,M):
  if M-m <= N:
    print(M-m)
    N -= M-m
  else:
    if N!=0:
      print(N)
    break

Submission status: Accepted

Solution code:
import math
N=int(input())
M=int(math.sqrt(N*2-0.25)+0.5)
left = M*(M-1) // 2
sum_=0
for i in range(1,M-(N-left)):
    print(i)
    sum_ += i
for i in range(M-(N-left),M):
    print(i+1)
    sum_ += i+1

Submission status: Accepted

Solution code:
N=int(input())

sum=0
for i in range(1,N+1):
    sum+=i
    if sum==N:
        for i in range(1,i+1):
            print(i)
        exit()
    elif sum>N:
        for j in range(1,i+1):
            if not j==(i*(i+1)//2)-N:
                print(j)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(N):
    if N==0: return set()
    for n in range(N+1):
        S = (n+1)*n//2
        if S>=N:break
    return set(range(1,n+1)) - f(S-N)   

ans = f(int(input()))
for o in ans:
    print(o)

Submission status: Accepted

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())

if n==1 or n==2:
    print(n)
    exit()
s=0
for i in range(1,n+1):
    s+=i
    if s>=n:
        ans=[x for x in range(1,i+1) if x!=s-n]
        break
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

t = 0
i = 1

while t < n:

    t += i
    i += 1

pass_num = t - n

s = 0
i = 1
while s < n:
    if i != pass_num:
        s += i
        print(i)
        i += 1
    else:
        i += 1

Submission status: Accepted

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

for i in range(1,N+1):
    if sum(range(1, i + 1)) < N:
        continue
    else:
        ans = [i - 1,sum(range(1, i + 1)) - N]
        break
for i in range(ans[0]+1):
    if i + 1 != ans[1]:
        print(i + 1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#CODEFESTIVAL 2016 Final B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = []
tmp = 0
for i in range(1,n+1):
    if tmp + i <= n:
        ans.append(i)
        tmp += i
    else:
        tmp += i
        ans.append(i)
        ans.remove(tmp - n)
        break
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())

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

l = 0
r = 1000000
a = 0

for _ in range(100):
    a = (l + r) // 2
    c = f(a)
    if c < N:
        l = a
    elif c > N:
        r = a
    else:
        break

if f(a) == N:
    for i in range(1, a + 1):
        print(i)
else:
    p = f(a + 1) - N
    for i in range(1, a + 2):
        if i != p:
            print(i)

Submission status: Accepted

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