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,sum,div,cnt=0;

	while(cin>>n){
		sum=0;
		for(int i=0;i<10;i++){
			sum+=(int)pow(2,i);
			if(sum>n){
				div=sum-n;
				while(div/=2) cnt++;
				for(int j=0;j<=i;j++){
					if(j!=cnt) printf("%d ",(int)pow(2,j));
				}
				break;
			}
			else if(sum==n){
				for(int k=0;k<=i;k++){
					printf("%d ",(int)pow(2,k));
				}
				break;
			}
		}
		printf("\n");
	}
	return 0;
}

C++: // 天秤

#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int weight;
  
  while(cin >> weight) {
    vector<int> answer;
    for(int i = 10; i >= 0; --i) {
      if((1 << i) <= weight) {
        weight -= (1 << i);   // ビット演算を使用
        answer.push_back(1 << i);
      }
    }
    
    cout << answer[answer.size() - 1];
    for(int i = answer.size() - 2; i >= 0; --i) {
      cout << " " << answer[i];
    }
    cout << endl;
  }
}

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

int main(){
	while (true)
	{
		int R[10], S[10], n;
		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) {
				cout << R[i] << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int w;
  
  while ( cin >> w )
    {
      bool flag = false;
      
      for ( auto i = 0; i < 10; ++i )
        {
          if ( (w >> i) & 1 )
            {
              if ( flag ) cout << " ";
              flag = true;
              cout << (1 << i);
            }
        }
      cout << endl;
    }
  return 0;
}

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

int main() {
	ios :: sync_with_stdio(false);
	for(int n; cin >> n; ) {
		for(int i = 0; i < 9; i ++) if((n >> i) & 1) {
			n -= (1 << i);
			cout << (1 << i) << (n ? ' ' : '\n');
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int n;
    while (cin >> n)
    {
        vector<int> ans;
        for (int i = 1; i <= n; i <<= 1)
        {
            if (i & n)
            {
                ans.push_back(i);
            }
        }
        for (int i = 0; i < ans.size(); ++i)
        {
            if (i)
                cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}

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

int main(){

  int weight;
  int n;

  while(cin>>weight,weight){
    vector<int> result;
    while(1){
      if(weight == 1 || weight ==2 || weight ==4 || weight ==8 || weight ==16 || weight ==32 || weight ==64 || weight ==128 || weight ==256 || weight ==512){
	result.push_back(weight);
	break;
      }
      if(weight<4)
	n=2;
      else if(weight<8)
	n=4;
      else if(weight<16)
	n=8;
      else if(weight<32)
	n=16;
      else if(weight<64)
	n=32;
      else if(weight<128)
	n=64;
      else if(weight<256)
	n=128;
      else if(weight<512)
	n=256;

      result.push_back(n);
      weight-=n;
    }

    sort(result.begin(),result.end());

    for(auto i:result)
      cout<<i<<" ";
    cout<<endl;
  }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;

int main(){
   int n;
   vector<int> num;
   int m,s,i;
   
   while(cin>>n){
      num.clear();
      
      for(;;){
         m=1;
         if(n<1) break;
         
         else{
            for(int i=0;i<10;i++){
               if(m>n) break;
               m*=2;
            }
            m/=2;
            num.push_back(m);
            n-=m;
         }
      }
      
      s=(int)num.size()-1;
      cout<<num[s];
      s--;
      for(i=s;i>=0;i--){
         cout<<" "<<num[i];
      }
      puts("");
   }
   return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,d[10]={512,256,128,64,32,16,8,4,2,1};
	bool a[10];
	while(cin>>n){
		for(int i=0;i<10;i++){
			a[i]=false;
			while(d[i]<=n){n-=d[i];a[i]=true;}
		}
		
		for(int i=9;i>=0;i--)
			if(a[i]==true)cout<<d[i]<<" ";
		cout<<endl;
	}

}

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

int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    while (g != 0) {
      int i = 1;
      while (g >= i * 2) {
        i *= 2;
      }
      v.push_back(i);
      g -= i;
    }
    reverse(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      if (i == v.size() - 1) {
        cout << v.at(i) << endl;
      } else {
        cout << v.at(i) << " ";
      }
    }
    v.clear();
  }
}

C++: #include <iostream>

int main(int argc, const char * argv[])
{
    int cu[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int g, j = 0, cu2[10] = {0};
    scanf("%d", &g);
    
    for (int i = 0; i < 10; i++) {
        if ((g - cu[i]) < 0) {
            g -= cu [i - 1];
            cu2[j] = cu[i - 1];
            i = 0; j++;
        }
        if (g == 0) break;
    }
    for (int i = 0; i < j / 2; i++) {
        int tmp;
        tmp = cu2[j - 1 - i];
        cu2[j - 1 - i] = cu2[i];
        cu2[i] = tmp;
    }
    
    for (int i = 0; i < j; i++) {
        printf("%d ", cu2[i]);
    }
    puts("");
    
    return 0;
}

C++: #include <stdio.h>
  int main(){
   int x[10]={1,2,4,8,16,32,64,128,256,512};
   int n,i,sum=0;
    while(scanf("%d",&n) != EOF){
		int y[10]={};
     for(i=9;i>=0;i--){
		 if(n>=x[i]){  n -= x[i]; y[i]=1; sum++;}
       }
      for(i=0;i<10;i++){
		  if(y[i]==1) {sum--; if(sum!=0){printf("%d ",x[i]);}
		  else{printf("%d\n",x[i]);
		  }}}
	  sum=0;
}
return 0;
}

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

int weight[10];
weight[1]=1;
for(int i = 2;i<=9;i++)weight[i]=2*weight[i-1];


int main(){
	while(true)
	{
	int object;
	cin >> object;
	if (cin.eof())break;
	for(int i =1;int <=9;i++){
		if(object%2==1)
			{
			cout << weight[i] ;
			if( i != 9 ) cout << " ";
			}
		}
	cout << endl;
	}
	
	return 0;
}

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

int main(){
  int a;
  int count = 0;
  std::vector<int> v;
  std::vector<std::vector<int> > x;
  while(std::cin >> a){
    v.push_back(a);
    count++;
  }
  int i;
  for(i = 0; i < count; i++){
    int data;
    data = v[i];
    int j;
    std::vector<int> w;
    for(j = 0; j < 10; j++){
      if(data == 0){
        break;
      }
      if(std::pow(2,9-j) <= data){
        w.push_back(std::pow(2,9-j));
        data -= std::pow(2,9-j);
      }
    }
    std::sort(w.begin(),w.end());
    x.push_back(w);
   }
  int k;
  for(k =0; k<count; k++){
    int l;
    for(l = 0; l<x[k].size(); l++){
      std::cout << x[k][l];
      if(l + 1 < x[k].size()){
        std::cout << " ";
      }
    }
    std::cout << "\n";
  }
  return 0;
}