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>
#define int long long
using namespace std;
int input() {
	int r;
	scanf("%lld", &r);
	return r;
}
signed main() {
	int x = input(), y = input();
	if      (       0 <= x && x <=       0 &&        0 <= y && y <=       0)printf("1\n");//1
	else if (       1 <= x && x <=       1 &&        0 <= y && y <=       0)printf("2\n");//1
	else if (       0 <= x && x <=       1 &&        1 <= y && y <=       2)printf("3\n");//2
	else if (      -3 <= x && x <=      -1 &&        0 <= y && y <=       2)printf("1\n");//3
	else if (      -3 <= x && x <=       1 &&       -5 <= y && y <=      -1)printf("2\n");//5
	else if (       2 <= x && x <=       9 &&       -5 <= y && y <=       2)printf("3\n");//8
	else if (      -3 <= x && x <=       9 &&        3 <= y && y <=      15)printf("1\n");//13
	else if (     -24 <= x && x <=      -4 &&       -5 <= y && y <=      15)printf("2\n");//21
	else if (     -24 <= x && x <=       9 &&      -39 <= y && y <=      -6)printf("3\n");//34
	else if (      10 <= x && x <=      64 &&      -39 <= y && y <=      15)printf("1\n");//55
	else if (     -24 <= x && x <=      64 &&       16 <= y && y <=     104)printf("2\n");//89
	else if (    -168 <= x && x <=     -25 &&      -39 <= y && y <=     104)printf("3\n");//144
	else if (    -168 <= x && x <=      64 &&     -272 <= y && y <=     -40)printf("1\n");//233
	else if (      65 <= x && x <=     441 &&     -272 <= y && y <=     104)printf("2\n");//377
	else if (    -168 <= x && x <=     441 &&      105 <= y && y <=     714)printf("3\n");//610
	else if (   -1155 <= x && x <=    -169 &&     -272 <= y && y <=     714)printf("1\n");//987
	else if (   -1155 <= x && x <=     441 &&    -1869 <= y && y <=    -273)printf("2\n");//1597
	else if (     442 <= x && x <=    3025 &&    -1869 <= y && y <=     714)printf("3\n");//2584
	else if (   -1155 <= x && x <=    3025 &&      715 <= y && y <=    4895)printf("1\n");//4181
	else if (   -7920 <= x && x <=   -1156 &&    -1869 <= y && y <=    4895)printf("2\n");//6765
	else if (   -7920 <= x && x <=    3025 &&   -12815 <= y && y <=   -1870)printf("3\n");//10946
	else if (    3026 <= x && x <=   20736 &&   -12815 <= y && y <=    4895)printf("1\n");//17711
	else if (   -7920 <= x && x <=   20736 &&     4896 <= y && y <=   33552)printf("2\n");//28657
	else if (  -54288 <= x && x <=   -7921 &&   -12815 <= y && y <=   33552)printf("3\n");//46368
	else if (  -54288 <= x && x <=   20736 &&   -87840 <= y && y <=  -12816)printf("1\n");//75025
	else if (   20737 <= x && x <=  142129 &&   -87840 <= y && y <=   33552)printf("2\n");//121393
	else if (  -54288 <= x && x <=  142129 &&    33553 <= y && y <=  229970)printf("3\n");//196418
	else if ( -372099 <= x && x <=  -54289 &&   -87840 <= y && y <=  229970)printf("1\n");//317811
	else if ( -372099 <= x && x <=  142129 &&  -602069 <= y && y <=  -87841)printf("2\n");//514229
	else if (  142130 <= x && x <=  974169 &&  -602069 <= y && y <=  229970)printf("3\n");//832040
	else if ( -372099 <= x && x <=  974169 &&   229971 <= y && y <= 1576239)printf("1\n");//1346269
	else if (-2550408 <= x && x <= -372100 &&  -602069 <= y && y <= 1576239)printf("2\n");//2178309
	else if (-2550408 <= x && x <=  974169 && -4126646 <= y && y <= -602069)printf("3\n");//3524578
	else if (  974169 <= x && x <= 4498746 && -4126646 <= y && y <= 1576239)printf("1\n");//3524578
}

C++: #include <iostream>

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    int l = 0, r = 0, d = 0, u = 0, k = 0, c = 0;
    while(x < l || x > r || y < d || y > u){
        if(k == 0){
            int dy = u-d+1;
            r += dy;
        }
        else if(k == 1){
            int dx = r-l+1;
            u += dx;
        }
        else if(k == 2){
            int dy = u-d+1;
            l -= dy;
        }
        else{
            int dx = r-l+1;
            d -= dx;
        }
        k = (k+1)%4;
        c = (c+1)%3;
    }
    cout << c+1 << endl;
    return 0;
}

C++: // 2020/07/20 Tazoe

#include <iostream>
using namespace std;

// フィボナッチ数
int fib(int n)
{
	if(n==0 || n==1)
		return 1;

	return fib(n-1)+fib(n-2);
}


int main()
{
	int x, y;
	cin >> x >> y;

	int x_min = 0;
	int x_max = 1;
	int y_min = 0;
	int y_max = 1;
	int c = 0;

	while(true){
		if(x_min<=x && x<x_max && y_min<=y && y<y_max){
			cout << c%3+1 << endl;
			return 0;
		}

		// 東
		c++;
		x_min = x_max;
		x_max = x_min+fib(c);
		y_min = y_min;
		y_max = y_min+fib(c);

		if(x_min<=x && x<x_max && y_min<=y && y<y_max){
			cout << c%3+1 << endl;
			return 0;
		}

		// 北
		c++;
		x_max = x_max;
		x_min = x_max-fib(c);
		y_min = y_max;
		y_max = y_min+fib(c);

		if(x_min<=x && x<x_max && y_min<=y && y<y_max){
			cout << c%3+1 << endl;
			return 0;
		}

		// 西
		c++;
		x_max = x_min;
		x_min = x_max-fib(c);
		y_max = y_max;
		y_min = y_max-fib(c);

		if(x_min<=x && x<x_max && y_min<=y && y<y_max){
			cout << c%3+1 << endl;
			return 0;
		}

		// 南
		c++;
		x_min = x_min;
		x_max = x_min+fib(c);
		y_max = y_min;
		y_min = y_max-fib(c);
	}

	return 0;
}