Go: 
package main

import (
	"fmt"
	"math"
)

func solve(n int) int {
	i := 0
	for {
		if val := math.Pow(2, float64(i)); val*2 > float64(n) {
			return int(val)
		}
		i++
	}
}

func main() {
	for {
		var n int
		_, err := fmt.Scan(&n)
		if err != nil {
			break
		}

		res := []int{}
		for {
			val := solve(n)
			res = append(res, val)
			n -= val

			if n <= 0 {
				break
			}
		}

		for i := range res {
			if i != 0 {
				fmt.Print(" ")
			}
			fmt.Print(res[len(res)-i-1])
		}
		fmt.Println()
	}
}

C++: #include<iostream>
#include<vector>
int n=1024;
std::vector<int> g;

int main(){
	int a;
	while(std::cin>>a){
		int n_=0;
		bool f=true;
		while(1){
			if(n<a&&f)g.push_back(n),a-=n,n_=n,f=false;
			else if(n<a)g.push_back(n),a-=n;
			else n/=2;
			if(a==1){
				g.push_back(1);
				break;
			}
		}
		
		for(auto it = g.rbegin();it!=g.rend();++it){
			std::cout<<*it;
			if(*it!=n_)std::cout<<" ";
		}
		std::cout<<std::endl;
		n=1024;
	}
	return 0;
}

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

int main() {
int n,m;
while(cin>>n){
	m=0;
	int wa=2;
	for (int k=0;k<=10;k++){
		if(n%wa!=0){
			if(m!=0){
				cout<<" ";
			}
			cout<<wa/2;
			n=n-wa/2;
			m=m+1;
		}
	wa=wa*2;
}
cout<<endl;
}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>

int i,j,k;
int n,flag[15],a=1,b=1;

int main(){
	while(scanf("%d",&n)!=EOF){
		while(n>=1)flag[a]=n%2*b,n/=2,a++,b*=2;
		for(i=1;i<11;i++)if(flag[i]!=0)printf("%d ",flag[i]);
		//printf("\n");
		for(i=1;i<11;i++)flag[i]=0;a=1;b=1;
	}
	return 0;
}

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

int main(){
    int n;
    while( cin >> n ){
        int m = 1, c = 0;
        while(n > 0){
            if( n%2 ){
                if( c ) cout << ' ';
                cout << m;
            }
            m *= 2;
            n /= 2;
            c = 1;
        }
        cout << endl;
    }
    return 0;
}

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


int main(){
	int weight[11];
	weight[0] = 1;
	for(int i = 1;i<=10;i++)weight[i]=2*weight[i-1];
	while(true)
	{
	int object;
	cin >> object;
	if (cin.eof())break;
	int j = 0;
	for(int i = 0;i <=9;i++){
		if((object % 2)==1)
			{
			cout << weight[i];
			if(object == 1) break;
			else cout << " ";
			}
		object = object /2;
		}
	cout << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    bool f = false;
    for(int i=1;i<=512;i*=2){
      if(n%2 == 1){
	if(f) cout <<" ";
	cout<<i;
	f = true;
      }
      n/=2;
    }
    cout <<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

template <class Type>
Type power(Type X, int Y)
{
	Type Ans = 1;

	if (Y >= 0)
	{
		for (int i = 0; i < Y; i++)
		{
			Ans *= X;
		}
	}
	else
	{
		for (int i = 0; i < (-Y); i++)
		{
			Ans /= X;
		}
	}

	return Ans;
}

int main()
{
	int N;

	while (cin >> N)
	{
		for (int i = 0; i < 10; i++)
		{
			if ((N / power<int>(2, i)) % 2 == 1)
			{
				cout << power<int>(2, i) << ' ';
			}
		}

		cout << char(127) << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

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

bool tukauka[10];//大きい順

int n,owari;
int main(){
	cin >> n;
	for(int i = 0;i < 10; i++) {
		if(n >= omosa[i])tukauka[i] = true, n -= omosa[i],owari=i;
	}
	for(int i = 0; i < 10; i++) {
		if(tukauka[9 - i]&&i==owari) {
			cout << omosa[9 - i] ;
		}else {
			cout<< omosa [ 9 - i]<<" ";
		}
	}
	cout << endl;
	return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n;

int main(){
	while(cin>>n){
		int two=1;
		vi ans;
		for(int i=0;i<10;i++){
			two*=2;
			if(n%two){
				n-=two/2;
				ans.push_back(two/2);
			}
		}
		for(int i=0;i<ans.size()-1;i++) cout<<ans[i]<<' ';
		cout<<ans[ans.size()-1]<<endl;
	}
}

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

using namespace std;

int main(void){

	int inp,arr[100],cnt;
	int wei[]={1,2,4,8,16,32,64,128,256,512};

	while(cin>>inp){
		cnt=0;
		for(int i=9;inp!=0;i--){
			if(inp-wei[i]>=0){
				inp-=wei[i];
				arr[cnt]=wei[i];
				cnt++;
			}
		}
		for(int j=cnt-1;j>=0;j--){
			cout<<arr[j];
			if(j==0) cout<<endl;
			else cout<<" ";
		}
	}

	return 0;
}

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

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

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

int main() {
  int a[10];
  int n;
  int x;

  a[0] = 1;
  for (int i=1; i<10; i++) {
    a[i] = a[i-1] << 1;
  }

  while (cin >> n) {
    for (int i=0; i<10; i++){
      x = n & 1;
      n >>=1;
      if (x) {
        if (n) {
          cout << a[i] << " ";
        } else {
          cout << a[i] << endl;
        }
      }
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a;
	while (cin >> a){
		bool b = false;
		if (a % 2 == 1){
			cout << '1';
			b = true;
			a -= 1;
		}
		if (a % 4 == 2){
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 2;
			a -= 2;
		}
		if (a % 8 == 4) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 4;
			a -= 4;
		}
		if (a % 16 == 8) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 8;
			a -= 8;
		}
		if (a % 32 == 16) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 16;
			a -= 16;
		}
		if (a % 64 == 32) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 32;
			a -= 32;
		}
		if (a % 128 == 64) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 64;
			a -= 64;
		}
		if (a % 256 == 128) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 128;
			a -= 128;
		}
		if (a % 512 == 256) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 256;
			a -= 256;
		}
		if (a % 1024 == 512) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 512;
			a -= 512;
		}
		cout << endl;
	}
}

C++: import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			int w = scan.nextInt();
			int i = 1;
			StringBuffer sb = new StringBuffer();
			sb.setLength(0);
			while(w / 2 > 1){
				if(w % 2 == 1){
					sb.append(i).append(' ');
				}
				w /= 2;
				i = i << 1;
			}
			sb.append(i);
			String s = sb.toString().trim();
			System.out.printf("%s\n", s);
		}
	}
}

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

using namespace std;

// 問題に出てくる分銅の質量は2のn乗
// 下位のビットから1ビットずつ確認していく

int main() {
	int w;
	while (cin >> w) {
		string weights;

		// 対応するビットが1になっている確認。
		// 対応していたら値を出力する
		for (int bit = 1; bit < 1024; bit <<= 1) {
			if (bit & w) {
				weights.append(to_string(bit));
				weights.push_back(' ');
			}
		}
		// 最後のスペースを改行に置き換え
		weights.back() = '\n';
		cout << weights;
	}
	return 0;
}