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>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) {
      cout << 0 << endl;
      continue;
    }
    vector<int> ans;
    if (n % 2 == 1) {
      n -= 1;
      ans.push_back(1);
    }
    int t = 2;
    while (n) {
      if ((int)log2(n) == log2(n)) {
        ans.push_back(n);
        break;
      }
      n -= t;
      ans.push_back(t);
      t *= 2;
    }
    REP(i, ans.size()) {
      cout << ans[i] << SPACE;
    }
    cout << endl;
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

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

int main() {
	int weight;

	while (cin >> weight) {
		vector<int> list;
		
		for (int i = 0; i < 10; i++) {
			int candidate = pow(2, 9 - i);

			if (weight >= candidate) {
				list.push_back(candidate);
				weight -= candidate;
			}
		}

		int max = list.size();

		for (int j = 0;j < max; j++) {
			if (j != 0)cout << " ";
			cout << list.at(max - j);
		}
		cout << endl;
	}
	
	return 0;
}

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

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) {
      cout << 0 << endl;
      continue;
    }
    vector<int> ans;
    if (n % 2 == 1) {
      n -= 1;
      ans.push_back(1);
    }
    int t = 2;
    while (n) {
      if (numofbits(n) == 1) {
        ans.push_back(n);
        break;
      }
      n -= t;
      ans.push_back(t);
      t *= 2;
    }
    REP(i, ans.size() - 1) {
      cout << ans[i] << SPACE;
    }
    cout << ans[ans.size() - 1] << endl;
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

C++: while g=gets
    g=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>
using namespace std;
int main()
{
	int n;
	int A[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
	while (cin >> n){
		int i = 0, k;
		while (n != 0){
			k = n;
			n = n / 2;
			if (1 == k % 2){
				cout << A[i];
				if (n != 0)
					cout << " ";
			}
			++i;
		}
		cout << "\n";
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in(){int x;cin>>x;return x;}
string s[10]={"1","2","4","8","16","32","64","128","256","512"};
int ss[10]={1,2,4,8,16,32,64,128,256,512};
string ans[1200];

void sss(string z,int y,int l)
{
	if(l==10)return ;
	ans[y]=z;
	sss(z,y,l+1);
	z+=" ";
	z+=s[l];
	y+=ss[l];
	sss(z,y,l+1);
	return ;

}


int main ()
{
	int a;
	sss("",0,0);	
	while(scanf("%d",&a)!=EOF)
	{
		cout<<ans[a]<<endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int now[10]={0};
	int max=0;
	while(cin>>n){
		for(int i=512;i>=1;i/=2){
			if(n>=i){n-=i;now[max]=i;max++;}
		}
		while(max>=1){
			cout<<now[max-1]<<" ";
			max--;
		}
	}
}

C++: #include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int weight[10] = {1,2,4,8,16,32,64,128,256,512};
	int count[10];
	int n;


	while(cin >> n){
		bool one = 0;
		memset(count,0,sizeof(count));

		while(n != 0){
			int u = 9;
			while(n < weight[u])u--;
			n -= weight[u];
			count[u]++;
		}

		for(int i=0;i<10;i++){
			if(count[i] != 0){
				if(one)printf(" ");
				printf("%d",weight[i]);
				one = 1;
			}
		}
		printf("\n");
	}

}

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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int pow(int number, int count) {
	if (count == 0 )
		return 1;
	return number * pow(number, count - 1);
}

int main(int argc, char *argv[]) {
	const int WeightNumber = 10;
	int weight[WeightNumber];
	// Make Weight
	for (int i = 0; i < 10; i++) {
		weight[i] = pow(2, i);
	}
	// Load
	int rcv;
	while (EOF != fscanf(stdin, "%d", &rcv)) {
		vector<int> answer;
		// Find Heaviest Weight
		int max_weight_ar_number;
		for (int i = 0; i < WeightNumber; i++) {
			if (weight[i] > rcv) {
				max_weight_ar_number = i;
				break;
			}
		}
		// Get Weight
		for (int i = max_weight_ar_number; i >= 0; i--) {
			if (rcv >= weight[i]) {
				rcv -= weight[i];
				answer.push_back(weight[i]);
			}
			if (rcv == 0) {
				break;
			}
		}
		// Print Result
		sort(answer.begin(), answer.end());
		const int loop_max = static_cast<int>(answer.size());
		for (int i = 0; i < loop_max ; i++) {
			if (i == loop_max - 1)
				printf("%d\n", answer[i]);
			else
				printf("%d ", answer[i]);
		}
	}
	
	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=0;
		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;
		}
		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;
		}
	}
	}