Please help !!! SIGSEGV in TCFST10

I don’t know why I am getting SIGSEGV in this problem. I checked other people’s code and my logic is correct. To check why I am getting SIGSEGV, I tried all possible things I could.

I even submitted someone else’s solution, I got AC, I modified my solution which was logically same to that to look like that but I still got SIGSEGV.

Here is the AC one : accepted

Here is my own solution without the modifications : without modification

Here is the one after modification which is almost same as the AC one : with modification

Please help me I have no idea why I am getting SIGSEGV.