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...
def check(n): cur = 0 for c in str(n): cur += int(c) return cur def main(): n, s = map(int, input().split()) a, exp = 0, 1 while check(n) > s: d = n % 10 n += (10 - d) % 10 a += (10 - d) % 10 * exp exp *= 10 n //= 10 print(a) for _ in range...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER 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 soma_total(n): result = 0 while n != 0: result += n % 10 n //= 10 return result numTestes = int(input()) for x in range(numTestes): numero, s = [int(i) for i in input().split()] contUnidade = 1 result = 0 atual = 0 for count in range(len(str(numero))): if so...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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...
result = [] total_test_case = int(input()) for i in range(total_test_case): first_number, second_number = map(int, input().split()) if first_number % second_number == 0: result.append(0) elif first_number < second_number: result.append(second_number - first_number) else: reminder...
ASSIGN VAR LIST 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 NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP 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()) if a < b: c = b - a elif a == b or a % b == 0: c = 0 elif a > b: c = (a // b + 1) * b - a print(c)
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 ASSIGN VAR BIN_OP VAR VAR IF VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER 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()) l = [] for i in range(t): l.append([int(x) for x in input().split()]) def xx(a, b): if a == b: return 0 elif a > b: d = a % b if d: return b - d return d return b - a for i in l: print(xx(i[0], i[1]))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR RETURN BIN_OP VAR VAR RETURN VAR RETURN BIN_OP VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR 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...
def find_number_of_moves(a, b): if a >= b: rem = a % b a = a - rem c = a - rem return c % b else: return b - a t = int(input()) for i in range(t): a, b = input().split() print(find_number_of_moves(int(a), int(b)))
FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 _ in range(t): n, s = map(int, input().split()) total = n x = list(map(int, str(n))) sum1 = sum(x) if s >= sum1: print(0) continue i = 10 while sum1 > s: if n % i != 0: n = n + (i - n % i) i *= 10 sum1 = list(map(int, s...
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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF 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...
for _ in range(int(input())): a, b = map(int, input().split()) if a > b and a % b != 0: print(str(b * (a // b + 1) - a)) elif a % b == 0: print("0") else: print(str(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 IF VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP 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...
from sys import stdin def sum_digits(n): return sum([int(i) for i in str(n)]) for _ in range(int(input())): n, k = map(int, stdin.readline().rstrip().split(" ")) c_n = n if sum_digits(n) <= k: print(0) else: i = 1 while True: c_n = c_n // 10**i * 10**i + 10**i...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP 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...
t = int(input()) for k in range(t): n, s = map(int, input().split()) sN = str(n) sum = 0 total = 0 i = 0 while i < len(sN): sum += int(sN[i]) i += 1 if sum <= s: total = 0 else: sum = 1 i = -1 while sum <= s: i += 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS...
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 = int(input()) for i in range(tc): a, b = map(int, input().split()) val = a // b + 1 if a % b == 0: print("0") else: print(b * val - 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 BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP 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...
for s in [*open(0)][1:]: n, s = s.split() s = int(s) m = "0" + n l = len(m) i = j = t = 0 if sum(map(int, n)) > s: for x in m: t += int(x) if t >= s: m = m[:j] + chr(ord(m[j]) + 1) + "0" * (l - j - 1) break j = (j, i)[m[...
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL 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...
t = int(input()) def nextMultiple(n, m): q = n // m n2 = 0 if n * m > 0: n2 = m * (q + 1) else: n2 = m * (q - 1) return n2 for _ in range(t): a, b = list(map(int, input().split(" "))) if a % b == 0: print(0, "\n") else: print(int(nextMultiple(a, b)) - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_O...
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 myfun(x, y): if x % y == 0: print(0) else: print(y - x % y) t = int(input()) mov = 0 for i in range(t): liste = input().split() myfun(int(liste[0]), int(liste[1]))
FUNC_DEF IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER 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...
def sum_digits(num): return sum([int(s) for s in str(num)]) def solve(N, S): Q = sum_digits(N) pow = 1 ans = 0 while Q > S: diff = N % 10**pow if N % 10**pow != 0: ans += 10**pow - diff N += 10**pow - diff Q = sum_digits(N) pow += 1 retur...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP BIN_OP NUMBER VAR 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...
d = [] for _ in range(int(input())): a, b = map(int, input().split()) c = b - a % b if c != b: d.append(c) else: d.append(0) for i in d: print(i)
ASSIGN VAR LIST 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 BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER 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...
t = int(input()) cases = [] for i in range(t): inp = input().split() a = int(inp[0]) b = int(inp[1]) cases.append([a, b]) for i in range(t): a = cases[i][0] b = cases[i][1] r = int(a / b) if a / b == r: print(0) else: r = r + 1 print(b * r - a)
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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN 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()) for i in range(n): times = 0 nums = tuple(map(int, input().split())) num1 = nums[0] num2 = nums[1] if num1 % num2 == 0: print(0) else: print(num2 - num1 % num2)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR 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...
n = int(input()) for i in range(0, n): a, b = [int(x) for x in input().split()] if a < b: print(b - a) elif a % b != 0: print(b - a % b) else: print(0)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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...
import sys input = sys.stdin.readline for ti in range(int(input().strip())): a, b = [int(x) for x in input().strip().split()] print((b - a % b) % b)
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP 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 x in range(t): s = input() s1 = s.split() sum1 = int(s1[1]) sum2 = 0 s = s1[0] flag = 0 def fun(s): sum2 = 0 for i in range(len(s)): sum2 = sum2 + int(s[i]) if sum2 <= sum1: return 0 else: return -1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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...
for _ in range(int(input())): n, s = list(map(int, input().split())) sd = 0 ans = 0 temp = n for i in range(len(str(n))): sd += int(str(n)[i]) if sd > s: flag = 0 temp = n sd = 0 for i in reversed(range(len(str(n)))): sd_pre = sd te...
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR 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 sumnum(x): a = 0 for i in x: a += int(i) return a def plone(lst): n = 0 for i in lst: n *= 10 n += int(i) n += 1 newlst = list(str(n)) return newlst def solve(): n, s = input().split() s = int(s) lst = list(n) prefzero = True ans = [] ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
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...
ssi = lambda: map(int, input().split()) def sm(n): n = str(n) res = 0 for i in range(len(n)): res += int(n[i]) return res for _ in range(int(input())): n, s = ssi() if sm(n) <= s: print(0) else: res = 0 i = len(str(n)) - 1 pw = 1 while sm(n...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSI...
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()) x = [list(map(int, input().split())) for _ in range(t)] for a, b in x: print(abs(b * -(-a // b) - a))
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 FOR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP 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...
n = int(input()) answers = [] numbers = [input() for _ in range(n)] for _ in numbers: a1, a2 = map(int, _.split()) dif = int(a1 % a2) if dif != 0: ans = a2 - dif else: ans = 0 answers.append(ans) [print(_) for _ in answers]
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR 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()) rem = 0 res = 0 a = [] b = [] for i in range(t): x, y = list(map(int, input().split())) a.append(x) b.append(y) for i in range(t): if a[i] % b[i] == 0: print("0") elif a[i] > b[i]: rem = a[i] % b[i] res = b[i] - rem print(res) elif a[i] < b[i]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER EXPR 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...
from sys import stdin def inp(): return stdin.buffer.readline().rstrip().decode("utf8") def itg(): return int(stdin.buffer.readline()) def mpint(): return map(int, stdin.buffer.readline().split()) def solve(): n, s = mpint() arr = list(map(int, str(n))) count = sum(arr) ans = bit = 0...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER WHILE 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...
t = int(input()) def ck(n, s): total = 0 for e in n: total += int(e) return total <= s for i in range(1, t + 1): n, s = input().split() s = int(s) mul = 1 count = 0 n = list(map(int, n)) if ck(n, s): print(0) continue for i in range(len(n) - 1, -1, -1)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF 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 mai(a, b): a = int(a) b = int(b) temp = 0 i = int(a / b) while temp < a and a % b != 0: temp = b temp = temp * i i = i + 1 if i == int(a / b): print(temp) else: print(temp - a) for i in range(int(input())): mai(*input().split())
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL 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...
for _ in range(int(input())): x, y = map(int, input().split()) z = x // y if x % y != 0: print((z + 1) * y - x) else: 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 BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER 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...
n = input() integers = [input() for i in range(int(n))] for i in integers: a, b = i.split() a = int(a) b = int(b) if a % b == 0: print(0) continue if a < b: print(b - a) continue else: div = a // b div += 1 factor = div * b print(fa...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR 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 NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER AS...
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(1, t + 1): arr = input() l = list(map(int, arr.split(" "))) if l[0] % l[1] != 0: print(l[1] - l[0] % l[1]) else: print(0)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER 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...
import sys input = sys.stdin.readline t = int(input()) for ti in range(1, t + 1): a, b = map(int, input().split()) if a % b == 0: print(0) else: print((a + b) // b * b - a)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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 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()) while t != 0: n1, n2 = map(str, input().split()) n2 = int(n2) s = 0 ans = 0 for i in range(len(n1)): if int(n1[i]) + s > n2: t1 = int("1" + "0" * (len(n1) - i)) - int(n1[i:]) ans = t1 break elif int(n1[i]) + s < n2: s +...
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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP STRING BIN_OP STRING 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...
num = int(input()) i = 0 while i < num: a, b = map(int, input().split()) if a < b: ans = b - a elif a % b == 0: ans = 0 else: re = a % b ans = b - re print(ans) i = i + 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE 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 VAR ASSIGN VAR BIN_OP VAR 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...
n = int(input()) for i in range(n): a, b = map(int, input().split()) rem = a % b ints = a // b num = (ints + 1) * b if num - a == b: print(0) else: print(num - 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 BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL 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...
from sys import stdin, stdout DEBUG = True class Scan: def __init__(self): self.read = stdin.read self.input = stdin.readline def integer(self, count=1): if count == 1: return self._integer() return [self._integer() for _ in range(count)] def _integer(self):...
ASSIGN VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF VAR VAR FUNC_CALL VAR NUMBER WHILE VAR STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR STRING NUMBER NUMBER 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 _ in range(t): a, b = map(int, input().split()) f = 1 if a % b == 0: f = 0 print("0") elif a < b: f = 0 print(b - a) if f == 1: n = a // b n += 1 d = b * n print(d - 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 NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR 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...
n = int(input()) ans = [] nums = [] for i in range(n): temp = input().split() temp = [int(l) for l in temp] if temp[0] % temp[1] == 0: ans.append(str(0)) else: res = (int(temp[0] / temp[1] // 1) + 1) * temp[1] - temp[0] ans.append(str(res)) print("\n".join(ans))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP 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...
number_test = int(input()) for k in range(number_test): ab = input().split(" ") a, b = int(ab[0]), int(ab[1]) if a < b: print(b - a) elif a % b == 0: print("0") else: res = b - a % b print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER 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 STRING ASSIGN VAR BIN_OP VAR BIN_OP VAR 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...
test_cases = eval(input()) total = [] for i in range(test_cases): a, b = list(map(int, input().split())) if a % b == 0: total.append(0) else: modulus = a % b total.append(b - modulus) for j in range(len(total)): print(total[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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL 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...
test_cases = int(input()) data = [] while test_cases > 0: data.append(list(map(int, input().split()))) test_cases -= 1 for test in data: if test[0] % test[1] == 0: print("0") else: ans = test[1] - test[0] % test[1] print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER 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 aux(n, s): if sum(int(x) for x in str(n)) <= s: return 0 a = 10 while n % a == 0: a *= 10 d = a - n % a return d + aux(n + d, s) for t in range(int(input())): n, s = map(int, input().split()) print(aux(n, s))
FUNC_DEF IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR 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 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...
n = int(input()) s = [tuple(map(int, input().split())) for i in range(n)] for v in s: if v[0] % v[1] == 0: ans = 0 else: ans = (v[0] // v[1] + 1) * v[1] - v[0] print(ans)
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 FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER 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()) count = 0 e = [] for i in range(n): k, m = map(int, input().split()) if k % m == 0: count = 0 else: r = k // m count = m * (r + 1) - k e.append(count) for i in range(len(e)): print(e[i])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FOR 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(t): n, s = map(int, input().split()) arr = [] num = [] sum = 0 for j in str(n): arr.append(int(j)) num.append(int(j)) sum += int(j) arr.reverse() num.reverse() if sum <= s: print(0) else: f = 1 j = 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 ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR 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, d = map(int, input().split()) if n <= d: print(abs(n - d)) elif n % d: print(d * (n // d + 1) - n) else: 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 IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER 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...
import sys input = sys.stdin.readline Q = int(input()) Query = [list(map(int, input().split())) for _ in range(Q)] for a, b in Query: ans = (b - a) % b print(ans)
IMPORT ASSIGN VAR VAR 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 FOR VAR VAR VAR ASSIGN VAR BIN_OP 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...
def getno(l): return int("".join(list(map(str, l)))) for _ in range(int(input())): n, s = [int(x) for x in input().split()] cs = 0 for i in str(n): cs += int(i) if cs <= s: print(0) continue cs -= s no = list(map(int, str(n))) for j in range(len(no) - 1, -1, -1)...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR 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 isDivisible(a, b): if a < b: return b - a mod = a % b if mod == 0: return 0 elif mod != 0: return (a // b + 1) * b - a else: return "out" t = int(input()) for i in range(t): a, b = map(int, input().split(" ")) print(isDivisible(a, b))
FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR RETURN STRING 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 STRING EXPR 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...
t = int(input()) for i in range(0, t): a = input().split() if int(a[0]) % int(a[1]) == 0: print(0) else: answer = int(a[1]) - int(a[0]) % int(a[1]) print(answer)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL 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 DivisibilityProb(totalValues, listofaChoices, listofbChoices): for index in range(totalValues): if listofaChoices[index] < listofbChoices[index]: print(listofbChoices[index] - listofaChoices[index]) elif listofaChoices[index] % listofbChoices[index] == 0: print(0) ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR AS...
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 Stepsneeded(a, b): if a % b == 0: return 0 elif a > b: s = a // b + 1 return b * s - a else: return b - a n = int(input()) for i in range(n): a, b = map(int, input().split()) print(Stepsneeded(a, b))
FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR RETURN BIN_OP VAR VAR 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 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...
def res(a, b): temp = a / b if int(temp) == temp: print(0) else: x = int(temp) + 1 y = b * x print(y - a) t = int(input()) for _ in range(t): a, b = [int(x) for x in input().split()] res(a, b)
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP 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 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 cnt(x): ret = 0 while x > 0: ret += x % 10 x //= 10 return ret t = int(input()) for _ in range(t): s, a = map(int, input().split()) if cnt(s) <= a: print(0) continue for i in range(19): cur = (s // 10**i + 1) * 10**i if cnt(cur) <= a: ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR 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 FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_O...
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 inp = stdin.readline t = int(inp()) for i in range(t): a, b = [int(x) for x in inp().split()] if a < b: print(b - a) elif a % b == 0: print(0) else: rounded = a // b + 1 print(abs(a - b * rounded))
ASSIGN 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 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 BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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...
l = [] for i in range(int(input())): a, b = map(int, input().split()) count = 0 if a % b == 0: l.append(0) else: x = a % b l.append(b - x) for i in range(len(l)): print(l[i])
ASSIGN VAR LIST 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 NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR 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...
cases = int(input()) def get_moves_to_divisibility(a, b): if a % b == 0: return 0 div_value = b * (a // b + 1) return div_value - a for _ in range(cases): vals = input().split(" ") print(get_moves_to_divisibility(int(vals[0]), int(vals[1])))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER 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...
def linput(): return [int(i) for i in input().split()] q = int(input()) for ______ in range(q): n, m = linput() if n % m == 0: print(0) else: print(m - n % m)
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR 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...
t = int(input()) while t > 0: s, sum = map(str, input().split()) sum = int(sum) tsum = 0 n = len(s) num = 0 q = 0 for i in range(n): q += int(s[i]) if q <= sum: print(0) t -= 1 continue for i in range(n): if num != 0: break ...
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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER 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...
def sumDigits(string): ans = 0 for char in string: ans += ord(char) - ord("0") return ans def solve(string, maxSum): if sumDigits(string) <= maxSum: return string for i in range(len(string) - 2, -1, -1): if string[i] == "9": continue newString = string[:...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR 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...
test = int(input()) for _ in range(test): n, s = map(int, input().split()) ns = str(n) flag = False last = -1 for i in range(len(ns)): if int(ns[i]) > s: if s == 0: h = ns[last + 1 :] l = len(h) dd = 10**l ans = dd -...
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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER 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 calc(n, s): total = 0 for i in range(len(n)): total += int(n[i]) if total >= s: rem = n[i : len(n)] break main = "1" + "0" * len(rem) return int(main) - int(rem) for ii in range(int(input())): n, s = map(int, input().split()) n = str(n) total = 0...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING BIN_OP STRING FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CA...
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 i in range(1, n + 1): l = list(map(int, input().split())) b = l[0] a = l[1] if b % a == 0: print(0) else: con = b // a ans = (con + 1) * a - b print(ans)
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 ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP 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...
ncases = int(input()) for i in range(ncases): pair = input().split() if int(pair[0]) % int(pair[1]) == 0: print("0") else: print(str(int(int(pair[1]) - int(pair[0]) % int(pair[1]))))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR 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...
def divisible(a, b): if a < b: n = b - a elif a > b: if a % b == 0: n = 0 else: n = b - a % b else: n = 0 return n t = int(input()) for _ in range(t): a, b = map(int, input().split()) print(divisible(a, b))
FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER RETURN VAR 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 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...
def Solution(a, b): if a < b: return b - a l = a % b if l is 0: return 0 return b - l for _ in range(int(input())): test = input().split(" ") print(Solution(int(test[0]), int(test[1])))
FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER 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...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, s = input().rstrip().split() s = int(s) N = list(map(int, reversed(list(n)))) + [0] ans = 0 S = sum(N) for i in range(len(str(n))): if S <= s: break if N[i] == 0: continue ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR 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...
rr = lambda: input().strip() rri = lambda: int(rr()) rrm = lambda: map(int, rr().split()) T = rri() for i in range(T): a, b = rrm() x = a % b if x: x = b - x print(x)
ASSIGN VAR FUNC_CALL FUNC_CALL 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR 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...
from sys import stdin def get_int(): return int(stdin.readline()) def get_str(): return stdin.readline().strip() def get_ints(): return map(int, stdin.readline().strip().split()) def get_array(): return list(map(int, stdin.readline().strip().split())) def get_array2d(row): return [list(map...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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...
k = int(input()) i = 0 my_list = [] while i < k: t = list(map(int, input().rstrip().split())) a = t[0] % t[1] b = t[1] - a if a == 0: my_list.append(0) else: my_list.append(b) i = i + 1 j = 0 while j < k: print(my_list[j]) j = j + 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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...
t = input() t = int(t) while t > 0: x = input() x = x.split(" ") a, b = int(x[0]), int(x[1]) if a < b: print(b - a) elif a % b == 0: print(0) else: count = a - a % b + b print(count - a) t = t - 1
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER 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 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...
num = int(input()) for i in range(num): num1, num2 = input().split() a = int(num1) b = int(num2) print((b - a % b) % b)
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 ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP 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()) while T: T -= 1 a, b = [int(x) for x in input().split()] f = a % b if f == 0: print(f) else: print(b - f)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL 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...
from sys import stdin def solve(tc): a, b = map(int, stdin.readline().split()) div = a // b rem = a % b if rem > 0: div += 1 print(b * div - a) LOCAL_TEST = not __debug__ if LOCAL_TEST: infile = __file__.split(".")[0] + "-test.in" stdin = open(infile, "r") tcs = int(stdin.readlin...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR IF VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR 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...
numbers_of_test_cases = int(input()) numbers = list() for i in range(numbers_of_test_cases): a, b = map(int, input().split()) if a > b: if a % b != 0: numbers.append(b - a % b) else: numbers.append(0) else: numbers.append(b - a) for move in numbers: print(...
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 FUNC_CALL FUNC_CALL VAR IF VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR VAR EXPR FUNC_CALL 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 function(a, b): if a == b: return 0 elif a > b: if a % b == 0: return 0 moves = a % b return b - moves else: moves = b - a return moves t = int(input()) for _ in range(t): a, b = map(int, input().split()) print(function(a, b))
FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR 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...
n = int(input()) count = 0 while n != 0: n -= 1 x, y = map(int, input().split()) if x % y == 0: print(count) else: s = x % y print(y - s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR 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...
results = "" for _ in range(int(input())): a, b = map(int, input().split()) if a % b: results += f"{-a % b}\n" else: results += "0\n" print(results[:-1])
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR STRING VAR STRING EXPR 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...
def ssum(n): csum = 0 lst = [] while n != 0: n, r = divmod(n, 10) csum += r lst.append(r) return lst, csum def solve(n, s, csum, start, steps): if csum <= s: return steps if n[start] == 0: return solve(n, s, csum, start + 1, steps) steps += (10 - n[s...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR VAR FUNC_DEF IF VAR VAR RETURN VAR IF VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR 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()) results = [] for i in range(n): a, b = map(int, input().split()) if a % b == 0: results.append(0) elif a < b: results.append(b - a) elif a > b: results.append((a // b + 1) * b % a) for i in range(len(results)): print(results[i])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR 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...
def divisible(a, b): if a % b == 0: return 0 power = a // b + 1 return b * power - a def main(): n = int(input()) ans = [] for i in range(n): a, b = list(map(int, input().split(" "))) ans.append(divisible(a, b)) for i in ans: print(i) main()
FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF 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 STRING EXPR FUNC_CALL VAR FUNC_CALL 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...
t = input() t = int(t) def solve(n, s): def digit_sum(n): rev_n = str(n) a = 0 for x in rev_n: a += int(x) return a current_sum = digit_sum(str(n)) if current_sum <= s: print(0) return rev_n = str(n)[::-1] limit = len(rev_n) for i i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL 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...
t = int(input()) def int_to_arr(n, s): arr = [] n_copy = n while n_copy > 0: arr.append(n_copy % 10) n_copy = n_copy // 10 return trying(arr, n, s) def trying(arr, n, s): summa = 0 for i in range(len(arr) - 1, -1, -1): summa += arr[i] if summa > s: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR VAR VAR IF 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...
for _ in range(int(input())): n, s = map(int, input().split()) st = str(n) p = [0] * len(st) for i in range(len(st) - 1, -1, -1): p[i] += int(st[i]) if i + 1 < len(p): p[i] += p[i + 1] if p[0] <= s: print(0) continue last = 0 moves = float("inf") ...
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 BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER 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...
output = [] for _ in range(int(input())): k = 0 numbers = input().split() a, b = int(numbers[0]), int(numbers[1]) if a <= b: output.append(b - a) else: need = b - a % b if need == b: need = 0 output.append(need) for _ in output: print(_)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FO...
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 j in range(t): n, s = [int(k) for k in input().split()] digs = [] while n > 0: digs.append(n % 10) n = n // 10 digs.append(0) sm = sum(digs) i = 0 if sm <= s: print("0") continue while sm + 1 > s: sm = sm - digs[i] i +=...
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 LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR 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...
tx = int(input()) for i in range(tx): a, b = [int(i) for i in input().split()] k = a t = 1 t2 = 0 s = str(a) for i in s: t2 += ord(i) - ord("0") while t <= pow(10, 18): if t > 1: a += t - a % t t2 = 0 s = str(a) for i in s: t2 +...
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 VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING WHILE VAR FUNC_CALL VAR NUMBER NUMBER IF 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...
for _ in range(int(input())): n, s = map(int, input().split(" ")) n_str = str(n) n_int = [int(num) for num in n_str] x = sum(n_int) if x <= s: ans = 0 else: tu = 0 a = len(n_int) for i in range(a): if tu + n_int[i] >= s: k = i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF 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...
import sys for t in range(int(sys.stdin.readline().strip())): n, m = [int(j) for j in sys.stdin.readline().split()] ans = (n // m + 1) * m - n if ans == m: sys.stdout.write("0") else: sys.stdout.write(str((n // m + 1) * m - n)) sys.stdout.write("\n")
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR 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 sum(n): s = str(n) ans = 0 for i in s: ans += int(i) return ans for _ in range(int(input())): n, s = map(int, input().split()) if sum(n) <= s: print(0) else: num = "" sm = 0 for i in str(n): sm += int(i) if sm >= s: ...
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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING 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...
for _ in range(int(input())): n, su = map(int, input().split()) s = str(n) summ = 0 ss = [] for i in range(len(s)): summ += int(s[i]) if summ <= su: print(0) else: summ = 0 for i in range(len(s)): if int(s[i]) + summ < su: summ += 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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CA...
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()) digsum = lambda x: sum(map(int, str(x))) t = n while digsum(t) > s: for i, j in enumerate(str(t)[::-1]): if int(j) > 0: t += (10 - int(j)) * 10**i break print(t - n)
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 FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE FUNC_CALL VAR VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR BIN_OP BIN_OP NUMBER 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...
n = int(input()) res = [] for i in range(n): a, b = map(int, input().split()) res.append(str((0, b - a % b)[a % b != 0])) print("\n".join(res))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING 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...
from sys import stdin, stdout def decrease_the_sum_of_digits(n, s): n_s = str(n) v = 0 ans = 0 for i in range(len(n_s)): v += ord(n_s[i]) - ord("0") if v >= s and ans == 0: ans = 10 ** (len(n_s) - i) - int(n_s[i:]) if v == s: return 0 else: return an...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN 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 sum_of_digit(n): ans = 0 while n > 0: ans += n % 10 n = n // 10 return ans for _ in range(int(input())): n, s = map(int, input().split()) if sum_of_digit(n) <= s: print(0) else: ans = 1 start = n while 1: n += 10**ans - n % 10**an...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER 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 VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE NUMBER 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...
t = int(input()) while t > 0: l = input().split() a = int(l[0]) b = int(l[1]) p = a % b if p == 0: print(p) else: print(b - p) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP 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...
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [([c] * b) for i in range(a)] def list3d(a, b, c, d): return [[([d] * c) for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[([e] * d) for j in range(c)] for j in range(b)] for i in ran...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN 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...
def inp(): t = int(input()) G = [] for i in range(t): a, d = list(map(int, input().split())) G.append([a, d]) return G def A(G): for a, b in G: if a % b: print(b - a % b) else: print(0) A(inp())
FUNC_DEF 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 EXPR FUNC_CALL VAR LIST VAR VAR RETURN VAR FUNC_DEF FOR VAR VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EX...