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 <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	int n;
	while(cin >> n){
		for (int i=0; i<10; i++){
			if (n%2==1){
				cout << (int)pow(2.0,i);
				n = (n-1)/2;
			}else{
				n = n/2;
			}
			if (n==0){
				cout << endl;
				break;
			}else{
				cout << " ";
			}
		}
	}



	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int p2[10] = {512,256,128,64,32,16,8,4,2,1},n;
  vector<int> v;
  while(cin>>n){
    for(int i=0;i<10;i++){
      if(n>=p2[i])n-=p2[i],v.push_back(p2[i]);
    }
    sort(v.begin(),v.end());
    vector<int>::iterator it=v.begin();
    for(;it!=v.end();it++){
      cout<<*it;
      (it==v.end())?cout<<endl:cout<<" ";
    }
    cout<<endl;
    v.clear();
  }
  return 0;
}

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

int main ()
{
  int a[10];
  int n;

  while (cin >> n){
    for (int i = 0; i <= 9; 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 <= 9; i++){
      if (a[i] == 1){
        cout << (int)pow(2, i);
        for (int j = i + 1; j <= 9; j++){
          if (a[j] == 1){
            cout << " " << (int)pow(2, j);
          }
        }
        cout << endl;
        break;
      }
    }
  }
  return 0;
}

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!= EOF) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			if (judge[i] == true)cout << V[i] << ' ';
			judge[i] = false;
		}
		cout << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(){
    int a;
    while(~scanf("%d",&a)){
        for(int i=0;i<10;i++)if(1<<i&a)printf(1<<i+1>a?"%d":"%d ",1<<i);
        printf("\n");
    }
}

C++: #include<iostream>

using namespace std;

int main()
{
	int weight;
	int i,j;
	int ans[10];
	
	for(;cin >> weight;)
	{
		for(i=0;i<10;i++)
			ans[i]=0;
			
		for(i=0;weight>0;weight/=2,i++)
		{
			ans[i]=weight%2;
		}
		
		if(ans[0]==1)
			cout << "1" ;
		
		for(i=1,j=2;i<10;i++,j*=2)
			if(ans[i]==1)
				cout << " " << j ;
				
	}
}

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

using namespace std;

bool a[10];

    int main(){

    int N;
    int i=0;
    
    while(cin>>N)
    {
        
        i = 0;
        for(int j=0;j<10;j++)
        {
            a[j] = 0;
        }
        
        for(int k=9;k>-1;k--){
            
            if(i+(pow(2,k)) <= N){
                i += pow(2,k);
                a[k] = 1;
            }
        }
        
        bool last = false;
        for(int k=0;k<10;k++){
            
            if(a[k] ==1)
            {
                if(last){
                    cout<<" ";
                }
                last = true;
                cout<<pow(2,k);    
            }        
        }
 
        cout<<endl;
    }
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	int n;
	while(cin >> n)
	{
		stringstream stream;
		for(int i = 0; n; i++)
		{
			if(n & 1)
				stream << (1 << i) << ' ';
			n >>= 1;
		}

		string str = stream.str();
		str.erase(str.length() - 1);
		cout << str << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	int n;
	while(cin>>n){
		rep(i,10){
			if(1&(n>>i)){
				cout<<pow(2,i)<<" ";
			}
		}
		cout<<endl;
	}
    return 0;
}

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

int main()
{
	int ln;
	int weit[] = {1,2,4,8,16,32,64,128,256,512};
	bool fl;
	int n;

	
	while (cin >> n)
	{
		ln = 0;
		fl = 0;
		bool two[20] = { 0 };
		while (n)
		{
			two[ln] = n % 2;
			n /= 2;

			ln++;
		}

		int i;
		for (i = 0; i < ln; i++)
		{
			if (two[i]==1)
			{
				if (fl)
				{
					cout << " ";
				}
				fl = true;
				cout << weit[ i ];
			}
		}
		cout << endl;
	}

	return 0;
}

C++: 
#include <iostream>

using namespace std;

int main() {
    int N;
    while(cin >> N) {
        bool first = true;
        for(int i = 1; i < N; i <<= 1) {
            if(N & i) {
                if(!first) cout << ' ';
                cout << i;
                first = false;
            }
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;


int main(int argc, char const* argv[])
{
	unsigned long weight;
	int count = 0;
	while( cin >> weight ){
		count = 0;
		bitset<16> a( weight );
		for( int i = 0;i < 10;i++ ){
			if( a[i] == 1 ){ cout << ( ( count == 0 ) ? "" : " " ) << ( 1 << i ); count++;}
		}
		cout << endl;
	}
	return 0;
}

C++: //AOJ 0031

#include<stdio.h>
#include<iostream>
#include<vector>

using namespace std;

int main(){

	int data[10]={1,2,4,8,16,32,64,128,256,512};

	int num;

	while(cin>>num){
		int tmp=0;
		for(int j=0;j<10;j++){

			if(num%2==1){
				if(tmp==0){
					printf("%d",data[j]);
					tmp++;
				}
				else{
					printf(" %d",data[j]);
				}
				num/=2;
			}

			printf("\n");
		}

	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int w,j;
  int h[10]={1,2,4,8,16,32,64,128,256,512};
  while(cin>>w){
    if(w%2!=0){
      cout << h[0] << ' ';
      w -= 1;
    }
    for(int i=1;i<10;i++){
      if(w==h[i]){
	cout << h[i] << endl;
	w = 0;
	break;
      }
    }
    if(w!=0){
      j = 1;
      while(w!=0){
	cout << h[j];
	w -= h[j];
	j++;
	if(w==0) cout << endl;
	else cout << ' ';
      }
    }
  }
    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int ans[101][10];

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int m;
	while(scanf("%d",&m) != EOF){
		for(int j = 0; j < 10; j++){
			if((m / pow(2,j)) % 2 == 1){
				printf("%d ",pow(2,j));
			}
		}
		printf("\n");
	}
	
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}