qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = list(str(input()))
if S[0] == "1":
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "0":
            S[i] = "1"
        elif i % 2 == 1 and j == "1":
            S[i] = "0"
else:
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "1":
            S[i] = "0"
        elif i % 2 == 1 and j == "0":
            S[i] = "1"
print(S)

Fixed code:
S = list(str(input()))
count = 0
if S[0] == "1":
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "0":
            count += 1
        elif i % 2 == 1 and j == "1":
            count += 1
else:
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "1":
            count += 1
        elif i % 2 == 1 and j == "0":
            count += 1
print(count)
Buggy code:
s = str(input())

print(s)

cnt = 0
new = s[0]
for idx in range(len(s[1:])):
    idx += 1
    if new[idx-1]==s[idx]:
        if s[idx] == '0':
            new+='1'
        else:
            new+='0'
        cnt += 1
    else:
        new+=s[idx]
print(cnt)

Fixed code:
s = str(input())

cnt = 0
new = s[0]
for idx in range(len(s[1:])):
    idx += 1
    if new[idx-1]==s[idx]:
        if s[idx] == '0':
            new+='1'
        else:
            new+='0'
        cnt += 1
    else:
        new+=s[idx]
print(cnt)
Buggy code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
S = input()
lis = []
for t in range(len(S)):
    lis.append(S[t])
evencount0 = 0
unevencount0 = 0
evencount1 = 0
unevencount1 = 0
if len(S)%2 == 0:
    for t in range(int(len(S)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int(len(S)/2) - evencount0
    for t in range(int(len(S)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int(len(S)/2) - unevencount0

else:
    for t in range(int((len(S) - 1)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int(len(S)/2) - evencount0        

    for t in range(int((len(S)+1)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int(len(S)/2) - unevencount0

elist = [evencount0 , evencount1 , unevencount0 , unevencount1 ]
if evencount1 + unevencount0 > evencount0 + unevencount1:
    k = evencount0 + unevencount1
else:
    k = evencount1 + unevencount0
print(k)

Fixed code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
S = input()
lis = []
for t in range(len(S)):
    lis.append(S[t])
evencount0 = 0
unevencount0 = 0
evencount1 = 0
unevencount1 = 0
if len(S)%2 == 0:
    for t in range(int(len(S)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int(len(S)/2) - evencount0
    for t in range(int(len(S)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int(len(S)/2) - unevencount0

else:
    for t in range(int((len(S) - 1)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int((len(S) - 1)/2) - evencount0        

    for t in range(int((len(S)+1)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int((len(S)+1)/2) - unevencount0

elist = [evencount0 , evencount1 , unevencount0 , unevencount1 ]
if evencount1 + unevencount0 > evencount0 + unevencount1:
    k = evencount0 + unevencount1
else:
    k =evencount1 + unevencount0
print(k)
Buggy code:
S = list(input())

res = 0

for i in range(1, len(S)):
    if S[i] == S[i-1]:
        res += 1
        S[i] = "0" if int(S[i]) else "1"
        print("S")
print(res)


Fixed code:
S = list(input())

res = 0

for i in range(1, len(S)):
    if S[i] == S[i-1]:
        res += 1
        S[i] = "0" if int(S[i]) else "1"
print(res)
Buggy code:
S = input()
n = len(S)
T = ['{}'.format(i % 2) for i in range(n)]
print(T)
tmp = 0
for i in range(n):
    if S[i] == T[i]:
        tmp += 1
if tmp >= n - tmp:
    ans = n - tmp
else:
    ans = tmp
print(ans)


Fixed code:
S = input()
n = len(S)
T = ['{}'.format(i % 2) for i in range(n)]
tmp = 0
for i in range(n):
    if S[i] == T[i]:
        tmp += 1
if tmp >= n - tmp:
    ans = n - tmp
else:
    ans = tmp
print(ans)
Buggy code:
def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_doloring_colorfully(S))

Fixed code:
def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_coloring_colorfully(S))
Buggy code:
S=[]
for char in str(input()):
  S.append(char)

#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

#route 2
C2=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==0:
      S[i]=0
      C2+=1
  else:
    if S[i]==1:
      S[i]=1
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)
  
    
    
      

Fixed code:
S=[]
for char in input():
  S.append(char)
#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=='1':
      C1+=1
  else:
    if S[i]=='0':
      C1+=1

#route 2
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]=='0':
      C2+=1
  else:
    if S[n]=='1':
      C2+=1

if C2>=C1:
  print(C1)
else:
  print(C2)
Buggy code:
s = input()
n = len(s)

a = "10" * (n // 2) + ("1" if n % 2 == 0 or n == 1 else "")
b = "01" * (n // 2) + ("0" if n % 2 == 0 or n == 1 else "")

sum_a = 0
for i in range(n):
    if s[i] != a[i]: sum_a += 1

sum_b = 0
for i in range(n):
    if s[i] != b[i]: sum_b += 1

print(min(sum_a, sum_b))

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

a = "10" * (n // 2) + ("1" if n % 2 == 1 else "")
b = "01" * (n // 2) + ("0" if n % 2 == 1 else "")

sum_a = 0
for i in range(n):
    if s[i] != a[i]: sum_a += 1

sum_b = 0
for i in range(n):
    if s[i] != b[i]: sum_b += 1

print(min(sum_a, sum_b))
Buggy code:
s = str(input())
w1,w2,b1,b2 = 0,0,0,0
for i in range(len(s)):
  if i % 2 == 0:
  	if s[i] == "0":
      w1 += 1
    else:
      b1 += 1
  else:
    if s[i] == "0":
      w2 += 1
    else:
      b2 += 1
print(min(w1+b2,w2+b1))

Fixed code:
s = str(input())
w1,w2,b1,b2 = 0,0,0,0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      w1 += 1
    else:
      b1 += 1
  else:
    if s[i] == "0":
      w2 += 1
    else:
      b2 += 1
print(min(w1+b2,w2+b1))
Buggy code:
S=input()
N=len(S)
A=len([_ for i in range(N) if str(i%2)==S[i]])
print(min(A,N-A))

Fixed code:
S=input()
N=len(S)
A=len([i for i in range(N) if str(i%2)==S[i]])
print(min(A,N-A))
Buggy code:
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*len(S)//2
else:
  sample = unit*len(S)//2+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)


Fixed code:
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*(len(S)//2)
else:
  sample = unit*(len(S)//2)+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)
Buggy code:
s=list(input())
c1 = 0
c2 = 0
for i in range(len(s)):
    if i%2 == "0":
        if s[i] == "0":
            c1 += 1
    else:
        if s[i] != "0":
            c1 += 1
    if i%2 != "0":
        if s[i] == "0":
            c2 += 1
    else:
        if s[i] != "0":
            c2 += 1
print(min(c1,c2))

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

A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1
print(max(countA,countB))

Fixed code:
S=list(input())
N=len(S)
A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1

print(min(countA,countB))
Buggy code:
s = list(map(int,input()))

n = int(len(s)/2)

a = [0]*len(s)
b = [0]*len(s)

for i in range(n):
  a[2*i] = 0
  a[2*i+1] = 1
  b[2*i] = 1
  b[2*i+1] = 0

if len(s)%2 ==1:
  a[len(s)-1] = 0
  b[len(s)-1] = 1 

print(a)
print(b)

an = 0
bn = 0

for j in range(len(s)):
  if a[j] != s[j]:
    an += 1
  if b[j] != s[j]:
    bn += 1

print(min(an, bn))

Fixed code:
s = list(map(int,input()))

n = int(len(s)/2)

a = [0]*len(s)
b = [0]*len(s)

for i in range(n):
  a[2*i] = 0
  a[2*i+1] = 1
  b[2*i] = 1
  b[2*i+1] = 0

if len(s)%2 ==1:
  a[len(s)-1] = 0
  b[len(s)-1] = 1 


an = 0
bn = 0

for j in range(len(s)):
  if a[j] != s[j]:
    an += 1
  if b[j] != s[j]:
    bn += 1

print(min(an, bn))
Buggy code:
s = input()
set = [0, 1]
diff = 0

for i in range(len(s)):
    set.reverse()
    print(s)
    if set[1] == int(s[i]):
        diff += 1

print(min([diff, len(s)-diff]))


Fixed code:
s = input()
set = [0, 1]
diff = 0

for i in range(len(s)):
    set.reverse()
    if set[1] == int(s[i]):
        diff += 1

print(min([diff, len(s)-diff]))
Buggy code:
s=input()
count1=0
for i in range(0,len(s)-1,2):
  if s[i]=='0':
    count+=1
  if s[i+1]=='1':
    count+=1
if len(s)%2==1:
  if s[len(s)-1]=='0':
    count+=1
print(min(count,len(s)-count))

Fixed code:
s=input()
count=0
for i in range(0,len(s)-1,2):
  if s[i]=='0':
    count+=1
  if s[i+1]=='1':
    count+=1
if len(s)%2==1:
  if s[len(s)-1]=='0':
    count+=1
print(min(count,len(s)-count))
Buggy code:
# check
length = len(S)
if len == 1:
    print(0)
else:
    bwb = ["0", "1"]
    wbw = ["1", "0"]
    cnt = [0] * 2
    for i in range(length):
        if S[i] == bwb[i % 2]:
            cnt[0] += 1
        if S[i] == wbw[i % 2]:
            cnt[1] += 1
    
    print(min([cnt]))

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

# check
length = len(S)
if len == 1:
    print(0)
else:
    bwb = ["0", "1"]
    wbw = ["1", "0"]
    cnt = [0] * 2
    for i in range(length):
        if S[i] == bwb[i % 2]:
            cnt[0] += 1
        if S[i] == wbw[i % 2]:
            cnt[1] += 1

    print(min(cnt))
Buggy code:
n = list(map(int, input()))

even_list = list()
odd_list = list()

even_list = n[0::2]
odd_list = n[1::2]

count_zero = 0
count_one = 0

#print(len(even_list))
for i in range(len(even_list)):
    if even_list[i] == 1:
        count_zero += 1
for j in range(len(odd_list)):
    if odd_list[j] == 0:
        count_zero += 1

for n in range(len(even_list)):
    if even_list[n] == 0:
        print(even_list[i])
        count_one += 1
for m in range(len(odd_list)):
    if odd_list[m] == 1:
        count_one += 1

print(min(count_zero, count_one))


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

even_list = list()
odd_list = list()

even_list = n[0::2]
odd_list = n[1::2]

count_zero = 0
count_one = 0

#print(len(even_list))
for i in range(len(even_list)):
    if even_list[i] == 1:
        count_zero += 1
for j in range(len(odd_list)):
    if odd_list[j] == 0:
        count_zero += 1

for n in range(len(even_list)):
    if even_list[n] == 0:
        count_one += 1
for m in range(len(odd_list)):
    if odd_list[m] == 1:
        count_one += 1

print(min(count_zero, count_one))
Buggy code:
a = [int(n) for n in input()]
counter=1
for n in range(1, len(a)):
  if a[n-1]==a[n]:
    if a[n-1]==1:
      a[n]=0
    else:
      a[n]=1
    counter+=1
print(counter)

Fixed code:
a = [int(n) for n in input()]
counter=0
for n in range(1, len(a)):
  if a[n-1]==a[n]:
    if a[n-1]==1:
      a[n]=0
    else:
      a[n]=1
    counter+=1
print(counter)
Buggy code:
s = input()
t = len(s)
a = '01'*int(t/2) + '0'*int(t%2)
b = '10'*int(t/2) + '1'*int(t%2)
cta = 0
ctb = 0
for i in range(t):
    if s[i] == a[i]:
        cta += 1
    elif s[i] == b[i]:
        ctb += 1
if cta >= ctb:
    print(cta)
else:
    print(ctb)

Fixed code:
s = input()
t = len(s)
a = '01'*int(t/2) + '0'*int(t%2)
b = '10'*int(t/2) + '1'*int(t%2)
cta = 0
ctb = 0
for i in range(t):
    if s[i] == a[i]:
        cta += 1
    elif s[i] == b[i]:
        ctb += 1
if cta <= ctb:
    print(cta)
else:
    print(ctb)
Buggy code:
import numpy

s = list(input())
N = len(s)
count_A = 0
count_B = 0

for i in range(N):
    s[i] = int(str(s[i]))

A = numpy.empty(N)
B = numpy.empty(N)

for j in range(N):
    if j % 2 == 0 :
        A[j] = 1
        B[j] = 0
    else:
        A[j] = 0
        B[j] = 1

for k in range(N):
    A[k]=s[k]-A[k]
    B[k]=s[k]-B[k]
    if A[k] != 0:
        count_A = count_A + 1
    if B[k] != 0:
        count_B = count_B + 1

print(A)
print(B)

if count_A > count_B :
    print(count_B)
else :
    print(count_A)





Fixed code:
import numpy

s = list(input())
N = len(s)
count_A = 0
count_B = 0

for i in range(N):
    s[i] = int(str(s[i]))

A = numpy.empty(N)
B = numpy.empty(N)

for j in range(N):
    if j % 2 == 0 :
        A[j] = 1
        B[j] = 0
    else:
        A[j] = 0
        B[j] = 1

for k in range(N):
    A[k]=s[k]-A[k]
    B[k]=s[k]-B[k]
    if A[k] != 0:
        count_A = count_A + 1
    if B[k] != 0:
        count_B = count_B + 1

if count_A > count_B :
    print(count_B)
else :
    print(count_A)
Buggy code:
s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))
  

    
    



Fixed code:
s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
a.append('0')
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))
Buggy code:
import sys
S = "10010010"
S_list = list(S)

l = len(S)


if len(S) % 2 == 0:
  ideal1 = list('01' * int(l / 2))
  ideal2 = list('10' * int(l / 2))
else:
  ideal1 = list('01' * (l // 2) + '0')
  ideal2 = list('10' * (l // 2) + '1')

ans = 0
ans1 = 0

for base,compe1 in zip(S_list,ideal1):
    if base != compe1:
        ans = ans + 1

for base,compe2 in zip(S_list,ideal2):
    if base != compe2:
        ans1 = ans1 + 1

print(min(ans,ans1))
        

Fixed code:
import sys
S = input()
S_list = list(S)

l = len(S)


if len(S) % 2 == 0:
  ideal1 = list('01' * int(l / 2))
  ideal2 = list('10' * int(l / 2))
else:
  ideal1 = list('01' * (l // 2) + '0')
  ideal2 = list('10' * (l // 2) + '1')

ans = 0
ans1 = 0

for base,compe1 in zip(S_list,ideal1):
    if base != compe1:
        ans = ans + 1

for base,compe2 in zip(S_list,ideal2):
    if base != compe2:
        ans1 = ans1 + 1

print(min(ans,ans1))
Buggy code:
import numpy as np

S = input()

tile_color = []
for i in S:
    tile_color.append(int(i))

candidate = np.zeros((2,len(S)))
candidate[0, 0::2] = 1
candidate[1, 1::2] = 1

distance = [np.sum(np.abs(candidate[0,:] - tile_color)), np.sum(np.abs(candidate[1,:] - tile_color))]

print(min(distance))

Fixed code:
import numpy as np

S = input()

tile_color = []
for i in S:
    tile_color.append(int(i))

candidate = np.zeros((2,len(S)))
candidate[0, 0::2] = 1
candidate[1, 1::2] = 1

distance = [np.sum(np.abs(candidate[0,:] - tile_color)), np.sum(np.abs(candidate[1,:] - tile_color))]

print(int(min(distance)))
Buggy code:
s = input()

# 1
n = len(s)
case0=0
case1=0

for i in range(n):
  if (i%2==0):
    if s[i]=='0':
      case0 += 1
    else:
      case1 += 1

print(min(case0,case1))

Fixed code:
s = input()
n = len(s)
case0=0
case1=0

for i in range(n):
  if (i%2==0):
    if s[i]=='0':
      case0 += 1
    else:
      case1 += 1
  else :
    if s[i]=='0':
      case1 += 1
    else :
      case0 += 1

print(min(case0,case1))
Buggy code:
s=input()

odd_0=0
even_0=0
odd_1=0
even_1=0

for i in range(len(s)):
	if i%2==1:
		if s[i]==0:
			odd_0+=1
		else:
			odd_1+=1
	if i%2==0:
		if s[i]==0:
			even_0+=1
		else:
			even_1+=1
print(min([even_1+odd_0,even_0+odd_1]))



Fixed code:
s=input()

odd_0=0
even_0=0
odd_1=0
even_1=0

for i in range(len(s)):
	if i%2==1:
		if s[i]=='0':
			odd_0+=1
		else:
			odd_1+=1
	if i%2==0:
		if s[i]=='0':
			even_0+=1
		else:
			even_1+=1
print(min([even_1+odd_0,even_0+odd_1]))
Buggy code:
l =[int(i) for i in list(str(input()))]
ans = 0
num =0
n = 0

if l[0] == 1:
    l=[abs(i-1) for i in l]
print(l)

for i in l:
    if num%2 ==0:
        if i == 1:
            ans = ans +1
    else:
        if i == 0:
            ans =ans +1
    num = num +1
print(ans)

Fixed code:
l =[int(i) for i in list(str(input()))]
ans = 0
num =0
n = 0

if l[0] == 1:
    l=[abs(i-1) for i in l]

for i in l:
    if num%2 ==0:
        if i == 1:
            ans = ans +1
    else:
        if i == 0:
            ans =ans +1
    num = num +1
print(ans)
Buggy code:
l=str(input())
n=0
for i in range(len(l)):
  if i%2==0,l[i]==0:
    n+=1
  if i%2==1,l[i]==1:
    n+=1
print(min(n,len(l)-n))

Fixed code:
l=str(input())
n=0
for i in range(len(l)):
  if i%2==0 and l[i]=='0':
    n+=1
  if i%2==1 and l[i]=='1':
    n+=1
print(min(n,len(l)-n))
Buggy code:
s = input()
oddone = ''
evenone = ''

for i in range(len(s)):
    if i % 2 ==	1:
        oddone += '1'
        evenone += '0'
    else:
	oddone += '0'
	evenone += '1'

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
	print('error')
	return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
	    count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))


Fixed code:
s = input()
oddone = ''
evenone = ''

for i in range(len(s)):
    if i % 2 == 1:
        oddone += '1'
        evenone += '0'
    else:
        oddone += '0'
        evenone += '1'

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
        print('error')
        return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
            count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))
Buggy code:
#coding:utf-8

S = input()

N = len(S)
ans = 0
SR = []
if S[0] == '0':
	for i in range(int(N/2)):
		SR.append('0')
		SR.append('1')
else:
	for i in range(int(N/2)):
		SR.append('1')
		SR.append('0')

for i in range(N):
	if S[i] != SR[i]:
		ans += 1
		
print(ans)
			


Fixed code:
#coding:utf-8

S = input()
N = len(S)
ans = 0
SR = []
if S[0] == '0':
	for i in range(N):
		SR.append('0')
		SR.append('1')
else:
	for i in range(N):
		SR.append('1')
		SR.append('0')

for i in range(N):
	if S[i] != SR[i]:
		ans += 1
		
print(ans)
Buggy code:
s = str(input())

test0 = [x%2 for x in range(len(s))]
test1 = [x%2+1 for x in range(len(s))]

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1
        
print(min(cnt0, cnt1))

Fixed code:
s = str(input())

test0 = [x%2 for x in range(len(s))]
test1 = [x%2 for x in range(len(s) - 1)]
test1.insert(0, 1)

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1

print(min(cnt0, cnt1))
Buggy code:
S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]i
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count += 1

print(min(count,count2))

Fixed code:
S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count2 += 1

print(min(count, count2))
Buggy code:
s = input()
size = len(s)

def poe(b):
  res = 0
  for i in range(size):
    if b:
      a = '1' if i % 2 == 0 else '0'
    else:
      a = '0' if i % 2 == 0 else '1'
 
    if a != s[i]:
      res+=1

  return res

print (poe(True), poe(False))


Fixed code:
s = input()
size = len(s)

def poe(b):
  res = 0
  for i in range(size):
    if b:
      a = '1' if i % 2 == 0 else '0'
    else:
      a = '0' if i % 2 == 0 else '1'
 
    if a != s[i]:
      res+=1

  return res

print(min(poe(True), poe(False)))
Buggy code:
s=list(map(int,str(input())))
print(s)
n=len(s)
a=0
b=0
for i in range(n):
  if ((i%2)+s[i])%2==0:
    a+=1
  else:
    b+=1
print(n-max(a,b))

Fixed code:
s=list(map(int,str(input())))
n=len(s)
a=0
b=0
for i in range(n):
  if ((i%2)+s[i])%2==0:
    a+=1
  else:
    b+=1
print(n-max(a,b))
Buggy code:
#2019/10/24
S = list(map(int, list(open(0).read())))
# print(S)
print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0)) 

Fixed code:
#2019/10/24
# S = list(map(int, list(open(0).read())))
S = list(map(int, input()))
# print(S)
print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0))
Buggy code:
import sys

a = input()
S = [int(c) for c in a]

ans = 0

if S[0] == 0:
	nxt = 1
else:
	nxt = 0

for i, tar in enumerate(S):
	if tar == 0:
		nxt = 1
	else:
		nxt = 0

	if i!=len(S)-1 and S[i] == S[i+1]:
		S[i+1] = nxt
		ans += 1
	

print(S,ans)


Fixed code:
import sys

a = input()
S = [int(c) for c in a]

ans = 0

if S[0] == 0:
	nxt = 1
else:
	nxt = 0

for i, tar in enumerate(S):
	if tar == 0:
		nxt = 1
	else:
		nxt = 0

	if i!=len(S)-1 and S[i] == S[i+1]:
		S[i+1] = nxt
		ans += 1
	

print(ans)
Buggy code:
string=list(input())
if int(string[1]==0):
  c=1
else:
  c=0
a=0
for s in string:
  if int(s)==0 and c==1:
    c-=1
  elif int(s)==0 and c==0:
    c+=1
    a+=1
  elif int(s)==1 and c==0:
	c+=1
  elif int(s)==1 and c==1:
	c-=1
    a+=1
print(a)

Fixed code:
string=list(input())
if int(string[0])==1:
    c=0
else:
    c=1
a=0
for s in string:
    if int(s)==0 and c==1:
        c-=1
    elif int(s)==0 and c==0:
        c+=1
        a+=1
    elif int(s)==1 and c==0:
        c+=1
    elif int(s)==1 and c==1:
        c-=1
        a+=1
print(a)
Buggy code:
s = input()
n = len(s)
count = 0
count2 = 0
print(s, len(s))
for i in range(n):
    if i % 2 == 0:
        x = "0"
    else:
        x = "1"
    if s[i] == x:
        count2 += 1
        #print(i, s[i], x, "OK")
    else:
        count += 1
        #print(i, s[i], x)
print(min(count,count2))

Fixed code:
s = input()
n = len(s)
count = 0
count2 = 0
for i in range(n):
    if i % 2 == 0:
        x = "0"
    else:
        x = "1"
    if s[i] == x:
        count2 += 1
    else:
        count += 1
print(min(count,count2))
Buggy code:
S=input()
N=len(S)
tile=[0 if i&1==0 else 1 for i in range(N)]
ans=0
for i in range(N):
  if S[i]!=tile[i]:
    ans+=1
print(ans if ans<= N//2 else N-ans)

Fixed code:
S=input()
N=len(S)
tile=['0' if i&1==0 else '1' for i in range(N)]
ans=0
for i in range(N):
  if S[i]!=tile[i]:
    ans+=1
print(ans if ans<=N//2 else N-ans)
Buggy code:
N = input()
S = [int(c) for c in N]

A = [0] * (len(S)+1)
B = [0] * (len(S)+1)

for i in range((len(S)//2)+1):
  A[i*2+1] = 1
  B[i*2] = 1
  
  
ca =0
cb =0
for i in range(len(S)):
  ca += abs(S[i]-A[i])
  cb += abs(S[i]-B[i])
print(min(ca, cb))
  
  

Fixed code:
N = input()
S = [int(c) for c in N]

A = [0] * (len(S)+4)
B = [0] * (len(S)+4)

for i in range((len(S)//2)+1):
  A[i*2+1] = 1
  B[i*2] = 1
  
ca =0
cb =0
for i in range(len(S)):
  ca += abs(S[i]-A[i])
  cb += abs(S[i]-B[i])
print(min(ca, cb))