TAXSAVING - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: tejas10p
Testers: iceknight1093, rivalq
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

You earned X rupees this year; and anyone who earns strictly more than Y rupees per year must pay taxes.
Given that Y \lt X, how much money must you invest so that you no longer have to pay taxes?

EXPLANATION:

Since Y \lt X, it’s clearly optimal to bring our money down to Y (since it only shouldn’t be strictly more than Y).
This can be done by investing X-Y rupees.

So, the answer is simply X-Y.

TIME COMPLEXITY:

\mathcal{O}(N) per testcase.

CODE:

Code (Python)
for _ in range(int(input())):
    x, y = map(int, input().split())
    print(x - y)