Editorial
Map the tier names, from easiest to hardest, to . If the mapped tier value is , assign difficulty the rank
A smaller rank means an easier difficulty. This also correctly handles the reversed numeric direction within one tier name: level is easier than level .
Let be the rank of the threshold difficulty. Keep exactly the problems whose rank is at most , then sort them by rank in increasing order. The relative order of problems with the same rank is irrelevant.
The reference implementation additionally sorts equal-difficulty problems by problem number, only to make its own output deterministic.
The time complexity is per test case and the memory complexity is .
Solution written by GPT5.6