SPP- 1 test case fails


The code is giving wrong answer because of mod. Can you please check whether i am using mod right or not?
Hint on spoj suggest to use %lld instead of %l64d. I am using long long Is it same as %lld ?

Why code gives TLE if I change unsigned long long to long long