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;
using i64 = long long;

struct coor{
    pair<i64, i64> x, y;
};

int main(){
    i64 X,Y;
    cin >> X >> Y;
    vector<i64> fib(500);
    fib[0] = fib[1] = 1;
    for(int i = 2; i < 500; i++) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }

    coor now = {{0, 1}, {0, 1}};
    i64 way = 0;
    i64 color = 0;
    int i = 1;
    while(i < 500){

        //cout << color << " -----" << endl;
        //cout << now.x.first << " " << now.x.second << endl;
        //cout << now.y.first << " " << now.y.second << endl;

        if(now.x.first <= X && X < now.x.second 
        && now.y.first <= Y && Y < now.y.second){
            cout << color+1 << endl;
            return 0;
        }
        
        coor next;
        if(way == 0) {
            next.x.first = now.x.second;
            next.x.second = next.x.first + fib[i];
            next.y.first = now.y.first;
            next.y.second = next.y.first + fib[i];
        }
        if(way == 1){
            next.x.second = now.x.second;
            next.x.first = next.x.second - fib[i];
            next.y.first = now.y.second;
            next.y.second = next.y.first + fib[i];
        }
        if(way == 2){
            next.x.second = now.x.first;
            next.x.first = next.x.second - fib[i];
            next.y.second = now.y.second;
            next.y.first = now.y.second - fib[i]; 
        }
        if(way == 3){
            next.x.first = now.x.first;
            next.x.second = next.x.first + fib[i];
            next.y.second = now.y.first;
            next.y.first = next.y.second - fib[i];
        }

        now = next;
        i++, way++, color++;
        way %= 4;
        color %= 3;
    }

    cout << 0 << endl;
}

C++: #include<iostream>
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 <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll x,y;
    cin >> x >> y;
    ll sx,sy,tx,ty;
    sx = sy = tx = ty = 0;
    ll color = 0;
    ll dir = 0;
    while(sx > x || x > tx || sy > y || y > ty){
              switch(dir){
                    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;
              }
              color = (color+1)%3;
              dir = (dir+1)%4;
          }
    cout << color + 1 << endl;
    return 0;
}

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

int main() {
	pair<int, int> xy, a, b;
	cin >> xy.first >> xy.second;
	int i;
	vector<int> c(34, 1);
	for (i = 2; i < 34; ++i) c[i] = c[i - 2] + c[i - 1];
	for (i = 0; a.first > xy.first || a.second > xy.second || b.first < xy.first || b.second < xy.second; ++i) {
		if (0 == i % 4) {
			a.first += c[i];
			b.first += c[1 + i];
			b.second += c[1 + i] - c[i];
		}
		else if (1 == i % 4) {
			a.first += c[i] - c[1 + i];
			a.second += c[i];
			b.second += c[1 + i];
		}
		else if (2 == i % 4) {
			a.first -= c[1 + i];
			a.second += c[i] - c[1 + i];
			b.first -= c[i];
		}
		else {
			a.second -= c[1 + i];
			b.first += c[1 + i] - c[i];
			b.second -= c[i];
		}
	}
	cout << 1 + i % 3 << endl;
}

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

int fib[10000];

int main(){
	fib[0]=fib[1]=1;
	for(int i=2;i<40;i++){
		fib[i]=fib[i-1]+fib[i-2];
	}

	double x,y;	cin>>x>>y;
	x+=0.5;	y+=0.5;

	double sY=1, sX=0;
	int flag=0;

	while(1){
		double pY=sY, pX=sX;
		switch(flag%4){
			case 0:	// 東
				sY-=fib[flag];
				sX+=fib[flag];
				break;
			case 1: // 北
				sY+=fib[flag];
				sX+=fib[flag];
				break;
			case 2: // 西
				sY+=fib[flag];
				sX-=fib[flag];
				break;
			case 3: // 南
				sY-=fib[flag];
				sX-=fib[flag];
				break;
		}

		int color=1+(flag%3);
		if( (pY<y && y<sY)||(sY<y && y<pY)){
			if((pX<x&&x<sX)||(sX<x&&x<pX)){
				cout<<color<<endl;
				break;
			}
		}

		flag++;
	}


	return 0;
}

C++: #include <bits/stdc++.h>
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;
}