We consider lattice paths starting from $(0,0)$ containing horizontal $(1,0)$-steps and vertical $(0,1)$-steps only, with $x<y$ at all other points besides the origin.
The following is valid. The number of paths of length $2n$ starting at $(0,0)$ and never touching the diagonal $x=y$ again is
\begin{align*}
\binom{2n-1}{n-1}\qquad\qquad\qquad n\geq 1
\end{align*}
Note, the number of paths of shortest length from $(x_0,y_0)$ to $(x_1,y_1)$ with $x_0\leq x_1$ and $y_0\leq y_1$ is
\begin{align*}
\binom{(x_1-x_0)+(y_1-y_0)}{x_1-x_0}\tag{1}
\end{align*}
Paths of length $2n$ starting at $(0,0)$ and never touching the diagonal again end in points
\begin{align*}
(k,2n-k)\qquad\qquad\qquad 0\leq k \leq n-1
\end{align*}
Since the first step is always from $(0,0)$ to $(0,1)$ in order to walk above the diagonal, we consider at first the number of all paths from $(0,1)$ to $(k,2n-k)$. This number is according to (1)
\begin{align*}
\binom{2n-1}{k}\qquad\qquad\qquad 0\leq k \leq n-1
\end{align*}
From this number we have to subtract the number of all paths from $(0,1)$ to $(k,2n-k)$ which touch (or cross) the diagonal $x=y$.
This can be determined using Andre's Reflection Principle:
A path starting from $(0,1)$ going to $(k,2n-k)$ which touches the diagonal, will touch it the first time let's say at $(t,t)$. So, each such path consists of two parts. The first part from $(0,1)$ to $(t,t)$ and the second from $(t,t)$ to $(k,2n-k)$. We bijectively map paths of this shape by reflecting the first part at the diagonal and leaving the second part unchanged. This way we get a reflected path starting at $(1,0)$ crossing at $(t,t)$ the diagonal the first time and ending in $(k,2n-k)$.
We conclude: The number of paths from $(0,1)$ to $(k,2n-k)$ which touch the diagonal $x=y$ is equal to the number of all pathes from $(1,0)$ to $(k,2n-k)$ and is according to (1)
\begin{align*}
\binom{2n-1}{k-1}
\end{align*}
Let's denote with $P_k(n)$ the number of all paths from $(0,0)$ to $(k,2n-k)$ which do not touch the diagonal again. The following is valid for $n\geq 1$
\begin{align*}
P_k(n)=
\begin{cases}
1\qquad\qquad &k=0\\
\binom{2n-1}{k}-\binom{2n-1}{k-1}\qquad\qquad &k\geq 1
\end{cases}\tag{2}
\end{align*}
Note that for $k=0$ there is exactly one path from $(0,0)$ to $(0,2n)$. Since in this case there are no paths touching the diagonal which are to subtract, we interpret the binomial coeffient $\binom{r}{s}$ with negative $s$ as usual with zero and we obtain $P_0(n)=\binom{2n-1}{0}-\binom{2n-1}{-1}=1$.
Now it's time to harvest: The number of all paths of length $2n$ starting at $(0,0)$ and never touching the diagonal again is
\begin{align*}
\sum_{k=0}^{n-1}P_k(n)&=\sum_{k=0}^{n-1}\left(\binom{2n-1}{k}-\binom{2n-1}{k-1}\right)\\
&=\sum_{k=0}^{n-1}\binom{2n-1}{k}-\sum_{k=1}^{n-1}\binom{2n-1}{k-1}\tag{3}\\
&=\sum_{k=0}^{n-1}\binom{2n-1}{k}-\sum_{k=0}^{n-2}\binom{2n-1}{k}\\
&=\binom{2n-1}{n-1}
\end{align*}
and the claim is proved.
Comment: In (3) we split the sum and skip the index $k=0$ in the right hand sum since it's contribution is zero. In the following line we shift the index by $1$ in the right hand sum.
I find it easier to work with up-down paths, defined as sequence of up-steps (e.g., from $\langle m,n\rangle$ to $\langle m+1,n+1\rangle$) and downsteps (e.g., from $\langle m,n\rangle$ to $\langle m+1,n-1\rangle$). A Dyck path is then an up-down path that does not go below the $x$-axis, and there are $C_n$ Dyck paths from $\langle 0,0\rangle$ to $\langle 2n,0\rangle$.
If $n,n'\ge 0$, $m<m'$, and $t\ge 0$, let $\mathscr{D}(m,n,m',n',t)$ be the set of Dyck paths from $\langle m,n\rangle$ to $\langle m',n'\rangle$ that hit the $x$-axis exactly $t$ times, and let $d(m,n,m',n',t)=|\mathscr{D}(m,n,m',n',t)|$. Thus, $d(0,0,2n,0,2)=C_n$.
Suppose that $t\ge 1$, and $0\le k<t$. Let $P\in\mathscr{D}(m,n,m',n',t)$. Let the points where $P$ hits the $x$-axis be $\langle\ell_i,0\rangle$ for $i=1,\ldots,t$, where $\ell_1<\ldots<\ell_t$. Since $P$ is a Dyck path, $P$ has an up-step immediately after each of these points except possibly the last. Remove the first $k$ of these up-steps, and translate the resulting path upwards $k$ units to get a path $\hat P$; it’s straightforward to check that $\hat P\in\mathscr{D}(m,n+k,m'-k,n',t-k)$: the path has been shortened by $k$ steps, and the first $k$ hits have been eliminated.
This procedure is reversible. If $P\in\mathscr{D}(m,n+k,m'-k,n',t-k)$, we first shift $P$ down by $k$ units to get an up-down path $P'$. For $i=1,\ldots,k$ let $\ell_i$ be minimal such that $\langle\ell_i,1-i\rangle$ is on $P'$. Let $Q$ be the up-down path obtained from $P'$ by inserting an up-step immediately after each of the points $\langle\ell_i,1-i\rangle$. Then $Q\in\mathscr{D}(m,n,m',n',t)$, and $Q=\hat P$. It follows that
$$d(m,n,m',n',t)=d(m,n+k,m'-k,n',t-k)\;.$$
In particular,
$$d(0,0,2n,0,k+1)=d(0,k,2n-k,0,1)=d(0,0,2n-k,k,1)\;.$$
This bijection between paths $P$ and $\hat P$ is the up-down version of the correspondence that is very, very badly described at your CodeChef link, where its author writes ‘This mapping is same as decreasing value of $y$ for a path when it touches a diagonal’.
Each path in $\mathscr{D}(0,0,2n-k,k,1)$ must begin with an up-step; if we remove this up-step and shift the path one unit down and to the left, we get a Dyck path from $\langle 0,0\rangle$ to $\langle 2n-k-1,k-1\rangle$. Conversely, any Dyck path from $\langle 0,0\rangle$ to $\langle 2n-k-1,k-1\rangle$ becomes a path in $\mathscr{D}(0,0,2n-k,k,1)$ if we shift it one unit up and to the right and prepose an up-step. Thus,
$$d(0,0,2n-k,k,1)=\sum_{t\ge 1}d(0,0,2n-k-1,k-1,t)\;.$$
Each up-down path from $\langle 0,0\rangle$ to $\langle 2n-k-1,k-1\rangle$ corresponds to a possible sequence of $2n-k-1$ votes, $n-1$ of them for candidate $A$ and $n-k$ of them for candidate $B$. On this interpretation the Dyck paths in $\mathscr{D}(0,0,2n-k-1,k-1,1)$ correspond to the sequences in which candidate $A$ is never behind candidate $B$. Calculating the number of such paths is essentially the ballot problem.
Clearly there are $\binom{2n-k-1}{n-1}$ up-down paths from $\langle 0,0\rangle$ to $\langle 2n-k-1,k-1\rangle$. If $P$ is one of these paths that is not a Dyck path, there is a least $\ell$ such that $\langle\ell,-1\rangle$ is on the path $P$. Reflect the initial segment of $P$ between $\langle 0,0\rangle$ and $\langle\ell,-1\rangle$ in the line $y=-1$; the result is a path $P'$ from $\langle 0,-2\rangle$ to $\langle 2n-k-1,k-1\rangle$ that first hits the line $y=-1$ at $x=\ell$. Note that if this initial segment has $u$ up-steps, then it has $u+1$ down-steps, and the rest of $P$ has $n-1-u$ up-steps. As a result, $P'$ has $(n-1-u)+(u+1)=n$ up-steps and $n-k-1$ down-steps.
Conversely, if $P$ is an up-down path from $\langle 0,-2\rangle$ to $\langle 2n-k-1,k-1\rangle$ that first hits the line $y=-1$ at $x=\ell$, reflecting the first $\ell$ steps of $P$ in the line $y=-1$ produces an up-down path $Q$ from $\langle 0,0\rangle$ to $\langle 2n-k-1,k-1\rangle$ that first hits the line $y=-1$ at $x=\ell$, and it’s clear that $Q'=P$. Every up-down path from $\langle 0,-2\rangle$ to $\langle 2n-k-1,k-1\rangle$ hits the line $y=-1$, and there are $\binom{2n-k-1}{n}$ such paths (since each has $n$ up-steps and $n-k-1$ down-steps). Thus, the number of up-down paths from $\langle 0,0\rangle$ to $\langle 2n-k-1,k-1\rangle$ that are not Dyck paths is $\binom{2n-k-1}n$, and
$$\begin{align*}
d(0,0,2n,0,k+1)&=\binom{2n-k-1}{n-1}-\binom{2n-k-1}n\\
&=\binom{2n-k-1}{n-k}-\binom{2n-k-1}{n-k-1}\\
&=\binom{2n-k-1}{n-k}\left(1-\frac{n-k}{n}\right)\\
&=\binom{2n-k-1}{n-k}\frac{k}n\;.
\end{align*}$$
The Dyck paths in $\mathscr{D}(0,0,2n,0,k+1)$ correspond naturally to the paths in the plane from $\langle 0,0\rangle$ to $\langle n,n\rangle$ using only right-steps and up-steps that hit the diagonal exactly $k-1$ times between the two endpoints, or $k+1$ times including the endpoints.
Best Answer
There are $2C_{n-1}$ paths that never touch the diagonal between the endpoints. A path that touches the diagonal exactly once between the endpoints, at $\langle k,k\rangle$, is the union of a Dyck path of length $k-1$ and a Dyck path of length $n-k-1$, and there are $2$ choices for each of these paths, one above and one below the diagonal. Thus, there are
$$4\sum_{k=1}^{n-1}C_{k-1}C_{n-k-1}=4\sum_{k=0}^{n-2}C_kC_{n-2-k}=4C_{n-1}$$
paths that hit the diagonal exactly once between the endpoints, and the desired number is therefore
$$\binom{2n}n-6C_{n-1}\,.$$
As a quick minimal sanity check, for for $n=2$ this is $\binom42-6C_1=0$, and for $n=3$ it is $\binom63-6C_2=20-6\cdot 2=8$, both of which are correct.