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 <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		vector<int>ans;
		while (N != 0) {
			if (N - 512 >= 0) {
				N -= 512;
				ans.push_back(512);
			} else if (N - 256 >= 0) {
				N -= 256;
				ans.push_back(256);
			} else if (N - 128 >= 0) {
				N -= 128;
				ans.push_back(128);
			} else if (N - 64 >= 0) {
				N -= 64;
				ans.push_back(64);
			} else if (N - 32 >= 0) {
				N -= 32;
				ans.push_back(32);
			} else if (N - 16 >= 0) {
				N -= 16;
				ans.push_back(16);
			} else if (N - 8 >= 0) {
				N -= 8;
				ans.push_back(8);
			} else if (N - 4 >= 0) {
				N -= 4;
				ans.push_back(4);
			} else if (N - 2 >= 0) {
				N -= 2;
				ans.push_back(2);
			} else {
				N--;
				ans.push_back(1);
			}
		}

		SORT(ans);
		REP(i, ans.size()) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>

#define TRUE 1
#define FALSE 0

int use_num[10];

int get_input(void) {
    int i;
    std::cin >> i;
    if (std::cin.fail()) 
        exit(0);
    return i;
}

int power(int m, int n) {
    int acc = 1;
    for (int i = 0; i < n; i++) {
        acc *= m;
    }
    return acc;
}    

void solve(int weight) {
    for (int i = 9; i >= 0; i--) {
        if (power(2, i) > weight) {
            use_num[i] = FALSE;
        } else {
            use_num[i] = TRUE;
            weight -= power(2, i);
        }
    }
}

void output(void) {
    for (int i = 0; i <= 8; i++) {
        if (use_num[i] != FALSE) {
            std::cout << power(2, i) << ' ';
        }
    }
    if (use_num[9] != FALSE) {
        std::cout << power(2, i);
    }
    std::cout << std::endl;
}

int main(void) {
    int weight;
    while (weight = get_input()) {
        solve(weight);
        output();
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
    int w;
    while (true) {
        cin >> w;
        if (cin.eof()) break;
        for (int x = 1; x <= 512; x *= 2) {
            if (w % (x * 2) != 0) {
                cout << x;
                w -= x;
                if (w == 0) {
                    cout << endl;
                    break;
                }
                cout << " ";
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int w[]={1,2,4,8,16,32,64,128,256,512};
main(){
  int n;
  while(cin >>n){
    vector<int> ans;
    for(int i=9;i>-1;i--){
      if(w[i]<=n){
	ans.push_back(w[i]);
	n-=w[i];
      }
    }
    reverse(ans.begin(),ans.end());
    int m=ans.size();
    for(int i=0;i<m;i++){
      printf("%d",ans[i]);
      if( i==m-1 ) printf("\n");
      else printf(" ");
    }
  }
}

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

int main(){
    int data[10] = {1,2,4,8,16,32,64,128,256,512};
    int ch[10];
    int mem;
    int sta;
    while(cin >> sta){
        mem = 0;
        memset(ch,0,sizeof(ch));
        for(int i=9;i>=0;i--){
            if(sta >= data[i]){
                if(mem == 0) mem = i;
                sta -= data[i];
                ch[i] = 1;
            }
        }
        for(int i=0;i<10;i++){
            if(mem == i) cout << data[i] << endl;
            else if(ch[i] == 1){
                cout << data[i] << " ";
            }
        }
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int field[10][10];

int H = 10;
int W = 10;

bool ng(int y, int x) {
	return y < 0 || H <= y || x < 0 || W <= x;
}

int main() {
	int n;
	while (cin >> n) {
		rep(i, 12) {
			int n2 = 1 << i;
			// dump((n >> i) & 1);
			if (((n >> i) & 1) == 0) continue;
			n ^= n2;
			// dump(n);
			if (n == 0) {
				cout << n2 << endl;
				break;
			}
			else cout << n2 << " ";
		}
	}


	return 0;
}

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

using namespace std;



int main () {
	int n;
	
	while(cin>>n){
		bool m[10]={false};
		int i=512,j=9,max=0;
		while(n!=0){
			if (n>=i) {
				m[j]=true;
				n%=i;
				if(j>max)max=j;
			}
			
			i/=2;
			j--;
		}
		
		for (int k=0; k<10; k++) {
			if (m[k]) {
				cout << (int)pow(2, (double)k);
				if (k!=max) {
					cout << ' ';
				}
			}
		
		}
		
		cout << endl;
		
		
	}
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;




int main(){


	int n,m;
	while (cin >> n){
		stack<int> stack;
		m = 512;
		while (m){
			if (n >= m){
				stack.push(m);
				n -= m;
			}
			m /= 2;
		}
		int k(0);
		if (!stack.empty()){
			k += stack.top();
			cout << stack.top();
			stack.pop();
		}
		while (!stack.empty()){
			cout << " ";
			k += stack.top();
			cout << stack.top();
			stack.pop();
		}
		cout << endl;
	}
	return 0;
}

C++: #include <cstdio>

int main(){
  int n;
  while(~scanf("%d",&n)){
    bool f=false;
    for(int i=0; i<10; i++)
      if(n>>i&1)
	if(f)
	  printf(" %d",1<<i);
	else{
	  f=true;
	  printf("%d",1<<i);
	}
    printf("\n");
  }
}

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

int main(){
	int n;
	while(cin >> n){
		bool first = true;
		for(int i = 0; i <= 9; i++){
			if((n >> i) & 1){
				if(!first){
					cout << " ";
				}
				cout << (1<<i);
				first = false;
			}
		}
		cout << endl;
	}

	return 0;
}

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

int w[10];

void a(int x, int y){
  if(x==0)return;
  if(x%2==1){
    w[y]=1;
  }
  else{
    w[y]=0;
  }
  a(x/2, y+1);
}

int main(){
  int n;
  while(cin>>n){
    bool flag=false;
    for(int i=0; i<10; i++)w[i]=0;
    a(n, 0);
    for(int i=0; i<10; i++){
      if(w[i]==1){
        if(flag)cout << ' ';
        cout << (int)pow(2.0, i);
        flag=true;
      }
    }
    cout << endl;
  }
  return 0;
}