Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		w := 512
		weights := make([]int, 10)
		for i := 9; i >= 0; i-- {
			if n >= w {
				weights[i] = w
				n -= w
			}
			w /= 2
		}

		output := []int{}
		for i := 0; i < 10; i++ {
			if weights[i] > 0 {
				output = append(output, weights[i])
			}
		}
		outputStr := fmt.Sprint(output)
		fmt.Println(outputStr[1:(len(outputStr) - 1)])
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int a;
	int b=512;
	int c[10]={0};
	int d=0;
        while(cin>>a){

            int i=0;
            if (a>=512){
                a-=512;
                c[i]=512;
                i++;
            }
            if (a>=256){
                a-=256;
                c[i]=256;
                i++;
            }
            if (a>=128){
                a-=128;
                c[i]=128;
                i++;
            }
            if (a>=64){
                a-=64;
                c[i]=64;
                i++;
            }
            if (a>=32){
                a-=32;
                c[i]=32;
                i++;
            }
            if (a>=16){
                a-=16;
                c[i]=16;
                i++;
            }
            if (a>=8){
                a-=8;
                c[i]=8;
                i++;
            }
            if (a>=4){
                a-=4;
                c[i]=4;
                i++;
            }
            if (a>=2){
                a-=2;
                c[i]=2;
                i++;
            }
            if (a>=1){
                a-=1;
                c[i]=1;
                i++;
            }

            for(i-=1;i>=0;i--){
                if(i==0){
                    cout<<c[i];
                    break;
                }
                cout<<c[i]<<" ";

            }
            cout<<endl;
        }
	return 0;
}

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

using namespace std;

int main() {
	vector<int> weights;
	vector<int> use;
	weights.push_back(1);
	weights.push_back(2);
	weights.push_back(4);
	weights.push_back(8);
	weights.push_back(16);
	weights.push_back(32);
	weights.push_back(64);
	weights.push_back(128);
	weights.push_back(256);
	int w;

	while(cin>>w,!cin.eof()) {
		while(w!=0){
			for(int i=0; i<weights.size(); i++){
				if(w == 0) break;
				if(weights.at(i) > w){
					w -= weights.at(i-1);
					use.push_back(weights.at(i-1));
					break;
				}
			}
		}
		sort(use.begin(), use.end());
		for(int i=0; i<use.size()-1; i++){
			cout<<use[i]<<" ";
		}
		cout<<use[use.size()-1]<<endl;
		use.clear();
	}
	return 0;
}

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

int main(){
	int n;
	while(cin >> n;){ 
		int weight[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		for(int i = 9; i >= 0; i--){
			if(n >= pow(2, i)){
				n -= pow(2, i);
				weight[i] = 1;
			}
		}

		cout << "1";
		for(int i = 1; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

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;
}