Problem:


Score : 300 points

Problem Statement

The problem set at CODE FESTIVAL 20XX Finals consists of N problems.

The score allocated to the i-th (1≦i≦N) problem is i points.

Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.

As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him.

Determine the set of problems that should be solved.

Constraints

1≦N≦10^7

Partial Score

200 points will be awarded for passing the test set satisfying 1≦N≦1000.

Additional 100 points will be awarded for passing the test set without additional constraints.

Input

The input is given from Standard Input in the following format:

N

Output

Among the sets of problems with the total score of N, find a set in which the highest score of a problem is minimum, then print the indices of the problems in the set in any order, one per line.

If there exists more than one such set, any of them will be accepted.

Sample Input 1

4

Sample Output 1

1
3

Solving only the 4-th problem will also result in the total score of 4 points, but solving the 1-st and 3-rd problems will lower the highest score of a solved problem.

Sample Input 2

7

Sample Output 2

1
2
4

The set \{3,4\} will also be accepted.

Sample Input 3

1

Sample Output 3

1



Sample input:
4


Sample output:
1
3

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
if N == 1:
  print(1)
  exit()

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

ans = []
while 1:  
  ans1 = bisect.bisect_left(acms,N)
  if N-ans1<ans1:
    ans.append(ans1)
    ans.append(N-ans1)
    break
  else:
    ans.append(ans1)
    N = N-ans1
    
[print(val) for val in sorted(ans)]

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
if N == 1:
  print(1)
  exit()

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

ans = []
while 1:  
  ans1 = bisect.bisect(acms,N)
  if N-ans1<ans1:
    ans.append(ans1)
    ans.append(N-ans1)
    break
  else:
    ans.append(ans1)
    N = N-ans1
    
[print(val) for val in sorted(ans)]

Submission status: Wrong Answer

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

while N:
    if N <= k:
        print(N)
        break
    N -= k
    print(k)
    k -= 1

Submission status: Wrong Answer

Solution code:
N = int(input())
tmp = 0
right = 1
for i in range(1, N):
    tmp += i
    if tmp >= N:
        right = i
        break
forbidden = tmp - N
for i in range(1, right+1):
    if i == forbidden:
        continue
    print(i)

Submission status: Wrong Answer

Solution code:
def solve(n):
    score = 0
    res = []
    for p in range(1, n+1):
        res.append(p)
        score += p
        if score >= n:
            break
    return "\n".join(map(str, res))

n = int(input())
print(solve(n))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
import bisect
n = int(input())
l = list(range(1,int(n**0.5)+2))
l = list(accumulate(l))
a = []
while n:
  i = bisect.bisect_left(l,n)
  a.append(i+1)
  n-=i+1
print(*a,sep='\n')

Submission status: Wrong Answer

Solution code:
n = int(input())


def calc(n):
    mx = 1
    while True:
        if n <= mx * (mx + 1) // 2:
            break
        mx += 1
    return mx


ans = []
while n > 0:
    x = calc(n)
    ans.append(x)
    n -= x
    if x > n:
        ans.append(n)
        break

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

Submission status: Wrong Answer

Solution code:
N=int(input())

ans=[N]
while True:
  cnt1=1
  cnt2=ans.pop()
  n=len(ans)
  while True:
    if cnt1>=cnt2-cnt1:
      break
    elif cnt1 not in ans and cnt2-cnt1 not in ans:
      ans.append(cnt1)
      ans.append(cnt2-cnt1)
      break
    else:
      cnt1+=1
  if n==len(ans): # 更新されなかったら
    ans.append(cnt2)
    break
for x in ans:
  print(x)

Submission status: Wrong Answer

Solution code:
N=int(input())
for m in range(1,4*10**3):
    if m*(m+1)//2>=N:
        break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = 0
ans = []
for i in range(1, N+1):
  ans.append(i)
  s += i
  if s == N:
    break
  elif (N-s) < i:
    s-= i
    ans.pop(-1)

  
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = 0
ans = []
index = 1
while(True):
  ans.append(index)
  s += index
  if s == N:
    break
  if (N-s) < index:
    s-= index
    ans.pop(-1)
  index+=1
  
for i in ans:
  print(i)

Submission status: Wrong Answer

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

index = 1
while(True): 
  ans.append(index)
  if sum(ans) == N:
    break
  if (N-sum(ans)) < index:
    ans.pop(-1)
  index+=1
  
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
# 最大値の最小値、ちょうどn/2臭い
# あとは帳尻合わせが効きそう
# 14とかだと7+4+2+1 （7+5+2でも7+4+3でもいい
# かと思いきや 1+2+3+4+5で15いくので, 5+4+3+2でよかった
# 10^7なので毎回足してもどうせ間に合う。これで答えの集合のうち最大値は確定
# あとはそれでnを引いて0になるまで

n = int(input())
ans = []
cur = 0

while cur != n:
    tmp = 0
    for i in range(1, n + 1 - cur):
        if i + tmp >= n + 1 - cur:
            tmp = i
            break
        tmp += i
    ans.append(tmp)
    cur += tmp
    # print("tmp = {}, cur = {}".format(tmp, cur))
# print(ans)
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N=int(input())

for i in range(1,N+1):
    if(N<=(i*(i+1)//2)):
        print(i)
        if(N==1 or N==2):
            exit()
        if(N-i==i):
            print(i-1)
            print(1)
        else:
            print(N-i)
        
        exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
N=10**7
lst=set()
num=0
for i in range(1,N+1):
    lst.add(i)
    num+=i
    if num>=N:
        if num==N:
            break
        else:
            lst.remove(num-N)
            break
for s in lst:
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
num = 1
while num * (num + 1) <= 2 * n:
  num += 1
now = n
for i in range(num,0,-1):
  if now >= i:
    print(i)
    now -= i

Submission status: Wrong Answer

Solution code:
a = int(input())
print(a-1)
if a != 1:
  print(1)

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(4000):
    if i * (i + 1) / 2 == N:
        for i in range(1, i + 1):
            print(i)
        break
    elif i * (i + 1) / 2 > N:
        remove = i * (i + 1) / 2 - N
        for i in range(1, i + 1):
            if i != remove:
                print(i)
        break

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
cnt = 0
i = 1
if n == 1:
    print(1)
    quit()
while True:
    cnt += i
    if cnt >= n:
        break
    i += 1
res = []
while n > 0:
    res.append(i)
    n -= i
    i -= 1
    if n > i:
        continue
    res.append(n)
    break
for i in range(len(res))[::-1]:
    print(res[i])

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
M = (math.ceil((math.sqrt(1+8*N)-1)/2))
for m in range(M+1):
  if M-m <= N:
    print(M-m)
    N -= M-m
  else:
    if N!=0:
      print(N)
    break

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
M = (math.ceil((math.sqrt(1+8*N)-1)/2))
for m in range(M+1):
  if M-m <= N:
    print(M-m)
    N -= M-m
  else:
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
M=int(math.sqrt(N*2-0.25)+0.5)
left = M*(M-1) // 2
sum_=0
for i in range(1,M-(N-left)):
    print(i)
    sum_ += i
for i in range(M-(N-left),M):
    print(i+1)
    sum_ += i+1
print(sum_)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
print(int(math.sqrt(N*2-0.25)+0.5))

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

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


n=int(input().rstrip())
if n==1 or n==2:
    print(n)
    exit()
y=1
while 1:
    s=(y*(y-1))//2
    if s>n:
        break
    y+=1
a=set(range(1,y))
#print(y)
for i in range(1,n):
    if s-i==n:
        a.remove(i)
        print(*a,sep="\n")
        break

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

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


n=int(input().rstrip())
if n==1 or n==2:
    print(n)
    exit()
if n&1==0:
    print(n//2-1,n//2+1,sep="\n")
else:
    print(n//2,n//2+1,sep="\n")

Submission status: Wrong Answer

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

def num_split(x):
    a = x // 2
    b = x - a
    if a > b:
        a,b = b,a
    while(b < N):
        if a in nums or b in nums or a == b:
            a -= 1
            b += 1
        else:
            break
    return(a,b)

def calc(x):
    a,b = num_split(x)
    if a == 0:
        nums.append(b)
    else:
        calc(a)
        calc(b)
    return


calc(N)

for i in range(N):
    if i + 1 in nums:
        print(i + 1)

Submission status: Wrong Answer

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

def num_split(x):
    a = x // 2
    b = x - a
    if a > b:
        a,b = b,a
    while(b < N):
        if a in nums or b in nums or a == b:
            a -= 1
            b += 1
        else:
            break
    return(a,b)

def calc(x):
    a,b = num_split(x)
    if a == 0:
        nums.append(b)
    else:
        calc(a)
        calc(b)
    return


calc(N)

for i in range(1,N):
    if i in nums:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = [0]*N

def num_split(x):
    a = N // 2
    b = N - a
    while(b < N):
        if nums[a] == 1 or nums[b] == 1 or a == b:
            a -= 1
            b += 1
        else:
            break
    return(a,b)
a,b = num_split(N)
if a > 0:
    print(a)
print(b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#CODEFESTIVAL 2016 Final B

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:
        ans.pop()
        ans.append(n - (tmp-(i-1)))
        break
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#CODEFESTIVAL 2016 Final B

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:
        ans.pop()
        ans.append(i)
        break
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

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

n=int(input())
a=[0]+list(accumulate(list(range(1,n+1))))


def bsct(a,key):
    l=0
    r=len(a)
    mid=(l+r)//2
    while l<=r:
        if a[mid]==key:
            return mid
        elif a[mid]>key:
            r=mid-1
        else:
            l=mid+1
        mid=(l+r)//2
    return 0

res=bsct(a,n)
if res:
    print(res)
    exit()

idx=bisect_left(a,n)
rem=a[idx]-n

ans=list(range(1,idx+1))
del ans[rem]
print(*ans,sep='\n')

Submission status: Wrong Answer

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

Solution code:
N = int(input())

MAX = N
check = [0]
pre = 0
for i in range(1, MAX+1):
    pre += i
    if pre <= MAX:
        check.append(pre)
    else:
        break

len_ = len(check)

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = math.floor(math.sqrt(N))
while N - 2 * i * (i+1) > 2 * i:
  i += 1
print(i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
a = 1 + N // 2
if N != a:
    print(N - a)
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
ruiseki = N
if N == 1:
    ans.append(N)
for i in range(1,N):

    if ruiseki - i > i:
        ans.append(i)
    else:
        ans.append(ruiseki)
        break
    ruiseki -= i
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
i = 1
temp = N
while True:
    if temp - i <= i:
        ans.append(temp)
        break
    ans.append(i)
    temp = temp - i
    i += 1

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(int((2*n)**0.5-3),n):
  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: Wrong Answer

Solution code:
def f(n):
  return int((2*n+0.25)**0.5-0.6)+1
n=int(input())
Ans=[]
while n>1:
  Ans.append(f(n))
  n-=f(n)
if n>=1:
  Ans.append(1)
print(*Ans,sep="\n")

Submission status: Wrong Answer

Solution code:
def f(n):
  return int((2*n+0.25)**0.5-0.5)
n=int(input())
Ans=[]
while n>1:
  Ans.append(f(n))
  n-=f(n)
Ans.append(1)
print(*Ans,sep="\n")

Submission status: Wrong Answer

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()
  if N==1:
    exit()

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

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]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
if N > 1000:
    print(-1)
    sys.exit()
dp = [(0, -1)] + [None] * (2 * N)
for i in range(1, N+1):
    for j in range(N, -1, -1):
        if dp[j] is not None:
            continue
        if dp[j-i] is None:
            continue
        dp[j] = (i, j-i)
idx, par = dp[N]
while par >= 0:
    print(idx)
    idx, par = dp[par]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for bit in range(1<<n):
  sum = 0
  for i in range(n):
    if bit & (1<<i):
      sum += i+1
      
  if sum == n:
    a = bin(bit)
    break
s = str(a)
s = s[2:]
s = s[::-1]


for i in range(len(s)):
  if s[i] == '1':
    print(i + 1)

Submission status: Time Limit Exceeded

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))
import itertools
for i in itertools.product([0,1], repeat=n):
    a = [s[j-1] for j in s if i[j-1]]
    if sum(a) == N:
        for k in a:
            print(k)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = {}
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: Time Limit Exceeded

Solution code:
n = int(input())
if n <= 2:
    print(n)
if n == 3:
    print(1)
    print(2)
    exit()

num = 0
for i in range(1,n):
    if i*(i+1)//2 >= n:
        num = i
        break
#print(num)
if num*(num+1)//2== n:
    for i in range(1,num+1):
        print(i)
    exit()
s = []
sum1 = 0
while sum1 <=n:
    sum1 +=num
    s.append(num)
    num -=1

if sum1 > n:
    s[-1] -=sum1-n
if s[-1] == 0:
    s.pop()
    
for i in range(len(s)):
    print(s[i])

Submission status: Time Limit Exceeded

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

# from numba import njit
import sys
sys.setrecursionlimit(10**9)
# input = stdin.readline

INF = 10**9

# @njit
def solve(n):
  def dp(i,x,acc=[]):
    # i番目までで和をちょうどxにできるか
    if i == 0:
      if x == 0:
        return acc
      else:
        return [INF]
    else:
      return min(dp(i-1,x-i,[i]+acc),dp(i-1,x,acc),key=lambda x: x[-1])
  

  return dp(n,n)



def main():
  N = int(input())
  # N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(*solve(N),sep="\n")
  return

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

ans = {i for i in range(1,n+1)}

sum=n*(n+1)//2

for i in range(n,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()

# 数列の和
def re(x):
    return x*(x+1)//2

# 二分探索
l, r = 0, N+1
exact = -1
while abs(l - r) > 1:
    mid = (l + r) // 2
    if re(mid) > N:
        r = mid
    elif re(mid) == N:
        exact = mid
    else:
        l = mid

# 途中抜けしない場合
if exact != -1:
    for i in range(1, exact + 1):
        print(i)

# する場合
else:
    temp = re(r) - N
    for i in range(1, r+1):
        if i != temp:
            print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = []
cnt = 0
for i in range(1, int(n**0.7)+3):
    if n > cnt:
        ans.append(i)
        cnt += i
    else:
        if cnt - n in ans:
            ans.remove(cnt - n)
            break
for i in ans:
    print(i)

Submission status: Time 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))
b = bisect_left(al,N)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

#bit探索
def bit():
    for i in range(2 **N):
        op = []
        tmp=0
        for j in range(N):
            if ((i >> j) & 1):
                op.append(j+1)
                tmp += (j+1)
        if tmp == N:
            return op

li=bit()

for k in li:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N = int(input())
    ans = []

    for i in range(N, 0, -1):
        sm = 0
        elems = []
        for k in range(i, 0, -1):
            if sm + k <= N:
                sm += k
                elems.append(k)
                if sm == N:
                    ans = elems
    print(*ans,sep='\n')

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N = int(input())
    ans = []

    for i in range(N, 0, -1):
        sm = 0
        elems = []
        for k in range(i, 0, -1):
            if sm + k <= N:
                sm += k
                elems.append(k)
                if sm == N:
                    ans = elems
    print(*ans,sep='\n')

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
ldp=[[[False,[]] for j in range(N+1)] for i in range(N)]
ldp[0][0][0]=True
ldp[0][1][0]=True
ldp[0][1][1].append(0)
if N==1:
    print(1)
for i in range(N-1):
    for j in range(N+1):
        #if N<i+2:
        if j<i+2:
            ldp[i+1][j][0]=ldp[i][j][0]
            ldp[i+1][j][1]=ldp[i][j][1]
        else:
            #ldp[i+1][j]=(ldp[i][j] or ldp[i][N-(i+2)])
            if ldp[i][j][0]==True:
                ldp[i+1][j][0]=True
                ldp[i+1][j][1]=ldp[i][j][1]
            #elif ldp[i][N-(i+2)][0]==True:
            elif ldp[i][j-(i+2)][0]==True:
                ldp[i+1][j][0]=True
                #ldp[i+1][j][1]=ldp[i][N-(i+2)][1]+[i+1]
                ldp[i+1][j][1]=ldp[i][j-(i+2)][1]+[i+1]
            else:
                ldp[i+1][j][0]=False
    if ldp[i+1][N][0]==True:
        for k in ldp[i+1][N][1]:
            print(k+1)
        break
#for i in range(N):
#    print(ldp[i])

Submission status: Time Limit Exceeded

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

if n==1:
    print(1)
    exit()
t=0
acc=[]
for i in range(1,n+1):
    t+=i
    acc.append(t)
max_v=-1
for i in range(len(acc)-1):
    if acc[i]<n<=acc[i+1]:
        max_v=i+2
        break
ans=[]
ans.append(max_v)
cur=max_v
vv=acc[i+1]
vv-=cur
s=max_v

while vv and s<n:
    cur-=1
    if vv>cur and s+cur<=n:
        vv-=cur
        ans.append(cur)
        s+=cur
    elif vv<cur:
        continue
    elif vv==cur:
        vv-=cur
        ans.append(cur)
        s+=cur
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10000)

def nat_sum(n):
  if n==0:
    pass
  else:
    k = 0
    for i in range(n):
      if i*(i+1)//2 < n <= (i+1)*(i+2)//2:
        k = i+1
        break
    print(k)
    nat_sum(n-k)
    
n = int(input())
nat_sum(n)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
while N>0:
    if N==1:
        A.append(1)
        break
    high = N
    low = 0
    while True:
        mid = (high+low)//2
        if N<=((mid-1)*mid)//2:
            high = mid
        elif N>(mid*(mid+1))//2:
            low = mid
        else:
            break
    A.append(mid)
    N -= mid
for i in range(len(A)):
    print(A[i])

Submission status: Time Limit Exceeded

Solution code:
def bisect(lst, target, l, r):
    cent = (l + r) // 2

    if r - l == 1:
        return r

    if lst[cent] == target:
        return cent
    elif lst[cent] > target:
        return bisect(lst, target, l, cent)
    else:
        return bisect(lst, target, cent, r) 

N = int(input())
sm = []
buf = 0
for i in range(N + 1):
    sm.append(i + buf)
    buf += i

mx = bisect(sm, N, 0, N)

sub = sm[mx] - N

for i in range(1, mx + 1):
    if i != sub:
        print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
A = np.arange(1, N+1, dtype=np.int64)
A_cum = A.cumsum()
i = np.nonzero(A>=N)[0][0]
diff = A_cum[i] - N
s = set(range(1, i+1))
for j in range(i+1, 0, -1):
    if j <= diff:
        s -= {j}
        diff -= j
    else:
        print(j)
# 57

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

c=[i+1 for i in range(N)]
ans=[]
for i in range(2**N):
  total=[]
  for j in range(N):
    if i>>j&1:
      total.append(c[j])
  if sum(total)==N:
    if len(ans)<len(total):
      ans=total
for x in ans:
  print(x)

Submission status: Time Limit Exceeded

Solution code:
# 最大値の最小値、ちょうどn/2臭い
# あとは帳尻合わせが効きそう
# 14とかだと7+4+2+1 （7+5+2でも7+4+3でもいい
# かと思いきや 1+2+3+4+5で15いくので, 5+4+3+2でよかった
# 10^7なので毎回足してもどうせ間に合う。これで答えの集合のうち最大値は確定
# あとはそれでnを引いて0になるまで

n = int(input())
ans = []
cur = 0

while cur != n:
    tmp = 0
    for i in range(1, n + 1 - cur):
        if i + tmp >= n - cur:
            tmp = i
            break
        tmp += i
    ans.append(tmp)
    cur += tmp
    # print("tmp = {}, cur = {}".format(tmp, cur))
# print(ans)
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
lst=set()
for i in range(1,N+1):
    lst.add(i)
    if sum(lst)>=N:
        if sum(lst)==N:
            break
        else:
            lst.remove(sum(lst)-N)
for s in lst:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = N*(N+1)//2
for n in range(N,0,-1):
    if S-n<N:
        print(n)
    else:
        S-=n

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