Source Code
def mod(str, int):
    ret = 0
    for ch in str:
        ret *= 10
        ret += ord(ch) - ord('0')
        ret %= int
    return ret

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

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

    MOD = mod(str,n)
    if MOD:
        MOD = n - MOD

    print(int(str)+MOD)

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