well I used modulo as well 
simply because he declared it globally
You have a nice knowledge of algos. Good !
she herself said she was an icpc silver medalist bro.
Thanks great. I will learn more and more when people like her be active on discuss.
Konsa waala silver? Regionals yaa world finals? Apne yahaa India mai kuch gold/silver nhi milta for regionalsš
Why donāt you go there (where loopfree is) XD?
you should learn balloon popping problem. This question is very similar to that problem. Here is the link : - LeetCode
why modulus is so time consuming
I used the greedy approach that you stated will pass the Subtask #2 (with distinct powers of 2).
Can you tell me why this greedy approach gave WA for other Subtasks? For which test case my greedy approach will give WA?
Thanks in advance.
I know it only because of experience btw you can refer here - https://stackoverflow.com/questions/27977834/why-is-modulus-operator-slow
Bade hi experienced ho aap toh 
Bs apse kuch 5-10%. Dot dot dot
might be because of integer overflow, try having long dp[][]
Where can we find material to read about Garsia Wachs algortihms?
What does āLinear Caseā mean??
it means just a normal array, i.e. not taking the first and last elements to be adjacent here.
That was really a great problem . Learned many things .
Try making an algorithm to find division and modulus using bitwise operations.
You will realize why.
Solve similar problems like mixture(spoj),matrix chain multiplication