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 <cstdio>
#include <cmath>
using namespace std;

int main(){
	int n;
	while( scanf(" %d", &n) != EOF ){
		int use[10]={0};
		int count=0, m=0;
		for(int i=9; i>=0; --i){
			if(n >= (int)pow(2.0, i)){
				use[i]=1;
				n-=(int)pow(2.0, i);
				++count;
			}
		}
				
		for(int i=0; i<10; ++i){
			if(use[i]==1){
				printf("%d", (int)pow(2.0, i));
				if(m<count-1){
					printf(" ");
					++m;
				}
			}
		} 
	
		printf("\n");
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int w,ans[10],wei[10];
signed main(void){
		ios::sync_with_stdio(false);
		for(int i=0;i<10;i++)
			wei[i]=1<<i;
		while(cin>>w){
			memset(ans,0,sizeof(ans));
			for(int i=9;i>=0;i--)
				if(w>=wei[i]){
					ans[i]=1;
					w-=wei[i];
				}
			for(int i=0,j=0;i<10;i++)
				if(ans[i]){
					if(j!=0)
						cout<<" ";
					else
						j=1;
					cout<<wei[i];	
				}
			cout<<endl;
		}
}

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

int main() 
{
  int wigth;
  cin >> wigth;
  int i = 1;
  bool flag = false;
  while (i < 256) {
    if (wigth & i) {
      if (flag) cout << " ";
      cout << i;
      flag = true;
    }
    i *= 2;
  }
  if (wigth & i) {
    if (flag) cout << " ";
    cout << i << endl;
  }else cout << endl;

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> m, ans;
  int n=1;
  m.push_back(n);
  for(int i=0; i<9; i++){
    n = n*2;
    m.push_back(n);
  }
  sort(m.begin(), m.end(), greater<int>());

  while(cin >> n){
    ans.clear();
    vector<int>::iterator it = m.begin();
    while( it != m.end() ){
      if(n - *it >= 0){
	n = n - *it;
	ans.push_back(*it);
      }
      ++it;
    }
    sort(ans.begin(), ans.end());
    vector<int>::iterator it2 = ans.begin();
    while( it2 != ans.end() ){
      cout << *it2 << " ";
      ++it2;
    }
    cout << endl;
    
  }
  return 0;
}

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

int main() {
  int d;

  while(cin>>d){
    int a=1;
    while(true){
      if(d==0) break;
      if(d%2==1) {
	cout<<a;
	d--;
	if(d>0) cout<<" ";
      }
      d/=2;
      a*=2;
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){

int m,w[10];

while(cin>>m){
	
	for(int i=0;i<10;i++)w[i]=0;
	
	for(int i=9;i>=0;i--)if(m>=pow(2,i)){w[i]=1;m-=pow(2,i);}
	
	for(int i=0;i<10;i++)if(w[i]==1)cout<<pow(2,i)<<" ";
	cout<<endl;
	}
	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+1==v.end())?cout<<endl:cout<<" ";
    }
    v.clear();
  }
  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;
		while(n!=0){
			if (n>=i) {
				m[j]=true;
				n%=i;
				
			}
			i/=2;
			j--;
		}
		
		for (int k=0; k<10; k++) {
			if (m[k]) {
				cout << pow(2, (double)k) <<' ';
			}
		
		}
		
		cout << endl;
		
		
	}
}

C++: #include <cstdio>
#include <cmath>
#include <vector>
#define pb push_back
using namespace std;
int main(void)
{
	int n,b;
	vector<int> vec;
	while(scanf("%d",&n)!=EOF)
	{
		b=n;
		vec.clear();
		while(b>0)
		{
			vec.pb(b%2);
			b/=2;
		}
		int size = vec.size();
		for(int i=0;i<size;i++)
		{
			if(vec[i])
			{
				printf("%d",(int)(pow(2,i)));
				(i==size-1) ? printf("\n") : printf(" ");
			}
			else
			{
				if(i==size-1)printf("\n");
			}
		}
	}
	return 0;
}

C++: 
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>

using namespace std;

double sq(double x){return x*x;}

int main(){
	int n;
	while(cin>>n){
		for (int i = 0; i < 10; i++)
		{
			if(n & (1 << i)) printf("%d ",1 << i);
		}
		puts("");
	}


	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

vector< bool > w( 9, 0 );

int main()
{
    int weight;
    while( scanf( "%d\n", &weight ) != EOF )
    {
        for( int i = 8; i >= 0; i-- )
        {
            if( pow( 2, i ) <= weight )
            {
                weight %= ( int ) pow( 2, i );
                w[i] = 1;
            }
        }
        for( int i = 0; i < 9; i++ )
        {
            if( w[i] )
            {
                printf( "%.0lf ", pow( 2 , i ) );
            }
        }
        printf( "\n" );
    }
    return 0;
}

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

int main(){
	while (true)
	{
		int R[10], S[10], n;
		string str;
		R[0] = 1;
		S[0] = 0;
		for (int i = 1; i < 10; i++) {
			R[i] = R[i - 1] * 2;
			S[i] = 0;
		}
		cin >> n;
		if (cin.eof() || n == 0) { break; }
		for(int i=9;i>=0;i--){
			if(n>=R[i]){
				n -= R[i];
				S[i] += 1;
			}
		}
		for(int i=0;i<10;i++){
			if (S[i] == 1) {
				str += to_string(R[i]);
				str += " ";
			}
		}
		cout << str << endl;
	}
	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){
    int type[10]={0};
    for(int j = 10;j >=0;j--){
      if(W-weights[j] >=0){
	W -=weights[j];
	type[j] = 1;
      }
    }
      for(int i = 0;i <10;i++){
	if(type[i] ==1){
	  cout <<weights[i];
	  if(i !=9)
	    cout <<" ";
	}
      }
      cout <<endl;	
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  int square[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  vector<int> num;

  while(cin >> n){
    if(n == 0) break;

    for(int i = 9; i >= 0; i--){
      if(n >= square[i]){
        num.push_back(i);
        n -= square[i];
      }
    }

    for(int i = num.size() - 1; i >= 0; i--){
      cout << square[ num[i] ];
      if(i == 0) cout << endl;
      else      cout << " ";
    }    
    num.clear();
  }
}