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++: //53
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n;){
    bool out=false;
    for(int i=0;i<=9;i++){
      if(n&1<<i){
	if(out){
	  cout<<' ';
	}
	out=true;
	cout<<(1<<i);
      }
    }
    cout<<endl;
  }
  return 0;
}

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

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n;
  while(cin>>n){
    int i = 1;
    while(i != 1024){
      if((n&i)!=0)
	printf("%d ",i);
      i <<= 1;
    }
    puts("");
  }
  return 0;
}

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

using namespace std;

int main(){
  vector<int> weightarray;
  int weight;
  while(cin>>weight){
    weightarray.push_back(weight);
  }
  for(auto weight:weightarray){
    bool first=true;
    for(int i=0;i<sizeof(weight)*8;i++){
      int bit=1<<i;
      if(weight&bit){
        if(!first)cout<<" ";
        first=false;
        cout<<bit;
      }
    }
    cout<<endl;
  }
}

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<iostream>
using namespace std;

int main(void)
{
	int n;
	while(cin >> n)
	{
		int e = 1;
		for(int i=0; i<=10; i++)
		{
			if( (n & e) == e )
			{
				if(e==1)
					cout << "1";
				else
					cout << " " << e;
			}
			e *= 2;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int x;
	while(cin>>x){
		vector<int>ans;
		for(int i=0;i<10;i++){
			if((x>>i)&1)ans.push_back(1<<i);
		}
		for(int i=0;i<ans.size();i++){
			if(i>0)cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
	int weight;
	int i,j;
	int ans[10];
	int flag;
	
	for(;cin >> weight;)
	{
		for(i=0;i<10;i++)
			ans[i]=0;
			
		for(i=0;weight>0;weight/=2,i++)
		{
			ans[i]=weight%2;
			if(weight%2==1)
				flag=i;
		}
		
		for(i=0,j=1;i<10;i++,j*=2)
		{
			if(ans[i]==1 && i<flag)
				cout << j << " " ;
			if(i==flag)
				cout << j ;
				
		}
		cout << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
    int input;
    const int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    bool check[10];

    while (cin >> input) {
        for (int i = 0; i < 10; i++)
            check[i] = false;

        int tmp = input;
        for (int i = 0; tmp != 0; i++) {
            if (tmp % 2)
                check[i] = true;
            tmp /= 2;
        }

        int max = 0;
        for (int i = 0; i < 10; i++)
            if (check[i] && i > max)
                max = i;

        for (int i = 0; i < max; i++)
            if (check[i])
                cout << weight[i] << " ";
        cout << weight[max] << endl;
    }

    return 0;
}

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

using namespace std;

int main(void)
{
    int a;
    while ( scanf("%d", &a) != EOF) {
        bool fl;
        for (int i = 0; i < 10; i++) {
            if ((a&1) == 1) {
                if (fl) {
                    cout << " ";
                } else { 
                    fl = true;
                }
                cout << (1<<i);
            } 
            a >>= 1;
        }
        puts("");
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int weight[10] = {1};
	for(int i = 1; i < 10; i++){
		weight[i] = weight[i-1]*2;
	}
	int n;
	while(cin >> n){
		vector<int> ans;
		for(int i = 10; i >= 0; i--){
			if(weight[i] < n){
				n -= weight[i];
				ans.pb(weight[i]);
			}
		}
		for(int i = ans.size(); i >=0; i--){
			if(i == 0)cout << ans[i] << endl;
			else cout << ans[i] << " ";
		}
	}


	return 0;
}

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, tmp, *array, tmp2;
	
	while(cin >> n){
		array = (int *)calloc(10, sizeof(int));
		tmp2 = 0;
		while(n > 0){
			tmp = 1;
			while(n >= tmp){
				tmp *= 2;
			}
			tmp /= 2;
			array[tmp2++] = tmp;
			n -= tmp;
		}
		tmp2--;
		cout << array[tmp2];
		for(int i = tmp2 - 1; i >= 0; i--){
			cout << " " << array[i];
		}
		cout << endl;
		free(array);
	}
	
	return 0;
}

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

int main() {
    int n;
    int weights[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
    
    while (cin >> n) {
        vector<int> result;
        for (int i = 0; i != 10; ++i) {
            if (n - weights[i] >= 0) {
                n -= weights[i];
                result.push_back(weights[i]);
            }
        }
        sort(result.begin(), result.end());

        for (int i = 0; i != result.size()-1; ++i) {
            cout << result[i] << " ";
        }
        cout << result[result.size()-1];
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void){
	int w;
	char s[100];
	int st = 0;
	int i = 0;
	while(scanf("%d", &w) != EOF){
		st = i = 0;
		while(10 > i){
			if(w & 1 == 1){
				st += sprintf(s+st, "%d ", 1<<i);
			}
			w >>= 1;
			i++;
		}
		s[st - 1] = '\0';
		puts(s);
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main(){
	int w[] = {1,2,4,8,16,32,64,128,256,512};
	int n;
	while(cin >> n){
		int flag[10], num[10];
		int end = 0;
		for(int i = 0;i < 10;i++){
			flag[i] = 0;
			num[i] = 0;
		}
		num[0] = n;
		for(int i = 0;i < 10;i++){
			flag[i] = num[i] % 2;
			num[i+1] = num[i] / 2;
			if(num[i+1] == 0) break;
		}
		for(int i = 0;i < 10;i++){
			if(flag[i] == 1) end = i; 
		}
		for(int i = 0;i < 10;i++){
			if(i == end) cout << w[i] << endl;
			else if(flag[i] == 1) cout << w[i] << " ";
		}

	}
	return 0;
}