Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02713 (python)

Fixed submission:
from math import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
K = int(input())
ans1 = 0
ans2 = 0
ans3 = 0
for a in range(1, K + 1):
  for b in range(a, K + 1):
    for c in range(b, K + 1):
      if a == b and b == c:
        ans1 += gcds(a, b, c)
      elif a == b or b == c or c == a:
        ans2 += gcds(a, b, c)
      else:
        ans3 += gcds(a, b, c)
print(ans1 + 3 * ans2 + 6 * ans3)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
def gcds(numbers):
  return reduce(gcd, numbers)
K = int(input())
ans = 0
for a in range(1, K + 1):
  for b in range(1, K + 1):
    for c in range(1, K + 1):
      ans += gcds(a, b, c)
print(ans)
Problem p02714 (python)

Fixed submission:
def main():
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = 2 * j - i
            if k >= N:
                continue
            if S[j] != S[i] and S[i] != S[k] and S[k] != S[j]:
                cnt += 1
    print(S.count("R") * S.count("B") * S.count("G") - cnt)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    S = input()
    R = set()
    G = set()
    B = set()
    for i,s in enumerate():
        if s == "R":
            R.add(i)
        elif s == "B":
            B.add(i)
        else:
            G.add(i)
    ans = 0
    for r in R:
        for b in B:
            for g in G:
                k = max(r, b, g)
                i = min(r, b, g)
                j = r + b + g - k - i
                if j - i != k - j:
                    ans += 1
    print(ans)

if __name__ == "__main__":
    main()
Problem p02718 (python)

Fixed submission:
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
all = sum(A)
L = len(A)
for a in A:
  if all / (4 * M) > a:
    L -= 1
  else:
    break
print("Yes" if L >= M else "No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = deque(sorted(list(map(int, input().split()))))
for a in A:
  if N / (4 * M) > a:
    A.pop()
  else:
    break
print("Yes" if len(A) >= M else "No")
Problem p02760 (python)

Fixed submission:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
L = []
L.append({a, b, c})
L.append({d, e, f})
L.append({g, h, i})
L.append({a, d, g})
L.append({b, e, h})
L.append({c, f, i})
L.append({a, e, i})
L.append({c, e, g})
N = int(input())
B = {int(input()) for i in range(N)}
if any(l <= B for l in L):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
L = ()
L.append(set(map(int, input().split())))
L.append(set(map(int, input().split())))
L.append(set(map(int, input().split())))
L.append((L[0][0], L[1][0], L[2][0]))
L.append((L[0][1], L[1][1], L[2][1]))
L.append((L[0][2], L[1][2], L[2][2]))
L.append((L[0][0], L[1][1], L[2][2]))
L.append((L[0][2], L[1][1], L[2][0]))
N = int(input())
B = (int(input()) for i in range(N))
if any(B >= l for l in L):
  print("Yes")
else:
  print("No")
Problem p02761 (python)

Fixed submission:
from sys import exit
N, M = map(int, input().split())
ans = ["a" for i in range(N)]
if M == 0:
  print(10 ** (N - 1) if N > 1 else 0)
  exit()
for i in range(M):
  s, c = map(int, input().split())
  if ans[s - 1] == "a":
    ans[s - 1] = str(c)
  elif ans[s - 1] != str(c):
    print(-1)
    exit()
if ans[0] == "a":
  ans[0] = "1"
if ans[0] == "0":
  if N != 1:
    print(-1)
    exit()
  else:
    print(0)
    exit()
ans = [a.replace("a", "0") for a in ans]
ans = int("".join(ans))
print(ans if 10 ** N > ans >= 10 ** (N - 1) else -1)

Buggy submission (verdict: Runtime Error):
from sys import exit
n, m = map(int, input().split())
X = ["" for _ in range(10)]
for _ in range(m):
    c, s = map(int, input().split())
    if X[c] != "" and X[c] != str(s):
        print(-1)
        exit()
    X[c] = str(s)
flag = False
for i in range(1, 11):
    if X[-i] == "":
        if flag:
            X[-i] = "0"
    else:
        flag = True
X = int("".join(X))
print(X if 10 ** (n - 1) <= X < 10 ** n else - 1)
Problem p02780 (python)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(len(P) - K):
  ans = max(sum(P[i:i + K - 1], ans))
print((ans + K) / 2)
Problem p02797 (python)

Fixed submission:
N, K, S = map(int, input().split())
U = str(S + 1) if S != 10 ** 9 else "1"
S = str(S)
ans = [S if i <= K - 1 else U for i in range(N)]
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
ans = [S if i <= K - 1 else 1 for i in range(N)]
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
ans = [S for i in range(N) if i =< K - 1 else 0]
print(" ".join(ans))
Problem p02804 (python)

Fixed submission:
from functools import lru_cache
n, k = map(int, input().split())
A = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
# 階乗とその逆元の計算
factrial = [0 for _ in range(n + 1)]
factrial[0] = 1
for i in range(1, n + 1):
    factrial[i] = (factrial[i - 1] * i) % mod
inverse_factrial = list()
for f in factrial:
    inverse_factrial.append(pow(f, -1, mod))


@lru_cache(maxsize=None)
def nCr(n, r):
    return (factrial[n] * inverse_factrial[r] * inverse_factrial[n - r]) % mod


ans = 0
# 最大値の和
for i, a in enumerate(A[k - 1:], k - 1):
    ans += ((a % mod) * nCr(i, k-1)) % mod
    ans %= mod
# 最小値の和
A.reverse()
for i, a in enumerate(A[k - 1:], k - 1):
    ans -= ((a % mod) * nCr(i, k-1)) % mod
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache


@lru_cache
def factrial(n):
    ans = 1
    for i in range(1, n+1):
        ans *= i
    return ans


@lru_cache
def combinations(n, r):
    return factrial(n) // (factrial(n - r) * factrial(r))


def main():
    n, k = map(int, input().split())
    A = sorted(map(int, input().split()))
    ans = 0
    mod = 10 ** 9 + 7
    for i, a in enumerate(A[k - 1:], k - 1):
        ans += ((a % mod) * (combinations(i, k - 1) % mod)) % mod
        ans %= mod
    for i, a in enumerate(A[: n - k + 1], 1):
        ans -= ((a % mod) * (combinations(n - i, k - 1)) % mod) % mod
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()
Problem p02882 (python)

Fixed submission:
from math import atan, degrees
a, b, x = map(int, input().split())
if x == a * b * b:
    print(0)
else:
    x = x / a ** 2
    if x >= b / 2:
        print(90-degrees(atan(a / (2 * b - 2 * x))))
    else:
        print(90-degrees(atan(2 * a * x / b ** 2)))

Buggy submission (verdict: Runtime Error):
from math import atan, degrees
a, b, x = map(int, input().split())
x = x / a ** 2
if x >= b / 2:
    print(90-degrees(atan(a / (2 * b - 2 * x))))
else:
    print(90-degrees(atan(2 * a * x / b ** 2)))

Buggy submission (verdict: Runtime Error):
from math import atan, degrees
a, b, x = map(int, input().split())
x = x / a ** 2
if x >= b / 2:
    print(degrees(atan(a / (2 * b - 2 * x))))
else:
    print(degrees(atan(2 * a * x / b ** 2)))

Buggy submission (verdict: Runtime Error):
from math import atan
a, b, x = map(int, input().split())
x = x / a ** 2
if x >= b / 2:
    print(atan(a / (2 * b - 2 * x)))
else:
    print(atan(2 * a * x / b ** 2))
Problem p02917 (python)

Fixed submission:
from collections import deque
N = int(input())
B = deque(map(int, input().split()))
base = B.popleft()
ans = base
while B:
  tmp = B.popleft()
  ans += min(base, tmp)
  base = tmp
ans += base
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
B = deque(map(int, input().split()))
base = B.popleft()
ans = base
while B:
  tmp = B.popleft()
  ans += min(base, tmp)
  base = tmp
ans += tmp
print(ans)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
a = sorted(A)
max = a[-1]
if max == a[-2]:
  for i in range(N):
    print(max)
else:
  n = A.index(max)
  for i in range(N):
    if i == n:
      print(a[-2])
      continue
    print(max)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
for i in range(N):
  a = A
  del a[i]
  print(max(a))
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if l + w >= 2019:
  print(0)
else:
  ans = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, (i * j) % 2019)
  print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if s + w >= 2019:
  print(0)
else:
  print(min((s * (s + 1))% 2019, (l * (l - 1)) % 2019)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
A, B, C, D = map(int, input().split())
A -= 1
X = gcd(C, D)
print(B - B//C - B//D + B//(C*D//X) - A + A//C + A//D -A//(C*D//X))

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
A -= 1
X = gcd(C, D)
print(B - B//C - B//D + B//(C*D//X) - A + A//C + A//D -A//(C*D//X))
Problem p03319 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

mini = min(A)
idx = N + 1
mid = N / 2

for i, a in enumerate(A):
  if a == mini and abs(idx - mid) > abs(i - mid):
    idx = i

ans = i // (K - 1)
rem = i % (K - 1)
if rem:
  ans += 1
  if (N - i - 1 - (K - rem)) // (K - 1) > 0:
    ans += (N - i - 1 - (K - rem)) // (K - 1)
    if (N - i - 1 - (K - rem)) % (K - 1) != 0:
      ans += 1
else:
  if (N - i - 1) // (K - 1) > 0:
    ans += (N - i - 1) // (K - 1)
    if (N - i - 1) % (K - 1) != 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

mini = min(A)
idx = N + 1
mid = N / 2

for i, a in enumerate(A):
  if a == mini and abs(idx - mid) > abs(i - mid):
    idx = i

ans = i // (K - 1)
rem = i % (K - 1)
if rem:
  ans += 1
  if (N - i - 1 - (K - rem)) // (K - 1) > 0:
    ans += (N - i - 1 - (K - rem)) // (K - 1)
    if (N - i - 1 - (K - rem)) % (K - 1) != 0:
      ans += 1
else:
  if (N - i - 1) // (K - 1) > 0:
    ans += (N - i - 1) // (K - 1)
    if (N - i - 1) % (K - 1) != 0::
        ans += 1
print(ans)
Problem p03370 (python)

Fixed submission:
N, X = map(int, input().split())
M =[int(input()) for i in range(N)]
X -= sum(M)
M.sort()
n = N
while X >= M[0]:
  n += 1
  X -= M[0]
print(n)

Buggy submission (verdict: Runtime Error):
N, X = map(int. input().split())
M =[int(input()) for i in range(N)]
X -= sum(M)
M.sort()
n = N
while X > M[-1]:
  n += 1
  X -= M[-1]
print(n)
Problem p03393 (python)

Fixed submission:
S = input()
if len(S) == 26:
    done = set()
    for i, s in enumerate(S[::-1]):
        s = ord(s)
        if done:
            if max(done) < s:
                done.add(s)
                if i == 25:
                    print(-1)
            elif i != 25:
                l = 30
                for d in done:
                    if l > abs(d - s) and s < d:
                        x = d
                        l = d - s
                print(S[: -(i + 1)] + chr(x))
                break
            else:
                print(chr(ord(S[0]) + 1))
        else:
            done.add(s)
else:
    for i in range(ord("a"), ord("z") + 1):
        if not (chr(i) in S):
            print(S + chr(i))
            break

Buggy submission (verdict: Runtime Error):
S = input()
if len(S) == 26:
    done = set()
    for i, s in enumerate(S[::-1]):
        s = ord(s)
        if done:
            if max(done) < s:
                done.add(s)
                if i == 25:
                    print(-1)
            elif i != 25:
                print(S[: -(i + 1)] + chr(min(done)))
                break
            else:
                print(chr(ord(S[0] + 1)))
        else:
            done.add(s)
else:
    for i in range(ord("a"), ord("z") + 1):
        if not (chr(i) in S):
            print(S + chr(i))
            break

Buggy submission (verdict: Runtime Error):

S = input()
L = list(map(ord, S))
if len(S) == 26:
    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        pre = set()
        for i, l in enumerate(L[::-1]):
            if pre:
                if min(pre) > l:
                    print(reversed(reversed(S)[i + 1 :]) + chr(min(pre)))
                    break
            pre.add(l)
else:
    for _ in range(ord("a"), ord("z") + 1):
        if not (i in L):
            break
    print(S + chr(i))
Problem p03403 (python)

Fixed submission:
from itertools import accumulate
N = int(input())
A = tuple([0,] + list(map(int, input().split())) + [0,])
D = []
sum = 0
for i, a in enumerate(A[1:-1]):
  i += 1
  pre = A[i - 1]
  tem = A[i]
  nex = A[i + 1]
  x = abs(pre - tem)
  y = abs(tem - nex)
  sum += x
  D.append(abs(pre - nex) - x - y)
sum += y
for d in D:
  print(sum + d)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
N = int(input())
A = tuple([0,] + list(map(int, input().split())) + [0,])
D = []
sum = 0
for i, a in enumarate(A[1:-1]):
  i += 1
  pre = A[i - 1]
  tem = A[i]
  nex = A[i + 1]
  x = abs(pre - tem) + abs(tem - nex)
  sum += x
  D.append(abs(pre - nex) - x)
for d in D:
  print(sum + d)
Problem p03416 (python)

Fixed submission:
A, B = map(int, input().split())
count = 0
for i in range(A, B + 1):
  a = str(i)
  b = a[::-1]
  if a == b:
    count += 1 
print(count)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
count = 0
for i in range(A, B + 1):
  a = str(i)
  b = a[::-1]
  count += 1 if a == b
print(count)
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())
print("Yes" if N % 500 <= A else "No")

Buggy submission (verdict: Runtime Error):
N = input()
A = input()
print("YES" if N / 500 <= A else "NO")
Problem p03434 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[::-2]) - sum(A[-2::-2]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A.sorted()
print(sum(A[::-2]) - sum(A[-2::-2])
Problem p03469 (python)

Fixed submission:
s = input()
print(s[:3] + "8" + s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = 8
print(s)
Problem p03478 (python)

Fixed submission:
N, A, B = map(int, input().split())
result = 0
for i in range(1, N + 1):
  sum = 0
  number = str(i)
  for j in number:
    sum += int(j)
  if A <= sum <= B:
    result += i
print(result)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
count = 0
for i in range(1, N + 1):
  sum = 0
  number = str(i)
  for j in number:
    sum += int(j)
    count += 1 if A <= sum <= B
print(count)
Problem p03612 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i, a in enumerate(A, 1):
  if a == i:
    if i != len(A):
      x = A[i - 1]
      y = A[i]
      A[i - 1] = y
      A[i] = x    
      cnt += 1
    else:
      x = A[i - 2]
      y = A[i - 1]
      A[i - 2] = y
      A[i - 1] = x    
      cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i, a in enumerate(A, 1):
  if a == i:
    if i != len(A) + 1:
      x = A[i - 1]
      y = A[i]
      A[i - 1] = y
      A[i] = x    
      cnt += 1
    else:
      x = A[i - 2]
      y = A[i - 1]
      A[i - 2] = y
      A[i - 1] = x    
      cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i, a in enumerate(A, 1):
  if a == i:
    if i == len(A) + 1:
      x = a[i - 1]
      y = a[i]
      a[i - 1] = y
      a[i] = x    
      cnt += 1
    else:
      x = a[i - 2]
      y = a[i - 1]
      a[i - 2] = y
      a[i - 1] = x    
      cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i, a in enumerate(A, 1):
  if a == i:
    x = a[i - 1]
    y = a[i]
    a[i - 1] = y
    a[i] = x    
    cnt += 1
print(cnt)
Problem p03624 (python)

Fixed submission:
S = input()
S = sorted(set(S))
A = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(A)):
  if len(A) == len(S):
    print("None")
    break
  if A[i] != S[i]:
    print(A[i])
    break
  if i == len(S) - 1:
    print(A[i + 1])
    break

Buggy submission (verdict: Runtime Error):
S = input()
S = sorted(set(S))
A = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(A)):
  if len(A) == len(S):
    print("None")
    break
  if A[i] != S[i]:
    print(A[i])
    break
  if i == len(S):
    print(A[i + 1])
    break

Buggy submission (verdict: Runtime Error):
S = input()
S = sorted(set(S))
A = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(A)):
  if len(A) == len(S):
    print("None")
    break
  if A[i] != S[i]:
    print(A[i])
    break
Problem p03645 (python)

Fixed submission:
N, M = map(int, input().split())
From = set()
To = set()
for _ in range(M):
  a, b = map(int, input().split())
  if a == 1:
    From.add(b)
  if b == N:
    To.add(a)
if From.isdisjoint(To):
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input())
From = set()
To = set()
for _ in range(M):
  a, b = map(int, input())
  if a == 1:
    From.add(b)
  if b == N:
    To.add(a)
if From.isdisjoint(To):
  print("INPOSSIBLE")
else:
  print("POOSIBLE")
Problem p03720 (python)

Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(M):
  A += list(map(int, input().split()))
B = [0 for i in range(N)]
for a in A:
  B[a - 1] += 1
for b in B:
  print(b)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for i in range(M):
  A += list(map(int, input().split()))
B = [0 for in range(N)]
for a in A:
  B[a - 1] += 1
for b in B:
  print(b)
Problem p03801 (python)

Fixed submission:
from sys import exit
from collections import Counter
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
ans = [0 for _ in range(n)]
D = dict()
S = set(A)
if len(S) == 1:
    print(sum(A))
    for _ in range(n - 1):
        print(0)
    exit()
X = sorted(S, reverse=True)
for i, x in enumerate(X):
    D[x] = i

index = [n + 1 for _ in range(len(S))]
for i, a in enumerate(A):
    index[D[a]] = min(index[D[a]], i)

cnt = 0
x = n + 1

for i in range(1, len(S)):
    tmp = X[i - 1]
    nxt = X[i]
    cnt += C[tmp]
    x = min(x, index[D[tmp]])
    ans[x] += (tmp - nxt) * cnt

for i, a in enumerate(A):
    if a != 0:
        cnt += C[nxt]
        ans[i] += nxt * cnt
        break

for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
ans = [0 for _ in range(n)]
D = dict()
S = set(A)
X = sorted(S, reverse=True)
for i, x in enumerate(X):
    D[x] = i

index = [n + 1 for _ in range(len(S))]
for i, a in enumerate(A):
    index[D[a]] = min(index[D[a]], i)

cnt = 0
x = n + 1

for i in range(1, len(S)):
    tmp = X[i - 1]
    nxt = X[i]
    cnt += C[tmp]
    x = min(x, index[D[tmp]])
    ans[x] += (tmp - nxt) * cnt

for i, a in enumerate(A):
    if a != 0:
        cnt += C[nxt]
        ans[i] += nxt * cnt
        break

for a in ans:
    print(a)
Problem p03814 (python)

Fixed submission:
s = input()
print(s.rfind("Z") - s.find("A") + 1)

Buggy submission (verdict: Runtime Error):
s = input()
print(s.rfond("Z") - s.find("A") + 1)
Problem p03817 (python)

Fixed submission:
x = int(input())
y = x % 11
if y > 0:
    cnt = 1
    if y > 6:
        cnt += 1
else:
    cnt = 0
    
print((x // 11) * 2 + cnt)

Buggy submission (verdict: Runtime Error):
x = input()
y = x % 11
if y > 0:
    cnt = 1
    if y > 6:
        cnt += 1
else:
    cnt = 0
    
print(x // 11 + cnt)
Problem p03838 (python)

Fixed submission:
x, y = map(int, input().split())
if abs(y) > abs(x):
    if (x >= 0 and y > 0):
        print(abs(y - x))
    elif x * y <= 0:
        print(abs(y) - abs(x) + 1)
    else:
        print(abs(y) - abs(x) + 2)
else:
    if x > 0 and y > 0:
        print(x - y + 2)
    elif x * y < 0 or (y == 0 and x > 0):
        print(abs(x) - abs(y) + 1)
    else:
        print(abs(x - y))

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
ans = 10 ** 9 + 3
if y >= x:
    ans = min(ans, abs(y - x))
if - y >= x:
    ans = min(ans, abs(-y - x) + 1)
if y >= -x:
    ans = min(ans, abs(y + x) + 1)
if - y >= -x:
    ans(min(ans, abs(-y + x) + 2))
print(ans)
Problem p03945 (python)

Fixed submission:
from sys import exit
S = input()
#0回判定
x = len(S)
if S.count("B") == x or S.count("W") == x:
    print(0)
    exit()



cntw=0
for s in S.split("W"):
    if s:
        cntw += 1
cntb=0
for s in S.split("B"):
    if s:
        cntb += 1
print(abs(cntb - cntw) + min(cntb, cntw) * 2 - 1)

Buggy submission (verdict: Runtime Error):
S = input()
cntb = 1000000 if if S[0] == "B" and S[-1] == "B" else 0
cntw = 1000000 if S[0] == "W" and S[-1] == "W" else 0
for s in S.split("B"):
  if s != "":
    cntb += 1
for s in S.split("W"):
  if s != "":
    cntw += 1
print(min(cntb, cntw))
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
print("".join(sorted(S)))

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
A = sorted([input() for _ in range(l)])
print("".join(A))
Problem p02717 (python)

Fixed submission:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    x,y,z = LI()
    print(z,x,y)
main()

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    x,y,x = LI()
    print(z,x,y)
main()
Problem p02639 (python)

Fixed submission:
A = list(map(int, input().split()))

key = 0
for i,a in enumerate(A):
    if a == 0:
        key = i+1
        break
print(key)

Buggy submission (verdict: Runtime Error):
1 print(15 - sum(list(map(int, input().split()))))
Problem p02696 (python)

Fixed submission:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    n = kwargs["n"]

    for i in range(min(b, n), -1, -1):
        res = a * i // b - a * (i // b)

        if res > 0:
            break

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["a"], kwargs["b"], kwargs["n"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    n = kwargs["n"]

    R = [0 for i in range(b)]

    for i in range(min(b, n) + 1):
        R[i] = a * i // b - a * (i // b)

    res = max(R)
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["a"], kwargs["b"], kwargs["n"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)