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())

ans_max = 0
while ans_max * (ans_max + 1) / 2 < N:
    ans_max += 1

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

Submission status: Accepted

Solution code:
import math
n=int(input())
k=math.ceil((math.sqrt(1+8*n)-1)/2)
tmp=k
while n>0:
    if tmp<=n:
        n-=tmp
        print(tmp)
    tmp-=1

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,10**4):
    if (i*(i-1))//2 < n <= ((i+1)*i)//2:
        maxn = i
        break
ans_list = []
for i in range(maxn,0,-1):
    if n >= i:
        ans_list.append(i)
        n -= i
for i in sorted(ans_list):
	print(i)

Submission status: Accepted

Solution code:
# 2019/08/09
from bisect import bisect_left

n=int(input())
acc=[0]
for i in range(1,n+1):
    acc.append(i+acc[i-1])
    if acc[i]==n:
        print(*range(1,i+1),sep='\n')
        exit()
    elif acc[i]>n:
        idx=i
        break

rem=acc[idx]-n

res=0
for i in range(1,idx+1):
    if i!=rem:
        print(i)

Submission status: Accepted

Solution code:
# cf16-finalB - Exactly N points
def main():
    # N <= cnt (1 + 2 + ... + ma) -> 1 ~ ma except ex
    N = int(input())
    cnt, ma = 0, 0
    for i in range(1, N + 1):
        cnt += i
        if cnt >= N:
            ma = i
            break
    ex = cnt - N  # exclusion
    ans = [i for i in range(1, ma + 1) if i != ex]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    lo = 1
    hi = 10000
    while lo < hi:
        mid = (lo + hi) // 2
        if mid * (1 + mid) // 2 < N:
            lo = mid + 1
        else:
            hi = mid
    total = lo * (1 + lo) // 2
    skip = total - N
    for i in range(1, lo+1):
        if i != skip:
            print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
total = 0
for i in range(1, n+1):
    total += i
    if total >= n:
        min_val = i
        trash = total - n 
        break
for i in range(1, min_val+1):
    if i == trash:
        continue
    print(i)

Submission status: Accepted

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

while n > 0:
    a = math.sqrt(2*n+0.25)+0.5
    if a == int(a):
        k = int(a)-1
    else:
        k = int(a)
    print(k)
    n = n - k

Submission status: Accepted

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:
    max_element = 0
    index = 1
    for i in range(1, n+1):
        for j in range(i):
            if index == n + 1:
                break
            max_element = i
            index += 1
    s = 0
    for num in range(max_element, 0, -1):
        s += num
        if s <= n:
            print(num)
        else:
            s -= num

Submission status: Accepted

Solution code:
N = int(input())

score = 0
scoremax=0
for i in range(1, N+1):
    if i * (i + 1) >= 2*N:
        scoremax = i
        break
for i in range(scoremax, 0, -1):
    if score + i <= N:
        score += i
        print(i)
    if score == N:
        exit()

Submission status: Accepted

Solution code:
N = int(input())

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

diff = current_sum - N
if diff > 0:
    ans.remove(diff)
for _ans in ans:
    print(_ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
 
i = math.floor(math.sqrt(2*N))
while i * (i+1) // 2 - N < 0:
  i += 1

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

Submission status: Accepted

Solution code:
N = int(input())

sum_score, set_score = 0, set()
for n in range(1, N + 1):
	sum_score += n
	set_score |= {n}
	if N <= sum_score:
		set_score -= {sum_score - N}
		break
for score in sorted(set_score):
	print(score)

Submission status: Accepted

Solution code:
import math
N=int(input())
for i in range(int(math.sqrt(N)) , int(math.sqrt(2*N+1))+100):
    if (i*(i+1))//2 >= N:
        ansmax=i
        dif=(i*(i+1))//2 - N
        break

for j in range(1,ansmax+1):
    if j!=dif:
        print(j)

Submission status: Accepted

Solution code:
N = int(input())
x = int((2*N)**0.5)
sums = (1+x)*x//2
ex = 0
if(sums<N):
    x+=1
    sums+=x
ex = sums-N
for i in range(1,x+1):
    if(i!=ex):
        print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
get = 0
solve = set()
for i in range(1,10000):
    get += i
    solve.add(i)
    if get >= n:
        break
for s in solve:
    if s!= get-n:
        print(s)

Submission status: Accepted

Solution code:
import math
ans = []
def main(num):

    lim =int(math.ceil((-1 + math.sqrt(1 + 8 * num))/2))
    for i in range(lim,0,-1):
        if num - i >= 0:
            ans.append(i)
            num = num - i
    for j in ans:
        print(j)




if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Accepted

Solution code:
n=int(input())
m=1
while m*(m+1)<2*n:
  m+=1
k=m*(m+1)//2-n
for i in range(m):
  if i+1==k:
    continue
  else:
    print(i+1)

Submission status: Accepted

Solution code:
N = int(input())
l, r = 0, N
while l + 1 != r:
    m = (l + r) // 2
    if m * (m - 1) // 2 < N - m:
        l = m
    else:
        r = m
s = r * (r - 1) // 2 - (N - r)
for n in range(1, r + 1):
    if n != s:
        print(n)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - Exactly N points
https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b

"""
import sys


def solve(N):
    def is_big_enough(n):
        x = n*(n+1) // 2
        if x >= N:
            return True
        return False

    ub, lb = 5000, 1
    while ub - lb > 0:
        mid = (ub + lb) // 2
        if is_big_enough(mid):
            ub = mid
        else:
            lb = mid + 1

    x, ans = lb, []
    while N:
        if N <= x:
            ans.append(N)
            N = 0
        else:
            ans.append(x)
            N -= x
            x -= 1
    return ans


def main(args):
    N = int(input())
    ans = solve(N)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
def search(n):
    for i in range(1, n+1):
        if i*(i+1)/2 >= n:
            return i

n = int(input())
lim = search(n)
s = lim*(lim+1)//2
ans = []

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

Submission status: Accepted

Solution code:
N = int(input())
n = 1
while True:
  sum = (n+1) * n / 2
  if sum >= N:
    p = sum - N
    for i in range(1, n+1):
      if i == p:
        continue
      else:
        print(i)
    break
  n += 1

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N=II()

  i=1
  l=[i]
  sm=i
  while True:
    if sm==N:
      break
    elif sm>N:
      l.remove(sm-N)
      break
    else:
      i+=1
      l.append(i)
      sm+=i

  for x in l:
    print(x)

main()
# print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N = int(input())

Y = math.floor(math.sqrt(2*N))
j = min(1,Y - 3)
while True:
    if (j-1)*j < 2 * N <= (j+1)*j:
        break
    j += 1

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

Submission status: Accepted

Solution code:
n = int(input())
res = 0
res_array = []
for i in range(1, n+1):
    res += i
    res_array.append(i)
    if res >= n:
        break
diff = res - n
for j in res_array[::-1]:
    if diff -j >= 0:
        diff -= j
        res_array.remove(j)
for k in res_array:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())

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

    if c >= N:
        break

for i in range(1,len(d)):
    if c - N != i:
        print(d[i])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

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

if sm>N:
    ans.remove(sm-N)
for a in ans:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt, ceil

n = int(input())

k = ceil(sqrt(2 * n + 0.25) - 0.5)
d = (k * (k + 1) // 2) - n

for i in range(1, k+1):
    if i == d:
        continue
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
#a = [int(i) for i in input().split()]
#s = [[int(j) for j in input().split()] for i in range(N)]

SUM = 0
a = [0 for i in range(10000)]
for i in range(1,10000):
    SUM+=i
    a[i] = SUM
    if N<=SUM:
        tmp = 0
        for j in range(i,-1,-1):
            print(j)
            N-=j
            if a[j-2]==N:
                tmp = j-1
                break
        for j in range(1,tmp):
            print(j)
        break

Submission status: Accepted

Solution code:
N = int(input())

for i in range(10000):
    temp = i * (i + 1) // 2
    if temp > N:
        break

temp2 = N - ((i - 1) * i // 2)
del_num = i - temp2

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
num=0
L=[]
for i in range(1,N+1):
    num+=i
    L.append(i)
    if num>=N:
        break
if num!=N:
    a=num-N
    L.remove(a)
print('\n'.join(map(str,L)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

tmp = list(range(1,n+1))

sum_t = sum(tmp)

res = sum_t - N

for i in range(1,n+1):
    if i != res:
        print(i)

Submission status: Accepted

Solution code:
def get_max(n):
	return int(((8*n+1)**0.5-1)/2 + 0.99999999)
n = int(raw_input())
while(n>0):
	k = get_max(n)
	print k
	n-=k

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import sys

N = int(input())

tt = 0
for i in range(5000):
    tmp = i * (i-1) // 2
    if tmp >= N:
        tt = i
        ans = tmp - N
        break

for t in range(1, tt):
    if t == ans:
        continue
    print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
N = int(sys.stdin.readline())
x = int(math.ceil((math.sqrt(1+8*N)-1)/2))

a = int((x*(x+1)/2-N))
for b in range(x):
    b = b+1
    if a != b:
        print(b)

Submission status: Accepted

Solution code:
N = int(input())

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

lo = 1
hi = 100000

while abs(lo - hi) > 1:
    md = (lo + hi) // 2
    if fn(md) >= N:
        hi = md
    else:
        lo = md
if N == 1:
    x = 1
else:
    x = hi
rem = N
now = x

while rem != 0:
    if now <= rem:
        print(now)
        rem -= now
    now -= 1

Submission status: Accepted

Solution code:
from math import ceil
N = int(input())
ans = int(ceil((-1 + (1 + 4 * 2 * N) ** 0.5) / 2))
for i in reversed(range(1, ans+1)):
    if i <= N:
        print(i)
        N -= i
assert(not N)

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()

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

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

while N > 0 and k > 0:
  if k <= N:
    N -= k; print(k)
  k -= 1

Submission status: Accepted

Solution code:
n = input()
k = 0
while n > k*(k+1)/2:
    k += 1
rem = k*(k+1)/2 - n
for i in xrange(1,k+1):
    if rem != i:
        print i

Submission status: Runtime Error

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: Runtime Error

Solution code:
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

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
        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: Runtime Error

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

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
        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
        """
    n-=m
    m-=1
    print(m)
    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
        	i+=1

Submission status: Runtime Error

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

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
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
    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 += 1import 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

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
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
    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

Submission status: Runtime Error

Solution code:
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: Runtime Error

Solution code:
def is_ok(n):
    global N
    return n*(n+1)//2>=N
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
n = meguru_bisect(0,10**7)
s = list(range(1, n+1))
d = n-2
while sum(s) != N:
    s.pop(d)
    d -= 1
for i in s:
    print(i)

Submission status: Runtime Error

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

ans = []

def dfs(m):
    if m == 1:
        ans.append(1)
        return 0
    elif m == 3:
        ans.append(2)
        ans.append(1)
        return 0
    elif m == 4:
        ans.append(3)
        ans.append(1)
        return 0
    elif m == 5:
        ans.append(3)
        ans.append(2)
        return 0
    else:
        k = ceil((sqrt(1+8*m)-1)/2)
        ans.append(k)
        dfs(m-k)

n = INT()
dfs(n)
for x in ans:
    print(x)

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
cnt = 0
s = set()
for i in range(1, N):
    cnt += i
    s.add(i)
    if cnt>=N:
        break
if N!=cnt:
    s.remove(cnt-N)

for i in s:
    print(i)

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())

    ans_list = [i*(i+1)//2 for i in range(1, N+1)]
    delta = 0
    if N > 1:
        for i in range(1, N+1):
            if ans_list[i-1] < N < ans_list[i]:
                delta = ans_list[i] - N
                res_list = list(range(1, i+2))
                break
            elif N == ans_list[i]:
                res_list = range(1, i+2)
    else:
        res_list = [1]

    if delta > 0:
        while delta > res_list[-1]:
            delta -= res_list[-1]
            del res_list[-1]

        res_list.remove(delta)    
    

    for item in res_list:
        print(item)



if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())

    ans_list = [i*(i+1)//2 for i in range(1, N+1)]

    if N > 1:
        for i in range(1, N+1):
            if ans_list[i-1] < N < ans_list[i]:
                delta = ans_list[i] - N
                res = list(range(1, i+2))
                res.remove(delta)
                break
            elif N == ans_list[i]:
                res = range(1, i+2)
    else:
        res = [1]

    for item in res:
        print(item)



if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

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

def main(n):
  global l
  i = 1
  while True:
    tmp = i*(i+1)//2
    if tmp >= n:
      l.append(i)
      if n-i == 0:
        return l
      else:
        return main(n-i)
    i += 1
        
li = main(N)
for n in li:
  print(n)

Submission status: Runtime Error

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

def main(n):
  global l
  i = 1
  if n == 1:
    l.append(1)
    return l
  else:
    while True:
      tmp = i*(i+1)//2
      if tmp >= n:
        l.append(i)
        if n-i == 0:
          return l
        else:
          return main(n-i)
      i += 1
        
li = main(N)
li.sort()
for n in li:
  print(n)

Submission status: Runtime Error

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    if N==1:
        print(1)
        exit()
    temp=0
    ans=[]
    for i in range(1,N):
        temp+=i
        ans.append(i)
        if temp>=N:
            ans.remove(temp-N)
            break
    for i in range(len(ans)):
        print(ans[i])
        

main()

Submission status: Runtime Error

Solution code:
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l

n = int(input())
def f(n):
    return (n+1)*n // 2
m = BisectSearch(f, l=1, r=10**7)(n)
m += f(m) != n
A = set(range(1, m+1))
A.remove(f(m) - n)
print(*A, sep='\n')

Submission status: Runtime Error

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


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

    l = list(range(1, sum_[0][0] + 1))
    remove = sum_[0][1] - N
    l.remove(remove)
    print(*l, sep="\n")

Submission status: Runtime Error

Solution code:
N=int(input())
ans=0
A=[]
for i in range(1,N+1):
    if ans+i==N:
        A.append(i)
        break
    if N-(ans+i)>=i+1:
        A.append(i)
        ans+=i
    else:
        del A[-1]
        ans-=i-1
        if (N-ans)%2==0:
            A.append((N-ans)//2-1)
            A.append((N-ans)//2+1)
        else:
            A.append((N-ans)//2)
            A.append((N-ans)//2+1)
        break
print(*A,sep="\n")

Submission status: Runtime Error

Solution code:
n=int(input())

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#import itertools
#import bisect
import math

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

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: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

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