Problem:


同じ大きさの正方形の紙が n 枚ある.これらの紙の下部を水平に揃えて何列かに並べる.ただし,隣り合う列は左側が右側より低くならないように並べなければならない.例えば, n = 5 のときは,次のような 7 通りの並べ方が可能である.

   これらを,各列に並んだ正方形の個数の列で表すことにする.例えば, n = 5 の
ときは,それぞれ,

          (5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)

	  

と表わされる.

   n を入力したとき, 辞書式順序で全て出力するプログラムを作成せよ.n ≤30
とする.ただし, 辞書式順序とは2つの並べ方 (a1, a2 , ..., as) が並べ方 (b1, b2, ..., bt ) に対して, a1 > b1 または, ある整数 i > 1 が存在して a1 = b1 , ..., ai-1 = bi-1 かつ ai > bi が成り立つとき (a1, a2, ..., as) が (b1 , b2, ..., bt) より先に出力されるように並べることである.

n が書かれている.

   出力ファイルのファイル名は “output.txt” である.“output.txt” には並べ方を辞書式順序で 1 行に1通りずつ書き最後に改行を入れること. 並べ方は (a1, a2, ..., as) の出力は整数 a1, a2, . . . , as をこの順番に空白で区切って出力すること.

-->

   入力データ は 1 行からなり,1 行目に n が書かれている.

   出力には並べ方を辞書式順序で 1 行に1通りずつ書き最後に改行を入れること. 並べ方は (a1, a2, ..., as) の出力は整数 a1, a2, . . . , as をこの順番に空白で区切って出力すること.

 

  入力例１
 

5

  　

  出力例１

5

4 1

3 2

3 1 1

2 2 1

2 1 1 1

1 1 1 1 1

入力

入力は複数のデータセットからなる．n が 0 のとき入力が終了する．データセットの数は 5 を超えない．

出力

データセットごとに、辞書式順序で全て出力する．

入力例

5
5
0

出力例

5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1

上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
5
5
0


Sample output:
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if not n:
        break
    print(n)
    for i in range(1, n):
        right_list = list((k,) for k in range(1, n // (i + 1) + 1))
        for j in range(i - 1):
            next_list = []
            for right in right_list:
                for k in range(right[0], (n - sum(right)) // (i - j) + 1):
                    next_list.append((k,) + right)
            right_list = next_list
        for right in right_list:
            print(n - sum(right), *right)

Submission status: Wrong Answer

Solution code:
def main():
    pass
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

def f(n,list,index):
    i = 0
    while i<n and list[i] > 0:
        sys.stdout.write(str(list[i]))
        i += 1
        if i<n and list[i] >= 1:
            sys.stdout.write(" ")
    print()
    if index==n:
        return True
    while list[index]>1:
        list[index] -= 1
        i=index+1
        while list[i] >=list[index]:
            i+=1
        list[i]+=1

        if f(n,list,i):
            return True
    return False

n=int(input())
while n!=0:
    list=[0]*n
    list[0]=n
    f(n,list,0)
    n=int(input())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0507

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n):
    print(*n)
    if max(n) == 1:
        return

    l = len(n)
    for i in range(l-1, -1, -1):
        if n[i] != 1:
            n[i] -= 1
            j = i + 1

            while True:
                if j >= l:
                    n.append(1)
                    break
                if n[i] >= n[j]+1:
                    n[j] += 1
                    break
                j += 1
            break
    solve(n)


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        solve([n])


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

Submission status: Wrong Answer

Solution code:
def func(n, M, k, s):
  if k == 0 and n == 0:
    print(s)
  elif n > 0:
    for i in range(min(n, M),0,-1):
      func(n - i, i, k - 1, s + " " + str(i) if s != "" else str(i))
while True:
  n = int(input())
  if not n:
    break
  for i in range(1,n + 1):
    func(n, n, i, "")

Submission status: Wrong Answer

Solution code:
import sys
while True:
    a= input()
    if a==0: break
    q=[]
    q.append(a)
    while True:
        for i,j in enumerate(q):
            sys.stdout.write("%d "%j)
        else: print 
        if len(q) == a: break
        i=1
        if 1 not in q:
            q[-i]-=1
            q.append(1)
            continue
        tt = q.index(1)
        if q[tt-1] != 2:
            q[tt-1]-=1
            q[tt]+=1
        elif q[tt-1] == 2:
            q[tt-1]-=1
            q.append(1)

Submission status: Wrong Answer

Solution code:
def f(n, nn, a):
    if n == 0:
        print ' '.join(map(str, a)).replace(' 0', '')
    else:
        i = min(n, a[nn-1] if nn!=0 else n)
        while i >= 1:
            a[nn] = i
            f(n-i, nn+1, a)
            i -= 1
while True:
    n = int(raw_input())
    if n == 0:
        break
    f(n, 0, [0]*n)

Submission status: Wrong Answer

Solution code:
def f(n, nn, a):
    if n == 0 and len(a)==sum(a):
        print ' '.join(map(str, a)).replace(' 0', '')
    else:
        i = min(n, a[nn-1] if nn!=0 else n)
        while i >= 1:
            a[nn] = i
            f(n-i, nn+1, a)
            i -= 1
while True:
    n = int(raw_input())
    if n == 0:
        break
    f(n, 0, [0]*n)

Submission status: Wrong Answer

Solution code:
while 1:
	n = input()
	if n == 0: break
	L = [n]
	print n
	while len(L) < n:
		for i in range(len(L)-1):
			if L[i] - L[i+1] > 1:
				L[i] -= 1
				L[i+1] += 1
				break
		else:
			for i in range(1,len(L)+1):
				if L[i-1] > 1 and (i == len(L) or L[i] == 1):
					L[i-1] -= 1
			L.append(1)
		print " ".join(map(str,L))

Submission status: Time Limit Exceeded

Solution code:
def dfs(s,com):
    if s==0:
        for i in xrange(len(com)-1):
            if com[i]<com[i+1]:return
        ans.append(com)
    for i in xrange(s,0,-1):
        if s>=i:
            com+=str(i)
            dfs(s-i,com)
            com=com[0:len(com)-1]
    return ans

while 1:
    n=int(raw_input())
    if n==0:break
    ans=[]
    ans=dfs(n,"")
    for i in xrange(len(ans)):
        print(' '.join(ans[i]))

Submission status: Accepted

Solution code:
l = [0 for i in range(31)]
pos = goal = 0
def solve(cur,sum):
    global pos, goal
    if cur == goal:
        print " ".join(map(str,l[:pos]))
        return
    for i in range(sum,0,-1):
        if cur + i <= goal:
            l[pos] = i
            pos += 1
            solve(cur+i,i)
            pos -= 1
while True:
    goal = int(raw_input())
    if goal==0: break
    solve(0,goal)

Submission status: Accepted

Solution code:
l = [0]*31
pos = goal = 0
def solve(cur,sum):
    global pos, goal
    if cur == goal:
        print " ".join(map(str,l[:pos]))
        return
    for i in range(sum,0,-1):
        if cur + i <= goal:
            l[pos] = i
            pos += 1
            solve(cur+i,i)
            pos -= 1
while True:
    goal = int(raw_input())
    if goal == 0: break
    solve(0,goal)

Submission status: Accepted

Solution code:
l = [0]*31
pos = goal = 0
def solve(sum,cur):
    global pos, goal
    if sum == goal:
        print " ".join(map(str,l[:pos]))
        return
    for i in range(cur,0,-1):
        if sum + i <= goal:
            l[pos] = i
            pos += 1
            solve(sum+i,i)
            pos -= 1
while True:
    goal = int(raw_input())
    if goal == 0: break
    solve(0,goal)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if not n:
        break
    results = {(n,)}
    for i in range(1, n):
        right_list = list((k,) for k in range(1, n // (i + 1) + 1))
        for j in range(i - 1):
            next_list = []
            for right in right_list:
                for k in range(right[0], (n - sum(right)) // (i - j) + 1):
                    next_list.append((k,) + right)
            right_list = next_list
        for right in right_list:
            results.add((n - sum(right),) + right)
    for result in sorted(results, reverse=True):
        print(*result)

Submission status: Accepted

Solution code:
import sys
def line():return sys.stdin.readline().strip()
def a(n,k,s):
    if k == 0:print(s[1:])
    elif k > 0:
        for i in range(1,n + 1)[::-1]:
            a(i,k - i,s + " " + str(i))
while True:
    n = int(line())
    if n == 0:break
    a(n,n,"")

Submission status: Accepted

Solution code:
def dfs(s,com):
    if s==0:
        ans.append(" ".join(map(str,com)))
        return
    for i in xrange(s,0,-1):
        if len(com)>0 and com[-1]<i:continue
        com.append(i)
        dfs(s-i,com)
        del com[-1]
    return ans

while 1:
    n=int(raw_input())
    if n==0:break
    ans=[]
    com=[]
    ans=dfs(n,com)
    for i in xrange(len(ans)):
        print(ans[i])

Submission status: Accepted

Solution code:
def generate_square(rest, output=[10000]):                   
  for i in range(rest, 0, -1):                               
    if output[-1] >= i:                                      
        yield from generate_square(rest - i, output + [i])   
  if rest == 0:                                              
    yield output                                             
                                                             
                                                             
while 1:                                                     
  x = int(input().strip())                                   
  if x == 0:                                                 
    break                                                    
  generator = generate_square(x)                             
  for x in generator:                                        
    print(" ".join(map(str, x[1:])))

Submission status: Accepted

Solution code:
def rec(n):
    if n>0:
        for i in range(n,0,-1):
            if i<=ans[-1]:
                ans.append(i)
                rec(n-i)
                ans.pop()
    else:
        if len(ans)!=0:
            print ((' ').join(map(str, ans[1:])))

while True:
    n = int(input())
    if n==0: break
    ans = [n]
    rec(n)

Submission status: Accepted

Solution code:
A= [[ [] for i in range(31)] for j in range (31)]
A[1][1]=["1"]
for i in range(2,31):
    A[i][i]=[str(i)]
    for j in range(1,i+1):
        for k in range(1,j+1):
            for a in A[i-j][k]:
                A[i][j].append( " ".join( [str(j), a] ))
while(1):
    n=int(raw_input())
    if n==0: break
    for p in reversed(A[n][1:n+1]):
        for q in reversed(p):
            print q

Submission status: Accepted

Solution code:
def solve():
    answers = [[] for i in range(31)]
    ans = []
    def square(n, rest, limit):
        if rest == 0:
            answers[n].append(ans[:])
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                ans.append(i)
                square(n, rest - i, i)
                ans.pop()
    
    import sys
    for n in map(int, sys.stdin.readlines()):
        if n == 0:
            break
        a = answers[n]
        if not a:
            square(n, n, n)
        for l in a:
            print(*l)

solve()

Submission status: Accepted

Solution code:
def solve():
    answers = []
    ans = []
    def square(n, rest, limit):
        if rest == 0:
            answers.append(' '.join(map(str, ans)))
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                ans.append(i)
                square(n, rest - i, i)
                ans.pop()
    
    import sys
    for n in map(int, sys.stdin.readlines()):
        if n == 0:
            break
        square(n, n, n)
    
    print('\n'.join(answers))

solve()

Submission status: Accepted

Solution code:
def solve():
    ans = []
    def square(n, rest, limit):
        if rest == 0:
            print(*ans)
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                ans.append(i)
                square(n, rest - i, i)
                ans.pop()
    
    import sys
    for n in map(int, sys.stdin.readlines()):
        if n == 0:
            break
        square(n, n, n)

solve()

Submission status: Accepted

Solution code:
def solve():
    answers = []
    def square(ans, rest, limit):
        if rest == 0:
            answers.append(' '.join(map(str, ans)))
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                square(ans + [i], rest - i, i)
    
    import sys
    for n in map(int, sys.stdin):
        if n == 0:
            break
        square([], n, n)
    
    print('\n'.join(answers))

solve()

Submission status: Accepted

Solution code:
def solve():
    answers = []
    def square(ans, rest, limit):
        if rest == 0:
            print(*ans)
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                square(ans + [i], rest - i, i)
    
    import sys
    for n in map(int, sys.stdin):
        if n == 0:
            break
        square([], n, n)

solve()

Submission status: Accepted

Solution code:
dic = [[] for i in range(31)]
dic[1].append([1])

def func(n):
  if dic[n]:
    return dic[n]
  else:
    dic[n].append([n])
    for i in range(n - 1, 0, -1):
      for l in func(n - i):
        if i >= l[0]:
          dic[n].append([i] + l)
    return dic[n]
func(30)

while True:
  n = int(input())
  if not n:
    break
  for l in dic[n]:
    print(" ".join(map(str, l)))

Submission status: Accepted

Solution code:
def main():
  dic = [[] for i in range(31)]
  dic[1].append([1])
  
  def func(n):
    if dic[n]:
      return dic[n]
    else:
      dic[n].append([n])
      for i in range(n - 1, 0, -1):
        for l in func(n - i):
          if i >= l[0]:
            dic[n].append([i] + l)
      return dic[n]
  func(30)
  
  while True:
    n = int(input())
    if not n:
      break
    for l in dic[n]:
      print(" ".join(map(str, l)))
main()

Submission status: Accepted

Solution code:
dic = [[] for i in range(31)]
dic[1].append([1])

def func(n):
  if dic[n]:
    return dic[n]
  else:
    dic[n].append([n])
    for i in range(n - 1, 0, -1):
      for l in func(n - i):
        if i >= l[0]:
          dic[n].append([i] + l)
    return dic[n]
func(30)

def main():
  while True:
    n = int(input())
    if not n:
      break
    for l in dic[n]:
      print(" ".join(map(str, l)))
main()

Submission status: Accepted

Solution code:
# AOJ 0507: Square
# Python3 2018.6.29 bal4u

a = [0]*31
def rec(k, n, m):
	if n <= 0:
		print(*a[:k])
		return
	if n < m: m = n
	for i in range(m, 0, -1):
		a[k] = i
		rec(k+1, n-i, i)

while True:
	n = int(input())
	if n == 0: break
	rec(0, n, n)

Submission status: Accepted

Solution code:
def square(n, height):
    if n == 0:
        yield ()
    else:
        for i in range(min(n, height),0, -1):
            for x in square(n-i, i):
                yield ('%d'%(i,),) + x 

def chunker(f):
    while True:
        line = f.readline()
        line = line.strip()
        n = int(line)
        if n == 0:
            raise StopIteration
        for s in square(n, n):
            yield s

import sys
for s in chunker(sys.stdin):
    print ' '.join(s)

Submission status: Accepted

Solution code:
l = []
def pl(m):
    for i in range(len(l)):
        print str(l[i]),
    print str(m)
def rfunc(n,lim):
    if n<=lim: pl(n)
    for i in range(1,n):
        if(i<n-lim):continue
        l.append(n-i)
        rfunc(i, n-i)
        l.pop()
while(1):
    m = int(raw_input())
    if m==0: break
    rfunc(m,m)

Submission status: Accepted

Solution code:
def rec(n):
    if n>0:
        for i in range(n,0,-1):
            if i<=ans[-1]:
                ans.append(i)
                rec(n-i)
                ans.pop()
    else:
        if len(ans)!=0:
            print ' '.join(map(str, ans[1:]))


while True:
    n = input()
    if n==0: break
    ans = [n]
    rec(n)

Submission status: Accepted

Solution code:
def solve(n):
	if n > 0:
		for i in range(n,0,-1):
			if i <= ans[-1]:
				ans.append(i)
				solve(n-i)
				ans.pop()
	else:
		print ' '.join(map(str,ans[1:]))
while 1:
	n = input()
	if n==0: break
	ans = [n]
	solve(n)

Submission status: Accepted

Solution code:
def f(a,n):
	for i in range(min(n,a[-1]),0,-1): f(a+[i],n-i)
	if n == 0: print " ".join(map(str,a[1:]))
while 1:
	n = input()
	if n==0: break
	f([n],n)

Submission status: Accepted

Solution code:
def f(a,n):
	for i in range(min(n,a[-1]),0,-1):f(a+[i],n-i)
	if n==0:print " ".join(map(str,a[1:]))
while 1:
	n=input()
	if n==0:break
	f([n],n)

Submission status: Accepted

Solution code:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


ANS = []
N = None

def recursive(table,pre,tmp_sum):
    global N
    for i in range(min(pre,N-tmp_sum),0,-1):
        work = []
        for k in range(len(table)):
            work.append(table[k])
        work.append(i)
        next_tmp_sum = tmp_sum+i

        if next_tmp_sum == N:
            ANS.append(work)
            continue
        recursive(work,i,next_tmp_sum)


while True:
    N = int(input())
    if N == 0:
        break

    ANS.clear()

    recursive([],BIG_NUM,0)
    for i in range(len(ANS)):
        print(' '.join(map(str,ANS[i])))

Submission status: Accepted

Solution code:
def sq(n_left,num_min,list_p = []):
  if n_left == 0:
    print(" ".join(list(map(str,list_p))))
    return 0
  for i in range(min(num_min,n_left),0,-1):
    list_p.append(i)
    sq(n_left - i, i ,list_p)
    list_p.pop()

while(True):
  n = int(input())
  if n == 0:
    break
  sq(n,n)

Submission status: Accepted

Solution code:
# リスト p を返す.
# p[n][k] (0 <= n <= N, 0 <= k <= n)
# は n の k 以下の正整数による分割のリスト.
def partitions(N):
    p = [[None for k in range(n + 1)] for n in range(N + 1)]
    p[0][0] = [[]]
    for n in range(1, N + 1):
        p[n][0] = []
        for k in range(1, n + 1):
            p[n][k] = p[n][k - 1] + list(map(lambda l: l + [k], p[n - k][min(n - k, k)]))
    return p

while True:
    n = int(input())
    if n == 0:
        break
    l = partitions(n)[n][n]
    for i in range(len(l) - 1, -1, -1):
        print(" ".join((map(str, reversed(l[i])))))

Submission status: Accepted

Solution code:
def sqmake(n):
    if sq[n-1:n]:pass
    else:sqmake(n-1)
    sq_n=[]
    for j in sq[n-1]:
        for k in range(len(j)):
            sq_n_i=j[:]
            sq_n_i[k]+=1
            sq_n_i.sort(reverse=True)
            if sq_n_i in sq_n:pass
            else:sq_n.append(sq_n_i)
    sq_n_i=j[:]
    sq_n_i.append(1)
    sq_n.append(sq_n_i)
    sq_n.sort(reverse=True)
    sq.append(sq_n)
sq=[[[0]],[[1]]]
while 1:
    n=int(input())
    if n==0:break
    sqmake(n)
    for i in sq[n]:print(' '.join(map(str,i)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0507

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n, a=0):
    result = []
    in_progress = [[[], n]]
    while in_progress:
        arr, rem = in_progress.pop()
        ub = min(arr[-1] if arr else rem, rem)
        for i in range(ub, 0, -1):
            if rem - i == 0:
                result.append(arr + [i])
            else:
                in_progress.append([arr + [i], rem - i])
    return sorted(result, reverse=True)


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        ans = solve(n)
        for row in ans:
            print(*row, sep=' ')


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

Submission status: Runtime Error

Solution code:
l = [0 for i in range(20)]
pos = goal = 0
def solve(cur,sum):
    global pos, goal
    if cur == goal:
        print " ".join(map(str,l[:pos]))
        return
    for i in range(sum,0,-1):
        if cur + i <= goal:
            l[pos] = i
            pos += 1
            solve(cur+i,i)
            pos -= 1
while True:
    goal = int(raw_input())
    if goal==0: break
    solve(0,goal)

Submission status: Runtime Error

Solution code:
while(1):
  l = []
  input = int(raw_input())
  if input == 0:
    break
  print input
  number = [input - 1, 1]
  for n in len(number):
    print n,
  print
  while(1):
    if number[1] == 2:
      l[0] = number[0] - 1
      for i in len(number):
        l.append[1]
    elif  number[1] == 1:
      l[0] = number[0] - 1
      l[1] = 2
      for i in len(number) - 2:
        l.append[1]
    elif number[0] == 1:
      break
    for i in len(l):
      print i,
  print

Submission status: Runtime Error

Solution code:
while(1):
  l = []
  input = input()
  if input == 0:
    break
  print input
  number = [input - 1, 1]
  for n in len(number):
    print n,
  print
  while(1):
    if number[1] == 2:
      l[0] = number[0] - 1
      for i in len(number):
        l.append[1]
    elif  number[1] == 1:
      l[0] = number[0] - 1
      l[1] = 2
      for i in len(number) - 2:
        l.append[1]
    elif number[0] == 1:
      break
    for i in len(l):
      print i,
  print

Submission status: Runtime Error

Solution code:
input = [input()]
if input[0] == 0:
  break
while input[0] != 1:
  if input[1] == 1:
    input[0] -= 1
    input[0] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print e,
  print

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break
input = [5, 0]
while input[0] != 1:
  if input[1] == 1:
    input[0] -= 1
    input[0] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print e,
  print

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break
input = [5, 0]
while input[0] != 1:
  if input[1] == 1 or input[2] == 0:
    input[0] -= 1
    input[0] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print e,
  print

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break
input = [5, 0]
while input[0] != 1:
  if input[1] == 1 or input[1] == 0:
    input[0] -= 1
    input[0] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print e,
  print

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break
input = [5, 0]
while input[0] != 1:
  if input[1] == 1 or input[1] == 0:
    input[0] -= 1
    input[0] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print input[e],
  print

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break
input = [5, 0]
while input[0] != 1:
  if input[1] == 1 or input[1] == 0:
    input[0] -= 1
    input[1] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print input[e],
  print

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break
input = [5, 0]
while input[0] != 1:
  if input[1] == 1 or input[1] == 0:
    input[0] -= 1
    input[1] += 1
  elif input[1] == 2:
    input[1] -= 1
    input.append(1)
  for e in range(0, len(input)):
    print input[e],
  print ''

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  for e in range(0, len(n)):
    print n[e],
  print ''

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  for e in range(0, len(n)):
    print n[e],
  print ''
n[1] -= 1
input.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  for e in range(0, len(n)):
    print n[e],
  print ''
n[1] -= 1
input.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1:
  if n[0] == 2 and n[1] == 1:
    break
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  for e in range(0, len(n)):
    print n[e],
  print ''
n[1] -= 1
input.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1:
  if n[0] == 2 and n[1] == 1:
    break
  elif n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  for e in range(0, len(n)):
    print n[e],
  print ''
n[1] -= 1
input.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1 and n[0] >= n[1]:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  if n[0] < n[1]:
    break
  for e in range(0, len(n)):
    print n[e],
  print ''
n[0] -= 1
input.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1 and n[0] >= n[1]:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    input.append(1)
  if n[0] < n[1]:
    break
  for e in range(0, len(n)):
    print n[e],
  print ''
n[0] -= 1
n.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1 and n[0] >= n[1]:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    n.append(1)
  if n[0] < n[1]:
    break
  for e in range(0, len(n)):
    print n[e],
  print ''
n[0] -= 1
n.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1 and n[0] >= n[1]:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    n.append(1)
  if n[0] < n[1]:
    break
  for e in range(0, len(n)):
    print n[e],
  print ''
n[1] -= 1
n.append(1)
for e in range(0, len(n)):
  print n[e],

Submission status: Runtime Error

Solution code:
input = input()
print input
if input == 0:
  break 
n = [input, 0]
while n[0] > 1 and n[0] <= input + 1 and n[0] >= n[1]:
  if n[1] == 1 or n[1] == 0:
    n[0] -= 1
    n[1] += 1
  elif n[1] == 2:
    n[1] -= 1
    n.append(1)
  if n[0] < n[1]:
    break
  for e in range(0, len(n)):
    print str(n[e]),
  print ''
n[1] -= 1
n.append(1)
for e in range(0, len(n)):
  print str(n[e]),

Submission status: Runtime Error

Solution code:
def generate_square(rest, output=[10000]):                   
  for i in range(rest, 0, -1):                               
    if output[-1] >= i:                                      
        yield from generate_square(rest - i, output + [i])   
  if rest == 0:                                              
    yield output                                             
                                                             
                                                             
while 1:                                                     
  x = int(input().strip())                                   
  if x == 0:                                                 
    break                                                    
  generator = generate_square(x)                             
  for x in generator:                                        
    print(" ".join(map(str, x[1:])))                         
GN-2:python kodairatomonori$

Submission status: WA: Presentation Error

Solution code:
def f(n,m,l):
  if n == 0:
    s = ''
    for i in l:
      s += str(i)
    print(s)
    return
  else:
    for i in range(1,min(n,m)+1):
      l.append(min(n,m)+1-i)
      f(n-min(n,m)-1+i,min(n,m)+1-i,l)
      l.pop()
while True:
  n = int(input())
  if n == 0:
    break
  else:
    f(n,30,[])

Submission status: WA: Presentation Error

Solution code:
def f(n,m,l):
  if n == 0:
    s = ''
    for i in l:
      s += str(i)
    print(s)
    return
  else:
    for i in range(1,min(n,m)+1):
      l.append(min(n,m)+1-i)
      f(n-min(n,m)-1+i,min(n,m)+1-i,l)
      l.pop()
while True:
  n = int(input())
  if n == 0:
    break
  else:
    f(n,30,[])
    print()

Submission status: WA: Presentation Error

Solution code:
def f(n,m,l):
  if n == 0:
    s = ''
    for i in l:
      s = s + str(i) + ' ' 
    s.rstrip()
    print(s)
    return
  else:
    for i in range(1,min(n,m)+1):
      l.append(min(n,m)+1-i)
      f(n-min(n,m)-1+i,min(n,m)+1-i,l)
      l.pop()
while True:
  n = int(input())
  if n == 0:
    break
  else:
    f(n,30,[])
    print()

Submission status: WA: Presentation Error

Solution code:
def f(n,m,l):
  if n == 0:
    s = ''
    for i in l:
      s = s + str(i) + ' ' 
    s.rstrip()
    print(s)
    return
  else:
    for i in range(1,min(n,m)+1):
      l.append(min(n,m)+1-i)
      f(n-min(n,m)-1+i,min(n,m)+1-i,l)
      l.pop()
while True:
  n = int(input())
  if n == 0:
    break
  else:
    f(n,30,[])

Submission status: WA: Presentation Error

Solution code:
def f(n,m,l):
  if n == 0:
    s = ''
    for i in l:
      s = s + str(i) + ' ' 
    s.rstrip()
    print(s)
    return
  else:
    for i in range(1,min(n,m)+1):
      l.append(min(n,m)+1-i)
      f(n-min(n,m)-1+i,min(n,m)+1-i,l)
      l.pop()
while True:
  n = int(input())
  if n == 0:
    break
  else:
    f(n,30,[])
print()