Can you please tell where I am going wrong

i have done some modifications in your code after that it got AC

  1. s=1 and e=e=((p*(p+1))/2)*8

  2. i have also done some changes in cancook function

you can check all changes in code below

Modified code