Need HELP!

This is a divide and conquer based problem.
I have tried really hard on this problem but still my solution is not getting accepted. Etiher TLE is coming or WA. I am confident with my logic and approach but still i am not able to find where am i going wrong … please guide me…

Problem link (CodeChef: Practical coding for everyone)
My solution (CodeChef: Practical coding for everyone)

Sample interaction

Output
500 0
No
249 0
No
124 0
No
61 0
No
30 0
No
14 0
No
6 0
No
2 0
Yes
4 0
No
3 0
No
0 502
No
0 252
No
0 127
No
0 65
No
0 34
No
0 18
No
0 10
Yes
0 14
No
0 12
No
0 11
No
501 4
No
251 4
No
126 4
No
63 4
No
32 4
No
16 4
No
8 4
Yes
12 4
No
10 4
Yes
11 4
No
Test case information :
square length = 4
Triangle base length = 20
Triangle height = 6
Actual area = 76
Your answer = 32