https://www.codechef.com/viewsolution/32099636

this is my solution and every possible thing is used to reduce the time.

use the function as ur code will take a lot time to calculate exponential power

long long fast_power(long long base, long long power) {

long long result = 1;

while(power > 0) {

```
if(power % 2 == 1) { // Can also use (power & 1) to make code even faster
result = (result*base) % MOD;
}
base = (base * base) % MOD;
power = power / 2; // Can also use power >>= 1; to make code even faster
}
return result;
```

}

if N is 10^5…

j<2*10^5+1

So loop will run for (10^5)*(2*10^5+1) will which give TLE!..

Try to think how to get rid of 2*i+1 loop