Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	weight := []int{512, 256, 128, 64, 32, 16, 8, 4, 2, 1}

	for sc.Scan() {
		var wgt []int
		i, _ := strconv.Atoi(sc.Text())

		if i > 1023 {
			i = 1023
		}

		bin := fmt.Sprintf("%010b", i)

		for i := 9; i >= 0; i-- {
			if bin[i] == '1' {
				wgt = append(wgt, weight[i])
			}
		}

		for i := 0; i < len(wgt); i++ {
			if i == len(wgt)-1 {
				fmt.Printf("%d\n", wgt[i])
			} else {
				fmt.Printf("%d ", wgt[i])
			}

		}
	}

}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;




int main(){
  int n;


  while (std::cin >> n) {
    int weight[10]={0};

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

    // for(int i=0;i<9;i++){
    //   if(weight[i]==1){
    //     std::cout << pow(2,i)<<" ";
    //   }
    // }
    // if(weight[9]==1){
    //   std::cout << "512" << '\n';
    // }

    int flag;
    int count=0;
    for(int i=9;i>=0;i--){
      if(count==2)break;
      if(weight[i]==1){
        flag=i;
        count++;
      }
    }

    if(count==1){
      std::cout << pow(2,flag) << '\n';
    }else{
      for(int i=0;i<=flag;i++){
        if(weight[i]==1){
          std::cout << pow(2,i) << " ";
        }
      }
      for(int i=9;i>=0;i--){
        if(weight[i]==1){
          std::cout << pow(2,i) << '\n';
          break;
        }
      }

    }



  }
}

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

int main()
{
    int n,weight;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}
		for(int i=0; i<10 ; i++){
			if(flag[i]!=0){
				cout << w[i] ;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int w;
        if(!(cin >> w))
            return 0;

        int tmp = 1;
        bool first = true;
        while(w > 0){
            if(w % 2 == 1){
                if(first)
                    first = false;
                else
                    cout << ' ';
                cout << tmp;
            }
            w /= 2;
            tmp *= 2;
        }
        cout << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
	int w;
	while (cin >> w) {
		bool first_output = true;
		for (int weight = 1; w>0; w>>=1, weight<<=1) {
			if ((w&1)==1) {
				if (!first_output) cout << " ";
				cout << weight;
				first_output = false;
			}
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int now[10]={0};
	int max=0;
	bool brank=false;
	while(cin>>n){
		for(int i=512;i>=1;i/=2){
			if(n>=i){n-=i;now[max]=i;max++;}
		}
		while(max>=1){
			if(brank==true)cout<<" ";
			if(brank==false)brank=true;
			cout<<now[max-1];
			max--;
		}
		brank=false;
	}
}

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

int main(){
	int n;
	while(cin >> n){
		vector<int> ans;
		for(int i = 9; i >= 0; i--){
			if(n - pow(2, i) >= 0){
				ans.push_back(pow(2, i));
				n -= pow(2, i);
			}
		}
		sort(ans.begin(), ans.end());
		for(int i = 0; i < ans.size(); i++){
			cout << ans[i] << " ";
		}
		cout << endl;
	}
}

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

int main(){
    int n;
    while(cin>>n,n!=EOF){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size();i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  bool f;
  int n, i;
  while (cin >> n) {
    f = 0;
    for (i = 0; i < 10; i++) {
      if (n & 1 << i) {
        if (f) {
          cout << ' ';
        }
        cout << (1 << i);
        f = 1;
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    int n, w[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
    while (cin >> n) {
        int s = 0;
        vector<int> vec;
        while (n > 0) {
            if (n % 2 == 1) {
                vec.push_back(w[s]);
            }
            n /= 2;
            s++;
        }
        for (int i = 0; i < vec.size() - 1; i++) {
            cout << vec[i] << " ";
        }
        cout << vec[vec.size() - 1] << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(i!=s.size()-1)std::cout<<" ";} num/=10;}
    std::cout<<std::endl;
    }
}

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

using namespace std;

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

bool tukauka[10];//大きい順

int n,owari;
int main(){
	while(cin >> n){
		for(int i = 0;i < 10; i++) {
			if(n >= omosa[i])tukauka[i] = true, n -= omosa[i],owari=i;
		}
		for(int i = 0; i < 10; i++) {
			if(tukauka[9 - i]&&i==owari) {
				cout << omosa[9 - i] ;
			}else {
				cout<< omosa [9 - i]<<" ";
			}
		}
		cout << endl;
		for(int i=0;i<10;i++)tukauka[i]=false;
	}
	return 0;
}

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

int main() {
	int m;
	vector<int> M,N;
	vector<vector<int>> POW;
	while (cin >> m) 
		M.push_back(m);
	for (int i = 0; i < M.size(); i++) {
		int mi = M[i];
		for (int j = 0; j < 10; j++) {
			if (pow(2, j) <= mi && mi < pow(2, j + 1)) {
				N.push_back(j); mi -= pow(2, j);
				if (mi == 0)break;
				else j = -1;
			}
		}
		sort(N.begin(), N.end());
		POW.push_back(N); N.clear();
	}
	for (int i = 0; i < POW.size(); i++) {
		for (int j = 0; j < POW[i].size(); j++) {
			if (j != POW[i].size() - 1)cout << pow(2, POW[i][j]) << " ";
			else cout << pow(2,POW[i][j]) << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int
main(void)
{
	char line[80];

	int w;

	int f[10];
	int u[10];

	int k = 512;
	for (int& d : f) {
		d = k;
		k >>= 1;
	}

	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			break;
		}
		if (sscanf(line, "%d", &w) != 1) {
			break;
		}

		int p;
		for (p = 0; p < 10; p++) {
			if (w >= f[p]) {
				break;
			}
		}

		memset(u, 0, sizeof u);

		int t = f[p];
		u[p] = 1;
		p++;

		while (true) {
			if (t == w) {
				break;
			} else if (t > w) {
				t -= f[p-1];
				u[p-1] = 0;
			}

			t += f[p];
			u[p] = 1;
			p++;
		}

		const char* sp = "";
		for (int i = 9; i >= 0; i--) {
			if (u[i]) {
				printf("%s%d", sp, f[i]);
				if (*sp == 0) {
					sp = " ";
				}
			}
		}
		printf("\n");

	}

	return 0;
}