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<cstdio>
using namespace std;
int main(void)
{
	int n;
	bool kari = 0;
	int a[10] = {1,2,4,8,16,32,64,128,256,512};
	while(scanf("%d",&n) != EOF)
	{
		bool flag[10] = {0};
		for(int i = 9;i >= 0;i--)
		{
			if(a[i] <= n)
			{
				n -= a[i];
				flag[i] = 1;
			}
		}
		for(int i = 0;i < 10;i++)
		{
			if(flag[i] == 1)
			{
				printf("%d",a[i]);
				for(int j = i+1;j < 10;j++)
				{
					if(flag[j] == 1) kari = 1;
				}
				if(kari == 1) printf(" ");
				else printf("\n");
				kari = 0;
			}
		}
	}
	
	return 0;
}

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<vector>
using namespace std;
int main(){
	int weight;
	int n[10];
	int arr[10];
	vector<int> ans;

	for(int i=0,j=1;j<=512;j*=2){
		arr[i++]=j;
	}
	while(cin>>weight){
		ans.clear();
		for(int i=9;i>-1;i--){
			if(weight<=1){
				if(weight==1){
					ans.push_back(weight);
					break;
				}
			}else if(weight>=arr[i]){
				weight-=arr[i];
				ans.push_back(arr[i]);
			}
		}
		for(int i=ans.size()-1;i>-1;i--){
			cout<<ans[i];
			(i==0)? cout<<endl:cout<<" "; 
		}
	}
	return 0;
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
//#include <map>

using namespace std;


int main(){

	int m, buf;
	string s ;

	while (cin >> m){
		buf = 1;
		s = "";

		for (int i = 0; i < 10; i++){
			if (m % 2 == 1) {
				cout << s << buf;
				s = " ";
			}
			m >>= 1;
			buf *= 2;
		}
		cout << endl;

	}

	return 0;
}

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

using namespace std;
const int V[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int n;

void solve(){
    vector<int> w;
    for(int i=0; i<10; i++){
        int f = n/V[i];
        if(f!=0){
            n -= V[i];
            w.push_back(V[i]);
        }
    }
    for(int i=w.size()-1; i>=0; i--){
        cout<<" "<< w[i];
    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }





int main() {
	int in;
	while (cin >> in) {
		bitset<10> b(in);
		int hit = 0;
		for_(i, 0, 9) {
			if (b[i]) {
				if (hit>0) cout << " ";
				cout << pow(2, i);
				hit++;
			}
		}
		cout << endl;
	}
	
	return 0;
}

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

int main()
{
	int weights[10] = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };
	vector<int> ans;
	int n;

	while (cin >> n)
	{
		ans.clear();
		for (int i = 0; i < 10; ++i)
		{
			if (n >= weights[i])
			{
				n -= weights[i];
				ans.push_back(weights[i]);
			}
		}

		//??????????????????
		for (int i = ans.size() - 1; i >= 0; --i)
		{
			cout << ans[i];
			if (i != 0) cout << " ";
		}

		cout << endl;
	}

	return 0;
}

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

int main(){
	int n,a[10],b[10];
	a[0]=1;
	for(int i=1;i<10;i++){
		a[i]=2*a[i-1];
	}
	
	while(cin >> n){
		for(int i=0;i<10;i++){
			b[i]=0;
		}
		for(int i=9;n!=0;i--){
			if(n>=a[i]){
				n-=a[i];
				b[i]=a[i];
			}
		}
		for(int i=0;i<10;i++){
			if(b[i]!=0){
				cout << b[i] << " ";
			}
		}
		cout << "\n" ;
	}
		
		
		
return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

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

void input(void) {
	CI N;
	return;
}


int main(void) {
	int nn = 0;
	while (CI N) {
		for (int i = 9; i >= 0; i--) {
			if (W[i] <= N) {
				N -= W[i];
				W_b[i] = true;
				nn++;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (W_b[i] == true) {
				CO W[i];
				if (i != nn - 1)CO " ";
				W_b[i] = false;
			}
		}
		CO "\n";
		nn = 0;
	}
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int main(){
  vector<int> ar;
  int g[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int n;
  while(cin >> n){
    for(int i=9;i>=0;i--){
      if(n>=g[i]){
	n -= g[i];
	ar.push_back( g[i] );
      }
    }
    for(int i=ar.size()-1;i>=0;i--){
      if(i != 0)cout << ar[i] << ' ';
      else cout << ar[i] << endl;
    }
  }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int w;

	while ( cin >> w )
	{
		set<int> weights;

		for ( int i = 9; 0 <= i; i-- )
		{
			int weight = pow( 2, i );

			if ( weight <= w )
			{
				w -= weight;
				weights.insert( weight );
			}
		}

		for ( set<int>::iterator it = weights.begin(); it != weights.end(); )
		{
			cout << *it;

			if ( ++it == weights.end() )
			{
				cout << endl;
			}
			else
			{
				cout << ' ';
			}
		}
	}
	
	return 0;
}

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

using namespace std;

int main()
{
	int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int gram;
	vector<int> ans;
	while(cin>>gram){
		for(int i=9;i>=0;i--){
			if(gram >= weight[i]){
				ans.push_back(i);
				gram -= weight[i];
			}
		}
		
		for(size_t i=ans.size()-1;i>=0;i--){
			cout<<weight[ ans[i] ];
			if(i != 0) cout<<' ';
		}
		cout<<endl;
		ans.clear();
		
	}
	return 0;
}