Only one case is giving correct


can i know what the problem in the code is?

(a-b)%MOD = (a%MOD - b%MOD + MOD)%MOD

because (a>b) does not imply (a%MOD>b%MOD) so to keep everything positive, additional +MOD, which would be nullified by the whole (…)%MOD