Lunchtime July 2021 - Beautiful Pairs

Why PBDS solution gives TLE ?
I have solved the problem using lower bound but I want to know why PBDS is giving TLE it works in O(log(n))…

Problem Link :- Contest Page | CodeChef
TLE solution :- Solution: 49295112 | CodeChef
Ac solution :- Solution: 49296921 | CodeChef