qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = input()
c0, c1 = 0,0
ans = 0
for ch in S:
  if c0 == 0 and ch = '1':
    c1 += 1
  elif c1 == 0 and ch = '0':
    c0 += 1
  elif ch == '1':
    ans += 2
    c0 -= 1
  else:
    ans += 2
    c1 -= 1
    
print(ans)


Fixed code:
S = input()
c0, c1 = 0,0
ans = 0
for ch in S:
  if c0 == 0 and ch == '1':
    c1 += 1
  elif c1 == 0 and ch == '0':
    c0 += 1
  elif ch == '1':
    ans += 2
    c0 -= 1
  else:
    ans += 2
    c1 -= 1
    
print(ans)
Buggy code:
def daruma(s):
    ans = 0
    s_stack = [s[0]]
    for i in range(1, len(s)):
        if len(s_stack) != 0:
            if s_stack[-1] + s[i] == "01" or s_stack[-1] + s[i] == "10":
                s_stack.pop()
                ans += 2
            else:
                s_stack.append(s[i])
        else:
            s_stack.append(s[i])
    return ans

def main():
    s = input()
    ans = daruma(s)
    print(ans)


Fixed code:
def daruma(s):
    ans = 0
    s_stack = [s[0]]
    for i in range(1, len(s)):
        if len(s_stack) != 0:
            if s_stack[-1] + s[i] == "01" or s_stack[-1] + s[i] == "10":
                s_stack.pop()
                ans += 2
            else:
                s_stack.append(s[i])
        else:
            s_stack.append(s[i])
    return ans

def main():
    s = input()
    ans = daruma(s)
    print(ans)

main()
Buggy code:
S = input()
cnt_0 = 0
cnt_1 = 0
for i in S:
    if i == "0":
        cnt_0 += 1
    else:
        cnt_1 +=1
print(min(cnt_0,cnt_1))

Fixed code:
S = input()
cnt_0 = 0
cnt_1 = 0
for i in S:
    if i == "0":
        cnt_0 += 1
    else:
        cnt_1 +=1
print(min(cnt_0,cnt_1)*2)
Buggy code:
s=input()
print(2*min(s.count("0"),mins.count("1")))


Fixed code:
s=input()
print(2*min(s.count('0'),s.count('1')))
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(max(S.count('0'),S.count('1')))

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(2*min(S.count('0'),S.count('1')))
Buggy code:
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 2)

Fixed code:
s = input()
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 2)
Buggy code:
from collections import deque
r=deque(map(int,list(input())))
l=deque()
cnt=0
while len(r)>0:
	if len(l)==0:
		l.append(r.popleft())
	if len(r)==0:
		break
	if l[-1] + r[0]==1:
		l.pop()
		r.popleft()
		cnt += 2
	else:
		l.append(r.popleft())
	print(l,r)
		
print(cnt)

Fixed code:
from collections import deque
r=deque(map(int,list(input())))
l=deque()
cnt=0
while len(r)>0:
	if len(l)==0:
		l.append(r.popleft())
	if len(r)==0:
		break
	if l[-1] + r[0]==1:
		l.pop()
		r.popleft()
		cnt += 2
	else:
		l.append(r.popleft())
		
print(cnt)
Buggy code:
L = list(input())
L_ = []
a = L.pop(0)
cnt = 0

while True:
    if len(L) == 0:
        break
    else:
        b = L.pop(0)
    if a is not b:
        cnt += 1
        L = L_ + L
        L_ = []
        a = L.pop(0)
    elif a is b:
        L_.append(a)
        a = b
    # print(L_, a,  L)

print(cnt * 2)



Fixed code:
L = list(input())
L_ = []
a = L.pop(0)
cnt = 0

while True:
    if len(L) == 0:
        break
    else:
        b = L.pop(0)
    if a is not b:
        cnt += 1
        if len(L_) != 0:
            a = L_.pop()
        elif len(L) == 0:
            break  
        else:
            a = L.pop(0)
    elif a is b:
        L_.append(a)
        a = b
    # print(L_, a,  L)

print(cnt * 2)
Buggy code:
S = input().strip()
x = sum(c == '0' for c in S)
y = len(n) - x
print(2 * min(x, y))

Fixed code:
S = input().strip()
x = sum(c == '0' for c in S)
y = len(S) - x
print(2 * min(x, y))
Buggy code:
s = input()
print(min(s.count(1), s.count(0))*2)

Fixed code:
s = input()
print(min(s.count('1'), s.count('0'))*2)
Buggy code:
from collections import Counter


def main():
    s = list(input())
    Count = Counter(s)
    if "0" not in s or "1" not in s:
        ans = 0
        exit()
    min_key = min(Count, key=Count.get)
    ans = Count[min_key] * 2
    print(ans)


if __name__ == "__main__":
    main()


Fixed code:
from collections import Counter


def main():
    s = list(input())
    Count = Counter(s)
    if "0" not in s or "1" not in s:
        ans = 0
        print(ans)
        exit()
    min_key = min(Count, key=Count.get)
    ans = Count[min_key] * 2
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
s=input()
if s.count("0")==len(s) or s.count("1"):
    print(0)
else:
    print(min(s.count("0"),s.count("1"))*2)

Fixed code:
s=input()
if s.count("0")==len(s) or s.count("1")==len(s):
    print(0)
else:
    print(min(s.count("0"),s.count("1"))*2)
Buggy code:
s = input()
cnt_0, cnt_1 = s.count('0'), s.count('1')
print(max(cnt_0, cnt_1) - min(cnt_0, cnt_1))

Fixed code:
s = input()
cnt_0, cnt_1 = s.count('0'), s.count('1')
print(len(s) - (max(cnt_0, cnt_1) - min(cnt_0, cnt_1)))
Buggy code:
s = list(map(int, list(input())))
i = [x for x in s if x == 1]
n = len(s)
m = sum(i)
if n <= m:
    print(n*2)
else:
    print(m*2)

Fixed code:
s = list(map(int, list(input())))
i = [x for x in s if x == 1]
m = sum(i)
n = len(s)-m

if n <= m:
    print(n*2)
else:
    print(m*2)
Buggy code:
s = input()
print(2 * min(s.count(0), s.count(1)))


Fixed code:
s = input()
print(2 * min(s.count('0'), s.count('1')))
Buggy code:
S=input()

count=0

for i in S:
  if i=="1":
    count +=1

print(min(i,len(S)-count))

Fixed code:
S=input()
 
count=0
 
for i in S:
  if i=="1":
    count +=1
 
print(min(count,len(S)-count)*2)
Buggy code:
S = input()
ans = 0
while i < len(S):
    if any(['01' in S[i:i+2],'10' in S[i:i+2]]):
        S = S[:i]+S[i+2:]
        ans += 2
        i -= 1
    else:
        i += 1
print(ans)

Fixed code:
S = input()
ans = 0
i = 0
while i < len(S):
    if any(['01' in S[i:i+2],'10' in S[i:i+2]]):
        S = S[:i]+S[i+2:]
        ans += 2
        i -= 1
    else:
        i += 1
print(ans)
Buggy code:
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)

Fixed code:
S = input()
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)
Buggy code:
string = str(input())
zero = 0
one = 0
for char in string:
    if char == list(chars)[0]:
        zero += 1
    else:
        one += 1

if zero == 0 or one == 0:
    print(0)
else:
    print(min(zero, one) * 2)

Fixed code:
string = str(input())
zero = 0
one = 0
chars = set(string)
for char in string:
    if char == list(chars)[0]:
        zero += 1
    else:
        one += 1

if zero == 0 or one == 0:
    print(0)
else:
    print(min(zero, one) * 2)
Buggy code:
S=input()
stack=[]
ans=0
for s in S:
    if not stack:
        stack.append(s)
    elif stack[-1]!=s
        stack.pop()
        ans+=2
    else:
        stack.append(s)
print(ans)

Fixed code:
S=input()
stack=[]
ans=0
for s in S:
    if not stack:
        stack.append(s)
    elif stack[-1]!=s:
        stack.pop()
        ans+=2
    else:
        stack.append(s)
print(ans)
Buggy code:
def resolve():
    S = int(input())
    zeros = S.count("0")
    print(min(zeros, len(zeros)*2)

if '__main__' == __name__:
    resolve()

Fixed code:
def resolve():
    S = input()
    zeros = S.count("0")
    print(min(zeros, len(S)-zeros)* 2)

if '__main__' == __name__:
    resolve()
Buggy code:
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == 0:
        counter_0 += 1
    if S[i] == 0:
        counter_1 += 1

if counter_0 <= counter_1:
    print(2*counter_0)
else:
    print(2*counter_1)

Fixed code:
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == '0':
        counter_0 += 1
    if S[i] == '1':
        counter_1 += 1
if counter_0 <= counter_1:
    print(2*counter_0)
else:
    print(2*counter_1)
Buggy code:
import numpy as np

s=np.array(list(map(int,list(input()))))
k = s*2-1
print(len(k)-sum(k))

Fixed code:
import numpy as np

s=np.array(list(map(int,list(input()))))
k = s*2-1
print(len(k)-abs(sum(k)))
Buggy code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B
"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""

#C
s = input()
an0 = 0
an1 = 0
for i in s:
    if s == ""1":
        an1 += 1
    if s == "0":
        an0 += 1
print(min(an0, an1))

Fixed code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B
"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""

#C
s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)
Buggy code:
P=input();print min(P.count('0'),P.count('1'))*2

Fixed code:
P=input();print(min(P.count('0'),P.count('1'))*2)
Buggy code:
s=list(input())
n=len(s)
a=s.count('1')
b=n-a
print(abs(a-b))

Fixed code:
s=list(input())
n=len(s)
a=s.count('1')
b=n-a
c=abs(a-b)
print(n-c)
Buggy code:
s=str(input())
n=len(s)
b=s.count('0')
A=[b,n-b]
print(n-min(A)-min(A))

Fixed code:
s=str(input())
n=len(s)
b=s.count('0')
A=[b,n-b]
print(min(A)+min(A))
Buggy code:
#%%
s = input()
n = len(s)
rem = []

ans = 0
i = 0

if n < 2:
    print(0)

else:
    while i < n:
        if rem:
            if rem[-1] != s[i]:
                rem.pop()
                i += 1
                ans += 2
            
            else:
                if i + 1 < n:
                    if s[i] == s[i+1]:
                        rem.append(s[i])
                        i += 1

                    else:
                        i += 2
                        ans += 2

                else:
                    i += 1

        else:

            if i+1 < n and s[i] == s[i+1]:
                rem.append(s[i])
                i += 1

            else:
                i += 2
                ans += 2

print(ans)


Fixed code:
#%%
s = input()
n = len(s)

if n < 2:
    print(0)

else:
    ans, i = 0, 0
    rem = []

    while i < n:

        if not rem:

            if i+1 < n:
                if s[i] == s[i+1]:
                    rem.append(s[i])
                    i += 1

                else:
                    i += 2
                    ans += 2

            else:
                i += 1

        else:
            if rem[-1] != s[i]:
                rem.pop()
                i += 1
                ans += 2
            
            else:
                if i + 1 < n:
                    if s[i] == s[i+1]:
                        rem.append(s[i])
                        i += 1

                    else:
                        i += 2
                        ans += 2

                else:
                    i += 1
    print(ans)
Buggy code:
s=input()
zero=0
one=0
for i in range(len(s)):
  if s[i]=='0':
    zero+=1
  else:
    one+=1
print(abs(one-zero))

Fixed code:
s=input()
zero=0
one=0
for i in range(len(s)):
  if s[i]=='0':
    zero+=1
  else:
    one+=1
print(len(s)-abs(one-zero))
Buggy code:
if __name__ == '__main__':
    S = str(input())
    N = len(S)

    count_0 = S.count('0')
    count_1 = S.count('1')

    answer = min(count_1, count_1)

    print(answer)

Fixed code:
if __name__ == '__main__':
    S = str(input())
    N = len(S)

    count_0 = S.count('0')
    count_1 = S.count('1')

    answer = 2 * min(count_0, count_1)

    print(answer)
Buggy code:
S = str(input())

a = 0
b = 0
for i in range(len(S)):
  if S[i] == "1":
    a += 1
  else:
    b += 1

print(len(S)-min(a, b)*2)

Fixed code:
S = str(input())

a = 0
b = 0
for i in range(len(S)):
  if S[i] == "1":
    a += 1
  else:
    b += 1

print(min(a, b)*2)
Buggy code:
import sys
S = str(input())

#(S[i - 1] == '1' and S[i] == '0') or (S[i - 1] == '0' and S[i] == '1')

S_dict = {}
if len(S) == 1:
    print(1)
    sys.exit()

for letter in S:
    if letter == '1':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
    elif letter == '0':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1

if len(S_dict.values()) == 1:
    print(0)
    sys.exit()
print(min(S_dict.values()) * 2)

Fixed code:
import sys
S = str(input())

#(S[i - 1] == '1' and S[i] == '0') or (S[i - 1] == '0' and S[i] == '1')

S_dict = {}
if len(S) == 1:
    print(0)
    sys.exit()

for letter in S:
    if letter == '1':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
    elif letter == '0':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1

if len(S_dict.values()) == 1:
    print(0)
    sys.exit()
print(min(S_dict.values()) * 2)
Buggy code:
S = list(input())
print(min(S.count('0'), S.count('1')) ** 2)

Fixed code:
S = list(input())
print(min(S.count('0'), S.count('1')) * 2)
Buggy code:
s = input()
q = []
l = 0
o = 0
for c in s:
    q.append(c)
    l += 1
    while 2 < l and q[l-1] == q[l-2]:
        q.pop()
        q.pop()
        o += 2
        l -= 2
print(o)


Fixed code:
s = input()
q = []
l = 0
o = 0
for c in s:
    q.append(c)
    l += 1
    while 1 < l and q[l-1] != q[l-2]:
        q.pop()
        q.pop()
        o += 2
        l -= 2
print(o)
Buggy code:
s = input()
# ans = 0
# while '01' in s or '10' in s:
#     # print('yes')
#     if '01' in s:
#         s = s.replace('01', '', 1)
#         ans += 2
#     if '10' in s:
#         s = s.replace('10', '', 1)
#         ans += 2
#     # print(s, ans)

# # print(ans)

ans = min(s.count('0'), s.count('1'))
print(ans)

Fixed code:
s = input()
# ans = 0
# while '01' in s or '10' in s:
#     # print('yes')
#     if '01' in s:
#         s = s.replace('01', '', 1)
#         ans += 2
#     if '10' in s:
#         s = s.replace('10', '', 1)
#         ans += 2
#     # print(s, ans)

# # print(ans)

ans = min(s.count('0'), s.count('1'))*2
print(ans)
Buggy code:
s = input()
cnt_one = s.count('1')
cnt_zero = len(s) - cnt_one
print(len(s) - min(cnt_zero, cnt_one)*2)

Fixed code:
s = input()
cnt_one = s.count('1')
cnt_zero = len(s) - cnt_one
print(min(cnt_zero, cnt_one)*2)
Buggy code:
cubes= list(input())
one=0
zero=0

for i in cubes:
  if i=='1':
    one+=1
  else:
    zero+=1
if one>= zero:
  print(zero)
else:
  print(one)

Fixed code:
cubes= list(input())
one=0
zero=0

for i in cubes:
  if i=='1':
    one+=1
  else:
    zero+=1
if one>= zero:
  print(zero*2)
else:
  print(one*2)
Buggy code:
s=sorted(list(input()))
if s[0]==s[-1]:
  print(0)
else:
  a=s.index('1')
  print(2*min(a,len(s)-a)

Fixed code:
s=sorted(list(input()))
if s[0]==s[-1]:
  print(0)
else:
  a=s.index('1')
  print(2*min(a,len(s)-a))
Buggy code:
s=input()
l=[]
for ak in range(len(s)):
    l.append(s[ak])
no=[]
s=l
no.append(s[0])
br=0
for i in range(1,len(s)):
    no.append(s[i])
   
    if no[-1]!=no[-2]:
        no.pop(-1)
        no.pop(-1)
        br+=2
print(br)


Fixed code:
s=input()
l=[]
for ak in range(len(s)):
    l.append(s[ak])
no=[]
s=l
no.append(s[0])
br=0
for i in range(1,len(s)):
    no.append(s[i])
   
    if len(no) >= 2 and no[-1]!=no[-2]:
        no.pop(-1)
        no.pop(-1)
        br+=2
print(br)
Buggy code:
string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeroes += 1
print(2*min(ones, zeros))

Fixed code:
string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeros += 1
print(2*min(ones, zeros))
Buggy code:
import deque
S=input()

stack=deque()
cnt=0
for s in S:
    if not stack:
        stack.append(s)
    elif s!=stack[-1]:
        stack.pop()
        cnt+=2
    else:
        stack.append(s)
        
print(cnt)
        

Fixed code:
S=input()

stack=[]
cnt=0
for s in S:
    if not stack:
        stack.append(s)
    elif s!=stack[-1]:
        stack.pop()
        cnt+=2
    else:
        stack.append(s)
        
print(cnt)
Buggy code:
s=input()
a_1=s.count("1")
b_1=s.cpunt("0")
if a_1<=b_1:
  print(2*a_1)
else:
  print(2*b_1)

Fixed code:
s=input()
a_1=s.count("1")
b_1=s.count("0")
if a_1<=b_1:
  print(2*a_1)
else:
  print(2*b_1)
Buggy code:
l = []
ans = 0

for s in input():
    if s == "0":
        if l and l[-1] == "1":
            l.pop()
            ans += 2
        else:
            l.append(s)
    else:
        if l and l[-1] == "0":
            l.pop()
            ans += 2
        else:
            l.append(i)

print(ans)

Fixed code:
l = []
ans = 0

for s in input():
    if s == "0":
        if l and l[-1] == "1":
            l.pop()
            ans += 2
        else:
            l.append(s)
    else:
        if l and l[-1] == "0":
            l.pop()
            ans += 2
        else:
            l.append(s)

print(ans)
Buggy code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


n = ri()
s = collections.Counter(rr())
print(min(s['0'], s['1']))















Fixed code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


s = collections.Counter(rr())
print(min(s['0'], s['1']) * 2)
Buggy code:
v = input()
l = len(v)
a = 0
b = 0
for c in v:
    if c == '0':
        a += 1
    else:
        b += 1
print(min(a, b))

Fixed code:
v = input()
l = len(v)
a = 0
b = 0
for c in v:
    if c == '0':
        a += 1
    else:
        b += 1
print(2 * min(a, b))
Buggy code:
s =input()
zero =s.count("0")
one =s.count("1")
MIN =min(zero,one)
print(min*2)    

Fixed code:
s =input()
zero =s.count("0")
one =s.count("1")
MIN =min(zero,one)
print(MIN*2)
Buggy code:
S = input().strip()
cnt0 = 0
cnt1 = 1
for i in range(len(S)):
    if S[i]=="0":
        cnt0 += 1
    else:
        cnt1 += 1
print(min(cnt0,cnt1)*2)

Fixed code:
S = input().strip()
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
    if S[i]=="0":
        cnt0 += 1
    else:
        cnt1 += 1
print(min(cnt0,cnt1)*2)
Buggy code:
import collections

l=list(input())
c=collections.Counter(l)
print(c['0'],c['1'])
if c['0']==c['1']:
    print(c['0']*2)
else:
    print(min(c['0'],c['1'])*2)

Fixed code:
import collections

l=list(input())
c=collections.Counter(l)
#print(c['0'],c['1'])
if c['0']==c['1']:
    print(c['0']*2)
else:
    print(min(c['0'],c['1'])*2)
Buggy code:
S=list(map(int,input()))
a=0
b=0
for i in range(lin(S)):
  if S[i]==1:
    a+=1
  else:
    b+=1
print(2*min(a,b))

Fixed code:
S=list(map(int,input()))
a=0
b=0
for i in range(len(S)):
    if S[i]==1:
        a+=1
    else:
        b+=1
print(2*min(a,b))
Buggy code:
s = input()
a = 0
for i in s:
  a += i
print(2 * min(a, len(s)-a))

Fixed code:
s = input()
a = 0
for i in s:
    a += int(i)
print(2 * min(a, len(s)-a))
Buggy code:
#C
s = list(input())
zero = 0
one = 0
for i in s:
    if i == "1":
        one += 1
    else:
        zero += 1
print(min(one,zero))

Fixed code:
#C

s = list(input())
zero = 0
one = 0
for i in s:
    if i == "1":
        one += 1
    else:
        zero += 1
print(2*min(one, zero))
Buggy code:
# -*- coding: utf-8 -*-

def main():
    s = input().split(" ")

    sl = list(s[0])
    prev = -1
    n = 0

    i = 0
    while True:
        if len(sl) <= i:
            break

        if (prev == 0 and sl[i] == '1') or (prev == 1 and sl[i] == '0'):
            # print(str(sl))
            # print("remove", i, prev, sl[i])
            del sl[i]
            del sl[i-1]
            n += 2
            if len(sl) <= i:
                break
            else:
                prev = int(sl[i-2])
                i = i-1
        else:
            prev = int(sl[i])
            i += 1

    print(n)

main()


Fixed code:
# -*- coding: utf-8 -*-

def main():
    s = input().split(" ")

    sl = list(s[0])
    prev = -1
    n = 0

    i = 0
    while True:
        if len(sl) <= i:
            break

        if (prev == 0 and sl[i] == '1') or (prev == 1 and sl[i] == '0'):
            # print(str(sl))
            # print("remove", i, prev, sl[i])
            del sl[i]
            del sl[i-1]
            n += 2
            if i-2 < 0:
                prev = -1
                i = 0
            else:
                prev = int(sl[i-2])
                i = i-1
        else:
            prev = int(sl[i])
            i += 1

    print(n)

main()
Buggy code:
S = input()


count_1 = 0
count_0 = 0

for i in range(len(S)):
  if S[i]=="1":
    count_1 = count_1 + 1
  elif S[i]=="0":
    count_0 = count_0 + 1
    

if count_1 >= count_0:
  print(count_0*2)
elif:
  print(count_1*2)

Fixed code:
S = input()


count_1 = 0
count_0 = 0

for i in range(len(S)):
  if S[i]=="1":
    count_1 = count_1 + 1
  elif S[i]=="0":
    count_0 = count_0 + 1
    

if count_1 >= count_0:
  print(count_0*2)
else:
  print(count_1*2)
Buggy code:
import sys
input = sys.stdin.readline

S = list(map(int, input().replace('\n', '')))

N = len(S)
stack = []
cnt = 0
index = N - 1
while index > -1:
    print(index, S, stack)
    if(len(stack) == 0):
        stack.append(S.pop())
        index -= 1
    else:
        if stack[-1] != S[index]:
            stack.pop()
            S.pop(index)
            index -= 1
            cnt += 2
        else:
            stack.append(S.pop())
            index -= 1
print(cnt)

Fixed code:
import sys
input = sys.stdin.readline

S = list(map(int, input().replace('\n', '')))

N = len(S)
stack = []
cnt = 0
index = N - 1
while index > -1:
    if(len(stack) == 0):
        stack.append(S.pop())
        index -= 1
    else:
        if stack[-1] != S[index]:
            stack.pop()
            S.pop()
            index -= 1
            cnt += 2
        else:
            stack.append(S.pop())
            index -= 1
print(cnt)
Buggy code:
s=input()
count0=0
count1=0
for i in range(len(s)-1):
	if s[i]=='0':
		count0+=1
	else:
		count1+=1
print(min(count0,count1)*2)

Fixed code:
s=input()
count0=0
count1=0
for i in range(len(s)):
	if s[i]=='0':
		count0+=1
	else:
		count1+=1
print(min(count0,count1)*2)
Buggy code:
S = list(input())
N = len(S)

c=0
i=0
f=0
while(1):
    if S[i] != S[i+1]:
        del S[i:i+2]
        c+=2
        N-=2
        if i>=1:
            i-=2
        else:
            i-=1
    i+=1
    #print(i,N,S,f)                                                                      
    if i+1 == N:
        break
print(c)

Fixed code:
S = list(input())
N = len(S)

c=0
i=0
f=0
while(1):
    if i+1 == N or N < 2:
        break
    if S[i] != S[i+1]:
        del S[i:i+2]
        c += 2
        N -= 2
        if i >= 1:
            i -= 2
        else:
            i -= 1
    i += 1
    #print(i,N,S,f)                                                                      
print(c)
Buggy code:
s=input()
l=len(s)
a=[0 for i in range(l)]

for i in range(l):
  a[i]=int(s[i])
  
ichi=0
zero=0

for i in range(l):
  if a[i]==1:
    ichi+=1
  else:
    zero+=1
    
print(2*min(ichi.zero))

Fixed code:
s=input()
l=len(s)
a=[0 for i in range(l)]

for i in range(l):
  a[i]=int(s[i])
  
ichi=0
zero=0

for i in range(l):
  if a[i]==1:
    ichi+=1
  else:
    zero+=1
    
print(2*min(ichi,zero))