Codechef•Sep 15, 2025
True and False Paper
Hazrat Ali
Codechef
Bob wrote the same exam but he marked each and every question as the opposite of what Alice did, i.e, for whichever questions Alice marked true, Bob marked false and for whichever questions Alice marked false, Bob marked true.
Determine the score of Bob.
Input Format
- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two space-separated integers N and K — the total number of questions in the exam and the score of Alice.
Output Format
For each test case, output on a new line the score of Bob.
Constraints
- 1≤T≤2000
- 1≤N≤100
- 0≤K≤N
Sample 1:
Input
3 1 1 50 0 100 76
Output
0 50 24
Solution
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int k, n;
cin >> k >> n;
cout << abs(k - n) << endl;
}
return 0;
}