description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = [int(j) for j in input().split()]
a = input().split("1")
p = 0
for i in a:
if "0" in i:
p += 1
if p == 0:
print(0)
else:
print((p - 1) * min(x, y) + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF STRING VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
cnt = 0
i = 0
while i < n:
if s[i] == "0":
cnt += 1
while i < n and s[i] == "0":
i += 1
i += 1
ans = 10**18
for i in range(cnt, 0, -1):
val = i * y + (cnt - i) * x
ans = min(ans, val)
if ans == 10**18:
print(0)
else:
pri... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
a = str(input())
f = 1
d = 0
if a.find("0") == -1:
print(0)
else:
for i in a:
if i == "0" and f == 1:
d += 1
f = 0
elif i == "1":
f = 1
print((d - 1) * min(x, y) + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def r(a, b):
ans = a // b
if a % b != 0:
ans += 1
return ans
n, x, y = map(int, input().split())
a = list(input()) + ["1"]
count = 0
for i in range(1, n + 1):
if a[i] == "1" and a[i - 1] == "0":
count += 1
ans = 999999999999999999
if count == 0:
print(0)
exit()
for i in range(c... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR LIST STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUM... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = [int(s) for s in input().split(" ")]
a = input()
z = len([t for t in a.split("1") if t])
ans = max(min(z * y, y + (z - 1) * x), 0)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | [n, x, y] = map(int, input().strip().split())
a = input().strip() + "1"
k = a.count("01")
if k == 0:
print(0)
else:
print((k - 1) * min(x, y) + y) | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split(" "))
s = input()
isolated = 0
ones = 0
last = "1"
for digit in s:
if digit == "1" and last == "0":
isolated += 1
if digit == "0":
ones += 1
last = digit
if last == "0":
isolated += 1
if ones == 0:
print(0)
else:
print(min(isolated * y, (isolated ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR F... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | from itertools import groupby
n, x, y = map(int, input().split())
s = input().strip()
b = [(1 if k == "1" else 0) for k, g in groupby(s)]
dp = [0] * len(b)
dp[0] = y if b[0] == 0 else 0
for i in range(1, len(b)):
if b[i] == 0:
dp[i] = dp[i - 1] + y
if i >= 2:
dp[i] = min(dp[i], x + dp[i... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER AS... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
count = 0
if s[0] == "1":
tp = -1
else:
tp = 0
count = 1
for i in range(1, n):
if s[i] == "0":
if tp == -1:
tp = 0
count += 1
elif tp == 0:
tp = -1
if x >= y:
print(count * y)
elif count >= 2:
print((coun... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
a = ["1"] + list(input())
c = 0
for i in range(n):
if a[i : i + 2] == ["1", "0"]:
c += 1
print(max(c - 1, 0) * min(x, y) + (y if c >= 1 else 0)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER LIST STRING STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR VAR VAR ... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
c = len([_ for _ in s.split("1") if _])
ans = 1e19
if not c:
ans = 0
for i in range(c):
ans = min(ans, i * x + (c - i) * y)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = list(map(int, input().split()))
a = input()
a = a + "1"
cnt = 0
for i in range(n):
if a[i] == "0" and a[i + 1] == "1":
cnt += 1
if cnt == 0:
print(0)
exit()
print(min(y * cnt, y + (cnt - 1) * x)) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL V... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
A = input()
cnt = 0
k = A.find("0")
while k < n and k != -1:
while A[k] != "1":
k += 1
if k >= n:
break
cnt += 1
k = A.find("0", k)
if cnt == 0:
print(0)
else:
print((cnt - 1) * min(x, y) + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR VAR VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
u = list(map(int, input()))
d0 = 0
k0 = 0
for i in range(n):
if k0 == 1 and u[i] == 1:
d0 += 1
k0 = 0
elif u[i] == 0:
k0 = 1
if k0 == 1:
d0 += 1
if d0 == 0:
p = 0
else:
p = (d0 - 1) * min(x, y) + y
print(p) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN ... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
k = 0
if s[0] == "0":
for i in range(n - 1):
if s[i] + s[i + 1] == "01":
k += 1
if s[-1] == "0":
k += 1
else:
for i in range(n - 1):
if s[i] + s[i + 1] == "10":
k += 1
if k == 0:
print(0)
else:
print(min(... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
a = input()
a = a.strip("1")
n = len(a)
c = 0
i = 0
while i < n:
try:
i1 = a.index("1", i)
if x < y:
try:
i = a.index("0", i1)
except:
i = n
c += x
else:
i = a.index("0", i1)
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_C... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
c = input()
f = 0
t = 0
for i in range(n):
if c[i] == "0":
if not f:
t += 1
f = 1
else:
f = 0
if not t:
print(0)
else:
print(y + (t - 1) * min(x, y)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VA... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = input().split()
n = int(n)
x = int(x)
y = int(y)
s = input()
count = 0
is_zero = s[0] == "0"
if is_zero:
count += 1
for i in range(1, n):
if s[i] == "0" and not is_zero:
is_zero = True
count += 1
elif s[i] == "1" and is_zero:
is_zero = False
if y <= x or count == 0:
pri... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER STRING IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR STRIN... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
seq = input()
segments = 0
flag = False
for i in seq:
if i == "0":
if flag:
continue
else:
flag = True
elif flag:
segments += 1
flag = False
else:
continue
if flag:
segments += 1
flag = False
cost = s... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_O... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def readline():
return map(int, input().split())
def main():
n, x, y = readline()
line = input()
one = line.count("10")
zero = line.count("01")
assert abs(one - zero) < 2
if one != zero:
segments_of_zeros = max(one, zero)
else:
segments_of_zeros = one + (line[0] == "0")... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING EXPR FUNC_C... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | import time
n, x, y = (int(i) for i in input().split())
a = input()
start = time.time()
I = 0
while a[I] == "1":
I += 1
if I == n:
break
flag = 1
N = 0
for i in range(I, n):
if flag == 0:
if a[i] == "1":
flag = 1
elif a[i] == "0":
flag = 0
N += 1
if N == 0:
... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING ASS... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def f(reverse_cost, inverse_cost, bit_string):
prev_value = True
zero_section_count = 0
for v in bit_string:
cur_value = bool(v == "1")
if prev_value != cur_value:
if not cur_value:
zero_section_count += 1
prev_value = cur_value
if zero_section_cou... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING IF VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FU... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = input().strip().split()
n, x, y = int(n), int(x), int(y)
s = input().strip()
if n == 1 and s == "0":
print(y)
elif n == 1 and s == "1":
print(0)
else:
l = [s[0]]
for i in s[1:]:
if i != l[-1]:
l.append(i)
t = l.count("0")
if t == 0:
print(0)
else:
... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR NUM... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | l = [int(x) for x in input().split()]
n = input()
x = 0
y = 0
if len(set(n)) == 1:
if n[0] == "1":
print(0)
else:
print(l[2])
else:
for i in range(0, len(n)):
if i == 0:
if n[0] == "0":
x += 1
y += 1
continue
if n[i]... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER STRING V... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = list(map(int, input().split(" ")))
s = list(map(int, list(input())))
t = []
last0 = False
isfirst = True
for i in s:
if i == 0:
if isfirst:
t.append(i)
isfirst = False
last0 = True
elif last0:
continue
else:
last0 = True
... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBE... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def numberofgroupsofzeroes(s):
count = 0
if s[len(s) - 1] == "0":
count = 1
for i in range(0, len(s) - 1):
if s[i] == "0" and s[i + 1] == "1":
count += 1
return count
def minimum(num1, num2):
if num1 <= num2:
return num1
else:
return num2
n, x, y =... | FUNC_DEF ASSIGN VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_C... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = (int(x) for x in input().split())
s = input()
k = s.count("01")
if s.endswith("0"):
k += 1
if k == 0:
print(0)
elif y < x:
print(y * k)
else:
print(x * (k - 1) + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
c = 0
for i in range(1, n):
if s[i] == "1" and s[i - 1] == "0":
c += 1
if s[-1] == "0":
c += 1
if c == 0:
print(0)
elif x >= y:
print(c * y)
else:
print((c - 1) * x + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUN... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
chains = 0
zero = False
for i in range(n):
if not zero and s[i] == "0":
zero = True
elif not zero and s[i] == "1":
continue
elif zero and s[i] == "0":
continue
elif zero and s[i] == "1":
chains += 1
zero = False
if z... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR VAR STRING IF VAR VAR VAR STRING IF VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER EXPR ... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | from itertools import groupby
noc, x, y = [int(x) for x in input().split()]
s = input()
sg = groupby(s)
sg = [(k, list(g)) for k, g in sg if set(list(g)) == {"0"}]
lsg = len(sg)
ans = (len(sg) - 1) * min(x, y) + y
print(0 if lsg == 0 else ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR EXPR ... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
io = "1"
c = 0
for i in input():
if i == "0":
c += int(io != i)
io = i
if c > 0:
print(min(y * c, y + x * (c - 1)))
else:
print(0) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR STRING VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = list(map(int, input().split()))
a = input()
k = 0
for i in range(n):
if i == 0 or a[i] != a[i - 1]:
if a[i] == "0":
k += 1
if k == 0:
print(0)
else:
print(min([(x * r + (k - r) * y) for r in range(k)])) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP B... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | header = input()
header = [int(i) for i in header.split()]
n = header[0]
revCost = header[1]
opCost = header[2]
numsData = input()
clusters = 0
i = 0
complete = False
while numsData[i] == "1":
i += 1
if i >= len(numsData):
complete = True
break
if not complete:
while True:
while nums... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR WHILE NUMBER WHILE VA... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | N, x, y = input().split()
x = int(x)
y = int(y)
array = input()
the_list = array.split("1")
length = len(the_list)
for k in the_list:
if k == "":
length -= 1
if length == 0:
print(0)
elif x < y:
print((length - 1) * x + y)
else:
print(length * y) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR N... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = (int(s) for s in input().split())
str_ = input()
if str_[0] == "0":
number_of_zero_sequence = 1
else:
number_of_zero_sequence = 0
for i in range(1, n):
if str_[i] == "0" and str_[i - 1] != "0":
number_of_zero_sequence += 1
ans = 0
if x > y:
ans = number_of_zero_sequence * y
elif number... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BI... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def countIt(a):
assert a
count = 1
start = ord(a[0]) - ord("0")
delim = 1 - start
for ch in a:
if ord(ch) - ord("0") == delim:
count += 1
delim = 1 - delim
return count, start
def calcIt(f_count, start, x, y):
if f_count == 1:
return y if start == 0 ... | FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def solve(s, x, y):
z = False
c = 0
for i in range(len(s)):
if s[i] == "0" and not z:
z = True
c += 1
elif s[i] != "0" and z:
z = False
min_cost = float("inf")
for i in range(c):
min_cost = min(min_cost, i * x + (c - i) * y)
return 0 if... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR RETURN VA... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
pr = "2"
s2 = ""
nol = 0
ed = 0
for i in range(n):
if s[i] != pr:
pr = s[i]
s2 += s[i]
if int(s[i]) == 0:
nol += 1
else:
ed += 1
if y <= x or nol == 0:
print(nol * y)
else:
print(y + max(0, nol - 1) * x) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().strip().split())
count = 0
r = input()
if r[0] == "0":
count = count + 1
for i in range(1, n):
if r[i] == "0" and r[i - 1] != "0":
count = count + 1
if count == 0:
print(0)
exit(0)
elif y < x:
print(y * count)
else:
print(x * (count - 1) + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FU... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | import sys
bla, wort, *_ = sys.stdin.read().split("\n")
n, x, y = [int(z) for z in bla.split(" ")]
anz = wort[0] == "0"
for a, b in zip(wort[:-1], wort[1:]):
if b == "0" and a != "0":
anz += 1
if anz == 0:
print(0)
else:
print(y + min(x, y) * (anz - 1)) | IMPORT ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER STRING FOR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR STRING VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL V... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = input().split()
n = int(n)
x = int(x)
y = int(y)
s = input()
s += "@"
zero = 0
one = 0
for i in range(n):
if s[i] == "1" and (s[i + 1] == "0" or s[i + 1] == "@"):
one += 1
if s[i] == "0" and (s[i + 1] == "1" or s[i + 1] == "@"):
zero += 1
if zero == 0:
print(0)
else:
print((zer... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VA... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
a = "1" + input()
c = 0
for i in range(1, n + 1):
if a[i] == "0" and a[i - 1] == "1":
c += 1
print(min(c * y, max(0, y + (c - 1) * x))) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = input().split()
n = int(n)
x = int(x)
y = int(y)
ch = input()
cnt = 0
if ch[0] == "0":
cnt += 1
for i in range(1, len(ch)):
if ch[i] == "0" and ch[i - 1] == "1":
cnt += 1
ans = 0
if cnt > 0:
ans = y
cnt -= 1
if x < y:
ans += x * cnt
else:
ans += y * cnt
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def readline():
return map(int, input().split())
def main():
n, x, y = readline()
line = input()
zero_segments = line.count("10") + line.startswith("0")
print((zero_segments - 1) * min(x, y) + y if zero_segments else 0)
main() | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
lst = -1
cnt = 0
for i in s:
if i == "1":
if lst == 0:
cnt += 1
lst = -1
else:
lst = 0
if s[n - 1] == "0":
cnt += 1
if cnt == 0:
exit(print(0))
ans = 0
if x >= y:
ans = y * cnt
else:
ans = (cnt - 1) * x + y
p... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUM... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | from sys import stdin, stdout
def main():
n, x, y = [int(i) for i in stdin.readline().split()]
a = stdin.readline()
prev = "1"
count = 0
for i in range(n):
if a[i] == "0" and prev == "1":
count += 1
prev = a[i]
if count == 0:
print(0)
else:
print... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER FUNC_... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = list(map(int, list(input())))
if s[0] == 0:
se = 1
else:
se = 0
r = s[0]
for i in range(1, n):
if s[i] == int(not r) and r == 1:
se += 1
r = 0
elif s[i] == int(not r):
r = 1
k = se * y
for i in range(1, se):
k = min(k, (se - i) * y + i ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR ... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = [int(i) for i in input().split()]
v = 1
s = list(input())
cnt = 0
for digit in s:
if digit == "0" and v == 1:
cnt += 1
v = 0
if digit == "1":
v = 1
if cnt == 0:
print(0)
exit(0)
ans = min(cnt * y, (cnt - 1) * x + y)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | a = list(map(int, input().split()))
n = a[0]
x = a[1]
y = a[2]
s = input()
c = 0
f = 0
p = s[0]
b = s[0]
if s[0] == "0":
f = 1
for i in range(1, n):
if s[i] != p:
c += 1
p = s[i]
if f == 0:
if s[i] == "0":
f = 1
e = p
ans1 = c // 2 * x
if f == 1:
ans1 += y
if b == e a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, cost_rev, cost_inv = [int(i) for i in input().split()]
a = input()
lst = []
for i in range(len(a)):
lst.append(int(a[i]))
count = 0
flag = False
for i in range(len(a)):
if lst[i] == 0 and flag == False:
count += 1
flag = True
if lst[i] == 1:
flag = False
if count > 0:
cost = m... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | import sys
n, x, y = map(int, input().split())
s = input()
if s.count("1") == n:
print(0)
sys.exit()
if x > y:
started = False
sep = 0
for c in s:
if c == "0" and started:
continue
if c == "0" and not started:
sep += 1
started = True
if c ... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR IF VAR STRING VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBE... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def problem():
in1 = input()
in2 = input()
inp1 = list(map(int, in1.split()))
n = inp1[0]
exc_cost = inp1[1]
flip_cost = inp1[2]
s = in2
zeros = 0
sign = s[0]
for num in s[1:]:
if num != sign:
if sign == "0":
zeros += 1
sign = num
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR STRING... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
sl = []
for i in s:
sl += [int(i)]
sl.append(1)
count = 0
for i in range(n):
if sl[i] == 0 and sl[i + 1] == 1:
count += 1
if count != 0:
print(y + min(x, y) * (count - 1))
else:
print("0") | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR VAR LIST FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP ... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
if "0" not in s:
print(0)
elif "1" not in s:
print(y)
else:
zero_start = s[0] == "0"
zero_end = s[-1] == "0"
ones_groups = 0
i = 0
while i < n:
found = False
while i < n and s[i] == "1":
found = True
i +=... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER STRING ASSIGN VAR VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING AS... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, a, b = map(int, input().split())
l = list(map(int, input()))
f = True
ans = 0
for t in l:
if t == 0 and f:
ans += 1
f = False
if t == 1:
f = True
if ans == 0:
print(0)
elif b <= a:
print(ans * b)
else:
print((ans - 1) * a + b) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_O... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = [int(x) for x in input().split()]
s = input()
c = 0
for i in range(0, len(s) - 1):
if s[i] == "0" and s[i + 1] == "1":
c += 1
if s[len(s) - 1] == "0":
c += 1
if c == 0:
print(0)
else:
print((c - 1) * min(x, y) + y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUM... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
a = input()
if n == 1 and a[0] == "0":
print(y)
elif n == 1:
print("0")
else:
mx = 0
for i in range(n - 1):
if (
a[i] == "0"
and a[i + 1] == "1"
or i == n - 2
and (a[i] == "0" or a[i + 1] == "0")
):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER VAR VAR STRI... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def main():
n, x, y = list(map(int, input().split()))
a = input()
islands = a[0] == "0"
for i in range(1, n):
if a[i] == "0":
islands += a[i - 1] == "1"
if islands == 0:
print(0)
return 0
if x >= y:
print(y * islands)
else:
print(x * (islan... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
s = input()
c = s.count("10")
if s[0] == "0":
c += 1
ans = 10**18
if c == 0:
print(0)
else:
for i in range(c):
ans = min(ans, x * i + y * (c - i))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | n, x, y = map(int, input().split())
a = input()
k = 0
i = 0
if a[i] == "0":
k += 1
while i < n and a[i] == "0":
i += 1
for j in range(i, n - 1):
if a[j] == "1" and a[j + 1] == "0":
k += 1
if k == 0:
print(0)
elif x < y:
print((k - 1) * x + y)
else:
print(k * y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CAL... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | [n, x, y] = [int(x) for x in input().split()]
A = input()
if len(A) == 1:
if A[0] == "1":
print("0")
else:
print(y)
else:
c = 0
if A[0] == "0":
c = 1
for i in range(1, len(A)):
if A[i] == "0" and A[i - 1] == "1":
c += 1
m = y * c
for i in range(1, ... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR B... |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | def segments(s, x, y):
count = s.count("10") + s.startswith("0")
if count:
return (count - 1) * min(x, y) + y
return 0
n, X, Y = [int(i) for i in input().split()]
t = input()
print(segments(t, X, Y)) | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR |
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.
You can apply the following operations any number of times:
* Choose some substring of string a (for example, you can choose entire strin... | inp = input().split()
n = int(inp[0])
x = int(inp[1])
y = int(inp[2])
a = input().split("1")
zeros = 0
for z in a:
if len(z) > 0:
zeros += 1
print(max(0, min(zeros * y, y + (zeros - 1) * x))) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR V... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
s = "!" + s + "!"
cnt = 0
if n > 1:
for char in range(ord("z"), ord("a") - 1, -1):
i = 0
while len(s) > 0 and i < len(s):
if i == 0:
if s[i] == chr(char) and s[i] == chr(ord(s[i + 1]) + 1):
s = s[:i] + s[i + 1 :]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
L = list(input())
ans = 0
for i in range(25):
target = chr(ord("z") - i)
rm = chr(ord("z") - i - 1)
update = True
while update:
update = False
j = 0
while j < len(L):
if L[j] == target:
v = []
if j > 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHI... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | import sys
input = sys.stdin.readline
n = int(input())
a = input()
A = [100]
for i in a:
A.append(ord(i) - 97)
A.append(100)
B = [i for i in range(26, -1, -1)]
for i in B:
j = 1
while j < len(A) - 1:
if A[j] == i:
if A[j] == A[j - 1] + 1 or A[j] == A[j + 1] + 1:
A.pop(j)... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUM... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
st = input()
k = 0
while True:
mx1 = -1
ar = 96
for i in range(len(st)):
if i + 1 < len(st):
if ord(st[i]) + 1 == ord(st[i + 1]) or ord(st[i]) - 1 == ord(st[i + 1]):
if ar <= ord(st[i]):
mx1 = i
ar = ord(st[i])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | alphabet = "abcdefghijklmnopqrstuvwxyz"
pos = {alphabet[i]: i for i in range(26)}
def compute(s, n):
if len(s) <= 1:
return 0
char = alphabet[n]
word = []
ans = 0
for i in range(len(s)):
if s[i][0] == char:
if (
i != 0
and pos[s[i - 1][0]... | ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER NUMBER VAR BIN_... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = str(input())
s = list("$" + s + "$")
char = []
for i in s:
char.append(ord(i))
removable = []
z = len(char)
for i in range(1, n + 1):
if char[i] == char[i - 1] + 1 or char[i] == char[i + 1] + 1:
removable.append((char[i], i))
while len(removable) > 0:
removable.sort()
char.p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR BIN_OP... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def f(s):
if len(s) == 1 or len(s) == 0:
return -1
z = -1
for i in range(len(s)):
if i == 0:
if ord(s[1]) - ord(s[0]) == -1:
if z == -1:
z = i
elif s[i] > s[z]:
z = i
elif i == len(s) - 1:
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input().strip()
ans = 0
for i in range(26):
c = chr(122 - i)
f = True
while f:
f = False
n = len(s)
for i in range(n):
if s[i] == c:
if (
i > 0
and ord(s[i]) - ord(s[i - 1]) == 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR NUMBER BIN_OP FUNC_CALL VAR VAR V... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | ol = int(input())
s = [(ord(x) - ord("a")) for x in input()]
t = sorted(s, reverse=True)
for i in t:
l = len(s)
if l == 1:
break
for j in range(l):
if s[j] == i:
if j == 0:
if abs(s[1] - i) == 1:
s.pop(j)
break
e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = str(input())
al = "abcdefghijklmnopqrstuvwxyz"
ans = 0
def p(a, j):
global s, n
if s[0] == a and s[1] == al[j - 1]:
s = s[1:]
n -= 1
return True
if s[n - 1] == a and s[n - 2] == al[j - 1]:
s = s[: n - 1]
n -= 1
return True
for i in r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def main():
for _ in range(1):
n = int(input())
s = tuple(ord(c) - 97 for c in input())
ans = 0
while True:
b = True
mx_ = -1
mx_i = -1
for i in range(n):
if i > 0 and s[i] - s[i - 1] == 1:
b = False
... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | from sys import stdin
input = stdin.buffer.readline
n, s = int(input()), [(_ - ord("a")) for _ in input().rstrip()]
for v in range(25, 0, -1):
u = v - 1
for x in [_ for _, w in enumerate(s) if w == u]:
for _ in range(x + 1, len(s)):
if s[_] != v:
break
s[_] = -1
... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = list(input())
d = {}
alp = "abcdefghijklmnopqrstuvwxyz"
c = 0
for i in range(26):
d[alp[i]] = i
l = []
mi = d[s[0]]
for i in range(n):
l.append(d[s[i]])
if l[i] < mi:
mi = l[i]
idx = 25
while idx != 0:
if len(l) == 1:
break
else:
while True:
c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIG... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
for _ in range(len(s)):
mx = 0
ind = -1
for i in range(len(s)):
a = -1
b = -1
if i > 0:
if ord(s[i - 1]) == ord(s[i]) - 1:
a = i
if i + 1 < len(s):
if ord(s[i + 1]) == ord(s[i]) - 1:
b = i
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
res = 0
for _ in range(n):
max_char, max_index = "A", -1
for i in range(len(s)):
is_ok = False
if i > 0 and ord(s[i]) == ord(s[i - 1]) + 1:
is_ok = True
if i < len(s) - 1 and ord(s[i]) == ord(s[i + 1]) + 1:
is_ok = True
if is_o... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP FUNC_CA... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = [ord(i) for i in input()]
for mx in range(122, 96, -1):
i = 0
while i < len(s):
flag = 1
if s[i] == mx:
if i < len(s) - 1:
if s[i + 1] == s[i] - 1:
j = i
while s[j] == mx:
del s[j]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR V... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def calc(i):
if i != 0 and ord(s[i - 1]) == ord(s[i]) - 1:
return True
if i != len(s) - 1 and ord(s[i + 1]) == ord(s[i]) - 1:
return True
return False
n = int(input())
s = list(input())
ans = 0
for i in range(122, 96, -1):
j = 0
while j < len(s):
if ord(s[j]) == i and calc(... | FUNC_DEF IF VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CAL... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = [100] + [(ord(i) - 97) for i in input()] + [100]
alp = [i for i in range(26, -1, -1)]
for i in alp:
j = 1
while j < len(a) - 1:
if a[j] == i:
if a[j] == a[j - 1] + 1 or a[j] == a[j + 1] + 1:
a.pop(... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR LIST NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | from sys import stdin
input = stdin.readline
n = int(input())
s = list(input().strip())
for i in range(26):
char = chr(ord("z") - i)
prev = chr(ord("z") - i - 1)
updated = True
while updated:
updated = False
for idx in range(len(s) - 1, -1, -1):
if s[idx] == char:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER FOR VAR FUNC_C... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
s = [(ord(x) - ord("a")) for x in s]
cur_size = n
for i in range(1, 26)[::-1]:
j = cur_size - 1
while j >= 0:
if s[j] != i:
j -= 1
continue
if j - 1 >= 0 and s[j - 1] == i - 1 or j + 1 < len(s) and s[j + 1] == i - 1:
s = s[:j] + s[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n, v = int(input()), 0
s = input()
for _ in range(100):
max_b, max_i = -1, -1
for i in range(1, n - 1):
a, b, c = ord(s[i - 1]), ord(s[i]), ord(s[i + 1])
if (b == a + 1 or b == c + 1) and b > max_b:
max_b, max_i = b, i
if n < 2:
break
b, a = ord(s[0]), ord(s[1])
i... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VA... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
actual = n
s = input()
for i in range(100):
n = len(s)
ind = -1
big = 0
for i in range(n):
L = 0
R = 0
curr = ord(s[i])
if i - 1 >= 0:
L = ord(s[i - 1])
if i + 1 < n:
R = ord(s[i + 1])
if curr == L + 1 or curr == R ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def solve(N, S):
for c in sorted(set(S), key=ord, reverse=True):
temp = []
val = ord(c)
for x in S:
if ord(x) == val:
if temp and ord(temp[-1]) == val - 1:
continue
if ord(x) == val - 1:
while temp and ord(temp[-1]) ... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN V... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def solve(n, s):
alphabet = "zyxwvutsrqponmlkjihgfedcba"
for i, c in enumerate(alphabet):
if c == "a":
continue
nxt = alphabet[i + 1]
cnt = s.count(c)
for _ in range(cnt):
for j, v in enumerate(s):
if c != v or len(s) == 1:
... | FUNC_DEF ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR V... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
ans = 0
done = True
while done:
done = False
ind = -1
char = 0
for i in range(len(s)):
if i - 1 >= 0 and ord(s[i]) - ord(s[i - 1]) == 1:
done = True
if ord(s[i]) > char:
char = ord(s[i])
ind = i
if i + 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBE... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
u = ord("a")
for i in range(n):
a = 0
m = 0
for j in range(len(s)):
if j == 0:
if j + 1 < len(s) and ord(s[j]) == ord(s[j + 1]) + 1:
if ord(s[j]) > m:
m = ord(s[j])
a = j
elif j == len(s) - 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMB... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = input()
string = input()
lastString = string
go = True
removed = 0
def removeChar(s):
index = 0
found = False
for i in range(len(s)):
if (ord(s[i]) > ord(s[index]) or found == False) and (
i > 0
and ord(s[i]) - ord(s[i - 1]) == 1
or i < len(s) - 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
alf = "abcdefghijklmnopqrstuvwxyz"
nums = [[] for i in range(26)]
for i in range(n):
num = alf.index(s[i])
nums[num].append(i)
res = 0
e_n_r = {}
e_n_l = {}
que = []
used = [0] * n
def f(k):
global res, que, e_n_r, e_n_l, used, nums, alf, s, n
i = alf.index(s[k])
if us... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF AS... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
ans = 0
maxs = max(s)
now = 0
while ord(maxs) > ord("a"):
pos = s.find(maxs, now)
if pos != -1:
if (
pos - 1 >= 0
and ord(s[pos - 1]) == ord(maxs) - 1
or pos + 1 < len(s)
and ord(s[pos + 1]) == ord(maxs) - 1
):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER BIN... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
string = input()
arr = list(string)
count = 0
if n == 1:
print("0")
else:
for i in range(122, 97, -1):
lis = []
counter = 0
j = 0
while j < len(arr):
if len(arr) == 1:
break
if ord(arr[j]) == i:
if j == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR V... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | import sys
input = sys.stdin.readline
n = int(input())
s = [*map(ord, input().rstrip())]
v = [(x, i) for i, x in enumerate(s)]
v.sort()
ans = 0
i = n - 1
while i >= 0:
u, id = v[i]
if 1 <= id and s[id - 1] == u - 1 or id + 1 < len(s) and s[id + 1] == u - 1:
s.pop(id)
v = sorted((x, i) for i, x ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR VAR IF NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUM... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | from sys import gettrace, stdin
if not gettrace():
def input():
return next(stdin)[:-1]
def main():
_ = input()
ss = [(ord(s) - ord("a")) for s in input()]
res = 0
for c in range(26, -1, -1):
found = True
while c in ss and found:
found = False
i = ... | IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL ... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def pc(c):
return chr(ord(c) - 1)
strlen = int(input())
string = input()
removalcount = 0
azindex = {chr(96 + 26 - n): [] for n in range(26)}
for n, c in enumerate(string):
azindex[c].append(n)
change = True
while change:
change = False
for letter, indices in azindex.items():
if len(indices) =... | FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSI... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
for i in range(121, 96, -1):
s1 = True
while s1:
s1 = False
if len(s) == 1:
break
for j in range(len(s)):
if j == 0:
if s[j] == chr(i) and s[j + 1] == chr(i + 1):
s = s[: j + 1] + s[j + 2 :]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER AS... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | n = int(input())
s = input()
s = list(s)
for i in range(97 + 26, 97, -1):
c = chr(i)
k = []
for j in range(len(s)):
if j - 1 >= 0 and s[j - 1] == chr(i - 1) and s[j] == c:
k.append(j)
l = j + 1
while l < len(s) and s[l] == s[j]:
k.append(l)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | def MaxActions(strin):
if strin:
cleard = 0
peak = max(strin)
start = strin.find(peak)
while start != -1:
group = 0
remember = False
end = start
while end < len(strin) and strin[end] == peak:
end += 1
if (
... | FUNC_DEF IF VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_O... |
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the La... | t = int(input())
s = input()
ans = ""
count = 0
while True:
flag = True
j = -1
ch = 0
for i in range(len(s)):
if (
i != 0
and ord(s[i - 1]) - ord(s[i]) == -1
or i != len(s) - 1
and ord(s[i + 1]) - ord(s[i]) == -1
):
if j == -1 o... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.