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>

int main(){
	int a,b,c=1;
	int d[10];
	
	while(std::cin>>a){
		
		for(b=0;b<2;b++){
			if(a==b){
				d[1]=b;
			}else{
				for(c=0;c<3;c=c+2){
					if(a==b+c){
						d[1]=b;
						d[2]=c;
						
						
					}else{
						for(int e=0;e<5;e=e+4){
			if(a==b+c+e){
				d[1]=b;
				d[2]=c;
						d[3]=e;
					
			}else{
				for(int f=0;f<9;f=f+8){
					if(a==b+c+e+f){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						
					}else{
						for(int g=0;g<17;g=g+16){
			if(a==b+c+e+f+g){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						
			}else{
				for(int h=0;h<33;h=h+32){
					if(a==b+c+e+f+g+h){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						
					
					}else{
						for(int i=0;i<65;i=i+65){
			if(a==b+c+e+f+g+h+i){
				d[1]=b;d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						
			}else{
				for(int j=0;j<129;j=j+128){
					if(a==b+c+e+f+g+h+i+j){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						
					}else{
						for(int k=0;k<257;k=k+256){
			if(a==b+c+e+f+g+h+i+j+k){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						
			}else{
				for(int l=0;l<513;l=l+512){
					if(a==b+c+e+f+g+h+i+j+k+l){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						d[10]=l;
					}else{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		for(int m=1;m<11;m++){
		if(d[m]!=0){
			std::cout<<d[m];
		}
	}
	std::cout<<std::endl;
	}
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int n, s;
int main() {
	while (true) {
		cin >> n; s = 0;
		for (int i = 1; i < 31; i++) {
			if ((n / (int)pow(2, i)) % 2 == 1) {
				if (s) { cout << ' '; }
				cout << pow(2, i - 1); s++;
			}
		}
		cout << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	int x;
	while(cin>>x){
		for(int i=0;i<10;i++){
			if((x>>i)&1)cout<<(1<<i)<<" ";
		}
		cout<<endl;
	}
}

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>
#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];
			}
		}
		for(int i=9;i!=0;i--){
			if(tukauka[i])owari=i;
		}
		for(int i = 0; i < 10; i++) {
			if( i==9-owari) {
				cout << omosa[9 - i] ;
			}else if(tukauka[9 - i]){
				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 N;
	cin >> N;
	vector<int> res;
	for (int i = 0; i < 10; i++) {
		if (N & (1 << i)) {
			res.push_back(1 << i);
		}
	}
	reverse(res.begin(), res.end());
	for (int i = 0; i < (int)res.size(); i++) {
		cout << res[i] << " \n"[i +  1 == (int)res.size()];
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>

using namespace std;

main {
  int x;
  while(cin>>x) {
    vi r;
    x=x<<1;
    for(int i=0; x=x>>1; i++) {
      if (x&1) r.pb(1<<i);
     }
    if (!r.size()) {cout<<endl;continue;}
    cout<<r[0];
    loop(i,1,r.size()) cout<<' '<<r[i];
    cout<<endl;
  }
  bye;
}

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

int main() {
	int w;
	while (std::cin >> w) {
		std::vector<int> scales;
		while (w != 0) {
			int s = w % 2;
			scales.push_back(s);
			if (s == 1) w--;
			w = w / 2;
		}
		int weight = 0;
		bool first = false;
		for (std::vector<int>::iterator itr = scales.begin(); itr != scales.end(); ++itr) {
			if (weight == 0) weight = 1;
			else weight = weight * 2;
			if (*itr == 1) {
				if (first) std::cout << " ";
				std::cout << weight;
				first = true;
			}
		}
		std::cout << std::endl;
	}

	return 0;
}

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

int main(){
	int n;
	while( cin >> n ){
		for( int i=0; i<10; i++ ){
			if( n & (1<<i) ){
				cout << (1<<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==v.end())?cout<<endl:cout<<" ";
    }
    v.clear();
  }
  return 0;
}

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

int main() {
	int g;
	int num[]={1,2,4,8,16,32,64,128,256,512};
	stack<int> ans;
	while(cin>>g){
		for(int i=9;i>=0;i--){
			if(g>=num[i]){
				g-=num[i];
				ans.push(num[i]);
			}
		}while(!ans.empty()){
			cout<<ans.top()<<" ";
			ans.pop();
		}cout<<endl;
	}
}

C++: #include<cstdio>

using namespace std;

const int Weit=2;
int weit;
int date;
bool flag;

int main()
{
	while(scanf("%d",&date)!=EOF)
	{
		flag=true;
		for(int i=0;i<10;i++)
		{
			if(i==0)weit=Weit;
			else weit*=2;
			if(date%weit!=0)
			{
				date-=date%weit;
				if(flag==true) flag=false;
				else printf(" ");
				printf("%d",weit/2);
			}
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
  int x;
  vector<int> v;

  while (scanf("%d ", &x) == 1) {
    v.clear();
    int omori = 512;
    while (x > 0) {
      if (x >= omori) {
	x -= omori;
	v.push_back(omori);
      }
      omori /= 2;
      //cout << x << endl;
    }
    for (int i = v.size() - 1; i >= 0; i--) {
      cout << v[i];
      if (i == 0) {cout << endl;}
      else {cout << " ";}
    }
  }
  return 0;
}