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

int main() {
	int n;
	while (cin >> n) {
		int pow[10] = {}, p = 0, rem, quo;
		while (1) {
			rem = n % 2; quo = n / 2;
			if (rem) {
				pow[p]++;
			}
			if (quo == 0) break;
			p++;
			n = quo;
		}
		for (int i = 0, j = 0, r = 1; i < 10; i++, r *= 2) {
			if (pow[i]) {
				if (j) cout << " ";
				cout << r;
				j++;
			}
		}
		cout << endl;
	}
}

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

int main(){
  int w,flag;
  int b[10]={0};

  while(std::cin >> w){
    for(int i=0;i<10;i++){
      b[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(w>=std::pow(2,i)){
        w = w - std::pow(2,i);
        b[i] = 1;
      }
    }
    flag = 1;
    for(int i=0;i<10;i++){
      if(flag){
        std::cout << std::pow(2,i);
        flag = 0;
        continue;
      }
      if(b[i] == 1){
        std::cout << ' ' << std::pow(2,i);
      }
    }
    std::cout << std::endl;
  }
}

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

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);
				break;
			}
		}
		for(; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
	int n,a[10],c;
	
	while(cin>>n){
		c=0;
		for(int i=0;i<10;i++) a[i]=0;
		for(int i=9;i>=0;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				a[i]++;
			}
		}
		for(int i=0;i<10;i++){
			if(a[i]!=0){
				if(c!=0) cout << " ";
				cout << pow(2,i);
				c++;
			}
		}
		cout << endl;
	}
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a;
  int i = 0;
  while (cin >> a) {
    while (1) {
      a -= pow(2, i);
      if (a == 0) {
        for (int j = 0; j <= i; j++) {
          cout << pow(2, j) << ' ';
        }
        cout << endl;
        i = 0;
        break;
      } else {
        i++;
      }
    }
  }
  return 0;
}

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

int main() {
    int weight;
    while (cin >> weight) {
        for (int i = 0; weight > 0; weight /= 2, i++) {
            if (weight % 2 == 1) {
                cout << pow(2, i) << " ";
            }
        }
        cout << endl;
    }
}

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 << "\n";
	}
	return 0;
}

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

int main()
{
	int w;
	while (cin >> w)
	{
		int weight[] = {512,256,128,64,32,16,8,4,2,1};
		bool used[] = {false,false,false,false,false,false,false,false,false,false};
		int i = 0;
		while (w > 0 && i < 10)
		{
			if (w < weight[i])
			{
				i++;
			}
			else
			{
				w -= weight[i];
				used[i] = true;
				i++;
			}
		}
		bool f = false;
		for (i = 9; i >= 0; i--)
		{
			if (used[i])
			{
				if (!f)cout << weight[i];
				else cout << " " <<weight[i];
				f = true;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n){
    int s=0,a[10],k=0;
    for(int i=512;i>0;i/=2)if(n>=i){
        a[k++]=i;
	n-=i;
      }
    for(int i=k-1;i>=0;i--,s++){
      if(!s)cout<<a[i];
      else cout<<' '<<a[i];
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int weight[10];
	weight[0] = 1;
	for(int i = 1; i < 10; i++){
		weight[i] = weight[i-1]*2;
	}
	int n;
	while(cin >> n){
		vector<int> ans;
		for(int i = 10; i >= 0; i--){
			if(weight[i] <= n){
				n -= weight[i];
				ans.pb(weight[i]);
			}
			if(n == 0)break;
		}
		for(int i = ans.size()-1; i > 0; i--){
			//if(i == 1)cout << ans[i] << endl;
			//else 
				cout << ans[i] << " ";
		}
	}


	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<bitset>
#include<sstream>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int x;
    bool first;
    int i;
    int g;
    while(cin >> x){
        first = true;
        g = 1;
        int ans[10] = {0};
        for(i = 0; x > 1; i++){
            ans[i] = x % 2;
            x /= 2;
        }ans[i] = x;
        rep(j,10){
            if(ans[j] == 1 && first == true){
                cout << g;
                first = false;
            }else if(ans[j] == 1){
                cout << " " << g;
            }g *= 2;
        }cout << endl;
    }
}