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 h[10]={1,2,4,8,16,32,64,128,256,512};
  int o,hk;
  while(cin>>o){
    hk = true;
    int w[1023][10]={0};
    for(int i=0;i<10;i++){
      if(h[i]>o) break;
      for(int j=o;j>=0;j--){
	if(j==0) w[h[i]][0] = h[i];
	else if(w[j][0]!=0&&j+h[i]<=o){
	  for(int n=0;n<10;n++){
	    if(w[j][n]==0){
	      for(int m=0;m<n;m++) w[j+h[i]][m] = w[j][m];
	      w[j+h[i]][n] = h[i];
	      break;
	    }
	  }
	}
	if(j==0) w[h[i]][0] = h[i];
      }
    }
      for(int i=0;i<10;i++){
	if(w[o][i]==0) break;
	if(hk!=true) cout << ' ';
	cout << w[o][i];
	if(hk==true) hk = false;
      }
      cout << 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 = 256; 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<vector>

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

int main(){

	int n;
	while (std::cin >> n){

		std::vector<int> res;

		for (int i = 9; i >= 0; i--){
			if (n >= bun[i]){
				res.push_back(bun[i]);
				n -= bun[i];
			}
		}

		for (int i = res.size() - 1; i >= 0; i--){
			if (i == 0)std::cout << res[i] << std::endl;
			else std::cout << res[i] << " ";
		}
	}

	return 0;
}

C++: #include <iostream>

int main(){
	int a,b,c=1;
	int d[10];
	
	
	while(std::cin>>a){
		for(b=1;b<=10;b++){
		d[b]=0;
	}
		
		for(b=0;b<2;b++){
			if(a==b){
				d[1]=b;
			}else{
				for(c=0;c<3;c=c+2){
					if(a==b+c){
						d[1]=b;
						d[2]=c;
						
						
					}else{
						for(int e=0;e<5;e=e+4){
			if(a==b+c+e){
				d[1]=b;
				d[2]=c;
						d[3]=e;
					
			}else{
				for(int f=0;f<9;f=f+8){
					if(a==b+c+e+f){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						
					}else{
						for(int g=0;g<17;g=g+16){
			if(a==b+c+e+f+g){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						
			}else{
				for(int h=0;h<33;h=h+32){
					if(a==b+c+e+f+g+h){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						
					
					}else{
						for(int i=0;i<65;i=i+65){
			if(a==b+c+e+f+g+h+i){
				d[1]=b;d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						
			}else{
				for(int j=0;j<129;j=j+128){
					if(a==b+c+e+f+g+h+i+j){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						
					}else{
						for(int k=0;k<257;k=k+256){
			if(a==b+c+e+f+g+h+i+j+k){
				d[1]=b;
				d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						
			}else{
				for(int l=0;l<513;l=l+512){
					if(a==b+c+e+f+g+h+i+j+k+l){
						d[1]=b;
						d[2]=c;
						d[3]=e;
						d[4]=f;
						d[5]=g;
						d[6]=h;
						d[7]=i;
						d[8]=j;
						d[9]=k;
						d[10]=l;
					}else{
						
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
					}
				}
			}
			
		}
		for(int m=1;m<11;m++){
		if(d[m]!=0){
			std::cout<<d[m]<<" ";
		}
	}
	std::cout<<std::endl;
	}
}

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]);
			}
		}for(int i=ans.size();i>0;i--){
			cout<<ans.top();
			ans.pop();
			if(i!=1)cout<<" ";
		}cout<<endl;
	}
}

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

int main()
{
    int n;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
	
		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		if(flag[0]!=0){
			cout << w[0];
		}
		for(int i=1; i<=9 ; i++){
			if(flag[i]!=0){
				cout << " " << w[i];
			}
		}
		
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int cnt[10];
  int flag=0;
  int t[10] = {1,2,4,8,16,32,64,128,256,512};
  while(cin>>n){
    flag = 0;
    for(int i=0;i<10;i++){
      cnt[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(n - t[i] >= 0 && flag==0){
	n = n - t[i];
	cnt[i]+=2;
	flag=1;
      }else if(n - t[i] >= 0 && flag==1){
	n = n - t[i];
	cnt[i]++;
      }
      if(n == 0) break;
    }
    for(int i=0;i<10;i++){
      if(cnt[i] == 1){
	cout<<t[i]<<" ";
      }else if(cnt[i] == 2){
	cout<<t[i]<<endl;
      }
    }
    
  }
  
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, n) for(int i = 0; i <= n; i++)
#define MREP(i, n) for(int i = n; i >= 0; i--)

using namespace std;

int main(){
	int input;
	int tmp = 1, n = 9;
	bool fact[10];
	
	PREP(i, n){
		tmp *= (!i) ? 1 : 2;
		fact[i] = false;
	}

	while(cin >> input){
		MREP(i, n){
			if(tmp <= input){
				input -= tmp;
				fact[i] = true;
			}
			if(input == 0) break;
			tmp /= 2;
		}
		PREP(i, n){
			tmp *= (!i) ? 1 : 2;
			if(fact[i] == true){
				cout << tmp;
				if(i != n) cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<cstdio>
main(){int d,a;for(;a=1,~scanf("%d",&d);)for(;a<=d;a<<=1)if(a&d)printf((d/a>2)?"%d ":"%d\n",a);}

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

using namespace std;

int main(){
  int i,j,n;
  int a[10];
  int we[10]={1,2,4,8,16,32,64,128,256,512};
   
  while(cin>>n){
    i=0; 
    while(n!=1){
      a[i]=n%2;
      i++;
      n/=2;
    }
    a[i]=1;
    while(i!=9){
      i++;
      a[i]=0;    
    }
    i=0;
    for(j=0;j<10;j++){
      if(i&&a[j]==1)cout<<" ";
      if(a[j]==1){
	cout<<we[j];
	i=1;
      }
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){

  int a[10], b[10], g, cnt;

  for(int i=0; i<10; i++){
    a[i] = pow(2, i);
  }

  fill(b, b+10, 0);
  cnt = 0;
  while(cin >> g){
    for(int i=9; i>=0 && g != 0; i--){
      if(a[i] <= g){
        b[i] = 1;
        g -= a[i];
        cnt++;
      }
    }

    for(int i=0; i<10; i++){
      if(b[i] == 1){
        cnt--;
        cout << a[i] << (cnt? " " : "");
        b[i] = 0;
      }
    }
    cout << endl;

  }

  return 0;

}

C++: #include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int x;
    while(cin>>x){
        for(int i=0;i<15;i++){
            if(x&1){
                cout<<pow(2,i);
                x=x>>1;
                if(x)cout<<' ';
            }
            else x=x>>1;
        }
        cout<<endl;
    }
    return 0;
}