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

C++: #include<iostream>
using namespace std;
int main()
{
int a;
int i[10][3];
i[0][2]=1;
i[1][2]=2;
i[2][2]=4;
i[3][2]=8;
i[4][2]=16;
i[5][2]=32;
i[6][2]=64;
i[7][2]=128;
i[8][2]=256;
i[9][2]=512;
while(cin>>a)
{
    for(int h=0;h<10;h++)
    {
        i[h][0]=0;
        i[h][1]=0;
    }
    for(i[0][0]=0;i[0][0]<=1;i[0][0]++)
    {
    for(i[1][0]=0;i[1][0]<=2;i[1][0]+=2)
    {
    for(i[2][0]=0;i[2][0]<=4;i[2][0]+=4)
    {
    for(i[3][0]=0;i[3][0]<=8;i[3][0]+=8)
    {
    for(i[4][0]=0;i[4][0]<=16;i[4][0]+=16)
    {
    for(i[5][0]=0;i[5][0]<=32;i[5][0]+=32)
    {
    for(i[6][0]=0;i[6][0]<=64;i[6][0]+=64)
    {
    for(i[7][0]=0;i[7][0]<=128;i[7][0]+=128)
    {
    for(i[8][0]=0;i[8][0]<=256;i[8][0]+=256)
    {
    for(i[9][0]=0;i[9][0]<=512;i[9][0]+=512)
    {
    if(i[0][0]+i[1][0]+i[2][0]+i[3][0]+i[4][0]+i[5][0]+i[6][0]+i[7][0]+i[8][0]+i[9][0]==a)
    {
    for(int j=0;j<10;j++)
    {
    if(i[j][0]!=0)
    {
    i[j][1]++;
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    int l=0;
    for(int k=0;k<10;k++)
    {
    if(l==0&&i[k][1]>0)
    {
    cout<<i[k][2];
    l++;
    }
    else if(i[k][1]>0)
    {
    cout<<" "<<i[k][2];
    }
    }
    cout<<endl;
}
return 0;
}

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

int main(){
  int n;
  while(cin>>n){
    int last = -1;
    for(int i=0;i<10 && (1<<i) <= n;i++){
      if(( (1<<i) & n )>>i == 0x1){
	if(last !=-1){
	  cout<<last<<" ";
	}
	last = (1<<i);
      }
    }
    if(last != -1)
      cout<<last;
    cout<<endl;
  }
  return 0;
}