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: Wrong Answer

Solution code:
import math
import sys
N=int(input())
c=int(math.sqrt(2*N))
for i in range(c,N):
  a=i*(i+1)//2
  if a>=N:
    L=list(range(1,i+1))
    L.pop(a-N-1)
    for j in range(len(L)):
      print(L[j])
    sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

for k in range(1,N+1):
    if(N >= 2 * k + 1):
        N -= k
        print(k)
    else:
        print(N)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

for k in range(1,N):
    if(N >= 2 * k + 1):
        N -= k
        print(k)
    else:
        print(N)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

for k in range(N):
    if(N >= 2 * k + 1):
        N -= k
    else:
        break

print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[];ans=0
for i in range(1,n):
  ans+=i
  a.append(i)
  if ans>=n: break
for x in a:
  if x==ans-n: continue
  else: print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
t = n
for i in range(1,n//2+2):
    if t - i > i: 
        print(i)
    else:
        print(t)
        break
    t -= i
    # print(t, '-')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

a = 0
n = 1
for n in range(1, N):
    a += n
    if a >= N:
        break

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

Submission status: Wrong Answer

Solution code:
n,a=int(input()),[]
for i in range(int(round(n))+1,0,-1):
  if n>=i:n-=i;a.append(i)
  if n==0:break
for i in a[::-1]:print(i)

Submission status: Wrong Answer

Solution code:
n=int(input());print(int(round(n*2))+1if n!=1else"1")

Submission status: Wrong Answer

Solution code:
n=int(input());print(int(round(n)*2)+1if n!=1else"1")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = float(input())

import math

if  math.floor(math.sqrt(2*n+0.25)-0.5)==math.sqrt(2*n+0.25)-0.5:
    for i in range(math.floor(math.sqrt(2*n+0.25)-0.5)):
        print(i+1)
else:
    while n>0:
        x = math.floor(math.sqrt(2*n+0.25)-0.5)
        print(x+1)
        n -= x+1

Submission status: Wrong Answer

Solution code:
print(1)
print(2)
print(3)

Submission status: Wrong Answer

Solution code:

print(2)

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
print(1)
print(2)

Submission status: Wrong Answer

Solution code:
N = int(input())
q, r = divmod(N, 2)
if r == 0:
    ans = [q-1, q+1]
else:
    ans = [q, q+1]
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
N = int(input())
bin_N = format(N, 'b')
ans = []
if set(bin_N[1:]) == {'0'}:
    ans = [1, N - 1]
else:
    ans = [2**i for i, s in enumerate(reversed(bin_N)) if s == '1']
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
ex=0
for i in range(1,10000):
  tmp=i*(i+1)//2
  if tmp>=n:
    ans=i
    ex=tmp-n
    break
if n==1:
  print(1)
else:
  for i in range(1,ans):
    if i!=ex:
      print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
now = 0
count = 0
while n > 0:
  n -= count
  now += count
  count += 1
ignore = now - N
for i in range(1, count+1):
  if i == ignore:
    continue
  print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=math.ceil(math.sqrt(n*2))
for i in range(x+1,0,-1):
    y=sum(range(i))
    if y<=n:
        s=list(range(1,i))
        t=n%y
        break
s=s[::-1]
for r in range(t):
    s[r]+=1
for h in s[::-1]:
    print(h)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=int(n**0.5)
t=0
for i in range(10**5):
    if i*(i+1)//2>n:
        t=i
        l=t*(t+1)//2-n
        break
for i in range(1,t):
    if i!=l:
        print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=int(n**0.5)
t=0
for i in range(p,10**5):
    if i*(i+1)//2>n:
        t=i
        l=t*(t+1)//2-n
        break
for i in range(1,t):
    if i!=l:
        print(i)

Submission status: Wrong Answer

Solution code:
import heapq

n = int(input())

def divide_two(s, heap):
    use = -heapq.heappop(heap)
    #print(s, heap)
    #print(use)
    top, bot = use//2+use%2, use//2
    while True:
        #print(top, bot)
        if top >= use or bot <= 0:
            heapq.heappush(heap, -use)
            return False
        if top == bot:
            top += 1
            bot -= 1
            continue
        if top in s or bot in s:
            top += 1
            bot -= 1
            continue
        heapq.heappush(heap, -top)
        heapq.heappush(heap, -bot)
        s.add(top)
        s.add(bot)
        return True
s = set([n])
heap = [-n]
while divide_two(s, heap):
    pass
for i in heap:
    print(-i)

Submission status: Wrong Answer

Solution code:
import heapq

n = int(input())

def divide_two(s, heap):
    use = -heapq.heappop(heap)
    #print(s, heap)
    #print(use)
    top, bot = use//2+use%2, use//2
    while True:
        #print(top, bot)
        if top >= use or bot <= 0:
            print(use)
            exit()
        if top == bot:
            top += 1
            bot -= 1
            continue
        if top in s or bot in s:
            top += 1
            bot -= 1
            continue
        heapq.heappush(heap, -top)
        heapq.heappush(heap, -bot)
        s.add(top)
        s.add(bot)
        return True
s = set([n])
heap = [-n]
while divide_two(s, heap):
    pass

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
for i in range(10**7):
  ans.append(i+1)
  su = i+1*(i+2)//2
  if su > n:
   ans.remove(su-n)

   break
  elif su == n:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
Ulimit = int(math.sqrt(2 * N))
if Ulimit ** 2 == 2 * N:
    Ulimit -= 1

Total = Ulimit * (Ulimit + 1) // 2
Diff = N - Total
Ans = [int(i) for i in range(1, Ulimit+1)]
Ans[-Diff] += Diff
for a in Ans:
    print(a)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
Ulimit = int(math.sqrt(2 * N))

Total = Ulimit * (Ulimit + 1) // 2
Diff = N - Total
Ans = [int(i) for i in range(1, Ulimit)]
Ans.append(Ulimit + Diff)
for a in Ans:
    print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(1, N):
    if (1 + i) * i // 2 >= N:
        if i % 2 == 0:
            print(N // 2 + 1)
            print(N // 2 - 1)
        else:
            print(N // 2 + 1)
            print(N // 2)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

while N:
    print(N // 2 + 1)
    N -= (N // 2 + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

l, r = -1, N
while r - l > 1:
    m = (l + r) // 2
    S = m*(1 + m) // 2

    if S >= N:
        r = m
    else:
        l = m

X = r * (1 + r) // 2 - N
if X == 0:
    print(*list(range(1, r+1)), sep="\n")
else:
    print(*list(range(1, X)) + list(range(X+1, m+1)), sep="\n")

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

N = getN()
for i in range(10**4):
    if i*(i+1)/2 >= N:
        M = i
        upper =int(M*(M+1)/2)
        break

diff = upper-N
for i in range(M):
    j = i+1
    if j is not diff:
        print(j)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = 0
for i in range(n):
    if i*(i+1)//2 >= n:
        a = i
        break

b=[]
c = a*(a+1)//2
for i in range(1,a+1):
    b.append(i)


if c > n:
    b.pop(c-n-1)
    
for i in b:
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())

sum = 0
m = 0
for i in range(1, 10**3 + 1):
    sum += i
    if sum >= N:
        m = i
        break

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

Submission status: Wrong Answer

Solution code:
import sys

def calc(n):
    i=1
    sm = 0
    st = set()
    if n<=2:
        st.add(n)
        return st
    while sm<=n:
        st.add(i)
        sm += i
        i+=1
    st = st - calc(sm-n)
    return st
sys.setrecursionlimit(10000000)
n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Submission status: Wrong Answer

Solution code:
a = int(raw_input())

_sum = 0
i = 1
while _sum <= a:
    _sum += i
    i += 1
odd = _sum - a
for b in range(i):
    if b + 1 == odd:
        continue
    print b + 1

Submission status: Wrong Answer

Solution code:
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

l=[]
for i in range(1,5001):
    if i%2==0:
        l.append((1+i)*(i/2))
    else:
        l.append((1+i)*(i/2)+(i+1)/2)
n=int(raw_input())
if n in l:
    for i in range(1,l.index(n)+2):
        print i
        exit()
chk=bisect.bisect_right(l,n)
tmp=l[chk]
for i in range(1,chk+2):
    if i!=tmp-n:
        print i

Submission status: Wrong Answer

Solution code:
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

l=[]
for i in range(1,5001):
    if i%2==0:
        l.append((1+i)*(i/2))
    else:
        l.append((1+i)*(i/2)+(i+1)/2)
n=int(raw_input())
if n in l:
    for i in range(1,l.index(n)+2):
        print i
chk=bisect.bisect_right(l,n)
tmp=l[chk]
for i in range(1,chk+2):
    if i!=tmp-n:
        print i

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(raw_input())
NList = []
if N == 1:
    print 1
if N == 2:
    print 2
if N >= 3:
    NList = [1,2]
    for i in xrange(N-3):
        if min(NList) != 1:
            NList.append(1)
        else :
            diff = [NList[i]+1 == NList[i+1] for i in xrange(len(NList)-1)]
            print diff
            if all(diff):
                max_index = np.argmax(NList)
                NList[max_index]+=1
            else:
                addindex = diff.index(False)
                NList[addindex]+=1
        NList.sort()
    for e in NList:
        print e

Submission status: Wrong Answer

Solution code:
N=int(input())
x=int((-1+(1+8*N)**0.5)/2)

if x*(x+1)/2==N:

    for i in range(x):
        print(i+1)
    exit()
else:
    print(x+1)
    ans=N-x-1
    for i in range(x-1,0,-1):
        ans -= i+1
        if ans <0:
            ans += i+1
            continue
        else:
            print(i+1)

        if ans==0:
            break

Submission status: Wrong Answer

Solution code:
n = int( raw_input() )

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

print i
while n > 0:
    if i <= n:
        print i
        n -= i
    i -= 1

Submission status: Wrong Answer

Solution code:
import sys

#f = open('input.txt')
f = input()

N = int(f)


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

# print(' '.join(map(str, out)))

Submission status: Wrong Answer

Solution code:
N=int(input())
x=int((-1+(1+8*N)**0.5)/2)

if x*(x+1)/2==N:

    for i in range(x):
        print(i+1)
        exit()
else:
    print(x+1)
    ans=N-x-1
    for i in range(x-1,0,-1):
        ans -= i+1
        if ans <0:
            ans += i+1
            continue
        else:
            print(i+1)

        if ans==0:
            break

Submission status: Wrong Answer

Solution code:
a = int(input().strip())

tmp = []
res = []
ind = 1

def bar(foo,hoge):
    if(foo == 0):
        return
    if foo == 1:
        res.append(1)
        return
    elif foo == 2:
        res.append(2)
        return
    for i in reversed(range(hoge)):
        if (tmp[i] >= foo):
            res.append(i + 1)
            bar(foo - (i + 1) , i)
            return
        

for i in range(1000000):
    ind = ind + i
    tmp.append(ind)
    if ind >= a :
        bar(a, i+1)
        break
for i in res:
    print(i)

Submission status: Wrong Answer

Solution code:
import sys

n = int(next(sys.stdin).strip())

i = 1
while n > 0:
    if n == i or n > i * 2:
        print(i)
        n -= i
    i += 1

Submission status: Wrong Answer

Solution code:
import sys
import math

N = int(sys.stdin.readlines()[0].strip())

r = N
while r >= 2:
    ans = int((1 + math.sqrt(1 + 8*r))/2)
    print ans
    r -= ans

if r != 0:
    print 1

Submission status: Wrong Answer

Solution code:
N = input()
i = 1
while i*(i-1)/2 < N:
    i += 1

print i

N -= i
j = i-1
while N > 0:
    if N - j >= 0:
        print j
        N -= j
    j -= 1

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
r=n+1
l=1
while r-l>1:
    m=(r+l)/2
    if m*(m+1)/2>n:
        r=m
    else:
        l=m
if l*(l+1)/2==n:
    print(l)
else:
    for i in xrange(1,l+2):
        if (l+1)*(l+2)/2-i==n:
            idx=i
            break
    for i in xrange(1,l+2):
        if i==idx:continue
        print(i)

Submission status: Wrong Answer

Solution code:
N = input()
i = 1
while N > 0:
    if N - i == 0 or N - i > i:
        print i
        N -= i
    i += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = 0
cnt = 1
while True:
    s += cnt
    if s < n <= s+cnt+1:
        use = cnt+1
        sub = use*(use+1)//2 - n
        for i in range(use):
            if i+1 == sub:
                continue
            print(i+1)
        exit()
    else:
        cnt += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**9)

N = int(input())

L = [0]
l = 0
for i in range(1,10**6) :
    l += i
    L.append(l)
ans = []
while N > 0 :
    for i in range(len(L))  :
        #print(L[i],N,L[i+1])
        if (L[i]+1 <= N <= L[i+1]) :
            ans.append(i+1)
            N -= i+1
            break
    
print(*ans,sep="\n")

Submission status: Time Limit Exceeded

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

for k in range(1,n+1):
    s = k*(k+1)//2
    if s==n:
        res = set(range(1,k+1))
        break
    if s>=n and (s-n)<=k:
        res = set(range(1,k+1))
        res.remove(s-n)

for r in res:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(raw_input())
NList = []
if N == 1:
    print 1
if N == 2:
    print 2
if N >= 3:
    NList = [1,2]
    findex = None
    for i in xrange(N-3):
        if min(NList) != 1:
            NList.append(1)
            findex = None
        else :
            if findex == None:
                NList[-1]+=1
                findex = len(NList)-2
            else:
                NList[findex]+=1
                findex -= 1
                
#            diff = [NList[i]+1 == NList[i+1] for i in xrange(len(NList)-1)]
#            print NList
#            print diff
            
#            if all(diff):
#                max_index = np.argmax(NList)
#                NList[max_index]+=1
#            else:
#                addindex = diff.index(False)
#                NList[addindex]+=1
        NList.sort()
#        print NList
#        print findex
    for e in NList:
        print e

Submission status: Memory Limit Exceeded

Solution code:
N = int(input())
M = list(range(1, N+1))

for i in range(N):
    s = sum(M[:i+1])
    if s >= N:
        c = s - N
        for l in M[:i+1]:
            if c != l:
                print(l)
        break

Submission status: Memory Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
N = int(input())
a = [ tmp for tmp in range(1, N+1) ]
ans = 0
before = a[0]
factor = 0
for tmp in range(N):
    ans += a[tmp]
    if before < N and N <= ans:
        factor = tmp
        break
    before = ans
difference = ans - N
if difference != 0:
    for tmp in range(factor+1):
        if difference != a[tmp]:
            print(tmp+1)
        else:
            pass
else:
    for tmp in range(factor+1):
        print(tmp+1)

Submission status: Accepted

Solution code:
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
A=[i*(i+1)//2 for i in range(4500)]

def qq(score,ANS):
    if score==0:return ANS
    if score==1: return ANS+[1]
    maxmon= bileft(A,score)
    return qq(score-maxmon, ANS+[maxmon])
ANS=qq(n,[])
for i in ANS:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
diff = 0
last = 0
for i in range(1, N+1):
    sum += i
    if sum >= N:
        diff = sum - N
        last = i
        break
for i in range(1, last+1):
    if i == diff:
        continue
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

total = []
for i in range(1,n+1):
  
  if sum(total)>=n:
    break
  total.append(i)
  
if sum(total)-n<total[-1]:
  if sum(total)-n in total:
    del total[sum(total)-n-1]
      
for i in total:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n + 1):
    if (i + 1) * i // 2 >= n:
        ans = []
        for j in range(i, 0, -1):
            if n - j >= 0:
                n -= j
                ans.append(j)

        print(*ans[::-1], sep="\n")
        exit()

Submission status: Accepted

Solution code:
import math
import sys
N=int(input())
c=int(math.sqrt(2*N))
for i in range(c-1,N+1):
  a=i*(i+1)//2
  if a>N:
    L=list(range(1,i+1))
    L.pop(a-N-1)
    for j in range(len(L)):
      print(L[j])
    sys.exit()
  elif a==N:
    L=list(range(1,i+1))
    for i in range(len(L)):
      print(L[i])
    sys.exit()

Submission status: Accepted

Solution code:
n=int(input())

c=0
for i in range(1,10000):
  c+=i
  if c>n:
    break
for j in range(1,i+1):
  if j!=c-n:
    print(j)

Submission status: Accepted

Solution code:
def answer(n):
    _except = 0
    stack = 0
    arr = []
    i = 0
    while(True):
        if stack == n:
            break
        if stack > n:
            _except = stack - n
            break
        i += 1
        arr.append(i)
        stack += i
    for a in arr:
        if a == _except:
            continue
        print(a)

n = int(input())
answer(n)

Submission status: Accepted

Solution code:
N=int(input())
for i in range(1,N+1):
   if (1+i)*(i/2) >= N:
      break
S=i
for i in reversed(range(1,S+1)):
   if N >=i:
      N-=i
      print(i)
   if N == 0:
      exit()

Submission status: Accepted

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

Submission status: Accepted

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

k = 0
sum = 0
while(k**2 + k < 2*N):
  k += 1
  sum += k
  vec.append(k)
if(sum - N):
  vec.remove(sum - N)


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

Submission status: Accepted

Solution code:
n = int(input())
# sum(i + 1 for i in range(4500)) = 10127250

num = 0
for i in range(4500):
  num += (i + 1)
  if num >= n:
    break
print(*(j + 1 for j in range(i + 1) if j + 1 != num - n), sep='\n')

Submission status: Accepted

Solution code:
N=int(input())
tmp=0
b=0
for i in range(1,N+10):
    n=(i+1)*i//2
    if(n>=N):
        tmp=n-N
        b=i
        break
for i in range(1,b+1):
    if(i==tmp):
        continue
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
#M = list(range(1, N+1))
s = 0
for i in range(1, N+1):
    s += i
    if s >= N:
        c = s - N
        for l in range(1, i+1):
            if c != l:
                print(l)
        break

Submission status: Accepted

Solution code:
n=int(input())
a=[];ans=0
for i in range(1,n+1):
  ans+=i
  a.append(i)
  if ans>=n: break
for x in a:
  if x==ans-n: continue
  else: print(x)

Submission status: Accepted

Solution code:
n = int(input())


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


tmp = 0
for i in range(n):
    if intsum(i + 1) >= n:
        tmp = i + 1
        break
for i in range(tmp):
    if i + 1 == intsum(tmp) - n:
        continue
    print(i + 1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

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

n=ii()

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

ans=0
i=0
p=0
while ans<n:
    i+=1
    ans+=i
if ans>n:
    p=ans-n

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    ok = N + 1
    ng = 0
    while abs(ok - ng) > 1:
        m = (ok + ng) // 2
        if m * (m + 1) // 2 >= N:
            ok = m
        else:
            ng = m
    for i in reversed(range(1, ok + 1)):
        if N >= i:
            print(i)
            N -= i


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

while n > 0:
    half = int(n**0.5)
    while half * (half+1) // 2 < n:
        half += 1
    print(half)
    n -= half

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1,10**5):
    ans += i
    if ans >= n:
        k = i
        break


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

Submission status: Accepted

Solution code:
n=int(input())
def bs(n):
    l,r=0,10**9
    while l+1!=r:
        if n>(((l+r)//2)**2+(l+r)//2)/2:
            l=(l+r)//2
        else:
            r=(l+r)//2
    return r
a=(bs(n)**2+bs(n))//2-n
for i in range(bs(n)):
    if i+1==a:
        continue
    print(i+1)

Submission status: Accepted

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

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

i = 0
s = 0
while s <= N:
    i += 1
    s += i
ans = set(range(1, i + 1))
ans.remove(s - N)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
Ans = []
n = N
for i in range(1, 10000000):
    if n >= i:
        n -= i
        Ans.append(i)
    else:
        break
for i in range(1, n+1):
    Ans[-i] += 1
print("\n".join(map(str, Ans)))

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




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

    now_ind = 1
    while 1:
        if (now_ind + 1) * now_ind >= num * 2:
            break
        now_ind += 1
    hiku = ((now_ind + 1) * now_ind) // 2 - num

    for i in range(now_ind):
        if i + 1 == hiku:
            continue
        print(i + 1)







if __name__ == '__main__':
    main()

Submission status: Accepted

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