Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.table = [-1 for _ in range(n)]

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1<=d2:
            self.table[r2] = r1
            if d1==d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2

n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(n):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.union(x, y)

ans = 0
for v in uf.table:
    if v<0:
        ans += 1
print(ans)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.table = [-1 for _ in range(n)]

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1<=d2:
            self.table[r2] = r1
            if d1==d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2

n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.union(x, y)

ans = 0
for v in uf.table:
    if v<0:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
dist = [0]*5
for i in range(5):
    dist[i] = int(input())
k = int(input())

for i in range(5):
    for j in range(i):
        if abs(dist[j]-dist[i]) > k:
            exit(":(")

print("Yay!")

Fixed submission:
dist = [0]*5
for i in range(5):
    dist[i] = int(input())
k = int(input())

for i in range(5):
    for j in range(i):
        if abs(dist[j]-dist[i]) > k:
            print(":(")
            exit()

print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
V = list(map(int, input().split()))

Odd, Evn = [], []
for i in range(n):
    Evn.append(V[i]) if i%2 == 0 else Odd.append(V[i])
Evn = sorted( dict(Counter(Evn)).items(), key = lambda x:x[1])
Odd = sorted( dict(Counter(Odd)).items(), key = lambda x:x[1])

cnt = -1
for evn in Evn:
    for odd in Odd:
        if evn[0] != odd[0]:
            cnt = max(cnt, evn[1]+odd[1])
print(n-cnt) if cnt > 0 else print(n//2)

Fixed submission:
from collections import Counter
n = int(input())
V = list(map(int, input().split()))

Odd, Evn = [], []
for i in range(n):
    Evn.append(V[i]) if i%2 == 0 else Odd.append(V[i])
Evn = sorted( dict(Counter(Evn)).items(), key = lambda x:x[1], reverse=True)
Odd = sorted( dict(Counter(Odd)).items(), key = lambda x:x[1], reverse=True)

cnt = -1
for evn in Evn[0:2]:
    for odd in Odd[0:2]:
        if evn[0] != odd[0]:
            cnt = max(cnt, evn[1]+odd[1])
print(n-cnt) if cnt > 0 else print(n//2)
Buggy python submission (verdict: Runtime Error):
chokudai
redcoder

Fixed submission:
S = input()
T = input()
d0, d1 = {}, {}
for s, t in zip(S, T):
    if s in d0:
        if d0[s] != t:
            print('No')
            exit()
    elif t in d1:
        if d1[t] != s:
            print('No')
            exit()
    else:
        d0[s] = t; d1[t] = s
print('Yes')
Buggy python submission (verdict: Runtime Error):
a, b = min(map(int, input().split()))
print(a) if a <= b else print(a-1)

Fixed submission:
a, b = map(int, input().split())
print(a) if a <= b else print(a-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ary = [0 for _ in range(10**5)]

for i in range(n):
    ary[a[i]-1] += 1
    ary[a[i]] += 1
    ary[a[i]+1] += 1

print(max(ary))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ary = [0 for _ in range(10**5)]

for i in range(n):
    if a[i] > 1:
        ary[a[i]-2] += 1
        ary[a[i]-1] += 1
    ary[a[i]] += 1

print(max(ary))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ary = []

for i in range(n):
    ary.append(a[i]-1)
    ary.append(a[i])
    ary.append(a[i]+1)

maxcount = 1
for i in ary:
    if ary.count(i) > maxcount:
        maxcount = ary.count(i)

print(maxcount)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ary = [0 for _ in range(10**5)]

for i in range(n):
    if a[i] > 1:
        ary[a[i]-2] += 1
        ary[a[i]-1] += 1
    ary[a[i]] += 1

print(max(ary))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ary = []

for i in range(n):
    ary.append(a[i]-1)
    ary.append(a[i])
    ary.append(a[i]+1)

maxcount = 1
for i in range(10**5):
    if ary.count(i) > maxcount:
        maxcount = ary.count(i)

print(maxcount)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ary = [0 for _ in range(10**5)]

for i in range(n):
    if a[i] > 1:
        ary[a[i]-2] += 1
        ary[a[i]-1] += 1
    ary[a[i]] += 1

print(max(ary))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
import sys
input = sys.stdin.readline

n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans*x//gcd(ans, x)
print(ans)

Fixed submission:
from fractions import gcd
import sys
input = sys.stdin.readline

n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans*t//gcd(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a

    return gcd(b, a%b)

N = int(input())
t = []
for _ in range(N):
    t.append(int(input()))

lcm = max(t)

for i in range(N):
    if lcm % t[i] != 0:
        lcm = lcm * t[i] / gcd(lcm, lcm%t[i])

print(int(lcm))

Fixed submission:
from fractions import gcd
import sys
input = sys.stdin.readline

n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans*t//gcd(ans, t)
print(ans)
Buggy python submission (verdict: Runtime Error):
last = input()
if input[1] == "B":
  print("ARC")
else:
  print("ABC")

Fixed submission:
S = input()
if S[1] == "B":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
ans = 0
while True:
  if N >= A:
    ans += A
    N -= A + B
  else:
    ans += max(N, 0)
    break
print(ans)
  

Fixed submission:
N, A, B = map(int, input().split())
ans = (N // (A+B)) * A + min(A, N%(A+B))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S = input()
S = [S[i] for i in range(len(S))]
S = deque(S)                         
Q = int(input())
rev = 1
for i in range(Q):
  comm = input()
  if comm == "1":
    rev *= -1
  else:
    T, F, C = comm.split()
    F = int(F) * 2 - 3
    if rev * F == 1:
      S.append(C)
    else:
      S.appendleft(C)
ans = ""
for i in range(len(S)):
  ans += S[i * rev + (rev-1) // 2]
print(ans)
      

Fixed submission:
from collections import deque
S = input()
S = [S[i] for i in range(len(S))]
S = deque(S)                         
Q = int(input())
rev = 1
for i in range(Q):
  comm = input()
  if comm == "1":
    rev *= -1
  else:
    T, F, C = comm.split()
    F = int(F) * 2 - 3
    if rev * F == 1:
      S.append(C)
    else:
      S.appendleft(C)
S = list(S)
ans = ""
for i in range(len(S)):
  ans += S[i * rev + (rev-1) // 2]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S = input()
S = [S[i] for i in range(len(S))]
S = deque(S)                         
Q = int(input())
rev = 1
for i in range(Q):
  comm = input()
  if comm == "1":
    rev *= -1
  else:
    T, F, C = comm.split()
    F = int(F) * 2 - 3
    if rev * F == 1:
      S.append(C)
    else:
      S.appendleft(C)
ans = ""
for i in range(len(S)):
  ans += S[i * rev + (rev-1) // 2]
print(ans)
      

Fixed submission:
from collections import deque
S = input()
S = [S[i] for i in range(len(S))]
S = deque(S)                         
Q = int(input())
rev = 1
for i in range(Q):
  comm = input()
  if comm == "1":
    rev *= -1
  else:
    T, F, C = comm.split()
    F = int(F) * 2 - 3
    if rev * F == 1:
      S.append(C)
    else:
      S.appendleft(C)
S = list(S)
ans = ""
for i in range(len(S)):
  ans += S[i * rev + (rev-1) // 2]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))
D = [sum(p[i:i+K]) for i in range(N-K+1)]
print(max(D) / 2 + 0.5 * K)

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
D = [sum(p[0:K])]
if N-K >= 1:
  for i in range(1, N-K+1):
    D.append(D[-1] - p[i-1] + p[i+K-1])
#print(D)
print(max(D) / 2 + 0.5 * K)
Buggy python submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
K = int(input())
A = []
ans = 1


for i in range(K):
  n = int(str(N)[0])
  dig = len(str(N)) - 1
  A.append([n, dig])
  N -= n * 10**dig


for i in range(K):
  if A[i][1] >= K-i:
    ans += comb(A[i][1], K-i) * 9 ** (K-i) 
  ans += (A[i][0]-1) * comb(A[i][1], K-i-1) * 9 ** (K-i-1)
#  print(ans)

print(ans)

Fixed submission:
import math
def comb(n, r):
  if n >= r:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  else:
    return 0
N = int(input())
K = int(input())
A = []
ans = 0


for i in range(K):
  n = int(str(N)[0])
  dig = len(str(N)) - 1
  A.append([n, dig])
  N -= n * 10**dig
  if N == 0:
    break
#print(A)

for i in range(len(A)):
  if A[i][1] >= K-i:
    ans += comb(A[i][1], K-i) * 9 ** (K-i) 
#    print(ans)
  ans += (A[i][0]-1) * comb(A[i][1], K-i-1) * 9 ** (K-i-1)
#  print(ans)
if len(A) == K:
  ans += 1


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])


Fixed submission:
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

  print(mp_min)

print(mp_min[-1])


Fixed submission:
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
m = min([ATK[i][1] for i in range(N)])
mp_min = [0]
if m < H:
  for hp in range(1, H+1):
    mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

    #print(mp_min)

  print(mp_min[-1])
else:
  print(min([ATK[i][1] for i in range(N) if ATK[i][0] >= H]))

Fixed submission:
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
ATK = []
dmg_max = []
mp = 0
for i in range(N):	
  ATK.append(list(map(int, input().split())))

while True:
  dmg_max.append(max([dmg_max[mp-ATK[i][1]] + ATK[i][0] for i in range(N) if mp - ATK[i][1] >= 0] + [0]))
  if dmg_max[-1] >= H:
    break
  mp += 1
  #print(dmg_max)

print(mp)


Fixed submission:
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])
Buggy python submission (verdict: Runtime Error):
K, X= map(int, input().split())
if K * 500 >= X:
  print("Yes")
else:
  prine("No")

Fixed submission:
K, X= map(int, input().split())
if K * 500 >= X:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
K, X= map(int, input().split())
if K * 500 > X:
  print("Yes")
else:
  prine("No")

Fixed submission:
K, X= map(int, input().split())
if K * 500 >= X:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import fractions:
A, B = map(int, input().split())
C = fractions.gcd(A, B)
print(A * B // C)

Fixed submission:
import fractions
A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
import fractions:
A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
n = 1
p = 0
for i in range(max(a)):
  if not n in a[p:]:
    break
  else:
    p = a[p:].index(n) + 1
    n += 1
if n == 1:
  print(-1)
else:
  print(N - n + 1)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
K = 0
p = 0
bricks = [[] for i in range(N)] #iと書かれたレンガがどこにあるか

for i in range(N):
  bricks[a[i] - 1].append(i)

for i in range(N):
  if len(bricks[i]) == 0:
    break
  elif bricks[i][-1] < p:
    break
  else:
    for j in bricks[i]:
      if j >= p:
        p = j
        K += 1
        break
if K == 0:
  print(-1)
else:
  print(N - K)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)

Fixed submission:
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [[0, 0] for i in range(60)]
for a in A:
  for i in range(60):
    digit[i][int(a[i])] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i][0] * digit[i][1])
print(ans %Num)

Fixed submission:
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [[0, 0] for i in range(60)]
for a in A:
  for i in range(60):
    digit[i][int(a[i])] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i][0] * digit[i][1]) % Num
print(ans)

Fixed submission:
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [[0, 0] for i in range(60)]
for a in A:
  for i in range(60):
    digit[i][int(a[i])] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i][0] * digit[i][1]) % Num
print(ans)

Fixed submission:
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = ""
for s in S:
  ans += chr((ord(S) + N - 65)%26 + 65)
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = ""
for s in S:
  ans += chr((ord(s) + N-65)%26 + 65)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
arr = [0] * N
for i in range(N):
  arr[i] = A.index(i+1) + 1
print(*arr)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
arr = {}
for i in range(N):
  arr[A[i]] = i + 1
for i in range(N):
  print(arr[i+1], end="")
  if i == N-1:
    print("\n", end="")
  else:
    print(" ",end="")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(M):
  A[0] //= 2
  if N > 1:
    j = 0
    while A[j] < A[j+1]:
      A[j], A[j+1] = A[j+1], A[j]
      j += 1
      if j == N-2:
        break
#  print(A)
print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)
for i in range(M):
  m = heapq.heappop(A)
  heapq.heappush(A, (-m // 2) * (-1))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(M):
  A[0] //= 2
  if N > 1:
    if A[0] < A[1]:
      A.sort(reverse=True)
print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)
for i in range(M):
  m = heapq.heappop(A)
  heapq.heappush(A, (-m // 2) * (-1))

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]]
  if memory + 1 == A[i]:
    happiness += C[A[i]-1]
  memory = A[i]
print(happiness)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]-1]
  if memory + 1 == A[i]:
    happiness += C[A[i]-2]
  memory = A[i]
print(happiness)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]]
  if memory + 1 == A[i]:
    happiness += C[A[i]]
  memory = A[i]
print(happiness)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]-1]
  if memory + 1 == A[i]:
    happiness += C[A[i]-2]
  memory = A[i]
print(happiness)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int, input().split())
B = list(int, input().split())
C = list(int, input().split())
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]]
  if memory + 1 == A[i]:
    happiness += C[A[i]]
  memory = A[i]
print(happiness)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]-1]
  if memory + 1 == A[i]:
    happiness += C[A[i]-2]
  memory = A[i]
print(happiness)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input.split())
S = input()
ans = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    ans += 1
print(min(N-1, ans + 2 * K))

Fixed submission:
N, K = map(int,input().split())
S = input()
ans = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    ans += 1
print(min(N-1, ans + 2 * K))

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input.split())
S = input()
ans = 0
for i in range(N):
  if S[i] == S[i+1]:
    ans += 1
print(min(N-1, ans + 2 * K))

Fixed submission:
N, K = map(int,input().split())
S = input()
ans = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    ans += 1
print(min(N-1, ans + 2 * K))
Buggy python submission (verdict: Runtime Error):
N = input()
print(N * (N - 1)/2)

Fixed submission:
N = int(input())
print((N - 1) * N // 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input()))
L.sorted
ans = reduce(lambda x, y: (x + y)/2, L)
print(ans)

Fixed submission:
from functools import reduce
N = int(input())
L = list(map(int, input().split()))
L.sort()
print(reduce(lambda x, y: (x + y)/2, L))