Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = str(sys.stdin.readline())
o = len(s)
for i in range(1000000000000):
    p1 = s.find("01")
    p2 = s.find("10")
    if p1 == -1 and p2 == -1:
        break
    elif p1 == -1:
        i = p2
    elif p2 == -1:
        i = p1
    else:
        i = p1 if p1 < p2 else p2

    s = s[:i] + s[i + 2:]
    
print(o - len(s))

Fixed submission:
import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = str(sys.stdin.readline())
o = len(s)
while True:
    p1 = s.find("01")
    p2 = s.find("10")
    if p1 == -1 and p2 == -1:
        break
    elif p1 != -1 and p2 != -1:
        i = p1 if p1 < p2 else p2      
    elif p1 == -1:
        i = p2
    elif p2 == -1:
        i = p1

    s = s[:i] + s[i + 2:]
    
print(o - len(s))

Fixed submission:
import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = str(sys.stdin.readline())
o = len(s)
while True:
    p1 = s.find("01")
    p2 = s.find("10")
    if p1 == -1 and p2 == -1:
        break
    elif p1 == -1:
        i = p2
    elif p2 == -1:
        i = p1
    else:
        i = p1 if p1 < p2 else p2

    s = s[:i] + s[i + 2:]
    
print(o - len(s))

Fixed submission:
import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = str(sys.stdin.readline())
count = 0
f = False
while True:
    p1 = s.find("01")
    p2 = s.find("10")
    if p1 == -1 and p2 == -1:
        break
    elif p1 == -1:
        i = p2
    elif p2 == -1:
        i = p1
    else:
        i = p1 if p1 < p2 else p2

    count += 2
    s = s[:i] + s[i + 2:]
    
print(count)

Fixed submission:
import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = str(sys.stdin.readline())
count = 0
f = False
while True:
    p1 = s.find("01")
    p2 = s.find("10")
    if p1 == -1 and p2 == -1:
        i = None
    elif p1 == -1:
        i = p2
    elif p2 == -1:
        i = p1
    else:
        i = p1 if p1 < p2 else p2

    if i is not None:
        count += 2
        s = s[:i] + s[i + 2:]
        continue

    break
print(count)

Fixed submission:
import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = str(sys.stdin.readline())
count = 0
f = False
while True:
  for i in range(len(s)-1):
    if s[i] == '0' and s[i+1] == '1':
      count += 2
      s = s[:i] + s[i+2:]
      f = True
      break 
    if s[i] == '1' and s[i+1] == '0':
      count += 2
      f = True
      s = s[:i] + s[i+2:]
      break 
  if f:
    f = False
    continue
  break
print(count)

Fixed submission:
import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)