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 <stack>
using namespace std;

int main(){
  int w[]={512,256,128,64,32,16,8,4,2,1};
  int n;
  while(cin>>n){
    stack<int> a;
    for(int i=0;i<10;i++){
      if(n>=w[i]){
	a.push(w[i]);
	n-=w[i];
      }
    }
    cout<<a.top();
    a.pop();
    while(!a.empty()){
      cout<<' '<<a.top();
      a.pop();
    }
    cout<<endl;
  }
  return 0;
}

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

int main(void){
	int n;
	while(cin>>n){
		int m[10]={0};
		int i=0;
		for(int max = 1024;max /= 2;max<1){
			if(n>=max){
//				cout<<max<<" "<<n<<endl;
				n=n-max;
				m[i++]=max;
//				cout<<max<<endl;
			}
		}
		
		sort(m,m+10);
		for(i=0;i<10;i++)
			if(m[i]!=0){
				cout<<m[i];
				break;
			}
		for(int j=i+1;j<10;j++)
			if(m[j]!=0)cout<<" "<<m[j];
		cout<<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int x;
    while(cin>>x){
        for(int i=0; i<=1023; i++){
            int bit =i;
            int sum =0;
            for(int j=0; j<10; j++){
                if(bit%2==1){
                    sum+=weight[j];
                }
                bit=bit/2;
            }
            
            if(sum == x){
                int flag = 0;
                for(int j=0; j<10; j++){
                    if(i%2==1&&flag==0){
                        cout<<weight[j];
                        flag++;
                    }else if(i%2==1){
                        cout<<" "<<weight[j];
                    }
                    i=i/2;
                }
                cout<<endl;
                break;
            }
            
            
            
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
int main(){
	int w;
	int weight[10]={1,2,4,8,16,32,64,128,256,512};
	std::vector<bool> vec(10,0);
	while(1){
		int a=0;
		std::cin>>w;
		if(std::cin.eof())break;
		//if(w==0)break;
		while(w>0){
			vec[a]=w%2;
			w/=2;
			a++;
		}
		for(int i=0;i<10;i++){
			if(vec[i]!=0)std::cout<<weight[i]<<" ";
		}
		std::cout<<std::endl;
	}
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    vector<int> v;
    for (int i = 0; i < 10; i++) {
      if (1 << i & n) {
        v.push_back(1 << i);
      }
    }
    cout << v[0];
    for (size_t i = 1; i < v.size(); i++) {
      cout << " " << v[i];
    }
    cout << "\n";
  }
}

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

int main(){

  int weight;
  int n;

  while(cin>>weight){
    vector<int> result;
    while(1){
      if(weight == 0 || weight == 1 || weight ==2 || weight ==4 || weight ==8 || weight ==16 || weight ==32 || weight ==64 || weight ==128 || weight ==256 || weight ==512){
	result.push_back(weight);
	break;
      }
      if(weight<4)
	n=2;
      else if(weight<8)
	n=4;
      else if(weight<16)
	n=8;
      else if(weight<32)
	n=16;
      else if(weight<64)
	n=32;
      else if(weight<128)
	n=64;
      else if(weight<256)
	n=128;
      else if(weight<512)
	n=256;
      else
	n=512;
      
      result.push_back(n);
      weight-=n;
    }

    sort(result.begin(),result.end());

    int flag=0;
    for(auto i:result){
      if(flag==1)
	cout<<" ";
      else flag=1;
      cout<<i;
    }
    
    cout<<endl;
    result.clear();
  }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  int square[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  vector<int> num;

  while(cin >> n){
    if(n == 0) break;

    for(int i = 9; i >= 0; i--){
      if(n >= square[i]){
        num.push_back(i);
        n -= square[i];
      }
    }

    for(int i = num.size() - 1; i >= 0; i--){
      cout << square[ num[i] ];
      if(i = 0) cout << endl;
      else      cout << " ";
    }    
    num.clear();
  }
}

C++: #include <iostream>
#include <limits>
#include <cmath>

using namespace std;

int main() {

	int v;
	while (cin >> v) {
		int sum = 0;
		for(unsigned i = 0; i < 10; ++i) {
			if ((v>>i)&1) {
				sum += pow(2,i);
				cout << pow(2,i);
				if (sum != v) cout << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	while(~scanf("%d",&n)){
		bool f = false;
		for(int i=0; (1<<i)<=n; i++)if( n&(1<<i) ){
			if( f )putchar(' ');
			printf("%d",1<<i);
			f = true;
		}
		puts("");
	}
	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};
	
		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		for(int i=0; i<9 ; i++){
			if(flag[i]!=0){
				cout << w[i] <<" ";
			}
		}
		if(flag[9]!=0){
			cout << w[9];
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
    for (int w; cin >> w;) {
        bool first = true; // flag for output
        for (int x = 1; w; x <<= 1) {
            int result = w & x;
            if (result) {
                if (first) {
                    first = false;
                    cout << result;
                } else
                    cout << " " << result;
                w -= x;
            }
        }
        cout << endl;
    }

    return 0;
}