Hello everybody! The above problem is a combinatorics problem I could not solve. :( This is ZIO $2014$, P$1$.
Here is my approach (feel free to point out any mistakes in it, that's why I am asking this question for): The example given provides a really neat walk-through of how to solve the problem. Also, noticing the fact that the words in the sets have a lot in common motivates us to use the approach. I first began trying to find out elements that share a lot in common and then group them into different sets and then try to find the elements in the sets with common parts. Rearrange accordingly and what we have got there is how to solve the problem. I made this: {there, theirs, therefore, three, threshold, thorium, tree} ; {hence, her} ; {shore, rest} Now for the master-plan, I tried to put the "th" so that it is always there and change the rest, then we can remove the "h" and write "tree" and then the rest similarly. But apparently, this doesn't seem to be the optimal solution.
How do we solve this problem?
The answers are - $88, 120, 115$.
Any help would be appreciated. Thanks!

Here's an optimal strategy, with proof that there isn't a better strategy:
Let $w$ be your word set.
Proof that this is optimal:
Consider the set $T := \{w' : w' \text{ is a nonempty prefix of some }w \in S\}$.
For each $w' \in T$, at least one "add" operation needs to be performed to make the prefix show up on the rack, namely the operation that adds the prefix's last character. These operations must all be distinct.
For each $w' \in T$ that is not a prefix of the last printed word, a "remove" operation needs to be performed to make the prefix stop being on the rack, namely the operation that removes the prefix's last character. Again, these operations must all be distinct.
For each word, at least one "print" operation needs to be performed.
The total amount of operations is therefore bounded from below by $|T| + (|T|-n) + |S|$.
It is easy to verify that the aforementioned algorithm does indeed complete each prefix only once, and dismantle each prefix only once (except the prefixes of $x$, which are permanent), and print each word only once. Therefore the algorithm is optimal.
Example: The word set $S = \{their, her, tree, three, there\}$ would be sorted as follows (given $x = their$): $$L = (her, tree, three, there, their)$$
There are 16 distinct prefixes in these words, so the number of required operations is $16 + (16 - 5) + 5 = 32$.