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 <bits/stdc++.h>
using namespace std;

int main() {
	for(int n; cin >> n;) {
		vector<int> ans;

		for(int bit = 1; bit <= n; bit <<= 1) {
			if(bit & n) ans.emplace_back(bit);
		}

		for(unsigned i = 0; i < ans.size(); ++i) {
			cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    int w[10];
    w[0]=1;
    for (int i=1;i<10;++i) {
        w[i]=w[i-1]<<1;
    }
    while (scanf("%d",&n)!=EOF) {
        int tmp=0;
        stack<int> st;
        for (int i=9;i>=0;--i) {
            if (w[i]<=n) {
                st.push(w[i]);
                n-=w[i];
                tmp++;
            }
        }
        for (int i=0;i<tmp-1;++i) {
            printf("%d ",st.top());
            st.pop();
        }
        printf("%d\n",st.top());
    }
    return 0;
}

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

int ans[10];
int count=0;
int weight;
int temp[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(){
	while(scanf("%d", &weight) != EOF){
		count = 0;
		for(int i=9; 0 <= i; i--){
			if(temp[i] <= weight){
				weight -= temp[i];
				ans[count] = temp[i];
				count++;
			}
			if(weight == 0) break;
		}
		for(int i=count-1; 0 <= i; i--){
			if(i != 0) cout << ans[i]  << ' ';
			else cout << ans[i] << endl;
		}
	}
}

C++: #include <stdio.h>

int main(void)
{
	int n;
	while (scanf("%d", &n) != EOF){
		int i;
		int flag;

		flag = 0;
		for (i = 0; i < 20; i++){
			if (((n >> i) & 1) != 0){
				if (flag == 0){
					printf("%d", 1 << i);
				}
				else {
					printf(" %d", 1 << i);
				}
				flag = 1;
			}
		}
		puts("");
	}
	return (0);
}

C++: #include<iostream>
using namespace std;
int n;
int main(){
  while(cin>>n){
    for(int i=1;n>0;i*=2){
   
      if(n&1){
	if(i>1)cout<<' ';
	cout<<i;
      }
      n=n>>1;
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
	int n,i;
	stack <int> ans;
	while(cin >> n){
		for (i = 9; i >= 0; i--) {
			if(pow(2.0, i) <= n){
				n -= pow(2.0, i);
				ans.push(pow(2.0, i));
			}
		}

		while(!ans.empty()){
			cout << ans.top();
			ans.pop();
			if(!ans.empty()){
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  int w,we[10]={1,2,4,8,16,32,64,128,256,512},i;
  queue<int> k;
  while(cin>>w){
    while(w!=0){
      k.push(w%2);
      w=w/2;
    }
    i=0;
    while(k.size()){
      if(k.front()==1&&k.size()>=2)cout<<we[i]<<" ";
      else if(k.front()==1)cout<<we[i]<<endl;
      k.pop();
      i++;
    }
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
int n;
int g;
while(cin >>n){
g=1;
while(g<1000){
if(n%(2*g)==g&&n!=0;){cout <<g<<" "; n=n-g;}
else if(n%(2*g)==g&&n==g){cout <<g<<endl; n=n-g;}
g=g*2;}
}
}

C++: #include<iostream>
using namespace std;
int main(){
	int n=0;
	while(cin >>n){
		int x=1;
		for(int i=0; i<10; i++){
			if(n%2 == 1 && i == 0){cout<<x;}
			else if(n%2 == 1 && i != 0){cout<<" "<<x;}
			x*=2;
			n = n/2;
		}
		cout<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.weight", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		stringstream ss (str );
		int w;
		ss >> w;
		vector<int> res; res.clear();
		int weight = 1;
		while (w > 0 ){
			if (w % 2 != 0 ) res.push_back (weight );
			weight *= 2;
			w /= 2;
		} // end while
		rep (i, res.size() ){
			cout << res[i] << (i != res.size() - 1 ? ' ' : '\n' );
		} // end rep

	} // end loop
		
	return 0;
}

C++: #include<stdio.h>
int main(){
int a,x[12],k,i;
while(scanf("%d",&a)!=EOF){
k=0;
if(a>=512){
x[k++]=512;
a-=512;
if(a>=256){
x[k++]=256;
a-=256;
}
if(a>=128){
x[k++]=128;
a-=128;
}
if(a>=64){
x[k++]=64;
a-=64;
}
if(a>=32){
x[k++]=32;
a-=32;
}
if(a>=16){
x[k++]=16;
a-=16;
}
if(a>=8){
x[k++]=8;
a-=8;
}
if(a>=4){
x[k++]=4;
a-=4;
}
if(a>=2){
x[k++]=2;
a-=2;
}
if(a>=1){
x[k++]=1;
a-=1;
}
if(a==0)
for(i=k-1;i>=0;i--)
printf("%d ",x[i]);
printf("\n");
}
return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    while (cin >> n) {
        bool f = false;
        for (int i = 0; i <= 9; ++i) {
            if (n >> i & 1) {
                printf(f ? " %d" : "%d", 1 << i);
                f = true;
            }
        }
        printf("\n");
    }
}

C++: #include <stdio.h>
  int main(){
   int x[10]={1,2,4,8,16,32,64,128,256,512};
   int n,i;
    while(scanf("%d",&n) != EOF){
		int y[10]={};
     for(i=9;i>=0;i--){
		 if(n>=x[i]){  n -= x[i]; y[i]=1;}
       }
      for(i=0;i<10;i++){
         if(y[i]==1) printf("%d ",x[i]);
            }

      printf("\n");
}
return 0;
}

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

bool used[10], ans[10], endR;
int bundo[] = {1, 2, 4, 8, 16, 32, 64, 128, 256};

void init(){ for(int i = 0; i < 10; i++) used[i] = false; endR = false;}

void copyAns(){
  for(int i = 0; i < 10; i++) ans[i] = used[i];
}

void dfs(int i, int w){
  if(w == 0) { copyAns(); endR = true; return; }
  if(i == 10 || w < 0 || endR) return;

  if(!used[i]){
    used[i] = true;
    dfs(i + 1, w - bundo[i]);
  }
  used[i] = false;
  dfs(i + 1, w);
}

int main(void){
  int w;
  while(cin >> w){
    init();
    dfs(0, w);
    for(int i = 0; i < 10; i++){
      if(ans[i]) cout << bundo[i];
      if(ans[i] && i < 9) cout << " ";
    }
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int w;
    while (cin >> w) {
        vector<int> v;
        for (int i = 0; i <= 9; i++) {
            if (w >> i & 1) {
                v.push_back(1<<i);
            }
        }
        for (int i = 0; i < (int)v.size(); i++) {
            if (i > 0) cout << " ";
            cout << v[i];
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  int n;
  int elm[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int use[10];
  int i;

  while(cin>>n){
    for(i=0; i<10; i++) use[i]=0;
    for(i=9; i>=0; i--){
      if(n<elm[i]) continue;
      n-=elm[i]; use[i]=1;
      if(n==0) break;
    }
    if(use[0]==1) printf("1");
    for(i=1; i<9; i++)
      if(use[i]==1) printf(" %d", elm[i]);
    printf("\n");
  }

  return 0;
}