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

int main() {
	int n;
	while (cin >> n) {
		bool first = true;
		for (int i = 0; i < 10; i++) {
			if (n & (1<<i)) {
				if (first)
					first = false;
				else
					cout << " ";
				cout << (1<<i);
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int tmp[10]={512,256,128,64,32,16,8,4,2,1};
  int in;
  while(cin>>in){
    vector<int>out;
    rep(i,10)if(in>=tmp[i]){in-=tmp[i];out.pb(tmp[i]);}
    sort(all(out));
    rep(i,out.size()-1)cout<<out[i]<<" ";
    cout<<out[out.size()-1]<<endl;
  }
}

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

int main() {
	int n;
	while (cin >> n) {
		int pow[10] = {}, p = 0, rem, quo;
		while (1) {
			rem = n % 2; quo = n / 2;
			if (rem) {
				pow[p]++;
			}
			if (quo == 0) break;
			p++;
			n = quo;
		}
		for (int i = 0, j = 0, r = 1; i < 10; i++, r *= 2) {
			if (pow[i]) {
				if (j) cout << " ";
				cout << r;
				j++;
			}
		}
		cout << endl;
	}
}

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

int main(){
  int w,flag;
  int b[10]={0};

  while(std::cin >> w){
    for(int i=0;i<10;i++){
      b[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(w>=std::pow(2,i)){
        w = w - std::pow(2,i);
        b[i] = 1;
      }
    }
    flag = 1;
    for(int i=0;i<10;i++){
      if(flag){
        std::cout << std::pow(2,i);
        flag = 0;
        continue;
      }
      if(b[i] == 1){
        std::cout << ' ' << std::pow(2,i);
      }
    }
    std::cout << std::endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
      int a,i;
      while(cin>>a){
            for(i=0;i<=9;i++){
                  if(a&(1<<i)){
                        cout<<(1<<i);
                        if(a<(2<<i))break;
                        cout<<' ';
                  }
            }
            cout<<endl;
      }
}

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

int main(){
	int n;
	while(cin >> n){ 
		int weight[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		for(int i = 9; i >= 0; i--){
			if(n >= pow(2, i)){
				n -= pow(2, i);
				weight[i] = 1;
			}
		}

		int i;
		for(i = 0; i < 10; i++){
			if(weight[i]){
				cout << pow(2, i);
				break;
			}
		}
		for(; i < 10; i++){
			if(weight[i]){
				cout << " " << pow(2, i);
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
	int n,a[10],c;
	
	while(cin>>n){
		c=0;
		for(int i=0;i<10;i++) a[i]=0;
		for(int i=9;i>=0;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				a[i]++;
			}
		}
		for(int i=0;i<10;i++){
			if(a[i]!=0){
				if(c!=0) cout << " ";
				cout << pow(2,i);
				c++;
			}
		}
		cout << endl;
	}
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a;
  int i = 0;
  while (cin >> a) {
    while (1) {
      a -= pow(2, i);
      if (a == 0) {
        for (int j = 0; j <= i; j++) {
          cout << pow(2, j) << ' ';
        }
        cout << endl;
        i = 0;
        break;
      } else {
        i++;
      }
    }
  }
  return 0;
}

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

int main() {
    int weight;
    while (cin >> weight) {
        for (int i = 0; weight > 0; weight /= 2, i++) {
            if (weight % 2 == 1) {
                cout << pow(2, i) << " ";
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		vector<int>ans;
		while (N != 0) {
			if (N - 512 >= 0) {
				N -= 512;
				ans.push_back(512);
			} else if (N - 256 >= 0) {
				N -= 256;
				ans.push_back(256);
			} else if (N - 128 >= 0) {
				N -= 128;
				ans.push_back(128);
			} else if (N - 64 >= 0) {
				N -= 64;
				ans.push_back(64);
			} else if (N - 32 >= 0) {
				N -= 32;
				ans.push_back(32);
			} else if (N - 16 >= 0) {
				N -= 16;
				ans.push_back(16);
			} else if (N - 8 >= 0) {
				N -= 8;
				ans.push_back(8);
			} else if (N - 4 >= 0) {
				N -= 4;
				ans.push_back(4);
			} else if (N - 2 >= 0) {
				N -= 2;
				ans.push_back(2);
			} else {
				N--;
				ans.push_back(1);
			}
		}

		SORT(ans);
		REP(i, ans.size()) {
			cout << ans[i] << " ";
		}
		cout << "\n";
	}
	return 0;
}

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

int main()
{
	int w;
	while (cin >> w)
	{
		int weight[] = {512,256,128,64,32,16,8,4,2,1};
		bool used[] = {false,false,false,false,false,false,false,false,false,false};
		int i = 0;
		while (w > 0 && i < 10)
		{
			if (w < weight[i])
			{
				i++;
			}
			else
			{
				w -= weight[i];
				used[i] = true;
				i++;
			}
		}
		bool f = false;
		for (i = 9; i >= 0; i--)
		{
			if (used[i])
			{
				if (!f)cout << weight[i];
				else cout << " " <<weight[i];
				f = true;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n){
    int s=0,a[10],k=0;
    for(int i=512;i>0;i/=2)if(n>=i){
        a[k++]=i;
	n-=i;
      }
    for(int i=k-1;i>=0;i--,s++){
      if(!s)cout<<a[i];
      else cout<<' '<<a[i];
    }
    cout<<endl;
  }
}