Go: package main

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

func parseToArray2d(lines []string) [][]int64 {
	var result [][]int64
	for _, line := range lines {
		var parsedLine []int64
		for _, element := range strings.Split(line, " ") {
			n, err := strconv.ParseInt(element, 10, 64)
			if err != nil {
				fmt.Printf("Error: element = %v\n", element)
			}
			parsedLine = append(parsedLine, n)
		}
		result = append(result, parsedLine)
	}
	return result
}

func pop(stack []int64) ([]int64, int64) {
	lenStack := len(stack)
	return stack[0:(lenStack - 1)], stack[lenStack-1]
}

func contains(s []int64, e int64) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	content := []string{}
	for scanner.Scan() {
		line := scanner.Text()
		content = append(content, line)
	}
	arr := parseToArray2d(content)
	x := arr[0][0]
	y := arr[0][1]

	if x == 0 && y == 0 {
		fmt.Println(1)
		return
	}

	filledRange := []int64{1, 0, 0, 0}
	direction := 0
	var prev int64 = 1
	var curr int64 = 1
	xSatisfied := false
	ySatisfied := false
	i := 1
	for ; i < 100; i++ {
		filledRange[direction%4] += curr
		direction++
		// fmt.Println(filledRange)

		if (x >= 0 && x <= filledRange[0]) || (x <= 0 && -x <= filledRange[2]) {
			xSatisfied = true
		}
		if (y >= 0 && y <= filledRange[1]) || (y <= 0 && -y <= filledRange[3]) {
			ySatisfied = true
		}

		if xSatisfied && ySatisfied {
			break
		}

		prev, curr = curr, prev+curr
	}

	fmt.Println(i%3 + 1)
}

Python: # coding: utf-8
# Your code here!

x,y = [int(i) for i in input().split()]

fiboMax = 100

fibo = [0 for i in range(fiboMax)]
fibo[1] = 1
fibo[2] = 1

for i in range(3,fiboMax):
    fibo[i] = fibo[i-1] + fibo[i-2]
    
xMax = 0
yMax = 0
xMin = 0
yMin = 0

ans = -1
if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
    ans = 1
else:
    i = 2
    while(True):
        xMax += fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1
        yMax += fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1
        xMin -= fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1
        yMin -= fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1

ans %= 3
if ans == 0:
    ans = 3

print(ans)

C++: #include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main() {
    int x,y; cin >> x >> y;
    int cnt,lx,dy,rx,uy;
    cnt = lx = dy = 0;
    rx = uy = 1;
    while (true) {
        if (lx <= x and x < rx and dy <= y and y < uy) break;
        if (cnt%4==0) rx += uy-dy;
        else if (cnt%4==1) uy += rx-lx;
        else if (cnt%4==2) lx -= uy-dy;
        else dy -= rx-lx;

        cnt++;
    }
    cout << cnt%3 + 1 << endl;
}

C++: #include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll x, y, d = 0, c = 0, ux, uy, dx, dy, t;
  scanf("%lld%lld", &x, &y);
  for(ux = uy = dx = dy = 0; ux < x || dx > x || uy < y || dy > y; c = (c + 1) % 3, d = (d + 1) % 4) {
    if(!d) t = uy - dy + 1, ux += t;
    else if(d == 1) t = ux - dx + 1, uy += t;
    else if(d == 2) t = uy - dy + 1, dx -= t;
    else t = ux - dx + 1, dy -= t;
  }
  printf("%lld\n", c + 1);
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;


int main() {
    llong x, y;
    llong sx, sy;
    llong tx, ty;

    cin >> x >> y;

    sx = sy = tx = ty = 0;

    llong c = 0;
    llong d = 0;
    while (sx > x || x > tx ||
           sy > y || y > ty) {
        switch(d) {
        case 0:
            tx += llabs(ty - sy) + 1;
            break;
        case 1:
            ty += llabs(tx - sx) + 1;
            break;
        case 2:
            sx -= llabs(ty - sy) + 1;
            break;
        case 3:
            sy -= llabs(tx - sx) + 1;
            break;
        }

        c = (c + 1) % 3;
        d = (d + 1) % 4;
    }

    cout << c + 1 << endl;

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < int(n); i++)

int main(){
    lint x, y;
    cin >> x >> y;
    lint l = 0, r = 1, d = 1, u = 1; // [l, r), [d, u)
    rep(i, 1000000){
        lint l2, r2, u2, d2;
        if(i % 2 == 0){
            l2 = l;
            r2 = r;
            if(i % 4 == 0){ // 下
                u2 = d;
                d2 = u2 - (r - l);
            }else{ // 上
                d2 = u;
                u2 = d2 + (r - l);
            }
        }else{
            d2 = d;
            u2 = u;
            if(i % 4 == 1){ // 右
                l2 = r;
                r2 = l2 + (u - d);
            }else{ // 左
                r2 = l;
                l2 = r2 - (u - d);
            }
        }
        if(l2 <= x && x < r2 && d2 <= y && y < u2){
            cout << i % 3 + 1 << endl;
            return 0;
        }
        //cout << l2 << " " << r2 << " " << d2 << " " << u2 << endl;
        l = min(l, l2);
        r = max(r, r2);
        d = min(d, d2);
        u = max(u, u2);
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int gx,gy;
  cin>>gx>>gy;

  int y=0,x=0,sz=1,pr=0,color=0,dir=0;
  while(1){
    if(y<=gy&&gy<y+sz&&x<=gx&&gx<x+sz){
      cout<<(color%3)+1<<endl;
      break;
    }
    int nx=sz+pr;
    if(dir==0){
      x+=sz;
    }
    if(dir==1){
      x-=pr;
      y+=sz;
    }
    if(dir==2){
      x-=nx;
      y-=pr;
    }
    if(dir==3){
      y-=nx;
    }
    pr=sz;
    sz=nx;
    color++;
    dir=(dir+1)%4;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y,xmax=0,xmin=0,ymax=0,ymin=0;
int v=0,ans=0;
ll f[1000]={};

ll dp(ll a){
	if(a<=1){
		return a;
	}
	if(f[a] != 0){
		return f[a];
	}else{
		return f[a]=dp(a-1)+dp(a-2);
	}
}

int main(){
	cin>>x>>y;
	ll k=2;
	ans=1;
	while(true){
		if(xmin<=x&&xmax>=x&&ymin<=y&&ymax>=y){
			break;
		}
		if(v==0){
			xmax+=dp(k);
			v++;
		}else if(v==1){
			ymax+=dp(k);
			v++;
		}else if(v==2){
			xmin-=dp(k);
			v++;
		}else{
			ymin-=dp(k);
			v=0;
		}
		//cout<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax<<endl;
		k++;
		if(ans==3){
			ans=1;
		}else{
			ans++;
		}
	}
	//cout<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax<<endl;
	//cout<<k<<endl;
	//for(int i=0;i<k;i++){
	//	cout<<f[i]<<" ";
	//}
	//cout<<endl;
	cout<<ans<<endl;
}