Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == -1 {
			break
		}
		if n == 0 {
			fmt.Println(0)
			continue
		}
		ans := make([]int, 0)
		for n > 0 {
			ans = append([]int{n % 4}, ans...)
			n = n / 4
		}

		buf := make([]string, len(ans))
		for i := range ans {
			buf[i] = strconv.Itoa(ans[i])
		}
		fmt.Println(strings.Join(buf, ""))
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int fo[10]={1,4,16,64,256,1024,4096,16384,65536,262144};
int main(void)
{
	int i,j,k,cnt=1,flg;
	int n;
	
	while(1) {
		cin>>n;
		flg=0;
		if(n==-1) break;
		for(i=10;i>=0;i--) {
			if(n==0&&flg==0) {
				cout<<"0";
				break;
			}
			if(n/fo[i]>0) {
				cout<<n/fo[i];
				n=n%fo[i];
				flg=1;
			}
			else if(flg==1) cout<<"0";
		}
		cout<<endl;
	}
}

C++: //b
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;	

int main(){
	
	int n;
	
	while(cin>>n, n>=0){
		
		string res = "";
		vector<int> b;
		
		while(n>0){
			b.push_back(n % 2);
			n /= 2;	
		}
		
		n = b.size();
		
		if(n%2){
			b.push_back(0);
			n++;
		}
		
		reverse(b.begin(), b.end());

		for(int i=0; i<n; i+=2){
			int d = b[i]*2+b[i+1];
			res += (char)('0'+d);
		}
		
		if(res=="")
			res = "0";
		
		cout << res << endl;
	}
	
	return 0;	
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


int n;
string s;

int main(){
	while(cin>>n && n != -1){
		s="";
		int d=1;
		while(d*4<=n)d*=4;
		//cout<<n<<" "<<d<<endl;
		for(int i=d; i>0; i/=4){
			s+=(n/i+'0');
			n%=i;
		}
		//s+=(n+'0');
		cout<<s<<endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    int n;
    while(cin >> n && n + 1)
    {
        vint v;
        
        do {
            v.push_back(n % 4);
        } while (n /= 4);
        
        rep(i, v.size())
            cout << v[v.size() - i - 1];
        cout << endl;
    }
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	
	
	long long n;
	
	
	while(cin>>n,n!=-1){
		bool f=false;
		string s="";
		for(int k=9;k>=0;k--){
			int i=int(pow(4,k));
			int count=0;
			for(int j=0;j<3;j++){
				if(n-i>=0){
					n=n-i;
					count++;
				}
				else
					break;
			}
			if(count!=0||f)
			s=s+to_string(count);
			if(s!="")
				f=true;
			
		}
		if(!f)
			s="0";
		cout<<s<<endl;
	}
			

}

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

void convert(int x){
    if ( x == 0 ) return;
    convert(x/4); cout << x%4;
}

main(){
    int n;
    while( cin >> n && n >= 0 ) {
	if ( n == 0 ) cout << 0 << endl;
	else {
	    convert(n); cout << endl;
	}
    }
}

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

int main(void)
{
	int n;

	while(cin >> n, n >= 0){
		if(!n){
			cout << n << endl;
			continue;
		}
		stack<int> sta;
		while(n > 0){
			sta.push(n%4);
			n /= 4;
		}
		while(sta.size()){
			cout << sta.top();
			sta.pop();
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == -1)break;
    vector<int> _4bit;
    while(true){
      if(n < 4)break;     
      _4bit.push_back(n%4);
      n /= 4;
    }
    _4bit.push_back(n);
    for(int i=_4bit.size()-1;i>=0;i--){
      cout << _4bit[i];
    }
    cout << endl;

  }
  return 0;
}

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

int a[10], hd;
int main(void){
	int n;
	for(;;){
		scanf("%d", &n);
		if(n == -1)break;
		hd = 0;
		for(;n;n/=4)a[hd++] = n % 4;
		if(hd == 0)puts("0");
		else{
			for(;hd--;)printf("%d", a[hd]);
			puts("");
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	int a[100], b = 0, n, c[100], sum2 = 1;
	long long sum = 1;
	while (sum <= 1000000) {
		a[b] = sum;
		c[b] = sum2;
		b++;
		sum *= 4;
		sum2 *= 10;
	}
	while (cin >> n&&n != -1) {
		char sum3[100];
		bool e = false, f = false;
		sum2 = 0;
		for (int i = b - 1; i >= 0; i--) {
			if (n >= a[i]) {
				e = true;
				f = true;
				int d = (n - (n%a[i])) / a[i];
				sum3[sum2] = (char)d+'0';
				sum2++;
				n -= (a[i] * d);
			}
			if (e&&!f) {
				sum3[sum2] = '0';
				sum2++;
			}
			f = false;
		}
		for (int i = 0; i < sum2; i++) {
			cout << sum3[i];
		}
		if (sum2 == 0) cout << 0;
		cout << endl;
	}
}