Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}

C++: #include <iostream>

using namespace std;

void output(int num){
  static bool flag=true;
  if(num == -1){
    flag=true;
    cout << endl;
  }  
  else if(flag){
    cout << num;
    flag=false;
  }
  else
    cout << " " << num;
}

void func(int weight){
  if(weight > 0){
    int buf=1;
    while(buf <= weight)
      buf <<= 1;
    buf >>=1;
    output(buf);
    func(weight-buf);
  }
}

int main(){
  int buf;
  while(cin >> buf){
    func(buf);
    output(-1);
  }
  return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

bool W_b[10] = { false };
int W[] = { 1, 2, 4, 8 ,16, 32, 64, 128, 256, 512 };

void input(void) {
	CI N;
	return;
}


int main(void) {
	int nn = 0;
	while (CI N) {
		for (int i = 9; i >= 0; i--) {
			if (W[i] <= N) {
				N -= W[i];
				W_b[i] = true;
				nn++;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (W_b[i] == true) {
				CO W[i];
				if (i != nn - 1)CO " ";
				W_b[i] = false;
			}
		}
		CO "\n";
		CO pow(2, 32) E;
		nn = 0;
	}
	

	
	return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		stack<int> s;
		for(int i = 512; i > 0; i /= 2){
			if(n - i >= 0){
				s.push(i);
				n -= i;
			}
		}
		int o;
		while(!s.empty()){
			o = s.top();
			s.pop();
			if(s.empty())cout << o << endl;
			else cout << o << " ";
		}
	}
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main(){
  int p2[10] = {512,256,128,64,32,16,8,4,2,1},n;
  vector<int> v;
  while(cin>>n){
    for(int i=0;i<10;i++){
      if(n>=p2[i])n-=p2[i],v.push_back(p2[i]);
    }
    vector<int>::iterator it=v.begin();
    while(it!=v.end()){
      cout<<*it<<endl;
      it++;
    }
    v.clear();
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.weight", "r", stdin );

	int w;
	while (scanf ("%d", &w ) != EOF ){
		vector<int> res; res.clear();
		for (int i = 1; i <= 512; i<<=1 ){
			 if (w & i ) res.push_back (i );
		} // end for
		rep (i, res.size() ){
			cout << res[i] << (i != res.size() - 1 ? ' ' : '\n' );
		} // end rep
	} // end while

	return 0;
}

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

int main(){
  int w;
  vector<int> v;

  while( !cin.eof() && cin>>w ){

    if( w>0 ){
      v.clear();
      for( int i=512;i>=1;i= i/2 ){
	//	cout << "i="<<i<<endl;
	if( w>=i ){
	  w-=i;
	v.push_back( i );
	}
      }

      for( int i=v.size()-1;i>0;--i )
	cout << v[i]<< " ";
      cout << v[0] << endl;
    }else
      cout << "0" << endl;
  }

  return 0;
}

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

int n;

int main() {
  while (1) {
    if (scanf("%d", &n) != 1) return 0;

    bool first = true;
    for (int i=0; i<10; i++) {
      if (n >> i & 1) {
        if (first) printf("%d", 1 << i);
        else printf(" %d", 1 << i);
        first = false;
      }
    }
    puts("");
  }
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

//C++11

int main() {
	for (int w; cin >> w;) {
		string s = "";
		for (int i = 9; i >= 0; i--) {
			int a = pow(2, i);
			if (w / a) {
				if (s == "")
					s = to_string(a);
				else
					s = to_string(a) + " " + s;
				w -= a;
			}
		}
		cout << s << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
main()
{
	int a;
	while(cin>>a)
	{
		int f=0;
		for(int i=1;i<=a;i*=2)if(i&a)cout<<(f++?" ":"")<<i;
		cout<<endl;
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
	int weight;
	int i,j;
	int ans[10];
	
	for(;cin >> weight;)
	{
		for(i=0;i<10;i++)
			ans[i]=0;
			
		for(i=0;weight>0;weight/=2,i++)
		{
			ans[i]=weight%2;
		}
		
		if(ans[0]==1)
			cout << "1" ;
		
		for(i=1,j=2;i<10;i++,j*=2)
			if(ans[i]==1)
				cout << " " << j ;
				
		cout << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int weight[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(cin >> n){
		int t = 0;
		for(int i = 0; i < 10; i++){
			if(n % 2){
				if(t++) cout << " ";
				cout << weight[i];
			}
			n /= 2;
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  int used[10]={0,0,0,0,0,0,0,0,0,0};
  int omori[10] = {1,2,4,8,16,32,64,128,256,512};

  while( cin >> n){
    int i = 0;
    int f = 0;
    while(n){
      if(n >= omori[9-i]) {n -= omori[9-i];used[i] = omori[9-i];f++;}
      i++;
    }

    for(int j=9;j >= 0;j--){
      if(used[j] != 0 && f == 1){ cout << used[j] << endl;}
      if(used[j] != 0 && f != 1){ cout << used[j] << ' ' << flush;f--;}
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
// #define first first
// #define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;


signed main(){
    int n;
    while(cin >> n){
        vector<int> ans;
        rep(i, 0, 10){
            int t = 1 << i;
            if(n & t){
                ans. push_back(t);
            }
        }
        rep(i, 0, ans.size()){
            if(i != 0) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
}