Source Code
def solve():
    input_string = input()
    list = input_string.split()

    s = list[0]
    n = int(list[1])

    MOD = 0
    for ch in s:
        MOD *= 10
        MOD += ord(ch) - ord('0')
        MOD %= n

    if MOD:
        MOD = n - MOD

    print(int(s)+MOD)

tc = int(input())
while tc:
    tc -= 1
    solve()
Copy
AZOZ with an O (Needs a Carry) YazanIstatiyeh
Python 3
2078 ms
5.1 MB
Time Limit Exceeded