/bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

I am getting this doubt while my code is similar to what he taught in the video

Here is the link to my code: https://ide.codingblocks.com/s/473452

use long long and add return at the end of function
here

It worked but how?

also it is still showing wrong answer on hackerblock question
Link to question:https://hack.codingblocks.com/app/practice/1/1039/problem
Link to Code: https://ide.codingblocks.com/s/473689