How to optimize this code

question–https://codeforces.com/contest/1366/problem/A
solution -https://ide.codingblocks.com/s/254961

in the contest my i am getting TLE. please tell my wrong approach and how to correct it.

@shivamgoel150
Hey Your logic is wrong. I am adding my mathematical solution. Try to implement it.

Here just multiply equation (i) with 2 and subtract it from 2. Using this you will get x and similarly find y. Final ans would be (x+y).

@shivamgoel150
If any of x or y is calculated as less than zero than make it zero.