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<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//n??????
//Radix r;
//cout << r.to(n, 4) << endl;
class Radix {
private:
	const char* s;
	int a[128];
public:
	Radix(const char* s = "0123456789ABCDEF") : s(s) {
		for (int i = 0; s[i]; i++) a[(int)s[i]] = i;
	}
	string to(long long p, int q) {
		if (!p) return "0";
		char t[64] = {};
		int i;
		for (i = 62; p; i--) {
			t[i] = s[p % q];
			p /= q;
		}
		return string(t + i + 1);
	}
	string to(const string &t, int p, int q) {
		return to(to(t, p), q);
	}
	long long to(const string &t, int p) {
		long long sm = a[(int)t[0]];
		for (int i = 1; i < (int)t.length(); i++)
			sm = sm * p + a[(int)t[i]];
		return sm;
	}
};

signed main() {
	for (int n; cin >> n&&n != -1;) {
		Radix r;
		cout << r.to(n, 4) << endl;
	}
	return 0;
}

C++: # include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

string trance(int a){
    string ret;
    if(a==0)return "0";
    while (a)
    {
        ret = char(a % 4 + '0') + ret;
        a /= 4;
        //cerr << a << endl;
    }
    return ret;
}

int main(){
    INIT;
    while(cin>>n&&n!=-1){
        cout << trance(n) << endl;
    }
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n != -1)
	{
		if(n == 0)
		{
			cout << 0 << endl;
			continue;
		}
		string binary;
		while(n)
		{
			binary += (char)(n % 2 + '0');
			n /= 2;
		}
		if(binary.size() % 2)
		{
			binary += "0";
		}
		string fourDigits = "";
		for(int i = 0; i < binary.size(); i += 2)
		{
			fourDigits += binary[i] - '0' + 2 * (binary[i + 1] - '0') + '0';
		}
		reverse(fourDigits.begin(), fourDigits.end());
		cout << fourDigits << endl;
	}
}

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

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n=-1)break;
        int ans=0;
        for(int i=0;;i++){
            ans+=(n%4*pow(10,i));
            if(n/4==0) break;
            n=n/4;
        }
        cout<<ans<<endl;
    }
    return 0;
}



AOJ 0175 why wrong answer?

C++: # define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	int n;
	while (cin >> n&&n != -1)
	{
		stringstream ss;
		while (n)
		{
			ss << n % 4;
			n /= 4;
		}
		string ans = ss.str();
		reverse(ALL(ans));
		if (ans == "")ans = "0";
		cout << ans << endl;
	}
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[100000],f,g,h,j,i;
	while(1){
		scanf("%d",&a);
			if(a==-1) break;
		s=4;
		while(1){
			if(a<s) break;
			s*=4;
		}
		s/=4;
		i=0;
		while(1){
			if(s==1) break; 
			d[i]=a/s;
			a=a%s;
			s/=4;
			i++;
		}
		d[i]=a;
		for(j=0;j<=i;j++)
			printf("%d",d[j]);
		printf("\n");
	}
	return 0;
}

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

int main(){

  int n;

  while(1){

    cin >> n;
    if(n < 0) break;

    string s;

    while(1){
      s += (n%4 + 48);

      n /= 4;
      if(n == 0) break;
    }

    for(int i=s.size()-1;i >= 0;i--) cout << s[i];
    cout << endl;
  }
}

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

int main() {
  int n;
  while(cin >> n) {
    if(n == -1) break;
    int mod = 4*4*4*4*4*4*4*4*4;
    bool r = false;
    for(int i=0;i<10;i++) {
      if( n/mod != 0 || i==9) {
        r = true;
      }
      if(r) {
        cout << n/mod;
      }
      n -= (n/mod) * mod;
      mod/=4;
    }
    cout << endl;
  }
}

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

int n;

int main() {
	while(cin>>n){
		if(n==-1)return 0;
		int m=n,d=1;
		while(m>3){m/=4;d++;}
		for(int i=d-1;i>=0;i--)cout<<(n/(int)(pow(4,i)+0.1))%4;
		cout<<endl;
	}
}