description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
inp = int(input()) lt = [] for i in range(inp): lt.append(input().split()) for i in lt: a = int(i[0]) b = int(i[1]) if a % b == 0: print("0") else: print((a // b + 1) * b - a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys input = sys.stdin.readline def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return map(int, input().split()) tests = inp() testcount = 0 while testcount < tests: arr = inlt() ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): n, s = map(int, input().split()) nn = n n = [0] + list(map(int, str(n))) if sum(n) <= s: print(0) continue for i in range(len(n) - 1, 0, -1): if sum(n[:i]) < s: for j in range(i, len(n) - 1): n[j] = 0 n[i -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys input = sys.stdin.readline t = int(input()) def d_sum(x): y = str(x) ans = 0 for char in y: ans += int(char) return ans for _ in range(t): a, b = list(map(int, input().split())) c = a mul = 1 if d_sum(c) > b: while True: c += mul if...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR WHI...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
from sys import stdin N = int(stdin.readline()) for case in range(N): num, maxsum = map(int, stdin.readline().split()) power = 0 sol = 0 ds = 0 idx = 0 for i in str(num): ds += int(i) for count in range(18): if ds <= maxsum: break digit = int(str(num)[-1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(0, t): ab = input().split(" ") ab = [int(i) for i in ab] a = ab[0] b = ab[1] i = 1 g = b h = 0 if a % b == 0: print(0) elif b <= 1000: while a % b != 0: a += 1 h += 1 print(h) else: while a > ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER WHILE BIN...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for i in range(int(input())): n, s = map(int, input().split()) l1 = list(str(n)) sum = 0 j = 0 final = [] if n == s: print(0) continue current_sum = 0 for k in range(len(l1)): current_sum = current_sum + int(l1[k]) if current_sum <= s: print(0) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR F...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): n, s = map(int, input().split()) arr1 = [int(d) for d in list(str(n))] arr2 = [] k = 0 if sum(arr1) <= s: print(0) continue for i in range(len(arr1)): if s - arr1[i] > 0: arr2.append(arr1[i]) s -= arr1[i] k...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR N...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
T = int(input()) while T > 0: n, s = map(int, input().split()) x = n digits = [] while x > 0: digits.append(x % 10) x //= 10 digits.append(0) temp = sum(digits) res = 0 last_digit = 0 ad = 1 while temp > s: res += (10 - digits[last_digit]) * ad tem...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WH...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): a, b = map(int, input().split()) d = 0 while a % b != 0: c = a % b d = b - c a += d print(d)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def somc(n): cnt = 0 while n != 0: cnt = cnt + n % 10 n = n // 10 return cnt def ansc(n, s): if somc(n) <= s: return 0 else: a = 10 while n % a == 0: a *= 10 d = a - n % a return d + ansc(n + d, s) for _ in range(int(input())): ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
x = input() y = int(x) lis = [] for i in range(y): x2 = input() spl = x2.split() i1 = int(spl[0]) i2 = int(spl[1]) i3 = i1 // i2 if i1 % i2 == 0: i4 = 0 else: i4 = (i3 + 1) * i2 - i1 lis.append(i4) for i in lis: print(i)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
f = lambda x: sum(map(int, str(x))) for t in range(int(input())): n, s = list(map(int, input().split())) if f(n) <= s: print(0) continue for i in range(1, 19): z = int("1" + "0" * i) k = (n + z) // z * z if f(k) <= s: print(k - n) break
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRIN...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) for k in range(n): test = input().split(" ") maxi = int(test[1]) l = len(test[0]) suma = 0 test[0] = list(map(int, test[0])) i = 0 i2 = -1 for i in range(l): suma += test[0][i] if suma > maxi: break if suma == maxi and i2 == -1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) while n > 0: n -= 1 count = 0 a, b = map(int, input().split()) if a % b == 0: count += 0 elif a > b: div = a % b count += b - div else: count += b - a print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) ab = [list(map(int, input().split())) for _ in range(t)] ans = [(b - a % b if a % b != 0 else 0) for a, b in ab] print(*ans, sep="\n")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys input = sys.stdin.readline for _ in range(int(input())): a, b = [x for x in input().split()] b = int(b) temp = [int(i) for i in a] n = len(a) i = n - 1 curr = sum(temp) while curr > b: now = temp[i] if now == 0 and i != 0: i -= 1 elif curr - no...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) while t: a, b = [int(i) for i in input().split()] t -= 1 if a % b != 0: m = a // b print((m + 1) * b - a) else: print(0)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
from sys import stdin def f(b, x): return b * x def binarySearch(a, b): lo, hi, mid = 0, 10**9 + 1, 0 while lo + 1 != hi: mid = lo + hi >> 1 if f(b, mid) <= a: lo = mid else: hi = mid return hi def solve(a, b): ans = None if a % b == 0: ...
FUNC_DEF RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NONE IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): ab = tuple(map(int, input().split())) if ab[0] % ab[1] == 0: print(0) elif ab[0] < ab[1]: print(ab[1] - ab[0]) else: print(ab[1] * (int(ab[0] / ab[1]) + 1) - ab[0])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def solve(): n, s = [str(i) for i in input().split(" ")] s = int(s) count = 0 ans = "" cum = sum(int(i) for i in n) if cum <= s: print(0) return if int(n[0]) >= s: if int(n[0]) == s and len(n) == 1: print(0) return ans = "10" + "0" * le...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF FUNC_CALL VAR VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR N...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def main(): T = int(input()) for _ in range(T): n, s = (int(i) for i in input().split()) cur = sum(int(v) for v in str(n)) ans = 0 if cur <= s: print(ans) else: d = 0 while cur > s: r = int(str(n)[::-1][d]) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) arr = [] for i in range(n): temp = input().split() temp[0] = int(temp[0]) temp[1] = int(temp[1]) arr.append(temp) for i in range(n): a = arr[i][0] b = arr[i][1] if a % b == 0: print(0) else: print(b - a % b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): n, s = [int(x) for x in input().split()] a = [int(x) for x in str(n)] if sum(a) <= s: print(0) else: acum = 0 j = 0 encontrado = -1 for i in range(len(a) - 1, -1, -1): if sum(a[0 : i + 1]) + 1 <= s: encontr...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for _ in range(t): a, b = map(int, input().split()) if a % b: if a > b: x = a // b y = b * (x + 1) print(y - a) else: print(b - a) else: print(0)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def inc(a, b): i = 0 if a > b: if a % b != 0: r = a // b + 1 i = b * r - a return i else: return i else: i = b - a return i n = int(input()) for i in range(n): a, b = input().split() a = int(a) b = int(b) print...
FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR RETURN VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_C...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def ab(): a, b = map(int, input().split()) t = a % b if t == 0: print(0) return print(b - t) for i in range(0, int(input())): ab()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) while n > 0: a, b = map(int, input().split()) count = 0 if a < b: print(b - a) elif a % b == 0: print("0") else: temp = a // b a1 = b * (temp + 1) print(a1 - a) n = n - 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys cases = int(sys.stdin.readline().strip()) for i in range(cases): candles = sys.stdin.readline().strip().split(" ") a = int(candles[0]) b = int(candles[1]) if a % b == 0: print("0") else: print(str(b - a % b))
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): a, b = map(int, input().split()) bb = b can = 0 d = 10000000000000000000 while d > 0: bb = bb - a // d % 10 d = d // 10 if bb >= 0: can = 1 d = 10000000000000000000 t = 0 while d > 0 and b - a // d % 10 >= 1: b = b - a // ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for _ in range(t): n, s = map(str, input().split()) s = int(s) flag = 0 p = len(n) sum = 0 for i in range(p): sum = sum + int(n[i]) if sum > s: flag = 1 break else: pass if flag == 0: print(0) elif flag ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VA...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): a, b = map(int, input().split()) temp = str(a) c = b i = 0 if sum([int(x) for x in temp]) <= b: print(0) continue while c > int(temp[i]): c -= int(temp[i]) i += 1 if i > 0: no = str(int(temp[:i]) + 1) + (len(temp) - i) * "...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NU...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for z in range(t): arr = list(map(int, input().rstrip().split())) a = arr[0] b = arr[1] if a > b and b % a != 0: d = int(a / b) rem = a % b if rem == 0: print("0") else: r = b * (d + 1) ans = r - a print(ans...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR ST...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
T = int(input()) def digsum(N): return sum(list(map(int, list(str(N))))) for _ in range(T): n, s = [int(x) for x in input().split()] sm = digsum(n) if sm <= s: print(0) else: i = 0 cnt = 0 while True: cnt += (10 - n % 10) * 10**i i += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def solve(n, s, ans): total = 0 n = list(str(n)) for i in range(len(n)): n[i] = int(n[i]) total += n[i] if total <= s: ans.append("0") return moves = 0 index = 0 while n and total > s: last = n.pop() total -= last moves += (10 - last) *...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR F...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): a, b = map(int, input().split()) if a <= b: x = b - a elif a % b == 0: x = 0 else: x = b - a % b print(int(x))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): n, k = map(str, input().split()) k = int(k) j = 0 s = 0 l = len(n) while j < l and s + int(n[j]) < k: s = s + int(n[j]) j = j + 1 if j == l: print(0) else: q = 0 for v in n: q = q + int(v) if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VA...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys stdin = sys.stdin stdout = sys.stdout def getCount(n): ans = 0 while n: ans += n % 10 n = n // 10 return ans def getLastSetBit(n): ans = 0 power = 1 while n: ans = n % 10 if ans != 0: return ans, power n = n // 10 power ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FU...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): n, s = input().split() s = int(s) t1 = sum([int(i) for i in n]) if t1 <= s: print(0) else: t, k, m = "", 0, len(n) for i in range(m): k += int(n[i]) if k >= s: for j in range(i, m): t +=...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR STRING NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def minimum_moves(n, s): moves = 0 multiplier = 1 while sum(map(int, str(n))) > s: if n % 10: delta = 10 - n % 10 n += delta moves += multiplier * delta n //= 10 multiplier *= 10 return moves for _ in range(int(input())): n, s = map(int, ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CAL...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def f(n): ans = 0 for i in n: ans += int(i) return ans for i in range(int(input())): n, s = input().split(" ") s = int(s) if f(n) <= s: print(0) else: store = 0 ind = 0 while store + int(n[ind]) < s: store += int(n[ind]) ind +...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR FUNC_CALL VAR VAR V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def fun2(s, n): ans = 0 for i in range(n): ans += ord(s[i]) - 48 return ans def fun(s, n, x): for i in reversed(range(1, n)): s2 = s[0:i] temp = fun2(s2, i) if temp < x: temp2 = int(s[i:n]) return 10 ** (n - i) - temp2 temp2 = int(s) temp...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP BIN_OP NUMBER BIN_OP VAR VAR VAR ASSIGN...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def isdiv(): a, b = map(int, input().split()) val = 0 if a % b != 0: val = b - a % b return val t = int(input()) for i in range(t): print(isdiv())
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) out = [] while t != 0: a, b = input().split(" ") a = int(a) b = int(b) z = int(0) if a % b == 0: out.append(0) else: out.append(b - a % b) t -= 1 print(*out, sep="\n")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER EXPR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
cases = int(input()) def digits(n): l = [] while n > 0: l.append(n % 10) n //= 10 l.reverse() return l def form(l): n = 0 for i in l: n *= 10 n += i return n for case in range(cases): n, s = map(int, input().split()) d = digits(n) if sum(d) <...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VA...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): a, b = map(int, input().split()) f = a // b ans = 0 if a < b: ans = b - a elif a % b != 0: ans = b * (f + 1) - a print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def solve(): for _ in range(ii()): a, b = mi() mod = a % b if mod == 0: print(0) else: print(b - mod) ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) si = lambda: input() solve()
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def operation(pairNum): n, s = pairNum s = int(s) k = 0 allDigits = list(n) revDigits = allDigits[::-1] revDigits = list(map(int, revDigits)) revDigits.append(0) i = 0 while i <= len(revDigits) - 2 and sum(revDigits) > s: if revDigits[i] == 10: revDigits[i] = 0 ...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def sm(s): x = 0 for i in str(s): x += int(i) return x for _ in range(int(input())): n, s = map(int, input().split()) x = n i = 1 l = len(str(n)) f = 0 if sm(x) <= s: print(x - n) continue while 1: if sm(x) <= s and x > n: f = 1 ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUN...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for _ipj_ in range(t): n, s = map(int, input().split()) n = str(n) n = [0] + [int(x) for x in list(n)] ans = 0 pow = 1 if sum(n) <= s: print(0) continue while sum(n) > s: if n[-1] == 0: n.pop() pow = pow * 10 contin...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE FUNC_C...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for f in [*open(0)][1:]: n, s = map(int, f.split()) v = n d = 1 while sum(map(int, str(n))) > s: n += -(n // d % 10) % 10 * d d *= 10 print(n - v)
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for i in range(int(input())): a, b = map(int, input().split()) n = 0 if a % b == 0: print("0") else: rem = a % b print(b - rem)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) a = [] for i in range(0, n): l, m = input().split() l = int(l) m = int(m) p = l % m if p == 0: a.append(0) else: a.append(m - p) for i in range(0, n): print(a[i])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EX...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): inp = input().split(" ") remainder = int(inp[0]) % int(inp[1]) if remainder == 0: print(remainder) else: print(int(inp[1]) - remainder)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def solve(a, b): print((b - a % b) % b) t = int(input()) for i in range(0, t): nums = list(map(lambda n: int(n), input().split())) solve(nums[0], nums[1])
FUNC_DEF EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
m = int(input()) a = [] n = m for i in range(0, n): b = input() a.append(b) for i in range(0, m): k = a[i] x = [int(y) for y in k.split()] count = 0 if x[0] > x[1] and x[0] % x[1] != 0: h = x[0] % x[1] count = count + x[1] - h elif x[0] < x[1]: count = count + x[1] - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBE...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def digsum(n): ans = 0 while n: ans += n % 10 n //= 10 return ans for _ in range(int(input())): n, s = map(int, input().split()) a = digsum(n) t = n if a > s: i = 1 while True: r = t % 10**i t += 10**i - r if digsum(t) <= ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BI...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): n, s = map(int, input().split()) digits = [] while n > 0: digits.append(n % 10) n //= 10 result = 0 cur_sum = 0 cur = len(digits) - 1 while cur >= 0 and cur_sum <= s: cur_sum += digits[cur] cur -= 1 cur += 1 while cur_sum ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER VAR N...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
from sys import stdin, stdout input = stdin.readline def su(n): ans = 0 for i in str(n): ans += int(i) return ans for _ in range(int(input())): n, s = map(int, input().split()) l = su(n) ans = 0 i = 0 while l > s: ans += 10 ** (i + 1) - n % 10 ** (i + 1) n +=...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) lst = [] for i in range(n): c = 0 a, b = input().split() a = int(a) b = int(b) if a % b == 0: lst.append(c) else: c = b - a % b lst.append(c) for i in lst: print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def dsum(x): res = 0 while x: res += x % 10 x //= 10 return res for _ in range(int(input())): n, s = map(int, input().split()) p = 1 ans = 0 csum = dsum(n) while csum > s: add = 10 * p - n % (10 * p) if add == 10 * p: add = 0 ans += a...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR BIN_OP...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def res(l): if l[0] % l[1] == 0: print(0) else: k = l[0] % l[1] print(l[1] - k) t = int(input()) while t > 0: t = t - 1 l = list(map(int, input().split())) res(l)
FUNC_DEF IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CAL...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) def fon(mini): a, b = map(int, mini.split()) c = 0 if a > b and a % b != 0: c = b - a % b return c elif a % b == 0: return "0" else: return b - a for i in range(n): print(fon(input()))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR IF BIN_OP VAR VAR NUMBER RETURN STRING RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_C...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) while t: n, s = input().split() s = int(s) l = len(n) u = 0 f = 0 flag = 0 index = 0 for x in range(l): u += int(n[x]) if u == s and flag != 1: flag = 1 index = x if u > s: f = 1 break if f: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) while t != 0: a, b = map(int, input().split()) if a % b == 0: print(0) else: m = a // b mi = m + 1 n = b * mi - a print(n) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): li = [int(x) for x in input().split()] n = li[0] m = li[1] if n > m: if n % m == 0: print(n % m) else: print(m - n % m) else: print(m - n)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def f(i, s): if s == arr[i]: if pres[-1] - pres[i + 1] != 0: arr[i - 1] += 1 for i in range(i, len(arr)): arr[i] = 0 return 0 else: return 0 elif s < arr[i]: arr[i - 1] += 1 for i in range(i, len(arr)): a...
FUNC_DEF IF VAR VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN NUMBER...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def getDigit(n, i): if i > 1: return getDigit(n // 10, i - 1) else: return n % 10 t = int(input()) while t: t -= 1 line = input().split() n = int(line[0]) s = int(line[1]) ans = 0 ns = str(n) tot = 0 for char in ns: tot += int(char) if tot <= s: ...
FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR A...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) while t: l = list(map(int, input().split())) r, q = 0, 0 r = l[0] % l[1] if r == 0: q = 0 else: q = l[1] - r print(q) t = t - 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) dig = [] for i in range(t): a, b = list(map(int, input().split())) if a % b != 0: number = a // b + 1 number *= b dig.append(number - a) else: dig.append(0) for j in range(len(dig)): print(dig[j])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys line = sys.stdin.readline() cases = int(line.strip()) for case in range(cases): nums = sys.stdin.readline().strip().split() a = int(nums[0]) b = int(nums[1]) add = a % b if add != 0: res = int(a / b) add = (res + 1) * b - a print(int(add))
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP B...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def f(n): res = 0 while n > 0: res = res + 1 n = n // 10 return res def check(n): res = 0 while n > 0: res = res + n % 10 n = n // 10 return res for _ in range(int(input())): n, s = list(map(int, input().split())) len = f(n) ans = pow(10, 20) i...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
from sys import exit as sys_ret from sys import stdin, stdout f_input, f_print, f_flush = stdin.readline, stdout.write, stdout.flush for _ in range(int(f_input())): a, b = map(int, f_input().split()) if a == b or a % b == 0: f_print("0\n") continue if a < b: f_print(str(b - a) + "\n...
ASSIGN VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EX...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
tc = input() tc = int(tc) for i in range(tc): inp = input() inp_lst = inp.split() a = int(inp_lst[0]) b = int(inp_lst[1]) ans = (b - a % b) % b print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) s = 0 for i in range(n): s = 0 m, z = map(int, input().split()) if m % z == 0: print(0) else: print((m // z + 1) * z - m)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): a, b = (int(x) for x in input().split()) if a % b == 0: ans1 = 0 elif a <= b: ans1 = b - a else: ans1 = b - a % b print(ans1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(0, t): ip = str(input()).split(" ") a = int(ip[0]) b = int(ip[1]) print(-a % b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): a, b = map(int, input().split()) ans = 0 k = a // b if a % b == 0: print(0) else: r = b * (k + 1) ans = r - a print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def summer(s): re = 0 s = str(s) for i in s: re += int(i) return re def sol(n, s): if summer(n) <= s: print(0) return ans = 0 pw = 1 for i in range(18): digit = n // pw % 10 add = pw * ((10 - digit) % 10) n += add ans += add ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) while t: user_input = list(map(int, input().split())) digits = [] i = 0 total = 0 temp = user_input[0] while temp: digits.append(temp % 10) temp //= 10 total += digits[i] i += 1 if total <= user_input[1]: print(0) else: for...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR V...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): n, s = map(int, input().split()) m = n s1 = sum([int(i) for i in str(n)]) i = 0 while s1 > s: x = n // 10**i % 10 n += 10**i * (10 - x) i += 1 s1 = sum([int(i) for i in str(n // 10**i)]) print(n - m)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def divisible(a, b): return b - a % b if a % b > 0 else 0 testcases = int(input()) for i in range(1, testcases + 1): data = tuple(map(int, input().split())) print(divisible(data[0], data[1]))
FUNC_DEF RETURN BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for _ in range(t): n, s = input().split() n = [int(i) for i in list(n)] s = int(s) cursum = sum(n) if cursum <= s: print(0) else: n = n[::-1] p = 1 cur = 0 gone = 0 for i in range(len(n)): if n[i] == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR N...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def problem(a, b): count = 0 if a % b == 0: return count else: res = a % b count = b - res return count for i in range(int(input())): a, b = [int(x) for x in input().split()] print(problem(a, b))
FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for _ in range(t): a, b = map(int, input().split()) min_inc = a if a % b != 0: min_inc -= a % b min_inc += b print(min_inc - a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys def q1(): for inx, line in enumerate(sys.stdin): if inx == 0: continue tokens = line.rstrip("\n").split() a = int(tokens[0]) b = int(tokens[1]) if a < b: print(b - a) continue elif a % b == 0: print(0) ...
IMPORT FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BI...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def to_list(s): return list(map(lambda x: int(x), s.split(" "))) def solve(a, b): residue = a % b if residue == 0: return "0" else: return str(b - residue) t = int(input()) answers = [] for i in range(t): a, b = to_list(input()) answers.append(solve(a, b)) print("\n".join(ans...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN STRING RETURN FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for _ in range(int(input())): number, mx = input().split() number = [i for i in number] mx = int(mx) su = sum(int(i) for i in number) if su <= mx: print(0) continue number = ["0"] + number inumber = int("".join(number)) ln = len(number) res = int(2e18) for i in ra...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def sumd(n): return sum([int(x) for x in str(n)]) t = int(input()) for tc in range(t): n, s = [int(x) for x in input().split()] ans = 0 while sumd(n) > s: if n <= 9: ans += 10 - n n = 10 else: st = str(n)[::-1] l = 0 for i in ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) ar = list() for i in range(n): a, b = [int(s) for s in input().split()] if a % b == 0: ar.append(0) else: ar.append(int((a // b + 1) * b - a)) for i in ar: print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) l = list() def process(x, y): r = 0 if x % y != 0: print(y - x % y) else: print("0") while n > 0: f = [int(x) for x in input().split()] l.append(f) n -= 1 for i in l: process(i[0], i[1])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CAL...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for i in range(int(input())): a, s = [x for x in input().split()] n = len(a) s = int(s) lst = [] for i in a: lst.append(int(i)) su = 0 i = 0 while i != n: su += lst[i] if su > s: break i += 1 if i == n: print(0) else: wh...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR EXPR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
import sys def input(): return sys.stdin.readline()[:-1] def getInt(): return int(input()) def getIntIter(): return map(int, input().split()) def getIntList(): return list(getIntIter()) for _ in range(int(input())): n, s = getIntIter() digits = [] while n > 0: digits.insert...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
n = int(input()) Result = [] for i in range(0, n): List = list(map(int, input().strip().split()))[0:2] a = List[0] b = List[1] residue = a % b if residue == 0: Result.append(0) else: Res = b - residue Result.append(Res) for i in Result: print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
from sys import stdin class Problem: def __init__(self, n, s): self.n = n self.s = s self.stack = [] def solve(self): number = "0" + str(self.n) current_sum = 0 for digit in number: d = int(digit) self.stack.append(d) curren...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NU...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): n, s = map(int, input().split()) pn = n tn = [] while n: n, a = divmod(n, 10) tn.append(a) tn.append(0) def cal(p): tn[p] = 0 tn[p + 1] += 1 for d in range(p + 1, 100000000): if tn[d] == 10: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
number = int(input()) data = list(map(int, input().split())) for index in range(1, number, 1): current = list(map(int, input().split())) data.append(current[0]) data.append(current[1]) def devide(number): array = [] while number > 0: array.append(number % 10) number = (number - num...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
def digits_sum(n): s = 0 while n > 0: s += n % 10 n //= 10 return s def main(): t = int(input()) for _ in range(t): n, s = map(int, input().split()) sm = digits_sum(n) ops = 0 mul = 1 while sm > s: last = n % 10 if las...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR ...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
t = int(input()) for i in range(t): s, m = [int(s) for s in input().split()] s = str(s) sumi = 0 for i in range(len(s)): sumi = sumi + int(s[i]) if sumi >= m: answer = int(s[i:]) answer = int("1" + (len(s) - i) * "0") - answer break sumi = 0 fo...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP F...
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
for t in range(int(input())): n, s = input().split() s = int(s) nl = [int(i) for i in n] digits = len(nl) sum_s = sum(nl) while sum_s > s: sum_s -= nl.pop() while nl and nl[-1] == 9: sum_s -= nl.pop() if nl: nl[-1] += 1 else: nl...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR FUNC_CALL VAR WHILE VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR IF VAR VAR NUMBER NUMBER EXPR...