Let $n \ge 1$ be a fixed positive integer. We consider all the sets $S$ which consist of sub-sequences of the sequence $0, 1,2, ..., n$ satisfying the following conditions: i) If $(a_i)_{i=0}^k$ belongs to $S$, then $a_0 = 0$, $a_k = n$ and $a_{i+1} - a_i \le 2$ for all $0 \le i \le k - 1$. ii) If $(a_i)_{i=0}^k$ and $(b_j)^h_{j=0}$ both belong to $S$, then there exist $0 \le i_0 \le k - 1$ and $0 \le j_0 \le h - 1$ such that $a_{i_0} = b_{j_0}$ and $a_{i_0+1} = b_{j_0+1}$. Find the maximum value of $|S|$ (among all the above-mentioned sets $S$).
Problem
Source: 2016 Saudi Arabia GMO TST level 4+, III p2
Tags: inequalities, Subsets, combinatorics, algebra