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)
}

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

struct square {
	long long l, r, d, u;
};

int main() {
	long long X, Y, NL = 0, NR = 0, ND = 0, NU = 0, H = 1, W = 1;
	cin >> X >> Y;
	vector<square> V;
	V.push_back({ 0, 0, 0, 0 });
	for (int i = 0; ; i++) {
		square SQ;
		if (i % 4 == 0) {
			SQ.l = NR + 1, SQ.r = NR + H, SQ.d = ND, SQ.u = NU;
			W += H;
			NR = SQ.r;
		}
		if (i % 4 == 1) {
			SQ.l = NL, SQ.r = NR, SQ.d = NU + 1, SQ.u = NU + W;
			H += W;
			NU = SQ.u;
		}
		if (i % 4 == 2) {
			SQ.l = NL - H, SQ.r = NL - 1, SQ.d = ND, SQ.u = NU;
			W += H;
			NL = SQ.l;
		}
		if (i % 4 == 3) {
			SQ.l = NL, SQ.r = NR, SQ.d = ND - W, SQ.u = ND - 1;
			H += W;
			ND = SQ.d;
		}
		V.push_back(SQ);
		if (100000000 <= H) break;
	}
	for (int i = 0; i < V.size(); i++) {
		if (V[i].l <= X && X <= V[i].r && V[i].d <= Y && Y <= V[i].u) {
			cout << i % 3 + 1 << endl;
			return 0;
		}
	}
}

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

int main(){
    int x_min(0),x_max(0),y_min(0),y_max(0);
    int x,y;    cin >> x >> y;
    int side[35];
    side[0] = 1;    side[1] = 1;

    for(int i=2;i<35;i++){
        side[i] = side[i-1] + side[i-2];
    }

    int i(1);
    while(1){
        if(x_min<=x && x<=x_max && y_min<=y && y<=y_max){
            if(i%3==0)
                cout << 3 << endl;
            else
                cout << i%3 << endl;
            
            break;
        }else{
            switch (i%4){
            case 0:
                y_min -= side[i];
                break;

            case 1:
                x_max += side[i];
                break;

            case 2:
                y_max += side[i];
                break;
            
            case 3:
                x_min -= side[i];
            
            default:
                break;
            }

            i++;
        }
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

enum { UP = 0, RIGHT, DOWN, LEFT };
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
int x, y;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> x >> y;

    if (x == 0 and y == 0) {
        cout << 1 << endl;
        return;
    }

    int sx = 0, sy = 0, tx = 0, ty = 0;
    int dir = LEFT;
    int col = 2;

    rep(_, 0, 101010) {
        int sx2 = sx, tx2 = tx, sy2 = sy, ty2 = ty;

        if (dir == DOWN) {
            ty2 = sy - 1;
            sy2 = ty2 - (tx - sx + 1) + 1;
        } else if (dir == LEFT) {
            sx2 = tx + 1;
            tx2 = sx2 + (ty - sy + 1) - 1;
        } else if (dir == UP) {
            sy2 = ty + 1;
            ty2 = sy2 + (tx - sx + 1) - 1;
        } else if (dir == RIGHT) {
            tx2 = sx - 1;
            sx2 = tx2 - (ty - sy + 1) + 1;
        }

        if (sx2 <= x and x <= tx2 and sy2 <= y and y <= ty2) {
            cout << col << endl;
            return;
        }

        col++;
        if(3 < col) col = 1;

        dir = (dir + 1) % 4;

        chmin(sx, sx2);
        chmin(sy, sy2);
        chmax(tx, tx2);
        chmax(ty, ty2);

        //printf("%d %d %d %d\n", sx, tx, sy, ty);
    }
}

C++: #include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

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

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	ll x, y;
	cin >> x >> y;
	ll rx=0, lx=0, uy=0, dy=0, l=0, bf=1, bff = 0, dir=0;
	for(int i=0;;i = (i+1)%3)
	{
		if (lx <= x && x <= rx && dy <= y && y <= uy) {
			cout << i + 1 << endl;
			return 0;
		}
		l = bf + bff;
		bff = bf, bf = l;
		if (dir == 0) {
			rx += l;
		}
		if (dir == 1) {
			uy += l;
		}
		if (dir == 2) {
			lx -= l;
		}
		if (dir == 3) {
			dy -= l;
		}
		dir = (dir+1)%4;
	}

	return 0;
}