description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
a = [char for char in input()]
pointer_esquerda = 0
pointer_direita = 0
mov = k
len_maior = 0
len_atual = 0
while pointer_esquerda <= n - 1:
while mov >= 0 and pointer_direita <= n - 1:
if a[pointer_direita] == "b" and mov - 1 >= 0:
mov -= 1
pointer_d... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR STRING BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = [int(i) for i in input().split()]
s = input()
def beauty(x):
ret = 0
cnt = 0
r = 0
for l in range(n):
while r < n and (cnt < k or s[r] != x):
if s[r] == x:
cnt += 1
r += 1
if s[l] == x:
cnt -= 1
ret = max(ret, r - l)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | MOD = 1000000007
MOD2 = 998244353
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
n, k = f()
s = si()
k1, k2 = k, k
mx = 0
i, j = 0, 0
while j < n:
while j < n:
... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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 FUNC_CALL VAR ASSI... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
def solve(x, y):
res, j, t = 0, 0, k
for i in range(n):
if j < i:
j = i
t = k
while j < n and (s[j] == x or s[j] == y and t > 0):
t -= int(s[j] == y)
j += 1
res = max(res, j - i)
t += i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def answer(n, k, A):
if n == 1:
return 1
dp = [0] * (n + 1)
for i in range(1, n + 1):
if A[i - 1] == "a":
dp[i] = dp[i - 1] + 1
else:
dp[i] = dp[i - 1]
l = 0
r = 0
maxi = 0
while r >= l and r < n:
x = dp[r + 1] - dp[l]
if min(x,... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
d = {"a": 0, "b": 0}
l = 0
a = 0
for i in s:
d[i] += 1
if min(d.values()) > k:
d[s[l]] -= 1
l += 1
else:
a += 1
print(a) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | from sys import *
inp = lambda: stdin.readline()
def solve(x, s, n, k):
ans, r, bal = 0, 0, 0
for l in range(n):
while r < n and (s[r] == x or bal < k):
if s[r] != x:
bal += 1
r += 1
ans = max(ans, r - l)
if s[l] != x:
bal -= 1
r... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR AS... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | from sys import stdin, stdout
def fn(a, ch):
ans = 0
for i in range(n):
l, r = i, n - 1
while l <= r:
mid = l + r >> 1
req = a[i] + k - int(s[i] != ch)
if a[mid] <= req:
l = mid + 1
else:
r = mid - 1
ans = ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | __author__ = "Utena"
n, k = map(int, input().split())
s = ["0"] + list(input())
beauty = 0
i = 0
j = 0
a = 0
b = 0
while i < n:
i += 1
if s[i] == "a":
a += 1
if s[i] == "b":
b += 1
while min(a, b) > k:
j += 1
if s[j] == "a":
a -= 1
if s[j] == "b":
... | ASSIGN VAR STRING ASSIGN 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER WHILE FUNC_CAL... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
res = 1
i = -1
j = 0
cur = 0
while i < j <= n:
if j == n and i == n - 1:
break
while cur <= k and j < n:
if cur == k and s[j] == "b":
break
else:
cur += s[j] == "b"
j += 1
res = max(res, j - i - 1)
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR STRING VAR VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP B... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | num = input()
n, k = num.split()
n = int(n)
k = int(k)
string = input()
count_a = 0
count_b = 0
def check(ch):
i = 0
j = 0
count = 0
answer = 0
for i in range(n):
if string[i] == ch:
count += 1
if count > k:
while count > k:
if string[j] == c... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR WHI... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = input().split(" ")
n = int(n)
k = int(k)
s = input()
def stack(s, more, less, k):
flag = True
count = k
pos = []
maxsize = -1
decrement = 0
for index, ch in enumerate(s):
if ch == less:
if count > 0:
count -= 1
pos.append(index)
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def bigsub(s, n, k, x):
j = 0
i = 0
tmp = 0
ans = 0
ck = 0
while j < n and i < n:
if s[j] != x:
tmp += 1
j += 1
if tmp > ans:
ans = tmp
else:
ck += 1
if ck <= k:
j += 1
tmp... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUM... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | import sys
inf = float("inf")
mod = 1000000007
def get_array():
return list(map(int, sys.stdin.readline().split()))
def get_ints():
return map(int, sys.stdin.readline().split())
def input():
return sys.stdin.readline()
def solve(c, s, k):
global ans
r = 0
balance = 0
for i in range(... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CAL... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | import sys
__author__ = "goran"
n, k = map(int, sys.stdin.readline().split())
s = input()
L, R = 0, 0
cnt = [0, 0]
best = 1
while R < n:
if (
min(cnt[ord(s[R][0]) - ord("a"[0])] + 1, cnt[1 - ord(s[R][0]) + ord("a"[0])])
> k
):
cnt[ord(s[L][0]) - ord("a"[0])] -= 1
L += 1
else... | IMPORT ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR STRING NUMBER NUMBER VAR BIN_OP BIN_OP NUMBE... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def count(a, n, s, k):
j = 0
kk = 0
ans = 0
for i in range(n):
if a[i] == s:
kk += 1
while kk > k:
if a[j] == s:
kk = kk - 1
j += 1
ans = max(ans, i - j + 1)
return ans
n, k = [int(i) for i in input().split()]
a = list(inp... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
counta, countb = 0, 0
s = input()
l, r = 0, 0
maxlength = 0
while r < n:
if s[r] == "a":
counta += 1
else:
countb += 1
if counta <= k or countb <= k:
maxlength = max(maxlength, r - l + 1)
else:
if s[l] == "a":
counta -= 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
left, right = 0, 1
a = []
b = []
t1, t2 = 0, 0
for i in s:
if i == "a":
t1 += 1
else:
t2 += 1
a.append(t1)
b.append(t2)
temp1 = 0
temp2 = 0
ans = 0
for i in s:
if i == "a":
temp2 = 0
temp1 += 1
ans = max(ans, temp1)... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def solve(i, j):
alpha = {"a": 0, "b": 0}
alpha[string[i]] += 1
alpha[string[j]] += 1
m = 0
while i < j < len(string):
a = alpha["a"]
b = alpha["b"]
if a <= k or b <= k:
m = max(m, j - i + 1)
if a > k and b > k:
alpha[string[i]] -= 1
... | FUNC_DEF ASSIGN VAR DICT STRING STRING NUMBER NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBE... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
a = input()
ac = 0
bc = 0
ans = -1
s = 0
e = 0
if k == 0:
while e < n:
ac = 0
if a[e] == "a":
while e < n and a[e] == "a":
ac += 1
e += 1
else:
while e < n and a[e] == "b":
ac += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = [*input()]
a, b = [0], [0]
for i in s:
if i == "a":
a.append(a[-1] + 1)
b.append(b[-1])
else:
a.append(a[-1])
b.append(b[-1] + 1)
def check(m):
for i in range(m, n + 1):
if a[i] - a[i - m] <= k:
return True
if... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER LIST NUMBER FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF FOR VAR FUN... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = list(input())
a, b = [], []
for i in range(n):
if s[i] == "a":
a.append(i)
else:
b.append(i)
a = [-1] + a + [n]
b = [-1] + b + [n]
res = 0
if len(a) <= k + 2 or len(b) <= k + 2:
print(n)
else:
for i in range(1, len(a) - k):
res = max(res, a[i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST 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 BIN_OP LIST NUMBER VAR LIST VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR LIST VAR ASSIGN VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def get_best(s, n, k, c):
l = 0
r = 0
curr_k = k
best = 0
while l < n and r < n:
if s[r] == c:
r += 1
elif curr_k > 0:
curr_k -= 1
r += 1
else:
if s[l] != c:
curr_k += 1
l += 1
best = max(best... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | a, b = map(int, input().split())
d = input()
e = 1
f = a + 1
a1 = [0]
a2 = [0]
for i in range(a):
if d[i] == "a":
a1.append(a1[-1] + 1)
a2.append(a2[-1])
else:
a2.append(a2[-1] + 1)
a1.append(a1[-1])
def s1(i, j):
return a1[j + 1] - a1[i]
def s2(i, j):
return a2[j + 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def max_substring(s, ch, n, k):
i, j = 0, 0
cnt = 0
best = 0
while j < n:
if s[j] == ch:
cnt += 1
if cnt > k:
tmp = j - i
if tmp > best:
best = tmp
while i < j and s[i] != ch:
i += 1
i += 1
... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR VAR VAR NU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = list(input())
dp = [[(0) for i in range(2)] for i in range(n + 1)]
aNum = 0
bNum = 0
a = []
b = []
for i in range(n):
if s[i] == "a":
aNum += 1
a.append(i)
if aNum <= k:
dp[i + 1][1] = i + 1
else:
dp[i + 1][1] = a[aNum - 1]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def solve(middle, s, k):
aa = 0
bb = 0
f = 0
for i in range(0, middle):
if s[i] == "a":
aa += 1
else:
bb += 1
if min(aa, bb) <= k:
f = 1
for i in range(0, len(s) - middle):
if s[i] == "a":
aa -= 1
else:
bb -=... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR VAR STRING VAR NUMBER... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def solve(n, k, l):
ki = i = s = 0
po = 1
for j in range(n):
s += l[j] == 0
while s > k:
s -= l[i] == 0
i += 1
if j - i > ki - po:
po, ki = i, j
return ki - po + 1
n, k = map(int, input().split())
s = input()
a1, a2 = [], []
for i in range(n)... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSI... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | l1 = input().split()
l2 = list(input())
l1 = [int(i) for i in l1]
x = l1[0]
y = l1[1]
j = 0
c = 0
r = 0
for i in range(x):
if l2[i] == "a":
c += 1
if c > y:
while c > y:
if l2[j] == "a":
c -= 1
j += 1
r = max(r, i - j + 1)
lul = r
j = 0
c = 0
r = 0
for... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR WHILE VAR VAR IF VAR VAR STRING VAR NUMBER VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split(" "))
s = input()
res = 0
i = 0
j = 0
h = 0
for l in s:
i += 1
if l != "a":
if h < k:
h += 1
else:
for u in range(j, i):
if s[u] == "b":
j = u + 1
break
else:
... | ASSIGN 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 NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR STRING IF VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def maxim(s, ch, k):
res = 0
maxi = 0
c = 0
start = 0
kc = 0
for i in range(0, len(s)):
if s[i] == ch:
c += 1
else:
kc += 1
c += 1
maxi = max(maxi, i - start) if kc > k else max(maxi, i - start + 1)
while kc > k:
if ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF VAR VAR VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def count():
global ca, cb
if s[r] == "a":
ca += 1
else:
cb += 1
n, k = map(int, input().split())
s = input()
l = 0
r = 0
sm = 0
mx = 0
ca = 0
cb = 0
count()
while l < n:
while min(ca, cb) <= k:
sm += 1
r += 1
if r == n:
break
count()
if ... | FUNC_DEF IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR WHILE VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR N... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def solve(letter):
i = 0
j = 0
k1 = 0
while j < n and k1 <= k:
if s[j] != letter:
k1 += 1
if k1 <= k:
j += 1
best = j - i
while i < n and j < n:
if s[i] != letter:
i += 1
if i < n:
j = max(i, j)
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, m = map(int, input().split())
s = input()
ans, a, b, c, l = 0, 0, 0, 0, 0
for i in s:
if i == "a":
a += 1
else:
b += 1
if min(a, b) > m:
if s[l] == "a":
a -= 1
else:
b -= 1
l += 1
else:
ans += 1
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def executa(n, k, letra, s):
r = 0
tk = k
p = 0
for i in range(n):
while r < n and tk >= 0:
if a[r] == letra:
if tk == 0:
break
tk -= 1
r += 1
p += 1
s = max(s, p)
p -= 1
if a[i] == le... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER IF VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER IF VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = list(map(int, input().split()))
s = input()
l = 0
f = 0
g = 0
m = 0
i = 0
while i < n:
while min(f, g) <= k and i < n:
if s[i] == "a":
f += 1
else:
g += 1
i += 1
if i == n and min(f, g) <= k:
m = max(i - l, m)
else:
m = max(i - l - 1, m)... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR FUNC_CALL VAR VAR ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | s = input()
s1 = s.split()
K = int(s1[1])
s = input()
i = 0
j = 0
k = K
maxlen = 0
while j < len(s):
if s[j] == "a":
j = j + 1
elif k > 0:
k = k - 1
j = j + 1
else:
maxlen = max(maxlen, j - i)
while k == 0:
if s[i] == "b":
k = k + 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
a = 0
b = 0
ff = -1
pp = 0
for i in range(n):
if s[i] == "a":
a += 1
else:
b += 1
if min(a, b) <= k:
ff = max(a + b, ff)
else:
if s[pp] == "a":
a -= 1
else:
b -= 1
pp += 1
if min(a, b) <=... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR STRING VAR NUMBE... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().strip().split())
s = input().strip()
max_len = 0
def fun(letter):
global max_len
curr_len = swaps = l = 0
r = -1
while r < n - 1:
r += 1
curr_len += 1
c = s[r]
if c == letter:
swaps += 1
while swaps > k:
curr_len -... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
ca = cb = 0
q = []
ans = 0
l = 0
r = 0
for i in s:
if i == "a":
ca += 1
else:
cb += 1
r += 1
q.append(i)
while l <= r and min(ca, cb) > k:
if q[l] == "a":
ca -= 1
else:
cb -= 1
l += 1
ans... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR STRING VAR NU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | s = input().split()
n, k = int(s[0]), int(s[1])
s = input()
ans = 0
k1 = k
i1 = -1
i2 = 0
while i1 < n - 1:
i1 += 1
if s[i1] == "b":
if k1 > 0:
k1 -= 1
else:
while s[i2] != "b":
i2 += 1
i2 += 1
if ans < i1 - i2:
ans = i1 - i2
k1 = k... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR NUMBER VAR NUMBER WHILE VAR VAR STRING VAR NUMBER VAR NUMBER I... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
i = 0
j = 0
a = 0
b = 0
ans = 0
while j < n:
if s[j] == "a":
a += 1
if s[j] == "b":
b += 1
if a <= k or b <= k:
ans = max(ans, a + b)
else:
if s[i] == "a":
a -= 1
if s[i] == "b":
b -= 1
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR ST... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
w = input()
ans, i, j = 0, 0, -1
perm = k
a, b = 0, 0
if k >= w.count("a") or k >= w.count("b"):
ans = n
else:
while i < n:
if i > 0:
if w[i - 1] == "a":
a -= 1
else:
b -= 1
if w[i] == "a" and w[i] != w[... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING ASSIGN VAR VAR WHILE VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | from sys import stdin
def magic(n, k, arr, ch, comp):
last = 0
end = -1
temp = k
i = 0
count = 0
while i < n:
if arr[i] == ch:
i += 1
count = max(count, i - last)
elif temp > 0:
temp -= 1
i += 1
count = max(count, i - ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR N... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = input().split()
n = int(n)
k = int(k)
s = list(input())
ans1 = 0
ans2 = 0
a = []
b = []
if k != 0:
for i in range(n):
if s[i] == "a":
a.append(i)
else:
b.append(i)
if len(a) <= k:
ans1 = n
else:
i = 0
j = k - 1
while j < len(a):
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
l, r = 0, 0
a, b = 0, 0
def check(l, r, a, b, s):
while l <= r:
if min(a, b) <= k:
return a, b, l, a + b
else:
if s[l] == "a":
a -= 1
else:
b -= 1
l += 1
return a, b, l,... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF WHILE VAR VAR IF FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR VAR BIN_OP VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR VAR BIN_OP VAR VAR ASSIGN VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = list(map(int, input().split()))
s = input()
sums = [0] * (n + 1)
for i in range(n):
if s[i] == "a":
sums[i] = sums[i - 1] + 1
else:
sums[i] = sums[i - 1]
l = 0
r = 0
def check_interval(l, r):
length = r - l + 1
a_count = sums[r] - sums[l - 1]
return a_count <= k or length - ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
a = list(input())
ca = k
i = 0
j = 0
aa = 0
ab = 0
ma = 0
mb = 0
while j < n:
if a[j] == "a":
j = j + 1
aa = aa + 1
elif a[j] == "b" and ca > 0:
j = j + 1
aa = aa + 1
ca = ca - 1
else:
if a[i] == "b":
ca = ca + 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
p1 = 0
c = 0
maxi = -1
for p0 in range(n):
p1 = max(p1, p0)
while p1 < n and (s[p1] == "a" or c < k):
if s[p1] == "b":
c += 1
p1 += 1
maxi = max(maxi, p1 - p0)
if s[p0] == "b":
c -= 1
c = max(c, 0)
p1 = 0
c = 0
for p0 i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR VAR VAR STRING VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def occurence_list(string):
o = [[(0) for i in range(2)] for j in range(len(string))]
for i, j in enumerate(string):
o[i][ord(j) - ord("a")] += 1
for i in range(1, len(string)):
for j in range(0, 2):
o[i][j] += o[i - 1][j]
return o
def freq(o, l, r, target):
if l == 0:
... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR FUNC_DEF ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
text = input() + "0"
forward = dump = 0
if len(text) == 1:
print(1)
quit()
def m(a, r):
begin = 0
end = 0
maximum = 0
while end != len(text) - 1:
if text[end] != a:
if r > 0:
r -= 1
end += 1
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR IF VAR NU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
txt = list(input())
l = 0
r = 0
countA = 0
countB = 0
ans = 1
while r <= n - 1:
if txt[r] == "a":
countA += 1
else:
countB += 1
change = min(countA, countB)
if change <= k:
ans = max(r - l + 1, ans)
else:
if txt[l] == "a":
... | ASSIGN 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
l, r = 0, -1
cnt = 0
ans = 0
while l != n:
while (
r + 1 != n
and min(cnt + int(s[r + 1] == "a"), r - l + 2 - (cnt + int(s[r + 1] == "a")))
<= k
):
r += 1
cnt += int(s[r] == "a")
ans = max(ans, r - l + 1)
cnt -= int(s[l... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR FUNC_CALL VAR VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
prefix_a = [0] * (n + 1)
for i in range(1, n + 1):
if s[i - 1] == "b":
prefix_a[i] = 1
prefix_a[i] = prefix_a[i] + prefix_a[i - 1]
dic = {}
ans = -1
dic.update({(0): 0})
for i in range(1, n + 1):
if prefix_a[i] <= k:
ans = max(ans, i)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER EXP... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def check(s, x, k):
a = s[:x].count("a")
b = s[:x].count("b")
i = x
while i < len(s):
if min(a, b) <= k:
return True
if s[i - x] == "a":
a -= 1
else:
b -= 1
if s[i] == "a":
a += 1
else:
b += 1
i +... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER IF VAR BIN_OP VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER RETURN N... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def longest(s, n, k):
d = {"a": 0, "b": 0}
i = j = m = l = 0
for i in range(n):
d[s[i]] = d.get(s[i], 0) + 1
mm = min(list(d.values()))
if mm > k:
while j < n and mm > k:
d[s[j]] -= 1
j += 1
mm = min(list(d.values()))
... | FUNC_DEF ASSIGN VAR DICT STRING STRING NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CAL... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
freq = {"a": 0, "b": 0}
for i in s:
freq[i] = freq[i] + 1
char = "b" if freq["a"] > freq["b"] else "a"
if k >= freq[char]:
print(n)
exit()
cnts = []
cnt = 0
for i in s:
if i != char:
cnt += 1
else:
cnts.append(cnt)
cnt = 0
if cnt !... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR STRING VAR STRING STRING STRING IF VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s, ans = input(), 0
for j in ["a", "b"]:
b, c, p1, p2 = [], k, 0, 0
for i in range(n):
if s[i] == j:
b.append(i)
if c:
c -= 1
else:
p1 = b[p2] + 1
p2 += 1
ans = max(ans, i - p1 + ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FOR VAR LIST STRING STRING ASSIGN VAR VAR VAR VAR LIST VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
a, b = 0, 0
ma = 0
i2 = 0
st = input()
if st[0] == "a":
a += 1
else:
b += 1
for i1 in range(n):
while min(a, b) <= k and i2 < n - 1:
i2 += 1
if st[i2] == "a":
a += 1
else:
b += 1
if min(a, b) > k:
if st[i2] == "a":
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def checkmax(s, ch, k):
count = 0
ptr1 = 0
maxx_length = 0
temp = 0
for i in range(len(s)):
temp += s[i] != ch
while temp > k:
temp -= s[ptr1] != ch
ptr1 += 1
temp_length = i - (ptr1 - 1)
maxx_length = max(temp_length, maxx_length)
return m... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | a = [int(x) for x in input().split()]
b = 0
c = 0
asum = 0
bsum = 0
sorozat = input()
helyek = []
helyek.append(-1)
for x in range(len(sorozat)):
if sorozat[x] == "a":
asum += 1
helyek.append(x)
helyek.append(a[0])
if asum <= a[1]:
c = a[0]
else:
for x in range(len(helyek)):
if b + a... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER IF... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
res, cnta, cntb, oldi = 0, 0, 0, 0
for i in range(n):
if s[i] == "a":
cnta += 1
else:
cntb += 1
while oldi <= i and k < min(cnta, cntb):
if s[oldi] == "a":
cnta -= 1
else:
cntb -= 1
oldi += 1
res... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR B... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = list(map(int, input().split()))
s = input()
i = 1
j = 0
ca = 0
cb = 0
ans = 1
if s[0] == "a":
ca += 1
else:
cb += 1
while i < len(s):
if s[i] == "a":
ca += 1
else:
cb += 1
if ca > k and cb > k:
if s[j] == "a":
ca -= 1
else:
cb -= 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR IF V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | read = lambda: list(map(int, input().split()))
n, k = read()
s = input()
i = j = 0
cur = k
while cur and j < n:
if s[j] == "a":
cur -= 1
j += 1
while j < n and s[j] == "b":
j += 1
ans = j
while j < n:
while i < n and s[i] == "b":
i += 1
i += 1
j += 1
while j < n and s[j] == "... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR WHILE VAR VAR VAR VAR STRING VAR NU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
a = [0] * len(s)
b = [0] * len(s)
for i in range(len(s)):
if s[i] == "a":
a[i] += 1
else:
b[i] += 1
if i > 0:
a[i] += a[i - 1]
b[i] += b[i - 1]
ans = 0
for i in range(len(s)):
lo = 0
hi = len(s) - 1
while lo <= hi:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def main():
n, k = map(int, input().split())
s, x = input(), 2
if not k < s.count("a") < n - k:
print(n)
return
for a in ("a", "b"):
j, cnt = -1, k
try:
for i, c in enumerate(s):
if c != a:
if cnt:
cn... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER IF VAR FUNC_CALL VAR STRING BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR STRING STRING ASSIGN VAR VAR NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR NUMBER IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_O... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | import sys
input = lambda: sys.stdin.readline().strip("\r\n")
n, k = map(int, input().split())
s = input()
a, b, j = 0, 0, 0
for i in range(n):
if s[i] == "a":
a += 1
else:
b += 1
if min(a, b) > k:
if s[j] == "a":
a -= 1
else:
b -= 1
j += 1
pr... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER EXP... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = list(map(int, input().split()))
s = input()
l = 0
r = 0
maxi = {"a": 0, "b": 0}
cur = {"a": 0, "b": 0}
while r < n:
if min(cur.values()) > k:
maxi["a"] = max(maxi["a"], cur["a"] + k)
maxi["b"] = max(maxi["b"], cur["b"] + k)
cur[s[l]] -= 1
l += 1
continue
cur[s[r]] ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING NUMBER NUMBER ASSIGN VAR DICT STRING STRING NUMBER NUMBER WHILE VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FUNC_CALL VAR VAR STRING BIN_OP V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | l = input().split()
n = int(l[0])
k = int(l[1])
s = input()
maxa = []
i = 0
j = 0
numofs = 0
while i < n:
while j < n and numofs <= k:
if s[j] == "a":
j += 1
elif numofs < k:
numofs += 1
j += 1
else:
break
maxa.append(j - i + 1)
if s[i]... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR B... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | import sys
input = sys.stdin.readline
n, k = map(int, input().split())
s = [i for i in input() if i != "\n"]
def checker(m):
l = [0, 0]
for i in range(m):
l[ord(s[i]) - 97] += 1
if min(l) <= k:
return True
for i in range(m, len(s)):
l[ord(s[i - m]) - 97] -= 1
l[ord(s[i... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def f():
n, k = map(int, input().split())
s = input()
cnta = [0]
cntb = [0]
for c in s:
cnta.append(cnta[-1] + (c == "a"))
cntb.append(cntb[-1] + (c == "b"))
l = 1
r = len(s)
while l < r:
m = (l + r + 1) // 2
flag = False
for n in range(len(s) - m ... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = [int(s) for s in input().split(" ")]
str = input()
def length_of_longest_substring(str, k):
window_start, window_end, maxCharCount, maxLen = 0, 0, 0, 0
char_freq = {}
for window_end in range(len(str)):
right_char = str[window_end]
if right_char not in char_freq:
char_fre... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR WHILE B... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def check(l, r, k, count):
if l != 0:
a = count[r][0] - count[l - 1][0]
b = count[r][1] - count[l - 1][1]
else:
a = count[r][0]
b = count[r][1]
if a > b and b <= k:
return a + b
elif b >= a and a <= k:
return a + b
else:
return 0
def solve_te... | FUNC_DEF IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR VAR RETURN BIN_OP VAR VAR IF VAR VAR VAR VAR RETURN BIN_OP VAR VAR RETURN NUMBER FUNC_DEF ASSIGN VAR VAR F... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = list(map(int, input().split(" ")))
st = input()
a, b = 0, 0
i, j = 0, 0
while i < n:
while j < n and b <= k:
if st[j] == "b":
b += 1
j += 1
if b > k:
a = max(a, j - i - 1)
else:
a = max(a, j - i)
if st[i] == "b":
b -= 1
i += 1
aa, ba = 0, 0
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUN... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, limit = input().split()
limit = int(limit)
string = input()
start = 0
n_a = 0
n_b = 0
for letter in string:
if letter == "a":
n_a += 1
else:
n_b += 1
if n_a > limit and n_b > limit:
if string[start] == "a":
n_a -= 1
else:
n_b -= 1
start += 1... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def solve(string, k):
n = len(string)
ans = 0
left = 0
cur = 0
for i in range(n):
cur += string[i] == "b"
while cur > k:
cur -= string[left] == "b"
left += 1
ans = max(ans, i - left + 1)
return ans
n, k = map(int, input().split())
string = list(i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR STRING WHILE VAR VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def solve(n, k, s):
ans = 0
c = {"a": 0, "b": 0}
l = 0
cur_len = 0
for r in range(n):
cur_len += 1
c[s[r]] += 1
while l <= r and min(c.values()) > k:
c[s[l]] -= 1
cur_len -= 1
l += 1
ans = max(ans, cur_len)
return ans
n, k = m... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR NUMBER WHILE VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = str(input())
i, j, a, b, m = 0, 0, 0, 0, 0
while i < n:
if s[i] == "a":
a += 1
else:
b += 1
if min(a, b) <= k:
m = max(m, a + b)
else:
e = s[j]
if e == "a":
a = a - 1
else:
b = b - 1
m = ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR IF VAR STRING AS... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = list(map(int, input().split()))
s = input()
ret = 0
for b in ["a", "b"]:
l = 0
r = 0
curr = k
while r < n:
if s[r] == b:
r += 1
elif curr > 0:
r += 1
curr -= 1
else:
if s[l] != b:
curr += 1
l += 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR LIST STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
a = list(input())
i = 0
j = 0
ans = 1
ca = cb = 0
if a[j] == "a":
ca += 1
else:
cb += 1
while j < n and i < n:
if min(ca, cb) <= k and j < n - 1:
j += 1
if a[j] == "a":
ca += 1
else:
cb += 1
else:
if a[i] == "a":
... | ASSIGN 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 ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
mx = 0
i, j, cn = 0, 0, 0
while j < n:
if s[j] == "b":
cn += 1
while cn > k:
if s[i] == "b":
cn -= 1
i += 1
mx = max(j - i + 1, mx)
j += 1
i, j, cn = 0, 0, 0
while j < n:
if s[j] == "a":
cn += 1
while cn > k... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | entrada = input().split()
n = int(entrada[0])
k = int(entrada[1])
s = input()
esquerda = 0
tamanho = 0
ct = [0] * 2
for direita in range(0, n):
ct[ord(s[direita]) - ord("a")] += 1
if ct[0] <= k or ct[1] <= k:
temp = direita - esquerda + 1
tamanho = tamanho if tamanho > temp else temp
else:
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER IF VAR NUMBER VAR VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
m = k
a = s[:k].count("a")
b = k - a
l = 0
for r in range(k, len(s)):
if s[r] == "a":
a += 1
else:
b += 1
while min(a, b) > k:
if s[l] == "a":
a -= 1
else:
b -= 1
l += 1
m = max(m, r - l + 1)
pri... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBE... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().strip().split())
s = input()
maxi = 0
start = 0
last = 0
left = k
for i in range(n):
if s[i] == "a":
last += 1
elif left > 0:
left -= 1
last += 1
else:
while s[start] != "b":
start += 1
last -= 1
start += 1
maxi = ma... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUN... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
S = input()
l = r = 0
a = b = 0
ans = 0
while r < n:
if a <= k or a == 0 or b <= k or b == 0:
ans = max(ans, r - l)
if S[r] == "a":
a += 1
else:
b += 1
r += 1
else:
if S[l] == "a":
a -= 1
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMB... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def calc(string, k, char):
offsets = [i for i, v in enumerate(string) if v != char]
if k >= len(offsets):
return len(string)
left_idx = 0
result = max(offsets[k], len(string) - offsets[len(offsets) - k - 1] - 1)
for end_idx in range(k, len(offsets) - 1):
right = offsets[end_idx + 1] ... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | import sys
def solve(ch):
l = 0
ans = 0
maxx = 0
for r in range(n):
if ch == "a":
if s[r] == "b":
maxx += 1
elif s[r] == "a":
maxx += 1
while maxx > k:
if ch == "a":
if s[l] == "b":
maxx -= ... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER WHILE VAR VAR IF VAR STRING IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMB... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | from sys import stdin
def scan(K, line, x):
start = 0
length = len(line)
max_t = 0
cx, cnx = 0, 0
for end in range(length):
char = line[end]
if char == x:
cx += 1
else:
cnx += 1
if cnx > K:
max_t = max(max_t, cx + cnx - 1)
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN V... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = list(input())
def isPossible(x):
count_a = 0
count_b = 0
for i in range(x):
if s[i] == "a":
count_a += 1
else:
count_b += 1
if max(count_a, count_b) + k >= x:
return True
for i in range(1, n - x + 1):
if s... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER I... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
res = 1
p1 = 0
p2 = 0
ck = 0
while p2 < n and p1 < n:
if s[p2] == "b" and ck < k or s[p2] == "a":
if s[p2] == "b":
ck += 1
p2 += 1
l = p2 - p1
if l > res:
res = l
else:
if s[p1] == "b":
ck -=... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR STRING VAR VAR VAR VAR STRING IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def check(m):
if min(a[m - 1], b[m - 1]) <= k:
return True
for i in range(1, n - m + 1):
na, nb = a[i + m - 1] - a[i - 1], b[i + m - 1] - b[i - 1]
if min(na, nb) <= k:
return True
else:
return False
n, k = map(int, input().split())
s = input()
a, b = [0] * (n + ... | FUNC_DEF IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR RETURN... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
k1 = k
k2 = k
a = b = ans = 0
for i in range(n):
if s[i] == "b":
k1 -= 1
else:
k2 -= 1
while k1 < 0:
if s[a] == "b":
k1 += 1
a += 1
while k2 < 0:
if s[b] == "a":
k2 += 1
b += 1
ans = ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER AS... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
st = 0
end = 1
s = input()
l = [0] * (n + 1)
for i in range(len(s)):
l[i + 1] = 1 if s[i] == "a" else 0
su = 0
m = 0
while end < n + 1:
su += l[end]
if su > k and end - st - su > k:
st += 1
su -= l[st]
m = max(m, st - end)
end += 1
m = max(m, end ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR STRING NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | n, k = map(int, input().split())
s = input()
l = 0
r = 0
d = {}
v = -1
ans = 0
while l < n:
while r < n:
if v != r:
d[s[r]] = d.get(s[r], 0) + 1
if len(d) > 2:
d[s[r]] -= 1
if d[s[r]] == 0:
d.pop(s[r])
break
if d:
m ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR IF VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER IF... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def func(A, n, k, ch):
i = 0
j = 0
cnt = 0
maxlen = 1
while i < n:
if A[i] != ch:
cnt += 1
while cnt > k:
if A[j] != ch:
cnt -= 1
j += 1
maxlen = max(maxlen, i - j + 1)
i = i + 1
return maxlen
n, k = map(int, i... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def retMaxConsecutive(string, n, k, choice):
if string.count(choice) <= k:
return n
maxi = -1
index = 0
count = 0
for i in range(n):
if string[i] != choice:
count += 1
while count > k and index < n:
if string[index] != choice:
count -= ... | FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ST... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | def stringcheckerb(k, n, string):
l = 0
r = 0
bsinstring = 0
best = 0
try:
while True:
while bsinstring != k + 1:
r += 1
if best < r - l + 1:
best = r - l + 1
if string[r - 1] == "b":
bsinstri... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | import sys
inf = float("inf")
abc = "abcdefghijklmnopqrstuvwxyz"
abd = {
"a": 0,
"b": 1,
"c": 2,
"d": 3,
"e": 4,
"f": 5,
"g": 6,
"h": 7,
"i": 8,
"j": 9,
"k": 10,
"l": 11,
"m": 12,
"n": 13,
"o": 14,
"p": 15,
"q": 16,
"r": 17,
"s": 18,
"t": ... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NU... |
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. W... | aplha = [chr(i) for i in range(ord("a"), ord("z") + 1)]
n, k = map(int, input().split())
s = list(input())
out = 0
for i in aplha:
l = 0
r = 0
t = k
while l < n and r < n:
if s[r] == i:
r += 1
elif t > 0:
t -= 1
r += 1
elif s[l] == i:
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR... |
There are $n$ points on a plane. The $i$-th point has coordinates $(x_i, y_i)$. You have two horizontal platforms, both of length $k$. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the same $y$-coordinate) and have integer borders. If the left border of the platform is $(x, y)... | import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
n, k = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
X2 = sorted(X)
S = [0] * n
LAST = [0] * n
end = 0
for start in range(n):
v = X2[start]
w... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 ASSIGN VAR BI... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.