[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n,x,y=long long
    ny=long long
    wasOut=bool
    borderPoints=0
    nx=0
    read n
    if n is 0
        print 1
        return to indicate successful execution
    else if n<0
        return to indicate successful execution
    end of the block
    subtract n from x
    while x<=0
        wasOut=true
        ny=sqrt(n*n-x*x)+1
        for y=-ny to 0 inclusive
            if x*x+y*y <= n*n
                if wasOut is true
                    wasOut=false
                    increment borderPoints
                    if x is 0 increment nx
                else
                    if x<0
                        if (x-1)^2+y^2 > n^2
                            increment borderPoints
                            if x is 0 increment nx
                        else
                            y=n+1
                        end of the block
                    else if x>0
                        if (x+1)^2+y^2 > n^2
                            increment borderPoints
                            if x is 0 increment nx
                        else
                            y=n+1
                        end of the block
                    end of the block
                end of the block
            end of the block
        end of the block
        increment x
    end of the block
    print 2*(borderPoints*2-nx)-2
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n, x, y;
    long long ny;
    bool wasOut;
    long long borderPoints = 0;
    long long nx = 0;
    cin >> n;
    if (n == 0) {
        cout << 1 << endl;
        return 0;
    } else if (n < 0) {
        return 0;
    }
    x = -n;
    while (x <= 0) {
        wasOut = true;
        ny = sqrt(n * n - x * x) + 1;
        for (y = -ny; y <= 0; y++) {
            if (x * x + y * y <= n * n) {
                if (wasOut == true) {
                    wasOut = false;
                    borderPoints++;
                    if (x == 0) { nx++; }
                } else {
                    if (x < 0) {
                        if ((x - 1) * (x - 1) + y * y > n * n) {
                            borderPoints++;
                            if (x == 0) { nx++; }
                        } else {
                            y = n + 1;
                        }
                    } else if (x > 0) {
                        if ((x + 1) * (x + 1) + y * y > n * n) {
                            borderPoints++;
                            if (x == 0) { nx++; }
                        } else {
                            y = n + 1;
                        }
                    }
                }
            }
        }
        x++;
    }
    cout << 2 * (borderPoints * 2 - nx) - 2 << endl;
    return 0;
}