Count total number of distinct substrings using tries

I am trying to solve this problem where I have to count total number of distinct substring. I am doing this problem using tries by creating a suffix tries and then counting the number of nodes in my tries. My code works correctly for sample test cases but on submission it is giving SIGBART error. Can someone plz help me identify the problem in my code.

code link - https://onlinegdb.com/HyS4X57bS

problem link - Practice | GeeksforGeeks | A computer science portal for geeks