Problem:
 Score : 300 points    Problem Statement N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N .  The i -th tile from the left is painted black if the i -th character of S is 0 , and painted white if that character is 1 .  You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.  At least how many tiles need to be repainted to satisfy the condition?      Constraints  1 \leq |S| \leq 10^5  S_i is 0 or 1 .         Input Input is given from Standard Input in the following format:  S       Output Print the minimum number of tiles that need to be repainted to satisfy the condition.        Sample Input 1 000      Sample Output 1 1  The condition can be satisfied by repainting the middle tile white.       Sample Input 2 10010010      Sample Output 2 3       Sample Input 3 0      Sample Output 3 0

Solution (Python):
def main():
    S = input()

    cnt1 = 0

    
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s == '0':
                cnt1 += 1
        else:
            if s == '1':
                cnt1 += 1

    cnt2 = 0
    
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s == '1':
                cnt2 += 1
        else:
            if s == '0':
                cnt2 += 1

    print(min(cnt1,cnt2))



main()

Solution (Python):
s=input()
n=s[::2].count("1")+s[1::2].count("0")
print(min(n,len(s)-n))

Solution (Python):
S=input()

WB=['1' if i%2==1 else '0' for i in range(len(S))]

answb,ansbw=0,0
for i in range(len(S)):
  if S[i]!=WB[i]:
    answb+=1
  else:
    ansbw+=1
print(min(answb,ansbw))

Solution (Python):
S = list(map(int, input().strip()))

T = [(1 + (-1)**i) / 2 for i in range(len(S))]
U = [(1 + (-1)**(i-1)) / 2 for i in range(len(S))]

st = sum([abs(s-t) for s, t in zip(S, T)])
su = sum([abs(s-u) for s, u in zip(S, U)])

print(int(min(st, su)))

Solution (Python):
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)))

Solution (Python):
s = list(input())
toBeList1 = []
toBeList2 = []
ans1 = 0
ans2 = 0
for i in range(len(s)):
  toBeList1.append(str(i%2))
  toBeList2.append(str((i+1)%2))
  if s[i] != toBeList1[i]:
    ans1 += 1
  if s[i] != toBeList2[i]:
    ans2 += 1

print(min(ans1,ans2))

Solution (Python):
S = input()
E = ''
O = ''
for i in range(len(S)):
  if i % 2 == 0:
    E += '1'
    O += '0'
  else:
    E += '0'
    O += '1'
p, q = 0, 0
for i in range(len(S)):
  if E[i] != S[i]:
    p += 1
  if O[i] != S[i]:
    q += 1
print(min(p, q))

Solution (Python):
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]))

Solution (Python):
s=[int(i) for i in input()]
c=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:
        c+=1
print(min([c,l-c]))

Solution (Python):
s=input()
n = s[::2].count("0") + s[1::2].count("1")
print(min(n,len(s)-n))

Solution (Python):
s = input()
n = len(s) // 2 + 1
l1 = "01" * n
l2 = "10" * n
a1 = 0
a2 = 0
for i in range(len(s)):
    if l1[i] != s[i]:
        a1 += 1
    if l2[i] != s[i]:
        a2 += 1
    
print(min(a1, a2))

Solution (Python):
import sys
input=sys.stdin.readline

def main():
    s = input().strip()
    S = [int(i) for i in s]
    n1 = 0
    n2 = 0
    for i,v in enumerate(S):
        if i%2 == 0:
            if v == 0:
                n1 += 1
            else:
                n2 += 1
        else:
            if v == 1:
                n1 += 1
            else:
                n2 += 1
    print(min(n1,n2))
if __name__ == '__main__':
    main()

Solution (Python):
s = input()
n = len(s)
c0 = 0
c1 = 0
for i in range(n):
  if i % 2 == 0 and s[i] == '1':
    c0 += 1
  elif i % 2 == 1 and s[i] == '0':
    c0 += 1    
for i in range(n):
  if i % 2 == 1 and s[i] == '1':
    c1 += 1
  elif i % 2 == 0 and s[i] == '0':
    c1 += 1    
print(min(c0,c1))

Solution (Python):
s = input()
n = len(s)
c0 = 0
c1 = 0
for i in range(n):
  if i % 2 == 0 and s[i] == '1':
    c0 += 1
  elif i % 2 == 1 and s[i] == '0':
    c0 += 1    
for i in range(n):
  if i % 2 == 1 and s[i] == '1':
    c1 += 1
  elif i % 2 == 0 and s[i] == '0':
    c1 += 1    
print(min(c0,c1))

Solution (Python):
S = input()
prev = S[0]
res = 0
for i in range(1, len(S)):
  if prev == S[i]:
    res += 1
  prev = ["1", "0"][int(prev == "1")]
print(res)

Solution (Python):
s = list(input())
ans = 0
for idx in range(1,len(s)):
    if s[idx] == s[idx-1]:
        ans += 1
        if s[idx] == '0':
            s[idx] = '1'
        else:
            s[idx] = '0'
print(ans)

Solution (Python):
S = input()
n = len(S)
templ1 = ""
templ2 = ""
if n&1:
    templ1 = "10" * (n//2) + "1"
    templ2 = "01" * (n//2) + "0"
else:
    templ1 = "10" * (n//2)
    templ2 = "01" * (n//2)

diff1 = 0
diff2 = 0
for s,t1,t2 in zip(S,templ1,templ2):
    if s != t1:
        diff1 += 1
    if s != t2:
        diff2 += 1
print(min(diff1,diff2))

Solution (Python):
S = input()
pattern1 = "".join([str(x%2) for x in range(len(S))])
pattern2 = "".join([str((x+1)%2) for x in range(len(S))])

def energy(st1, st2):
  ene = 0
  for i in range(len(st1)):
    ene += abs(int(st1[i])-int(st2[i]))
  return ene

print(min(energy(S, pattern1), energy(S, pattern2)))

Solution (Python):
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))

Solution (Python):
s = input()
n = len(s)
a = "10"*(n//2) + '1'*(n%2)
p = 0

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

print(min(p,n-p))

Solution (Python):
s = list(input())
ans = 0

for i in range(len(s)):
    if s[0] == '0':
        if i % 2 == 0:
            if s[i] != '0':
                ans += 1
        else:
            if s[i] != '1':
                ans += 1
    else:
        if i % 2 == 0:
            if s[i] != '1':
                ans += 1
        else:
            if s[i] != '0':
                ans += 1
            
print(ans)

Solution (Python):
def dif(s, l):
    diff = 0
    for i, j in zip(s, l):
        if i != j:
            diff += 1
    return diff


S = list(input())
S = list(map(int, S))
L1 = [int(1) if i % 2 == 0 else int(0) for i in range(len(S))]
L2 = [int(0) if i % 2 == 0 else int(1) for i in range(len(S))]
print(min(dif(S, L1), dif(S, L2)))

Solution (Python):
s = input()
n = len(s)

A = [i%2 for i in range(n)]
B = [(i+1)%2 for i in range(n)]

ans0 = 0
ans1 = 0

for i in range(n):
    if int(s[i]) != A[i]:
        ans0 += 1
    if int(s[i]) != B[i]:
        ans1 += 1

print(min(ans0, ans1))

Solution (Python):
def MAP(): return map(int,input().split())
s = input()
ans_1, ans_2= 0,0
for i,v in enumerate(s):
    if (i%2==0) and (v!="0"):
        ans_1+=1
    elif (i%2==1) and (v!="1"):
        ans_1+=1

for i,v in enumerate(s):
    if (i%2==0) and (v!="1"):
        ans_2+=1
    elif (i%2==1) and (v!="0"):
        ans_2+=1

print(min(ans_1,ans_2))

Solution (Python):
import numpy as np
S = np.array(list(input()), dtype = int)
r = [0,0]
for ii in range(2):
    l = np.zeros(len(S), dtype = int)
    l[ii::2] = 1
    r[ii] = abs(S - l).sum()

print (min(r))

Solution (Python):
s = list(map(int, list(input())))
x = [i % 2 for i in range(len(s))]
y = [i % 2 for i in range(1, len(s) + 1)]
cntx = cnty = 0
for i, j, k in zip(s, x, y):
    if i != j:
        cntx += 1
    if i != k:
        cnty += 1
print(min(cntx, cnty))

Solution (Python):
import math
S = input()



kzero = 0
kone = 0
gzero = 0
gone = 0


buff1 = [0 for i in range(2)]
buff2 = [0 for i in range(2)]

_len = len(S)
gu_kazu = math.ceil(_len/2)
ki_kazu = _len//2

for i in range(_len):
    if i % 2 == 0:
        if S[i] == '0':
            buff1[0] += 1
        else:
            buff1[1] += 1

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

print(min(gu_kazu-buff1[0]+ki_kazu-buff2[1],gu_kazu-buff1[1]+ki_kazu-buff2[0]))

Solution (Python):
def dist(x, y):
    return sum([0 if x == y else 1 for x, y in zip(x, y)])


S = list(input())

p1 = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
p2 = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

print(min(dist(S, p1), dist(S, p2)))

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
ans1,ans2 = 0,0
for i in range(len(s)):
    if i % 2:
        if s[i] == '0':
            ans1 += 1
        else:
            ans2 += 1
    else:
        if s[i] == '1':
            ans1 += 1
        else:
            ans2 += 1
ans = min(ans1,ans2)
print(ans)

Solution (Python):
s = list(map(int, list(input())))

a = [abs(s[i]-1) if i%2==0 else s[i] for i in range(len(s))]
b = [abs(s[i]-1) if i%2==1 else s[i] for i in range(len(s))]
print(min(sum(a),sum(b)))

Solution (Python):
s = input()
t = s[::2].count('0') + s[1::2].count('1')
print(min(t, len(s)-t))

Solution (Python):
s = input()
n = len(s)
if n % 2 == 1:
    pattern1 = '01' * (n // 2) + '0'
    pattern2 = '10' * (n // 2) + '1'
else:
    pattern1 = '01' * (n // 2)
    pattern2 = '10' * (n // 2)

diff1 = 0
diff2 = 0
for i in range(n):
    if pattern1[i] != s[i]:
        diff1 += 1
    if pattern2[i] != s[i]:
        diff2 += 1
print(min(diff1, diff2))

Solution (Python):
s = input()
cnt_01 = 0
cnt_10 = 0

for i in range(len(s)):
    if (i % 2 == 0 and s[i] == "0") or (i % 2 == 1 and s[i] == "1"):
        cnt_01 += 1
    if (i % 2 == 0 and s[i] == "1") or (i % 2 == 1 and s[i] == "0"):
        cnt_10 += 1

print(min(cnt_01, cnt_10))

Solution (Python):
s = input()


def count(a):
    global s
    cnt = 0
    for i in range(len(s)):
        if (i % 2 == 0 and s[i] == a[0]) or (i % 2 == 1 and s[i] == a[1]):
            cnt += 1
    return cnt


print(min(count("10"), count("01")))

Solution (Python):
s = input()
s = list(s[i] for i in range(len(s)))
count=0
if len(s)==0 and s[0]=="0":
  print(0)
else:
  for i in range(len(s)):
    if i==len(s)-1:pass
    else:
      if s[i]==s[i+1]=="0":
        s[i+1]="1"
        count+=1
      elif s[i]==s[i+1]=="1":
        s[i+1]="0"
        count+=1
print(count)

Solution (Python):
import math
import copy
import fractions
import numpy as np
from functools import reduce



def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



n, = map(str, input().split())
inputlist = list(n)

ansZero = 0
ansOne = 0

flg = False
for i in range(len(n)):
    if flg:
        if inputlist[i]=="0":
            ansZero+=1
    else:
        if inputlist[i]=="1":
            ansZero+=1
    flg = not flg

flg = True
for i in range(len(n)):
    if flg:
        if inputlist[i]=="0":
            ansOne+=1
    else:
        if inputlist[i]=="1":
            ansOne+=1
    flg = not flg

ans = min(ansZero, ansOne)

print(ans)

Solution (Python):
N = list(input())

ans1 = 0
expected = N[0]
for n in N[1:]:
    if expected == n:
        ans1 += 1
        if n == '0':
            expected = '1'
        else:
            expected = '0'
    else:
        expected = n

N.reverse()
ans2 = 0
expected = N[0]
for n in N[1:]:
    if expected == n:
        ans2 += 1
        if n == '0':
            expected = '1'
        else:
            expected = '0'
    else:
        expected = n


print(min(ans1, ans2))

Solution (Python):
s=input()

d={'0':'1','1':'0'}

s1='1'
s2='0'
cnt1=0
cnt2=0
for a in s:
	if s1!=a:cnt1+=1
	if s2!=a:cnt2+=1
	s1=d[s1]
	s2=d[s2]
print(min(cnt1,cnt2))

Solution (Python):
S = input()
n = len(S)
S = int(S, 2)

A = '0b'
B = '0b'
for i in range(n):
    if i % 2 == 0:
        A += '0'
        B += '1'
    else:
        A += '1'
        B += '0'

ans = min(bin(S ^ int(A, 0)).count('1'), bin(S ^ int(B, 0)).count('1'))
print(ans)

Solution (Python):
s = input()
a = 0
b = 0
for i in range(len(s)):
    x = int(s[i])
    a += abs(x - i % 2)
    b += abs(x - (i+1) % 2)
print(min(a, b))

Solution (Python):
n = input()
l = len(n)

per0 = str('0')
for i in range(l-1):
    if (i+1)%2 == 0:
        per0 = per0 + str('0')
    else:
        per0 = per0 + str('1')

per1 = str('1')
for i in range(l-1):
    if (i+1)%2 == 0:
        per1 = per1 + str('1')
    else:
        per1 = per1 + str('0')

count0 = 0
count1 = 0
for i in range(l):
    if n[i] == per0[i]:
        count0 = count0 + 1
    elif n[i] == per1[i]:
        count1 = count1 + 1
    else:
        count0 = count0
        count1 = count1

print(min(count0,count1))

Solution (Python):
text=input()
N=len(text)
count0=0
count1=0
sgn=0
for i in range(N):
  if(int(text[i])==sgn):
    count1=count1+1
  else:
    count0=count0+1
  sgn=1-sgn
print(min([count0,count1]))

Solution (Python):
import numpy as np

S = input()
N = len(S)
s = np.array([int(i) for i in list(S)])
s1 = np.array([i % 2 for i in range(N)])
s2 = abs(s1 - np.array([1] * N))

print(min(np.sum(np.abs(s - s1)), np.sum(np.abs(s - s2))))

Solution (Python):
import numpy as np

S = input()
N = len(S)
s = np.array([int(i) for i in list(S)])
s1 = np.array([i % 2 for i in range(N)])
s2 = np.array([(i + 1) % 2 for i in range(N)])

print(min(np.sum(np.abs(s - s1)), np.sum(np.abs(s - s2))))

Solution (Python):
s = input()
a = 0
b = 1
x = 0
y = 0
for i in range(len(s)):
  t = ord(s[i]) - 48
  if t != a:
    x += 1
  if t != b:
    y += 1
  a ^= 1
  b ^= 1
print(min(x, y))

Solution (Python):
import numpy as np

S = list(int(x) for x in input())
L1 = [0 if x%2 == 0 else 1 for x in range(len(S))]
L2 = [0 if x%2 == 1 else 1 for x in range(len(S))]

print(min(sum(np.logical_xor(S, L1)), sum(np.logical_xor(S,L2))))

Solution (Python):
O = input()
N = len(O)
total0=0
total1=0

for i in range(N):
    if(int(O[i])==i%2):
        total0+=1
    else:
        total1+=1

print(min(total0,total1))

Solution (Python):
import sys
input = list(input())
s = [int(i) for i in input]

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

ans2 = 0
for j in range(len(s)):
    if j % 2 == 0:
        if s[j] == 0:
            ans2 += 1
    else:
        if s[j] == 1:
            ans2 += 1

print(min(ans1,ans2))

Solution (Python):
s = input()
a = [int(c) for c in s]
b = a[:]
ans1 = 0
ans0 = 0


if a[0] == 0:
    a[0] = 1
    ans1 += 1
for i in range(1,len(s)):
    if a[i] == a[i-1]:
        a[i] = (a[i-1]+1)%2
        ans1 += 1

if b[0] == 1:
    b[0] = 0
    ans0 += 1
for i in range(1,len(s)):
    if b[i] == b[i-1]:
        b[i] = (b[i-1]+1)%2
        ans0 += 1
print(min(ans1,ans0))

Solution (Python):
import sys
input = sys.stdin.readline

import copy

def main(): 

    row = list(input().split())
    row = list(map(int,row[0]))

    S = copy.deepcopy(row)
    count = 0
    for i in range(1,len(S)):
        if S[i-1] == S[i]:
            if S[i-1] == 1: S[i] = 0
            else: S[i] = 1
            count+=1

    S = copy.deepcopy(row)
    count2 = 1
    if S[0] == 1: 
        S[0] = 0
    else: 
        S[0] = 1
    for i in range(1,len(S)):
        if S[i-1] == S[i]:
            if S[i-1] == 1: S[i] = 0
            else: S[i] = 1
            count2+=1
    print(min(count,count2))

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline

import copy

def main(): 

    row = list(input().split())
    row = list(map(int,row[0]))

    S = copy.deepcopy(row)
    count = 0
    for i in range(1,len(S)):
        if S[i-1] == S[i]:
            if S[i-1] == 1: S[i] = 0
            else: S[i] = 1
            count+=1

    S = copy.deepcopy(row)
    count2 = 1
    if S[0] == 1: 
        S[0] = 0
    else: 
        S[0] = 1
    for i in range(1,len(S)):
        if S[i-1] == S[i]:
            if S[i-1] == 1: S[i] = 0
            else: S[i] = 1
            count2+=1
    print(min(count,count2))

if __name__ == "__main__":
    main()

Solution (Python):
S = input()
odd0 = 0
odd = 0
even0 = 0
even = 0
for i in range(len(S)):
    if i%2==0:
        even += 1
        if S[i] == "0":
            even0 += 1
    if i%2==1:
        odd += 1
        if S[i] == "0":
            odd0 += 1
print(min(even - even0 + odd0, odd - odd0 + even0))

Solution (Python):
s = list(input())
n = len(s)
even0 = s[1::2].count("0")
even1 = n // 2 - even0
odd0 = s[::2].count("0")
odd1 = n - even0 - even1 - odd0
print(n - max(even0 + odd1, even1 + odd0))

Solution (Python):
S = list(input())
ansA=0 
ansB=0
for i in range(len(S)):
    if i%2 ==0:
        if S[i] =="1" :
            ansA+=1
    else:
        if S[i] == "0":
            ansA+=1
for i in range(len(S)):
    if i%2 ==0:
        if S[i] == "0":
            ansB+=1
    else:
        if S[i] == "1":
            ansB+=1
ans = min(ansA,ansB)
print(ans)

Solution (Python):
S = input()

a = sum([1 for i in range(len(S)) if S[i] == "0" and i % 2 == 0 or  
                                     S[i] == "1" and i % 2 == 1])
b = sum([1 for i in range(len(S)) if S[i] == "1" and i % 2 == 0 or  
                                     S[i] == "0" and i % 2 == 1])
print (min(a,b))

Solution (Python):
s = input()
c = 0
nums = ["0", "1"]
for i,v in enumerate(s):
  if v == nums[i % 2]:
    c += 1
print(min(c, len(s)-c))

Solution (Python):
s = input()
n = len(s)
if n == 1:
  print(0)
  exit()

cnt_e = 0
cnt_o = 0
for i in range(0,n,2):
  if s[i] == '1':
    cnt_o += 1
for i in range(1,n,2):
  if s[i] == '1':
    cnt_e += 1
print(min((n+1)//2 - cnt_o + cnt_e, n//2 - cnt_e + cnt_o))

Solution (Python):
def main(s):
    pattern1 = ["0" if i % 2 == 0 else "1" for i in range(len(s))]
    pattern2 = ["1" if i % 2 == 0 else "0" for i in range(len(s))]
    dist1 = 0
    dist2 = 0
    for i in range(len(s)):
        if s[i] != pattern1[i]:
            dist1 += 1
        if s[i] != pattern2[i]:
            dist2 += 1

    return min(dist1, dist2)


s = input()



print(main(s))

Solution (Python):
s = input()

ev = s[0::2]
od = s[1::2]

print(min(ev.count('1')+od.count('0'), ev.count('0')+od.count('1')))

Solution (Python):
def main():
    S = input()
    N = len(S)
    count1 = 0
    count2 = 0
    for i in range(N):
        count1 += (str(i%2) != S[i])
        count2 += (str((i+1)%2) != S[i])
    return min(count1, count2) 

if __name__ == '__main__':
    print(main())

Solution (Python):

S = list(map(int, input()))

before = S[0]
count = 0
for c in S[1:]:
    if before == c:
        before = (c ^ 1)
        count += 1
    else:
        before = c

print(count)

Solution (Python):
s = input()
m1 = {0 : 0, 1 : 0}
m2 = {0 : 0, 1 : 0}
for c in s[::2]:
    m1[int(c)] += 1
for c in s[1::2]:
    m2[int(c)] += 1
print(min(m1[0] + m2[1], m1[1] + m2[0]))

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



S = str(input())
n = len(S)

count1 = 0
count2 = 0

for i in range(n):
    if i%2==0:
        if S[i]=='0':
            count1 += 1
        else:
            count2 += 1
    else:
        if S[i]=='1':
            count1 += 1
        else:
            count2 += 1

print(min(count1,count2))

Solution (Python):
*S, = map(int, list(input()))
n = len(S)
T = [0, 1]*(n//2)+[0]*(n%2)
A = [s^t for s, t in zip(S, T)]
a = sum(A)
print(min(a, n-a))

Solution (Python):
s = list(input())
count1 = 0
count2 = 0

if s[0] == '0':
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == '0':
                continue
            else:
                count1 +=1
        else:
            if s[i] == '1':
                continue
            else:
                count1 += 1
            
else:
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == '1':
                continue
            else:
                count2 += 1
        else:
            if s[i] == '0':
                continue
            else:
                count2 += 1
            
print(max(count1,count2))

Solution (Python):
s = str(input())
len_s = len(s)

p = "0"
ans_1 = 0
for i in range(len_s):
    if s[i] != p:
        ans_1 += 1
    if p == "0":
        p = "1"
    else:
        p = "0"
        
q = "1"
ans_2 = 0
for j in range(len_s):
    if s[j] != q:
        ans_2 += 1
    if q == "0":
        q = "1"
    else:
        q = "0"

ans = min(ans_1, ans_2)
print(ans)

Solution (Python):
s=input()
l=len(s)
sum1=0
sum2=0

a=[0 for i in range(l)]
c=[0 for i in range(l)]
d=[0 for i in range(l)]

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

for i in range(l):
  if i%2==0:
    c[i]=1

for i in range(l):
  if i%2==1:
    d[i]=1
    
for i in range(l):
  sum1+=abs(a[i]-c[i])
  sum2+=abs(a[i]-d[i])
  

print(min(sum1,sum2))

Solution (Python):
S = input()
c = S[::2].count('0') + S[1::2].count('1') 
d=S[::2].count('1') + S[1::2].count('0')
print(min(c,d))

Solution (Python):
from collections import defaultdict as dd


INF = float("inf")
MOD = int(1e9 + 7)


def main():
    S = input()
    N = len(S)

    class solve:
        def __init__(self):
            self.v = [0, 0]
    count = dd(solve)
    for i, s in enumerate(S):
        count[i % 2].v[int(s)] += 1
    
    
    print(min(count[0].v[0] + count[1].v[1], count[0].v[1] + count[1].v[0]))

main()

Solution (Python):
s = list( input() )
n = len(s)

ans1 = 0
for i in range(n):
    if i % 2 != int(s[i]):
        ans1 += 1

ans2 = 0
for i in range(n):
    if (i+1) % 2 != int(s[i]):
        ans2 += 1

print(min(ans1,ans2))

Solution (Python):
S = input()

count1 = 0
count2 = 0

n = 0

for c in S:
    if n % 2 == 0 and c == '0':
        count1 += 1
    if n % 2 == 1 and c == '1':
        count1 += 1
    n += 1

n = 0

for c in S:
    if n % 2 == 0 and c == '1':
        count2 += 1
    if n % 2 == 1 and c == '0':
        count2 += 1
    n += 1
print(min(count1,count2))

Solution (Python):
s = list(map(int,list(input())))

n = len(s)
anses = [[], []]
for i in range(n):
  anses[0].append(i % 2)
  anses[1].append((i + 1) % 2)

draw = [0, 0]
for i in range(n):
  if s[i] != anses[0][i]:
    draw[0] += 1
  if s[i] != anses[1][i]:
    draw[1] += 1

print(min(draw))

Solution (Python):
s = list(map(int,input()))
sp = s.copy()
count = 0
counta = 0
if sp[0] == 0:
  for i in range(len(sp)):
    if sp[i] != i%2:
      count += 1
      sp[i] = i%2
    
  for i in range(len(sp)):
    if sp[i] != (i+1)%2:
      counta += 1
      sp[i] = (i+1)%2
    
if s[0] == 1 :
  for i in range(len(s)):
    if s[i] != (i+1)%2:
      counta += 1
      s[i] = (i+1)%2
  for i in range(len(s)):
    if s[i] != i%2:
      count += 1
      s[i] = i%2



print(min(count,counta))

Solution (Python):
S = list(input())

l = len(S)
c1 = 0 
c2 = 0

for i in range(l):
  if i%2 ==0:
    if S[i] == "0":
      c1 += 1
    else:
      c2 += 1
  else:
    if S[i] == "0":
      c2 += 1
    else:
      c1 += 1
    
print(min(c1,c2))

Solution (Python):
s=list(input())
cnt=0
for i in range(len(s)-1):
    if s[i]==s[i+1] and s[i]=='0':
        s[i+1]='1'
        cnt+=1
    elif s[i]==s[i+1] and s[i]=='1':
        s[i+1]='0'
        cnt+=1
print(cnt)

Solution (Python):

def main():
    S = input()
    a = S[::2].count("1") + S[1::2].count("0")
    b = len(S) - a
    print(min(a, b))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    S = input()
    a = sum(i != "1" for i in S[::2]) + sum(i != "0" for i in S[1::2])
    b = len(S) - a
    print(min(a, b))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    s = input()
    a, ans = s[0], 0
    for i, j in enumerate(s):
        if (i % 2 and j == a) or (not i % 2 and j != a):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import collections

s=list(input())
ans=0
for i in range(len(s)-1):
    if s[i]=="0" and s[i+1]=="0":
        s[i+1]="1"
        ans+=1
    elif s[i]=="1" and s[i+1]=="1":
        s[i+1]="0"
        ans+=1
    else:
        pass
    
print(ans)

Solution (Python):
S = str(raw_input())
n = len(S)

pattern0 = ("10" * (n//2 + 1))
pattern1 = ("01" * (n//2 + 1))
count0 = 0
count1 = 0

for i in range(n):
    if pattern0[i] != S[i]:
        count0 += 1
    if pattern1[i] != S[i]:
        count1 += 1

print min(count0, count1)

Solution (Python):
s = input()

ans_a = 0
ans_b = 0
for i in range(len(s)):
	if i%2 == 0 and s[i] =="0":
		pass
	elif i%2 == 1 and s[i]=="1":
		pass
	else:
		ans_a += 1

for i in range(len(s)):
	if i%2 == 0 and s[i] =="1":
		pass
	elif i%2 == 1 and s[i]=="0":
		pass
	else:
		ans_b += 1
print(min(ans_a, ans_b))

Solution (Python):
s = list(str(input()))
l = len(s)
ans = 0
for i in range(l-1):
    if s[i] == s[i+1]:
        if s[i] == '0':
            s[i+1] = '1'
            ans += 1
        else:
            s[i+1] = '0'
            ans += 1
    else:
        continue

print(ans)

Solution (Python):
S=input()
a,c=0,True
for i in range(len(S)):
    if int(S[i])!=c:
        a+=1
    c=not c
print(min(a,len(S)-a))

Solution (Python):
s = list(input())
s = [int(_) for _ in s]
if len(s)%2 == 0:
    li1 = [0,1]*(len(s)//2)
    li2 = [1,0]*(len(s)//2)
if len(s)%2 == 1:
    li1 = [0,1]*(len(s)//2) + [0]
    li2 = [1,0]*(len(s)//2) + [1]
cnt1,cnt2 = 0,0
for i in range(len(s)):
    if s[i] != li1[i]:
        cnt1 += 1
    if s[i] != li2[i]:
        cnt2 += 1

print(min(cnt1,cnt2))

Solution (Python):
def solve():
    s = [i for i in input()]
    n = len(s)
    return min([len([True for i, j in zip(s, ["1" if i % 2 == mod else "0" for i in range(n)]) if i != j]) for mod in [0, 1]])


if __name__ == "__main__":
    print(solve())

Solution (Python):
From0 = ['0','1']*(10**6)
From1 = ['1','0']*(10**6)
s = list(input())
F0 = From0[:len(s)]
F1 = From1[:len(s)]
count_0 = 0
count_1 = 0
for i in range(len(s)):
  if s[i] != F0[i]:
    count_0 += 1
for i in range(len(s)):
  if s[i] != F1[i]:
    count_1 += 1
print(min(count_0,count_1))

Solution (Python):

s = input()
n = len(s)


t = ''.join(['0' if i % 2 == 0 else '1' for i in range(n)])
t_count = 0
for i, j in zip(s, t):
    if i == j:
        pass
    else:
        t_count += 1


u = ''.join(['1' if i % 2 == 0 else '0' for i in range(n)])

u_count = 0
for i, j in zip(s, u):
    if i == j:
        pass
    else:
        u_count += 1
print(min(t_count, u_count))

Solution (Python):
s = list(map(int, input()))

top_zero = []
top_one = []

for i in range(len(s)):
    if i % 2 == 0:
        top_zero.append(0)
        top_one.append(1)
    else:
        top_zero.append(1)
        top_one.append(0)

count_zero = 0
count_one = 0

for i in range(len(s)):
    if top_zero[i] == s[i]:
        count_zero += 1
    if top_one[i] == s[i]:
        count_one += 1

print(min(count_zero, count_one))

Solution (Python):
s = list(map(int, input()))

count_even = 0
count_odd = 0

for i in range(len(s)):
    if i % 2 == 0 and s[i] == 1:
        count_even += 1
    if i % 2 == 1 and s[i] == 1:
        count_odd += 1

if len(s) % 2 == 0:
    ans = (int(len(s)/2) - max(count_even, count_odd)) + min(count_even, count_odd)
else:
    if count_even >= (len(s)+1)/4:
        ans = (((len(s)+1)/2) - count_even) + count_odd
    else:
        ans = count_even + (len(s)-1)/2 - count_odd

print(int(ans))

Solution (Python):
s = input()
b = True
a1 = 0
a2 = 0
for i in range(len(s)):
    if s[i] != ("0" if b else "1"):
        a1 += 1
    if s[i] != ("1" if b else "0"):
        a2 += 1
    b = not b
print(min(a1, a2))

Solution (Python):
s=list(map(int,input()))
an=0

for i in range(1,len(s)):
    if s[0]==0:
        if i%2==0 and s[i]==1:
            an+=1
        elif i%2==1 and s[i]==0:
            an+=1
    else:
        if i%2==0 and s[i]==0:
            an+=1
        elif i%2==1 and s[i]==1:
            an+=1

print(an)

Solution (Python):
s = input()
print(min(s[::2].count('0') + s[1::2].count('1'), s[::2].count('1') + s[1::2].count('0')))

Solution (Python):
s = input()
a = s[::2].count('0') + s[1::2].count('1')
b = s[::2].count('1') + s[1::2].count('0')
print(min(a, b))

Solution (Python):
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
n = len(s)

case1 = []
case2 = []
now = 0
for i in range(n):
    c = '0' if now else '1'
    case1.append(c)
    c = '1' if c == '0' else '0'
    case2.append(c)
    now = 1 - now

case1 = "".join(case1)
case2 = "".join(case2)

res1, res2 = 0, 0
for i in range(n):
    res1 += 1 if case1[i] != s[i] else 0
    res2 += 1 if case2[i] != s[i] else 0

print(min(res1, res2))

Solution (Python):
s = input()

chenge_01 = 0
chenge_10 = 0

for i in range(len(s)):
    if i%2 == 0:
        if s[i] == '0':
            chenge_01 += 1
        else:
            chenge_10 += 1
    else:
        if s[i] == '1':
            chenge_01 += 1
        else:
            chenge_10 += 1

print(min(chenge_01,chenge_10))

Solution (Python):
s = list(input())
n = len(s)

l1 = ["0" if i % 2 == 0 else "1" for i in range(n)]
l2 = ["1" if i % 2 == 0 else "0" for i in range(n)]

diff1, diff2 = 0, 0

for i in range(n):
    if s[i] == l1[i]:
        diff1 += 1
    if s[i] == l2[i]:
        diff2 += 1

print(diff1 if diff1 <= diff2 else diff2)

Solution (Python):
list_S = list(input())
S = [int(s) for s in list_S]
s1 = S[::2]
s2 = S[1::2]
sums1 = sum(s1)
sums2 = sum(s2)
if sums1>sums2: print(len(s1)-sums1+sums2)
else: print(len(s2)-sums2+sums1)

Solution (Python):
def resolve():
    list_S = list(input())
    S = [int(s) for s in list_S]


    s1 = S[::2]
    s2 = S[1::2]


    


    sums1 = sum(s1)
    sums2 = sum(s2)
    if sums1>sums2:
        print(len(s1)-sums1+sums2)
    else:
        print(len(s2)-sums2+sums1)

resolve()

Solution (Python):
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)))

Solution (Python):
s = input()
l = [int(x) for x in list(str(s))]

ans_a = 0
for i in range(len(s)):
	if i%2 ==0 and l[i] == 0:
		pass
	elif i%2==1 and l[i] ==1:
		pass
	else:
		ans_a += 1

ans_b = 0
for i in range(len(s)):
	if i%2 ==0 and l[i] == 1:
		pass
	elif i%2 ==1 and l[i] == 0:
		pass
	else:
		ans_b += 1
print(min(ans_b,ans_a))