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: Time Limit Exceeded

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

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

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
if n == 1 or n == 2:
    print(n)
else:
    dp = [[] for _ in range(n+1)]
    dp[1].append(1)
    dp[2].append(2)
    max_element = [[] for _ in range(n+1)]
    max_element[0] = 0
    index = 1
    for i in range(1, n+1):
        for j in range(i):
            if index == n + 1:
                break
            max_element[index] = i
            index += 1
    # for i in range(3, n+1):
    #     dp[i] += [max_element[i]]
    #     dp[i] += dp[i - max_element[i]]
    # for ans in dp[n]:
    #     print(ans)
    s = 0
    for num in range(max_element[n], 0, -1):
        s += num
        if s <= n:
            print(num)
        else:
            s -= num

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

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

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
if n == 1 or n == 2:
    print(n)
else:
    # まにあわない
    dp = [[] for _ in range(n+1)]
    dp[1].append(1)
    dp[2].append(2)
    max_element = [[] for _ in range(n+1)]
    max_element[0] = 0
    index = 1
    for i in range(1, n+1):
        for j in range(i):
            if index == n + 1:
                break
            max_element[index] = i
            index += 1
    for i in range(3, n+1):
        dp[i].append(max_element[i])
        for num in dp[i - max_element[i]]:
            dp[i].append(num)
    for ans in dp[n]:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
L = []

ctr = 1
tmp = 0
for i in range(N) :
    if tmp == ctr :
        ctr += 1
        tmp = 1
    else :
        tmp += 1
    L.append(ctr)

ma = L[-1]
su = sum(np.arange(0,ma+1))
for i in range(1,ma+1) :
    if i != (su-N) :
        print(i)

Submission status: Time Limit Exceeded

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

ctr = 1
tmp = 0
for i in range(N) :
    if tmp == ctr :
        ctr += 1
        tmp = 1
    else :
        tmp += 1
    L.append(ctr)
ma = L[-1]

ans = [ma]
pa = 1
while sum(ans) != N :
    if (ans[-1]-pa + sum(ans)) <= N :
        ans.append(ans[-1]-pa)
        pa = 1
    else :
        pa += 1
ans = sorted(ans)
for i in ans :
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import bisect
N = int(input())
S = tuple(map(lambda x: (x**2+x)//2, range(N)))
while N > 0:
    i = bisect.bisect_left(S, N)
    N -= i
    #print(i, N, S)
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())

num = [2]
index = 1

if N < 3:
    print N
else:
    for i in xrange(N - 2):
        if len(num) == index:
            num.append(1)
            index = 0
        else:
            num[index] += 1
            index += 1
    
    for i in num:
        print i

Submission status: Memory Limit Exceeded

Solution code:
n = int(input())
ls = [0]*(n+1)
ls[1] = 1
ans = 0
for i in range(2,n+1):
    ls[i] = ls[i-1]+i
for j in range(1,n+1):
    if ls[j] >= n:   
        ans = j
        break
for k in range(1,ans+1):
    if ls[ans] - n != k:
        print(k)
    else:
        continue

Submission status: Memory Limit Exceeded

Solution code:
from itertools import accumulate
import bisect

N = int(input())
li = [i for i in range(1, N + 1)]
acc_list = list(accumulate(li))
index = bisect.bisect_left(acc_list, N)
garbage = acc_list[index] - N
for i in range(index + 1):
    if li[i] != garbage:
        print(li[i])

Submission status: Memory Limit Exceeded

Solution code:
from itertools import accumulate
from bisect import bisect_left

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

al = list(accumulate(l))
l = 0
b = bisect_left(al,N)
alb = al[b]
if alb == N:
  for i in range(b+1):
    print(i+1)
else:
  ng = alb - N
  for j in range(1,b+2):
    if j != ng:
      print(j)

Submission status: Memory Limit Exceeded

Solution code:
import itertools
#import bisect

N = int(input())

acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))
#print(acu) 
#index = bisect.bisect_left(acu,N)
#print(index)

for i in range(len(acu)):
    if N == acu[i]:
        index = i
        Max = acu[i-1]
        break
    elif N < acu[i]:
        index = i
        Max = acu[i]
        break
Left = Max - N    
#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: Memory Limit Exceeded

Solution code:
import itertools
#import bisect

N = int(input())
L = [i for i in range((N+1)//2+2)]

acu = list(itertools.accumulate(L))
#print(acu) 
#index = bisect.bisect_left(acu,N)
#print(index)

for i in range(len(acu)):
    if N == acu[i]:
        index = i
        Max = acu[i-1]
        break
    elif N < acu[i]:
        index = i
        Max = acu[i]
        break
Left = Max - N    
#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: Memory Limit Exceeded

Solution code:
import itertools
import bisect

N = int(input())
L = [i for i in range((N+2)//2+1)]

acu = list(itertools.accumulate(L))
#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: Memory Limit Exceeded

Solution code:
import numpy as np
import bisect

n = int(input())

cumsum = np.cumsum([i for i in range(1,n+1)])

idx = bisect.bisect_left(cumsum, n)

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

Submission status: Memory Limit Exceeded

Solution code:
import numpy as np
import bisect

n = int(input())

cumsum = np.cumsum([i for i in range(1,n+1)])

idx = bisect.bisect_left(cumsum, n)

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

for i in ans_l[::-1]:
    if i == 0:
        continue
    
    print(i)

Submission status: Memory Limit Exceeded

Solution code:
N=int(input())
ans=[]
count=[]
n=0
for i in range(1,N+1):
    n+=i
    count.append(n)
num=0
for i in range(N):
    if count[i]>=N:
        num=i+1
        break
tmp=N
chk=[0 for _ in range(N+1)]
c=0
while(1):
    if tmp==0:
        break
    if tmp>=num:
        tmp=tmp-num
        ans.append(num)
        chk[num]=1
        num=num-1
        c=num
    else:
        if chk[tmp]==0:
            ans.append(tmp)
            tmp=0
        else:
            for i in range(1,tmp):
                if chk[tmp-i]==0:
                    tmp=tmp-(tmp-i)
                    break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Memory Limit Exceeded

Solution code:
from itertools import accumulate
import bisect

n = int(input())
ls = [i for i in accumulate(range(1,n+1))]
while n:
    ind = bisect.bisect_left(ls, n)
    print(ind + 1)
    n -= ind + 1

Submission status: Memory Limit Exceeded

Solution code:
from itertools import accumulate
import bisect

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

Submission status: Memory Limit Exceeded

Solution code:
from itertools import accumulate
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(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: Memory Limit Exceeded

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

for i in range(1,N+1):
  temp_sum += i
  if temp_sum > N:
    break
    
# temp_sum==N
NL = list(range(N+1))
answer = NL[1:(temp_sum-N)] + NL[(temp_sum-N+1):i+1]

for a in answer:
  print(a)

Submission status: Accepted

Solution code:
N = int(input())
n = 1
exclude = 0
while n*(n+1)//2 < N:
  n += 1
exclude = n*(n+1)//2-N
for num in range(n+1):
  if num == exclude or num == 0:
    continue
  else:
    print(num)

Submission status: Accepted

Solution code:
N = int(input())
K = 0
k = 0
while K < N:
  k += 1
  K += k
while N > 0:
  if N >= k:
    print(k)
    N -= k
  k -= 1

Submission status: Accepted

Solution code:
n = int(input())

num_sum = 0
max_num = 1
for i in range(n+1):
    num_sum += i
    if num_sum >= n:
        max_num = i
        break

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

Submission status: Accepted

Solution code:
N=int(input())

sums=0
A=[]
i=1
while sums<N:
    sums+=i
    A.append(i)
    i+=1

cnt=sum(A)-N
for i in A:
    if i!=cnt:
        print(i)

Submission status: Accepted

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

#import
#import math
#import numpy as np
N = int(input())

i = 0
isum = 0

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

t = isum - N

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

Submission status: Accepted

Solution code:
import sys

N=int(input())
temp=0
ans=[]
for i in range(1,N+1):
  temp+=i
  if temp==N:
    for j in range(1,i+1):
      print(j)
    else:
      sys.exit()
  elif temp>N:
    for j in range(1,i+1):
      if j==temp-N:
        continue
      print(j)
    else:
      sys.exit()

Submission status: Accepted

Solution code:
#97 B - Exactly N points
N = int(input())

A = []
num = 1
cnt = 0
for _ in range(N):
    A.append(num)
    cnt += 1
    if num == cnt:
        cnt = 0
        num += 1

ans = [A[-1]]
tgt = N - A[-1]

for i in range(A[-1]-1,0,-1):
    tgt -= i
    if tgt == 0:
        ans.append(i)
        break
    if tgt < 0:
        tgt += i
        continue
    ans.append(i)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())

W = 0

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

Submission status: Accepted

Solution code:
N = int(input())

i = 1
num = 0
while True:
    num += i
    if num >= N:
        break
    i += 1

del_num = num - N
min_num = i
for i in range(1, min_num+1):
    if i != del_num:
        print(i)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    n = 1
    # 1～n番目の問題を全部解いた時の点数が初めてN点以上になるnを求める
    while n * (n + 1) // 2 < N:
        n += 1
    # 後は間を抜いて、ジャストN点になるよう調整していく
    d = n * (n + 1) // 2 - N
    solve = [1] * (n + 1)  # 1-indexで扱うので0番目は使わない
    for i in range(n, 0, -1):
        if i <= d:
            d -= i
            solve[i] = 0
        if d == 0:
            break
    for i in range(1, n + 1):
        if solve[i] == 1:
            print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

aa =[]
i = 0
score = 0

while score < n:
  i += 1
  score += i
  aa.append(i)
  
if score == n:
  for k in range(len(aa)):
    print(aa[k])
    
else:
  aa.remove(score - n)
  for k in range(len(aa)):
    print(aa[k])

Submission status: Accepted

Solution code:
n = int(input())
score = 0
i = 0
ans_list = []

while score <= n:
    i += 1
    score += i
    ans_list.append(i)

ans_list.remove(score - n)
for k in range(len(ans_list)):
    print(ans_list[k])

Submission status: Accepted

Solution code:
n = int(input())
score = 0
i = 0
ans_list = []

while score < n:
    i += 1
    score += i
    ans_list.append(i)

if score == n:
    for k in range(len(ans_list)):
        print(ans_list[k])
else:
    ans_list.remove(score - n)
    for k in range(len(ans_list)):
        print(ans_list[k])

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,n+1):
    now = i*(i+1)//2
    if n-now <= 0:
        break

ans = []
for j in range(i,0,-1):
    if n < j:
        if n != 0:
            ans.append(n)
        break
    ans.append(j)
    n -= j
    
for r in ans:
    print(r)

Submission status: Accepted

Solution code:
n = int(input())

def f(n):
    return ((1 + n) * n) // 2
 
s = 0
for x in range(1, n+1):
    if f(x) > n:
        s = f(x)
        break

dif = s - n

for ans in range(1, x+1):
    if ans != dif:
        print(ans)

Submission status: Accepted

Solution code:
n=int(input())
i=1
res=0
ans=[]
while res<n:
  res+=i
  ans.append(i)
  i+=1
if res-n!=0:
  ans.remove(res-n)
for p in ans:
  print(p)

Submission status: Accepted

Solution code:
n = int(input())
point = 0
ans = []
for i in range(1, n+1):
    point += i
    ans.append(str(i))
    if point >= n:
        if str(point - n) in ans:
            ans.remove(str(point - n))
        print('\n'.join(ans))
        break

Submission status: Accepted

Solution code:
n = int(input())

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

if s == n:
  for i in range(1,t+1):
    print (i)
else:
  for i in range(1,t+1):
    if i == s-n:
      continue
    print (i)
exit()

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    ok = n
    ng = 0

    while ok-ng > 1:
        middle = (ok+ng)//2
        max_score = (middle)*(middle+1)//2
        if max_score >= n:
            ok = middle
        else:
            ng = middle
    
    ans_lst = []
    num = ok

    while n != 0:
        if n > num:
            ans_lst.append(num)
            n -= num
            num -= 1
        else:
            ans_lst.append(n)
            n -= n

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

    # print(ok*(ok+1)//2, ok*(ok-1)//2,sum(ans_lst))

main()

Submission status: Accepted

Solution code:
import math

n = int(input())
max_num = int(-(-(math.sqrt(1 + 8*n) - 1) // 2))

s = int(max_num * (1 + max_num) / 2)

d = s - n

for i in range(max_num):
    if i+1 != d:
        print(i+1)

Submission status: Accepted

Solution code:
import math

n = int(input())


def ts(x):
    return x * (x + 1)


m = n
for i in range(math.ceil(math.sqrt(2 * n) - 2), math.floor(math.sqrt(2 * n)) + 1, 1):
    if ts(i) < 2 * n <= ts(i + 1):
        m = i + 1
        break



if m % 2 == 0:
    a = n % (m + 1)
    b = n // (m + 1)
    if a != 0:
        print(a)
    i = 1
    c = 0
    while c != b:
        if i != a and m + 1 - i != a:
            print(i)
            print(m + 1 - i)
            c += 1
        i += 1
else:
    """
  check=[]
  if a!=0:
      check.append(a)
  i = 1
  c = 0
  while c!=b and i<(m+1)//2:
      if i!=a and m+1-i!=a:
          check.append(i)
          check.append(m+1-i)
          c+=1
      i+=1
  if c==b:
      for i in check:
          print(i)
  else:

      n-=(m+1)//2
      a = n % (m + 1)
      b = n // (m + 1)
      if m % 2 == 0:
          if a != 0:
              print(a)
          i = 1
          c = 0
          while c != b:
              if i != a and m + 1 - i != a:
                  print(i)
                  print(m + 1 - i)
                  c += 1
      """
    print(m)
    n -= m
    m -= 1

    a = n % (m + 1)
    b = n // (m + 1)
    if a != 0:
        print(a)
    i = 1
    c = 0
    while c != b:
        if i != a and m + 1 - i != a:
            print(i)
            print(m + 1 - i)
            c += 1
        i += 1

Submission status: Accepted

Solution code:
import math
N = int(input())
number = math.ceil((N * 2) ** 0.5)
if number * (number + 1) // 2 == N:
    answers = [n for n in range(1, number + 1)]
    for answer in answers:
        print(answer)
else:
    whole=number*(number+1)//2
    sa=whole-N
    answers = [n for n in range(1, number + 1)]
    bad=[]
    for n in range(N):
        if sa>answers[-n-1]:
            sa-=answers[-n-1]
            bad.append(answers[-n-1])
        elif sa==answers[-n-1]:
            sa-=answers[-n-1]
            bad.append(answers[-n-1])
            break
    for ans in answers:
        if ans in bad:
            continue
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
def floor(x):
  if x == int(x):
    return x
  else:
    return int(x)+1
m = floor(((1+8*N)**0.5 - 1 ) /2)
S = ((m+1)*m) // 2
skip = S - N
for i in range(int(m)):
  if i+1 == skip:
    continue
  print(i+1)

Submission status: Accepted

Solution code:
n = int(input())
x = 0
i = 0
while n > x:
    i += 1
    x = (i * (i + 1)) // 2

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

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    k = 1
    while k*(k+1)//2 < N:
        k += 1
    if k*(k+1)//2 > N:
        k -= 1

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

    for i in range(k, 0, -1):
        if i > k-r:
            print(i+1)
        else:
            print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N = intput()
K = 1
while K*(K+1)//2<N:
    K += 1
for i in range(1,K+1):
    if i!=K*(K+1)//2-N:
        print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

    for i in range(10**4):
        if n <= i * (i + 1) / 2:
            tmp = i
            break
    tmpsum = tmp * (tmp + 1) / 2
    if n == tmpsum:
        for i in range(1, tmp + 1):
            print(i)
    else:
        for i in range(1, tmp + 1):
            if i == tmpsum - n:
                continue
            print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())

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

ng=0
ok=N+1

while abs(ng-ok)>1:
    mid=(ok+ng)//2

    if is_ok(mid):
        ok=mid
    else:
        ng=mid

diff=ok*(ok+1)//2-N

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

Submission status: Accepted

Solution code:
n = int(input())

k = 1
i = 1
while k < n:
    i += 1
    k += i

while n > i:
    print(i)
    n -= i
    i -= 1
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

    idx = 0
    for i in range(1, 5000):
        if i*(i+1)//2 <= N:
            idx = i

    delta = N - idx * (idx + 1) // 2

    r = m = 0
    if delta % idx == 0 and delta != 0:
        r = 1
    else:
        r, m = divmod(delta, idx)

    prob = [r + (i + 1) for i in range(idx)]

    for i in range(1, m + 1):
        prob[idx - i] += 1

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
    return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, n):
            ok = mid
        else:
            ng = mid
    return ok
def f(n):
    if n>0:
        m = meguru_bisect(0,10**7, n)
        print(m)
        f(n-m)
N = int(input())
f(N)

Submission status: Accepted

Solution code:
N = int(input())

lst = []
i = 1
sm = 0
while sm < N:
  lst.append(i)
  sm += i
  i += 1
  
if sm == N:
  for l in lst:
    print(l)
else:
  a = sm - N
  lst.remove(a)
  for l in lst:
    print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from itertools import  accumulate
n = int(input())
tmp = n

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

d = sum - n
if d in ans:
    ans.remove(d)

for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
import math
from math import gcd,pi
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    l = [1]
    ans = []
    for i in range(2,10**4):
        l.append(l[i-2]+i)
    while True:
        if n == 0:
            break
        for i,k in enumerate(l):
            if n <= k:
                if i == 0:
                    a = k
                else:
                    a = k - l[i-1]
                ans.append(a)
                n -= a
                break
    for i in ans:
        print(i)

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
b = 1
e = 100000
score = 0
while True:
    mid = (e + b) // 2
    score = (mid * (mid + 1)) // 2
    if score >= n:
        e = mid
    else:
        b = mid
    if abs(e - b) <= 1:
        break
    #print(mid)
if b * (b + 1) // 2 >= n:
    ans = b
else:
    ans = e

rest = ((ans * (ans + 1)) // 2) - n
for num in range(1, ans + 1):
    if rest == num:
        continue
    print(num)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    def isOK(mid):
        if N <= (mid * (mid + 1)) // 2:
            return True
        else:
            return False

    ok = 10 ** 7
    ng = 0

    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    while N > 0:
        if N >= ok:
            print(ok)
            N -= ok
            ok -= 1
        else:
            ok -= 1


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
val, a = 0, 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n+1):
  if i*(i+1)//2>=n:break
ans=[]
for j in range(i,0,-1):
  if j<=n:
    n-=j
    ans+=[j]
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
total = 0
ans = []
for i in range(1, n+1):
    ans.append(i)
    total += i
    if total > n:
        break
ng = total - n
print(*[i for i in ans if i != ng], sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = 0
i = 1
while b < n:
    a.append(i)
    b += i
    i += 1
b -= n
for i in a:
    if i != b:
        print(i)

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
ans = []
n = int(input())
for i in range(n+1):
  s = i*(i+1)//2
  if s >= n:
    k = i
    break
sabun = s - n
for i in range(k,0,-1):
  # print(sabun)
  if sabun >= i:
    sabun -= i
  else:
    ans.append(i)
print(*reversed(ans),sep = "\n")
# print(k)

Submission status: Accepted

Solution code:
from itertools import accumulate
import bisect
n=int(input())
l=list(accumulate(range(4473)))
while True:
    i=bisect.bisect_left(l,n)
    if i<1:break
    print(i)
    n-=i

Submission status: Accepted

Solution code:
from itertools import accumulate
n=int(input())
l=list(accumulate(range(4473)))

while True:
    for i,x in enumerate(l):
        if n==x:
            for y in range(1,i+1):
                print(y)
            exit()
        elif n<x:
            print(i)
            n-=i
            break