qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S_array = [int(c) for c in list(input())]
count = 0

if len(S_array) == 1:
  print(count)

for i in range(len(S_array) - 1):
  if S_array[i] != S_array[i + 1]:
    continue
  elif S_array[i] == 0:
    S_array[i + 1] = 1
  else:
    S_array[i + 1] = 0
  count = count + 1

print(count)


Fixed code:
S_array = [int(c) for c in list(input())]
count = 0

if len(S_array) == 1:
  print(count)
  exit()

for i in range(len(S_array) - 1):
  if S_array[i] != S_array[i + 1]:
    continue
  elif S_array[i] == 0:
    S_array[i + 1] = 1
  else:
    S_array[i + 1] = 0
  count = count + 1

print(count)
Buggy code:
def color(s):
    k = 0
    for i in range(len(s)-1):
        if s[i+1]==s[i]:
            if s[i]=='0':
                s[i+1]='1'
            if s[i]=='1':
                s[i+1]='0'
            k = k+1
    return k
    
s=list(input())
color(s)

Fixed code:
def color(s):
    k = 0
    for i in range(len(s)-1):
        if s[i+1]==s[i]:
            if s[i]=='0':
                s[i+1]='1'
            if s[i]=='1':
                s[i+1]='0'
            k = k+1
    return k
    
s=list(input())
print(color(s))
Buggy code:
tiles = input()

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

for i, t in enumerate(tiles):
    if i % 2 == 0:
        if t == '0':
            even_0 += 1
        else:
            even_1 += 1
    else:
        if t == '0':
            even_0 += 1
        else:
            even_1 += 1

if even_0 + odd_1 >= even_1 + odd_0:
    print(even_1 + odd_0)
else:
    print(even_0 + odd_1)

Fixed code:
tiles = input()

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

for i, t in enumerate(tiles):
    if i % 2 == 0:
        if t == '0':
            even_0 += 1
        else:
            even_1 += 1
    else:
        if t == '0':
            odd_0 += 1
        else:
            odd_1 += 1

# print(even_0, even_1, odd_0, odd_1)

if even_0 + odd_1 >= even_1 + odd_0:
    print(even_1 + odd_0)
else:
    print(even_0 + odd_1)
Buggy code:
s=input()
sento1 = 0
sento0 = 0
for i in range(len(s)):

  if i % 2 == 0:
    
    if s[i] == '1':
      sento1 += 1
      
    elif s[i] == '0':
      sento0 += 1
      
  else:
    if s[i] == '0':
      sento1 += 1
    elif s[i] == '1'
      sento0 += 1
      
print(min(sento1,sento0))

Fixed code:
s=input()
sento1 = 0
sento0 = 0
for i in range(len(s)):

  if i % 2 == 0:
    
    if s[i] == '1':
      sento1 += 1
      
    elif s[i] == '0':
      sento0 += 1
      
  else:
    if s[i] == '0':
      sento1 += 1
    elif s[i] == '1':
      sento0 += 1
      
print(min(sento1,sento0))
Buggy code:
import numpy as np
H = input()
H = str.split(H)
H = np.array(H, int)
x = []
y = []
for i in range(len(H)):
    x.append(i%2)
    y.append((i+1)//2)
print(H == np.array(x))
print(H == np.array(y))
a = sum(H == np.array(x))
b = sum(H == np.array(y))

if(a>=b):
    print(len(H)-a)
else:
    print(len(H)-b)

Fixed code:
import numpy as np
tmp = str(input())

H = []
for i in range(len(tmp)):
    H.append(int(tmp[i]))

#print(H)
H = np.array(H, int)

#print(H)
x = []
y = []
for i in range(len(H)):
    x.append(i%2)
    y.append((i+1)%2)
#print(H == np.array(x))
#print(H == np.array(y))
a = sum(H == np.array(x))
b = sum(H == np.array(y))

if(a>=b):
    print(len(H)-a)
else:
    print(len(H)-b)
Buggy code:
import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
else:
    for u in range(len(s)):
        if s[u] != b[u]:
            c+=1
print(c)

Fixed code:
import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)
Buggy code:
import sys

input = sys.stdin.readline

def main():
    S = input()
    l = len(S)
    ws = ''
    bs = ''
    for i in range(l):
        if i%2 == 0:
            ws += '0'
            bs += '1'
        else:
            ws += '1'
            bs += '0'
    wsc = 0
    bsc = 0
    for i in range(l):
        if S[i] != ws[i]:
            wsc += 1
        if S[i] != bs[i]:
            bsc += 1
    print(min(wsc, bsc))

if __name__ == '__main__':
    main()

Fixed code:
import sys

input = sys.stdin.readline

def main():
    S = input().rstrip('\n')
    l = len(S)
    ws = bs = ''
    for i in range(l):
        if i%2 == 0:
            ws += '0'
            bs += '1'
        else:
            ws += '1'
            bs += '0'
    wsc = bsc = 0
    for i in range(l):
        if S[i] != ws[i]:
            wsc += 1
        if S[i] != bs[i]:
            bsc += 1
    ans = min(wsc, bsc)
    print(ans)

if __name__ == '__main__':
    main()
Buggy code:
S = input()
d = int(S[0])
T = []
U = []
for i in range(len(S)):
  T.append(d)
  d = (d + 1) % 2
  U.append(d)
count1 = 0
count2 = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count1 += 1
  if S[i] != U[i]:
    count2 += 1
print(min(count1, count2))

  

Fixed code:
S = input()
d = int(S[0])
T = []
U = []
for i in range(len(S)):
  T.append(d)
  d = (d + 1) % 2
  U.append(d)
count1 = 0
count2 = 0
for i in range(len(S)):
  if int(S[i]) != T[i]:
    count1 += 1
  if int(S[i]) != U[i]:
    count2 += 1
print(min(count1, count2))
Buggy code:
s = input()
x, count0, count1 = 0
for i in s:
    count0 = count0+1 if i==str(x) else count0
    x = int(not(x))
x = 1
for i in s:
    count1 = count1 + 1 if i == str(x) else count1
    x = int(not(x))
print(min(count0, count1))

Fixed code:
s = input()

x = 0
count0 = 0
count1 = 0

for i in s:
    if i == str(x):
        count0 += 1
    x = int(not(x))

x = 1
for i in s:
    if i == str(x):
        count1 += 1
    x = int(not(x))

print(min(count0, count1))
Buggy code:
S = input()
s1 = '0'
s2 = '1'
c1 = 0
c2 = 0

for i in range(len(S)):
    if i == 0:
        s1 = '0'
        s2 = '1'
    elif i % 2 == 1:
        s1 += 1
        s2 += 0
    else:
        s1 += 0
        s2 += 1

for i in range(len(S)):
    if S[i] == s1[i]:
        c2 += 1
    else:
        c1 += 1

print(min(c1, c2))

Fixed code:
S = input()
c1 = 0
c2 = 0

for i in range(len(S)):
    if i == 0:
        s1 = '0'
        s2 = '1'
    elif i % 2 == 1:
        s1 += '1'
        s2 += '0'
    else:
        s1 += '0'
        s2 += '1'

for i in range(len(S)):
    if S[i] == s1[i]:
        c2 += 1
    else:
        c1 += 1

print(min(c1, c2))
Buggy code:
s=list(input())
count1=0
count2=0
for i in range(len(s)):
  if s[i]==s[i+1]:
    count1=count1+1
for i in range(1,len(s)):
  if s[i]==s[i+1]:
    count2=count2+1
if count1>=count2:
  print(count1)
else:
  print(count2)

Fixed code:
s=list(input())
count1=0
count2=0
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    count1=count1+1
    if s[i+1]=='0':
      s[i+1]='1'
    else:
      s[i+1]='0'
for i in range(1,len(s)-1):
  if s[i]==s[i+1]:
    count2=count2+1
    count1=count1+1
    if s[i+1]=='0':
      s[i+1]='1'
    else:
      s[i+1]='0'
if count1>=count2:
  print(count1)
else:
  print(count2)
Buggy code:
import sys, math
input = sys.stdin.readline

S = list(input().replace('\n',''))
S = map(int, S)
prev = S[0]
ans = 0
for i in range(1, len(S)-1):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)

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

S = list(input().replace('\n',''))
S = list(map(int, S))
prev = S[0]
ans = 0
for i in range(1, len(S)):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
#     if i == 1:
#       if cur ^ S[i+1] == 1:
#         prev = cur
#       else:
#         prev = 2 + ~cur
#     else:
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)
Buggy code:
def load_input():
    s = [int(c) for c in list(input())]
    return s


def main():
    s = load_input()

    cand = []
    cand.append([0 if i % 2 == 0 else 1 for i in range(len(s))])
    cand.append([0 if i % 2 == 0 else 1 for i in range(len(s))])

    diff = [0, 0]
    for i in range(2):
        for j in range(len(s)):
            if s[j] != cand[i][j]:
                diff[i] += 1
    if diff[0] < diff[1]:
        print(diff[0])
    else:
        print(diff[1])


if __name__ == '__main__':
    main()


Fixed code:
def load_input():
    s = [int(c) for c in list(input())]
    return s


def main():
    s = load_input()

    cand = []
    cand.append([0 if i % 2 == 0 else 1 for i in range(len(s))])
    cand.append([0 if i % 2 == 1 else 1 for i in range(len(s))])

    diff = [0, 0]
    for i in range(2):
        for j in range(len(s)):
            if s[j] != cand[i][j]:
                diff[i] += 1
    if diff[0] < diff[1]:
        print(diff[0])
    else:
        print(diff[1])


if __name__ == '__main__':
    main()
Buggy code:
a = list(input())
b = a[::2].index('0') + a[1::2].index('1')
c = min(b, len(a) - b)
print(c)


Fixed code:
a = list(input())
b = a[::2].count('0') + a[1::2].count('1')
c = min(b, len(a) - b)
print(c)
Buggy code:
S = input().strip()
ansB = 0
ansW = 0
for i,c in emumerate(S):
  if (i % 2 == 0):
    if (c == '0'):
      ansW += 1
  else:
   	if (c == '1'):
      ansB += 1

ans = min(ansW, ansB)
print(ans)

Fixed code:
S = input().strip()
ansB = 0
ansW = 0
for i,c in enumerate(S):
	if (i % 2 == 0):
		if (c == '0'):
			ansW += 1
		else:
			ansB += 1
	else:
		if (c == '1'):
			ansW += 1
		else:
			ansB += 1
ans = min(ansW, ansB)
print(ans)
Buggy code:
l=len(s)

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

else:
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "0":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "1":
                ans+=1

print(ans)

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

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

else:
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "0":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "1":
                ans+=1

print(ans)
Buggy code:
gen = get_input()

S = list(input())

count = 0
s1 = S[:]
for i in range(1, len(S)):
    if s1[i - 1] == s1[i]:
        s1[i] = '0' if s1[i-1] == '1' else '1'
        count += 1

count2 = 0
s2 = S[:]
for i in reversed(range(len(S)-1)):
    if s2[i] == s2[i +1]:
        s2[i] = '0' if s2[i+1] == '1' else '1'
        count2 += 1

print(min(count, count2))

Fixed code:
S = list(input())
 
count = 0
s1 = S[:]
for i in range(1, len(S)):
    if s1[i - 1] == s1[i]:
        s1[i] = '0' if s1[i-1] == '1' else '1'
        count += 1
 
count2 = 0
s2 = S[:]
for i in reversed(range(len(S)-1)):
    if s2[i] == s2[i +1]:
        s2[i] = '0' if s2[i+1] == '1' else '1'
        count2 += 1
 
print(min(count, count2))
Buggy code:
s = input()

fc = s[0]
nc = ""

count = 0

if fc == "0":
    nc = "1"
else:
    nc = "0"

for i in range(1,len(s)):
    if s[i] != nc :
        count += 1
        nc = s[i]

print(count)


Fixed code:
s = input()

fc = s[0]
nc = ""

count = 0

if fc == "0":
    nc = "1"
else:
    nc = "0"

for i in range(1,len(s)):
    if s[i] != nc :
        count += 1
        nc = s[i]
    else:
        if nc == "0":
            nc = "1"
        else:
            nc = "0"

print(count)
Buggy code:
cnt = 0
num = '1'
    s = input()
    for i in range(len(s)):
        if s[i] == num:
            cnt += 1
        if num == '1':
            num = '0'
        else:
            num = '1'
    print(min(int(len(s)-cnt),cnt))

Fixed code:
cnt = 0
num = '1'
s = input()
for i in range(len(s)):
    if s[i] == num:
        cnt += 1
    if num == '1':
        num = '0'
    else:
        num = '1'
print(min(int(len(s)-cnt),cnt))
Buggy code:
S = list(int, map(input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)-1):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)-1):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



Fixed code:
S = list(map(int, 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 i in range(len(S)):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))
Buggy code:
S = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0 and S[i] == 0:
      ans1 += 1
  elif i %2 ==1 and S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0 and S[i] == 1:
      ans2 += 1
  elif i % 2 ==1 and S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



Fixed code:
S = list(map(int, input()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0 and S[i] == 0:
      ans1 += 1
  elif i %2 ==1 and S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0 and S[i] == 1:
      ans2 += 1
  elif i % 2 ==1 and S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))
Buggy code:
S = list(input())

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

Fixed code:
S = list(input())

a = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        a += 1
        if S[i] == "0":
            S[i] = "1"
        else:
            S[i] = "0"
    else:
        pass
print(a)
Buggy code:
l = len(colors)
count1 = 0
for i in range(l):
	if colors[i] == i % 2:
		count1 += int(colors[i])
print(min(count1, l-count1))

Fixed code:
colors = input()
l = len(colors)
count1 = 0
for i in range(l):
	if int(colors[i]) == (i % 2):
		count1 += 1
print(min(count1, l-count1))
Buggy code:
s = input()
pattern1 = 0
patetrn2 = 0
for i in range(len(s)):
  if i %2 == 0:
    if s[i] == "0":
      pattern1 += 1
    else:
      patetrn2 += 1
  else:
    if s[i] == "0":
      pattern2 += 1
    else:
      patetrn1 += 1
print(min(patetrn1,patetrn2))

Fixed code:
s = input()
pattern1 = 0
pattern2 = 0
for i in range(len(s)):
  if i %2 == 0:
    if s[i] == "0":
      pattern1 += 1
    else:
      pattern2 += 1
  else:
    if s[i] == "0":
      pattern2 += 1
    else:
      pattern1 += 1
print(min(pattern1,pattern2))
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
        e =s[i]

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
if k == '1':
    e = '0'
else :
    e = '1'

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))
Buggy code:
a=input()

if len(a)==1:
  print(0)
  exit()
  
b=[::2]
c=[1::2]

b0=b.count("0")
b1=b.count("1")
c0=c.count("0")
c1=c.count("1")

print(min(b0+c1,b1+c0))

Fixed code:
a=input()

if len(a)==1:
  print(0)
  exit()
  
b=a[::2]
c=a[1::2]

b0=b.count("0")
b1=b.count("1")
c0=c.count("0")
c1=c.count("1")

print(min(b0+c1,b1+c0))
Buggy code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
S = stdin.readline()
L = len(S)
cnt = 0
# 0101010101
for i, s in enumerate(S):
    if i & 1 == 1:
        cnt += 1 if s == '1' else 0
    else:
        cnt += 1 if s == "0" else 0
print(min(cnt, L-cnt))


Fixed code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
S = stdin.readline()
L = len(S)
cnt = 0
cnt1 = 0
# 0101010101
for i, s in enumerate(S):
    if i & 1 == 1:
        incr = 1 if s == '1' else 0
        cnt += incr
    else:
        incr = 1 if s == '0' else 0
        cnt += incr
for i, s in enumerate(S):
    if i & 1 == 1:
        incr = 1 if s == '0' else 0
        cnt1 += incr
    else:
        incr = 1 if s == '1' else 0
        cnt1 += incr
print(min(cnt, cnt1))
Buggy code:
li = list(input())
sums = 0
leng = int(len(li))

for i in range(leng):
    now = i
    print(now)
    if (now + 1) >= leng:
        print(now)
        break
    if(li[now] == li[now + 1]):
        if(li[now + 1] == '0'):
            li[now + 1] = '1'
        else:
            li[now + 1] = '0'
        sums += 1
print(sums)


Fixed code:
li = list(input())
sums = 0
leng = int(len(li))

for i in range(leng):
    now = i
    if (now + 1) >= leng:
        break
    if(li[now] == li[now + 1]):
        if(li[now + 1] == '0'):
            li[now + 1] = '1'
        else:
            li[now + 1] = '0'
        sums += 1
print(sums)
Buggy code:
S = input()
odd = S[1::2]
even = S[::2]
print(min(odd.count("1") + even.count("0"), even.count("0") + odd.count("1")))

Fixed code:
S = input()
odd = S[1::2]
even = S[::2]
print(min(odd.count("1") + even.count("0"), even.count("1") + odd.count("0")))
Buggy code:
S = input()

min(S[::2].count("0")+S[1::2].count("1"), S[::2].count("1")+S[1::2].count("0"))

Fixed code:
S = input()

print(min(S[::2].count("0")+S[1::2].count("1"), S[::2].count("1")+S[1::2].count("0")))
Buggy code:
s = input()
n = len(s)
if n % 2 == 1:
    n += 1
pattern = '01' * (n // 2)

ans_a = 0
ans_b = 0
for i, (a, b) in enumerate(zip(pattern[1:], pattern[:-1])):
    if pattern[i] != a:
        ans_a += 1
    if pattern[i] != b:
        ans_b += 1
print(min(ans_a, ans_b))


Fixed code:
s = input()
n = len(s)
if n % 2 == 1:
    n += 1
pattern = '01' * ((n + 10) // 2)

ans_a = 0
ans_b = 0
for i, (a, b, ss) in enumerate(zip(pattern[1:], pattern[:-1], s)):
    if ss != a:
        ans_a += 1
    if ss != b:
        ans_b += 1
print(min(ans_a, ans_b))
Buggy code:
s = str(input())

print(s)
count =0
for xi in range(len(s)):
    if xi%2 ==0:t="0"
    if xi%2 ==1:t="1"

    if s[xi]==t:
        count+=1

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


Fixed code:
s = str(input())

# print(s)
count =0
for xi in range(len(s)):
    if xi%2 ==0:t="0"
    if xi%2 ==1:t="1"

    if s[xi]==t:
        count+=1

# print(count)
print(min(count,len(s)-count))
Buggy code:
from collections import Counter
moji = str(input())
guall = len(moji)//2
kiall = guall + len(moji) % 2
gucount=dict(Counter(moji[1::2]))
kicount=dict(Counter(moji[0::2]))
if max(gucount, key=gucount.get) != max(kicount, key=kicount.get):
    ans = guall - max(gucount.values()) + kiall - max(kicount.values())
else:
    if kiall - max(kicount.values()) > guall - max(gucount.values()):
        ans = max(kicount.values()) + guall - max(gucount.values())
    else:
        ans = max(gucount.values()) + kiall - max(kicount.values())
print(ans)

Fixed code:
from collections import Counter
moji = str(input())
guall = len(moji)//2
kiall = guall + len(moji) % 2
gucount=dict(Counter(moji[1::2]))
kicount=dict(Counter(moji[0::2]))
if len(moji) == 1:
    ans = 0
elif max(gucount, key=gucount.get) != max(kicount, key=kicount.get):
    ans = guall - max(gucount.values()) + kiall - max(kicount.values())
else:
    if kiall - max(kicount.values()) > guall - max(gucount.values()):
        ans = max(kicount.values()) + guall - max(gucount.values())
    else:
        ans = max(gucount.values()) + kiall - max(kicount.values())
print(ans)
Buggy code:
s = int(input())
count = 0
for i in ragen(len(s)):
    if (i % 2 == 0 and s[i] ==0) or (i % 2 ==1 and s[i] == 1):
        pass
    else:
        count += 1
print(min[count,len(s) - count])

Fixed code:
s = [int(i) for i in input()]
count = 0
l = len(s)
for i in range(l):
    if (i % 2 == 0 and s[i] ==0) or (i % 2 ==1 and s[i] == 1):
        pass
    else:
        count += 1
print(min([count,l - count]))
Buggy code:
S = list(input())
a=0
b=0
if S[0]=="0":
    for i in S[::2]:
        print(i)
        if i=="1":
            a+=1
    for k in S[1::2]:
        if k=="0":
            a+=1

if S[0]=="1":
    for i in S[::2]:
        if i=="0":
            b+=1
    for k in S[1::2]:
        if k=="1":
            b+=1
print(max(a,b))

Fixed code:
S = list(input())
a=0
b=0
for i in S[::2]:
    if i=="1":
        a+=1
for k in S[1::2]:
    if k=="0":
        a+=1

for i in S[::2]:
    if i=="0":
        b+=1
for k in S[1::2]:
    if k=="1":
        b+=1
print(min(a,b))
Buggy code:
s = list(input())
count = 0
for i in range(1,n):
  if s[i] == s[i-1]:
    if s[i] == "0":
      s[i] = "1"
    else:
      s[i] = "0"
    count += 1
print(count)

Fixed code:
s = list(input())

count = 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"
    count += 1
    
print(count)
Buggy code:
s = list(input())
s1 = []
s2 = []
for i in range(len(s)):
    if i % 2 == 0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
print(min(min_1, min_2))

Fixed code:
s = list(input())
s1 = []
s2 = []
for i in range(len(s)):
    if i % 2 == 0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
min_1 = 0
#for i in range(2):
for i in range(len(s)):
    if s[i] != s1[i]:
        min_1 += 1
        
min_2 = 0
for i in range(len(s)):
    if s[i] != s2[i]:
        min_2 += 1
print(min(min_1, min_2))
Buggy code:
n = list(map(int,list(input())))
print(n)

num = n[0]
total = 0
for i in range(1,len(n)):
    if n[i] == n[i-1]:
        total += 1
        if n[i] == 1:
            n[i] = 0
        else:
            n[i] = 1

print(total)


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

num = n[0]
total = 0
for i in range(1,len(n)):
    if n[i] == n[i-1]:
        total += 1
        if n[i] == 1:
            n[i] = 0
        else:
            n[i] = 1

print(total)
Buggy code:
def resolve():
    S = list(input())

    ans = 0
    for i in range(1, len(S)):
        if (S[i - 1] == S[i]):
            ans += 1

            if S[i] == '0':
                S[i] = '1'
            else:
                S[i] = '0'

    print(ans)

Fixed code:
def resolve():
    S = list(input())

    ans = 0
    for i in range(1, len(S)):
        if (S[i - 1] == S[i]):
            ans += 1

            if S[i] == '0':
                S[i] = '1'
            else:
                S[i] = '0'

    print(ans)


resolve()
Buggy code:
l=list(str(input()))
l=[int(i) for i in l]
cnt=0
for i in range(len(l)-1):
  if(l[i]==l[i+1]):
    cnt+=1
    if(l[i]==0):
      l[i+1]=1
    elif(l[i]==1):
      l[i+1]=0
print(l,cnt)

Fixed code:
l=list(str(input()))
l=[int(i) for i in l]
cnt=0
for i in range(len(l)-1):
  if(l[i]==l[i+1]):
    cnt+=1
    if(l[i]==0):
      l[i+1]=1
    elif(l[i]==1):
      l[i+1]=0
print(cnt)
Buggy code:
S = input()
back = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = S

print(n);

Fixed code:
S = input()
back = 0
n = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = i

print(n);
Buggy code:
import numpy as np

n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size-1):
#  print(i)
  if int(n[i]) == new_list[i]:
    count+=1

ans = n_size-count    
print(ans)    
    


Fixed code:
#import numpy as np

n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size):
  if (int(n[i]) != int(new_list[i])):
    count+=1

#print(new_list)    
if n_size == 1:
  print(0)
else:
#  ans = n_size-count    
  print(count)