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++: //AOJ 0031

#include<stdio.h>
#include<iostream>
#include<vector>

using namespace std;

int main(){

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



	vector<int> input;

	int num;

	while(cin>>num){

		for(int j=0;j<10;j++){

			if(num%2==1){
				printf("%d ",data[j]);
			}
			num/=2;
		}

		printf("\n");
	}

	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    while(cin>>x){
        bool first=true;
        for(int w=1; w<1024; w<<=1){
            if(w&x){
                if(!first) cout<<' ';
                else first=false;
                cout<<w;
            }
        }
        cout<<'\n';
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int weights[10] = { 1,2,4,8,16,32,64,128,256,512 };
bool have[10] = { false,false,false,false,false,false,false,false,false,false };
int main() {
	int w;
	while (cin >> w) {
		int now = 0;
		int tmp = 0;
		for (int i = 0; i < 10; i++)have[i] = false;
		while (tmp < w) {
			tmp += weights[now];
			have[now] = true;
			now++;
		}
		while (tmp != w) {

			if (have[now]) {
				if (tmp - weights[now] >= w) {
					tmp -= weights[now];
					have[now] = false;
					now--;
				}
				else now--;
			}
			else {
				now--;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (have[i]) {
				if (i != 10)cout << weights[i] << ' ';
				else cout << weights[i];
			}
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#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 INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

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

int main() {

	int n, cnt = 0;

	while (cin >> n && n!= EOF) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			if (judge[i] == true) {
				if (cnt != 0)cout << " ";
				cnt++;
				cout << V[i];
				
			}
			judge[i] = false;
		}
		cnt = 0;
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

const int w[10]={1,2,4,8,16,32,64,128,256,512};
int c[10];
int main(void){
	int n;
	int a;
	while(~scanf("%d",&n)){
		bool b=false;
		for(a=0;a<=9;a++)c[a]=0;
		for(a=9;a>=0;a--){
			if(n>=w[a])c[a]=1,n-=w[a];
			if(n==0)break;
		}
		for(a=0;a<=9;a++){
			if(c[a]==1){
				if(b==true)cout << " " << w[a];
				if(b==false){
					cout << w[a];
					b=true;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000
int main(){
int w;
bool ans[10];
for(int i=0;i<11;i++){
ans[i]=0;
}
while(cin>>w){
for(int i=0;i<11;i++){
ans[i]=0;
}
for(int i=10;i--;){
if(w>=pow(2,i)){
ans[i]=1;
w=w-pow(2,i);
}
}
int i=0;
for(;i<11;i++){
if(ans[i]){
cout<<pow(2,i);
break;
}
}i++;
for(;i<11;i++){
if(ans[i]){
cout<<" "<<pow(2,i);
}
}cout<<endl;
}
return 0;
}

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

int main() {

  int n;

  while( cin >> n ) {

    bool flag = false;

    for ( int i = 1; i <= 512; i*=2 ) {

      if ( n % (i*2) != 0 ) {
	if ( flag ) cout << " ";
	flag = true;
	cout << i;
	n -= i;
      }

    }

    cout << endl;

  }

  return 0;

}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int n;

void solve() {
    int a=1;
    bool f=false;
    rep(i,10) {
        if((n>>i)&1) {
            if(f) cout<<" "<<a;
            else {
                cout<<a;
                f=true;
            }

        }
        a<<=1;
    }
    cout<<endl;

}
int main() {
    while(cin>>n) {
        solve();
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> ans;
  int n, flag;
  while(cin >> n){
    ans.clear();
    flag=0;
    if(n > 1023) return 0;
    for(int i=512; i >= 1; i /= 2){
      if(n - i >= 0){
	n -= i;
	ans.push_back(i);
      }
    }
    sort(ans.begin(), ans.end());
    vector<int>::iterator it = ans.begin();
    while( it != ans.end() ){
      if(flag == 0) {
	cout << *it;
	flag = 1;
      }
      else
	cout << " " << *it;
      ++it;
    }
    cout << endl;
    
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(i!=(s.size()-1))std::cout<<" ";} num/=10;}
    std::cout<<std::endl;
    }
    return 0;
}

C++: #include <stdio.h>

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

int get_ans(int a, int rem)
{
	int i = a-1;

	while(rem >= weights[i] || i >= 0){
		if(rem > weights[i]) break;
		else if(rem == weights[i]) return weights[i];

		i--;
	}

	printf("%d ", get_ans(i, rem - weights[i]));

	return weights[i];
}

int main()
{
	int G, A;

	while(scanf("%d", &G) != EOF){
		printf("%d ", get_ans(10, G));
		printf("\n");
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#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 INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

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

int main() {

	int n;

	while (cin >> n, n) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			if (i != 0 && judge[i] == true)cout << " " << V[i];
			if (i == 0 && judge[i] == true)cout << V[i];
			judge[i] = false;
		}
		cout << endl;
	}

	return 0;
}