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;

vector<int> MapData;
int Coordinate[4];

int solve(int x, int y) {
	int flag, color, curPos;

	flag = 0;
	color = 1;
	curPos = 0;
	while (true) {
		if (MapData.size() < 2) {
			MapData.push_back(1);
		} else {
			MapData.push_back(MapData[curPos - 1] + MapData[curPos]);
		}
		++curPos;
		if (flag == 0) {
			Coordinate[1] += MapData[curPos];
		}else if (flag == 1) {
			Coordinate[3] += MapData[curPos];
		}else if (flag == 2) {
			Coordinate[0] -= MapData[curPos];
		}else if (flag == 3) {
			Coordinate[2] -= MapData[curPos];
		}
		//cout << Coordinate[0] << ends << Coordinate[1] << ends << Coordinate[2] << ends << Coordinate[3] << endl << "color:" << color << endl;
		if (x >= Coordinate[0] && x <= Coordinate[1] && y >= Coordinate[2] && y <= Coordinate[3]) {
			return color + 1;
		}
		flag = (flag + 1) % 4;
		color = (color + 1) % 3;
	}
}

int main() {
	int x, y;

	memset(Coordinate, 0, sizeof(Coordinate));
	MapData.push_back(1);
	cin >> x >> y;
	if (x == 0 && y == 0) {
		cout << "1" << endl;
		return 0;
	}
	cout << solve(x, y) << endl;

	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll x, y;
    cin >> x >> y;
    ll lx = 0, ly = 0, rx = 0, ry = 0;
    int t = 0;
    vector<ll> A(90);
    A[0] = 0, A[1] = 1;
    for(int i = 2; i < 90; i++) {
        A[i] = A[i - 1] + A[i - 2];
    }
    while(1) {
        if(lx <= x && ly <= y && x <= rx && y <= ry)
            break;
        if(t % 4 == 0) {
            lx += A[t + 1];
            rx += A[t + 2];
            ry += A[t];
        } else if(t % 4 == 1) {
            lx -= A[t];
            ly += A[t + 1];
            ry += A[t + 2];
        } else if(t % 4 == 2) {
            lx -= A[t + 2];
            ly -= A[t];
            rx -= A[t + 1];
        } else {
            ly -= A[t + 2];
            rx += A[t];
            ry -= A[t + 1];
        }
        t++;
    }
    cout << t % 3 + 1 << endl;
    return 0;
}

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

#define inRange(x,a,b) (a <= x && x <= b)

int main(){
    int x, y;
    cin >> x >> y;
    int lx = 0, rx = 0, ly = 0, ry = 0, col = 0, turn = 0;
    while(!inRange(x,lx,rx) || !inRange(y,ly,ry)){
        col = (col+1)%3;
        if(turn == 0)   rx += ry-ly+1;   
        if(turn == 1)   ry += rx-lx+1;
        if(turn == 2)   lx -= ry-ly+1;
        if(turn == 3)   ly -= rx-lx+1;
        turn = (turn+1)%4;
    }
    cout << col+1 << endl;
    return 0;
}

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

int x, y;

int dfs(int lx, int ly, int ux, int uy, int n) {
    if(lx <= x && x <= ux && ly <= y && y <= uy) return n % 3 + 1;
    int dx = ux - lx + 1, dy = uy - ly + 1;
    if(n % 4 == 0) return dfs(lx, ly, ux + dy, uy, n + 1);
    if(n % 4 == 1) return dfs(lx, ly, ux, uy + dx, n + 1);
    if(n % 4 == 2) return dfs(lx - dy, ly, ux, uy, n + 1);
    if(n % 4 == 3) return dfs(lx, ly - dx, ux, uy, n + 1);
    return -999;
}

int main() {
    cin >> x >> y;
    cout << dfs(0, 0, 0, 0, 0) << '\n';
    return 0;
}

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

class Point {
  public:
    int x;
    int y;
};

int main() {
    
    int x, y;
    cin>>x>>y;
    
    Point top_right, under_left;
    top_right.x = 1;
    top_right.y = 1;
    under_left.x = 0;
    under_left.y = 0;
    
    for (int i = 0;; i++) {
        if (top_right.x > x && top_right.y > y && under_left.x <= x && under_left.y <= y) {
            cout<<(i % 3) + 1<<endl;
            break;
        }
        
        if (i % 4 == 0) top_right.x += top_right.y - under_left.y;
        else if (i % 4 == 1) top_right.y += top_right.x - under_left.x;
        else if (i % 4 == 2) under_left.x += under_left.y - top_right.y;
        else under_left.y += under_left.x - top_right.x;
    }

    return 0;
}

C++: #include <cstdio>
using namespace std;
int ys[4] = {0, 0, -2, -2};
int xs[4] = {0, 1, 1, 0};
int fib[3];

void fibCalc() {
    fib[0] = fib[1];
    fib[1] = fib[2];
    fib[2] = fib[0]+fib[1];
}

bool check(const int &y, const int &x) {
    if (y <= ys[0] && y >= ys[3] && x >= xs[0] && x <= xs[1]) return true;
    return false;
}

void change(const int &idx) {
    if (idx == 3) xs[0]-=fib[2], xs[3]-=fib[2];
    else if (idx == 0) ys[0]+=fib[2], ys[1]+=fib[2];
    else if (idx == 1) xs[1]+=fib[2], xs[2]+=fib[2];
    else if (idx == 2) ys[2]-=fib[2], ys[3]-=fib[2];
}


int main()
{

    int x, y, idx, num; //y: height val, x: width val
    scanf("%d %d", &x, &y);
    y*= -1;
    num = 3;
    idx = 3;
    fib[0] = 1, fib[1] = 2, fib[2] = 3;
    if (x == 0 && y == 0) printf("%d\n", 1);
    else if (x == 1 && y == 0) printf("%d\n", 2);
    else {
        for (;;) {
            if (check(y, x)) { printf("%d\n", num); break; }
            else {
                change(idx);
                idx = (idx+1) % 4;
                fibCalc();
                num = (num + 1 > 3) ? 1 : num+1;
            }
        }

    }
    return 0;
}