Copy the following values and paste into A1:E9 cells in excel sheet.
The formula is in cell D25
=RANK.EQ($B25,$B$25:$B$32)+COUNTIFS($B$25:$B$32,$B25,$C$25:$C$32,">"&$C25)+COUNTIFS(B$24:B24,B25,C$24:C24,C25)
Since it takes one row above the table, the table cannot be started in row 1. If there is a header, then it works and return this result: