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 <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];
	weight[0] = 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]);
			}
			if(n == 0)break;
		}
		for(int i = ans.size()-1; i > 0; i--){
			//if(i == 1)cout << ans[i] << endl;
			//else 
				cout << ans[i] << " ";
		}
	}


	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<bitset>
#include<sstream>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int x;
    bool first;
    int i;
    int g;
    while(cin >> x){
        first = true;
        g = 1;
        int ans[10] = {0};
        for(i = 0; x > 1; i++){
            ans[i] = x % 2;
            x /= 2;
        }ans[i] = x;
        rep(j,10){
            if(ans[j] == 1 && first == true){
                cout << g;
                first = false;
            }else if(ans[j] == 1){
                cout << " " << g;
            }g *= 2;
        }cout << endl;
    }
}

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

int main() {
	ios :: sync_with_stdio(false);
	for(int n; cin >> n; ) {
		for(int i = 0; i < 10; i ++) if((n >> i) & 1) {
			n -= (1 << i);
			cout << (1 << i) << (n ? ' ' : '\n');
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    int w[10];
    w[0]=1;
    for (int i=1;i<10;++i) {
        w[i]=w[i-1]<<1;
    }
    while (scanf("%d",&n)!=EOF) {
        int tmp=0;
        stack<int> st;
        for (int i=9;i>=0;--i) {
            if (w[i]<=n) {
                st.push(w[i]);
                n-=w[i];
                tmp++;
            }
        }
        for (int i=0;i<tmp;++i) {
            printf("%d ",st.top());
            st.pop();
        }
        printf("\n");
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;




int main(){


	int n,m;
	while (cin >> n){
		stack<int> stack;
		m = 512;
		while (m){
			if (n >= m){
				stack.push(m);
				n -= m;
			}
			m /= 2;
		}
		int k(0);
		if (!stack.empty()){
			k += stack.top();
			cout << stack.top();
			stack.pop();
		}
		while (!stack.empty()){
			cout << " ";
			k += stack.top();
			cout << stack.top();
			stack.pop();
		}
		cout << ":::::::"  << k;
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int x;
    while(cin>>x){
        for(int i=0; i<1023; i++){
            int bit =i;
            int sum =0;
            for(int j=0; j<10; j++){
                if(bit%2==1){
                    sum+=weight[j];
                }
                bit=bit>>1;
            }
            
            if(sum == x){
                int flag = 0;
                for(int j=0; j<10; j++){
                    if(i%2==1&&flag==0){
                        cout<<weight[j];
                        flag++;
                    }else if(i%2==1){
                        cout<<" "<<weight[j];
                    }
                    i=i>>1;
                }
                cout<<endl;
                break;
            }
            
            
            
        }
    }
    return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		int ans[10] = {};
		while(n >= 512){
			n -= 512;
			ans[9]++;
		}
		while(n >= 256){
			n -= 256;
			ans[8]++;
		}
		while(n >= 128){
			n -= 128;
			ans[7]++;
		}
		while(n >= 64){
			n -= 64;
			ans[6]++;
		}
		while(n >= 32){
			n -= 32;
			ans[5]++;
		}
		while(n >= 16){
			n -= 16;
			ans[4]++;
		}
		while(n >= 8){
			n -= 8;
			ans[3]++;
		}
		while(n >= 4){
			n -= 4;
			ans[2]++;
		}
		while(n >= 2){
			n -= 2;
			ans[1]++;
		}
		while(n >= 1){
			n -= 1;
			ans[0]++;
		}

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


}

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

int main()
{

	int weight = 0;
	while (std::cin >> weight)
	{
		std::bitset<10> bit(weight);

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

	return 0;
}

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&&b[i]){
        std::cout << std::pow(2,i);
        flag = 0;
        continue;
      }
      if(b[i]){
        std::cout << ' ' << std::pow(2,i);
      }
    }
    std::cout << std::endl;
  }
}

C++: #include<iostream>
using namesapce std;
int main(){
  int n,bell,heavy[1000]={0};
  while(cin >> n){
    bell=0;
    if(n>=512){
      n-=512;
      heavy[512]++;
    }
    if(n>=256){
      n-=256;
      heavy[256]++;
    }
    if(n>=128){
      n-=128;
      heavy[128]++;
    }
    if(n>=64){
      n-=64;
      heavy[64]++;
    }
    if(n>=32){
      n-=32;
      heavy[32]++;
    }
    if(n>=16){
      n-=16;
      heavy[16]++;
    }
    if(n>=8){
      n-=8;
      heavy[8]++;
    }
    if(n>=4){
      n-=4;
      heavy[4]++;
    }
    if(n>=2){
      n-=2;
      heavy[2]++;
    }
    if(n>=1){
      n-=1;
      heavy[1]++;
    }
    for(int i=512;i!=0;i/=2){
      if(heavy[i]!=0){
	if(bell==0){
	  cout << i << endl;
	}
	else{
	  cout << " " << i;
	}
      }
    }
    cout << endl;
  }
  return (0);
}