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 <iostream>
using namespace std;

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

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) {
		for (int i = 9; i >= 0; i--) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		for (int i = 0; i < 10; i++) {
			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;
}

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

int input,i;


int main(){
	while(cin>>input){
		string ans("");
		while(1){
			if(input%2==0) ans.insert(ans.begin(),'0');
			else ans.insert(ans.begin(),'1');
			input/=2;
			if(input==0) break;
		}
		if(ans[ans.length()-1]=='1'){
			cout<<"1"<<" ";
		}
		ans.pop_back();
		i=2;
		while(1){
			if(ans.empty()==1) break;
			if(ans[ans.length()-1]=='1'){
				cout<<(int)pow(2.0,i)/2<<" ";
			}
			ans.pop_back();
			i++;
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>

int main(){
	int a,b,c=1;
	int d[10];
	
	
	while(std::cin>>a){
		for(b=1;b<=10;b++){
		d[b]=0;
	}
		
		for(b=0;b<2;b++){
			if(a==b){
				d[1]=b;
			}else{
				for(c=0;c<3;c=c+2){
					if(a==b+c){
						d[1]=b;
						d[2]=c;
						
						
					}else{
						for(int e=0;e<5;e=e+4){
			if(a==b+c+e){
				d[1]=b;
				d[2]=c;
						d[3]=e;
					
			}else{
				for(int f=0;f<9;f=f+8){
					if(a==b+c+e+f){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						
					}else{
						for(int g=0;g<17;g=g+16){
			if(a==b+c+e+f+g){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						
			}else{
				for(int h=0;h<33;h=h+32){
					if(a==b+c+e+f+g+h){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						
					
					}else{
						for(int i=0;i<65;i=i+64){
			if(a==b+c+e+f+g+h+i){
				d[1]=b;d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						
			}else{
				for(int j=0;j<129;j=j+128){
					if(a==b+c+e+f+g+h+i+j){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						
					}else{
						for(int k=0;k<257;k=k+256){
			if(a==b+c+e+f+g+h+i+j+k){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						
			}else{
				for(int l=0;l<513;l=l+512){
					if(a==b+c+e+f+g+h+i+j+k+l){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						d[10]=l;
					}else{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		for(int m=1;m<11;m++){
		if(d[m]!=0){
			std::cout<<d[m]<<" ";
		}
	}
	std::cout<<std::endl;
	}
	return 0;
}

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

int main(){
	int n,a[10],b[10],k;
	a[0]=1;
	for(int i=1;i<10;i++){
		a[i]=2*a[i-1];
	}
	
	while(cin >> n){
		for(int i=0;i<10;i++){
			b[i]=0;
		}
		for(int i=9;n!=0;i--){
			if(n>=a[i]){
				n-=a[i];
				b[i]=a[i];
			}
		}
		k=0;
		for(int i=0;i<10;i++){
			
			if(b[i]!=0){
				if(k!=0){
					cout <<" ";
				}
				cout << b[i] ;
				k++;
			}
		}
		cout << "\n" ;
	}
		
		
		
return 0;
}

C++: #include <iostream>

using namespace std;
 
int main(){
  int n;
  while(cin >> n){
    int i = 1;
    bool f = true;
    while(i != 1024){
      if((n&i) != 0){
	if(f) f = false;
	else cout << " ";
	cout << i;
      }
      i <<= 1;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int weight[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
	int n;
	while( cin >> n, n ){
		int j = 0;
		int ans[10];
		for( int i = 9; i >= 0; i-- ){
			if( n == 0 ) break;
			if( n >= weight[i] ){
				n -= weight[i];
				ans[j++] = weight[i];
			}
		}
		for( int i = j - 1; i >= 0; i-- ){
			cout << ans[i] << ' ';
		}
		cout << endl;
	}
}

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

int main() {
  int x10=0;
  int x2=0;
  int k=0;
  int ans[10] = {0};

  while(cin >> x10) {
    k=0;
    int ans[10] = {0};
    for(int i=0;i<10;i++) {
      x2 = x10 % (int)(pow(2,i+1));
      if(x2 != 0){
        ans[k] = (int)pow(2,i);
        k++;
        x10 -= x2;
      }
    }
    for(int i=0;i<k-1;i++) {
      cout << ans[i] << " ";
    }
    cout << ans[k-1] << endl;
    }
  }

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 1000000;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

typedef long long ll;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/




int main()
{
	int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int n;
	set<int> weights;
	
	
	while (cin >> n)
	{
		for (int i=9; i>=0; i--)
		{
			if (n >= weight[i])
			{
				weights.insert(weight[i]);
				n -= weight[i];
			}
		}
		bool first_flag = true;
		set<int>::iterator it = weights.begin();
		while (it != weights.end())
		{
			if (first_flag)
			{
				cout << *it;
				first_flag = false;
			} else {
				cout << " " << *it;
			}
			it++;
		}
		cout << endl;
		weights.clear();
	}
	
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N;
	while (cin >> N) {
		vector<int>anss;
		for (int i = 0; i < 100; ++i) {
			if (N % 2) {
				anss.push_back(1<<i);
			}
			N /= 2;
		}
		for (int i = 0; i < anss.size(); ++i) {
			cout << anss[i];
			if (i == anss.size() - 1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

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

using namespace std;
 
int main(){
	int w[]={1,2,4,8,16,32,64,128,256,512};
	int n;

	while(scanf("%d",&n)!=EOF){
		int a[10]={0};
		int i=10, j=0;

		while(0<n&&0<=i){
			if(w[--i]<=n){
				a[i]=1;
				n-=w[i];
				++j;
			}
		}

		for(i=0,--j; i<10&&0<j; ++i,--j)
			if(a[i])	printf("%d ", w[i]);

		for(; i<10; ++i)
			if(a[i])	printf("%d\n", w[i]);
	}

    return 0;
}