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>

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

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int n;

int main(){
	while(cin >> n){
		for(int i = 0; i <= 9; i++){
			if(n & (1 << i)){
				int scale = 1;
				for(int j = 0; j < i; j++){
					scale *= 2;
				}
				cout << scale << " ";
			}
		}
		cout << '\b' << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int w;
	while(scanf("%d", &w) != EOF){
		rep(i, 10){
			if(w&1){
				printf("%d", 1<<i);
				w >>= 1;
				if(w) printf(" ");
			}else
				w>>=1;
		}
		puts("");
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){

    int ans[1000];
    int p = 0;

    int m = n;
    for(int i = 2 ; i < m ; i*=2){
      if(i*2 > m)m = i;
    }

    for(int i = m ;i > 1; i/=2 ){
      if(n - i > 0 ){
	ans[p++] = i;
	n -= i;
      }
    }
  cout << 1;
  for(int i = p - 1 ; i >= 0 ; i-- ){
    cout << " " << ans[i];
  }
  cout << endl;

  }
  }

C++: #include <iostream>
#include <string.h>

using namespace std;
int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
void solve()
{
	int a;
	while(cin >> a)
	{
		bool flag[10];
		memset(flag, 0, sizeof(bool)  * 10);
		for(int i = 9; i >= 0; --i)
		{
			if(a / weight[i])
			{
				flag[i] = true;
			}
			a %= weight[i];
		}
		for(int i = 0; i < 9; ++i)
		{
			if(flag[i])
			{
				cout << weight[i] << " ";
			}
		}
		if(flag[9])
		{
			cout << weight[9];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}