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<algorithm>
using namespace std;
inline 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 xmin=0;
    int xmax=1;
    int ymin=0;
    int ymax=1;
    int c=0;

    while(1){
        if(xmin<=x&&x<xmax&&ymin<=y&&y<ymax){
            cout << c%3+1 <<endl;
            return 0;
        }
        
        c++;
        xmin=xmax;
        xmax=xmin+fib(c);
        ymin=ymin;
        ymax=ymin+fib(c);
        if(xmin<=x&&x<xmax&&ymin<=y&&y<ymax){
            cout << c%3+1 <<endl;
            return 0;
        }

        c++;
        xmax=xmax;
        xmin=xmax-fib(c);
        ymin=ymax;
        ymax=ymin+fib(c);
        if(xmin<=x&&x<xmax&&ymin<=y&&y<ymax){
            cout << c%3+1 <<endl;
            return 0;
        }

        c++;
        xmax=xmin;
        xmin=xmax-fib(c);
        ymax=ymax;
        ymin=ymax-fib(c);
        if(xmin<=x&&x<xmax&&ymin<=y&&y<ymax){
            cout << c%3+1 <<endl;
            return 0;
        }

        c++;
        xmin=xmin;
        xmax=xmin+fib(c);
        ymax=ymin;
        ymin=ymax-fib(c);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int a, b, x, y;

bool inRange(int t, int u, int v) {
	return (u <= t && t <= v);
}

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	cin >> x >> y;
	int lx = 0, rx = 0;
	int ly = 0, ry = 0;
	int 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 fib[200000] ={ 1,1,2 };

int main(){
	int x, y;
	cin >> x >> y;
	if(x == 0 && y == 0){
		cout << 1 << endl;
		return 0;
	}
	if(x == 1 && y == 0){
		cout << 2 << endl;
		return 0;
	}
	int l = 0;
	int r = 1;
	int u = 2;
	int d = 1;
	for(int i=2; i<100000; i++){
		if(l <= x && x <= r && d <= y && y <= u){
			cout << i%3 +1 << endl;
			break;
		}
		fib[i+1] = fib[i] + fib[i-1];
		if(i % 4 == 0){
			u = d + fib[i+1] - 1;
			l = r + 1;
			r = l + fib[i+1] - 1;
		}
		if(i % 4 == 1){
			l = r - fib[i+1] + 1;
			d = u + 1;
			u = d + fib[i+1] - 1;
		}
		if(i % 4 == 2){
			d = u - fib[i+1] + 1;
			r = l - 1;
			l = r - fib[i+1] + 1;
		}
		if(i % 4 == 3){
			r = l + fib[i+1] - 1;
			u = d - 1;
			d = u - fib[i+1] + 1;
		}
	}
	return 0;
}

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

int main()
{
  i64 x, y;
  cin >> x >> y;
  i64 px[2] = {0, 1};
  i64 py[2] = {0, 1};
  if (x == 0 && y == 0)
  {
    cout << 1 << endl;
    return 0;
  }
  for (i64 i = 0;; i++)
  {
    if (i % 4 == 0)
    {
      px[1] += abs(py[1] - py[0]);
      if (px[0] <= x && x < px[1] && py[0] <= y && y < py[1])
      {
        cout << (i + 1) % 3 + 1 << endl;
        return 0;
      }
    }
    else if (i % 4 == 1)
    {
      py[1] += abs(px[1] - px[0]);
      if (px[0] <= x && x < px[1] && py[0] <= y && y < py[1])
      {
        cout << (i + 1) % 3 + 1 << endl;
        return 0;
      }
    }
    else if (i % 4 == 2)
    {
      px[0] -= abs(py[1] - py[0]);
      if (px[0] <= x && x < px[1] && py[0] <= y && y < py[1])
      {
        cout << (i + 1) % 3 + 1 << endl;
        return 0;
      }
    }
    else
    {
      py[0] -= abs(px[1] - px[0]);
      if (px[0] <= x && x < px[1] && py[0] <= y && y < py[1])
      {
        cout << (i + 1) % 3 + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int x,y; cin >> x >> y;
   long long w = 1, h = 1;
   long long d[4] = {};
   int i = 0;
   while(1){
      if(-1*d[2] <= x && d[0] >= x && -1*d[3] <= y && d[1] >= y){
         
         cout << i%3 + 1 << "\n";
         break;
      }

      if(i%2 == 0){
         w += h;
         d[i%4] += h;
      }else{
         h += w;
         d[i%4] += w;
      }

      
      i++;
      // << w << " " << h << " " << d[0] << " " << d[1] << "\n";
   }
}