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>
#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!= EOF) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			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>

using namespace std;

int main() {
    int M,scale[10];
    scale[0]=1;
    for(int i=1;i<10;i++){
    scale[i] = scale[i-1]*2;
    }
    while(cin >> M){
    int i=0;
    int count=2;
    while(true){
        if(M==0) break;
        if(M % count!=0){
            M -= scale[i];
            if(M != 0){
            cout << scale[i] << " ";
            }
            else{
            cout << scale[i] <<endl;
            }
        }
        i++;
        count *= 2;
    }
    }
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(i!=(s.size()-1))std::cout<<" ";} num/=10;}
    std::cout<<std::endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
typedef vector<int> vi;

const int w[] = {9,8,7,6,5,4,3,2,1,0};

int main() {
	int in;
	while (cin>>in) {
		vi used;
		REP(i,10) {
			int weight = pow(2,w[i]);
			if (weight<=in) {
				in -= weight;
				used.push_back(weight);
			}
		}
		sort(used.begin(),used.end());
		REP(i,used.size()) {
			if(i!=0) cout<<" ";
			cout<<used[i];
		}
		cout<<endl;
	}
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int ans[101][10];

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int m;
	int flug = 0;
	while(scanf("%d",&m) != EOF){
		flug = 0;
		for(int j = 0; j < 10; j++){
			

			if((m / pow(2,j)) % 2 == 1){
				if(flug){
				printf(" ");
			}
				printf("%d",pow(2,j));
				flug = 1;
			}
		}
		printf("\n");
	}
	
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	for (int n; cin >> n; ) {
		for (int i = 0; (n >> i); i++) if ((n >> i) & 1) cout << (1 << i) << ((n >> (i + 1)) ? ' ' : '\n');
	}
	
	return 0;
}

C++: #include <stdio.h>
int main(){
int n,temp;
while(scanf("%d",&n)!=EOF){
temp=1;
while(temp<=n)temp*=2;
temp/=2;
printf("%d",temp);
n-=temp;
while(n>0){
while(temp>n)temp/=2;
n-=temp;
printf(" %d",temp);
}
printf("\n");
}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

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 printf(" ");
	printf("%d",i);
      }
      i <<= 1;
    }
    puts("");
  }
  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 <iostream>
#include <math.h>
using namespace std;

int main() {
	short int n;
	while (cin >> n) {
		for(int i=1; n>0; i*=2,n/=2){
			if (n % 2 == 1) {
				cout << i<<" ";
				//if (n > 1)
					//cout << " ";
			}
		}
		cout << "\b" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[51];
signed main() {
    int n;
    while (cin >> n) {
        int a = 0;
        if (n >= 512) { test[a] = 512; a++; n -= 512; }
        if (n >= 256) { test[a] = 256; a++; n -= 256; }
        if (n >= 128) { test[a] = 128; a++; n -= 128; }
        if (n >= 64) { test[a] = 64; a++; n -= 64; }
        if (n >= 32) { test[a] = 32; a++; n -= 32; }
        if (n >= 16) { test[a] = 16; a++; n -= 16; }
        if (n >= 8) { test[a] = 8; a++; n -= 8; }
        if (n >= 4) { test[a] = 4; a++; n -= 4; }
        if (n >= 2) { test[a] = 2; a++; n -= 2; }
        if (n >= 1) { test[a] = 1; a++; n -= 1; }
        sort(test, test + a);
        for (int h = 0; h < a; h++) {
            if (h != a - 1)cout << test[h] << ' ';
            else cout << test[h];
        }
        cout << endl;
    }
}