Buggy python submission (verdict: Time Limit Exceeded):
a=raw_input()
ary=list(a)
count = 0

tmp=""
for i,v in enumerate(ary):
  if v == tmp:
    del(ary[i])
    tmp=v
  else:
    tmp=v

def countStr(arys):
  cW=0
  cB=0
  for i in arys:
    if i == "B":
      cB += 1
    else:
      cW += 1
  return cW, cB

while len(set(ary)) != 1:
  count += 1
  #W, B=countStr(ary)

  
  if ary[len(ary)-1] == "W":
    ary.append("B")
    m = 2
    for i in ary:
      if ary[len(ary)-m] == "W":
        ary[len(ary)-m] = "B"
        m += 1 
      else:
        break
  else:
    ary.append("W")
    m=2
    for i in ary:
      if ary[len(ary)-m] == "B":
        ary[len(ary)-m] = "W"
        m += 1
      else:
        break
  
print count

Fixed submission:
a=raw_input()
ary=list(a)
count = 0

tmp=ary[0]
for i,v in enumerate(ary):
  if v == tmp:
    tmp=v
  else:
    tmp=v
    count += 1

print count

Buggy python submission (verdict: Time Limit Exceeded):
a=raw_input()
ary=list(a)
count = 0

def countStr(arys):
  cW=0
  cB=0
  for i in arys:
    if i == "B":
      cB += 1
    else:
      cW += 1
  return cW, cB

while len(set(ary)) != 1:
  count += 1
  #W, B=countStr(ary)

  if ary[len(ary)-1] == "W":
    ary.append("B")
    m = 2
    for i in ary:
      if ary[len(ary)-m] == "W":
        ary[len(ary)-m] = "B"
        m += 1 
      else:
        break
  else:
    ary.append("W")
    m=2
    for i in ary:
      if ary[len(ary)-m] == "B":
        ary[len(ary)-m] = "W"
        m += 1
      else:
        break
  
print count

Fixed submission:
a=raw_input()
ary=list(a)
count = 0

tmp=ary[0]
for i,v in enumerate(ary):
  if v == tmp:
    tmp=v
  else:
    tmp=v
    count += 1

print count

Buggy python submission (verdict: Runtime Error):

def main():
    N = input()
    edges = [raw_input() for _ in range(N-1)]
    K = input()
    VP = [raw_input() for _ in range(K)]

    VP = [map(int, _.strip().split()) for _ in VP]
    edges = [map(int, _.strip().split()) for _ in edges]
    # print VP
    # print edges
    scores = {}
    for n_idx, value in VP:
        scores[n_idx] = [value]
    pre_defined = scores.keys()
    # print scores
    def check(value, n1, n2):
        if value == (n1 - n2) or value == (n2 - n1):
            return True
        return False

    for n1, n2 in edges:
        # print n1, n2
        if scores.get(n1) is None and scores.get(n2) is None:
            pass
        else:
            if scores.get(n1) is None:
                for v in scores.get(n2, []):
                    scores[n1] = [_ for _ in scores.get(n1, []) if check(_, n1, n2)] + [v - 1, v+1]
            elif scores.get(n2) is None:
                for v in scores.get(n1, []):
                    scores[n2] = [_ for _ in scores.get(n2, []) if check(_, n1, n2)] + [v - 1, v+1]

    for n1, n2 in edges[-1::]:
        # print n1, n2
        if scores.get(n1) is None and scores.get(n2) is None:
            pass
        else:
            if scores.get(n1) is None:
                for v in scores.get(n2, []):
                    scores[n1] = [_ for _ in scores.get(n1, []) if check(_, n1, n2)] + [v - 1, v+1]
            elif scores.get(n2) is None:
                for v in scores.get(n1, []):
                    scores[n2] = [_ for _ in scores.get(n2, []) if check(_, n1, n2)] + [v - 1, v+1]

        # print scores.get(n1), scores.get(n2) 
        # print "----------"

    # decide step
    adding = []
    for n in range(1, N+1):
        v = scores.get(n, [None])[0]
        adding.append(v)
    if all([_ is not None for _ in adding]):
        print "Yes"
        for a in adding:
            print a
    else:
        print "No"


    # print scores


if __name__ == '__main__':
    main()

Fixed submission:

def main():
    s = raw_input()
    check_b = lambda x: x=='B'
    check_w = lambda x: x=='W'
    if all(map(check_b, list(s))) or all(map(check_w, list(s))):
        return 0

    work = list(s)[:]
    flag_b = False
    flag_w = False
    stack = []
    cnt = 0
    for i in range(len(work)-1):
        w_list = work[i:i+2]
        if w_list[0] == w_list[1]:
            pass
        else:
            cnt += 1

    return cnt



if __name__ == '__main__':
    print main()