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<cmath>
#include<bitset>
int main(){
    int t; 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))<<" "; num/=10;}
    std::cout<<std::endl;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int ta[]={1,2,4,8,16,32,64,128,256,512},n;
	while(cin>>n){
	vector<int>ans(0);
	for(int i=9;i>=0;i--){
	if(n>=ta[i]){ans.push_back(ta[i]);n-=ta[i];}
	}
	reverse(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){cout<<ans[i];if(i==ans.size()-1)cout<<endl;else cout<<" ";}
	}
	return 0;
}

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

int main(){
int n;
vector<int>v;
while(cin>>n)
{
	if(n%2==1){
		n-=1;
		v.push_back(1);
		}
		
	if(n%4==2){
		n-=2;
		v.push_back(2);
		}	
		
	if(n%8==4){
		n-=4;
		v.push_back(4);
		}	
		
	if(n%16==8){
		n-=8;
		v.push_back(8);
		}	
		
	if(n%32==16){
		n-=16;
		v.push_back(16);
		}	
		
	if(n%64==32){
		n-=32;
		v.push_back(32);
		}	
		
	if(n%128==64){
		n-=64;
		v.push_back(64);
		}	
		
	if(n%256==128){
		n-=128;
		v.push_back(128);
		}	
		
	if(n%512==256){
		n-=256;
		v.push_back(256);
		}	
		
	if(n%1024==512){
		n-=512;
		v.push_back(512);
		}	
		int a=v.size();
		for(int i=0;i<a;i++){
			cout<<v[i];
			if(i==a-1){
				cout<<endl;
				}
			else{
				cout<<" ";
				}	
			}
	}
	return 0;
		}

C++: #include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int main(){
		
	int wg;
	
	while(cin>>wg, !cin.eof()){
		
		queue<int> qu;
		int fundoh = 1;
		
		for(int i=0; i < 10; ++i){
		
			if( BIT(wg, i) )
				qu.push(fundoh);
				
			fundoh*=2;
		}
		
		while(!qu.empty()){
			
			cout << qu.front();
			qu.pop();
			
			if(!qu.empty())
				cout << ' ';
		}
		
		cout << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<memory.h>
using namespace std;
const int g[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
int f[10] = { 0 };
vector<int> p;
int main()
{
	
	while (1){
		p.clear();
		memset(f, 0, sizeof(f));
		int n;
		cin >> n;
		while (n != 0){
			for (int i = 9; i >= 0; i--){
				if (n - g[i] >= 0 && f[i] == 0){
					n -= g[i];
					f[i] = 1;
					p.push_back(g[i]);
				}
			}
		}
		for (int i = p.size() - 1; i >= 1; i--){
			cout << p[i] << " ";
		}
		cout << p[0] << endl;
	}
}

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

int main(void){
	int n;
	while(cin>>n){
		int m[10]={0};
		int i=0;
		for(int max = 1024;max /= 2;max<1){
			if(n>=max){
//				cout<<max<<" "<<n<<endl;
				n=n-max;
				m[i++]=max;
//				cout<<max<<endl;
			}
		}
		
		sort(m,m+10);
		for(int i=0;i<10;i++)
			if(m[i]!=0)cout<<m[i]<<" ";
		cout<<endl;
	}
}

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

int main(){
  int n;
  while(cin>>n){
    vector<int> a(10);
    a[0]=512;
    a[1]=256;
    a[2]=128;
    a[3]=64;
    a[4]=32;
    a[5]=16;
    a[6]=8;
    a[7]=4;
    a[8]=2;
    a[9]=1;
    vector<int> ans;
    for(int i=0;i<10;i++){
      if(n>=a[i]){
        n-=a[i];
        ans.push_back(a[i]);
      }
    }
    for(int i=ans.size()-1;i>=0;i--){
      if(i!=ans.size()-1)cout<<" ";
      cout<<ans[i];
    }
    cout<<endl;
  }
}

C++: #include <iostream>

int main(){
	int a,b,c;
	int d[10];
	
	
	while(std::cin>>a){
		for(b=1;b<=10;b++){
		d[b]=0;
		}
		
		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+64){
			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{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		int n=0;
		for(int m=1;m<11;m++){
		if(d[m]!=0&&n==0)
		{
			std::cout<<d[m];
			n++;
		}
		else if(d[m]!=0){
			std::cout<<" "<<d[m];
		}
	}
	std::cout<<std::endl;
	}
	return 0;
}

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

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

  return 0;
}

C++: //AOJ 0031

#include<stdio.h>
#include<iostream>
#include<vector>

using namespace std;

int main(){

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

	int num;

	while(cin>>num){
		int tmp=0;
		for(int j=0;j<10;j++){

			if(num%2==1){
				if(tmp==0){
					printf("%d",data[j]);
				}
				else{
					printf(" %d",data[j]);
				}
				num/=2;
			}

			printf("\n");
		}

	}
	return 0;
}