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 <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

ll l,r,d,u ;

bool check(ll x,ll y){
	return l<=x&&x<r&&d<=y&&y<u ;
}

int main(){

	l = 0 ; r = 1 ; d = 0 ; u = 1 ;
	ll x,y ;
	cin >> x >> y ;
	ll cnt = 1 ;
	while(!check(x,y)){
		if(cnt%4==1){
			ll sub = u-d ;
			r += sub ;
		}
		if(cnt%4==2){
			ll sub = r-l ;
			u += sub ;
		}
		if(cnt%4==3){
			ll sub = u-d ;
			l -= sub ;
		}
		if(cnt%4==0){
			ll sub = r-l ;
			d -= sub ;
		}
		cnt++ ;
	}
	if(cnt%3==0) cout << 3 ;
	else cout << cnt%3 ;
	cout << endl ;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007



signed main(){
    int u = 0, r = 0;
    int d = 0, l = 0;
    int x, y;
    cin >> x >> y;
    int f[3] = {0};
    f[0] = 0;
    f[1] = 0;
    f[2] = 1;
    int ans = 0;
    int mp[3];
    mp[0] = 1;
    mp[1] = 2;
    mp[2] = 3;
    for(int i = 0;;i++){
        if(l <= x && x <= r && d <= y && y <= u){
            ans = mp[i % 3];
            break;
        }
        f[0] = f[1];
        f[1] = f[2];
        f[2] = f[0] + f[1];
        int fb = f[2];
        if(i % 4 == 0){
            r += fb;
        }
        else if(i % 4 == 1){
            u += fb;
        }
        else if(i % 4 == 2){
            l -= fb;
        }
        else if(i % 4 == 3){
            d -= fb;
        }
    }
    cout << ans << endl;
    

    return 0;
}

/*

*/

C++: #include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

struct Problem {

	void Solve() {
		int x, y; cin >> x >> y;
		int L = 0, T = 1, R = 1, B = 0;
		int C = 0;
		int D = 0;
		while (true) {

			if (L <= x && x < R)
				if (B <= y && y < T) {
					cout << C + 1 << endl;
					break;
				}

			if (D == 0) { R += (T - B); }
			if (D == 1) { T += (R - L); }
			if (D == 2) { L -= (T - B); }
			if (D == 3) { B -= (R - L); }

			D = (D + 1) % 4;
			C = (C + 1) % 3;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}