Buggy python submission (verdict: Runtime Error):
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u:
		stack[-1] += v-u
	elif v < u:
		stack.append( u - v)

print n - (stack[-1] if stack else 0)

Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)

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

s = raw_input()
q = 0
n = len(s)
while(True):
	s = s.replace('01','')
	s = s.replace('10','')
	if len(s)  == n:
		break
	else:
		q += n - len(s)

print q

Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
i,j = 0,0 
s = raw_input()
q = collections.deque([])
while(j < len(s)):
	while(j < len(s) and s[j] == s[i]): j+=1
	q.append(j - i - 1)
	j = i

#5 6 5 1 1 4 2 1 1 1 1 1
ns = len(s)
while(len(q) > 1):
	u,v = q.popleft(), q.popleft()
	if q: q[0] += abs(u-v)
print ns - (q[0] if q else 0)


Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)

Buggy python submission (verdict: Runtime Error):
import collections
i,j = 0,0 
s = raw_input()
q = collections.deque([])
while(j < len(s)):
	while(s[j] == s[i]): j+=1
	q.append(j - i - 1)
	j = i

#5 6 5 1 1 4 2 1 1 1 1 1
ns = len(s)
while(len(q) > 1):
	u,v = q.popleft(), q.popleft()
	if q: q[0] += abs(u-v)
print ns - (q[0] if q else 0)


Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)

Buggy python submission (verdict: Runtime Error):
import collections
i,j = 0,0 
q = collections.deque([])
while(j < len(s)):
	while(s[j] == s[i]): j+=1
	q.append(j - i - 1)
	j = i

#5 6 5 1 1 4 2 1 1 1 1 1
ns = len(s)
while(len(q) > 1):
	u,v = q.popleft(), q.popleft()
	if q: q[0] += abs(u-v)
print ns - (q[0] if q else 0)


Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)

Buggy python submission (verdict: Runtime Error):
import collections
i,j = 0,0 
q = collections.deque([])
while(j < len(s)):
  while(s[j] == s[i]): j+=1
  q.append(j - i - 1)
  j = i

5 6 5 1 1 4 2 1 1 1 1 1

while(len(q) > 1):
  u,v = q.popleft(), q.popleft()
  if q: q[0] += abs(u-v)
print q[0] if q else 0

Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)