Help in DSA_ 3 Distinct pairs

https://www.codechef.com/viewsolution/32735902
Here is my solution please help where I’m doing wrong . I try so many time but still I’m getting wrong or TLE
@everule1