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>
#include <string>

using namespace std;

int str[10];

void getBinStr(int target) {
  int nowMod;
  int nowDiv = target;
  int i;

  for(i = 0; i < 10 && nowDiv != 0; i++) {
    nowMod = nowDiv % 2;
    nowDiv /= 2;
    str[i] = nowMod;
  }
  for(int j = i; j < 10; j++) {
    str[j] = 0;
  }
}


int main(void) {
  int target;
  const static int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  while(cin >> target) {
    getBinStr(target);
    bool isFirst = true;
    for(int i = 0; i < 10; i++) {
      if(str[i] == 1) {
        if(isFirst) {
          cout << weight[i];
          isFirst = false;
        }
        else {
          cout << " " << weight[i];
        }
      }
    }
    cout << endl;
  }
  return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(){
	int two[15]={},n,cnt=-1,check[15]={},last=0;
	for(int i=0;i<11;i++){
		two[i]=1;
		for(int j=0;j<i;j++)two[i]*=2;
	}
	while(cin>>n){
		cnt=-1;
		last=0;
		for(int i=0;i<10;i++){
			check[i]=0;
			if(n<two[i+1]){
				cnt=i;
				break;
			}
		}
		for(int i=cnt;i>=0;i--){
			if(n%2==1)check[i]++;
			n/=2;
			//cout<<check[i]<<" "<<n<<endl;
		}
		for(int i=0;i<10;i++)if(check[i]==1)last=i;
		for(int i=0;i<10;i++){
			if(check[i]==1&&last!=i)cout<<two[i]<<" ";	
			else if(i==last)cout<<two[i]<<endl;
		}
	}
	}

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;
  }
}