June challenge div3 - Beautiful Pairs

Please either post all of your code, formatted or (better!) link to your submission :slight_smile:

Edit:

Also, run it through the testcase here and ensure it gives the correct answer.