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 <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int flag=1,count=0,x,y,minx=0,miny=0,maxx=0,maxy=0,flag2=0,falg3=0;
  int fi[1000000];
  cin>>x>>y;
  if(x==0 && y==0){
    cout<<1<<'\n';
    return(0);
  }
  fi[0]=1;
  while(true){
    if(count%4==0){
      if(count==0){
	maxx=1;
	fi[1]=1;
      }
      else{
	fi[count+1]=fi[count]+fi[count-1];
	maxx+=fi[count+1];
      }
    }
    if(count%4==1){
      fi[count+1]=fi[count]+fi[count-1];
      maxy+=fi[count+1];
    }
    if(count%4==2){
      fi[count+1]=fi[count]+fi[count-1];
      minx+=fi[count+1];
    }
    if(count%4==3){
      fi[count+1]=fi[count]+fi[count-1];
      miny+=fi[count+1];
    }
    count++;
    if(x>=0 && y>=0){
      if(maxy>=y && maxx>=x){
	cout<<count%3+1<<'\n';
	break;
      }
    }
    else if(y>=0 && x<=0){
      if(maxy>=y && minx+x>=0){
	cout<<count%3+1<<'\n';
	break;
      }
    }
    else if(y<=0 && x<=0){
      if(miny+y>=0 && minx+x>=0){
	cout<<count%3+1<<'\n';
	break;
      }
    }
    else if(y<=0 && x>=0){
      if(miny+y>=0 && maxx>=x){
	cout<<count%3+1<<'\n';
	break;
      }
    }      
  }
  return(0);
}

C++: #include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x,y;
  cin>>x>>y;
  int fibo[50];
  fibo[0]=1,fibo[1]=1;
  repi(i,2,50) fibo[i]=fibo[i-1]+fibo[i-2];
  int l=0,r=0,u=0,d=0;
  int color=1,cnt=0;
  while(!(x<=r && x>=l && y<=u && y>=d)){
    if(cnt%4==0){
      r+=fibo[color];
    }
    if(cnt%4==1){
      u+=fibo[color];
    }
    if(cnt%4==2){
      l-=fibo[color];
    }
    if(cnt%4==3){
      d-=fibo[color];
    }
    color++;
    cnt++;
  }
  cout<<1+(color-1)%3<<endl;
  return 0;
}