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 <stdio.h>

int quo,rem;

void divide_by_2(int x) {

  quo=x/2;
  rem=x%2;

}

int main(void) {

  int w;

  int count;

  while(scanf("%d",&w)!=EOF) {

    count=1;
    quo=w;

    while(quo>0) {

      divide_by_2(quo);
      
      if(rem==1) printf("%d ",count);

      count*=2;

    }

    puts("");

  }

  return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  unsigned int n;
  int p;
  bool f;
  while(cin>>n){
    p=1;
    f=false;
    while(n!=0){
      if(n&1==1){
	if(f){
	  cout<<" ";
	}
	else{
	  f=true;
	}
	cout<<p;
      }
      n=n>>1;
      p*=2;
    }
    cout<<endl;
  }
}

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

using namespace std;

int main(){
  int n;
  while(cin >> n){
    if(cin.eof())break;
    vector<int> ar;
    int flg = 0;
    for(int i = 1024 ; i>=1; i /=2){
   
      if(n >= i&&flg == 0){
	cout << i;
	flg = 1;
	n-=i; 
	continue;
      }
      if(n >= i&&flg == 1){
	cout <<" "<< i;
	n-=i; 
      }
    }
  }
  return 0;
}

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

int main() {
  int w;
  while(cin >> w) {
    for(int i = 0, cnt = 0; w; ++i) {
      if(w & (1<<i)) {
	if(cnt) cout << " ";
	++cnt;
	cout << (1<<i);
	w &= ~(1<<i);
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int n;
  int a[10] = {1,2,4,8,16,32,64,128,256,512};
  while (cin >> n) {
    stack<int> s;
    for (int i = 9; i >= 0; i--) {
      if (n >= a[i]) {
        n -= a[i];
        s.push(a[i]);
      }
    }
    int m = s.size() - 1;
    while (m--) {
      cout << s.top() << " ";
      s.pop();
    }
    cout << s.top() << endl;
  }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <assert.h>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int main() {
	int w;
	while (cin >> w) {
		int bun = 1;
		int flg = 0;
		while (bun != 1024) {
			if (w % (2 * bun)) {
				if (flg) cout << ' ';
				cout << bun;
				w -= bun;
				flg++;
			}
			bun *= 2;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

bool a[10];

    int main(){

    int N;
    int i=0;
    
    while(!cin.eof())
    {
        cin>>N;
        for(int k=9;k>-1;k--){
            
            if(i+(pow(2,k)) <= N){
                i += pow(2,k);
                a[k] = 1;
            }
        }
        
        bool last = false;
        for(int k=0;k<10;k++){
            
            if(a[k] ==1)
            {
                if(last){
                    cout<<" ";
                }
                last =true;
                cout<<pow(2,k);    
            }        
        }
 
        cout<<endl;
    }
}

C++: #include <stdio.h>

int quo,rem;

void divide_by_2(int x) {

  quo=x/2;
  rem=x%2;

}

int main(void) {

  int w;

  int count;

  while(scanf("%d",&w)!=EOF) {

    count=1;
    quo=w;

    while(quo>0) {

      divide_by_2(quo);
      
      if(rem==1) printf("%d ",count);

      count*=2;

    }

    printf("\n");

  }

  return 0;

}

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

const vector<int> v = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main() {
  int n;
  vector<int> sum(1024, 0);
  for (int i = 0; i <= 1024; ++i) {
    for (int j = 0; j < 10; ++j) {
      if ((i >> j) & 1) sum[i] += v[j];
    }
  }
  while (cin >> n) {
    int pos = 0;
    for (int i = 0; i <= 1024; ++i) {
      pos = i;
      if (sum[i] == n) break;
    }
    bool ok = false;
    for (int i = 0; i <= 10; ++i) {
      if ((sum[pos] >> i) & 1) {
        if (ok) {
          cout << ' ';
        } else {
          ok = true;
        }
        cout << (1 << i);
      }
    }
    cout << endl;
  }
  return 0;
}

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

int hoge(int s, int n) {
    int w = pow(2,n);

    if (n == -1)
        return 0;

    if (w == s) {
        cout << w;
        return 1;
    }

    if (w < s && hoge(s-w, n-1)) {
        cout << " " << w;
        return 1;
    }

    if (hoge(s, n-1)) {
        return 1;
    }

    return 0;
}

int main(void) {
    int s;
    while (cin >> s) {
        hoge(s, 9);
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: //0031
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl;
#define CIN(x) cin>>(x);

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

int main(){

	int w;
	while (1){
		stack <int> st;
		CIN(w)
		for (int i = 10; i >= 0; i--){
			if (w >= weight[i]) {
				st.push(weight[i]);
				w -= weight[i];
			}
		}

		while (st.top()!=0){
			cout << st.top()<<" ";
				st.pop();
		}
		cout << endl;
	}

	return 0;

}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int main(){
  vector<int> ar;
  int g[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int n;
  while(cin >> n){
    for(int i=9;i>=0;i--){
      if(n>=g[i]){
	n -= g[i];
	ar.push_back( g[i] );
      }
    }
    for(int i=ar.size()-1;i>=0;i--){
      if(i != 0)cout << ar[i] << ' ';
      else cout << ar[i] << endl;
    }
  }
}

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

int main(){
    bool fundo[10] = {false};
    int value[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

    int weight;

    while(cin >> weight){
        for(int i=0; i<=9; i++){
            if(weight % 2 == 1){
                fundo[i] = true;
            }
            weight /= 2;
        }

        for(int i=0; i<=9; i++){
            if(fundo[i] == true){
                if(i) printf(" ");
                printf("%d", value[i]);
                fundo[i] = false;
            }
        }
        cout << endl;
    }

    return 0;
}