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

Fixed submission:
# 12/25 AC日記
# GCDについて,2,3を追加しておくと全体のgcdは必ず1
# つまり残りは2の倍数または3の倍数を入れることにする?
# 2,3,a ではaは素数ではない.また3,(2+a)=3なのでa = 4?と思うが(3+a)は偶数なので7とする?
# 2,3,7に加えるとしたら？->この方法だと20000個数も取れないでしょ
# ちょっと難しいので休憩

# 12/27 再開
# 素因数は必ず2種類あるべきなのではないか
# それを2,3とする
# 0(mod2) ∧ !0(mod3) -> 総和は3の倍数
# 全部入れると丁度2万個なのでこれが想定されていそう
n = int(input())
nn = n
if n == 3:
    print("2 5 63")
else:
    res = [2, 4, 3, 9]
    n -= 4
    for i in range(2, 5001):
        if n < 2:
            break
        else:
            n -= 2
            res.append(6 * i - 4)
            res.append(6 * i - 2)
    for i in range(3, 5000, 2):
        if n < 2:
            break
        else:
            n -= 2
            res.append(6 * i - 3)
            res.append(6 * i + 3)
    for i in range(1, 5001):
        if n == 0:
            break
        else:
            n -= 1
            res.append(6 * i)
    for i in range(len(res)):
        print(str(res[i]) + " ", end="")

Buggy submission (verdict: Runtime Error):
# 12/25 AC日記
# GCDについて,2,3を追加しておくと全体のgcdは必ず1
# つまり残りは2の倍数または3の倍数を入れることにする?
# 2,3,a ではaは素数ではない.また3,(2+a)=3なのでa = 4?と思うが(3+a)は偶数なので7とする?
# 2,3,7に加えるとしたら？->この方法だと20000個数も取れないでしょ
# ちょっと難しいので休憩

# 12/27 再開
# 素因数は必ず2種類あるべきなのではないか
# それを2,3とする
# 0(mod2) ∧ !0(mod3) -> 総和は3の倍数
# 全部入れると丁度2万個なのでこれが想定されていそう
n = int(input())
nn = n
if n == 3:
    print("2 5 63")
else:
    res = [2, 4, 3, 9]
    n -= 4
    for i in range(2, 5001):
        if n < 2:
            break
        else:
            n -= 2
            res.append(6 * i - 4)
            res.append(6 * i - 2)
    for i in range(3, 5000, 2):
        if n < 2:
            break
        else:
            n -= 2
            res.append(6 * i - 3)
            res.append(6 * i + 3)
    for i in range(1, 5001):
        if n == 0:
            break
        else:
            n -= 1
            res.append(6 * i)

for i in range(len(res)):
    print(str(res[i]) + " ", end="")
Problem p02621 (python)

Fixed submission:
a = int(input())

a = a + a**2 + a**3
print(a)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
ab = list(map(int, input().split())) + list(map(int, input().split()))
O = 0
ab.sort()
for i in range(len(ab)):
    k -= ab[i]
    if k < 0:
        break
    O +=1
print(O)
Problem p02675 (python)

Fixed submission:
import sys
N = int(input())
n=N%10
if n==2 or n==4 or n==5 or n==7 or n==9:
    print("hon")
elif n==0 or n==1 or n==6 or n==8:
    print("pon")
elif n==3:
    print("bon")

Buggy submission (verdict: Runtime Error):
import sys
n = input()
p=3
a=n/100
n=n-a
b=n/10
n=n-b
c=n/
if(p==0):
    print(hon)
else if(p==1):
    print(pon)
else if(p==2):
    print(bon)
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())
if(n==m):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if(n==m):
    print(yes)
else:
    print(no)
Problem p02789 (python)

Fixed submission:
n,m = map(int,input().split())
if n == m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
ans = 0
temp = 0
for i in range(n):
    """
    for j in range(i+1):
        if p[i]<=p[j]:
            temp+=1
        if temp == i+1:
            #print("i:"+str(i))
            ans+=1
    temp=0
            """
    if min(p[:i+1]) == p[i]:
        #print("i:"+str(i))
        ans+=1
print(ans)
Problem p02818 (python)

Fixed submission:
a,b,k = map(int,input().split())
if a>k and a>0:
    a-=k
else:
    if b>k-a and b>0:
        b-=(k-a)
    else:
        b=0
    a=0
print(str(a)+" "+str(b))

Buggy submission (verdict: Runtime Error):
if a>k and a>0:
    a-=k
else:
    if b>k-a and b>0:
        b-=(k-a)
    else:
        b=0
    a=0
print(str(a)+" "+str(b))
Problem p02675 (python)

Fixed submission:
val = input()
if int(val) <= 999:
  str_val = str(val)
  val_one = str_val[-1]
  if val_one in {'2','4','5','9','7'}:
    print('hon')
  elif val_one in {'0','1','6','8'}:
    print('pon')
  elif val_one == '3':
    print('bon')

Buggy submission (verdict: Runtime Error):

val = input()
if val <= 999:
  str_val = str(val)
  val_one = str_val[-1]
  if val_one in {'2','4','5','9','7'}:
    print('hon')
  elif val_one in {'0','1','6','8'}:
    print('pon')
  elif val_one == '3':
    print('bon')
Problem p02969 (python)

Fixed submission:
Input =  int(input())

if 1<=Input<=100:
  Result = 3*Input**2

print(Result)

Buggy submission (verdict: Runtime Error):
Input = input()

Result = 3*Input**2

print(Result)
Problem p02612 (python)

Fixed submission:
n = int(input())
x = 0

while True:
    if n % 1000 == 0:
        break
    n += 1
    x += 1

print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = 0

whlie True:
  if n % 1000 == 0:
    break
   
  n += 1
  x += 1
  
print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = 0

whlie True:
  if n % 1000:
    break
   
  n += 1
  x += 1
  
print(x)
Problem p02675 (python)

Fixed submission:
n = str(input())
if n[-1] in ['2', '4', '5', '7', '9']:
    how_to_read = 'hon'
elif n[-1] in ['0', '1', '6', '8']:
    how_to_read = 'pon'
else:
    how_to_read = 'bon'
    
print(how_to_read)

Buggy submission (verdict: Runtime Error):
n = str(input())
if n[-1] in ['2', '4', '5', '7', '9']:
    how_to_read = 'hon'
elif n[-1] in ['0', '1', '6', '8':
    how_to_read = 'pon'
else:
    how_to_read = 'bon'
    
print(how_to_read)
Problem p02681 (python)

Fixed submission:
s = str(input())
t = str(input())
t_before = ''
for i in range(len(s)):
    t_before += t[i]

if s == t_before:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = str(input())
T = str(input())
t_before = ''
for i in range(len(s)):
    t_before += t[i]

if s == t_before:
    print('Yes')
else:
    print('No')
Problem p02830 (python)

Fixed submission:
n = int(input())
s, t = map(str,input().split())

ans = ''
for i in range(n):
    ans += s[i]
    ans += t[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s, t = map(str,input())

ans = ''
for i in range(n):
    ans += s[i]
    ans += t[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s, t = map(str,input())

ans = '' 
for i in range(n):
    ans += s[i]
    ams += t[i]
    
print(ans)
Problem p02953 (python)

Fixed submission:
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[0]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

    if flag:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[i]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)
                
    if flag:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[i]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
height_lst = list(map(int,input().split()))

flag = True
point = 0
count = 0

if n==1:
    print('Yes')
else:
    for i in range(n-1):
        height1 = height_lst[i]
        height2 = height_lst[i+1]
        poor = height2-height1

        if poor<=-2:
            flag = False
            break
        elif poor==-1:
            point += 1
            if point==2:
                flag = False
                break
        else:
            continue

if flag:
    height1 = height_lst[-2]
    height2 = height_lst[-1]
    poor = height2-height1

    if poor<=-2:
        print('No')
    elif poor==-1:
        if point==0:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

else:
    print('No')
Problem p02996 (python)

Fixed submission:
def main():
    n = int(input())
    ab_lst = [list(map(int, input().split())) for _ in range(n)]

    ba_lst = [0] * n
    for i in range(n):
        a = ab_lst[i][0]
        b = ab_lst[i][1]
        ba = [b, a]
        ba_lst[i] = ba
    ba_lst.sort()

    lst = []
    b = ba_lst[0][0]
    a = ba_lst[0][1]
    for i in range(n):
        b_tmp = ba_lst[i][0]
        a_tmp = ba_lst[i][1]

        if b == b_tmp:
            if i != 0:
                a += a_tmp
            if i == n - 1:
                lst.append([b, a])

        else:
            lst.append([b, a])
            b = b_tmp
            a = a_tmp

    if len(lst) > 1:
        if ba_lst[-1][0] != ba_lst[-2][0]:
            lst.append([ba_lst[-1][0], ba_lst[-1][1]])


    accumulate = 0
    flag = True
    for i in range(len(lst)):
        accumulate += lst[i][1]
        if accumulate > lst[i][0]:
            flag = False
            break

    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    ab_lst = [list(map(int, input().split())) for _ in range(n)]

    ba_lst = [0] * n
    for i in range(n):
        a = ab_lst[i][0]
        b = ab_lst[i][1]
        ba = [b, a]
        ba_lst[i] = ba
    ba_lst.sort()

    lst = []
    b = ba_lst[0][0]
    a = ba_lst[0][1]
    for i in range(n):
        b_tmp = ba_lst[i][0]
        a_tmp = ba_lst[i][1]

        if b == b_tmp:
            if i != 0:
                a += a_tmp
            if i == n - 1:
                lst.append([b, a])

        else:
            lst.append([b, a])
            b = b_tmp
            a = a_tmp

    if ba_lst[-1][0] != ba_lst[-2][0]:
        lst.append([ba_lst[-1][0], ba_lst[-1][1]])

    print(lst)

    accumulate = 0
    flag = True
    for i in range(len(lst)):
        accumulate += lst[i][1]
        if accumulate > lst[i][0]:
            flag = False
            break

    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
Problem p03031 (python)

Fixed submission:
n,m = map(int,input().split())
s_lst = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    del s_lst[i][0]
p_lst = list(map(int,input().split()))
answer = 0

for i in range(2**n): #各電球がonかoffかビット全探索
    on_lst =[0]*n
    flag = True
    for j in range(n):
        if (i>>j) & 1:
            on_lst[j] = 1
    for l in range(m): ##　一つ一つの電球について確認
        number = 0
        s = s_lst[l]
        for sw in s:
            if on_lst[sw-1]==1:
                number += 1
        if number%2 != p_lst[l]:
            flag = False
            break
    if flag:
        answer += 1

print(answer)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s_lst = [list(map(int,input().split())) for i in range(m)]
k_lst = []
for i in range(m):
    k = s_lst.pop(s_lst[i][0])
    k_lst.append(k)
p_lst = list(map(int,input().split()))
answer = 0

for i in range(2**n): #各電球がonかoffかビット全探索
    on_lst =[0]*n
    flag = True
    for j in range(n):
        if (i>>j) & 1:
            on_lst[j] = 1
    for l in range(m): ##　一つ一つの電球について確認
        number = 0
        s = s_lst[l]
        for sw in s:
            if on_lst[sw-1]==1:
                number += 1
        if number%2 != p[i]:
            flag = False
            break
    if flag:
        answer += 1

print(answer)
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
a, b = sorted([a, b])
lst = []

if b != 1:
    for i in range(1, a+1):
        if a%i==b%i==0:
            lst.append(i)

else:
    lst.append(1)

lst.reverse()
print(lst[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
a, b = sorted([a, b])
lst = []

if b != 1:
    for i in range(1, b):
        if a%i==b%i==0:
            lst.append(i)

else:
    lst.append(1)

lst.reverse()
print(lst[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
a, b = sorted([a, b])
lst = []

if b != 1:
    for i in range(1, b):
        if a%i==b%i==0:
            lst.append(i)

else:
    lst.append(1)

print(lst[k-1])
Problem p03109 (python)

Fixed submission:
s = str(input())

year = ''
for i in range(4):
    y = s[i]
    flag1 = True
    if y == '0':
        if len(year) == 0:
            flag1 = False
        if flag1:
            year += y
    else:
        year += y
year = int(year)

month = ''
for i in range(5, 7):
    m = s[i]
    if i == 5 and m == '0':
        continue
    else:
        month += m
month = int(month)


if year < 2019:
    answer = 'Heisei'

elif year == 2019 and month <= 4:
    answer = 'Heisei'

else:
    answer = 'TBD'

print(answer)

Buggy submission (verdict: Runtime Error):
s = str(input())
year = ''
month = ''
day = ''

for i in range(4):
    y = s[i]
    year += y
for i in range(5, 7):
    m = s[i]
    month += m
for i in range(9, 11):
    d = s[i]
    day += d

year = int(year)
month = int(month)
day = int(day)

if year < 2019:
    answer = 'Heisei'

elif year == 2019 and month <= 4:
    answer = 'Heisei'

else:
    answer = 'TBD'
    
print(answer)
Problem p03136 (python)

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

print('Yes' if max(l) < sum(l)-max(l) else 'No')

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()) for _ in range(n))

print('Yes' if max(l) < sum(l)-max(l) else 'No')
Problem p03262 (python)

Fixed submission:
import math


def main():
    n, x = map(int, input().split())
    x_lst = list(map(int, input().split()))
    x_lst.sort()

    if n == 1:
        minimum = abs(x_lst[0] - x)
    elif n == 2:
        minimum = abs(x_lst[1] - x_lst[0])
        lst = [abs(x_lst[1] - x), abs(x_lst[0] - x)]
        lst.sort()
        lst.reverse()
        for i in range(2):
            if minimum % lst[i] == 0:
                minimum = lst[i]
                break
    else:
        lst1 = []
        for i in range(n):
            if i != n - 1:
                lst1.append(abs(x_lst[i + 1] - x_lst[i]))

        minimum = math.gcd(lst1[0], lst1[1])
        for i in range(n - 1):
            if i != n - 2:
                minimum = min(minimum, math.gcd(lst1[i], lst1[i + 1]))

        lst2 = []
        for i in range(n):
            lst2.append(abs(x_lst[i] - x))

        lst2.sort()
        lst2.reverse()
        for i in range(n):
            if minimum % lst2[i] == 0:
                minimum = lst2[i]
                break

    print(minimum)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    n, x = map(int, input().split())
    x_lst = list(map(int, input().split()))
    x_lst.sort()

    if n == 1:
        minimum = abs(x_lst[0] - x)
    else:
        lst1 = []
        for i in range(n):
            if i != n - 1:
                lst1.append(abs(x_lst[i + 1] - x_lst[i]))

        minimum = math.gcd(lst1[0], lst1[1])
        for i in range(n - 1):
            if i != n - 2:
                minimum = min(minimum, math.gcd(lst1[i], lst1[i + 1]))

        lst2 = []
        for i in range(n):
            lst2.append(abs(x_lst[i] - x))

        lst2.sort()
        lst2.reverse()
        for i in range(n):
            if minimum % lst2[i] == 0:
                minimum = lst2[i]
                break

    print(minimum)


if __name__ == '__main__':
    main()
Problem p03280 (python)

Fixed submission:
a, b = map(int, input().split())
print(a * b - a - b + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = [135, 189, 105, 165, 195]
tmp = 0

for i in range(5):
    if n<=lst[i]:
        tmp += 1

print(tmp)
Problem p03281 (python)

Fixed submission:
n = int(input())
lst = [135, 189, 105, 165, 195]
tmp = 0
x = []

for i in range(5):
    x.append(n-lst[i])

for i in range(5):
    if x[i]>=0:
        tmp += 1

print(tmp)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = [135, 189, 105, 165, 195]
tmp = 0

for i in range(6):
    if n<=lst[i]:
        tmp += 1

print(tmp)
Problem p03407 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a +  b >= c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b, c = int(input())
if a +  b >= c:
    print('Yes')
else:
    print('No')
Problem p03474 (python)

Fixed submission:
a, b = map(int, input().split())
s = str(input())
cnt = 0

if s.count('-')==1 and s[a]=='-':
    for i in range(a):
        if int(s[i]) in range(0, 10):
            cnt += 1
    if s[a]=='-':
        cnt += 1
    for i in range(b):
        if int(s[a+1+i]) in range(0, 10):
            cnt += 1

    if cnt == a+b+1:
        print('Yes')
    else:
        print('No')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = str(input())
cnt = 0

for i in range(a):
    if int(s[i]) in range(0, 10):
        cnt += 1
if s[a]=='-':
    cnt += 1
for i in range(b):
    if int(s[a+1+i]) in range(0, 10):
        cnt += 1

if cnt == a+b+1:
    print('Yes')
else:
    print('No')
Problem p03487 (python)

Fixed submission:
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    a_lst.sort()
    a_set_lst = list(set(a_lst))
    a_set_lst.sort()

    count_lst = []
    count = 1
    if n == 1:
        count_lst.append(count)
    else:
        for i in range(n - 1):
            a1 = a_lst[i]
            a2 = a_lst[i + 1]

            if a1 == a2:
                count += 1
                if i == n - 2:
                    count_lst.append(count)
            else:
                count_lst.append(count)
                count = 1
        if a_lst[-1] != a_lst[-2]:
            count_lst.append(count)

    minimum = 0
    for i in range(len(a_set_lst)):
        number = a_set_lst[i]
        count = count_lst[i]

        if count < number:
            minimum += count
        else:
            minimum += count - number

    print(minimum)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    a_lst.sort()
    a_set_lst = list(set(a_lst))
    a_set_lst.sort()

    count_lst = []
    count = 1
    if n == 1:
        count_lst.append(count)
    else:
        for i in range(n - 1):
            a1 = a_lst[i]
            a2 = a_lst[i + 1]

            if a1 == a2:
                count += 1
                if i == n - 2:
                    count_lst.append(count)
            else:
                count_lst.append(count)
                count = 1

    minimum = 0
    for i in range(len(a_set_lst)):
        number = a_set_lst[i]
        count = count_lst[i]

        if count < number:
            minimum += count
        else:
            minimum += count - number

    print(minimum)


if __name__ == '__main__':
    main()
Problem p03633 (python)

Fixed submission:
import math


def lcm(x, y):
    return x * y // math.gcd(x, y)


def main():
    n = int(input())
    t_lst = [int(input()) for _ in range(n)]
    t_lst.sort()
    answer = t_lst[0]
    for i in range(1, n):
        t = t_lst[i]
        answer = lcm(answer, t)

    print(answer)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return x * y / math.gcd(x, y)


def main():
    n = int(input())
    t_lst = [int(input()) for _ in range(n)]
    t_lst.sort()
    answer = t_lst[0]
    for i in range(1, n):
        t = t_lst[i]
        answer = lcm(answer, t)
        answer = int(answer)

    print(answer)


if __name__ == '__main__':
    main()
Problem p03698 (python)

Fixed submission:
s = list(str(input()))
s1 = list(set(s))

print('yes' if len(s)==len(s1) else 'no')

Buggy submission (verdict: Runtime Error):
s = list(str(input()))
s1 = list(set(s1))

print('yes' if len(s)==len(s1) else 'no')
Problem p03773 (python)

Fixed submission:
a, b = map(int, input().split())
print((a + b) % 24)

Buggy submission (verdict: Runtime Error):
a. b = map(int, input().split())
print((a + b) % 24)

Buggy submission (verdict: Runtime Error):
a. b = map(int, input().split())
print((a + b) % 23)
Problem p03943 (python)

Fixed submission:
abc = list(map(int, input().split()))
abc.sort()
if abc[0] + abc[1] == abc[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
abc = map(int, input().split())
abc.sort()
if abc[0] + abc[1] == abc[2]:
    print('Yes')
else:
    print('No')
Problem p03945 (python)

Fixed submission:
def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
	def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                    continue
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


if __name__ == '__main__':
    main()