qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = input()
S = list(s)

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        print(S)
        ans += 1
print(ans)

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

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        ans += 1
print(ans)
Buggy code:
S = list(input())

count = 0
for i,s in enumerate(S):
    if i!=0:
        if S[i-1] == s:
            count += 1
            if s == "0":
                S[i] = "1"
            else:
                S[i] = "0"
            print(S)
print(count)



Fixed code:
S = list(input())

count = 0
for i,s in enumerate(S):
    if i!=0:
        if S[i-1] == s:
            count += 1
            if s == "0":
                S[i] = "1"
            else:
                S[i] = "0"
print(count)
Buggy code:
S = input()
p1 = ["1" if i%2==0 else "0" for i in range(len(S))]
p2 = ["0" if i%2==0 else "1" for i in range(len(S))]
print(min(bin(~(int(S,2)&int("".join(p1),2))).count("1"),bin(~(int(S,2)&int("".join(p2),2))).count("1")))

Fixed code:
S = input()
p1 = ["1" if i%2==0 else "0" for i in range(len(S))]
p2 = ["0" if i%2==0 else "1" for i in range(len(S))]
print(min(bin((int(S,2)^int("".join(p1),2))).count("1"),bin((int(S,2)^int("".join(p2),2))).count("1")))
Buggy code:
# ABC124C

s = input()
s = [int(t) for t in list(s)]
repaint = 0
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        repaint += 1
        s[i] = 1 - s[i]
paint(repaint)


Fixed code:
# ABC124C

s = input()
s = [int(t) for t in list(s)]
repaint = 0
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        repaint += 1
        s[i] = 1 - s[i]
print(repaint)
Buggy code:
s=input()

BW=s[::2]
WB=s[1::2]

x=BW.count("0") + WB.count("1")
y=BW.count("0") + WB.count("1")

print(min(x,y))

Fixed code:
s=input()

BW=s[::2]
WB=s[1::2]

x=BW.count("0") + WB.count("1")
y=BW.count("1") + WB.count("0")

print(min(x,y))
Buggy code:
s = input()
ans1 = 0
ans2 = 0

for i in range(len(s)):
    if s[i] != str(i%2):
        ans1 += 1

for i in range(len(s)):
    if s[i] != str((i+1)%2):
        ans2 += 1

print(ans2)

Fixed code:
s = input()
ans1 = 0
ans2 = 0

for i in range(len(s)):
    if s[i] != str(i%2):
        ans1 += 1

for i in range(len(s)):
    if s[i] != str((i+1)%2):
        ans2 += 1

print(min(ans1,ans2))
Buggy code:
def test():
    s = list(map(int,list(input())))
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            s[i+1] ^= 1
    print(s) 


if __name__ == "__main__":
    test()


Fixed code:
def test():
    s = list(map(int,list(input())))
    count = 0
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            s[i+1] ^= 1
            count += 1
    print(count)


if __name__ == "__main__":
    test()
Buggy code:
S = list(map(int, list(input())))
n = len(S)

num_0_even = 0
num_0_odd = 0

for i in range(n // 2):
    if S[2 * i] == 0:
        num_0_even += 1
    if S[2 * i + 1] == 0:
        num_0_odd += 1

a = n // 2 - num_0_even + num_0_odd
b = num_0_even + n // 2 + 1 - num_0_odd

if a > b:
    print(b)
else:
    print(a)

Fixed code:
S = list(map(int, list(input())))
n = len(S)

num_0_even = 0
num_0_odd = 0

for i in range(n // 2):
    if S[2 * i] == 0:
        num_0_even += 1
    if S[2 * i + 1] == 0:
        num_0_odd += 1
if n % 2:
    if S[n - 1] == 0:
        num_0_even += 1

a = n // 2 + n % 2 - num_0_even + num_0_odd
b = num_0_even + n // 2 - num_0_odd

if a > b:
    print(b)
else:
    print(a)
Buggy code:
import math

S = input()
S_list = []
N = len(S)
for i in range(N):
    S_list.append(S[i])

even_0 = S_list[1::2].count('0')
odd_0 = S_list[::2].count('0')
print(max(min(even_0+math.trunc(N/2)-odd_0, odd_0+math.ceil(N/2)-even_0), 0))

Fixed code:
import math

S = input()
S_list = []
N = len(S)
for i in range(N):
    S_list.append(S[i])

even_0 = S_list[1::2].count('0')
odd_0 = S_list[::2].count('0')
print(max(min(even_0+math.ceil(N/2)-odd_0, odd_0+math.trunc(N/2)-even_0), 0))
Buggy code:
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if w_b[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_eb, cnt_bw))

Fixed code:
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if wb[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_wb, cnt_bw))
Buggy code:
s=list(input())
dp=[[0,0] for i in range(len(s)+1)]
dp[0][1] = 1
for i in range( len(s)-1 ):
  if s[i] == s[i+1]:
    dp[i+1][0] = dp[i][1]
    dp[i+1][1] = dp[i][0]+1
  else:
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = dp[i][1]+1
  print(dp[i+1])
print(min(dp[len(s)-1]))


Fixed code:
s=list(input())
dp=[[0,0] for i in range(len(s)+1)]
dp[0][1] = 1
for i in range( len(s)-1 ):
  if s[i] == s[i+1]:
    dp[i+1][0] = dp[i][1]
    dp[i+1][1] = dp[i][0]+1
  else:
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = dp[i][1]+1
print(min(dp[len(s)-1]))
Buggy code:
str = input()
cnt = 0
num = 0
for i in str:
    if cnt % 2 == 0:
        if i == '0':
            num += 1
    else:
        if i == '1':
            num += 1
    cnt += 1
cnt2 = 0
num2 = 0
for i in str:
    if cnt2 % 2 == 0:
        if i == '1':
            num2 += 1
    else:
        if i == '0':
            num2 += 1
    cnt2 += 1
print(min(cnt,cnt2))


Fixed code:
str = input()
cnt = 0
num = 0
for i in str:
    if cnt % 2 == 0:
        if i == '0':
            num += 1
    else:
        if i == '1':
            num += 1
    cnt += 1

cnt2 = 0
num2 = 0
for i in str:
    if cnt2 % 2 == 0:
        if i == '1':
            num2 += 1
    else:
        if i == '0':
            num2 += 1
    cnt2 += 1

print(min(num,num2))
Buggy code:
S = input()
ans_0 = 0
ans_1 = 0
check = "0"
for i in S:
    if i == check:
        ans_1 += 1
    else:
        ans_0 += 1
    
    if check == "0":
        check = "1"
    else:
        check == "0"
print(min(ans_0,ans_1))

Fixed code:
S = input()
ans_0 = 0
ans_1 = 0
check = "0"
for i in S:
    if i == check:
        ans_0 += 1
    else:
        ans_1 += 1
    
    if check == "0":
        check = "1"
    else:
        check = "0"
print(min(ans_0,ans_1))
Buggy code:
s=input()
a=0
for i in range(len(s)):
  if i%2==0:
    if s[i]==0:
      a+=1
  if i%2==1:
    if s[i]==1:
      a+=1
print(min(a,len(s)-a)

Fixed code:
s=input()
a=0
for i in range(len(s)):
  if i%2==0 and s[i]=="0":
  	a+=1
  if i%2==1 and s[i]=="1":
  	a+=1  
print(min(a,(len(s)-a)))
Buggy code:
deata = list(input())
count = 0
for i in range(1, len(data)):
  if data[i] == data[i-1]:
    if data[i] == "0":
      data[i] = "1"
    else:
      data[i] = "0"
    count += 1
print(count)

Fixed code:
data = list(input())
count = 0
for i in range(1, len(data)):
  if data[i] == data[i-1]:
    if data[i] == "0":
      data[i] = "1"
    else:
      data[i] = "0"
    count += 1
print(count)
Buggy code:
S = [int(i) for i in input().split()]
N = len(S)

dis1 = 0
dis2 = 0
start = 0
for i in range(N):
    if (S[i]!=1-start):
        dis1 += 1
    if (S[i]!=start):
        dis2 += 1
    start = 1-start
res = min(dis1, dis2)
print (res)

Fixed code:
s = input()
S = [int(s[i]) for i in range(len(s))]
N = len(S)
 
dis1 = 0
dis2 = 0
start = 0
for i in range(N):
    if (S[i]!=1-start):
        dis1 += 1
    if (S[i]!=start):
        dis2 += 1
    start = 1-start
res = min(dis1, dis2)
print (res)
Buggy code:
n = input()
c1=c2=0
l = len(n)
c1 = n - (len([i for i in l[0::2] if i == "0"])) - (len([i for i in l[1::2] if i == "1"]))
c2 = n - (len([i for i in l[0::2] if i == "1"])) - (len([i for i in l[1::2] if i == "0"]))

print(min(c1,c2))

Fixed code:
n = input()
c1 = c2 = 0
l = len(n)
c1 = l - len([i for i in n[0::2] if i == "0"]) - len([i for i in n[1::2] if i == "1"])
c2 = l - len([i for i in n[0::2] if i == "1"]) - len([i for i in n[1::2] if i == "0"])

print(min(c1,c2))
Buggy code:
import numpy as np
tile=str(input())
a=['01','10'][int(tile[0])]*(10**5//2)
sum(np.array(list(tile),dtype=int)^np.array(list(a[:len(tile)]),dtype=int))

Fixed code:
import numpy as np
tile=str(input())
a=['01','10'][int(tile[0])]*(10**5//2)
print(sum(np.array(list(tile),dtype=int)^np.array(list(a[:len(tile)]),dtype=int)))
Buggy code:
s=input()
w=str()
b=str()
cnt1=0
cnt2=0
for i in range(n):
    if i%2==0:
        w+='1'
        b+='0'
    else:
        w+='0'
        b+='1'
for i in range(n):
    if s[i]!=w[i]:
        cnt1+=1
    if s[i]!=b[i]:
        cnt2+=1
print(min(cnt1,cnt2))

Fixed code:
s=input()
w=str()
b=str()
cnt1=0
cnt2=0
for i in range(len(s)):
    if i%2==0:
        w+='1'
        b+='0'
    else:
        w+='0'
        b+='1'
for i in range(len(s)):
    if s[i]!=w[i]:
        cnt1+=1
    if s[i]!=b[i]:
        cnt2+=1
print(min(cnt1,cnt2))
Buggy code:
n = str(input())
n_arr = list(str(n))
arr = list(map(int, n_arr))
print(arr)
zero = []
one = []
for i in range(len(arr)):
    if i % 2 == 0:
        zero.append(0)
        one.append(1)
    else:
        zero.append(1)
        one.append(0)
zero_diff = 0
one_diff = 0
for i in range(len(arr)):
    if arr[i] != zero[i]:
        zero_diff += 1
for i in range(len(arr)):
    if arr[i] != one[i]:
        one_diff += 1
print(min([one_diff,zero_diff]))

Fixed code:
n = str(input())
n_arr = list(str(n))
arr = list(map(int, n_arr))
zero = []
one = []
for i in range(len(arr)):
    if i % 2 == 0:
        zero.append(0)
        one.append(1)
    else:
        zero.append(1)
        one.append(0)
zero_diff = 0
one_diff = 0
for i in range(len(arr)):
    if arr[i] != zero[i]:
        zero_diff += 1
for i in range(len(arr)):
    if arr[i] != one[i]:
        one_diff += 1
print(min([one_diff,zero_diff]))
Buggy code:
s=list(input())
ans=0
for i in range(1,len(s)):
  if s[i]==s[i-1]:
    if s[i]=='0':
      s[i]=1
    else:
      s[i]=0
    ans+=1
print(ans)

Fixed code:
s=list(input())
ans=0
for i in range(1,len(s)):
  if s[i]==s[i-1]:
    if s[i]=='0':
      s[i]='1'
    else:
      s[i]='0'
    ans+=1
print(ans)
Buggy code:
N=list(input())

counter=0

pre = N.pop(0)
for n in N:
    print(pre,end=" ")
    if(pre == n):
        counter+=1
    if(pre == "0"):
        pre="1"
    else:
        pre="0"

print(pre)
print(counter)


Fixed code:
N=list(input())

counter=0

pre = N.pop(0)
for n in N:
    if(pre == n):
        counter+=1
    if(pre == "0"):
        pre="1"
    else:
        pre="0"

print(counter)
Buggy code:
import copy


def count_num_flip(S):
    num_flip = 0
    S_prev = S[0]
    for S_next in S[1:]:
        if S_prev == S_next:
            num_flip += 1
            S_prev = not S_next
    return num_flip


if __name__ == '__main__':
    S = [bool(int(x)) for x in input()]
    S_prime = copy.copy(S)
    S_prime[0] = not S_prime[0]
    print(min(count_num_flip(S), count_num_flip(S_prime) + 1))


Fixed code:
import copy


def count_num_flip(S):
    num_flip = 0
    S_prev = S[0]
    for S_next in S[1:]:
        if S_prev == S_next:
            num_flip += 1
            S_prev = not S_next
        else:
            S_prev = S_next
    return num_flip


if __name__ == '__main__':
    S = [bool(int(x)) for x in input()]
    S_prime = copy.copy(S)
    S_prime[0] = not S_prime[0]
    print(min(count_num_flip(S), count_num_flip(S_prime) + 1))
Buggy code:
s = input()
count = 0

for i in range(len(s)):
    if i % 2 == 0:
        if int(s[i]) == "0":
            count += 1
    else:
        if int(s[i]) == "1":
            count += 1

print(min(count, len(s) - count))



Fixed code:
s = input()
count = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            count += 1
    else:
        if s[i] == "1":
            count += 1

print(min(count, len(s) - count))
Buggy code:
data = [int(s) for s in input()]
count1 = 0
if data[0] == 0:
  
  
  for s in range(1,len(data)-1):
    
    
    print(s)
    if s % 2 == 0:
        if data[s] != 0:
            count1 += 1
            
    else :
        if data[s] != 1:
            count1 += 1
            
else:
  
  
  for s in range(1,len(data)-1):
    
    if s % 2 == 0:
      if data[s] != 0:
        count1 += 1

      else:
        if data[s] != 1:
          count1 += 1
          


print(count1)

Fixed code:
data = [int(s) for s in input()]
count1 = 0
if data[0] == 0:
  
  
  for s in range(1,len(data)):
    
    
    
    if s % 2 == 0:
        if data[s] != 0:
            count1 += 1
    else :
        if data[s] != 1:
            count1 += 1
            
else:
  
  
  for s in range(1,len(data)):
    
    if s % 2 == 0:
      if data[s] != 1:
        count1 += 1
        
    else:
      if data[s] != 0:
        count1 += 1
          


print(count1)
Buggy code:
S = str(input())
s0=0
s1=0
for i in range(len(S)):
    if i%2==0 and S[i]=="0":
        s1+=1
    elif i%2==0 and S[i]=="1" :
        s0+=1
        print("B")
    elif i%2==1 and S[i]=="0":
        s0+=1
        print("C")
    elif i%2==1 and S[i]=="1":
        s1+=1
        print("D")
print(min(s0,s1))

Fixed code:
S = str(input())
s0=0
s1=0
for i in range(len(S)):
    if i%2==0 and S[i]=="0":
        s1+=1
    elif i%2==0 and S[i]=="1" :
        s0+=1
    elif i%2==1 and S[i]=="0":
        s0+=1

    elif i%2==1 and S[i]=="1":
        s1+=1

print(min(s0,s1))
Buggy code:
s=input()
a=[]
for i in range(0,len(s),2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
elif a01>a10:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
else:
  cnt=len(a)
print(cnt)


Fixed code:
s=input()
a=[]
for i in range(0,len(s)//2*2,2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
elif a01>a10:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
else:
  cnt=len(a)
print(cnt)
Buggy code:
s = input()
a = 0
b = 0
for index, i in enumerate(s):
  if int(i) == index%2:
    a+=1
  else:
    b+=1

Fixed code:
s = input()
a = 0
b = 0
for index, i in enumerate(s):
  if int(i) == index%2:
    a+=1
  else:
    b+=1
    
print(min(a, b))
Buggy code:
S = int(input())
S = [int(i) for i in list(str(S))]

a = []
b = True
for i in range(len(S)):
    if b:
        a.append(1)
        b=False
    else:
        a.append(0)
        b=True
c = a[::-1]

combined1 = [abs(x-y) for (x, y) in zip(S, a)]
combined2 = [abs(x-y) for (x, y) in zip(S, c)]

if len(S)==1:
    print(0)
else:
    print(min(sum(combined1), sum(combined2)))

Fixed code:
S = input()
S = [int(i) for i in list(S)]

a = []
c = []
b = True
for i in range(len(S)):
    if b:
        a.append(1)
        c.append(0)
        b=False
    else:
        a.append(0)
        c.append(1)
        b=True

combined1 = [abs(x-y) for (x, y) in zip(S, a)]
combined2 = [abs(x-y) for (x, y) in zip(S, c)]

if len(S)==1:
    print(0)
else:
    print(min(sum(combined1), sum(combined2)))
Buggy code:
n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0 and len(n) != 1:
  counta=0 
  countb=0
  a=list("10"*int((int(n)/2)))
  b=list("01"*int((int(n)/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(n)-1)/2))+"1")
  bb=list("01"*int(((int(n)-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(a[i]))
    countbb+=abs(int(li[i])-int(b[i]))
  print(min(countaa,countbb))

Fixed code:
n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0:
  counta=0 
  countb=0
  a=list("10"*int((int(len(n))/2)))
  b=list("01"*int((int(len(n))/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(len(n))-1)/2))+"1")
  bb=list("01"*int(((int(len(n))-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(aa[i]))
    countbb+=abs(int(li[i])-int(bb[i]))
  print(min(countaa,countbb))
Buggy code:
s=list(input())
cnt=0
for i in range(1,n):
  if s[i]==s[i-1]=='1':
    cnt+=1
    s[i]='0'
  elif s[i]==s[i-1]=='0':
    cnt+=1
    s[i]='1'
print(cnt)

Fixed code:
s=list(input())
cnt=0
for i in range(1,len(s)):
  if s[i]==s[i-1]=='1':
    cnt+=1
    s[i]='0'
  elif s[i]==s[i-1]=='0':
    cnt+=1
    s[i]='1'
print(cnt)
Buggy code:
s=input()
ans1=0
ans2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            ans1+=1
    else:
        if s[i]=="1":
            ans1+=1
for k in range(len(s)):
    if k%2==0:
        if s[i]=="1":
            ans2+=1
    else:
        if s[i]=="0":
            ans2+=1
print(ans1,ans2)


Fixed code:
s=input()
ans1=0
ans2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            ans1+=1
    else:
        if s[i]=="1":
            ans1+=1
for k in range(len(s)):
    if k%2==0:
        if s[k]=="1":
            ans2+=1
    else:
        if s[k]=="0":
            ans2+=1
print(min(ans1,ans2))
Buggy code:
cnt_st0 = 0
cnt_st1 = 0
in_str = str(input())
for i, m in enumerate(in_str):
  if i % 2 == 0:
    if m == '0':
      cnt_st1 += 1
    else:
      cnt_st0 += 1
  else:
    if m == '0':
      cnt_st0 += 1
    else:
      cnt_st1 += 1
      
print(min(cnt_st0, cnt_St1))

Fixed code:
cnt_st0 = 0
cnt_st1 = 0
in_str = str(input())
for i, m in enumerate(in_str):
  if i % 2 == 0:
    if str(m) == '0':
      cnt_st1 += 1
    else:
      cnt_st0 += 1
  else:
    if str(m) == '0':
      cnt_st0 += 1
    else:
      cnt_st1 += 1
print(min(cnt_st0, cnt_st1))
Buggy code:
s=input()
n=len(s)
for i in range(n-1):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n-1):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))A

Fixed code:
s=input()
n=len(s)
ans=0
for i in range(n):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))
Buggy code:
s=list(input())
x=0
y=0
for i in range(0,len(s)):
  if i%2==0:
    if s[i]=="0":
      x+=1
  else:
    if s[i]=="1":
      x+=1
      
for j in range(0,len(s)):
  if i%2==0:
    if s[i]=="1":
      y+=1
  else:
    if s[i]=="0":
      y+=1
      
print(min(x,y))      
  

Fixed code:
s=list(input())
x=0
y=0
for i in range(0,len(s)):
  if i%2==0:
    if s[i]=="0":
      x+=1
  else:
    if s[i]=="1":
      x+=1
      
for j in range(0,len(s)):
  if j%2==0:
    if s[j]=="1":
      y+=1
  else:
    if s[j]=="0":
      y+=1
      
print(min(x,y))
Buggy code:
s = input()
o1e0 = 0
o0e1 = 0

for n, i in enumerate(s):
    print(n,i)
    if (n // 2 == 0):
        if (i == "0"):
            o1e0 += 1
        else:
            o0e1 += 1

    else:
        if (i == "1"):
            o1e0 += 1
        else:
            o0e1 += 1
            
print(min(len(s) - o1e0, len(s) - o0e1))

Fixed code:
s = input()
o1e0 = 0
o0e1 = 0

for n, i in enumerate(s):
    if n % 2 == 0:
        if i == "0":
            o1e0 += 1
        else:
            o0e1 += 1

    else:
        if i == "1":
            o1e0 += 1
        else:
            o0e1 += 1

print(min(len(s) - o1e0, len(s) - o0e1))
Buggy code:
s=input()
a=[]
for i in range(len(s)):
  if i%2==0:
    a.append(0)
  else:
    a.append(1)
b=[]
for j in range(len(s)):
  if j%2==0:
    b.append(1)
  else:
    b.append(0)
cnt=0
for k in range(len(s)):
  if s[k]!=a[k]:
    cnt+=1
ans=0
for l in range(len(s)):
  if s[l]!=b[l]:
    ans+=1
print(min(cnt,ans))

Fixed code:
s=input()
a=[]
for i in range(len(s)):
  if i%2==0:
    a.append('0')
  else:
    a.append('1')
b=[]
for j in range(len(s)):
  if j%2==0:
    b.append('1')
  else:
    b.append('0')
cnt=0
for k in range(len(s)):
  if s[k]!=a[k]:
    cnt+=1
ans=0
for l in range(len(s)):
  if s[l]!=b[l]:
    ans+=1
print(min(cnt,ans))
Buggy code:
s = str(input())
ans1=0
for i in range(len(s)):
  if(i%2==0 and s[i]!=0):ans1+=1
  if(i%2==1 and s[i]!=1):ans1+=1
ans2=0
for i in range(len(s)):
  if(i%2==0 and s[i]!=1):ans2+=1
  if(i%2==1 and s[i]!=0):ans2+=1
ans=min(ans1,ans2)
print(ans)

Fixed code:
s = str(input())
ans1=0
for i in range(len(s)):
  if(i%2==0 and s[i]!='0'):ans1+=1
  if(i%2==1 and s[i]!='1'):ans1+=1
ans2=0
for i in range(len(s)):
  if(i%2==0 and s[i]!='1'):ans2+=1
  if(i%2==1 and s[i]!='0'):ans2+=1
ans=min(ans1,ans2)
print(ans)
Buggy code:
s = input()
option1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 = 0
print(min(ans_1, ans_2))

Fixed code:
s = input()
option_1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option_2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 += 1
print(min(ans_1, ans_2))
Buggy code:
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
else:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Fixed code:
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if  len(s)>=2 and s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2 and len(s)>=4:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
elif len(s)%2==0 and len(s)>=4:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
Buggy code:
S = list(input())
S = [int(i) for i in S]
print(S)
print(len(S))
sum1,sum2 = 0,0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            sum1 += 1
    else:
        if S[i] == 1:
            sum1 += 1

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 1:
            sum2 += 1
    else:
        if S[i] == 0:
            sum2 += 1
print(sum1,sum2)
if sum1 <= sum2:
    print(sum1)
else:
    print(sum2)


Fixed code:
S = list(input())
S = [int(i) for i in S]
sum1,sum2 = 0,0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            sum1 += 1
    else:
        if S[i] == 1:
            sum1 += 1

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 1:
            sum2 += 1
    else:
        if S[i] == 0:
            sum2 += 1
if sum1 <= sum2:
    print(sum1)
else:
    print(sum2)
Buggy code:
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans1[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Fixed code:
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2)
    ans.append('0')

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))