Years(codeforces)

https://codeforces.com/problemset/problem/1424/G

can you explain this question??
i am not getting the logic for it.