Help in JAVA

I just solved Count Substrings in python and implement same logic in java but its WA. Can anybody tell me what I’m doing wrong in java implementation.
Here’s My Submissions

You should declare your c variable as long (instead of int) because the answer can be as large as 5.10^9 which doesn’t fit into int.

Your approach is correct , just declare c as long otherwise integer overflow will occur as constraint is 1 < N < 10^5.

Check your code ACcepted here with the said modification.

Edit : Looks like it has already been answered correctly, didn’t see that before posting. I need to type faster next time.