Birthday Paradox

my code gives TLE for testcase #6
link to my code : https://ide.codingblocks.com/s/172643

i checked my code with that given in the video, but still iā€™m getting TLE

@O17LPOLA020011
Handle the case when p==1 separately. The answer for that case must be 366.
That is giving you TLE.