Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}

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

int main() {
	int w;
	while (std::cin >> w) {
		std::vector<int> scales;
		while (w != 0) {
			int s = w % 2;
			scales.push_back(s);
			if (s == 1) w--;
			w = w / 2;
		}
		int weight = 0;
		bool first = false;
		for (std::vector<int>::iterator itr = scales.begin(); itr != scales.end(); ++itr) {
			if (weight == 0) weight = 1;
			else weight = weight * 2;
			if (*itr == 1) {
				if (first) std::cout << " ";
				std::cout << weight;
				first = true;
			}
		}
		std::cout << std::endl;
	}

	return 0;
}

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

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

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int p2[10] = {512,256,128,64,32,16,8,4,2,1},n;
  vector<int> v;
  while(cin>>n){
    for(int i=0;i<10;i++){
      if(n>=p2[i])n-=p2[i],v.push_back(p2[i]);
    }
    sort(v.begin(),v.end());
    vector<int>::iterator it=v.begin();
    for(;it!=v.end();it++){
      cout<<*it;
      (it==v.end())?cout<<endl:cout<<" ";
    }
    v.clear();
  }
  return 0;
}

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<cstdio>

using namespace std;

const int Weit=2;
int weit;
int date;
bool flag;

int main()
{
	while(scanf("%d",&date)!=EOF)
	{
		flag=true;
		for(int i=0;i<10;i++)
		{
			if(i==0)weit=Weit;
			else weit*=2;
			if(date%weit!=0)
			{
				date-=date%weit;
				if(flag==true) flag=false;
				else printf(" ");
				printf("%d",weit/2);
			}
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
  int x;
  vector<int> v;

  while (scanf("%d ", &x) == 1) {
    v.clear();
    int omori = 512;
    while (x > 0) {
      if (x >= omori) {
	x -= omori;
	v.push_back(omori);
      }
      omori /= 2;
      //cout << x << endl;
    }
    for (int i = v.size() - 1; i >= 0; i--) {
      cout << v[i];
      if (i == 0) {cout << endl;}
      else {cout << " ";}
    }
  }
  return 0;
}

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

using namespace std;

void Solution()
{
    int a[10]={1,2,4,8,16,32,64,128,256,512};
    
    int n;
    
    stack<int> save;
    
    while(cin>>n)
    {
        for(int i = 9; 0 <= i; i--) // first , find out(be sure) the biggest weight.
        {
            if(n - a[i] > -1)
            {
                save.push(a[i]); //and save it at stack
                
                n = n - a[i];  //loop until n == a[i]
            }
        }
        
        while(1)
        {
            cout<<save.top(); //output the result from stack
            
            save.pop(); // delete
            
            if (save.empty())
            {
                break;
            }
            else
            {
                cout<<" ";
            }
        }
        
        cout<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include<iostream>

using namespace std;

void conv(int n, int a[10])
{
	for(int i=0;i<10;i++)
	{
		a[i]=n%2;
		n=n/2;
	}
}

int pow(int x, int n)
{
	int ans=1;
	for(int i=0;i<n;i++)
	{
		ans*=x;
	}
	return ans;
}

int main(void)
{
	int w;
	while(cin>>w)
	{
		int a[10];
		conv(w,a);
		if(a[0]==1)
		{
			cout<<1;
		}
		for(int i=1;i<10;i++)
		{
			if(a[i]==1)
			{
				cout<<" "<<pow(2,i);
			}
		}
		cout<<endl;
	}
}

C++: #include <cstdio>

using namespace std;

int main() {
    int n = 0;

    while (scanf("%d", &n) != EOF) {
        int t = 1;

        for (int i = 0; i < 10; ++i) {
            if ((n & t) == t) {
                if (i != 0) {
                    printf(" ");
                }
                printf("%d", t);
            }

            t *= 2;
        }
        printf("\n");
    }

    return 0;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif



int main(int argc, char **argv){
	int weight[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
	int w = 0;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(ifs >> w){
#else
	while(std::cin >> w){
#endif
		std::vector<int> binary_expression;
		std::vector<int> result;
		while(w > 0){
			binary_expression.push_back(w % 2);
			w = w / 2;
		}

		for(int i = 0; i < binary_expression.size(); i++){
			if(binary_expression[i] > 0){
				result.push_back(weight[i]);
			}
		}
		
		std::cout << result[0];
		for(int i = 1; i < result.size(); i++){
			std::cout << " " << result[i];
		}
		std::cout << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#include <stdio.h>

using namespace std;

int v[] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int w;
stack<int> spent;

int main(void) {
    while(~scanf("%d", &w)) {
        for(int i = 0; i < 10; i++) {
            if(w >= v[i]) {
                w -= v[i];
                spent.push(v[i]);
            }
        }
        while(!spent.empty()) {
            if(spent.size() == 1) {
                cout << spent.top();
            } else {
                cout << spent.top() << " ";
            }
            spent.pop();
        }
        cout << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

bool W_b[10] = { false };
int W[] = { 1, 2, 4, 8 ,16, 32, 64, 128, 256, 512 };

void input(void) {
	CI N;
	return;
}


int main(void) {
	int nn = 0;
	while (CI N) {
		for (int i = 9; i >= 0; i--) {
			if (W[i] <= N) {
				N -= W[i];
				W_b[i] = true;
				nn++;
			}
		}
		int x = 0;
		for (int i = 0; i < 10; i++) {
			if (W_b[i] == true) {
				x++;
				CO W[i];
				if (x < nn)CO " ";
				W_b[i] = false;
			}
		}
		CO "\n";
	
		nn = 0;
	}
	

	
	return 0;
}

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

using namespace std;

void Solution()
{
    int a[10]={1,2,4,8,16,32,64,128,256,512};
    
    int n;
    
    stack<int> save;
    
    while(cin>>n)
    {
        for(int i = 9; 0 <= i; i--)
        {
            if(n - a[i] > -1)
            {
                save.push(a[i]);
                
                n = n - a[i];
            }
        }
        
        while(1)
        {
            cout<<save.top();
            
            save.pop();
            
            if (save.empty())
            {
                break;
            }
            else
            {
                cout<<" ";
            }
        }
        
        cout<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}