description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
res = n * (n - 1) // 2
cur = 1
for i in range(1, n):
if s[i] == s[i - 1]:
cur += 1
else:
res -= cur
cur = 1
s = s[::-1]
cur = 0
for i in range(1, n):
if s[i] == s[i - 1]:
cur += 1
else:
res -= cur
cur = 0
print(res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | def comp(a):
if a == "A":
return "B"
else:
return "A"
n = int(input())
s = input()
ans = n * (n - 1) // 2
groups = [0]
prev = s[0]
for i in range(1, n):
if s[i] != prev:
groups.append(i)
prev = s[i]
for i in range(0, len(groups) - 2):
ans -= groups[i + 2] - groups[i] - ... | FUNC_DEF IF VAR STRING RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CAL... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
ans = n * (n + 1) / 2 - n
count, i = 0, 0
l = list()
while i < n:
c = s[i]
val = 0
while i < n and s[i] == c:
i += 1
val += 1
l.append(val)
count += len(l) - 1
l = list(map(list, list(zip(l, l[1:]))))
for a, b in l:
count += a - 1 + b - 1
print(int(ans - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP FUNC... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
x = s[0]
l = 1
r = 0
for i in range(1, n):
y = s[i]
if x == y:
r += i
if l < i:
r -= 1
l += 1
else:
r += i - l
l = 1
x = y
print(r) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
tt = n * (n - 1) // 2
s = input().lower()
ss = 0
for i in range(0, n):
if s[i] == "a":
j = i - 1
while j > -1 and s[j] == "b":
ss += 1
j -= 1
j = i + 1
while j < n and s[j] == "b":
ss += 1
j += 1
for i in range(0, n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import sys
input = sys.stdin.readline
n = int(input())
S = input().strip()
A = []
B = []
for i in range(n):
if S[i] == "A":
A.append(i)
else:
B.append(i)
BE = [-1] * n
for i in range(1, len(A)):
BE[A[i]] = A[i - 1]
for i in range(1, len(B)):
BE[B[i]] = B[i - 1]
LEN = n + 10
BIT = [0] * ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VA... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
prev_b = -1
prev_a = -1
ans = 0
for i in range(n):
if s[i] == "B":
ans += prev_b + 1
if prev_b + 1 == i and prev_a != -1:
ans -= 1
prev_b = i
else:
ans += prev_a + 1
if prev_a + 1 == i and prev_b != -1:
ans -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIG... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import sys
def main():
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rnk = [0] * (n + 1)
def find_root(self, x):
if self.root[x] < 0:
return x
... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
if n == 1:
print(0)
exit(0)
s = input()
K = []
lc = s[0]
cnt = 0
for i in s:
if i == lc:
cnt += 1
else:
K.append(cnt)
cnt = 1
lc = i
K.append(cnt)
bad = 3 * n - K[0] - K[-1] - (len(K) - 1)
print(n * (n + 1) // 2 - bad) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
count = 0
prev = s[0]
groups = [1]
for i in range(1, n):
if prev == s[i]:
groups[-1] += 1
else:
prev = s[i]
groups.append(1)
for i in range(0, len(groups) - 1):
count += groups[i] + groups[i + 1] - 1
print(n * (n - 1) // 2 - count) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP BIN_OP VAR... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import sys
zz = 1
sys.setrecursionlimit(10**5)
if zz:
input = sys.stdin.readline
else:
sys.stdin = open("input.txt", "r")
sys.stdout = open("all.txt", "w")
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]
def fori(n):
return [fi() for i in range(n)]
def inc(d, c, x=1):
d[c] = d[c] + x if c in d else x
... | IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NU... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | from sys import stdin
n = int(input())
s = stdin.read(n)
ans = n * (n - 1) // 2
k = 0
m = 0
for i in range(1, n):
p = s[i - 1]
t = s[i]
if p == t:
k += 1
else:
ans -= k * (1 << m) + 1
m |= 1
k = 0
else:
ans -= k * m
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMB... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | from sys import stdin, stdout
n = int(stdin.readline().strip())
s = stdin.readline().strip()
acumA = [(0) for i in range(n + 3)]
acumB = [(0) for i in range(n + 3)]
dictA = [(-1) for i in range(n + 3)]
dictB = [(-1) for i in range(n + 3)]
for i in range(n):
if i != 0:
acumA[i] += acumA[i - 1]
acumB... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VA... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import sys
readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")
def solve():
n = ni()
s = ns() + "$"
c = n * ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VA... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
x = str(input())
count = 1
ans = n * (n - 1) / 2
dp = []
for i in range(1, n):
if x[i] == x[i - 1]:
count += 1
if x[i] != x[i - 1]:
dp.append(count)
count = 1
if i == n - 1:
dp.append(count)
for i in range(len(dp)):
if len(dp) == 1:
pass
elif ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF ... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
arr = []
for i in range(n):
c = 0 if s[i] == "A" else 1
if not arr or arr[-1][0] != c:
arr.append([c, 1])
else:
arr[-1][1] += 1
cnt = (n * n + n) // 2
if len(arr) == 1:
print(cnt - n)
exit()
for i in range(0, len(arr)):
cnt -= arr[i][1] + (arr[i][1] i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR STRING NUMBER NUMBER IF VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR F... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
cnt = n
for x in range(2):
cur = 1
for i in range(1, n):
if s[i] == s[i - 1]:
cur += 1
else:
cnt += cur - x
cur = 1
s = s[::-1]
print(n * (n + 1) // 2 - cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUM... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | def solve():
n = int(input())
s = input()
res = n * (n - 1) // 2
cur = 1
start = 0
end = n - 1
for i in range(1, n):
if s[i] == s[i - 1]:
cur += 1
else:
res -= cur - 1
start = i
cur = 1
break
for i in range(n - 2... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUM... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
a, b, c = -1, -1, 0
for i in range(n):
if s[i] == "A":
c += i - a - 1
a = i
else:
c += i - b - 1
b = i
t = s[::-1]
a, b = -1, -1
for i in range(n):
if t[i] == "A":
c += max(0, i - a - 2)
a = i
else:
c += max(0, i - b - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | X = input()
X = input()
a, b, c, d, k = 0, 0, 1, 1, 1
l = len(X)
for i in range(1, l):
if X[i] == X[i - 1]:
if c != 1:
c += 1
b += 1
else:
c += 1
b += d
else:
if c != 1:
b += 2 - c - k
d = c
c = 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR ... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | 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 ... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | from sys import setrecursionlimit, stdin
setrecursionlimit(10**7)
def iin():
return int(stdin.readline())
def lin():
return list(map(int, stdin.readline().split()))
def main():
n = iin()
s = list(input())
ans = n * (n - 1) // 2
for i in range(2):
ch = 1
for j in range(1, n... | EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | N = int(input())
S = list(input())
pre = S[0]
A = []
a = 0
for s in S:
if s == pre:
a += 1
else:
A.append(a)
a = 1
pre = s
A.append(a)
q = 0
for i in range(len(A) - 1):
q += A[i] + A[i + 1] - 1
ans = N * (N - 1) // 2 - q
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import itertools
n = int(input())
s = input()
x = []
for k, g in itertools.groupby(s):
l = len(list(g))
x += [l]
bad = 0
for f, g in zip(x, x[1:]):
bad += f + g - 1
good = n * (n + 1) // 2 - n - bad
print(good) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR LIST VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR N... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | from itertools import groupby
n = int(input())
a = [len(list(v)) for k, v in groupby(input())]
ans = n * (n - 1) // 2
for x, y in zip(a, a[1:]):
ans -= x + y - 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
tab = []
count = 1
for i in range(1, n):
if s[i] == s[i - 1]:
count += 1
else:
if count > 0:
tab.append(count)
count = 1
if count > 0:
tab.append(count)
dis = 0
k = len(tab)
if k == 0 or k == 1:
dis = 0
else:
dis += tab[1]
dis += t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | length = int(input())
s = input()
substrings = sum(range(length + 1))
substrings -= length
transitioned = False
journey = 0
i = 0
current_character = s[i]
journey += 1
i += 1
while i < length:
if s[i] == current_character:
journey += 1
else:
if journey > 1:
if i == journey:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_O... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | def solve():
n = int(input())
array = input()
i, j = 0, 0
totalBadString = 0
l = [0, 0]
l[ord(array[i]) - 65] += 1
while i < n - 1 and j < n:
if l[0] == 1 and l[1] >= 1 or l[1] == 1 and l[0] >= 1:
if l[0] == 1 and l[1] == 1:
expectedValue = array[j]
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER IF VAR NUMBE... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
S = input()
pa = -1
pb = -1
cnt = 0
for i, s in enumerate(S):
if s == "A":
if pa == -1:
pa = i
else:
cnt += pa + 1
if S[i - 1] == "A" and pb != -1:
cnt -= 1
pa = i
if s == "B":
if pb == -1:
pb = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR STRING IF VAR NUMBER ASSIGN VAR... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import sys
readline = sys.stdin.readline
N = int(readline())
S = [(1 if s == "A" else 0) for s in readline().strip()]
ans = 0
L1 = [None] * (N + 1)
L2 = [None] * (N + 1)
for i in range(N - 1, -1, -1):
s = S[i]
L1[i] = L1[i + 1]
L2[i] = L2[i + 1]
if s == 1:
L1[i] = i
else:
L2[i] = i
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
blocks = 1
first = 1
last = 1
while first < n and s[first] == s[first - 1]:
first += 1
while last < n and s[-last - 1] == s[-last]:
last += 1
for i in range(1, n):
if s[i] != s[i - 1]:
blocks += 1
print(n * (n - 1) // 2 - (2 * n + 1 - first - last - blocks)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL ... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = list(input())
u = []
k = 1
for i in range(1, n):
if s[i] != s[i - 1]:
u.append(k)
k = 1
else:
k += 1
u.append(k)
ans = n * (n - 1) // 2
for i in range(1, len(u)):
ans -= u[i - 1]
ans -= u[i]
ans += 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | import sys
def main():
n = int(input())
s = input()
groupSizes = []
sz = 0
for i in range(n):
if i - 1 >= 0 and s[i] != s[i - 1]:
groupSizes.append(sz)
sz = 0
sz += 1
groupSizes.append(sz)
badCnts = 0
m = len(groupSizes)
for i in range(m):
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | p = int(input())
s = input()
i = 0
cnt_Bad = 0
leng = 0
while i < len(s):
if s[i] == "A":
i += 1
while i < len(s) and s[i] == "B":
i += 1
leng += 1
else:
i += 1
cnt_Bad += leng
i = 0
leng = 0
while i < len(s):
if s[i] == "B":
i += 1
while i < l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
a = list(input())
A = B = -1
index = [0] * n
arr = 0
is_a = -1
is_b = -1
for i in range(n - 1, -1, -1):
if a[i] == "A":
index[i] = A
if A == -1:
is_a = i
A = i
else:
index[i] = B
if B == -1:
is_b = i
B = i
for i in range(n)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR V... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input().rstrip()
s += "#"
ans = (n - 1) * n // 2
if "A" not in s or "B" not in s:
print(ans)
exit()
cnt = 0
counts = []
for i, ch in enumerate(s):
if i == 0:
prev = ch
cnt += 1
continue
if prev == ch:
cnt += 1
else:
counts.append(cnt)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR... |
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | n = int(input())
s = input()
ans = int(n * (n - 1) / 2)
c = 0
for i in range(n):
if s[i] == "A":
c += 1
else:
if c > 1:
ans -= c - 1
c = 0
c = 0
for i in range(n):
if s[i] == "B":
c += 1
else:
if c > 1:
ans -= c - 1
c = 0
s = s[::-1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING... |
You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.
The boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$. You may play some of your cards during each ... | from sys import exit, stdin, stdout
n = int(input())
inf = 10**18
dp = [([-inf] * 10) for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
k = int(stdin.readline())
cards = []
for j in range(k):
c, d = map(int, stdin.readline().split())
cards.append((c, d))
cards.sort(reverse=True)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = sys.stdin.readline
a = [(0, 0), (2, 0), (0, 0), (2, 1)]
h = [(1, 0), (1, 0), (3, 0), (1, 0)]
z = [(0, 0), (0, 0), (0, 0), (0, 0)]
def f_s(x):
r = 0
for i in range(1, x + 1):
si = str(i)
sii = str(i - 1)
if len(si) > len(sii):
sii = "0" + sii
for ... | IMPORT ASSIGN VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN V... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = t = int(input().strip())
for _ in range(t):
l, r = map(int, input().strip().split())
ans, ok = 0, 1
while ok <= r:
ans += r // ok - l // ok
ok *= 10
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
a, b = input().split()
m, n = len(a), len(b)
a = "0" * (n - m) + a
ans = 0
for i in range(1, 1 + len(b)):
ans += int(b[:i]) - int(a[:i])
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for _ in range(t):
a, b = list(map(int, input().split()))
ans1 = b
i = 10
while i <= b:
ans1 += b // i
i *= 10
ans0 = a
i = 10
while i <= a:
ans0 += a // i
i *= 10
print(ans1 - ans0) | 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 VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = list(map(int, input().split(" ")))
res = r - l
while r > 0:
r //= 10
l //= 10
res += r - l
print(res) | 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 STRING ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
a, b = map(str, input().split())
x = a[::-1]
y = b[::-1]
n = len(x)
m = len(b)
l = [1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]
ans = 0
for i in range(m):
c = ord(y[i]) - 48
ans += c * l[i]
for i in range(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 VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def s(n):
l = len(str(n))
ret = 0
for i in str(n):
ret += int(i * l)
l -= 1
return ret
for _ in range(int(input())):
a, b = input().split()
a, b = int(a), int(b)
print(s(b) - s(a)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUN... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | n = int(input())
while n:
a, b = list(map(int, input().split()))
ans = 0
cnt = 0
while b:
q = b % 10
q = 10 if not q else q
ans += b - a
b //= 10
a //= 10
cnt += 1
print(ans)
n -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
def solve():
l, r = map(int, input().split())
ans = 0
while r > 0:
ans += r - l
r //= 10
l //= 10
print(ans)
for i in range(t):
solve() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
from sys import maxsize
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def get_list():
return list(map(int, sys.stdin.readline().strip().split()))
def get_list_string():
return list(map(str, sys.stdin.readline().strip().split()))
def get_string():
return sys.std... | IMPORT 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 FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL F... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for _ in range(t):
l, r = map(int, input().split())
n = len(str(r))
ans = 0
for i in range(n):
currl = l // 10**i
currr = r // 10**i
ans += currr - currl
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR EXPR FUNC_CA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | T = int(input())
for t in range(T):
l, r = map(int, input().split())
ans = 0
for i in range(10):
div = 10**i
ans += r // div - l // div
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for u in range(int(input())):
l, r = map(int, input().split())
ans = 0
f = 1
while f <= r:
ans += r // f
f *= 10
f = 1
while f <= l:
ans -= l // f
f *= 10
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for tt in range(t):
l, r = input().strip().split(" ")
l = int(l)
r = int(r)
ll = l // 10
rr = r // 10
while ll:
l += ll
ll = ll // 10
while rr:
r += rr
rr = rr // 10
print(r - l) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | a = int(input())
for i in range(a):
s = input()
s = s.split()
num1, num2 = int(s[0]), int(s[1])
digit = 0
ans = 0
while True:
cnt = num2 // 10**digit - num1 // 10**digit
if cnt == 0:
break
ans += cnt
digit += 1
print(ans) | 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 VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER V... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def main():
def solve(arr):
ans = 0
l, r = arr
while l > 0 or r > 0:
ans += r - l
r = r // 10
l = l // 10
return ans
number_tests = int(input())
for _ in range(number_tests):
arr = list(map(int, input().split()))
print(sol... | FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for _ in range(t):
l, r = map(int, input().split())
c1 = r - l
for i in range(1, 10):
c1 += r // 10**i
c2 = 0
for i in range(1, 10):
c2 += l // 10**i
print(c1 - c2) | 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 FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL V... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
out = []
def get_sum(l, r):
sum = r - l
dr = r // 10
dl = l // 10
while dr > 0:
sum += dr - dl
dr = dr // 10
dl = dl // 10
return sum
for i in range(t):
l, r = map(int, input().split())
out.append(get_sum(l, r))
for i in range(t):
print(out[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR ASSIGN 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 VAR FUNC_CAL... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for i in range(t):
l, r = map(str, input().split())
ans, pres = 0, 0
while len(l) < len(r):
l = "0" + l
for i in range(len(l)):
if l[i] == r[i] and pres == 0:
continue
el1 = int(l[i])
el2 = int(r[i])
if pres == 0:
ans = el2... | 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 NUMBER NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
ansl = 0
ansr = 0
ansl += l - 1
ansr += r - 1
while l:
ansl += l // 10
l //= 10
while r:
ansr += r // 10
r //= 10
print(ansr - ansl) | 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 VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = lambda: sys.stdin.readline().rstrip()
def f(n):
val, ans = 1, 0
while n:
v = n % 10
ans += val * v
n //= 10
val = 10 * val + 1
return ans
for _ in range(int(input())):
l, r = map(int, input().split())
print(f(r) - f(l)) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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 EXPR FUNC_... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | dic = {
(10): 11,
(100): 111,
(1000): 1111,
(10000): 11111,
(100000): 111111,
(1000000): 1111111,
(10000000): 11111111,
(100000000): 111111111,
(1000000000): 1111111111,
}
def foo(diff):
start = 0
ans = 0
while diff >= test[-1]:
if diff >= test[start]:
... | ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
a = b = c = d = e = f = g = h = j = 0
ans = 0
for i in range(t):
ll, r = input().split(" ")
ll, r = int(ll), int(r)
a = r // 10 - ll // 10
b = r // 100 - ll // 100
c = r // 1000 - ll // 1000
d = r // 10000 - ll // 10000
e = r // 100000 - ll // 100000
f = r // 1000000 - l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def func(r):
if r == 1:
return 0
total_digits = len(str(r))
nums_divisible_by_ten = [(0) for i in range(total_digits + 1)]
starting = total_digits - 1
count = 0
while starting > 0:
divisor = 10**starting
nums_divisible_by_ten[starting] = r // divisor - count
count... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMB... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for i in range(int(input())):
r, l = map(int, input().split())
ans = 0
while l >= 1:
ans += l - r
r //= 10
l //= 10
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def main(l, r):
res = 0
while l or r:
res += r - l
l //= 10
r //= 10
return res
t = int(input().strip())
for _ in range(t):
l, r = map(int, input().strip().split())
print(main(l, r)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def count(n):
ans = (
n // 10
+ n // 100
+ n // 1000
+ n // 10000
+ +(n // 100000)
+ n // 1000000
+ n // 10000000
+ n // 100000000
+ n // 1000000000
)
return ans
for _ in range(int(input())):
a, b = map(int, input().split())
l... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_C... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for i in range(0, t):
l, r = map(int, input().split())
a = 0
while l != 0 or r != 0:
a = a + abs(l - r)
l //= 10
r //= 10
print(a) | 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 NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def fun(n):
s, c = 10, n - 1
while s <= n:
c += n // s
s *= 10
return c
for _ in range(int(input())):
l, r = list(map(int, input().split()))
print(fun(r) - fun(l)) | FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR 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 EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def sol1toA(A):
count = A - 1
while A > 0:
A = A // 10
count += A
return count
def sol(a, b):
return sol1toA(b) - sol1toA(a)
x = int(input())
for _ in range(x):
A = list(map(int, input().split()))
print(sol(A[0], A[1])) | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR FUNC_CA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | test_cases = int(input())
for test_case in range(test_cases):
l, r = list(map(int, input().split()))
ans = 0
while r > 0:
ans += r - l
r = int(r / 10)
l = int(l / 10)
print(ans) | 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 NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
while t:
l, r = map(int, input().split())
c = r - l
s = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
sum = 0
while c > 0:
for i in range(10):
a = c // 10 ** s[i]
if a > 0:
c = c - a * 10 ** s[i]
d = s[i]
k = r - c
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def interesting_function(l, r):
result = 0
while r > 0:
result += r - l
r //= 10
l //= 10
print(result)
t = int(input())
for _ in range(t):
inputs = list(map(str, input().split()))
interesting_function(int(inputs[0]), int(inputs[1])) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | d = [
0,
10,
110,
1110,
11110,
111110,
1111110,
11111110,
111111110,
1111111110,
11111111110,
111111111110,
]
t = int(input())
for _ in range(t):
l, r = map(int, input().split())
lans = 0
rans = 0
mult = 1
count = 0
while l > 0:
ldigit = l ... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def calc(x):
f = 1
ans = []
while f <= x:
ans.append(x // f)
f *= 10
return sum(ans)
for case in range(int(input())):
l, r = [int(x) for x in input().split()]
print(calc(r) - calc(l)) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER RETURN FUNC_CALL 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 EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for z in range(t):
l, r = map(int, input().split())
ans = 0
x = str(l)[::-1]
y = str(r)[::-1]
for i in range(0, len(y)):
s = int("1" * (i + 1))
tp1 = int(y[i]) % 10 ** (i + 1)
ans += tp1 * s
for i in range(0, len(x)):
s = int("1" * (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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP STRING BIN_OP VAR NUMBER ASSI... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for t in range(int(input())):
x, y = input().split()
x = int(x)
y = int(y)
r = 0
while y:
r += y - x
x //= 10
y //= 10
print(r) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for i in range(int(input())):
l, r = list(map(int, input().split()))
a = 0
b = 0
for i in range(1, 10):
a += l // 10**i
b += r // 10**i
print(b - a + r - l) | 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 FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
ans = r - l
cnt = 0
x = r
y = l
sc = 0
while y != 0:
y = y // 10
sc = sc + y
while x != 0:
x = x // 10
cnt = cnt + x
print(cnt - sc + ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASS... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for i in range(t):
l, r = map(int, input().split())
res = r - l
while r // 10 >= 10:
r //= 10
l //= 10
res += r - l
print(r // 10 - l // 10 + res) | 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 WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in [*open(0)][1:]:
q, w = _.split()
q, e = "000000000" + q, 0
for i in range(len(w)):
e += int(w) - int(q)
w = w[:-1]
q = q[:-1]
print(e) | FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def funct(l, r):
out = 0
for i in range(0, 13):
f = 10**i
out = out + (r // f - l // f)
return out
for _ in range(int(input())):
l, r = map(int, input().split())
print(funct(l, r)) | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = sys.stdin.readline
def f(a):
ok = 0
while a > 0:
ok += a
a = a // 10
return ok
t = int(input())
for you in range(t):
l = input().split()
a = int(l[0])
b = int(l[1])
print(f(b) - f(a)) | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR 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 EXPR FUNC_CALL VAR BIN_OP FUNC_CAL... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
x = r - l
y = (
x
+ (r // 10 - l // 10)
+ (r // 100 - l // 100)
+ (r // 1000 - l // 1000)
+ (r // 10000 - l // 10000)
+ (r // 100000 - l // 100000)
+ (r // 1000000 - l // 1000000)
+... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBE... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
a, b = map(str, input().split())
a = a[::-1]
b = b[::-1]
aa = 0
bb = 0
for i in range(len(b)):
bb += int((i + 1) * "1") * int(b[i])
for i in range(len(a)):
aa += int((i + 1) * "1") * int(a[i])
print(bb -... | 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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER STRING FUNC_CALL VAR ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
L, R = [int(x) for x in input().split()]
ans = R - L
cnt_r = 0
cnt_l = 0
for i in range(1, 20):
cnt_r += R // pow(10, i)
cnt_l += L // pow(10, i)
ans +... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR FUNC_CALL ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def count(s):
ans = 0
for i in range(len(s), 0, -1):
ans += int(s[:i])
return ans
for t in range(int(input())):
l, r = input().split()
print(count(r) - count(l)) | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def f(l, r):
if r == 0:
return 0
else:
return r - l + f(l // 10, r // 10)
t = int(input())
for _ in range(t):
l, r = map(int, input().split())
print(f(l, r)) | FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER 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 two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for j in range(t):
l, r = map(int, input().split())
count = 0
sum = 0
ll = str(l)
sum += 1
rr = str(r)
sum += 1
ll = (len(rr) - len(ll)) * "0" + ll
sum += 1
n = len(rr)
sum += 1
for i in range(n):
sum += 1
s1 = int(ll[: n - i])
sum... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING VAR VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
oneee = 64656
l, r = map(int, input().split())
dxds = 3545
t = r
zsfv = 6435
ans = 0
segdvz = 5844
a1 = [0] * len(str(t))
tdgssge = True
z = str(l)[::-1]
for i in range(len(str(l))):
drgdrg = False
a1[-(i + 1)] = int(z[i])
sef... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for s in [*open(0)][1:]:
r = 0
k = -1
for x in map(int, s.split()):
while x:
r += k * x
x //= 10
k = 1
print(r) | FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR WHILE VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for w in range(t):
l, r = [x for x in input().split()]
a = [int(x) for x in l]
b = [int(x) for x in r]
count = 0
while len(a) > 0 or len(b) > 0:
s_a = 0
s_b = 0
for i in range(len(a)):
s_a += a[i]
s_a *= 10
for i in range(len(b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FU... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
s = int("1" + (len(str(r)) - 1) * "0")
i = s
prev = 0
ans = 0
prod = len(str(s))
while i > 0:
boom = r // i - l // i - prev
prev += boom
ans += boom * prod
i //= 10
prod -= 1
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASS... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
while t > 0:
t -= 1
a = [int(i) for i in input().split(" ")]
f, e = a[0], a[1]
out = e - f
while e > 0:
out += e // 10 - f // 10
f //= 10
e //= 10
print(out) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def solve():
l, r = map(int, input().split())
answer = 0
while r > 0:
answer += r - l
r //= 10
l //= 10
return answer
t = int(input())
while t > 0:
t -= 1
print(solve()) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for jj in range(t):
l, r = list(map(int, input().split()))
l = str(l)
r = str(r)
while len(l) != len(r):
l = "0" + l
ans = 0
old = 0
for i in range(len(l)):
diff = int(r[i]) - int(l[i])
ans += old * 10 + diff
old = old * 10 + diff
print(an... | 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 VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL V... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
def calc(a):
count = 0
while a > 0:
count = count + a
a = int(a / 10)
return count
t = int(sys.stdin.readline())
while t > 0:
l, r = map(int, sys.stdin.readline().split())
p = calc(l)
q = calc(r)
print(q - p)
t = t - 1 | IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR 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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | a = int(input())
for _ in range(a):
inp = input().split()
l = 0
r = 0
l = int(inp[0])
r = int(inp[1])
ans = 0
while l + r > 0:
ans += l - r
l = l // 10
r = r // 10
if ans <= 1111111110:
ans = abs(ans)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
while t > 0:
t -= 1
l, r = [int(x) for x in input().split()]
num1 = str(l)
num2 = str(r)
ans = 0
while len(num1) != len(num2):
num1 = "0" + num1
for i in range(len(num1)):
k1 = int(num1[: i + 1])
k2 = int(num2[: i + 1])
ans += k2 - k1
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIG... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
t = l
count = 0
a = 1
while t // a > 0:
count += t // a
a *= 10
t = r
c = 0
a = 1
while t // a > 0:
c += t // a
a *= 10
print(c - count) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NU... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
ans = []
for i in range(t):
l, r = map(int, input().split())
res = 0
for i in range(len(str(r))):
res += r // 10**i - l // 10**i
ans.append(res)
print(*ans, sep="\n") | 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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | from sys import stdin
input = stdin.readline
t = int(input())
def solve(n):
res, mul = 0, 1
for i in range(12):
res += n // mul
mul = mul * 10
return res
for _ in range(t):
l, r = map(int, input().split())
print(solve(r) - solve(l)) | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.