TLE in 4 cases for fib+GCD

https://ide.codingblocks.com/s/70998

can you please help me further optimize this code?

Hi

hint : use segment tree