description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
s = input()
s = "L" + s + "W"
a = []
p = 0
c = 0
koL = 0
sum = 0
for i in range(1, n + 2):
if s[i] == "W" and p == 0:
p = 1
if i != 1:
a.append(c)
c = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NU... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
t = int(input())
for _ in range(t):
n, k = [int(x) for x in input().split()]
s = list(input())
Wcnts = min(s.count("W") + k, n)
lStreaks = []
isStart = True
lStreakLen = 0
for c in s:
if c == "W":
isStart = F... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
s = input()
if "W" not in s:
print(max(min(n, k) * 2 - 1, 0))
continue
l = s.split("W")[1:-1]
l = list(filter(None, l))
l = [len(block) for block in l]
l.sort()
ncut = len(l) + 1
x = s.count("W")
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def score(s):
rv = 0
for z in range(len(s)):
if s[z] == "W":
if z == 0:
rv += 1
elif s[z - 1] == "W":
rv += 2
else:
rv += 1
return rv
for _ in range(int(input())):
n, k = map(int, input().split())
s = list(... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
t = int(input())
for _ in range(t):
n, k = [int(x) for x in input().split()]
s = list(input())
startGroup = []
endGroup = []
LGroups = []
currLGroup = []
isStart = False
isEnd = False
for i in range(n):
if i == 0... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
n, k = map(int, input().split())
s = input()
if n == 1:
if s.count("W") + k >= 1:
print(1)
else:
print(0)
else:
s = s[:n]
if s.count("L") == n:
du = 2 * k... | 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 IF VAR NUMBER IF BIN_OP FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR IF FUNC_CALL VAR STRING VAR ASS... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | ts = int(input())
for t in range(ts):
n, k = [int(i) for i in input().split(" ")]
l = input()
c = 0
wc = 0
d = {}
be = 0
head = 0
tail = n
for i in l:
if i == "L":
head += 1
be += 1
else:
break
for i in range(n - 1, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER FOR VAR FUN... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def getsum(result):
answer = 0
box = []
count = 0
for i in result:
if i == "W":
count += 1
else:
box.append(count)
count = 0
box.append(count)
for i in box:
if i != 0:
answer += 2 * i - 1
return answer
t = int(input())... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
cntW = s.count("W")
cntL = s.count("L")
cnt = 0
point = 0
gap = []
prevIndex = -1
firstIndex = -1
for i in range(n):
if s[i] == "W":
cnt += 1
if prevIndex == -1:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def solve(n, k, games):
W, L = "W", "L"
if n == 1:
if games[0] == L and k == 0:
return 0
return 1
gl = []
wins = 0
scores = 0
if games[0] == W:
scores += 1
wins += 1
else:
gl.append(1)
for i in range(1, n):
if games[i] == W:
... | FUNC_DEF ASSIGN VAR VAR STRING STRING IF VAR NUMBER IF VAR NUMBER VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR N... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = list(map(int, input().split()))
s = list(input())
mode = 0
ls = []
count = 0
for i in range(n):
if s[i] == "W":
if mode == 1:
if count != 0:
ls.append(count)
mode = 1
count ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def countStr(string, str_len):
l_len, l_sum = 0, 0
sw_idx, ew_idx = -1, -1
l_count = {}
l_flag, sw_flag = False, False
for i in range(str_len):
s = string[i]
if sw_flag and s == "L":
l_flag = True
l_len += 1
elif s == "W":
if l_flag:
... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER VAR NUMBER IF VAR STRING IF VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | I = input
for _ in [0] * int(I()):
n, k = map(int, I().split())
a = sorted(map(len, I().strip("L").split("W")))
m = len(a) + k
while a and a[0] <= k:
k -= a.pop(0)
print((2 * min(n, m - 1) - len(a) or 1) - 1) | ASSIGN VAR VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR WHILE VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, K = map(int, input().split())
s = input()
n = len(s)
def way1():
global n, K, s
if s.find("W") == -1:
return max(0, 2 * min(K, n) - 1)
k = K
score = int(s[0] == "W")
for i in range(1, n):
if s[i - 1] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR STRING NUMBER RETURN FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
a = input()
lc = a.count("L")
z = []
curr = 0
for i in range(n):
if a[i] == "L":
curr += 1
else:
if curr > 0:
z.append(curr)
curr = 0
ini = []
if a[0] == "L"... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR L... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for t_ in range(t):
n, k = map(int, input().split())
s = input()
gaps = [len(x) for x in s.split("W") if len(x) > 0]
runs = [len(x) for x in s.split("L") if len(x) > 0]
ends = 0
if s[0] == "L":
ends += gaps[0]
del gaps[0]
if s[-1] == "L" and len(gaps) > 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMB... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = [int(i) for i in input().split()]
S = input()
consL0 = []
consL1 = []
consL2 = []
startW = S[0] == "W"
c = 1 if S[0] == "L" else 0
ans = 1 if S[0] == "W" else 0
for i in range(1, n):
if S[i] == "L":
c += 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER STRING ASSIGN VAR VAR NUMBER STRING NUMBER NUMBER ASSIGN VAR VAR NUMBER STRING NUMBER NUMBER FOR VA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | tests = int(input())
for test in range(tests):
n, k = map(int, input().split())
s = "L" + input().strip() + "L"
res = 0
pr = "L"
for c in s[1:-1]:
if c == "W":
if pr == "L":
res += 1
else:
res += 2
pr = c
r = 0
if res ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR NUMBER NUMBER IF VAR STRING IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for t in range(int(input())):
n, k = map(int, input().split())
s = input()
if k >= n:
print(n * 2 - 1)
continue
l = 0
inter = []
count = 0
out = 0
for i in s:
if i == "L":
l += 1
count += 1
else:
if count != 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER IF VAR N... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
ik = k
sg = input().strip()
gaps = []
l = len(sg)
wins = 0
win_streaks = 0
i = 0
lcnt = 0
temp = 0
while i < l:
if sg[i] == "W":
break
i += 1
temp += 1
filled_gaps = 0
w... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def calc(p, n):
score = p[0]
for i in range(1, n):
if p[i] and p[i - 1]:
score += 2
elif p[i]:
score += 1
return score
for _ in range(int(input())):
n, k = map(int, input().split())
p = [(1 if i == "W" else 0) for i in input()]
if all(i == 0 for i in p):... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL VAR IF FUNC_CALL VAR V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | gans = []
for _ in range(int(input())):
n, k = map(int, input().split())
a = list(input())
cnt = 1
u = []
ok = False
ans = 0
for i in range(1, n):
if a[i] != a[i - 1]:
if a[i - 1] == "L":
u.append([cnt, 0])
if not ok:
u[... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMB... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = str(input())
base = 0
for i in range(n):
if s[i] == "W":
if i != 0:
if s[i - 1] == "W":
base += 2
else:
base += 1
else:
... | 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSI... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | from sys import stdin
T = int(stdin.readline().strip())
for caso in range(T):
n, k = map(int, stdin.readline().strip().split())
s = list(stdin.readline().strip())
aux = []
last = -1
for i in range(n):
if i > 0 and s[i] == "L" and s[i - 1] == "W":
last = i
if i < n - 1 an... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def count(s):
wins = 0
l = 0
arr = []
prev = None
for e in s:
if e == "L":
if prev == "W" or l > 0:
l += 1
if e == "W":
wins += 1
if l > 0:
arr.append(l)
l = 0
prev = e
return wins, arr
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NONE FOR VAR VAR IF VAR STRING IF VAR STRING VAR NUMBER VAR NUMBER IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for t in range(int(input())):
n, k = list(map(int, input().split(" ")))
s = input()
point = j = 0
flag = True
cnt = 0
c = []
j = 0
while j < n and s[j] == "L":
j += 1
st = j
if st == n and k > 0:
print(min(st, k) * 2 - 1)
continue
while j < n:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR NUMBE... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
score = 0
tmp = s.count("L")
for i in range(1, n):
if s[i] == "W" and s[i - 1] == "W":
score += 2
elif s[i] == "W":
score += 1
if s[0] == "W":
score += 1
if k == 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER STRI... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
tmp = k
s = input()
k = max(0, n - s.count("W") - k)
l = [0]
for i in range(n):
if i > 0 and s[i - 1] == s[i] == "W":
continue
if s[i] == "W":
l.append(0)
else:
l[-1] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR STRING VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBE... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
ans = [(0) for _ in range(t)]
def score(s):
ret = 0
n = len(s)
for i in range(n):
if s[i] == "W":
if i == 0 or s[i - 1] == "L":
ret += 1
else:
ret += 2
return ret
for i in range(t):
n, k = map(int, input().split())
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_C... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def solve():
n, k = map(int, input().split())
l = sorted(map(len, input().strip("L").split("W")))
z = len(l) + k
while l and l[0] <= k:
k -= l.pop(0)
ans = 2 * min(n, z - 1) - len(l)
if ans <= 0:
ans = 1
print(ans - 1)
t = int(input())
for _ in range(0, t):
solve() | FUNC_DEF 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 FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR WHILE VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | test = int(input())
for _ in range(test):
n, k = map(int, input().split())
arr = list(input())
less = []
over = []
wins = 0
last = False
pre = 0
found = False
for i in range(n):
if arr[i] == "W":
if last:
wins += 2
else:
... | 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 ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
a = list(input())
f = False
d = 0
cntt = 0
temp = []
for i, c in enumerate(a):
if c == "W":
if f and cntt != 0:
temp.append((cntt, d))
cntt = 0
elif f == False:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMB... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for bleh in range(int(input())):
a = list(map(int, input().strip().split(" ")))[1]
b = input()
w = b.count("W")
if w == 0:
if a > 0:
print(2 * a - 1)
else:
print(0)
else:
w = 0
wt = False
lcout = 0
if b[0] == "L":
lc... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
def solve(outcomes, k, raw):
n = len(outcomes)
nw = sum(outcomes)
nl = n - nw
last = 0
score = 0
for s in outcomes:
score += 0 if s == 0 else 1 if last == 0 else 2
last = s
if k == 0:
return score
elif k >= nl:
return 2 * n - 1
elif nw == ... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR IF VAR NUMBER RETURN VAR IF VAR VAR RETURN BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | I = input
for _ in [0] * int(I()):
n, k = map(int, I().split())
s = I()
a = sorted(map(len, filter(None, s.strip("L").split("W"))))
r = 0
while a and r + a[0] <= k:
r += a.pop(0)
print((2 * min(n, s.count("W") + k) - len(a) or 1) - 1) | ASSIGN VAR VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NONE FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR NUMBER VAR VAR FUNC_CALL ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = [int(i) for i in input().split(" ")]
s = input()
a = []
cur = 0
flag = False
b = []
w = 0
for i in range(n):
if s[i] == "L":
cur += 1
else:
w += 1
if cur > 0:
a.append(cur)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUM... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for qwe in range(t):
[n, k] = [int(j) for j in input().split()]
s = input()
l = list(s)
c = 0
a = []
if l[0] == "W":
ans = 1
else:
ans = 0
for i in range(1, n):
if l[i] == "W":
if l[i - 1] == "W":
ans += 2
e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST 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 NUMBER ASSIGN VAR LIST IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = str(input())
a = 0
b = 0
kek = []
fl = 0
su = 0
rs = 0
buf = 10000000000.0
buf1 = 10000000000.0
for i in range(len(s)):
if s[i] == "W":
if a > 0:
su += a
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def recal(l, n, k):
result = 0
cur = []
last_lose = 0
dex = 0
have_win = False
for i in l:
if i == "W":
if last_lose == 0:
if have_win:
result += 2
else:
result += 1
have_win = True
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR LIST VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR VAR NUMBER... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def print_arr(arr):
for i, ch in enumerate(arr):
if i == len(arr) - 1:
print(ch)
else:
print(ch, end=" ")
if not arr:
print()
def run(arr):
s = sum(arr)
if s == 0:
print("NO")
elif s < 0:
arr.sort()
print("YES")
print_... | FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING IF VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXP... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
def func(arr, n):
start = None
end = None
for i in range(n):
if arr[i] == "W":
start = i
break
for i in reversed(range(n)):
if arr[i] == "W":
end = i
break
return start, end
while t > 0:
t -= 1
n, k = list(m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR RETURN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
l = input().split()
n = int(l[0])
k = int(l[1])
s = input()
lfi = [i for i in s]
ans = 0
poss = 1
for i in s:
if i == "W":
poss = 0
break
if poss:
print(max(2 * k - 1,... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBE... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def solve():
n, k = map(int, input().split())
s = list(input())
i = 0
cnt = 0
la = []
for i in range(n):
if s[i] == "W":
la.append(i)
else:
cnt += 1
if la == []:
for i in range(n):
if k == 0:
break
s[i] =... | FUNC_DEF 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 LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
n, k = map(int, input().split())
S = input().strip()
if not "W" in S:
if k == 0:
print(0)
else:
print(min(n, k) * 2 - 1)
continue
LIST = [[S[0], 0]]
for s in S:
if s... | 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 FUNC_CALL VAR IF STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR LIST LI... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def solve():
n, k = map(int, input().split())
s = list(input())
if n == 1:
print(1 if s[0] == "W" or k > 0 else 0)
return
if not "W" in s:
print(min(k, n) * 2 - 1 if k > 0 else 0)
return
ans = 0
arr = []
arr2 = 0
i = 0
for i in range(n):
if s[i... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER STRING VAR NUMBER NUMBER NUMBER RETURN IF STRING VAR EXPR FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER RETURN ASSIGN VAR NUMBER ASSIGN... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
t = int(input())
while t > 0:
t -= 1
input = sys.stdin.readline()
n, k = map(int, input.split())
s = sys.stdin.readline()
no_los = 0
no_win = 0
for i in range(len(s)):
if s[i] == "L":
no_los += 1
else:
no_win += 1
if no_los <= k:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
from sys import stdin, stdout
def II():
return int(stdin.readline())
def IP():
return map(int, stdin.readline().split())
def solve():
n, k = IP()
s = input()
cnt = s.count("W")
if k == 0:
ans = 0
last = "L"
for ele in s:
if ele == "W" and last... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR NUMBER IF VAR STRING VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
l = list(input())
cont, edge = [], []
last = True
wCnt, lCnt, ans = 0, 0, 0
for i in range(n):
if l[i] == "L":
if wCnt > 0:
ans += wCnt * 2 - 1
wCnt = 0
lCnt += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMB... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
N, K = map(int, input().split())
S = [x for x in input()]
l = []
cnt = 0
check = -1
for i in range(N):
if S[i] == "L":
cnt += 1
if check == -1:
check = i
elif cnt >= 1:
if check != 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def main():
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
l = list(input())
segments = []
previous_w = -1
first_w = n
last_w = -1
for c, el in enumerate(l):
if el == "W":
if previous_w != -1 and c != previ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER EXP... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | ns = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
for _ in range(ni()):
n, k = nm()
s = ns()
w = []
l = []
i = count = 1
f = s[0]
ll = []
while i < n:
if s[i] == "W" and f != "W":
l.appen... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | T = int(input())
for _ in range(T):
n, k = map(int, input().split())
s = input()
res = 0
gaps = []
gap0 = 0
gap = 0
prev = False
f = True
for x in s:
if f:
if x == "L":
gap0 += 1
else:
f = False
res = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIG... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = iter(sys.stdin.read().splitlines()).__next__
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
num_losses = s.count("L")
if k >= num_losses:
print(2 * n - 1)
continue
score = 1 if s[0] == "W" else 0
interval_lengths = [] if s[0] ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER S... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
w = s.count("W")
if s.count("L") <= k:
ans = 2 * n - 1
print(ans)
elif k == 0 and w == 0:
print(0)
else:
i = 0
c1 = s.find("W")
c2 = s.rfind("W")
if c1 == -1:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
data = input()
start = data.find("W")
result = 0
prev = False
for x in data:
if x == "W":
if prev:
result += 2
else:
result += 1
prev = True
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER E... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for i in range(int(input())):
n, k = map(int, input().split())
s = input()
c = [len(i) for i in list(map(str, s.split("W"))) if len(i) > 0]
d = [len(i) for i in list(map(str, s.split("L"))) if len(i) > 0]
t = sum(c)
if t <= k:
print(2 * n - 1)
elif not d:
print(max(2 * k - 1,... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
gaps = []
winseq = 0
n, k = map(int, input().split())
wins = k
s = input()
l = 1
flag1 = 0
for i in range(n):
if s[i] == "W":
wins += 1
if i < len(s) - 1:
if s[i + 1] == "L":
winseq +=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR N... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + "\n")
for _ in range(int(input())):
n, k = map(int, input().split())
s = input().strip()
Ws = 0
prev = 0
for i in s:
if i == "W":
if prev:
Ws += 2
else:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMB... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | nums = int(input().strip())
for _ in range(nums):
n, k = map(int, input().strip().split())
s = input().strip()
cur_score = 0
l_part = []
cur_num = 0
l_count = w_count = 0
for i, v in enumerate(s):
if v == "W":
w_count += 1
if i > 0 and s[i - 1] == "W":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
lnth = sorted(map(len, s.strip("L").split("W")), reverse=True)
m = len(lnth) + k - 1
while lnth and lnth[-1] <= k:
k -= lnth.pop()
print((2 * min(n, m) - len(lnth) or 1) - 1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER WHILE VAR VAR NUMBER VAR VAR FUNC_CALL VAR EXP... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
l = sorted(map(len, input().strip("L").split("W")))
m = len(l) - 1 + k
while l and l[0] <= k:
k -= l.pop(0)
if m >= n:
print(2 * n - 1)
else:
print((2 * m - len(l) or 1) - 1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR WHILE VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FU... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
arr = list(input())
ind = []
p = -1
if arr[0] == "W":
p = 0
for i in range(1, n):
if arr[i] == "W" and arr[i - 1] == "L":
if p != -1:
ind.append([i - p - 1, [p, i]])
p = i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER EXPR FU... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = list(input())
s, l = 0, 0
ind, sp = [], []
for i in range(n):
if a[i] == "W":
if i > 0 and a[i - 1] == "W":
s += 2
else:
s += 1
ind.append(i)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUM... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
for _ in range(int(input())):
n, k = map(int, input().split())
S = input()
wins = S.count("W")
if k >= n - wins:
print(2 * n - 1)
continue
elif wins == 0 and k:
print(2 * k - 1)
continue
score = 0
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
n, k = map(int, stdin.readline().split())
s = list(stdin.readline()[:-1])
end = 0
if "W" not in s:
print(max(0, 2 * k - 1))
continue
while s[-1] == "L":
end += 1
del s[-1]
s.reverse()
whi... | 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 NUMBER ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER WHILE VAR NUMBER STRING VAR NUMBER VAR NUMBER EX... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n, k = map(int, input().split())
state = input()
state = [i for i in state]
ans, prev = 0, 0
store = []
if state[0] == "W":
rang = [-1]
else:
rang = []
for i in range(len(state)):
if state[... | 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 ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST IF VAR NUMBER STRING ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR F... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = input().split()
n, k = int(n), int(k)
s = input()
ind = []
if "W" not in s:
print(max(0, min(2 * n - 1, 2 * k - 1)))
continue
score = 0
prev = "L"
ind = []
for i in range(len(s)):
if s[i] == "W" and prev == "W":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = list(map(int, input().split()))
s = str(input())
ind = []
arr = []
p = 0
for i in range(n):
arr.append(s[i])
if s[i] == "W":
ind.append(i + 1)
p += 1
if p == 0:
if k == 0:
print(0)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_O... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
N, K = map(int, input().split())
S = input()
winning_steaks_cnt = wins = losses = 0
losing_steaks = []
for i in range(N):
if S[i] == "W":
wins += 1
if i == 0 or S[i - 1] == "L":
winning_steaks_cnt += 1
if S[i] == "... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR N... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for case in range(t):
n, k = [int(x) for x in input().split(" ")]
s = input()
score = int(s[0] == "W")
for i in range(1, n):
if s[i - 1 : i + 1] == "WW":
score += 2
elif s[i - 1 : i + 1] == "LW":
score += 1
losses = s.count("L")
if "W" in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
if "W" not in s:
ans = min(n, k) * 2 - 1
print(max(ans, 0))
else:
extra = 0
i = 0
while i < n and s[i] == "L":
i += 1
extra = i
j = n - 1
while j >... | 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 IF STRING VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, m = map(int, input().split())
s = " " + input()
q = s.count("L")
if q <= m:
print(max(0, 2 * n - 1))
elif q == len(s) - 1:
print(max(0, 2 * m - 1))
else:
x = 0
y = 0
C = []
for i in range(1, len(s)):
if ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR F... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def f(n, k, s):
score = 0
arr = []
sm = 0
if "W" not in s:
return max(min(n, k) * 2 - 1, 0)
arr = s.split("W")[1:-1]
arr = list(filter(None, arr))
arr = [len(i) for i in arr]
arr.sort()
sm = s.count("W")
ncut = len(arr) + 1
for i in range(len(arr)):
if k >= ar... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER IF STRING VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NONE VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_C... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in " " * int(input()):
n, k = map(int, input().split())
s = list(input())
if "W" not in s:
print(max(min(k, n) * 2 - 1, 0))
elif k >= s.count("L"):
print(n * 2 - 1)
else:
cnt = []
sm = 0
for i in range(n):
if s[i] == "W":
sm +... | FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER IF VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBE... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
a = list(input())
f = False
loss = 0
arr = []
start = 0
last = 0
ans = 0
if n == a.count("L") and k > 0:
ans -= 1
for i in range(n):
if a[i] == "W":
f = True
if f and i > 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = list(input())
st, ed = 0, 0
for i in range(n):
if s[i] == "W":
stw = i
break
st += 1
if st != n:
for j in range(n - 1, -1, -1):
if s[j] == "W":
edw = j
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def score(a, n):
score = 0 if a[0] == "L" else 1
for i in range(1, n):
if a[i] == a[i - 1] == "W":
score += 2
elif a[i] == "W":
score += 1
return score
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
mylist = []
x = 0... | FUNC_DEF ASSIGN VAR VAR NUMBER STRING NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for i in range(t):
n, k = list(map(int, input().split()))
s = input()
suml = 0
score = 0
lstl = []
count = 0
for j in range(n):
if j == 0 and s[0] == "W":
score += 1
continue
elif s[j] == "L":
score += 0
elif s[j] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = [int(i) for i in input().split()]
s = input()
s2 = s.strip("L")
Ls = len(s) - len(s2)
chains = []
chain = 0
score = 0
streak = False
for char in s2:
if char == "W":
if streak:
score += 2
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for q in range(t):
n, k = map(int, input().split())
s = input()
kol = []
mas = []
l = -1
kz = 0
for i in range(n):
if s[i] == "W":
if l == -1:
l = i
r = i
else:
r = i
mas.append(1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EX... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
x = 1
X = []
ans = 0
y = 0
for s in input():
if s == "W":
y = 1
if x:
X += [x]
ans += 1
x = 0
else:
ans += 2
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR STRING ASSIGN VAR NUMBER IF VAR VAR LIST VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = sys.stdin.readline
def get_close(n, i, res):
while i < n and res[i] == "L":
i += 1
return i - 1
def calc(n, res):
count = 0
for i in range(n):
if i > 0 and res[i - 1] == res[i] == "W":
count += 2
elif res[i] == "W":
count += 1
r... | IMPORT ASSIGN VAR VAR FUNC_DEF WHILE VAR VAR VAR VAR STRING VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for tt in range(t):
n, k = map(int, input().split())
s = input()
pre = False
cur = 0
mid = []
for i, c in enumerate(s):
if c == "W":
if pre:
if cur:
mid.append(cur)
else:
begin = cur
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for test_case in range(t):
n, k = [int(x) for x in input().split()]
s = input()
res = 0
zapol = []
probeli = []
i = 0
torf = False
coins = 0
if n == 1:
if s[0] == "W":
print()
print(1)
print()
elif k == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR EXPR FUNC_C... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def cal(s, n):
pits = []
wins = []
pit = 0
win = 0
for c in s:
if c == "W":
win += 1
if pit > 0:
pits.append(pit)
pit = 0
else:
pit += 1
if win > 0:
wins.append(win)
win = ... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER VA... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = lambda: sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
li = []
cnt = 0
ans = 0
lose = 0
first = True
for i in range(n):
if s[i] == "W":
if not first and cnt > 0:
li.app... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
s = input()
w = 0
l = 0
otv = 0
d = []
for j in range(n):
if w == 1 and s[j] == "L":
l += 1
if s[j] == "W":
otv += 1
if j != 0:
if s[j - 1] == "W":
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR N... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = input().rstrip()
c = a.count("L")
k = min(k, c)
out = sum(
2 if i > 0 and a[i - 1] == "W" else 1 for i, v in enumerate(a) if v == "W"
)
if k == 0:
print(out)
cont... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER STRING NUMBER NUMBER VAR VAR FUNC... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
s = list(input())
o = -1
def score(s):
if s[0] == "W":
ans = 1
x = 1
else:
ans = 0
x = 0
for i in range(1, len(s)):
if s[i] == "W" and x == 1:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
s1 = list(s)
l = [len(i) for i in s.split("W")]
w = 0
if sum(l) <= k:
print(2 * n - 1)
else:
prev = s[0]
if prev == "W":
w += 1
for i in s[1:]:
if prev == i and ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
l = list(s)
i = 0
temp = []
while i < n:
if l[i] == "W" and i + 1 < n and l[i + 1] == "W":
i += 1
elif l[i] == "W":
j = i + 1
while j < n and l[j] == "L":
... | 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF VAR VAR STRING BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRIN... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
input = sys.stdin.readline
def solution(n, k, s):
seq_lengths_L = []
count_L_seq = 0
first = 0
last = 0
score = 0
for pos in range(n):
if s[pos] == "W":
if pos > 0 and s[pos - 1] == "W":
score += 2
else:
score += 1
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_C... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
def input():
return sys.stdin.readline().rstrip()
def getMax(n):
if n <= 1:
return n
else:
return n * 2 - 1
def getPresentScore(len_arr):
countZero = 0
for l in len_arr:
if l == 0:
countZero += 1
return len(len_arr) - 1 + countZero
t = int(i... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR F... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | for _ in range(int(input())):
n, k = [int(i) for i in input().split()]
s = input()
chains = []
chain = 0
streak = False
if k + s.count("W") >= n:
print(2 * n - 1)
elif k == 0 and s.count("W") == 0:
print(0)
else:
for char in s.strip("L").strip("W"):
if... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER FUNC_CALL VAR STRING NUMBER ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | from sys import stdin
t = int(stdin.readline())
for i in range(t):
n, k = tuple(int(x) for x in stdin.readline().split())
line = "L" * (k + 1) + stdin.readline()[:-1] + "L" * (k + 1)
score = 0
flag = False
for char in line:
if char == "W":
if flag:
score += 2
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR V... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | def testcase():
n, k = map(int, input().split())
s = list(input())
ans = 0
if s[0] == "W":
ans += 1
for i in range(1, n):
if s[i] == "W":
ans += 1
if s[i - 1] == "W":
ans += 1
fw = 0
while fw < n and s[fw] == "L":
fw += 1
lw... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER AS... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | t = int(input())
ans = []
for test in range(t):
n, k = [int(i) for i in input().split()]
a = input()
loses = sum([(1) for i in a if i == "L"])
if "W" not in a:
ans.append(max(0, k * 2 - 1))
elif loses <= k:
ans.append(len(a) * 2 - 1)
else:
losing = False
left = a.... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR ... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | test_cases = int(input())
for test_case in range(test_cases):
n, k = list(map(int, input().split()))
s = input()
countl = 1
countw = 1
score = 0
l = []
w = []
lstart = 0
if len(s) == 1 and k > 0:
score = 1
else:
for i in range(n - 1):
if s[i] == "L":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBE... |
You like playing chess tournaments online.
In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ... | import sys
rd = sys.stdin.readline
t = int(rd())
for _ in range(t):
n, k = map(int, rd().split())
s = rd()
if n == 1:
if s[0] == "L" and k == 0:
print(0)
else:
print(1)
continue
gap = [0] * (n - 1)
renpai = 0
score = 0
startrenpai, lastrenpai ... | 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 IF VAR NUMBER IF VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIG... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.