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

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

int main()
{
	int w=-1,m=-1;
	while(cin >> m)
	{
		if(w>0) cout << endl;
		
		w=1;
		while(m)
		{
			if(m&1) cout << (w==1?"":" ") << w;
			m = m>>1;
			w = w<<1;
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int V[10] = { 1,2,4,8,16,32,64,128,256,512 };
bool judge[10] = { false };

int main() {

	int n;

	while (cin >> n, n) {
		for (int i = 9; i >= 0; i--) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		for (int i = 0; i < 10; i++) {
			if (i != 0 && judge[i] == true)cout << " " << V[i];
			if (i == 0 && judge[i] == true)cout << V[i];
			judge[i] = false;
		}
		cout << endl;
	}

	return 0;
}

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

int input,i;


int main(){
	while(cin>>input){
		string ans("");
		while(1){
			if(input%2==0) ans.insert(ans.begin(),'0');
			else ans.insert(ans.begin(),'1');
			input/=2;
			if(input==0) break;
		}
		if(ans[ans.length()-1]=='1'){
			cout<<"1"<<" ";
		}
		ans.pop_back();
		i=2;
		while(1){
			if(ans.empty()==1) break;
			if(ans[ans.length()-1]=='1'){
				cout<<(int)pow(2.0,i)/2<<" ";
			}
			ans.pop_back();
			i++;
		}
		cout<<endl;
	}
	return 0;
}