Number of simple cycles on the xy-plane We start at the origin, with a number $K=0$. For each step, we move one unit horizontally or vertically. For every vertical step, we add the x-coordinate of that point to $K$ if we go up, and subtract it from $K$ if we go down.
How many simple cycles (i.e., the path ends at the origin, not crossing itself except for the origin) are there ending up with $K=\pm5$?
For example, a rectangular path $(0,0)\to (1,0)\to(1,5)\to(0,5)\to(0,0)$ is such a path.
 A: Observation: We have 
$$
\DeclareMathOperator{curl}{curl}
K 
= \int\limits_C (0, x) \cdot (dx, dy)
= \int\limits_C (0, x, 0) \cdot du
= \int\limits_C A \cdot du
= \int\limits_S \curl A \cdot dS
= \int\limits_S (0,0,1) \cdot dS
= \lvert S \rvert
$$
due to extension into third dimension and Stokes theorem, so we get $K$ by determining the area, thus counting the squares within the loop.
Note: This is an oriented area, we get its normal (up or down) by the right hand rule. A counter clockwise running loop has positive area, a clockwise running loop has negative area.
Equivalent problem:
The number of simple cycles of a given $K$ value is the number of "unit-square areas" of (oriented) area size $K$, containing the origin as border point and the border curve not having intersections, except for the origin.
For $K = 1$ we have $4+2$ such areas.


Where we touch the origin, but do not cross for the diagonal blocks.
For $K = 2$ this seem to be $4 \times 2$ + $4$ + $2 = 14$ areas.



Here we cross the origin for the diagonal blocks.
