Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		w := 512
		weights := make([]int, 10)
		for i := 9; i >= 0; i-- {
			if n >= w {
				weights[i] = w
				n -= w
			}
			w /= 2
		}

		output := []int{}
		for i := 0; i < 10; i++ {
			if weights[i] > 0 {
				output = append(output, weights[i])
			}
		}
		outputStr := fmt.Sprint(output)
		fmt.Println(outputStr[1:(len(outputStr) - 1)])
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n;
  while(cin >> n){
    cerr << n << endl;
    if( n == 0 ) break;
    int a = 1024;
    vector<int> b;
    while( a != 0 ){
      if( n / a != 0 ){
        n %= a;
        b.push_back(a);
      }
      a /= 2;
    }
    for(int i=0; i<b.size(); i++){
      if( i != b.size()-1 ) cout << b[b.size()-1-i] << " ";
      else cout << b[b.size()-1-i] << endl;
    }

  }


  return 0;
}


// EOF

C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	int start;
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
		start=0;

		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
				start=i;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		cout << w[start];
		for(int i=start+1; i<=9 ; i++){
			if(flag[i]!=0){
				cout << " " << w[i];
			}
		}
		
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	const int b[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int w, i, j, t, a[10];
	while (cin >> w)
	{
		if (cin.eof()) return 0;
		for (i = 9, j = 0, t = 0; i >= 0; i--)
		{
			if (w >= t + b[i])
			{
				a[j] = b[i];
				t += a[j];
				if (w == t + b[i])
					break;
				j++;
			}
		}
		for (i = j - 1; i > 0; i--)
			cout << a[i] << " ";
		cout << a[0] << endl;
	}

	return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W;
int weights[10] ={1,2,4,8,16,32,64,128,256,512};
int main()
{
  while(cin>>W){
    if(cin.eof())
      break;
    int type[10]={0};
    for(int j = 10;j >=0;j--){
      if(W-weights[j] >=0){
	W -=weights[j];
	type[j] = 1;
      }
    }
      for(int i = 0;i <10;i++){
	if(type[i] ==1){
	  cout <<weights[i];
	  if(i !=9)
	    cout <<" ";
	}else if(i ==9)
	  cout <<endl;
      }
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>

using namespace std;

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

int main(void) {
	int in;
	int omori[] = {512,256,128,64,32,16,8,4,2,1};
	int i;
	string ret;

	while(true) {
		cin >> in;
		if(cin.eof()) { break; }
		ret = "";
		for(i = 0; i < 10; i++) {
			if(omori[i] <= in) {
				in -= omori[i];
				ret = IntToString(omori[i]) + ((ret=="")?(""):(" ")) + ret;
			}
			if(in == 0) { break; }
		}
		cout << ret << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
	int n, count = 0, sum = 1;
	int ans[100][9] = { 0 }, data[100] = { 0 }, ansdata[100] = {0};
	for (int a = 0; a <= 10; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		int data2, count2 = 0;
		for (int a = 0; a <= 10; a++) {
			if (n < data[a + 1]) {
				sum = data[a];
				data2 = a;
				ans[count][count2] = a;
				count2++;
				break;
			}
		}
		for (int a = data2-1; a > 0; a--) {
			sum = sum + data[a];
			if (sum > n) {
				sum = sum - data[a];
			}
			else {
				ans[count][count2] = a;
				count2++;
			}
			if (sum == n) {
				break;
			}
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a < count; a++) {
		for (int b = ansdata[a]-1; b>=0; b--) {
			cout << data[ans[a][b]]<< " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	int n;
	for(;cin>>n;){
		int k=1;
		while(n){
			if(n&1){
				cout<<k;
				cout<<(n!=1?' ':'\n');
			}
			n/=2;
			k*=2;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<bitset>
using namespace std;

void solve( int w, int* g, bitset<10> b, int i )
{
    if( i == 10 )
    {
        int sum = 0;
        int p;                              //prsentation error回避
        for( int j = 0; j < 10; j++ )
        {
            if( b[j] == 1 )
            {
                sum += g[j];
                p = j;
            }
        }
        if( w == sum )
        {
            for( int j = 0; j < 10; j++ )
            {
                if( b[j] == 1 )
                {
                    cout << g[j];
                    if( p != j )
                        cout << " ";
                }
            }
        }
        return;
    }
    b[i] = 0;
    solve( w, g, b, i + 1 );

    b[i] = 1;
    solve( w, g, b, i + 1 );

}

int main()
{
    int a = 1, w, g[10];
    bitset<10> b;

    for( int i = 0; i < 10; i++ )
    {
        g[i] = a;
        a *= 2;
    }

    while( cin >> w )
    {
        solve( w, g, b, 0 );
        cout << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int ans[100]={},cnt=0;
    while(n){
      ans[cnt]=n%2;
      n/=2;
      cnt++;
    }
    int tmp=1;
    bool f=true;
    for(int i=0;i<cnt;i++){
      if(ans[i]>0){
        if(!f){
          cout << " ";
        }
        cout << ans[i]*tmp;
        f=false;
      }
      tmp*=2;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int x;
    while(cin>>x){
        for(int i=0; i<1023; i++){
            int bit =i;
            int sum =0;
            for(int j=0; j<10; j++){
                if(bit&1==1){
                    sum+=weight[j];
                }
                bit=bit>>1;
            }
            
            if(sum == x){
                for(int j=0; j<10; j++){
                    if(i&1==1){
                        cout<<weight[j]<<" ";
                    }
                    i=i>>1;
                }
                cout<<endl;
                break;
            }
            
            
            
        }
    }
    return 0;
}