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>

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

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

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int i,in;
  char to[12];
  int w[10] = {1,2,4,8,16,32,64,128,256,512};

  while(cin >> in){
  vector<int> ans;
    for(i=0;in;i++){ to[i] = in%2; in /= 2;}
    rep(i,12) if(to[i] == 1) ans.push_back(w[i]);
    reverse(ans.begin(),ans.end());
    for(i = ans.size()-1; i >= 0; i--){
      cout << ans[i];
      (i == 0) ? cout << endl : cout << " ";
    }
  }


  return 0;
}

C++: 
#include <iostream>

using namespace std;

int main() {
    int N;
    while(cin >> N) {
        bool first = true;
        for(int i = 1; i <= N; i <<= 1) {
            if(N & i) {
                if(!first) cout << ' ';
                cout << i;
                first = false;
            }
        }
        cout << endl;
    }
    return 0;
}