Is it rated?
To solve this problem, you just had to read the problem statement carefully. Looking through the explanations for the example cases was pretty useful.
Step 1
How do we check if the round is rated for sure?
The round is rated for sure if anyone's rating has changed, that is, if ai ≠ bi for some i.
Step 2
How do we check if the round is unrated for sure?
Given that all ai = bi, the round is unrated for sure if for some i < j we have ai < aj. This can be checked using two nested for-loops over i and j.
Exercise: can you check the same using one for-loop?
Step 3
How do we find that it's impossible to determine if the round is rated or not?
If none of the conditions from steps 1 and 2 is satisfied, the answer is "maybe
".
Code
n = int(input())
results = []
for i in range(n):
results.append(list(map(int, input().split())))
for r in results:
if r[0] != r[1]:
print("rated")
exit()
for i in range(n):
for j in range(i):
if results[i][0] > results[j][0]:
print("unrated")
exit()
print("maybe")