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 <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
int main()
{
	int n;
	while(cin>>n){

		for(int i=0;i<10;i++){
			if(n & (1<<i)) cout<<(1<<i)<<" ";
		}
		cout<<endl;

	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,wei[10],ka=1,temp,ba[10];
  for(int i=0;i<10;i++){
    wei[i]=ka;
    ka*=2;
  }
   while(cin>>n){
     temp=0;
    for(int i=0;i<10;i++){
      ba[i]=0;
    }
    for(int i=9;i>=0;i--){
      if(n!=0){
	if(n-wei[i]>=0){
	  n-=wei[i];
	  ba[i]=wei[i];
	}
      }if(n==0){
	break;
      }
    }
    for(int i=0;i<10;i++){
      if(ba[i]!=0){
	temp++;
      }
    }
    for(int i=0;i<10;i++){
      if(ba[i]!=0){
	cout<<ba[i];
	if(temp>0){
	  cout<<" ";
	}
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  while(cin>>n,n){
    vector<int> x={1,2,4,8,16,32,64,128,256,512};
    vector<int> ans;
    while(n){
      int tmp;
      for(int i=0;i<10;i++){
        if(n>=x[i])tmp=x[i];
      }
      n-=tmp;
      ans.PB(tmp);
    }
    for(int i=ans.size()-1;i>=0;i--){
      cout<<ans[i]<<' ';
    }
    cout<<endl;
  }
  return 0;
}

C++: while gets
    g=$_.chomp.to_i
    h=Array.new
    loop do
        break if(g==0)
        h<<g%2
        g=g/2
    end
    ans=[]
    h.each_with_index{|item,num| ans<<item*2**num if(item*2**num!=0)}
    puts ans.join(" ")
end

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

using namespace std;

int main(){
  int n;
  while(cin >> n){
    vector<int> ar;
    int flg = 0;
    for(int i = 512 ; i>=1; i /=2){
   
      if(n >= i&&flg == 0){
	cout << i;
	flg = 1;
	n-=i; 
	continue;
      }
      if(n >= i&&flg == 1){
	cout << " " << i;
	n-=i; 
      }
    }
  }
  return 0;
}

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());

    for(auto i:result){
      cout<<i;
    }
    
    cout<<endl;
    result.clear();
  }
}

C++: #include <stdio.h>
int main(){
	int a;
	int weight[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(~scanf("%d",&a)){
		bool t[10];
		for(int i=9;i>-1;i--) t[i]=false;
		for(int i=9;i>-1;i--){
			if(weight[i]<=a){
				a-=weight[i];
				t[i]=true;
			}
		}
		int i;
		for(i=0;i<10;i++){
			if(t[i]){
				printf("%d",weight[i]);
				break;
			}
		}
		for(;i<10;i++){
			if(t[i]) printf(" %d",weight[i]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int input;

    while (cin >> input) {
        for (int i = 0; i < 10; i++) {
            if (input & 1) {
                cout << (1 << i);
                if (input >> 1)
                    cout << " ";
            }
            input >>= 1;
        }
        cout << endl;
    }

    return 0;
}

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

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

int main() {
  int d,a;

  while(cin>>d){
    a=1;
    for(;a<=d;a=a<<1) {
      if(a&d) {
	cout<<a;
	if(d/a>2) cout<<" ";
      }
    }
    cout<<endl;

    /*
    a=1;
    for(;d>0;) {
      if(d%2==1) {
	cout<<a;
	d--;
	if(d>0) cout<<" ";
      }
      d/=2;
      a*=2;
    }
    cout<<endl;
    */
  }

}

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

int main() {
	int n;
	while (cin >> n) {
		bool first = true;
		for (int i = 0; i < 10; i++) {
			if (n & (1<<i)) {
				if (first)
					first = false;
				else
					cout << " ";
				cout << (1<<i);
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int tmp[10]={512,256,128,64,32,16,8,4,2,1};
  int in;
  while(cin>>in){
    vector<int>out;
    rep(i,10)if(in>=tmp[i]){in-=tmp[i];out.pb(tmp[i]);}
    sort(all(out));
    rep(i,out.size()-1)cout<<out[i]<<" ";
    cout<<out[out.size()-1]<<endl;
  }
}

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

int main() {
	int n;
	while (cin >> n) {
		int pow[10] = {}, p = 0, rem, quo;
		while (1) {
			rem = n % 2; quo = n / 2;
			if (rem) {
				pow[p]++;
			}
			if (quo == 0) break;
			p++;
			n = quo;
		}
		for (int i = 0, j = 0, r = 1; i < 10; i++, r *= 2) {
			if (pow[i]) {
				if (j) cout << " ";
				cout << r;
				j++;
			}
		}
		cout << endl;
	}
}

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

int main(){
  int w,flag;
  int b[10]={0};

  while(std::cin >> w){
    for(int i=0;i<10;i++){
      b[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(w>=std::pow(2,i)){
        w = w - std::pow(2,i);
        b[i] = 1;
      }
    }
    flag = 1;
    for(int i=0;i<10;i++){
      if(flag){
        std::cout << std::pow(2,i);
        flag = 0;
        continue;
      }
      if(b[i] == 1){
        std::cout << ' ' << std::pow(2,i);
      }
    }
    std::cout << std::endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
      int a,i;
      while(cin>>a){
            for(i=0;i<=9;i++){
                  if(a&(1<<i)){
                        cout<<(1<<i);
                        if(a<(2<<i))break;
                        cout<<' ';
                  }
            }
            cout<<endl;
      }
}

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

int main(){
	int n;
	while(cin >> n){ 
		int weight[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		for(int i = 9; i >= 0; i--){
			if(n >= pow(2, i)){
				n -= pow(2, i);
				weight[i] = 1;
			}
		}

		int i;
		for(i = 0; i < 10; i++){
			if(weight[i]){
				cout << pow(2, i);
				break;
			}
		}
		for(; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
	int n,a[10],c;
	
	while(cin>>n){
		c=0;
		for(int i=0;i<10;i++) a[i]=0;
		for(int i=9;i>=0;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				a[i]++;
			}
		}
		for(int i=0;i<10;i++){
			if(a[i]!=0){
				if(c!=0) cout << " ";
				cout << pow(2,i);
				c++;
			}
		}
		cout << endl;
	}
}