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 _ in range(t): n, k = map(int, input().split()) s = input() s = s.replace("WL", "W L").replace("LW", "L W") s = s.split() ls = [len(li) for li in s if li[0] == "L"] wstr = 0 for si in s: wstr += si[0] == "W" wins = n - sum(ls) if wins + k >= n: pr...
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 FUNC_CALL VAR STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER STRING ASSIGN VAR NUMBER FOR 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(record, length, changes): if record == "L" * length: return changes * 2 - 1 if changes > 0 else 0 state = "N" loss_runs = [] win_runs = [] counter = 0 bonus = 0 score = 0 for i in record: if state == "N": if i == "L": bonus += 1 ...
FUNC_DEF IF VAR BIN_OP STRING VAR RETURN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR STRING VAR NUMBER ASSIGN VAR STRING VAR NUMBER IF VAR STRING IF VAR STRING VAR NUMBER EXPR 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, m = list(map(int, input().split())) ar = list(input()) kek = [] ans = 0 if "W" in ar: i = ar.index("W") flag = 0 cnt = 0 while i < n: if ar[i] == "L" and flag == 0: flag = 1 cnt = 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 LIST ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER A...
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 nt in range(int(input())): n, k = map(int, input().split()) f = input() if "W" not in f: if k != 0: print(1 + 2 * (k - 1)) else: print(0) continue if f.count("L") <= k: print(1 + 2 * (n - 1)) continue s = f.split("W") start, end...
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 STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP 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()) string = input() string = "LL" + string wcount = 0 lcount = 0 wlw = [] pre1 = "L" pre2 = "L" wstart = -100000000000 for j, i in enumerate(string[2:]): if i == "W": wcount += 1 wstart = ...
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 BIN_OP STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF 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 ...
t = int(input()) for i in range(0, t): n, m = list(map(int, input().split())) z = input() a = [z[j] for j in range(0, n)] s = 0 cw = 0 q = 0 b = [] d = [] for j in range(0, n): if a[j] == "W": cw = cw + 1 b.append(j) if q == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST 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 ...
import sys lines = sys.stdin.readlines() cur_line = -1 def input(): global lines, cur_line cur_line += 1 return lines[cur_line][:-1] for _ in range(int(input())): n, k = map(int, input().split()) s = input() base = 0 gaps = [] for i in range(n): if s[i] == "W": b...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER RETURN VAR VAR NUMBER 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 LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR 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 ...
import sys T = int(sys.stdin.readline()) for t in range(0, T): n, k = list(map(int, sys.stdin.readline().strip().split())) s = sys.stdin.readline().strip() ans = 0 v = False k2 = k x = 0 y = 0 if s[0] == "W": y = 1 ans = 1 v = True else: x = 1 L =...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING 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 ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = input() if k == 0: c = a.split("L") ans = 0 for i in range(len(c)): if len(c[i]) >= 1: ans = ans + ((len(c[i]) - 1) * 2 + 1) print(ans) continue c = a.split("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 IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP B...
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 print(val): sys.stdout.write(str(val) + "\n") def prog(): for _ in range(int(input())): n, k = map(int, input().split()) s = list(input().strip() + "W") bounds = [] if s[0] == "L": bounds.append([1, 1, 0]) for i i...
IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR NUMBER STRING EXPR FUNC_CALL VAR LIS...
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 _ in range(t): n, k = map(int, input().split()) s = input() streaks = [] firstwin = -1 for i in range(n): if s[i] == "W": firstwin = i break if firstwin == -1: print(max(0, min(2 * n - 1, 2 * k - ...
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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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 ...
for _ in range(int(input())): n, x = map(int, input().split()) l = list(input()) t = [] temp = x c = 0 m = 0 s = 0 f = 0 m2 = 0 e = 0 for i in range(1, n): if l[i] == "W": if l[i - 1] == "W": s += 2 else: s += 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 LIST ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) S = input() K = k s = [] for i in S: s.append(i) a = [] if s[0] == "L": ans = 0 else: ans = 1 for i in range(1, n): if s[i] == "W": ans += 1 if s[i - 1] == "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 FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR 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 ...
t = int(input()) def solve(s, k): gaps = [] last_pos = None if s.count("L") == len(s): if k: return k * 2 - 1 else: return 0 for i, x in enumerate(s): if x == "W": if last_pos is not None: gaps.append((i - last_pos - 1, last_p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NONE IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR IF VAR RETURN BIN_OP BIN_OP VAR NUMBER NUMBER RETURN NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR NONE EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN 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 ...
import sys t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = input() i = 0 l = [] el = 0 while i < n and s[i] == "L": i += 1 el += 1 j = n - 1 while j > i and s[j] == "L": j -= 1 el += 1 if i > j: print(max(0, 2 * k - 1)...
IMPORT 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 WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR STRING 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()) ans = 0 for i in range(1, n): if s[i] == "W": if s[i - 1] == "W": ans += 2 else: ans += 1 if s[0] == "W": ans += 1 k = min(k, s.cou...
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 FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR NUMBER STRING 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 solve(): n, k = map(int, input().split()) K = k s = list(input()) if s.count("W") + k > n: print(2 * n - 1) return if s.count("W") == 0: print(min(k, n) * 2 - 1 if k != 0 else 0) return arr = [] streak = 0 i = 0 while i < n: j = i w...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR STRING VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP FUNC_CALL 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 ...
t = int(input()) final = [] for _ in range(t): n, k = map(int, input().split()) s = input() st = 0 end = n - 1 sumw = s.count("W") if sumw == 0: if k >= n: final.append(str(n * 2 - 1)) elif k: final.append(str(k * 2 - 1)) else: final.ap...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP 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 ...
for t in range(int(input())): n, k = map(int, input().split()) h = input() if k >= h.count("L"): print(2 * n - 1) elif n == 0: print(0) elif "W" not in h: print(max(2 * k - 1, 0)) else: h = h.strip("L") n = len(h) score = 0 prev = "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 IF VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER 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()) a = input() b = [] b1 = [] c = [] t = 0 count = 0 ans = 0 m = n - 1 if a[0] == "L": while t < n and a[t] == "L": count += 1 t += 1 b1.append(count) count = 0 if a[-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 LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER STRING WHILE VAR VAR VAR VAR STRING 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 ...
def calculate(game): if not game: return 0 su = 1 if game[0] == "W" else 0 prev = game[0] for g in game[1:]: if g == "W": su += 2 if prev == "W" else 1 prev = "W" else: prev = "L" return su for t in range(int(input())): n, k = map(int...
FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR VAR NUMBER STRING NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR STRING VAR VAR STRING NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR STRING 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 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 i in range(t): n, m = map(int, input().split()) s = input() scoreinitial = 0 if s[0] == "W": scoreinitial += 1 for i in range(1, len(s)): if s[i] == "W" and s[i - 1] == "W": scoreinitial += 2 elif s[i] == "W": scoreinitial += 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 IF VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() s = list(s) cw = 0 w = [] idx = -1 cl = 0 fw = -1 lw = -1 ans = 0 for i in range(n): if s[i] == "W": if i > 0 and s[i - 1] == "W": 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR 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 VAR VAR IF 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 ...
for _ in range(int(input())): n, k = [*map(int, input().split())] s = input() c = s.count("W") z = [0] * (c + 1) x = 0 kk = k ans = 0 if c == 0 and k > 0: ans -= 1 for i in range(n): if i == 0: if s[i] == "W": ans += 1 if i != 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() check = [0] * (n + 1) loose = 0 a, b = 0, 0 wins, win_streak = 0, 1 c = 0 for i in s: if i == "L": c += 1 else: break for i in range(c, n): if s[i] == "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 FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER FOR 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 main(): t = int(input()) for _ in range(t): n, k = (int(x) for x in input().split()) s = input() print(solver(s, n, k)) def solver(s, n, k): cur_score = getCurScore(s) lcount = s.count("L") if lcount <= k: return 2 * n - 1 elif lcount == n: return ma...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR RETURN BIN_OP BIN_OP NUMBER 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 ...
t = int(input()) for i in range(t): n, k = map(int, input().split()) binstr = list(input()) losearr = [] current = 0 active = 0 wincntr = 0 for result in binstr: if result == "L": if active: wincntr += active active = 0 current ...
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 NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) ar = list(input()) fro = 0 bac = 0 li = [] for i in range(n): if ar[i] == "L": fro += 1 else: break for i in range(1, n + 1): if ar[-i] == "L": bac += 1 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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 = list(map(int, input().split())) s = input() k = min(k, s.count("L")) arr = [] cur = 0 sc = 0 se = False if s[0] == "W": sc += 1 for e in s: if e == "L": cur += 1 else: if cur > 0 and se: ...
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 ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER FOR VAR VAR IF 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 ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = input() if all(i == "L" for i in s): print(max(0, 2 * k - 1)) continue f = False if s[0] == "L": f = True cur = s[0] l = [] cnt = 1 f2 = True score = 0 for i in range(1, n): ...
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 FUNC_CALL VAR VAR STRING VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER 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 ...
t = int(input()) for inx in range(t): n, k = map(int, input().split()) l = input() b = sc = 0 g = [] p = "L" for c in l: if c == "W": if p == "W": sc += 2 else: sc += 1 p = "W" if b: g.append(...
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 NUMBER ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR VAR IF VAR STRING IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR STRING IF VAR EXPR 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 ...
def chess(string, n): temp = sorted(map(len, string.strip("L").split("W"))) m = len(temp) + n while temp and temp[0] <= n: n -= temp.pop(0) return (2 * min(len(string), m - 1) - len(temp) or 1) - 1 t = int(input()) for i in range(t): a, b = map(int, input().strip().split()) print(chess...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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 RETURN BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN 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): n, k = map(int, input().split()) s = str(input()) cw = 0 cnt = 0 lcount = -1 llen = dict() for i in range(n): if i == 0 and s[i] == "W": cnt += 1 lcount = 0 cw += 1 elif s[i] == "W": if s[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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN 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 ...
for x in range(int(input())): n, k = map(int, input().split()) string = list(input()) lose = [] count = 0 score, first, last = 0, 0, 0 for i in range(n - 1): if string[i] == string[i + 1]: count += 1 if i == n - 2: if string[i] == "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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP 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 t in range(int(input())): n, k = [int(i) for i in input().split()] wd = input() sc = 0 if wd[0] == "W": sc += 1 ls = [] l_cnt = 0 for i in range(1, n): if wd[i] == "W": if wd[i - 1] == "W": sc += 2 else: sc += 1 ...
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 NUMBER IF VAR NUMBER STRING VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER 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 ...
for _ in range(int(input())): a, b = map(int, input().split()) s = input() if s == "L" * a: if b: print(b * 2 - 1) else: print(0) elif s == "W" * a: print(a * 2 - 1) else: ans = 0 fst, lst = -1, -1 if s[0] == "W": an...
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 BIN_OP STRING VAR IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER 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 ...
def solve(): n, k = map(int, input().split()) s = input() wn = 0 for c in s: if c == "W": wn += 1 ln = 0 c = 0 while c < n and s[c] == "L": c += 1 ln += 1 a = c c = len(s) - 1 ln = 0 while c >= 0 and s[c] == "L": c -= 1 ln +...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE 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 w in range(int(input())): n, k = tuple(map(int, input().split())) s = str(input()) if k == n: print(1 + 2 * (n - 1)) elif n == 1 and k > 0: print(1) elif n == 1 and k == 0: if s[0] == "W": print(1) else: print(0) elif k >= s.count("L"):...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF 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 i in range(int(input())): n, k = map(int, input().split()) lst = input() count = 0 last = -1 ans = [] for i in range(len(lst)): if lst[i] == "L": continue count += 1 if last != -1 and last != i - 1: ans += [i - last - 1] last = i an...
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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR LIST BIN_OP BIN_OP 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 ...
from itertools import groupby for _ in range(int(input())): n, k = map(int, input().split()) s = input() if k >= s.count("L"): print(n * 2 - 1) else: s = s.strip("L") group = [] for i, g in groupby(s): if i == "L": group.append(len(list(g))) ...
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 FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR 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 ...
def solve(): n, k = map(int, input().split()) s = input()[:n] z = s.count("W") leftL = n - z if z == 0: if k != 0: print(1 + 2 * (k - 1)) else: print(0) else: total = 0 for i in range(n): if s[i] == "W": if i - 1...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF 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 it in range(0, t): n, k = tuple(list(map(int, input().split(" ")))) results = [char for char in input()] initial_score = 0 loss_amount = 0 for i in range(0, len(results)): if i > 0 and results[i] == "W" and results[i - 1] == "W": initial_score += 1 if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING VAR 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 ...
t = int(input()) arr = [0] for i in range(t): n, sm = map(int, input().split()) count = 0 count1 = 0 count2 = -2 a = input() arr.clear() for j in range(n): if a[j] == "W": count += 1 count1 += 1 if count2 + 1 == j: count1 += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP 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 _ in range(t): n, k = map(int, input().split()) a = list(input()) m = a.count("L") d = a.count("W") if m <= k: print(2 * (n - 1) + 1) continue if d == 0: print(max(2 * (k - 1) + 1, 0)) else: for i in range(n): if a[i] == "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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER 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 ...
for test in range(int(input())): [n, k] = list(map(int, input().split(" "))) s = input() w = False l = 0 sl = [] pg = False res = 0 z = 0 ko = 0 for r in s: if r == "W": if pg: res += 2 else: res += 1 pg ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN 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 FOR VAR VAR IF VAR STRING IF 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 ...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n, k = mints() i = 0 p = None pos = [] a = list(minp()) for i in range(n): if a[i] == "W": if p is not None:...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ...
import sys for _ in range(int(sys.stdin.readline())): N, k = map(int, sys.stdin.readline().split()) arr = list(map(str, input().strip())) dic = [] temp = k lose = 0 streak = 0 if "W" not in arr: print(max(0, 2 * k - 1)) elif "L" not in arr: print(2 * N - 1) else: ...
IMPORT 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 VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP 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 ...
import sys as _sys WIN = "W" LOSE = "L" def main(): t = int(input()) for i_t in range(t): n, k = _read_ints() s = _read_line() result = find_max_score_after_changing(s, k) print(result) def _read_line(): result = _sys.stdin.readline() assert result[-1] == "\n" re...
IMPORT ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER STRING RETURN VAR NUMBER FUNC_DEF RETURN 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) a = input() bet = [] score = 0 counter = 0 total = 0 flag = -1 for x in a: if x == "W": if flag == 0: bet.append(counter) counter = 0 if flag <= 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 LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER 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()) def binsearch(nums, target): left = 0 right = len(nums) - 1 while left <= right: mid = (left + right) // 2 if nums[mid] == target: return mid elif nums[mid] > target: right = mid - 1 elif nums[mid] < target: left = mid + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN 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 j in range(int(input())): n, k = map(int, input().split()) r = input() a = [] t = r[0] s = 1 for i in range(1, n): if r[i] == t: s += 1 else: a.append([t, s]) t = r[i] s = 1 a.append([t, s]) b = [] h = len(a) s =...
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 LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR VAR ASSIGN 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 ...
def cheat(n, k, origames): kk = k Llis, Wlis = origames.split("W"), origames.split("L") Wlis = sorted(Wlis, key=lambda x: len(x)) if Wlis[-1] == "": if 2 * k - 1 >= 0: return 2 * k - 1 else: return 0 if k >= origames.count("L"): return 2 * len(origames...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING IF BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER RETURN BIN_OP BIN_OP NUMBER VAR NUMBER RETURN NUMBER IF VAR FUNC_CALL VAR STRING RETURN BIN_OP BIN_OP NUMBER FUNC_CALL VAR 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 ...
t = int(input()) for _ in range(t): n, K = map(int, input().split()) s = input() diff = [0] * (n + 1) prev = 0 I = 0 J = n - 1 flag1, flag2 = True, True for k in range(n): if s[k] == "W": I = k flag1 = False break for k in range(n - 1, -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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF 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().strip() for i in range(int(input())): n, k = map(int, input().split()) a = list(input()) ans = [0] lol = [0] lk = 0 if len(a) == 1: if a[0] == "W": print(1) elif k: print(1) else: print(0...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() ar = [] i = 0 single = [] while i < n and s[i] == "L": i += 1 if i == n: if k > 0: print(k * 2 - 1) else: print(0) continue if i != 0: single.append(...
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 LIST ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL 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 ...
def solve(): n, k = map(int, input().split()) s = input() ans = 0 prev = False c = [] cc = 0 for i in range(n): if s[i] == "W": if cc: if cc != i: c.append(cc) cc = 0 if prev: ans += 2 ...
FUNC_DEF 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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()) tests = [] for i in range(t): n, k = map(int, input().split()) s = input() tests.append([n, k, s]) for test in tests: n, k, s = test result = 0 w = s.count("W") if w == 0: if k == 0: print(0) else: print(min(n, k) * 2 - 1) cont...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR 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 ...
t = int(input()) tag = [] for i in range(t): n, k = map(int, input().split()) s = input() cur, ans = k + 5, 0 tag.clear() for j in range(n): if s[j] == "L": cur += 1 else: ans += 1 if cur > 0 else 2 if cur > 0: tag.append(cur) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR VAR NUMBER NUMBER 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 ...
def main(): n, k = map(int, input().split()) line = input() was = False prev = False res = 0 before = 0 spare_sizes = [] sz = 0 for i in line: if not was: if i == "L": before += 1 else: was = True if was: ...
FUNC_DEF 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 LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR 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(m) for m in input().split()] s = list(input()) firstwin = s.index("W") if "W" in s else -1 if firstwin == -1: print(max(min(k, len(s)) * 2 - 1, 0)) continue left = firstwin noleft = True A = [] front, back = None, None i...
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 STRING VAR FUNC_CALL VAR STRING NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER 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 readline = sys.stdin.readline T = int(readline()) Ans = [None] * T for qu in range(T): N, K = map(int, readline().split()) S = [(1 if s == "W" else 0) for s in readline().strip()] if all(s == 0 for s in S): Ans[qu] = max(0, 2 * K - 1) continue ans = 0 ctr = 0 st = [] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER BIN_OP B...
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 ii in range(t): n, k = map(int, input().split()) s = input() a = [0] * n for i in range(n): if s[i] == "W": if i == 0: a[i] = 1 elif a[i - 1] != 0: a[i] = 2 else: a[i] = 1 stretch = [] ...
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 LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR 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 ...
a = int(input()) for k in range(a): b, n = [int(k) for k in input().split()] r = input() len_r = len(r) p_W = [] for x in range(len_r): if r[x] == "W": p_W.append(x) len_p_W = len(p_W) l_d = [] for y in range(len(p_W) - 1): d = p_W[y + 1] - p_W[y] l_d....
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 FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR 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 ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = list(input()) w = 0 for x in s: if x == "W": w += 1 if k >= n - w: print(1 + (n - 1) * 2) else: a = -1 b = -3 for i in range(n): if s[i] == "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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER 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 ...
for t in range(int(input())): n, k = map(int, input().split()) a = input() b = [0] * n s = 0 c = 0 w = a.count("W") if k >= n - w: print(2 * n - 1) elif w == 0: print(max(0, 2 * k - 1)) else: f = a.find("W") for i in range(f, n): if a[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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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...
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(): x, y = map(int, input().split()) s = list(input()) v = [] ind = -1 ct = 0 st = 0 for n in range(len(s)): if s[n] == "L": if st: if ind == -1: ind = n ct += 1 else: if ct: ...
FUNC_DEF 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR LIST VAR VAR A...
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 ...
TC = int(input()) for tc in range(TC): N, K = map(int, input().split()) S = list(input()) w = 0 l = [] rw = 0 rl = 0 start = 0 for s in S: if s == "W": if rl > 0: if w > 0: l.append(rl) else: star...
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 LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR 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 case in range(T): m, n = [int(x) for x in input().split()] s = input() lsw = sorted([x for x in s.split("L") if len(x)]) points = 0 for e in lsw: points += len(e) * 2 - 1 ll = [x for x in s.split("W") if len(x)] ends = 0 if s[0] == "L": ends += len(ll...
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 FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR 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 ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = list(input()) ind = [] ans = 0 for i in range(n): if s[i] == "W": ind.append(i) if i - 1 >= 0 and s[i - 1] == "W": ans += 1 ans += 1 if k == 0: print(ans) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING 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 ...
import sys input = lambda: sys.stdin.readline().rstrip() for _ in range(int(input())): n, k = [int(i) for i in input().split()] s = [i for i in input()] if s.count("W") == 0: print(max(2 * k - 1, 0)) continue if s[0] == "W": ans = 1 else: ans = 0 for i in range(1...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF 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 find_consecutive_lose_rounds(match_log): lose_sections_length = [] start_winning = False length = 0 original_point = 0 for i in range(len(match_log)): char = match_log[i] if char == "L": length += 1 start_winning = False else: if start_...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN 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 ...
t = int(input()) for case in range(t): n, k = map(int, input().split()) s = input().split()[0] prev = "L" score = 0 curr = 0 l = [] foundW = False for i in range(n): if s[i] == "W": foundW = True if curr != 0: l.append(curr) 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 FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF 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 reverse(li, i, k): i -= 1 t = 0 while k > 0 and i >= 0: if li[i] == "L": li[i] = "W" t += 1 else: return t i -= 1 k -= 1 return t def process(): n, k = list(map(int, input().split())) li = list(input()) if n == 1 and k...
FUNC_DEF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER RETURN VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR 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 = list(map(int, input().split())) arr = list(input()) last = False tot = 0 for i in range(n): if arr[i] == "W": if last: tot += 2 else: tot += 1 last = True else: la...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() a = [] prev = -1 for i in range(n): if s[i] == "W": if prev != -1 and i != prev + 1: a.append((prev, i - 1)) prev = i a.sort(key=lambda x: x[1] - x[0]) ans = 0 if s[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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR EXPR 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 = sys.stdin.readline def compress(string): string = string + "#" n = len(string) begin, end, cnt = 0, 1, 1 ans = [] while end < n: if string[begin] == string[end]: end, cnt = end + 1, cnt + 1 else: ans.append((string[begin], cnt)) ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR A...
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 itertools def remove_beginning(lst, bad): idx = 0 while lst[idx] == bad: idx += 1 if len(lst) == idx: break return idx def solve(): n, k = [int(x) for x in input().strip().split()] game_scores = list(input().strip()) win, lose = "W", "L" first_good_pos ...
IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR 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 ...
class Streak: def __init__(self, start_ind, end_ind): self.start_ind = start_ind self.end_ind = end_ind class StreakNbors: def __init__(self, streak_a, streak_b): self.streak_a = streak_a self.streak_b = streak_b def get_gap(self): return self.streak_b.start_ind ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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 ...
t = int(input()) def answer(n, k, s): win = [] for i in range(n): if s[i] == "W": win.append(i) l = len(win) if l <= 1: print(min(max(2 * (k + l) - 1, 0), 2 * n - 1)) elif win[-1] - l + 1 <= k: ans = min(2 * (k + l) - 1, 2 * n - 1) print(ans) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF 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 ...
import sys t = int(sys.stdin.readline().strip()) for _ in range(t): arr = [] n, k = map(int, sys.stdin.readline().strip().split()) s = input() ind = 0 while ind != n and s[ind] == "L": ind += 1 if ind == n: if k >= n: print(2 * n - 1) else: print(...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER 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 t = int(input()) for _ in range(t): [n, k] = list(map(int, input().split())) temp = 0 for line in sys.stdin: s = line break prev = "L" current = "L" lsum = 0 tempsum = 0 losses = [] startind = 0 endind = n - 1 while startind != n and s[startind] ==...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP 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().replace("\n", "")) for i in range(t): line1 = list(map(int, input().replace("\n", "").split(" "))) n = line1[0] k = line1[1] s = list(input().replace("\n", "")) wins, losses, gap_wins = 0, 0, 0 losses_gaps_len = [] for i in range(n): if s[i] == "W": if i =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() L = s.count("L") W = s.count("W") if L <= k: print(2 * (n - 1) + 1) continue if L == n and k != 0: print((k - 1) * 2 + 1) continue count = 0 p = 0 if s[0] == "W": count ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR 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 ...
for _ in range(int(input())): n, k = map(int, input().split(" ")) s = input() if s[0] == "W": score = 1 else: score = 0 for i in range(1, n): if s[i] == "W": if s[i - 1] == "W": score = score + 2 else: score = score + 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR B...
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() ans = 0 prev = "L" for i in s: if i == "W" and prev == "W": ans += 2 elif i == "W": ans += 1 prev = i temp = [] a = 0 b = 0 x = 0 y = 0 for i in s:...
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 STRING FOR VAR VAR IF VAR STRING VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST 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 ...
t = int(input()) for x in range(t): n, k = input().split(" ") n = int(n) k = int(k) s = input() count_ = s.count("W") calculate = 0 prev = 0 li = [] pre = -1 for x in range(n): if s[x] == "W": if pre == -1: pre = x calculate = 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() if s.count("W") == n: print(2 * n - 1) elif s.count("L") == n: print(max(2 * k - 1, 0)) else: score = 0 if s[0] == "W": score += 1 for i in range(1, n): 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 IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN 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 i in range(int(input())): n, k = map(int, input().split()) s = input() wins = s.count("W") + k if wins >= n: print(2 * n - 1) else: streaks = int(s[0] == "W") + s.count("LW") or int(wins > 0) gaps = s.strip("L").replace("W", " ").strip().split() for g in sorted(ma...
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 BIN_OP FUNC_CALL VAR STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING FUNC_CALL VAR STRING 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 ...
import sys t = int(input()) for i in range(t): n, k = map(int, input().split()) s = sys.stdin.readline().strip() s = list(s) q = 0 p = [] for j in range(n): if s[j] == "W": if q > 0: p.append([q, j - 1]) q = 0 else: q = q + 1 ...
IMPORT 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR 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 ...
import sys input = sys.stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) s = input() s = [s[i] for i in range(n)] base = s.count("W") if base == 0: if k: print(2 * k - 1) else: print(0) elif base + k >= n: print(2 * n -...
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 VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL 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 ...
t = int(input()) def cheatScore(s, n, k): lose = 0 score = 0 start = 0 tmp = [] flag = 0 Alllose = 1 for c in s: if c != "W": continue else: Alllose = 0 break if Alllose: return max(0, 2 * min(n, k) - 1) for i in range(len...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER IF VAR RETURN FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR 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 ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() ans, t, b, f = 0, 0, 0, 0 l = [] for i in range(n): if s[i] == "W": ans += f + 1 f = 1 if b: l.append(b) b = 0 else: f = 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 VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR ASSIGN ...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
def resi(): n, k = map(int, input().split()) a = list(map(int, input().split())) s = sum(a) for i in range(n): a[i] = a[i] - (n - (i + 1)) a.sort() print(s - sum(a[-k:]) - k * (k - 1) // 2) return for _ in range(int(input())): resi()
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 VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
for _ in range(int(input())): n, k = map(int, input().split()) l = [int(i) for i in input().split()] ll = sorted([(-l[i] + (n - 1 - i)) for i in range(n)]) base = sum(l) poss = [base] for i in range(k): base += ll[i] - i poss.append(base) print(min(poss))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CAL...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
for _ in range(int(input())): n, k = map(int, input().split()) l = list(map(int, input().split())) t = [] for i in range(n): t.append([l[i] - (n - i - 1), i]) t = sorted(t)[::-1] x = [(0) for _ in range(n)] for i in range(k): x[t[i][1]] = 1 ans = 0 p = 0 for i in ...
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 VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUM...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
for _ in range(int(input())): n, k = map(int, input().split()) d = list(map(int, input().split())) sm = sum(d) for i in range(n): d[i] = -d[i] + (n - 1 - i) d.sort() for i in range(k): sm += d[i] - i print(sm)
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 VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FOR VAR FUNC_...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
def find_minimal_damage_count(n, jumps, attacks): damageCount = 0 if n == jumps: return damageCount for i in range(n): damageCount += attacks[i] attacks[i] += i + 1 attacks.sort() attacks.reverse() for i in range(jumps): damageCount -= attacks[i] damageCou...
FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR S...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) traps = list(map(int, input().split())) if k >= n: print(0) continue sortedred = [] for i in range(n): sortedred.append((i, traps[i] - (n - i - 1))) sortedred.sort(key=lambda x: x[1], reverse=True) t...
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 IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP ...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
for _ in range(int(input())): n, k = [int(i) for i in input().split()] A = [int(i) for i in input().split()] res = sum(A) - k * (k - 1) // 2 for i in range(n): A[i] -= n - i - 1 A.sort() for i in range(k): res -= A[-i - 1] print(res)
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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_...
There are $n$ traps numbered from $1$ to $n$. You will go through them one by one in order. The $i$-th trap deals $a_i$ base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than $k$ traps. If you jump over a trap, it does not deal any damage to you. But there is an addit...
def getMin(d, k): l = [] for i in range(len(d)): penalty = len(d) - i l.append((d[i] - penalty, i)) l.sort(reverse=True) total = 0 indices = set([l[i][1] for i in range(k, len(d))]) penalty = 0 for i in range(len(d)): if i in indices: total += d[i] + penal...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL...