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つの並べ方 (
a
1
,
a
2
, ...,
a
s
) が並べ方 (
b
1
,
b
2
, ...,
b
t
) に対して,
a
1
>
b
1
または, ある整数
i
> 1 が存在して
a
1
=
b
1
, ...,
a
i
-1
=
b
i
-1
かつ
a
i
>
b
i
が成り立つとき (
a
1
,
a
2
, ...,
a
s
) が (
b
1
,
b
2
, ...,
b
t
) より先に出力されるように並べることである.
入力データ は 1 行からなり,1 行目に
n
が書かれている.
出力には並べ方を辞書式順序で 1 行に1通りずつ書き最後に改行を入れること. 並べ方は (
a
1
,
a
2
, ...,
a
s
) の出力は整数
a
1
,
a
2
, . . . ,
a
s
をこの順番に空白で区切って出力すること.
入力例１
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
上記問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

void solve(int n, VI ret, VVI& v) {
    if (n == 0) {
        v.push_back(ret);
    } else {
        for (int i = n; i >= 1; --i) {
            if (ret.size() > 0 && ret.back() < i) continue;
            ret.push_back(i);
            solve(n - i, ret, v);
            ret.pop_back();
        }
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        VVI v;
        solve(n, {}, v);
        sort(v.begin(), v.end(), [](VI& a, VI& b) { return a > b; });
        for (VI& r : v) {
            string out = "";
            for (int& x : r) {
                out += to_string(x) + " ";
            }
            out.pop_back();
            cout << out << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3592
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;


#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define reps(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,e,n) for (int i = (n); i >= (e); --i)
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define len(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()



template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class H, class...T>void puta(H&& h, T&&...t) { cout << h << ' ';puta(t...); }

int MOD = 1'000'000'007;
ll inf = (1 << 30);

static const int NIL = -1;
static const ll MAX1 = 1 + 10;
static const ll MAX2 = 3'000 + 10;



ll n, m, q;

vvl fml;

ll sumAry(vl f) {
	ll sum = 0;
	rep(i, len(f)) sum += f[i];
	return sum;
}

void dfs(vl f) {


	if (len(f) > 0 && f.back() == 0) {

		if (sumAry(f) == n) {
			fml.push_back(f);
		}
		return;
	}
	else {


		ll df = n - sumAry(f);
		ll wk = len(f) > 0 ? f.back() : df;
		df = min(wk, df);


		f.push_back(df);

		while (f.back() >= 0) {

			dfs(f);

			f.back()--;
		}
		f.pop_back();

		return;
	}
}



int main() {


	ll  mxln = 0;;

	while (true)
	{
		cin >> n;

		if (n == 0) break;

		fml = vvl();

		vl arg;

		dfs(arg);

		rep(i, len(fml)) {
			string s = "";
			rep(j, len(fml[i])) {
				if (fml[i][j] == 0) break;
				if (j > 0) s += ' ';
				s += to_string(fml[i][j]);
			}
			cout << s << endl;
		}
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3436
final_rank: 18

code_snippet: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

template<class T>
void outvo(vector<T> v) {
  if (v.size() == 0) return;
  cout << v[0];
  for (int i = 1; i < v.size(); i++)
    cout << " " << v[i];
  cout << endl;
}

void dfs(ll n, vector<ll> ans) {
  // debug2(n, ans.size());

  if (n == 0) {
    outvo(ans);
    return;
  }

  for (int i = n; i >= 1; i--) {
    // debug3(n, i, ans.size());
    ll len = ans.size();
    if (len == 0 || (len > 0 && i <= ans[len-1])) {
      ans.push_back(i);
      dfs(n-i, ans);
      ans.pop_back();
    }
  }
}

void solve() {
  while (true) {
    ll n; cin >> n;
    if (n == 0) break;
    dfs(n, vector<ll>{});
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}
accuracy: 1
time_ms: 10
memory_kb: 3152
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void calc(int n,VI s){
    if(n==0){
        for(int i=0;i<s.size();i++){
            if(i>0) cout<<" ";
            cout<<s[i];
        }
        cout<<endl;
        return;
    }
    for(int i=n;i>=1;i--){
        if(s.size()>=1&&i>s[s.size()-1]) continue;
        VI t=s;
        t.pb(i);
        calc(n-i,t);
    }
}

int main(){
    int i,j;
    int n;
    while(1){    
    cin>>n;
    if(n==0) break;
    VI s;
    calc(n,s);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3092
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

void hoge(int n, vector<int> vec = {}) {
  if (n == 0) {
    cout << vec[0];
    for_each(vec.begin() + 1, vec.end(), [](auto &v) {cout << " " << v;});
    cout << endl;
    return;
  }

  int h = (vec.size() != 0) ? min(*vec.rbegin(), n) : n;

  for (int i = h; 1 <= i; --i) {
    vector<int> vec2 = vec;
    vec2.push_back(i);
    hoge(n - i, vec2);
  }
}

int main() {
  int n;
  while (cin >> n, n)
    hoge(n);
}
accuracy: 1
time_ms: 10
memory_kb: 3012
final_rank: 5

code_snippet: #include<iostream>
#include<vector>
using namespace std;
typedef vector<int> ans_t;
void dfs(int &n,int k,int memo,ans_t ans){
    if(k == n){
        for(int i = 0;i < ans.size();i++){
            cout << ans[i];
            if(i < ans.size()-1)cout << " ";
        }
        cout <<endl;
        return;
    }
    for(int i = memo;i < memo + 2;i++){
        //cout << "*" << i <<" " <<k ;
        int a , b;
        if(i == 0){
            a = 0;
            b = 1;
        }
        else{
            if(ans.size() < i + 1)a = 0;
            else{
                a = ans[i];
            }
            b = ans[i - 1];
        }
        //cout <<" " << a << " " << b<<endl;
        if(a < b){
            int memo_next = i;
            ans_t ans_next;
            for(int j = 0;j < ans.size();j++){
                ans_next.push_back(ans[j]);
            }
            if(ans.size() < i + 1)ans_next.push_back(1);
            else ans_next[i]++;
            dfs(n,k + 1,memo_next,ans_next);
        }
    }
    return;

}
int main(){
    vector<int> n;
    int l = 0;
    while(1){
        int v;
        cin >> v;
        if(v == 0)break;
        n.push_back(v);
        l++; 
    }
    for(int i = 0;i < l;i++){
        int k = 1;
        int memo = 0;
        ans_t ans;
        ans.push_back(1);
        dfs(n[i],k,memo,ans);
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3040
final_rank: 8

code_snippet: #include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

bool isOK(ll *v,ll n){
    for(int i=0;i<n;i++){
        if (*(v+i)<*(v+i+1))return false;
    }
    return true;
}

bool breakdown(ll *v,ll n){
    bool flag=false;
    for(int i=n-1;i>=0;i--){
        if (*(v+i)==0)continue;
        if(*(v+i)>*(v+i+1)+1){
            //まとめられるならまとめる
            /*
            ll sum=0;
            ll j=n+1;
            while(j>i+1){
                j--;
                if (*(v+j)==0){
                    continue;
                }
                sum+=*(v+j);
            }
            */
            //if(*(v+i)>sum){
            ll j=n;
            while(j>i+1){
                if (*(v+j)==0){
                    j--;
                    continue;
                }
                *(v+j-1)+=*(v+j);
                *(v+j)=0;
            }
            //}
            //崩す
            *(v+i)=*(v+i)-1;
            *(v+i+1)=*(v+i+1)+1;
            flag=true;
        }else if(*(v+i)==2&&*(v+i+1)==1){
            ll j=i;
            while(*(v+j)!=0){
                j++;
            }
            *(v+i)=*(v+i)-1;
            *(v+j)=*(v+j)+1;
            flag=true;
        }
        if (flag)break;
    }
    return flag;

}


int main(){
    ll ans;
    ll n;
    ll v[31];
    for(int i=0;i<31;i++)v[i]=0;

    while(true){
        cin >>n;
        if(n==0)break;
        for(int i=0;i<31;i++)v[i]=0;
        v[0]=n;
        cout <<n<<endl;
        while(breakdown(v,n)){
            if(isOK(v,n)){
                for(int i=0;i<n&&v[i]!=0;i++){
                    cout <<v[i];
                    if(i<n&&v[i+1]!=0)cout <<" ";
                }
                cout <<endl;
            }
        }
        
    }

    return 0;

}
accuracy: 1
time_ms: 50
memory_kb: 3104
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;

using i64 = int64_t;

void solve(int n, const vector<int> v){
    if(n == 0){
        for(int i=0;i<v.size();++i){
            if(i)cout << " ";
            cout << v[i];
        }
        cout << endl;
        return;
    }
    auto vv = v;
    for(int i=n;i>0;--i){
        if(v.size() > 0 && i>v.back())continue;
        vv.push_back(i);
        solve(n-i, vv);
        vv.pop_back();
    }
}

int main(){
    int n;
    while(cin >> n, n > 0){
        vector<int> v;
        solve(n, v);
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3160
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

//a:残り
//b:１回に使っていい最大数
//c:今までの結果
void dfs(ll a,ll b,string c){
	if(a==0){
		cout<<c<<endl;
		return;
	}
	ireg(i,1,min(b,a)){
		dfs(a-i,i,(c==""?to_string(i):c+" "+to_string(i)));
	}
}

ll n;

int main(void){
	while(1){
		cin>>n;
		if(n==0)break;
		dfs(n,n,"");
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3192
final_rank: 15

code_snippet: #include<iostream>
#include<vector>
using namespace std;

void dfs(vector<int> v, int before, int res){
    if(res == 0){
        for(int i = 0; i < v.size(); i++){
            if(i)   cout << " ";
            cout << v[i];
        }
        cout << endl;
        return;
    }

    for(int j = res; j >= 1; j--){
        if(before >= j){
            v.push_back(j);
            dfs(v, j, res-j);
            v.pop_back();
        }
    }
}

int main(){
    int n;
    while(cin >> n, n){
        for(int j = n; j >= 1; j--){
            vector<int> v;
            v.push_back(j);
            dfs(v, j, n-j);
        }
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3068
final_rank: 7

code_snippet: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int now[30];
int inde=0;
int a;

void solve(int sum,int t){
//  cout<<"  sum:  "<<sum<<"   t:  "<<t<<en;
  if(sum==a){
    cout<<now[0];
    for(int i=1;i<inde;i++){
      cout<<" "<<now[i];
    }
    cout<<en;
    return;
  }
  for(int i=t;i>=1;i--){
    if(sum+i<=a){
      now[inde++]=i;
      solve(sum+i,i);
      inde--;
    }
  }
  return ;
}
signed main(){
  while(cin>>a&&a){
    solve(0,a);
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3008
final_rank: 4

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
void solve(vector<int>v,int r) {
	if (r == 0) {
		for (int i = 0; i < v.size(); i++) {
			if (i)printf(" ");
			printf("%d", v[i]);
		}
		printf("\n");
	}
	else {
		int k;
		if (v.size() >= 1)k = min(r, v[v.size() - 1]);
		for (int i = k; i >= 1; i--) {
			v.push_back(i);
			solve(v, r - i);
			v.pop_back();
		}
	}
	return;
}
int main() {
	int n;
	while (cin >> n, n) {
		vector<int>v;
		solve(v, n);
	}
	return 0;
}
accuracy: 1
time_ms: 810
memory_kb: 3084
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
  
typedef long long ll;
typedef pair<int, int> ii;
 
#define DEBUG false
 
void dfs(vector<int> v, int n, int u){
     
    if(n == 0) {
        rep(i, v.size()){
            cout << v[i];
            if(i != v.size()-1) cout << " ";
        }
        cout << endl;
        return;
    }
    for(int i = min(n, u); i > 0; i--){
        vector<int> tmp(v);
        tmp.push_back(i);
        dfs(tmp, n-i, i);
    }
     
    return;
}
 
int main(){
 
    int n;
    while(cin >> n, n){
         
        vector<int> null;
        dfs(null, n, n);
         
    }
     
     
     
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3024
final_rank: 6

code_snippet: #include<bits/stdc++.h>
using namespace std;

void solve(int left, int right, vector<int> v){
    if(right == 0){
        for(int i=0;i<v.size();++i){
            cout << v[i];
            if(i+1 == v.size())cout << endl;
            else cout << " ";
        }
    }else{
        for(int i=right;i>0;--i){
            if(i <= left){
                v.push_back(i);
                solve(i, right - i, v);
                v.pop_back();
            }
        }
    }
}

int main(){
    int n;
    while(cin >> n, n != 0){
        for(int i=n;i>0;--i){
            vector<int> v;
            v.push_back(i);
            solve(i, n - i, v);
            v.pop_back();
        }
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3000
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

void dfs(int n, string s, int prev) {
    if(n == 0) {
        cout << s << endl;
    }
    for(int i=min(n, prev); i>=1; --i) {
        string next = s;
        if(s.size() == 0) {
            next += to_string(i);
        } else {
            next += ' ';
            next += to_string(i);
        }
        dfs(n-i, next, i);
    }
}

int main() {
    int n;
    while(cin >> n, n) {
        dfs(n, "", 100);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3292
final_rank: 17

code_snippet: #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stack>
using namespace std;
void solve(int n,list<int>a) {
	if (n == 0) {
		list<int>::iterator it = a.begin();
		while (it != a.end()) {
			if (it == a.begin()) cout << (*it);
			else cout << " " << (*it);
			it++;
		}
		cout << endl;
		return;
	}
	if (!a.empty()) {
		list<int>::iterator it = a.end();
		it--;
		for (int j = n; j >= 1; j--) {
			if ((*it) >= j) {
				a.push_back(j);
				solve(n - j, a);
				a.pop_back();
			}
		}
	}
	else {
		for (int j = n; j >= 1; j--) {
			a.push_back(j);
			solve(n - j, a);
			a.pop_back();
		}
	}
}
int main() {
	int n;
	while (cin >> n&&n != 0) {
		list<int>a;
		solve( n,a);
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3084
final_rank: 9

code_snippet: #include <iostream>
#include <string>
using namespace std;

void dfs(int n,int last,string s){
	for(int i = n;i >= 1;i--){
		if(n - i == 0 && last >= i) {
			cout << s << n << endl;
		}
		else {
			if(last >= i) dfs(n - i,i,s + to_string(i) + " ");
		}
	}
}

int main(){
	int n;
	while(cin >> n,n){
		dfs(n,n,"");
	}
	return 0;	
}
accuracy: 1
time_ms: 10
memory_kb: 3176
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int n;

string intToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

void func( int bef, int cnt, string s )
{
  if( cnt == n ) cout << s << endl;
  else {
    for(int i=bef; i>=1; i--) {
      string add = intToString( i );
      string next;
      if( s == "" ) next = add;
      else next = s + " " + add;
      if( cnt + i <= n ) func( i, cnt + i, next );
    }
  }
}

int main()
{
  while( cin >> n, n ) {
    func( n, 0, "" );
  }
}
accuracy: 1
time_ms: 30
memory_kb: 3052
final_rank: 11

code_snippet: #include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int n;
int t[30];

void dfs(int k, int d) {
  if(k == 0) {
    REP(i, 0, d) {
      cout << t[i];
      if(i + 1 != d) cout << " ";
    }
    cout << endl;
  } else {
    int len = d == 0 ? k : min(t[d - 1], k);
    for(int i = len; i > 0; i--) {
      t[d] = i;
      dfs(k - i, d + 1);
    }
  }
}

int main(void) {
  while(cin >> n, n != 0) {
    dfs(n, 0);
  }

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1160
final_rank: 2

code_snippet: #include <stdio.h>

int sq(int rec[],int cur){
    int i;
    int lim,left = rec[cur];
    if(left){
        lim = (left > rec[cur-1]) ? rec[cur-1] : left;
        for(i=lim;i>0;i--){
            rec[cur] = i;
            rec[cur+1] = left-i;
            sq(rec,cur+1);
            rec[cur] = left;
        }
    }else{
        for(i=0;i<cur;i++){
            printf("%d",rec[i]);
            if(i==cur-1){
                printf("\n");
            }else{
                printf(" ");
            }
        }
    }
}

int main(){
    int n,i;
    int rec[30];
    scanf("%d",&n);
    while(n){
        for(i=n;i>0;i--){
            rec[0] = i;
            rec[1] = n-i;
            sq(rec,1);
        }
        scanf("%d",&n);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 1032
final_rank: 1