Help me in solving RCPITAPS16 problem

How to solve programming problems
In the previous modules - we solved simple programming problems that had a direct approach.
In this module, we will cover problems that focus on logic building. Some suggestions for this module:

Use a pen and paper to work out solutions.
The logic / algorithm first has to be clear in your mind before you decide to code it out.
Don’t spend more than 30 minutes on any problem. While the objective is to learn - if you don’t know the approach, it’s best to learn the concept / review the solution.
For Beginner’s level programming problems - we think the following works best

Step 1: Understand the problem statement and the sample test cases
Step 2: Generate examples - Create 10 input and output cases of your own
Step 3: Observations / Pattern - Observe your examples to identify the logic
Step 4: Plan your code - Modularise and solve sub-components of your problem
Step 5: Learn - You may come across components of you logic where you don’t know how to execute the code.
In such cases, ask Google or ChatGPT or your friends and learn!
Step 6: Write the code - For simpler programming problems - C++ solutions will be less than 20 lines in more than 95% of the cases.
Step 7: Identify edge cases - If your code still fails - try and and come up with corner cases where your code may fail

Introduction to the module on logic building
In the problems that follow, this is the approach that we will take
Step 1: Provide the problem statement - You need to read and understand the same
Step 2: Generate examples - Create additional input and output cases for each problem
Step 3: Draw observations / pattern based on the examples created
Step 4: Solve sub-components of the problem
Step 5: Solve the complete problem.

Let us start with our first logic building exercise!!! Click on Next to continue.

Problem (Make Avg) - Read the problem statement
You are given 2 integers -A and C.
You need to find if there exists any
integer B which meets the following condition
B must be an integer
B is the average of A and C

For each test case, output B. If no such integer exists, output −1

Sample 1:
Input
3
3 5
6 6
2 7
Output
4
6
-1

Explanation:

Test case 1: Considering B=4,B is the average of 3 and 5.
Test case 2: Considering B=,B is the average of 6 and 6.
Test case 3: There exists no integer B such that B can be the average of 2 and 7.
Average of 2 and 7 is 4.5 which is not an integer.

Problem (Make Avg) - Observations
What do we observe here?
Whenever we can generate B, then B is the average of A and C
1)if A and C are both odd, then we can generate B.
2)if A and C are both even, then we can generate B.

When can we not generate B?
if A is odd and C is even or vice versa,then we cannot generate B and the output is -1

Why is this the case?
1)Average of A and C is A+C/2
2)A+C/2 will be an integer when A+C is even.Else,it will not be an integer.
3)Even+Even is Even.
4)Odd+Odd is Even.
5)Even+Odd is Odd.
6)Hence,the average exists only when either both A and C are Even, or both Odd.

Sample 1:
Input
3 4
3 5
2 4
2 5
Output
-1
4
3
-1