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 <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int input,temp,a;
int print[11];

int main()
{
	while(scanf("%d",&input)!= EOF)
	{
	a=9;
	temp=512;
	for(int z=0;z<11;z++)
	{
		print[z]=0;
	}
	while(temp>=1)
	{
		if(input<temp)
		{
			temp=temp/2;
		}
		else if(temp<=input&&temp!=1)
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp/=2;
		}
		else
		{
			input-=temp;
			print[a]=temp;
			a--;
			temp=0;
			break;
		}
	}
	for(int z=0;z<11;z++)
	{
		if(print[z]!=0&&print[z+1]!=0)
		printf("%d ",print[z]);
		else if(print[z]!=0)
		printf("%d",print[z]);
	}
	printf("\n");
	}
	return 0;
}

C++: #include <cstdio>

int main(){
  int n;
  while(~scanf("%d",&n)){
    for(int i=0; i<10; i++)
      if(n>>i&1)
	printf("%d ",1<<i);
    printf("\n");
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        int weight=512,weights=1,flags=0;
        bool flag[15]={0};
        for(int i=1;i<11;i++){
            if(n-weight>=0){
                flag[i]=1;
                n-=weight;
            }
            weight/=2;
        }
        for(int i=10;i>0;i--){
            if(flag[i]==1&&flags==1){
                cout<<" ";
                flags=0;
            }
            if(flag[i]==1){
                flags=1;
                cout<<weights;
            }
            weights*=2;
        }
        cout<<endl;
    }
    return 0;
}

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

int main() {
    int weight;
    while (cin >> weight) {
        for (int i = 0; weight > 0; weight /= 2, i++) {
            if (weight % 2 == 1) {
                if (i > 0) {
                    cout << " ";
                }
                cout << pow(2, i);
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    int n;
    while(cin >> n) {
        vector<int> v;
        while(n != 0) {
            v.pb(n % 2);
            n /= 2;
        }
        //reverse(v.begin(), v.end());
        int j;
        rep(i,0,v.size()) {
            if(v[i] * pow(2,i) != 0) {
                j = i;
                cout << v[i] * pow(2,i);
                break;
            }
        }
        if(j != v.size()-1)
            rep(i,j+1,v.size()) (v[i] * pow(2,i) == 0) ? : cout << " " << v[i] * pow(2,i);
        cout << endl;
    }

    return 0;
}

C++: //0031
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl;
#define CIN(x) cin>>(x);

const int weight[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

int main(){

	int w;
	while (1){
		vector <int> v;
		CIN(w)
		int p = 0;
		for (int i = 9; i >= 0; i--){
			if (w >= weight[i]) {
				v[p] = weight[i];
				p++;
				w -= weight[i];
			}
		}

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

	return 0;

}

C++: #include <iostream>
#include <string>
using namespace std;
int main( void )
{
  int n;
  while( 1 ){
    string s="";
    cin>>n;
    if( cin.eof() ) break;
    for( int i=0; i<10; i++ ){
      if( n & (1<<i) ){ cout << s << (1<<i); s = " "; }
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
	int w;

	while (cin >> w){
		for (int i = 1; i <= 512; i *= 2){
			if (w % (i * 2) != 0){
				cout << i;
				w -= i;
				if (w != 0){
					cout << " ";
				}
			}
			if (w == 0){
				cout << endl;
				break;
			}
		}
	}

	return (0);
}

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

int main()
{
	int m;
	while(cin >> m)
	{
		int w=1;
		while(m)
		{
			if(m&1) cout << w << " ";
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

C++: #include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

vector< bool > w( 9, 0 );

///2進法のｎ桁目を考える。
//（ pow( 2, n ) <= input ）→ n + 1 digit == 1 (n:整数)

int main()
{
    int weight;
    while( scanf( "%d\n", &weight ) != EOF )
    {
        for( int i = 8; i >= 0; i-- )
        {
            if( pow( 2, i ) <= weight )
            {
                weight %= ( int ) pow( 2, i );
                w[i] = 1;
            }
        }
        for( int i = 0; i < 9; i++ )
        {
            if( w[i] )
            {
                printf( "%.0lf ", pow( 2 , i ) );
            }
        }
        printf( "\n" );
    }
    return 0;
}

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

int main() {
	int g,idx;
	int num[]={1,2,4,8,16,32,64,128,256,512};
	stack<int> ans;
	while(cin>>g){
		for(int i=9;i>=0;i--){
			if(g>=num[i]){
				g-=num[i];
				ans.push(num[i]);
			}
		}while(!ans.empty()){
			cout << ans.top() << " ";
			ans.pop();
		}cout<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
	int n;
	while(cin >>n,!cin.eof()){
		int i=1;
		if(i&n)
			cout << i;
		i <<=1;
		while(i<=n){
			if(i&n)
				cout << ' ' << i ;
 			i <<=1;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	const int MASK = 0x10000000;
	unsigned n, i;
	while(scanf("%u", &n) == 1)
	{
		for(i = 1; i < 0x400; i<<=1)
		{
			if(n&i)
			{
				if(n&MASK)
					printf(" %d", i);
				else
					printf("%d", i), n|=MASK;
			}
		}
		putchar('\n');
	}
	return 0;
}

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

int main(){
	int n, g;
	while(scanf("%d\n", &g) != EOF){
		n = 1;
		while(g > 0){
			if(g % (n * 2) > 0){
				printf("%d", n);
				g -= n;
				printf("%c", (g > 1)? ' ' : '\n');
			}
			n *= 2;
		}
	}
}