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...
t = int(input()) for ii in range(t): n, s = input().split() s = int(s) start = 0 for i in n: start += int(i) if start <= s: print(0) continue count = 0 ptr = len(n) - 1 while start >= s: start -= int(n[ptr]) ptr -= 1 if ptr < 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 ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR 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...
t = int(input()) for _ in range(t): s, n = map(str, input().split()) n = int(n) m = len(s) pos = -1 temp = 0 tt = 0 for i in range(0, m): tt += ord(s[i]) - ord("0") if tt <= n: print(0) continue for i in range(0, m): ch = ord(s[i]) - ord("0") i...
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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL 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 def solve(n, s): digits = [int(x) for x in str(n)] if sum(digits) <= s: return 0 if digits[0] > s: targ = int("1" + "0" * len(digits)) return targ - n lft = [0] nd = 0 while sum(lft) < s: lft.append(digits[nd]) nd += 1 if True: ith...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR RETURN NUMBER IF VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUM...
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 = list(map(int, str(n))) n_dig_sum = sum(digits) if n_dig_sum <= s: print(0) else: moves = 0 i = -1 j = 0 while n_dig_sum > s: moves += (10 - digits[i]) * 10**j digit...
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 FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP 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_case = int(input()) for i in range(test_case): val = list(map(int, input().split(" "))) if val[0] % val[1] == 0: print(0) continue else: res = val[1] - val[0] % val[1] print(res)
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 STRING IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER 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...
for _ in range(int(input())): n, s = map(str, input().split()) n = "0" + n l = [] for a in n: l.append(int(a)) sum = 0 s = int(s) i = 1 while i < len(l): sum = sum + l[i] if sum <= s: i = i + 1 else: sum = sum - l[i] for...
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 STRING VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN 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 = input() n = int(n) for i in range(n): a, b = (int(z) for z in input().split()) if a % b == 0: ans = 0 else: ans = b - a % b print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER 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...
def func(n): for i in range(n): k = list(map(int, input().split())) print((k[1] - k[0] % k[1]) % k[1]) n = int(input()) func(n)
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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()) def ceil(n, k): return n // k + (n % k != 0) for i in range(n): a, b = map(int, input().split()) t = ceil(a, b) print(b * t - a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR 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...
def dsum(num): s = 0 while num > 0: s += num % 10 num //= 10 return s T = int(input()) for t in range(T): num, s = [int(x) for x in input().strip().split(" ")] pow10 = 1 current_added = 0 for i in range(18): if dsum(num) <= s: break pos = (10 - n...
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 FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF 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...
x = int(input()) for i in range(x): found = False a, b = input().split() a = int(a) b = int(b) if a % b == 0 and not found: print(0) found = True if a < b and not found: print(b - a) found = True elif not found: print(b - a % b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN 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 solve(): n, s = input().split() s = int(s) sd = sum(list(map(int, n))) ans = 0 point = 0 a = int(n) n = n[::-1] debug = 0 while s < sd: a += 10**point * (10 - int(n[point])) ans += 10**point * (10 - int(n[point])) point += 1 n = str(a)[::-1] ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR 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...
import sys def main(): next(sys.stdin) for line in sys.stdin: a, b = tuple(map(lambda x: int(x), line.split())) if a % b == 0: print(0) else: m = a // b print((m + 1) * b - a) main()
IMPORT FUNC_DEF EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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 BIN_OP BIN_OP VAR NUMBER VAR 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...
from sys import stdin, stdout t = int(stdin.readline()) for _ in range(t): n, s = stdin.readline().split() s = int(s) sum = 0 movs = 0 for i in range(len(n)): sum += int(n[i]) if sum >= s: p = int(n[min(i + 1, len(n) - 1) :]) if sum != s or p != 0 and i != le...
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP 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): curr = 0 n1 = str(n) for i in range(len(n1)): curr += ord(n1[i]) - ord("0") if curr <= s: return 0 curr = 0 i = 0 while i < len(n1) and curr + int(n1[i]) + 1 <= s: curr += ord(n1[i]) - ord("0") i += 1 return 10 ** (len(n1) - i) - int(n1[i:]...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR BIN_OP 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 getSum(n): sum = 0 while n != 0: sum += int(n % 10) n //= 10 return sum t = int(input()) for _ in range(t): n, s = [int(s) for s in input().split(" ")] str_n = str(n) if getSum(n) <= s: print(0) else: zeroes = 0 sum = 0 j = 0 for ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL 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 STRING ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER 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...
import sys def gets(): return sys.stdin.readline().strip() def get(): return int(sys.stdin.readline().strip()) def geti(): return map(int, sys.stdin.readline().strip().split()) def getli(): return list(map(int, sys.stdin.readline().strip().split())) for _ in range(get()): a, b = geti() ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR 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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF 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 su(tmp): ans = 0 for i in tmp: ans += int(i) return ans for _ in range(int(input())): n, s = map(int, input().split()) tmp = list(str(n)) a = su(tmp) if s >= a: print(0) else: aa = ans = 0 c = 1 tmp = ["0"] + tmp for i in range(len(tm...
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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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...
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()) curr = a // b if not curr: if a >= b: print(0) else: print(b - a) else: while curr * b < a: curr += 1 print(curr * b - 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 IF VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER 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...
def stepdiv(a, b): return (b - a % b) % b for _ in range(int(input().strip())): a, b = list(map(int, input().strip().split(" "))) print(stepdiv(a, b))
FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING 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 fun(n): p = 0 while n: p += n % 10 n //= 10 return p for _ in range(int(input())): n, s = map(int, input().split()) orig = n while fun(n) > s: mod = 10 while n % mod == 0: mod *= 10 n += mod - n % mod print(n - orig)
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 VAR WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP 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...
t = int(input()) l = list() while t > 0: t = t - 1 a, b = map(int, input().split()) if a > b: if a % b != 0: c = a // b c += 1 d = c * b - a l.append(d) else: d = 0 l.append(d) else: c = b - a l.appen...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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...
for _ in range(int(input())): n, s = map(int, input().split()) l = [] while n > 0: l.append(n % 10) n = n // 10 ts = sum(l) ans = 0 l1 = [] c = 0 f = 0 if ts <= s: print(0) else: j = 0 for i in range(len(l)): if l[i] == 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 LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN 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...
def divisible(a, b): s = 0 if a > b and a % b != 0: s = b - (a - b) % b elif a <= b: s = b - a return s l = [] n = int(input()) for i in range(n): m = input().split() l.append(m) for i in l: print(divisible(int(i[0]), int(i[1])))
FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR 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...
import sys pin = sys.stdin.readline pout = sys.stdout.write ran = range m = int(pin()) mape = map for i in ran(m): a, b = mape(int, pin().split()) if a % b == 0: pout("0\n") else: print(b - a % b)
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 STRING 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()) ab = [] for n in range(N): a, b = (int(i) for i in input().split()) ab.append((a, b)) for a, b in ab: mod = a % b ans = b - mod if mod != 0 else 0 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR 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...
import sys input = sys.stdin.readline for i in range(int(input())): a, b = map(int, input().split()) n = a if a % b != 0: n = a // b * b + b print(n - a)
IMPORT ASSIGN 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 ASSIGN VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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...
t = int(input()) for i in range(t): n, s = map(int, input().split()) digits = [int(x) for x in str(n)] sum = 0 for j in range(len(digits)): sum += digits[j] if sum <= s: print("0") continue elif digits[0] > s or digits[0] + 1 > s: ans = [0] * len(digits) 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 FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER 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...
def sumnum(n): s = 0 while n: s += n % 10 n = n // 10 return s for _ in range(int(input())): n, s = map(int, input().split()) pw = 1 ans = 0 for i in range(18): z = sumnum(n) if z <= s: break dig = n // pw % 10 add = (10 - dig) % ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF 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...
t = int(input()) for qwerty in range(t): n, s = input().split() s = int(s) v = 0 pos = len(n) - 1 for i in range(len(n)): v += int(n[i]) if v <= s: a = int(n) else: v = 0 for i in range(len(n)): v += int(n[i]) if v >= s: ...
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 NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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...
n = int(input()) for i in range(n): z = input().split() a = int(z[0]) b = int(z[1]) d = a // b if a % b == 0: print(0) else: print((d + 1) * b - a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP 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...
t = int(input()) while t > 0: t -= 1 n, m = input().split() n = int(n) m = int(m) j = int(0) if n % m == 0: print(0) else: j = m - n % m print(j)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR 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 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...
testcase = int(input()) i = 0 answer = [] while i < testcase: a, b = map(int, input().split()) if a % b == 0: answer.append(0) else: answer.append(b - a % b) i += 1 for c in answer: print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE 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 EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR 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...
def digits_sum(num): s = 0 while num != 0: s = s + num % 10 num = num // 10 return s a = int(input()) i = 0 while i < a: inputs = input().split(" ") num = int(inputs[0]) num2 = int(inputs[1]) temp = num iterator = 0 while iterator < 19: temp2 = (10**iterator...
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE 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 ...
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 sum_digits(n): summ = 0 while n: summ += n % 10 n //= 10 return summ for _ in range(t): n, s = map(int, input().split()) ans = 0 pow_ten = 10 for i in range(18): if sum_digits(n) > s: ans += pow_ten - n % pow_ten n += p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN 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 FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP 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...
n = int(input()) langs = {"po": "FILIPINO", "desu": "JAPANESE", "masu": "JAPANESE", "mnida": "KOREAN"} res = [] for i in range(n): a, b = list(map(lambda x: int(x), input().split())) dif = a / b if dif > int(dif): dif = int(dif) + 1 res.append(b * int(dif) - a) for w in res: print(w)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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 _ in range(t): values = [int(x) for x in input().split()] a, b = values[0], values[1] if a % b == 0: print(0) elif a > b: div = (int(a / b) + 1) * b print(div - a) else: print(b - a)
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 VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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 = 0 i = 0 b = 0 while i < n: x, y = map(int, input().split()) if x % y == 0: a = 0 else: b = x % y a = y - b print(a) i = i + 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE 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 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...
t = int(input()) i = 0 y = [] while i < t: a, b = map(int, input().split()) a = int(a) b = int(b) i += 1 if a % b == 0: y.append(a % b) else: y.append((a // b + 1) * b - a) for i in y: print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP 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...
def addition(x, y): print([0, y - x % y][x % y != 0]) t = int(input()) for i in range(t): a, b = [int(x) for x in input().split()] addition(a, b)
FUNC_DEF EXPR FUNC_CALL VAR LIST NUMBER BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER 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 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...
n = int(input("")) for i in range(0, n): p, q = input("").split(" ") a = int(p) b = int(q) c = a // b if a % b == 0: print(0) else: print(b - a % b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR 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...
def divi(a, b): if b >= a: return b - a mod = a % b if mod == 0: return 0 return b - mod t = int(input()) l = [] for i in range(t): l.append(divi(*list(map(int, input().split(" "))))) for i in range(t): print(l[i])
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING 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...
t = int(input()) answer = [] def sum(n): result = 0 while n > 0: result += n % 10 n = n // 10 return result for t in range(t): n, s = list(map(int, input().split(" "))) nv = len(str(n)) count = 0 pow = 1 while sum(n) > s: digit = n // pow % 10 temp = p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST 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 VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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 divisible(a, b): c = 0 if a % b == 0 and a > b: c = 0 elif a > b: rem = a // b d = b * (rem + 1) f = d - a c = f elif a < b: c = b - a print(c) t = int(input()) while t > 0: t -= 1 a, b = map(int, input().split()) divisible(a, b)
FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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...
result = [] t = int(input()) for i in range(0, t): a, b = [int(x) for x in input().split()] if a % b == 0: result.append(0) else: result.append(b * (a // b + 1) - a) for i in range(0, len(result)): print(result[i])
ASSIGN VAR LIST 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 BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXP...
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(arr): if arr[0] % arr[1] == 0: return 0 else: return abs(arr[0] % arr[1] - arr[1]) for i in range(int(input())): print(solve(list(map(int, input().split(" ")))))
FUNC_DEF IF BIN_OP VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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...
t = int(input()) for _ in range(t): n, s = [int(x) for x in input().split()] arr = [int(x) for x in str(n)] currsum = sum(arr) while currsum > s: for j in range(len(arr) - 1, -1, -1): if arr[j] != 0: break arr[j] = 0 j -= 1 if j == -1: ...
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 VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN 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...
numCases = int(input()) for i in range(1, numCases + 1): line = input() arrNums = line.split(" ") num1 = int(arrNums[0]) num2 = int(arrNums[1]) if num1 % num2 != 0: print(num2 - num1 % num2) 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 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 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...
T = int(input()) def f_sum(n): s = last = pw = ctr = 0 fg = False while n != 0: k = n % 10 n = n // 10 if not fg and k != 0: last = k fg = True pw = ctr ctr += 1 s += k return [s, last, pw] arr = [] for _ in range(T): n,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR VAR RETURN LIST VAR VAR VAR ASSIGN VAR LIST FOR 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...
n = int(input()) ansl = [] for i in range(n): a, b = map(int, input().split()) m = 0 if a < b: m = b - a elif a % b == 0: m = 0 else: m = b - a % b ansl += [m] for r in ansl: print(r)
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 ASSIGN VAR NUMBER 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 VAR LIST 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...
def divisibility(list1): a = list1[0] b = list1[1] if a < b: print(b - a) elif a > b and a % b == 0: print(0) elif a > b: print(b - a % b) elif a == b: print(0) t = int(input()) for i in range(t): list1 = list(map(int, input().rstrip().split())) divisibi...
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR 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...
for _ in range(int(input())): n, s = map(int, input().split()) ns = str(n) l = len(ns) i = 0 sum_ = 0 p = n a = [] while p > 0: a.append(p % 10) p //= 10 a.reverse() sum_ = sum(a) if sum_ <= s: print("0") continue m = 0 i = 0 while ...
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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR 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()) l = [] for i in range(t): l.append(list(map(int, input().split()))) for ll in l: print((ll[1] - ll[0] % ll[1]) % ll[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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER 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...
x = int(input()) c = [] d = [] for i in range(x): a, b = list(map(int, input().split())) c.append(a) d.append(b) for i in range(x): if c[i] % d[i] == 0: print("0") elif c[i] > d[i]: f = c[i] % d[i] print(d[i] - f) else: print(d[i] - c[i])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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_CALL VAR STRING IF VAR VAR 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...
for _ in range(int(input())): n, s = map(int, input().split()) n = str(n) l = 10 ct = 0 i = -1 while sum(map(int, list(n))) > s: k = l - int(n[i:]) if k != 0: ct += k n = str(int(n) + k) l *= 10 i -= 1 print(ct)
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 ASSIGN VAR NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR 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()) for x in range(t): inp = input().split() a = int(inp[0]) b = int(inp[1]) moves = 0 if a % b == 0: pass elif a < b: moves = b - a elif a > b: rest = 1 - a / b % 1 moves = round(rest * b) print(moves)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR 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...
t = int(input()) tasks = [] for i in range(t): tasks.append(list(map(int, input().split()))) for i in range(t): n, s = tasks[i] str_n = str(n) if sum([int(str_n[j]) for j in range(len(str_n))]) <= s: print(0) else: x = len(str(n)) while sum([int(j) for j in "0" + str(n)[:-x]]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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, s = map(int, input().split()) string = str(n) l = len(string) tot = 0 for j in string: tot += int(j) if tot <= s: print(0) continue cnt = 0 tens = "" summ = 0 i = 0 while i < l and summ + int(string[i]) < s: ten...
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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING 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...
t = int(input()) for _ in range(0, t): n, m = map(int, input().split()) if n % m == 0: print(0) else: z = min(n, m) p = max(n, m) k = n // m + 1 k = k * z print(abs(k - p))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR 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 FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP 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...
def sum_digits(n): x = n ans = 0 while x > 0: ans += x % 10 x = x // 10 return ans t = int(input()) for i in range(t): a, b = input().split() a = int(a) b = int(b) x = a if sum_digits(x) > b: for i in range(20): dig = x % 10 ** (i + 1) // 10**i ...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF 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...
test = int(input()) for ans in range(test): n, s = map(int, input().split()) add = 0 x = 10 while n > 0: sums = sum(map(int, str(n))) if sums <= s: break else: add += x - n % x n = n + (x - n % x) x = x * 10 print(add)
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 WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP 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(0, t, 1): arr = [str(string) for string in input().split()] n = arr[0] s = arr[1] l1 = len(n) l2 = len(s) s_sum = int(s) n_sum = 0 j = 0 while j != l1: if int(n[j]) + n_sum <= s_sum: n_sum += int(n[j]) else: brea...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF ...
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()) d = [] for i in range(t): n = list(map(int, input().split())) d.append(n) for j in range(t): a = d[j][0] b = d[j][1] if a == b: print(0) elif 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER 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 _ in range(T): n, s = list(map(int, input().split())) a = list(map(int, str(n))) a = a[::-1] if sum(a) <= s: print(0) continue ans = 0 i = 0 n = len(a) while sum(a) > s and i < n: ans += (10 - a[i]) * 10**i a[i] = 0 if i + 1 >=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL 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 NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR 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...
def div(l): a = 0 b = l[0] if l[0] % l[1] == 0: a = 0 else: a = l[1] - l[0] % l[1] print(a) t = int(input()) while t > 0: l = list(map(int, input().split())) div(l) t = t - 1
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 is_good(n, s): return sum(int(i) for i in str(n)) <= s for _ in range(int(input())): n, s = map(int, input().split()) count = 0 m = 1 while True: m *= 10 if sum(int(i) for i in str(n)) <= s: break num = n % m count += m - num n += m - num ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN 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...
n = int(input()) lst = list() for i in range(n): lst.append(input().split()) for j in range(n): if int(lst[j][0]) % int(lst[j][1]): x = int(lst[j][1]) - int(lst[j][0]) % int(lst[j][1]) print(x) else: x = 0 print(x)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER 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...
num = int(input()) div = [] for i in range(num): arr = [i for i in input().split()][:2] j = 0 if int(arr[0]) % int(arr[1]) == 0: div.append(0) else: div.append(int(arr[1]) - int(arr[0]) % int(arr[1])) print(*div, sep="\n")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR 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 sumcal(x): s = 0 while x: s += x % 10 x //= 10 return s for _ in range(int(input())): n, s = list(map(int, input().split())) i = n b = 10 while sumcal(n) > s: n += b - n % b b *= 10 print(n - i)
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER EXPR 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...
a = int(input()) k = [] t = [] p = 0 for i in range(a): p = 0 k = list(map(int, input().split())) if k[0] < k[1]: print(k[1] - k[0]) elif k[0] == k[1]: print("0") else: if k[0] % k[1] != 0: l = k[0] % k[1] p = k[1] - l print(p)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STR...
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()) nstr = str(n) sum = [] sum.append(int(nstr[0])) for i in range(1, len(nstr)): lval = sum[-1] sum.append(lval + int(nstr[i])) ind = 0 while ind < len(nstr): if sum[ind] >= s: break ind +...
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 LIST EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR 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...
from sys import stdin, stdout class SOLVE: def solve(self): R = stdin.readline W = stdout.write ans = [] for i in range(int(input())): n, s = [x for x in R().split()] s = int(s) if sum([int(x) for x in n]) <= s: ans += ["0"] ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST 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 IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR LIST STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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...
a = int(input()) w = list() for i in range(a): b = input().split() b1 = int(b[0]) b2 = int(b[1]) val = 0 d = 0 if b1 % b2 != 0: d = int(b1 / b2) + 1 val = b2 * d - b1 else: val = 0 w.append(val) for i in w: print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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...
t = int(input()) for i in range(0, t): a, b = map(int, input().split()) c = a a1 = str(a) yy = len(a1) summ = 0 a2 = [] for j in range(0, yy): summ = summ + int(a1[j]) a2.append(int(a1[j])) if summ <= b: print(0) else: s1 = summ - b j = yy - 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR 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, m = map(int, input().split()) c = 0 if n % m == 0: print(c) elif n < m: m = m - n print(m) else: k = n // m k = k + 1 k = k * m k = k - n print(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 NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP 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...
n = int(input()) j = [] def cont(a, b): if a % b == 0: j.append(0) elif b > a: j.append(b - a) else: h = a % b ans = b - h j.append(ans) for i in range(n): a, b = map(int, input().split()) cont(a, b) print(*j, sep="\n")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF 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 ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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...
n = int(input()) l = [] for i in range(n): a, b = map(int, input().split()) l.append(a) l.append(b) i = 0 while i < 2 * n - 1: ct = 0 if l[i] % l[i + 1] != 0: q = int(l[i] / l[i + 1]) ct = l[i + 1] * (q + 1) - l[i] i += 2 print(ct)
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 VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER 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()) for _ in range(t): a, b = map(int, input().split()) start_a = a t = 0 s = 0 for i in str(a): s += int(i) while s > b: s = 0 for i in str(a): s += int(i) if s > b: break if s > b: a = (a // 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF 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 getSum(n): sum1 = 0 while n != 0: sum1 = sum1 + 1 n = n // 10 return sum1 def getNearest(n): c = 10 - n % 10 c = c + n return c def getSum1(n): sum = 0 while n != 0: sum = sum + n % 10 n = n // 10 return sum c = int(input()) for i in range(c)...
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 BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR 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 RETUR...
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(int, input().split()) if n % k == 0: p = 0 else: r = int(n / k) + 1 p = k * r - n print(p)
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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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 fun(a, b): if a % b == 0: return 0 else: x = a // b y = (x + 1) * b return y - a for _ in range(int(input())): a, b = list(map(int, input().split())) print(fun(a, b))
FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN BIN_OP 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 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...
for t in range(int(input())): n, s = map(int, input().split()) dif = sum(map(int, str(n))) - s if dif <= 0: print(0) continue n2 = n sm = 0 k = 0 while sm - 1 < dif: sm += n % 10 n //= 10 k += 1 k = 10**k print(k - n2 % 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 BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR 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()) while t: t -= 1 a, b = input().split() a = int(a) b = int(b) if a <= b: print(b - a) elif a % b == 0: print(0) else: res = a // b mul_res = b * (res + 1) print(mul_res - a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR 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 VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER E...
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 def i(): return input() def ii(): return int(input()) def iis(): return map(int, input().split()) def liis(): return list(map(int, input().split())) def print_array(a): print(" ".join(map(str, a))) t = ii() for _ in range(t): a, b = iis() div = a // b if ...
FUNC_DEF RETURN FUNC_CALL VAR 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 VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR 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...
def is_div(a, b): if a % b == 0: return 0 else: return b - a % b test_cases = [list(map(int, input().split())) for _ in range(int(input()))] for t in test_cases: print(is_div(t[0], t[1]))
FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR 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...
N = int(input()) data = [] for i in range(N): data.append(input().split()) for j in range(2): data[i][j] = int(data[i][j]) def res(a): x = a[0] y = a[1] cnt = 0 if x % y != 0: cnt = y - x % y else: cnt = x % y return str(cnt) for i in range(N): print(res(d...
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 FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR 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...
def noMoves(arr): a = arr[0] b = arr[1] c = a // b d = a / b if c == d: return 0 return b * (c + 1) - a i = int(input()) for j in range(0, i): arr = [int(num) for num in input().split()] print(noMoves(arr))
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL 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())): a, b = [int(i) for i in input().split()] if b * (a // b + 2 - 1) - a == b: print(0) else: print(b * (a // b + 2 - 1) - a)
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 BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER 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...
for _ in range(int(input())): n, s = map(int, input().split()) st = "0" * (19 - len(str(n))) + str(n) sm = 0 for i in st: sm += int(i) moves = 0 if sm <= s: print(moves) continue else: diff = sm - s st = st[::-1] pw = 1 prof = int(st[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 BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN 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 construct(s, index): if index == 0: return "1" + "0" * len(s) mid = str(int(s[index - 1]) + 1) if len(mid) < 2: return s[: index - 1] + str(int(s[index - 1]) + 1) + "0" * (len(s) - index) can = s[: index - 1] + "0" + "0" * (len(s) - index) p = len(s) - index + 1 return str(in...
FUNC_DEF IF VAR NUMBER RETURN BIN_OP STRING BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP 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 ProcessInputs(): A, B = map(int, input().strip().split()) if A % B == 0: print(0) return else: print(B - A % B) return T = int(input()) for _ in range(T): ProcessInputs()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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...
def main(): for _ in range(int(input())): a, b = list(map(int, input().split())) if a % b == 0: print("0") else: s = int(a // b) s = s + 1 b = b * s a = b - a print(a) main()
FUNC_DEF 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 BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR 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...
def ekline(): t = int(input()) for i in range(t): a, b = map(int, input().split()) if a % b != 0: if a > b: c = b * (a // b + 1) print(c - a) elif a < b: print(b - a) else: print(0) ekline()
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 IF BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL 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...
import sys input = sys.stdin.buffer.readline def print(val): sys.stdout.write(str(val) + "\n") def prog(): for _ in range(int(input())): n, s = map(int, input().split()) n = str(n)[::-1] prefix = [0] for i in range(len(n)): prefix.append(prefix[-1] + int(n[i])) ...
IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF 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 NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR 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...
tc = int(input()) while tc: num_str, n = input().split() n = int(n) digSum = sum(map(int, num_str)) if digSum <= n: print(0) else: tempSum = 0 for i, d in enumerate(num_str): if tempSum + int(d) < n: tempSum += int(d) else: ...
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 FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL 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...
def main(): result = str() for i in range(int(input())): a, b = map(int, input().split()) if a == b or a % b == 0: r = 0 else: r = (a // b + 1) * b - a result += f"{r}\n" print(result.strip()) main()
FUNC_DEF ASSIGN VAR FUNC_CALL 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR STRING EXPR 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...
t = int(input()) def check_sum(n): s = 0 for i in n: s += int(i) return s while t: a = input().split() n, s = int(a[0]), int(a[1]) moves = 0 sumi = check_sum(str(n)) if sumi <= s: print(0) t -= 1 continue l = len(str(n)) cnt = 1 orig = str(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR WHILE VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL 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()) i = 0 while i < t: riga = list(map(int, input().strip().split())) a = riga[0] b = riga[1] c = a % b mosse = 0 if c != 0: mosse = b - c else: mosse = 0 print(mosse) i = i + 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE 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 ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR 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...
t = int(input()) for _ in range(t): n, s = tuple([int(i) for i in input().split()]) cs = sum([int(i) for i in str(n)]) if cs <= s: print(0) continue digs = 0 for i in str(n)[::-1]: cs -= int(i) digs += 1 if cs + 1 <= s: break val = 10**digs - n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL 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 IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL 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()) for _ in range(t): n, k = map(int, input().split()) n1 = n l = [] while n: l.append(n % 10) n = n // 10 l.append(0) x = sum(l) i = 0 while x > k: x -= l[i] l[i] = 0 l[i + 1] += 1 if l[i + 1] < 10: x += 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 VAR ASSIGN VAR LIST WHILE VAR 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 WHILE VAR VAR VAR ...