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 <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
#include <random>
using namespace std;
typedef long long int ll;

int solve(int l,int r,int d,int u,int x,int y,int cnt,int res){
    if(l<=x&&x<r&&d<=y&&y<u){
        return res;
    }
    if(cnt==0){
        r+=(u-d);
    }
    if(cnt==1){
        u+=(r-l);
    }
    if(cnt==2){
        l-=(u-d);
    }
    if(cnt==3){
        d-=(r-l);
    }
    return solve(l,r,d,u,x,y,(cnt+1)%4,(res+1)%3);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x,y; cin >> x >> y;
    cout << solve(0,1,0,1,x,y,0,0)+1 << endl;
}

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int x,y;
    cin>>x>>y;
    int dx[4]={0,-1,0,1};
    int dy[4]={1,0,-1,0};
    int r=1,l=0,u=0,d=0;
    int f1=1,f2=1,f;
    int red=1,yellow=2,blue=3;
    if(x==0 && y==0){
        cout << red << endl;
        return 0;
    }
    if(x==1 && y==0){
        cout << yellow << endl;
        return 0;
    }
    int cnt = 0;
    int now = 2;
    while(true){
        f = f1+f2;
        f1 = f2;
        f2 = f;
        r += max(0,dx[cnt])*f;
        l += min(0,dx[cnt])*f;
        u += max(0,dy[cnt])*f;
        d += min(0,dy[cnt])*f;
        if(l<=x && r>=x && u>=y && d<=y){
            cout << now%3 + 1 << endl;
            return 0;
        }
        cnt = (cnt+1)%4;
        now++;
    }

}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  vector<long long> x1 = {0, 1, 0, -3};
  vector<long long> y1 = {0, 0, 1, 0};
  vector<long long> x2 = {1, 2, 2, 0};
  vector<long long> y2 = {1, 1, 3, 3};
  for (int i = 4; i < 40; i++){
    long long next_x1, next_y1, next_x2, next_y2;
    if (i % 4 == 0){
      long long a = x2[i - 3] - x1[i - 1];
      next_x1 = x1[i - 1];
      next_y1 = y1[i - 1] - a;
      next_x2 = x1[i - 1] + a;
      next_y2 = y1[i - 1];
    }
    if (i % 4 == 1){
      long long a = y2[i - 3] - y1[i - 1];
      next_x1 = x2[i - 1];
      next_y1 = y1[i - 1];
      next_x2 = x2[i - 1] + a;
      next_y2 = y1[i - 1] + a;
    }
    if (i % 4 == 2){
      long long a = x2[i - 1] - x1[i - 3];
      next_x1 = x2[i - 1] - a;
      next_y1 = y2[i - 1];
      next_x2 = x2[i - 1];
      next_y2 = y2[i - 1] + a;
    }
    if (i % 4 == 3){
      long long a = y2[i - 1] - y1[i - 3];
      next_x1 = x1[i - 1] - a;
      next_y1 = y2[i - 1] - a;
      next_x2 = x1[i - 1];
      next_y2 = y2[i - 1];
    }
    x1.push_back(next_x1);
    y1.push_back(next_y1);
    x2.push_back(next_x2);
    y2.push_back(next_y2);
  }
  int ans = -1;
  for (int i = 0; i < 40; i++){
    if (x1[i] <= x && x < x2[i] && y1[i] <= y && y < y2[i]){
      ans = i % 3 + 1;
      break;
    }
  }
  cout << ans << endl;
}

C++: #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;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int dp[100000] = {1,1};

int fib(int n){
   for(int i = 2; i <= n; i++){
       dp[i] = dp[i-1] + dp[i-2];
   }
   return dp[n];
}

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