$12 n$ is a positive integer, $S_{n}=\left\{\left(a_{1}, a_{2}, \cdots, a_{2^{n}}\right) \mid a_{i}=0\right.$ or 1 , $\left.1 \leqslant i \leqslant 2^{n}\right\}$, for any two elements $a=\left(a_{1}, a_{2}, \cdots, a_{2^{n}}\right)$ and $b=\left(b_{1}, b_{2}, \cdots, b_{2^{n}}\right)$ in $S_{n}$, let
$$
d(a, b)=\sum_{i=1}^{2^{n}}\left|a_{i}-b_{i}\right| \text {. }
$$

If $A \subseteq S_{n}$, such that for any two different elements $a, b$ in $A$, there is $d(a, b) \geqslant 2^{n-1}$, then $A$ is called a good subset. Find the maximum number of elements in a good subset of $S_{n}$.
If $a_{i} \neq b_{i}$, then $a$ and $b$ are said to have a different component at the $i$-th position. It is easy to see that $d(a, b)$ is the number of different component pairs in $a$ and $b$. If $A \subseteq S_{n}$, and any two different elements in $A$ contain at least $2^{n-1}$ different component pairs, then $A$ is called $n$-level good.
First, prove: If $A$ is $n$-level good, then $|A| \leqslant 2^{n+1}$.
In fact, if $|A| \geqslant 2^{n+1}+1$, then $A$ has at least $2^{n}+1$ elements with the same last bit. Without loss of generality, assume $B \subseteq A, |B|=2^{n}+1$, and each element in $B$ has the last bit as 0.
Consider the total number of different component pairs $N$ among all elements in $B$.
On one hand, since any two different elements in $B$ have at least $2^{n-1}$ different component pairs, we have
$$
N \geqslant 2^{n-1} \cdot \mathrm{C}_{2^{n}+1}^{2} = 2^{n-1} \cdot 2^{n-1} \cdot (2^{n}+1).
$$

On the other hand, for the $i$-th component of elements in $B$ ($1 \leqslant i \leqslant 2^{n}-1$), let there be $x_{i}$ zeros and $2^{n}+1-x_{i}$ ones, then
$$
\begin{aligned}
N & = \sum_{i=1}^{2^{n}-1} x_{i}(2^{n}+1-x_{i}) \leqslant \sum_{i=1}^{2^{n}-1} 2^{n-1} \cdot (2^{n-1}+1) \\
& = 2^{n-1}(2^{n-1}+1)(2^{n}-1),
\end{aligned}
$$

Thus, we have $2^{n-1} \cdot (2^{n-1}+1) \cdot (2^{n}-1) \geqslant 2^{n-1} \cdot 2^{n-1} \cdot (2^{n}+1)$, hence $0 \leqslant -1$, which is a contradiction!
Next, recursively construct an $n$-level good subset $A_{n}$ such that $|A_{n}|=2^{n+1}$.
When $n=1$, take $A_{1}=\{(0,0),(0,1),(1,0),(1,1)\}$.
Assume $A_{n}$ is an $n$-level good subset, and $|A_{n}|=2^{n+1}$. For $a \in S_{n}, a=(a_{1}, a_{2}, \cdots, a_{2^{n}})$, define $a'=(1-a_{1}, 1-a_{2}, \cdots, 1-a_{2^{n}})$, and let $A_{n+1}=\{(a, a) \text{ or } (a, a') \mid a \in A_{n}\} \subseteq S_{n+1}$. Clearly,
$$
|A_{n+1}|=2|A_{n}|=2^{n+2}.
$$

For different elements $a, b$ in $A_{n}$, it is easy to see:
$$
\begin{aligned}
d((b, b), (a, a')) & = 2^{n}, d((a, a), (b, b)) \\
& = 2d(a, b) \geqslant 2 \cdot 2^{n-1} = 2^{n}, \\
d((a, a), (b, b')) & = 2^{n}, d((a, a'), (b, b')) \\
& = 2d(a, b) \geqslant 2 \cdot 2^{n-1} = 2^{n}.
\end{aligned}
$$

Therefore, $A_{n+1}$ is $(n+1)$-level good.
Thus, the maximum value of $|A|$ is $2^{n+1}$.