qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S=input()
result1=0
result2=0
if S[0]=='1':
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                result1+=1
            if S[i]=='1':
                result2+=1
        else:
            if S[i]=='1':
                result1+=1
            if S[i]=='0':
                result2+=1
    print(min(result1,result2))
else:
     for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                result1+=1
            if S[i]=='1':
                result2+=1
        else:
            if S[i]=='1':
                result1+=1
            if S[i]=='0':
                result2+=1
    print(min(result1,result2))

Fixed code:
S=input()
result1=0
result2=0
if S[0]=='1':
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                result1+=1
            if S[i]=='1':
                result2+=1
        else:
            if S[i]=='1':
                result1+=1
            if S[i]=='0':
                result2+=1
    print(min(result1,result2))
else:
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                result1+=1
            if S[i]=='1':
                result2+=1
        else:
            if S[i]=='1':
                result1+=1
            if S[i]=='0':
                result2+=1
    print(min(result1,result2))
Buggy code:
S = list(input())
stlen = len(S) 
if len(S)%2 == 0:
    a = '10'*(stlen/2)
    b = '01'*(stlen/2)
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
else:
    a = '10'*(int(stlen/2))+'1'
    b = '01'*int((stlen/2))+'0'
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))

Fixed code:
S = list(input())
stlen = len(S) 
if len(S)%2 == 0:
    a = '10'*(int(stlen/2))
    b = '01'*(int(stlen/2))
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
else:
    a = '10'*(int(stlen/2))+'1'
    b = '01'*(int(stlen/2))+'0'
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
Buggy code:
s = list(map(int,input()))
count1 = 0
count2 = 0
if len(s) == 1:
    print(0) 
else:
    for i in range(len(s)):
        if i % 2 == 0 and s[i] != 0:
            count1 += 1
        elif i%2 !=0 and s[i] != 1:
            count1 += 1
    for i in range(len(s)):
        if i % 2 == 0 and s[i] != 2:
            count2 += 1
        elif i%2 !=0 and s[i] != 0:
            count2 += 1
    print(min(count1,count2))

Fixed code:
s = list(map(int,input()))
n = len(s)
count1 = 0
count2 = 0
if n == 1:
    print(0) 
else:
    for i in range(n):
        if i%2 == 0 and s[i] != 0:
            count1 += 1
        elif i%2 != 0 and s[i] != 1:
            count1 += 1
    for i in range(n):
        if i%2 == 0 and s[i] != 1:
            count2 += 1
        elif i%2 !=0 and s[i] != 0:
            count2 += 1
    print(min(count1,count2))
Buggy code:
s = input()
t = s[::2].count('0') + s[1::2].count('1')
print(min(t, len(s)))

Fixed code:
s = input()
t = s[::2].count('0') + s[1::2].count('1')
print(min(t, len(s)-t))
Buggy code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    s = input().rstrip()
    l = len(s)
    a = 0
    ans = 0

    t = 1
    for i in s:
        if t != i:
            a += 1
        t = 1-t
    ans = a
    t = 0
    for i in s:
        if t != i:
            a += 1
        t = 1-t
    ans = min(a,ans)
    print(ans)

if __name__=="__main__":
    main()


Fixed code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    s = input().rstrip()
    l = len(s)
    a = 0
    ans = 0

    t = 1
    for i in s:
        if t != int(i):
            a += 1
        t = 1-t
    ans = a
    t = 0
    a = 0
    for i in s:
        if t != int(i):
            a += 1
        t = 1-t
    ans = min(a,ans)
    print(ans)

if __name__=="__main__":
    main()
Buggy code:
s = list(input())

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

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

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))
Buggy code:
S = list(input())

res_10 = 0
res_01 = 0

for i in range(N):
    if i % 2 == 0:
        if S[i] == "0":
            res_10 += 1
        else:
            res_01 += 1
    else:
        if S[i] == "1":
            res_10 += 1
        else:
            res_01 += 1
print(min(res_10, res_01))

Fixed code:
S = list(input())
 
res_10 = 0
res_01 = 0
 
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            res_10 += 1
        else:
            res_01 += 1
    else:
        if S[i] == "1":
            res_10 += 1
        else:
            res_01 += 1
print(min(res_10, res_01))
Buggy code:
s = str(input())
S = [int(s[i]) for i in range(len(s))]
a = []
b = []
counta = 0
countb = 0
for i in range(len(S)):
    if i == 0 or i%2==0:
        a.append(0)
        b.append(1)
    else:
        a.append(1)
        b.append(0)
print(a)
print(b)
for i in range(len(S)):
    if S[i] != a[i]:
        counta += 1
    elif S[i] != b[i]:
        countb += 1
print(min(counta,countb))


Fixed code:
s = str(input())
S = [int(s[i]) for i in range(len(s))]
a = []
b = []
counta = 0
countb = 0
for i in range(len(S)):
    if i == 0 or i%2==0:
        a.append(0)
        b.append(1)
    else:
        a.append(1)
        b.append(0)
for i in range(len(S)):
    if S[i] != a[i]:
        counta += 1
    elif S[i] != b[i]:
        countb += 1
print(min(counta,countb))
Buggy code:
import Levenshtein

S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    print(S[x])
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
    

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

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
Buggy code:
s = input()
lb = 0
lw = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            lb += 1
        else:
            lw += 1
    else:
        if s[i] == '0':
            lw += 1
        else:
            lb += 1
print(max(lb,lw))

Fixed code:
s = input()
lb = 0
lw = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            lb += 1
        else:
            lw += 1
    else:
        if s[i] == '0':
            lw += 1
        else:
            lb += 1
print(min(lb,lw))
Buggy code:
s = int(input())

start0 = 0
start1 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      start1 += 1
    elif s[i] == "1":
      start0 += 1
  elif i % 2 == 1:
    if s[i] == "0":
      start0 += 1
    elif s[i] == "1":
      start1 += 1

print(min([start0, start1]))

Fixed code:
s = input()
 
start0 = 0
start1 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      start1 += 1
    elif s[i] == "1":
      start0 += 1
  elif i % 2 == 1:
    if s[i] == "0":
      start0 += 1
    elif s[i] == "1":
      start1 += 1

print(min([start0, start1]))
Buggy code:
S = list(input())
L = len(S)

def change():
    global moji
    if moji == "1":
        moij = "0"
    else:
        moji = "1"

# case 1
count_1 = 0
moji = "1"
for c in range(L):
    if moji == S[c]:
        pass
    else:
        count_1 += 1
    change()

# case 2
count_2 = 0
moji = "0"
for c in range(L):
    if moji == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)

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

def change():
    global kk
    if kk == "1":
        kk = "0"
    else:
        kk = "1"

# case 1
count_1 = 0
kk = "1"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_1 += 1
    change()
    

# case 2
count_2 = 0
kk = "0"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)
Buggy code:
s = input()
odd = s[0::2]
even = s[1::2]

odd0 = odd.count("0")
odd1 = odd.count("1")
even0 = even.count("0")
even1 = even.count("1")

print(max((odd0 + even1), (odd1 + even0)))


Fixed code:
s = input()
odd = s[0::2]
even = s[1::2]

odd0 = odd.count("0")
odd1 = odd.count("1")
even0 = even.count("0")
even1 = even.count("1")

print(min((odd0 + even1), (odd1 + even0)))
Buggy code:
List=[int(i) for i in input().split()] 
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)

Fixed code:
List=input()
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for (i,j) in zip(List,a):
	if int(i) != int(j):
		c1 += 1

for (i,j) in zip(List,b):
	if int(i) != int(j):
		c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)
Buggy code:
S = input().rstrip()
zero_zero = 0
one_zero = 0
zero_one = 0
one_one = 0
one = 0
zero = 0
for i in range(-(-len(S)//2)):
    tmp = S[i*2:i*2+2]
    if tmp == "00":
        zero_zero += 1
    elif tmp == "01":
        zero_one += 1
    elif tmp == "10":
        one_zero += 1
    elif tmp == "11":
        one_one += 1
    elif tmp == "1":
        one += 1
    else:
        zero += 1
counter = 0
if zero_one > one_zero:
    counter += one_zero*2 + zero_zero + one_one + one
elif zero_one < one_zero:
    counter += zero_one*2 + zero_zero + one_one + zero
else:
    counter += zero_one*2 + zero_zero + one_one + zero + one
print(counter if len(S) != 1 else 0)

Fixed code:
S = input().rstrip()
zero_zero = 0
one_zero = 0
zero_one = 0
one_one = 0
one = 0
zero = 0
for i in range(-(-len(S)//2)):
    tmp = S[i*2:i*2+2]
    if tmp == "00":
        zero_zero += 1
    elif tmp == "01":
        zero_one += 1
    elif tmp == "10":
        one_zero += 1
    elif tmp == "11":
        one_one += 1
    elif tmp == "1":
        one += 1
    else:
        zero += 1
counter = 0
if zero_one > one_zero:
    counter += one_zero*2 + zero_zero + one_one + one
elif zero_one < one_zero:
    counter += zero_one*2 + zero_zero + one_one + zero
else:
    counter += zero_one*2 + zero_zero + one_one
print(counter if len(S) != 1 else 0)
Buggy code:
s = input()
ans = s[0]

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

Fixed code:
s = input()
ans = s[0]
count = 0
for i in range(1, len(s)):
    if ans[len(ans)-1] == s[i]:
        if s[i] == "0":
            ans += "1"
        else:
            ans += "0"
        count += 1
    else:
        ans += s[i]
print(count)
Buggy code:
str = input()
S = list(str)
N = len(S)
count = 0
for x in range(N):
    if x % 2 == 0 and S[x] == "0":
        count += 1
    elif x % 2 == 1 and S[x] == "1":
        count += 1
if count >= 50000:
    print(count - 50000)
else:
    print(count)



Fixed code:
str = input()
S = list(str)
N = len(S)
count = 0
for x in range(N):
    if x % 2 == 0 and S[x] == "0":
        count += 1
    elif x % 2 == 1 and S[x] == "1":
        count += 1
if count > N / 2:
    print(N - count)
else:
    print(count)
Buggy code:
s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 1:
    a <<= 2
    a += 1
print(bin(a))
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))

Fixed code:
s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 0:
    a <<= 2
    a += 1
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))
Buggy code:
S = input()
N = len(S)
ans1 = 0
ans2 = 0
for i in range(N):
  x = a[i]
  if i % 2 == 0:
    if x == '0':
      ans1 += 1
    else:
      ans2 += 1
  else:
    if x == '1':
      ans1 += 1
    else:
      ans2 += 1
ans = min(ans1,ans2)
print(ans)

Fixed code:
S = input()
N = len(S)
ans1 = 0
ans2 = 0
for i in range(N):
  x = S[i]
  if i % 2 == 0:
    if x == '0':
      ans1 += 1
    else:
      ans2 += 1
  else:
    if x == '1':
      ans1 += 1
    else:
      ans2 += 1
ans = min(ans1,ans2)
print(ans)
Buggy code:
S = list(input())

cnt = 0
a = S[0]

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

Fixed code:
S = list(input())

cnt = 0
a = S[0]

for i in range(1,len(S)):
  if S[i] == a:
    cnt += 1
    if S[i] == "1":
      a = "0"
    else:
      a = "1"
  else:
    a = S[i]
    
print(int(cnt))
Buggy code:
s = list(input())
n = len(s)

s1 = [0]*n
s2 = [1]*n
for i in range(1,n,2):
  s1[i] = 1
  s2[i] = 0

count1 = 0
count2 = 0
for i in range(n):
  if s[i]!=s1[i]: count1 += 1
  if s[i]!=s2[i]: count2 += 1
print(min(count1,count2))


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

s1 = [0]*n
s2 = [1]*n
for i in range(1,n,2):
  s1[i] = 1
  s2[i] = 0

count1 = 0
count2 = 0
for i in range(n):
  if s[i]!=s1[i]: count1 += 1
  if s[i]!=s2[i]: count2 += 1
print(min(count1,count2))
Buggy code:
if __name__ == "__main__":
    l = int(input())
    l = [int(x) for x in list(str(l))]
    length = len(l)
    temp1 = []
    temp2 = []
    for i in range(length):
        temp1.append(i % 2)
        temp2.append((i + 1) % 2)
    t1 = 0
    t2 = 0
    for n in range(length):
        if temp1[n] != l[n]:
            t1 += 1
        if temp2[n] != l[n]:
            t2 += 1
    print(min(t1, t2))


Fixed code:
if __name__ == "__main__":
    l = str(input())
    l = [int(x) for x in list(str(l))]
    length = len(l)
    temp1 = []
    temp2 = []
    for i in range(length):
        temp1.append(i % 2)
        temp2.append((i + 1) % 2)
    t1 = 0
    t2 = 0
    for n in range(length):
        if temp1[n] != l[n]:
            t1 += 1
        if temp2[n] != l[n]:
            t2 += 1
    print(min(t1, t2))
Buggy code:
s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, n):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(-(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)

Fixed code:
s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, len(s)):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(-(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)
Buggy code:
S = input()
word_01 = '01'
word_10 = '10'
q, mod = divmod(len(S), 2)
if mod == 0:
    word_01 = word_01 * q
    word_10 = word_10 * q
else:
    word_01 = word_01 * (q-1) + '0'
    word_10 = word_10 * (q-1) + '1'
S_list = list(S)
word_01_list = list(word_01)
word_10_list = list(word_10)
counter1 = 0
counter2 = 0
for num1, num2, num3 in zip(S_list, word_01_list, word_10_list):
    if num1 != num2:
        counter1 += 1
    if num1 != num3:
        counter2 += 1
result = min(counter1, counter2)
print(result)

Fixed code:
S = input()
word_01 = '01'
word_10 = '10'
q, mod = divmod(len(S), 2)
if mod == 0:
    word_01 = word_01 * q
    word_10 = word_10 * q
else:
    word_01 = word_01 * q + '0'
    word_10 = word_10 * q + '1'
S_list = list(S)
word_01_list = list(word_01)
word_10_list = list(word_10)
counter1 = 0
counter2 = 0
for num1, num2, num3 in zip(S_list, word_01_list, word_10_list):
    if num1 != num2:
        counter1 += 1
    if num1 != num3:
        counter2 += 1
result = min(counter1, counter2)
print(result)
Buggy code:
s= str(input())
ans = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            ans += 1
            
    else:
        if s[i] == '1':
            ans += 1
            
print(min(ans,len(s)-ans),ans)

Fixed code:
s= str(input())
ans = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            ans += 1

    else:
        if s[i] == '1':
            ans += 1

print(min(ans,len(s)-ans))
Buggy 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
        #print(i, s[i], x, "OK")
    else:
        count += 1
        #print(i, s[i], x)
print(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
        #print(i, s[i], x, "OK")
    else:
        count += 1
        #print(i, s[i], x)
print(min(count,count2))
Buggy code:
char_list = list(input())
count1 = 0
count2 = 0
if len(char_list) == 1:
    print(count)
else:
    for i in char_list:
        if i % 2 == 0
            if char_list[i] is "0"
                continue
            else:
                count1 += 1
        else:
            if char_list[i] is "1"
                continue
            else:
                count1 += 1
    for i in char_list:
        if i % 2 == 0
            if char_list[i] is "1"
                continue
            else:
                count2 += 1
        else:
            if char_list[i] is "0"
                continue
            else:
                count2 += 1
print(min(count1,count2))

Fixed code:
char_list = list(input())
count1 = 0
count2 = 0
if len(char_list) == 1:
    print(0)
else:
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "0":
                continue
            else:
                count1 += 1
        else:
            if char_list[i] is "1":
                continue
            else:
                count1 += 1
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "1":
                continue
            else:
                count2 += 1
        else:
            if char_list[i] is "0":
                continue
            else:
                count2 += 1
    print(min(count1,count2))
Buggy code:
def d201(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='0'):
                count+=1
        else:
            if(a[i]=='1'):
                count+=1
    return count

                
def d210(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='1'):
                count+=1
        else:
            if(a[i]=='0'):
                count+=1
    return count

a=input()
print(min(d210(a),d201(a))
                




Fixed code:
def d201(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='0'):
                count+=1
        else:
            if(a[i]=='1'):
                count+=1
    return count

                
def d210(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='1'):
                count+=1
        else:
            if(a[i]=='0'):
                count+=1
    return count

a=input()
print(min(d210(a),d201(a)))
Buggy code:
s = input()

ans0 = 0
ans1 = 1
for i, s_i in enumerate(s):
    if i % 2 == 0:
        if s_i == '0':
            ans1 += 1
        else:
            ans0 += 1
    else:
        if s_i == '0':
            ans0 += 1
        else:
            ans1 += 1
print(min(ans0, ans1))


Fixed code:
s = input()

ans0 = 0
ans1 = 0
for i, s_i in enumerate(s):
    if i % 2 == 0:
        if s_i == '0':
            ans1 += 1
        else:
            ans0 += 1
    else:
        if s_i == '0':
            ans0 += 1
        else:
            ans1 += 1
print(min(ans0, ans1))
Buggy code:
s = input()
for i in range(1,len(s)):
    if s[i-1] == "0" and s[i] == s[i-1]:
        s = s[:i] + "1" + s[i+1:]
    elif s[i-1] == "1" and s[i] == s[i-1]:
        s = s[:i] + "0" + s[i+1:]
print(s)

Fixed code:
s = input()
count = 0
for i in range(1,len(s)):
    if s[i-1] == "0" and s[i] == s[i-1]:
        s = s[:i] + "1" + s[i+1:]
        count += 1
    elif s[i-1] == "1" and s[i] == s[i-1]:
        s = s[:i] + "0" + s[i+1:]
        count += 1
print(count)
Buggy code:
a  = input()
s = 0
t = 0
k = ["0","1"]
for n,i in enumerate(a):
  if i != k[(n%2)]:
    s+=1
  if i != k[(n%2)+1]:
    t+=1
print(min(s,t))
  
  

Fixed code:
a  = input()
s = 0
t = 0
k = ["0","1"]
for n,i in enumerate(a):
  if i != k[(n%2)]:
    s+=1
  if i != k[(n+1)%2]:
    t+=1
print(min(s,t))
Buggy code:
S = input()
T = []
tmp = '1'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
tmp = '0'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
print(T)
ans = float('inf')
for j in range(2):
    cnt = 0
    for i in range(len(S)):
        if S[i] != T[j][i]:
            cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)


Fixed code:
S = input()
T = []
tmp = '1'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
tmp = '0'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
ans = float('inf')
for j in range(2):
    cnt = 0
    for i in range(len(S)):
        if S[i] != T[j][i]:
            cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)
Buggy code:
s = input()
l = [int(i) for i in s[0::2]]
r = [int(i) for i in s[1::2]]
print(l)
print(r)
if len(s) == 1:
    print(0)
else:
    l_count1 = l.count(1)
    l_count0 = len(l)-l_count1
    r_count1 = r.count(1)
    r_count0 = len(r)-r_count1
    l_1 = l_count0+r_count1
    l_0 = l_count1+r_count0
    if (l_count1==len(l) and r_count0==len(r)) or (l_count0==len(l) and r_count1==len(r)):
        print(0)
    elif l_1 < l_0:
        print(l_1)
    else:
        print(l_0)


Fixed code:
s = input()
l = [int(i) for i in s[0::2]]
r = [int(i) for i in s[1::2]]

if len(s) == 1:
    print(0)
else:
    l_count1 = l.count(1)
    l_count0 = len(l)-l_count1
    r_count1 = r.count(1)
    r_count0 = len(r)-r_count1
    l_1 = l_count0+r_count1
    l_0 = l_count1+r_count0
    if (l_count1==len(l) and r_count0==len(r)) or (l_count0==len(l) and r_count1==len(r)):
        print(0)
    elif l_1 < l_0:
        print(l_1)
    else:
        print(l_0)
Buggy code:
def main():
    s = input()
    n = len(s)
    a = 0
    b = 0
    for i in range(n):
        if i & 1:
            if arr[i] == '1':
                a += 1
            else:
                b += 1
        else:
            if arr[i] == '1':
                b += 1
            else:
                a += 1
        print(min(a, b))
    return 0
main()

Fixed code:
def main():
    s = input()
    n = len(s)
    a = 0
    b = 0
    for i in range(n):
        if i & 1:
            if s[i] == '1':
                a += 1
            else:
                b += 1
        else:
            if s[i] == '1':
                b += 1
            else:
                a += 1
    print(min(a, b))
    return 0
main()