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>

using namespace std;

int main(){
	int two[15]={},n,cnt=-1,check[15]={},last=0;
	for(int i=0;i<11;i++){
		two[i]=1;
		for(int j=0;j<i;j++)two[i]*=2;
	}
	while(cin>>n){
		cnt=0;
		last=0;
		for(int i=0;i<10;i++){
			check[i]=0;
			if(n<two[i+1]){
				cnt=i;
				break;
			}
		}
		for(int i=cnt;i>=0;i--){
			if(n%2==1)check[i]++;
			n/=2;
		}
		for(int i=0;i<10;i++){
		if(check[i]==1){
			last=i;
			break;
		}
		}
		for(int i=cnt;i>=last;i--){
			if(check[i]==1&&last!=i)cout<<two[cnt-i]<<" ";	
			else if(i==last)cout<<two[cnt]<<endl;
		}
	}
}

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

const vector<int> v = {1, 2, 4, 8, 16, 32, 64, 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 <vector>

using namespace std;

int main(){
  int n;
  while(cin >> n){
    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>
#include <vector>
using namespace std;

int main(){
	int w, g[10];
	vector<int> ans;

	for(int i=0,j=1 ; j<=512 ; j*=2, i++){
		g[i] = j;
	}

	while(cin >> w){
		ans.clear();
		for(int i=9 ; i>=0 ; i--){
			if(w<=1){
				if(w==1)ans.push_back( w ); 
				break;
			}
			else if(g[i]<=w){
				w -= g[i];
				ans.push_back( g[i] ); 
			}
		}
		for(int i=ans.size()-1 ; i>=0 ; i--){
			cout << ans[i] ;
			if(i==0) cout << endl;
			else cout << " ";
		}
	}
	
	return 0;
}

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

int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    while (g) {
      int i = 1;
      while (g >= i * 2) {
        i *= 2;
      }
      v.push_back(i);
      g -= i;
    }
    
    for (int i = v.size() - 1; i >= 0; i--) {
      if (!i) {
        cout << v.at(i) << endl;
      } else {
        cout << v.at(i) << " ";
      }
    }
    v.clear();
  }
}

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

using namespace std;

int main(){
  vector<int> weightarray;
  int weight;
  while(cin>>weight){
    weightarray.push_back(weight);
  }
  
  for(auto weight:weightarray){
    for(int i=0;i<sizeof(weight)*8;i++){
      int bit=1<<i;
      if(weight&bit){
        cout<<bit<<" ";
      }
    }
    cout<<endl;
  }
}

C++: //AOJ 0031

#include<iostream>
#include<vector>

using namespace std;

int main(){

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



	vector<int> input;

	int num;

	while(cin>>num){
		input.push_back(num);
	}

	for(int i=0;i<input.size();i++){

		int tmp = input[i];

		for(int j=0;j<10;j++){

			if(tmp%2==1){
				printf("%d ",data[j]);
			}
			tmp/=2;
		}

		printf("\n");
	}

	return 0;
}

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

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

int main()
{
    int in_data;
    while(cin >> in_data)
    {
        int gram_num = 0;
        bool is_used[10] = {};
        stringstream ss;
        string ans;
        for(int i=9; i>=0; i--)
        {
            if(gram_num + WEIGHTS[i] <= in_data)
            {
                gram_num += WEIGHTS[i];
                is_used[i] = true;
            }
        }
        for(int i=0; i<10; i++)
        {
            if(is_used[i])
            {
                ss << std::to_string(WEIGHTS[i]) <<  " ";
            }
        }
        ans = ss.str();
        ans.pop_back();
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  char *line = NULL;
  size_t buffer_size = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int weight = atoi(line);

    vector<int> counter_weights;
    for (int i = 0; weight != 0 && i < 10; ++i) {
      int mask = 1 << i;
      if (weight & mask) { counter_weights.push_back(mask); }
      weight &= ~mask;
    }
    for (auto iter = counter_weights.begin();
         iter != counter_weights.end();
         ++iter) {
      printf("%d%c", *iter, iter + 1 == counter_weights.end() ? '\n' : ' ');
    }
  }
  free(line);

  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  int weight;
  while (cin >> weight) {
    bool flag = false;
    for (int b = 1; b <= 512; b *= 2) {
      if (b & weight) {
        if (flag) cout << ' ';
        cout << b;
        flag = true;
      }
    }
    cout << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int n, s;
int main() {
	while (true) {
		cin >> n; s = 0; if (!n) { break; }
		for (int i = 1; i < 31; i++) {
			if ((n / (int)pow(2, i)) % 2 == 1) {
				if (s) { cout << ' '; }
				cout << pow(2, i - 1); s++;
			}
		}
		cout << endl;
	}
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main(){
  int n;
  //ostream_iterator<int> out_it(cout, " ");
  while(cin >> n){
    int b = 1;
    vector<int> ans;
    while(n > 0){
      if((n & 1) == 1){
	ans.push_back(b);
      }
      b <<= 1;
      n >>= 1;
    }
    //copy(ans.begin(), ans.end(), out_it);
    for(int i = 0; i < ans.size() - 1; ++i){
      cout << ans[i] << " ";
    }
    cout << ans.back() << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

class STACK{

public:
	STACK(){
		index = 0;
	}
	void push(int data){
		array[index++] = data;
	}
	int pop(){
		index--;
		return array[index];
	}
	bool isEmpty(){
		return index == 0;
	}
	int getIndex(){
		return index;
	}

private:
	int array[10];
	int index;
};

int main(){
	int w;
	STACK stack;

	while(scanf("%d",&w) != EOF){
		for(int i = 512; i>= 1; i /= 2){
			if(w>=i){
				stack.push(i);
				w -= i;
			}
		}

		while(!stack.isEmpty()){
				if(stack.getIndex() == 1){
					printf("%d\n",stack.pop());
				}else{
					printf("%d ",stack.pop());
				}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
const int a[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
vector<int> solve(int n){
	vector<int> ans;
	int res = n;
	while(res != 0){
		for (int i = 0; i < 10; i++) {
			if(n - a[i] < 0){
				continue;
			}
			if((n - a[i]) < res) {
				res = n - a[i];
			}
		}
		ans.push_back(n - res);
		n = res;
	}
	return ans;
}
int main(void) {
	vector<int> ans;
	int n;
	while(cin >> n) {
		ans = solve(n);
		for(int i = 0; i < ans.size()-1; ++i){
			cout << ans[i] << " ";
		}
		cout << ans.back() << endl;
	}
	return 0;
}