Let $S$ be a subset of $\{\pm 1\}^n$ such that $\forall x,y\in S$ ($x\neq y$), $x\cdot y<0$. Determine the upper bound of $|S|$ as precise as possible.
(Thanks to the example from @kodlu, the proof is revised.) What I have already proved is $\mathrm{sup}|S|\leq n$ for odd $n$, $\mathrm{sup}|S|\leq n/2$ for even $n$, via probabilistic methods:
For any possible $S$, $m:=|S|$. Let $X_i=1$ whenever the chosen pair differs in the $i$ -th entry, $X_i=0$ otherwise. The expectation of pairs in $S$ different in the $i$ -th entry is $$\mathbb E X_i=\dfrac{m_i(m-m_i)}{\binom{m}{2}}\leq \dfrac{m^2}{4\cdot m(m-1)/2}=\dfrac{m}{2(m-1)}.$$ Here $m_i$ is the number of $v\in S$ taking value $1$ in the $i$ -th entry. Since $\sum_{i=1}^n X_i$ is the total number of entries where pairs taking different values, we shall exclude those $m$ such that $$\mathbb E\sum_{i=1}^n X_i\leq\dfrac{mn}{2(m-1)}<\dfrac{n+1}{2}\quad \text{when } n \text{ is odd},$$ $$\mathbb E\sum_{i=1}^n X_i\leq\dfrac{mn}{2(m-1)}<\dfrac{n}{2}+1\quad \text{when } n \text{ is even}.$$ Therefore, $\mathrm{sup}|S|\leq n+1$ for odd $n$, $\mathrm{sup}|S|\leq n/2$ for even $n$. There is no contradiction to the example from @kodlu.
The theorey of Plotkin bound is exactly what I'm looking for. See the answer by @Mike Earnest.
The condition $x\cdot y<0$ for $\pm1$ vectors is equivalent to the Hamming distance between $x$ and $y$ being least $(n+1)/2$ when $n$ is odd, and at least $n/2+1$ when $n$ is even. Therefore, your question can be rephrased in the language of coding theory:
The Plotkin bound implies the following:
When $n=4k$, there are at most $2\lfloor \frac{2k+2}{3}\rfloor$ vectors in $S$.
When $n=4k+1$, there are at most $2k+2$ vectors in $S$.
When $n=4k+2$, there are at most $2k+2$ vectors in $S$.
When $n=4k+3$, there are at most $4k+4$ vectors in $S$.
Levenshtein showed that the Plotkin bound is attainable provided certain Hadamard matrices exist. Here are the details of the construction which apply to your problem, which I got from Theory of Error Correcting Codes by MacWilliams and Sloane. First, some notation.
Let $H_m$ be an $m\times m$ Hadamard matrix, with entries in $\{\pm 1\}$, normalized so the first row and column are all $+1$.
Let $H_m'$ be the $m\times (m-1)$ matrix given by removing the first column of $H_m$.
Let $H_m''$ be the $(m/2)\times (m-2)$ matrix given by deleting all rows from $H_m'$ whose first entry is $-1$, then deleting the first column of what is left.
Now, onto the construction.
When $n=4k+3$, you can let $S$ be the set of rows of $H_{n+1}'$.
When $n=4k+2$, let $S$ be the set of rows of $H_{n+2}''$.
When $n=4k+1$, let $S$ be the set of rows of $H_{n+3}''$, with one column deleted.
The $n=4k$ case is the trickiest. We will construct a matrix in each sub-case, then $S$ is the set of rows of that matrix.
If $n\equiv 0\pmod {12}$, let $a=n/3$, and let $b=2n/3+4$. Take the first $a$ rows of $H_b''$, concatenate them horizontally with $H_a'$, and delete any column.
If $n\equiv 4 \pmod {12}$, let $a=(n+8)/3$, and let $b=2(n+2)/3$. Take the first $b/2$ rows of $H_a'$, concatenate them horizontally with $H_b''$, and delete any column.
If $n\equiv 8 \pmod{12}$, let $m=(n+4)/3$. Take three copies of $H_m'$, concatenate them horizontally, and delete any column.