What I did wrong during contest

1. I did realize that similarity grows much quicker than instability. Therefore, we need to somehow max the instability while minimizing the
similiarity

2. I also realized that because we have only 26 letters, adding 1 letter after the first 26 ones will increase the instablity by at most 1,
   and yet increase the similarly at by at least 3 when N = 100 (pigeonhole principle) 

3. From here on, I lost the idea

Solution

1. since we need to max instability and min similarily, let's solve them one by one, we will separate the alphabelt into 2 groups, 1 group
   just for contributing to instability and does not add to similarity, and the other just for similarity but not instability

2. Therefore, we choose pairs of letter AB, CD, EF...etc, such that first P words will be ABAB...,
CDCD..., and EFEF...

3. The remaining letters will go with single letter, G, H, I...., i.e, they will add to similarity among themselves (pigeonhole principle),
   but not to the first group , nor will they add to instability
  
4. Where to draw the line? We can brute force search for the size of group 2, but if we calculate the rough number, we can see that just
   take (A, B), (C, D) as part of the first group is enough

5. Reason: first group instability : up to 99 * 2 = 198, second group similarity < 22 * 5