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>
using namespace std;

bool isIn(int x, int y, int x_max, int x_min, int y_max, int y_min){
	if(x<=x_max && x>=x_min){
		if(y<=y_max && y>=y_min){
			return true;
		}
	}
	return false;
}

int main(){

	int x,y;
	cin >> x >> y;

	long int count = 0;
	int x_min=0, x_max=0, y_min=0, y_max=0;
	int f_n2=1, f_n1=1, f=1;
	if( isIn(x,y,x_max,x_min,y_max,y_min) ){cout << 1 << endl; return 0;};

	//n=1
	++count;
	x_max = 1;
	if (isIn(x,y,x_max,x_min,y_max,y_min)){cout << count%3 + 1 << endl; return 0;}	

	while(true){
		++count;
		f_n2 = f_n1;
		f_n1 = f;
		f = f_n2 + f_n1;

		if(count%4==2){y_max += f;}
		else if(count%4==3){x_min -= f;}
		else if(count%4==0){y_min -= f;}
		else {x_max += f;}
		if(isIn(x,y,x_max,x_min,y_max,y_min)){cout << count%3+1 << endl; break;}
	}

	return 0;
}

C++: //AOJ 409 Floor

#include<stdio.h>

#define MIN(a,b) ((a)<=(b)?(a):(b))
#define MAX(a,b) ((a)>=(b)?(a):(b))
typedef struct {int x1,y1,x2,y2;} Rect;
Rect a1,a2,a;
//a1.x1
int main()
{
	int x,y,id;
	
	scanf("%d%d",&x,&y);
	if(x==0&&y==0)puts("1");
	else if(x==1&&y==0)puts("2");
	else{
		a2.x1=a2.x2=1,id=2;
		while(1){
			if((id&1)==0){//北or南
				a.x1=MIN(a1.x1,a2.x1),a.x2=MAX(a1.x2,a2.x2);
				if(id%4==2)//北
				{
					a.y1=a2.y2+1,a.y2=a.y1+a.x2-a.x1;
				}
				else
				{
					a.y2=a2.y1-1,a.y1=a.y2-(a.x2-a.x1);
				}
			}else{
				a.y1=MIN(a1.y1,a2.y1),a.y2=MAX(a1.y2,a2.y2);
				if(id%4==1){//東
					a.x1=a2.x2+1,a.x2=a.x1+a.y2-a.y1;
				}else{
					a.x2=a2.x1-1,a.x1=a.x2-(a.y2-a.y1);
				}
			}
			
			if(a.x1<=x&&x<=a.x2&&a.y1<=y&&y<=a.y2){
				printf("%d\n",id%3+1);
				break;
			}
			
			id++;
			a1=a2,a2=a;
		}
	}
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int x,y; scanf("%d%d",&x,&y);
    int nx=0,ny=0,sz=1,pre=0,col=0,rot=0;
    while(1){
        if(nx<=x&&x<nx+sz&&ny<=y&&y<ny+sz){
            printf("%d\n",(col%3)+1); return 0;
        }
        int nxt=sz+pre;
        if(rot==0)nx+=sz;
        if(rot==1){
            nx-=pre; 
            ny+=sz;
        }
        if(rot==2){
            nx-=nxt;
            ny-=pre;
        }
        if(rot==3)ny-=nxt;
        pre=sz; sz=nxt;
        col++; rot=(rot+1)%4;
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 1; i < (n); i++)
using namespace std;
using ll = long long;

int f[101];

int main() {
	
	int x, y;
	int a, b;
	int limnx=0, limny=0;
	int limdx=0, limdy=0;
	int limx, limy;
	cin >> x >> y;

	a = 1; b = 1;
	int cnt =1;
	if (x == 0 && y == 0) {
		cout << cnt << endl; return 0;
	}	
	 if(x>0)x++;
	if(y>0)y++;
	while (1) {
		limx = a + b;//2=1+1
		a = b;
		b = limx;
		limnx = limx + limdx;//limnx=2
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}

		limy = a + b;//3=1+2
		a = b;
		b = limy;
		limny = limy + limdy;
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}

		limx = a + b;//2+3;
		a = b;
		b = limx;
		limdx = -limx + limnx;//limdx=-5+2
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}

		limy = a + b;
		a = b;
		b = limy;
		limdy = -limy + limny;//-8+3
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}
	}
	

	return 0;
}