Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++) 
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
 
int main(void)
{
  int pw[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
  int n;
  
  while (cin >> n){
    vi li;
    int cnt = 0;
    REP(i, 10){
      if (n - pw[i] >= 0){
        n -= pw[i];
        li.pb(pw[i]);
        cnt++;
      }
    }
    sort(all(li));
    REP(i, cnt){
      if (i == cnt - 1) cout << li[i] << endl;
      else cout << li[i] << " ";
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int main(){
  while(cin>>n){
    for(int i=1;n>0;i*=2){
   
      if(n&1){

	cout<<i<<' ';
      }
      n=n>>1;
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
	int g;
	int num[]={1,2,4,8,16,32,64,128,256,512};
	stack<int> ans;
	while(cin>>g){
		for(int i=9;i>=0;i--){
			if(g>=num[i]){
				g-=num[i];
				ans.push(num[i]);
			}
		}while(!ans.empty()){
			cout << ans.top() << " ";
			ans.pop();
		}cout<<endl;
	}
}

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

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

	while(cin >> n) {
		result.clear();
		while(true) {
			if(n<=0) break;
			if(n%2 == 1) result.push_back(1);
			else		 result.push_back(0);
			n /= 2;
		}

		for(int i=0;i<result.size();i++) {
			if(result[i] == 1 && i<result.size()-1) 
				cout << pow(2,i) << ' ';
			else 
				cout << pow(2,i);
		}
		cout << '\n';
	}

	return 0;
}

C++: #include<iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main(){int a1;
while(cin>>a1){
int w[10],i=0;
	if(a1>=512){
	a1-=512;w[i]=512;i++;}
	if(a1>=256){
	a1-=256;w[i]=256;i++;}
	if(a1>=128){
	a1-=128;w[i]=128;i++;}
	if(a1>=64){
	a1-=64;w[i]=64;i++;}
	if(a1>=32){
	a1-=32;w[i]=32;i++;}
	if(a1>=16){
	a1-=16;w[i]=16;i++;}
	if(a1>=8){
	a1-=8;w[i]=8;i++;}
	if(a1>=4){
	a1-=4;w[i]=4;i++;}
	if(a1>=2){
	a1-=2;w[i]=2;i++;}
	if(a1==1){
	a1-=1;w[i]=1;i++;}
	for(int ii=0;ii<i-1;ii++){
	cout<<w[i-ii-1]<<" ";}
	cout<<w[0]<<endl;}
	return 0;}

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

int main(){
	int n , j=0;
	vector<int> v;
	while(cin>>n){
		for(int i=512 ; i>=1 ; i>>=1){
			if(n>=i){
				v.push_back(i);
				n-=i;
			}
		}
		sort(v.begin(),v.end());
		for(vector<int>::iterator it=v.begin();it!=v.end();++it){
			cout << *it << " ";
		}
		cout << endl;
		v.clear();
	}
	return 0; 
}

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

int main(){
	int N, total;
	while (cin >> N) {
		for (int i = 0; i < 10; i++) {
			if (N & 1) {
				total = 1 << i;
				cout << total;
				if (N >> 1) {
					cout << ' ';
				}
			}
			N >>= 1;
		}
		cout << endl;
	}
}

C++: #include<iostream>
#include<vector>
int n=1024;
std::vector<int> g;

int main(){
	int a;
	while(std::cin>>a){
		int n_=0;
		bool f=true;
		while(1){
			if(n<a&&f)g.push_back(n),a-=n,n_=n,f=false;
			else if(n<a)g.push_back(n),a-=n;
			else n/=2;
			if(a==1){
				g.push_back(1);
				break;
			}
		}
		
		for(std::vector<int>::reverse_iterator it = g.rbegin();it!=g.rend();++it){
			std::cout<<*it;
			if(*it!=n_)std::cout<<" ";
		}
		std::cout<<std::endl;
		n=1024;
	}
	return 0;
}

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

int main() {
  int data[] = {1,2,4,8,16,32,64,128,256,512};
  int n;
  while ( cin >> n ) {
    vector<int> num;
    num.clear();
    for ( int i = 9; i >= 0; i-- ) {
      if ( n - data[i] >= 0 ) {
	n-= data[i];
	num.push_back(data[i]);
      }
    }
    for ( int i = num.size()-1; i >= 0; i-- ) {
      if ( i == 0 ) cout << num[i] << endl;
      else cout << num[i] << " ";
    }
  }

  return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W;
int weights[10] ={1,2,4,8,16,32,64,128,256,512};
int main()
{
  while(cin>>W){
    if(cin.eof())
      break;
    int type[10]={0};
    int first = 100;
    for(int j = 9;j >=0;j--){
      if(W-weights[j] >=0){
	W -=weights[j];
	type[j] = 1;
	if(first ==100)
	  first =j;
      }
    }
      for(int i = 0;i <=first;i++){
	if(type[i] ==1){
	  cout <<weights[i];
	  if(i !=first){
	  cout <<" ";
	  }
	}
	if(i ==first)
	  cout <<endl;
      }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<memory.h>
using namespace std;
const int g[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
int f[10] = { 0 };
vector<int> p;
int main()
{
	int n;
	while (cin >> n){
		p.clear();
		memset(f, 0, sizeof(f));
		
		
		while (n != 0){
			for (int i = 9; i >= 0; i--){
				if (n - g[i] >= 0 && f[i] == 0){
					n -= g[i];
					f[i] = 1;
					p.push_back(g[i]);
				}
			}
		}
		for (int i = p.size() - 1; i >= 1; i--){
			cout << p[i] << " ";
		}
		cout << p[0] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
int n;
int g;
while(cin >>n){
g=1;
while(g<1000){
if(n%(2*g)==g&&n!=g){cout <<g<<" "; n=n-g;}
else if(n%(2*g)==g&&n==g){cout <<g<<endl; n=n-g;}
g=g*2;}
}
}

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

using namespace std;

array< int, 10 > weight_array{ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
array< int, 1024 > sum_table;
array< array< int, 10 >, 1024 > bit_table;

void MakeTable()
{
	int i = 0, j = 0, tmp = 0;
	for ( i = 0 ; i < 1024 ; i++ )
	{
		tmp = i;
		for ( j = 0 ; j < 10 ; j++ )
		{
			bit_table[i][j] = tmp % 2;
			sum_table[i] = bit_table[i][j] * weight_array[j] + sum_table[i];
			tmp = tmp >> 1;
		}
	}
}

void PrintTable()
{
	for ( int i = 0 ; i < 1024 ; i++ )
	{
		cout << i << " " << sum_table[i] << " {";
		for ( int j = 0 ; j < 10 ; j++ )
		{
			cout << bit_table[i][j] << " ";
		}
		cout << "}" << endl;
	}
}

int main()
{
	int weight, j, i;
	MakeTable();
	//PrintTable();
	while( cin >> weight )
	{
		for ( i = 0 ; i < 1024 ; i++ )
		{
			if ( sum_table[i] == weight )
			{
				for ( j = 0 ; j < 10 ; j++ )
				{
					if ( bit_table[i][j] == 1 )
					{
						cout << weight_array[j];
						if( j != 9 )
						{
							cout << " ";
						}
					}
				}
				cout << endl;
				break;
			}
		}
	}

	return 0;
}