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>
#include <vector>

using namespace std;

int main(){
  int n;
  while(cin >> n){
    vector<int> ar;
    for(int i = 1024 ; i>=1; i /=2){
      if(n >= i){
	cout << i<<" ";
	n-=i; 
      }
    }
  }
  return 0;
}

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

int main(){
  int n;
  while(cin>>n){
    for(int i=0;i<10 && (1<<i) <= n;i++){
      if(( (1<<i) & n )>>i == 0x1)
	cout<<(1<<i)<<" ";
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<vector>
using namespace std;
int main(){
    int n;
    while(~scanf("%d",&n)){
        vector<int> ar;
        for(int i=512;i>=1;i/=2){
            if(n>=i){
                ar.push_back(i);
                n-=i;
            }
        }
        for(int i=ar.size()-1;i>=0;i--){
            printf("%d ",ar[i]);
        }
        printf("\n");
    }
}

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

int main()
{
	int n, count = 0, sum = 1;
	static int ans[100][9] = { 0 };
	int data[100] = { 0 }, ansdata[100] = {0};
	for (int a = 0; a <= 10; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		int data2, count2 = 0;
		for (int a = 0; a <= 10; a++) {
			if (n < data[a + 1]) {
				sum = data[a];
				data2 = a;
				ans[count][count2] = a;
				count2++;
				break;
			}
		}
		for (int a = data2-1; a > 0; a--) {
			sum = sum + data[a];
			if (sum > n) {
				sum = sum - data[a];
			}
			else {
				ans[count][count2] = a;
				count2++;
			}
			if (sum == n) {
				break;
			}
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a < count; a++) {
		for (int b = ansdata[a]-1; b>=0; b--) {
			cout << data[ans[a][b]]<< " ";
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;


bool solve(){
	int n;
	while(cin>>n){
		vector<int> a;
		int k = 0;
		int end_num;
		while(n){
			if(n%2) end_num = k;
			a.push_back(n%2);
			n /= 2;
			k++;
		}
		int num = 1;
		for(int i=0;i<k;i++){
			if(a[i]){
				cout<< num;
				if(i != k-1) cout<< " ";
			}
			num *= 2;
		}
		cout<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,d[10]={512,256,128,64,32,16,8,4,2,1};
	int a[10],c;
	while(cin>>n){
		for(int i=0;i<10;i++){
			a[i]=0;
			while(d[i]<=n){n-=d[i];a[i]=++c;}
		}
		
		for(int i=9;i>=0;i--){
			if(a[i]>1)cout<<d[i]<<" ";
			if(a[i]==1)cout<<d[i];
		}
		cout<<endl;
	}

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int sg;
int bn[] = {1,2,4,8,16,32,64,128,256,512};

	while(cin >>  sg){
		bool ck[10] ={false};
		rep(i,10){
			if(sg >= bn[9-i]){
				sg -= bn[9-i];
				ck[9-i] = true;
			}
		}
		int cnt=0;
		bool dsw=false;
		rep(i,10)
			if(ck[i]){
				cout << (dsw ? " ":"") << bn[i] ;
				dsw=true;
			}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int n;
	while(cin >> n){ 
		int weight[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		for(int i = 9; i >= 0; i--){
			if(n >= pow(2, i)){
				n -= pow(2, i);
				weight[i] = 1;
			}
		}

		int i;
		for(i = 0; i < 10; i++){
			if(weight[i]){
				cout << pow(2, i);
			}
		}
		for(; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

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

	while (cin >> N) {
		vector<int> ans;
		rep(i,10) {
			if (N >= num[i]) {
				ans.push_back(num[i]);
				N = N - num[i];
			}
		}
		reverse(all(ans));
		rep(i,ans.size()) {
			if (i == ans.size()-1) {
				cout << ans[i];
			}
			else {
				cout << ans[i] << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int g;
    while (scanf("%d", &g) != EOF) {
        int f = 0;
        rep (i, 10) if (g&(1<<i)) {
            if (f) printf(" ");
            f = 1;
            printf("%d", 1<<i);
        }
        printf("\n");
    }
    return 0;
}

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

int main()
{
    int n;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] <<" ";
			}
		}
		cout << endl;
	}
	
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
 
int main()
{
    int n;
    while(1){
	cin>>n;
	if(cin.eof()) break;
	vector <int> a;
	while(n>1){
		a.push_back(n%2);
		n=n/2;
	}
	a.push_back(n);
	for(int i=0;i<a.size();i++){
		if(a[i]*pow(2,i)==0) continue;
		cout<<a[i]*pow(2,i)<<" ";
	}
	cout<<endl;
    }
    return 0;
}

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

int main(void){
  int x;

  while(cin>>x){
    bool firstFlg = true;
    int pow = 1;

    while(x != 0){
      if(x % 2 == 1){
        if(firstFlg) firstFlg = false;
        else cout<<" ";
        cout<<pow;
      }

      x /= 2;
      pow *= 2;
    }

    cout<<endl;
  }

  return 0;
}

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

int main(){
int n;
while(cin>>n)
{
	if(n%2==1){
		cout<<"1 ";
		n-=1;
		}
		
	if(n%4==2){
		cout<<"2 ";
		n-=2;
		}	
		
	if(n%8==4){
		cout<<"4 ";
		n-=4;
		}	
		
	if(n%16==8){
		cout<<"8 ";
		n-=8;
		}	
		
	if(n%32==16){
		cout<<"16 ";
		n-=16;
		}	
		
	if(n%64==32){
		cout<<"32 ";
		n-=32;
		}	
		
	if(n%128==64){
		cout<<"64 ";
		n-=64;
		}	
		
	if(n%256==128){
		cout<<"128 ";
		n-=128;
		}	
		
	if(n%512==256){
		cout<<"256 ";
		n-=256;
		}	
		
	if(n%1024==512){
		cout<<"512 ";
		n-=512;
		}	
		cout<<'\n';
	}
	return 0;
		}

C++: #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to) 
int main() {
	int n;
	while(cin >> n) {
		vector<int> v;
		rep(i,10) {
			if(1<<i & n) v.push_back(1<<i);
		}
		cout << v[0];
		rep2(i,1,v.size()) {
			cout << " " << v[i];
		}
		cout << endl;
	}
	return 0;
}