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

Solution code:
def solve():
    N = int(input())
    score = 0
    for i in range(1, n+1):
        score += i
        if score >= n:
            break
    x = score - n
    res = list(range(1, x)) + list(range(x+1, i+1))
    return '\n'.join(map(str, res))
    
print(solve())

Submission status: Runtime Error

Solution code:
import sys

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

i = 1
for i in range(1, N):
    sum_i = i * (i + 1) // 2
    if N <= sum_i:
        break

max_i = i
sum_i = i * (i + 1) // 2
res = sum_i - N 
# print("sum", sum_i)
# print("res", res)
# print(i)
ans = set([i for i in range(1, max_i+1)])
if res:
    ans.remove(res)

for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
n = int(input())

if n == 1:
    print(1)
else:
    m = n //2 
    for i in range(1,m+1):
        if i * (i + 1) <= 2 *n < (i+1)*(i+2):
           right  = i + 1
           break
       
    diff = right * (right+1) //2 - n
       
    for i in range(1,right+1):
        if i != diff:
            print(i)

Submission status: Runtime Error

Solution code:
n = int(input())
r = 10**7+1
l = 1

def f(n):
  return n**2+n

while r-l>1:
  if f((l+r)//2)>n:
    r = (l+r)//2
  else:
    l = (l+r)//2
l = l+1
rm = (l+1)*l//2-n
ans = list(range(1, l+1))
ans.remove(rm)
for a in ans:
  print(a)

Submission status: Runtime Error

Solution code:
n = int(input())

if n == 1:
    print(1)
else:
    for x in range(1,n):
        tmp = (1+x)*x//2
        if tmp >= n:
            l = x
            break

    d = tmp - n
    for x in range(1,l+1):
        if x != d:
            print(x)

Submission status: Runtime Error

Solution code:
import math
N = int(input())
n = round((N//2) ** 0.5)
a,b = n+2, n+3
if a*(a+1)//2 > abs(a*(a+1)//2 - N):
    number = abs(a*(a+1)//2 - N)
    n = a
elif b*(b+1)//2 >= abs(b*(b+1)//2 - N):
    number = abs(b*(b+1)//2 - N)
    n = b

for i in range(1, n+1):
    if i == number: continue
    print(i)

Submission status: Runtime Error

Solution code:
import math
N = int(input())
n = round((N//2) ** 0.5)
a,b = n+2, n+3
if a*(a+1)//2 > abs(a*(a+1)//2 - N):
    number = abs(a*(a+1)//2 - N)
    n = a
elif b*(b+1)//2 > abs(b*(b+1)//2 - N):
    number = abs(b*(b+1)//2 - N)
    n = b

for i in range(1, n+1):
    if i == number: continue
    print(i)

Submission status: Runtime Error

Solution code:
from math import sqrt
n=int(input())
d=min(-(-int(sqrt(8*n+1))//2),n)
l=list(range(1,d+1))
remain=(d*(d+1))//2-n
while remain<=l[-1]:
    remain-=l[-1]
    l.pop()
print(set(l)-set([remain]))

Submission status: Runtime Error

Solution code:
# CODE FESTIVAL 2016 Final
# B - Exactly N points
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b
N = int(input())
for i in range(1, N):
    if i*(i+1)//2 >= N:
        k = i
        break

S = k*(k+1)//2
sub = S-N
for i in range(1, k+1):
    if i == sub:
        continue
    print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
def su(n):
    s = 0
    for i in range(1,n+1):
        s += i
    return s

if N == 1:
    print(1)

else:
    for i in range(N):
        if su(i) >= N:
            M = i
            break
    print(M)

    now = N-M
    
    for i in range(1,M):
        if now - (M-i) >=(M-i):
            now -= M-i
            print(M-i)
        else:
            print(M-i)
            print(now-(M-i))
            break

Submission status: Runtime Error

Solution code:
N = int(input())
if N == 1 or N == 2:
    print(N)
else:
    for i in range(N):
        if i*(i+1)//2 > N:
            num = i-1
            break
    ans = []
    for i in range(num):
        ans.append(i+1)
    if num*(num+1)//2 != N:
        cnt = N-num*(num+1)//2
        ans.pop(num-cnt)
        ans.append(num+1)
    for x in ans:
        print(x)

Submission status: Runtime Error

Solution code:
N = int(input())
if N == 1 or N == 2:
    print(N)
else:
    for i in range(N):
        if i*(i+1)//2 > N:
            num = i-1
            break
    ans = []
    for i in range(num):
        ans.append(i+1)
    if num*(num+1)//2 != N:
        cnt = N-num*(num+1)//2
        ans.remove(num+1-cnt)
        ans.append(num+1)
    for x in ans:
        print(x)

Submission status: Runtime Error

Solution code:
n = int(input())

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

if m == n:
    print(*a)
else:
    a.remove(m-n)
    print(*a)

Submission status: Runtime Error

Solution code:
n = int(input())

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

if m == n:
    print(*a)
else:
    a.pop(m-n)
    print(*a)

Submission status: Runtime Error

Solution code:
n = int(input())

if n == 1 or n == 2:
    print(n)
else:
    a = []
    m = 0
    for i in range(1, n):
        if m > n: break
        a.append(i)
        m += i


    b = []
    for i in range(len(a) ** 2):
        g = []
        for j in range(len(a)):
            if ((i >> j) & 1):
                g.append(a[j])
        if sum(g) == n:
            b.append([g[-1], g])

    b.sort()
    for item in b[0][1]:
        print(item)

Submission status: Runtime Error

Solution code:
# coding: utf-8
N = int(input())
if N == 1:
    print(1)
    exit()
ans = 0
for i in range(1, N+1):
    if ans < N:
        ans += i
    else:
        end = i
        break
res = ans - N
for i in range(1, end):
    if i != res:
        print(i)

Submission status: Runtime Error

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

def getk(n):
    return int((1+math.sqrt(8*n-7))/2)

while(True):
    k = getk(n)
    print(k,end="")
    print(" ",end="")
    if k ==1:
        break
    n-=k

Submission status: Runtime Error

Solution code:
N=int(input())
a=1
while N-a>=a:
    print(a)
    b=N-a
    N-=a
    a+=1 
print(b)

Submission status: Runtime Error

Solution code:
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Submission status: Runtime Error

Solution code:
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    i=k
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Submission status: Runtime Error

Solution code:
N=int(input())

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

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

Submission status: Runtime Error

Solution code:
N=int(input())

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

r = bisect_left(n, N)

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

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

Submission status: Runtime Error

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

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

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

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

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n=int(input())

for i in range(n):
    if i+i**2>=2*n:
        check=i
        break

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

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

Submission status: Runtime Error

Solution code:
import math
print(math.floor((math.sqrt(i+8*int(input()))-1)/2))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n=int(input())
for i in range((2*n)**0.5-3,n**0.5+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):
      ifr j!=k:
        print(j)
    break

Submission status: Runtime Error

Solution code:
def f(n):
  for i in range(n):
    if i*(i+1)>=2*n:
      return(i)
      break
n=int(input())
Ans=[]
while n>1:
  Ans.append(f(n))
  n-=f(n)
Ans.append(1)
print(*Ans,sep="\n")

Submission status: Runtime Error

Solution code:
N = int(input())
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]
va = N-ma
print(ma)
for i in range(ma-1,0,-1) :
    if (va - i) >= 0 :
        print(i)
        va -= i
    elif va < 0 :
        break