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

Solution (Python):


from collections import Counter,deque


from sys import stdin,setrecursionlimit


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

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

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

Solution (Python):
n = int(input())

t = 0
i = 1

while t < n:

    t += i
    i += 1

pass_num = t - n

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

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

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

Solution (Python):



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

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

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

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

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

l = 0
r = 1000000
a = 0

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

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

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

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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)

Solution (Python):

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)

Solution (Python):

def main():
    
    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  
    ans = [i for i in range(1, ma + 1) if i != ex]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

"""
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:])

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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()

Solution (Python):
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

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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])

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):


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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
N = int(input())



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

Solution (Python):
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)

Solution (Python):
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)))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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

Solution (Python):



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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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