Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}

C++: #include<iostream>
#include<vector>
int main(){
	int w;
	int weight[10]={1,2,4,8,16,32,64,128,256,512};
	std::vector<bool> vec(10,0);
	while(1){
		int a=0;
		std::cin>>w;
		if(std::cin.eof())break;
		//if(w==0)break;
		while(w>0){
			vec[a]=w%2;
			w/=2;
			a++;
		}
		for(int i=0;i<10;i++){
			if(vec[i]!=0)std::cout<<weight[i]<<" ";
		}
		std::cout<<std::endl;
	}
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    vector<int> v;
    for (int i = 0; i < 10; i++) {
      if (1 << i & n) {
        v.push_back(1 << i);
      }
    }
    cout << v[0];
    for (size_t i = 1; i < v.size(); i++) {
      cout << " " << v[i];
    }
    cout << "\n";
  }
}

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

int main(){

  int weight;
  int n;

  while(cin>>weight){
    vector<int> result;
    while(1){
      if(weight == 0 || weight == 1 || weight ==2 || weight ==4 || weight ==8 || weight ==16 || weight ==32 || weight ==64 || weight ==128 || weight ==256 || weight ==512){
	result.push_back(weight);
	break;
      }
      if(weight<4)
	n=2;
      else if(weight<8)
	n=4;
      else if(weight<16)
	n=8;
      else if(weight<32)
	n=16;
      else if(weight<64)
	n=32;
      else if(weight<128)
	n=64;
      else if(weight<256)
	n=128;
      else if(weight<512)
	n=256;
      else
	n=512;
      
      result.push_back(n);
      weight-=n;
    }

    sort(result.begin(),result.end());

    int flag=0;
    for(auto i:result){
      if(flag==1)
	cout<<" ";
      else flag=1;
      cout<<i;
    }
    
    cout<<endl;
    result.clear();
  }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  int square[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  vector<int> num;

  while(cin >> n){
    if(n == 0) break;

    for(int i = 9; i >= 0; i--){
      if(n >= square[i]){
        num.push_back(i);
        n -= square[i];
      }
    }

    for(int i = num.size() - 1; i >= 0; i--){
      cout << square[ num[i] ];
      if(i = 0) cout << endl;
      else      cout << " ";
    }    
    num.clear();
  }
}

C++: #include <iostream>
#include <limits>
#include <cmath>

using namespace std;

int main() {

	int v;
	while (cin >> v) {
		int sum = 0;
		for(unsigned i = 0; i < 10; ++i) {
			if ((v>>i)&1) {
				sum += pow(2,i);
				cout << pow(2,i);
				if (sum != v) cout << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	while(~scanf("%d",&n)){
		bool f = false;
		for(int i=0; (1<<i)<=n; i++)if( n&(1<<i) ){
			if( f )putchar(' ');
			printf("%d",1<<i);
			f = true;
		}
		puts("");
	}
	return 0;
}

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};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		// n - w[i] で引けた配列番号を flag[i] で記憶

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

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

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

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

int main()
{
    for (int w; cin >> w;) {
        bool first = true; // flag for output
        for (int x = 1; w; x <<= 1) {
            int result = w & x;
            if (result) {
                if (first) {
                    first = false;
                    cout << result;
                } else
                    cout << " " << result;
                w -= x;
            }
        }
        cout << endl;
    }

    return 0;
}

C++: //-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int wheit[10] = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };
	int a;
	while (cin >> a)
	{
		VI ANS;
		REP(i, 10)
		{
			if (a >= wheit[i])
			{
				a -= wheit[i];
				ANS.push_back(wheit[i]);
			}
		}
		REP(i, SZ(ANS))
		{
			if (i != SZ(ANS) - 1 || i == 0)
			{
				cout << ANS[SZ(ANS) - i];
			}
			else
			{
				cout << " ";
				cout << ANS[SZ(ANS) - i];
			}
		}
		cout << endl;
	}
#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

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

int main() {
	int we[10] = { 1,2,4,8,16,32,64,128,256,512 };
	int n;
	vector<int>v;
	vector<int>::iterator pv=v.begin();
	while (cin >> n) {
		int h = 9;
		while (n == 0) {
			if (n - we[h] > 0) {
				n -= we[h];
				v.push_back(h);
			}
			h--;
		}
		for (int i = v.size(); i >-1; i--) {
			cout << we[*pv];
			pv++;
			if (i != 0) { cout <<" "; }
			else { cout << endl; }
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  bool f, g = 0;
  int n, i;
  while (cin >> n) {
    if (g) {
      cout << endl;
      g = 0;
    }
    f = 0;
    for (i = 0; i < 10; i++) {
      if (f) {
        cout << ' ';
        f = 0;
      }
      if (n & 1 << i) {
        cout << (1 << i);
        f = 1;
      }
    }
    g = 1;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    int weight;
    while(cin >> weight)
{
        vector<int> vi;
        for(int i = 512; weight != 0; i = i / 2)
{
            if(weight >= i)
{
                weight -= i;
                vi.push_back(i);
            }
        }
        int size = vi.size();
        if(size > 0)
{
            cout << vi[size - 1];
            for(int i = size - 2; i >= 0; i--)
{
                cout << " " << vi[i];
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int w;
	while( cin >> w ) {
		vector<int> a;

		int x = 0;
		for( int i = 0; i < 10; ++i ) {
			if( w & (1 << i) ) {
				x |= 1 << i;
				a.push_back( 1 << i );
			}

			if( x == w ) {
				break;
			}
		}

		for( int i = 0; i < a.size(); ++i ) {
			cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
		}
	}
}