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):

S = list(input())
S_rev = list(reversed(S))
if len(S) == 1:
    count_min = 0
else:    
    count_front = 0
    for i in range(1,len(S)):
        if S[i] == S[i-1] == '1':
            S[i] = '0'
            count_front += 1
        elif S[i] == S[i-1] == '0':
            S[i] = '1'
            count_front += 1
    count_back = 0
    for j in range(1,len(S)):
        if S_rev[j] == S_rev[j-1] == '1':
            S_rev[j] = '0'
            count_back += 1
        elif S_rev[j] == S_rev[j-1] == '0':
            S_rev[j] = '1'
            count_back += 1
    count_min = min(count_front,count_back)
print(count_min)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
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()
n = len(s)
cnt1 = 0
for i in range(n):
    if i % 2:
        if s[i] == '0':
            cnt1 += 1
    else:
        if s[i] == '1':
            cnt1 += 1
cnt2 = 0
for i in range(n):
    if i % 2:
        if s[i] == '1':
            cnt2 += 1
    else:
        if s[i] == '0':
            cnt2 += 1
ans = min(cnt1, cnt2)
print(ans)

Solution (Python):
S = input()
count = 0
for i,tile in enumerate(S):
    if i % 2 and tile == "0":
        count += 1
    if i % 2 == 0 and tile == "1":
        count += 1

ans = min(count, len(S) - count)
print(ans)

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

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

n = len(a)

c = 0

for i in range(n):
    if (i % 2 == 0 and a[i] == "0") or (i % 2 == 1 and a[i] == "1"):
        c += 1

print(min(c, n-c))

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

Solution (Python):
"""
int(input())
map(int, input().split())
list(map(int, input().split()))
input()
input().split()
"""

s = input()
cnt = 0
new = s[0]
for i in range(1,len(s)):
    if (s[i]==new[i-1]) : 
        cnt += 1
        new +=  str((int(s[i])+1)%2)
    else: new += s[i]

print(cnt)

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

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

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

print(min(ans1,ans2))

Solution (Python):
N=list(str(input()))
ans=0
if len(N)==1:
  print("0")
  exit()
for i in range(len(N)-1):
  if N[i]=="0" and N[i+1]=="0":
    N[i+1]="1"
    ans+=1
  elif N[i]=="1" and N[i+1]=="1":
    ans+=1
    N[i+1]="0"
print(ans)

Solution (Python):
S = input()
N = len(S)

count1 = 0
count2 = 0
for i in range(N):
    ex = str(i % 2)
    if S[i] == ex:
        count1 += 1
    else:
        count2 += 1
print(min(count1, count2))

Solution (Python):
s=input()

c1=0
c2=0

for i in range(len(s)):
    if i%2==0:
        c1+=1 if s[i]=='1' else 0
        c2+=1 if s[i]=='0' else 0
    else:
        c1+=1 if s[i]=='0' else 0
        c2+=1 if s[i]=='1' else 0
    
print(min(c1,c2))

Solution (Python):
def solve(i,S):
    t = i
    ret = 0
    for c in S:
        if c != t:
            ret += 1
        t ^= 1
    return ret

S = list(map(int,input()))
print(min(solve(0,S),solve(1,S)))

Solution (Python):
def readinput():
    s=input()
    return s

def main(s):
    count=0
    t=['0','1']
    for i in range(len(s)):
        if s[i]==t[i%2]:
            count+=1
    return min(count,len(s)-count)

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)

Solution (Python):

S = input()

ctr = [0, 0]
for i in range(len(S)):
    if i % 2 == 0:
        ctr[0] += int(S[i]) == 0
        ctr[1] += int(S[i]) == 1
    else:
        ctr[0] += int(S[i]) == 1
        ctr[1] += int(S[i]) == 0

print(min(ctr))

Solution (Python):
word = input()

res = 0
colour = 0
for s in word:
    if colour % 2 != int(s):
        res += 1
    colour += 1
if len(word) // 2 < res:
    res = len(word) - res

print(res)

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

Solution (Python):
s=input()
cnt1b,cnt2b,cnt1w,cnt2w=0,0,0,0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='0':
      cnt1b+=1
    else:
      cnt1w+=1
  else:
    if s[i]=='0':
      cnt2b+=1
    else:
      cnt2w+=1
print(min(cnt1b+cnt2w,cnt2b+cnt1w))

Solution (Python):

s = input()
ss = [int(s[0]) if x % 2 == 0 else int(s[0])^1 for x in range(len(s))]

cnt = 0
for i in range(len(s)):
    if int(s[i]) != ss[i]:
        cnt += 1

print(cnt)

Solution (Python):
from distutils.util import strtobool
s = input()
ss = [int(s[0]) if x % 2 == 0 else int(s[0])^1 for x in range(len(s))]

cnt = 0
for i in range(len(s)):
    if int(s[i]) != ss[i]:
        cnt += 1

print(cnt)

Solution (Python):
S=input()

st1 = 0
st0 = 0

for i in range(len(S)):
    if S[i] == '1' and i%2==0:
        st0+=1
    elif S[i] == '0' and i%2==0:
        st1+=1
    elif S[i] == '1' and i%2!=0:
        st1+=1
    elif S[i] == '0' and i%2!=0:
        st0+=1

print(min(st1, st0))

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF = 10**20
def main():
    S=list(input())
    N=len(S)

    A,B=[],[]
    pre = "0"
    for i in range(N):
        if pre == "0":
            new = "1"
        else:
            new = "0"
        A.append(new)
        pre = new
        
    pre = "1"
    for i in range(N):
        if pre == "0":
            new = "1"
        else:
            new = "0"
        B.append(new)
        pre = new

    ans = INF
    for X in [A,B]:
        count = 0
        for i in range(N):
            if S[i] != X[i]:
                count += 1

        ans = min(ans,count)

    print(ans)





if __name__ == "__main__":
    main()

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

x=[i%2 for i in range(n)]
y=[(i+1)%2 for i in range(n)]
d=0
f=0

for i in range(n):
    if int(s[i])!=x[i]:
        d+=1
for i in range(n):
    if int(s[i])!=y[i]:
        f+=1
print(min(d,f))

Solution (Python):
s = input()
n = len(s)
cn0 = 0
cn1 = 0
for i in range(n):
    if s[i] != str(i % 2):
        cn0 += 1
for i in range(n):
    if s[i] != str((i+1)%2):
        cn1 += 1
print(min(cn0, cn1))

Solution (Python):
S = input()

S1 = S[0::2]
S2 = S[1::2]

S1_0 = S1.count("0")
S1_1 = S1.count("1")
S2_0 = S2.count("0")
S2_1 = S2.count("1")


ans1 = S1_0 + S2_1

ans2 = S1_1 + S2_0

print(min(ans1,ans2))

Solution (Python):
S = input().strip()
L = len(S)
p = 0
for i in zip(S, "01"*L):
    if i[0] != i[1]:
        p += 1
q = 0
for i in zip(S, "10"*L):
    if i[0] != i[1]:
        q += 1
print(min(p, q))

Solution (Python):
S=input()
A=[]
B=[]
a=0
b=0
for i in range(len(S)):
    if i%2==0:
        A.append("1")
        B.append("0")
    else:
        A.append("0")
        B.append("1")
for i in range(len(S)):
    if A[i]!=S[i]:
        a+=1
    if B[i]!=S[i]:
        b+=1
print(min(a,b))

Solution (Python):
li = list(input())
l = [int(n) for n in li]
x = len(l)
li_0 = [0 for i in range(x)]
li_1 = [0 for i in range(x)]
for i in range(x):
    if i % 2 == 0:
        li_0[i] = 1
    else:
        li_1[1] = 1
a = 0
b = 0
for i in range(x):
    if li_0[i] != l[i]:
        a += 1
    else:
        b += 1
print(min(a,b))

Solution (Python):
s=input()
l=len(s)
p0=[0]*l
p1=[1]*l
for i in range(l):
    if i%2==1:
        p0[i]=1
        p1[i]=0
c0=0
c1=0
for i in range(l):
    if int(p0[i])!=int(s[i]):
        c0+=1
for i in range(l):
    if int(p1[i])!=int(s[i]):
        c1+=1
print(min(c0,c1))

Solution (Python):
s = input()
n = len(s)
if n%2 == 0:
    im1 = '01'*(n//2)
    im2 = '10'*(n//2)
else:
    im1 = '01'*(n//2) + '0'
    im2 = '10'*(n//2) + '1'
cnt1 = 0
cnt2 = 0
for i in range(n):
    if s[i] != im1[i]:
        cnt1 += 1
    if s[i] != im2[i]:
        cnt2 += 1
print(min(cnt1,cnt2))

Solution (Python):
S = input()

a = ''
for i in range(len(S)//2):
    a += '0'
    a += '1'
if len(S)/2 % 1 != 0:
    a += '0'
b = ''
for i in range(len(S)//2):
    b += '1'
    b += '0'
if len(S)/2 % 1 != 0:
    b += '1'

count_a = 0
for i in range(len(S)):
    if S[i] != a[i]:
        count_a += 1

count_b = 0
for i in range(len(S)):
    if S[i] != b[i]:
        count_b += 1

print(min(count_a, count_b))

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

Solution (Python):
s = list(input())
a = 0
b = 0
f = 0
for i in s:
    if f == 0:
        if i == "0":
            a += 1
        else:
            b += 1
        f = 1
    else:
        if i == "0":
            b += 1
        else:
            a += 1
        f = 0
            
print(min(a,b))

Solution (Python):
s=list(input())
n=len(s)
count1=0
for i in range(1,n+1):
    if int(s[i-1])!=(i%2):
        count1+=1
count2=0
for j in range(n):
    if int(s[j])!=j%2:
        count2+=1
print(min(count1,count2))

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

a=n
for i in ['01','10']:
 a=min(a,sum(x!=y for x,y in zip(S,(i*(n//2+1))[:n])))
print(a)

Solution (Python):
S=input()
n=len(S)
print(min(sum(x!=y for x,y in zip(S,('01'*(n//2+1))[:n])),sum(x!=y for x,y in zip(S,('10'*(n//2+1))[:n]))))

Solution (Python):
S = input()
cnt = sum(i % 2 == 0 and s == "1" or i % 2 == 1 and s == "0" for i, s in enumerate(S))
print(min(cnt, len(S) - cnt))

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

ans = 0
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        pass
    else:
        x = S[i+1]
        if x == '0':
            S[i+1] = '1'
        else:
            S[i+1] = '0'
        ans += 1

print (ans)

Solution (Python):
cnt=0
cnt_2=0
s = str(input())
for i in range(len(s)):
    if s[i]=='0' and i%2==0:
        cnt+=1
    if s[i]=='1' and i%2==0:
        cnt_2+=1
    if s[i]=='1' and i%2!=0:
        cnt+=1
    if s[i]=='0' and i%2!=0:
        cnt_2+=1
print(min(cnt,cnt_2))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = [int(i) for i in SS()]
    N = len(S)

    ans0 = 0
    ans1 = 0
    for i in range(N):
        ans0 += abs(S[i] - i % 2)
        ans1 += abs(S[i] - (1 - i % 2))

    print(min(ans0, ans1))

if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
import copy

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def switch(s):
    if s == '0':
        return '1'
    else:
        return '0'


def main():
    S = list(input())
    S_1 = copy.copy(S)
    S_2 = copy.copy(S)
    ans_1 = 0
    for i in range(1, len(S_1)):
        if S_1[i] == S_1[i - 1]:
            S_1[i] = switch(S_1[i])
            ans_1 += 1
    ans_2 = 1
    S_2[0] = switch(S_2[0])
    for i in range(1, len(S_2)):
        if S_2[i] == S_2[i - 1]:
            S_2[i] = switch(S_2[i])
            ans_2 += 1
    print(min(ans_1, ans_2))


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
a = 0
b = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      a = a+1
    else:
      b = b+1
  else:
    if s[i] == "0":
      b = b+1
    else:
      a = a+1
if a < b:
  print(a)
else:
  print(b)

Solution (Python):
S = input()

res1 = 0
res2 = 0

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            res1 += 1
        else:
            res2 += 1
    else:
        if S[i] == "1":
            res1 += 1
        else:
            res2 += 1

print(min(res1, res2))

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = instr()

prev = s[0]
ans = 0

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

print(ans)

Solution (Python):
S = input()
N = len(S)


cnt1 = 0
for i in range(len(S)):
    if S[i] != str(i % 2):
        cnt1 += 1


cnt2 = 0
for i in range(len(S)):
    if S[i] != str((i + 1) % 2):
        cnt2 += 1

print(min(cnt1, cnt2))

Solution (Python):
s=list(input())
id_1=['1' if i%2 else '0' for i in range(len(s))]
id_2=['0' if i%2 else '1' for i in range(len(s))]
cnt=[0,0]
for si,id1,id2 in zip(s,id_1,id_2):
  cnt[0] += si!=id1
  cnt[1] += si!=id2
print(min(cnt))

Solution (Python):

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

n=len(s)
check_1=[i%2 for i in range(n)]
check_2=[(i%2+1)%2 for i in range(n)]

cnt_1=0
cnt_2=0
for i in range(n):
  if s[i]!=check_1[i]:
    cnt_1=cnt_1+1
  if s[i]!=check_2[i]:
    cnt_2=cnt_2+1
print(min(cnt_1,cnt_2))

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

ans = 0
cnt = 0
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    cnt += 1
  else:
    ans += (cnt+1) // 2
    if cnt % 2 == 0:
      cnt = 0
    else:
      cnt = 1
ans += (cnt+1) // 2
print(ans)

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

ans1 = 0
ans2 = 0

for i in range(n):
    if i%2 == 0 and s[i] == '0':
        ans1 +=1
    elif i%2 == 1 and s[i] == '1':
        ans1 += 1

for i in range(n):
    if i%2 == 0 and s[i] == '1':
        ans2 +=1
    elif i%2 == 1 and s[i] == '0':
        ans2 += 1
        
print(min(ans1, ans2))

Solution (Python):
s = input()

res = 0
previous = s[0]
for i in range(1, len(s)):
    if s[i] == previous:
        res += 1
        previous = str((int(previous) + 1) % 2)
    else:
        previous = s[i]

print(res)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())

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

ans2 = 0
for i, s in enumerate(S): 
    if i % 2 != 0:
        if s == "0":
            ans2 += 1
    else:
        if s == "1":
            ans2 += 1

ans = min(ans1, ans2)
print(ans)

Solution (Python):
import sys

S = str(input())
if len(S) == 1:
  print("0")
  sys.exit()
else:
  c1 = 0
  c2 = 0
  for i in range(len(S)):
    if i%2 == 0:
      if S[i] != "1":
        c1 += 1
    else:
      if S[i] != "0":
        c1 += 1
  for i in range(len(S)):
    if i%2 == 0:
      if S[i] != "0":
        c2 += 1
    else:
      if S[i] != "1":
        c2 += 1
print(min(c1,c2))

Solution (Python):
S = list(input())
f = False
c = 0

for i  in range(len(S) - 1):
    
    
    if S[i] != S[i + 1]:
        continue
    else:
        if S[i] == "0":
            S[i+1] = "1"
            c += 1
        else:
            S[i+1] = "0"
            c += 1

print(c)

Solution (Python):
S = input()
N = len(S)

cnt1 = 0
cnt2 = 0
for s in S[::2]:
    if s == '0':
        cnt1 += 1
    elif s == '1':
        cnt2 += 1
for s in S[1::2]:
    if s == '1':
        cnt1 += 1
    elif s == '0':
        cnt2 += 1

print(N-max(cnt1, cnt2))

Solution (Python):
s=[*input()];n=len(s);t=['1' if i%2==0 else '0' for i in range(n)]
r=[i==j for i,j in zip(s,t)];print(min(sum(r),n-sum(r)))

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

print(min(cnt1, cnt2))

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

one = 0
zero = 0
for i in s[::2]:
    if i == '1':
        one += 1
    else:
        zero += 1

for i in s[1::2]:
    if i == '0':
        one += 1
    else:
        zero += 1

print(min(one, zero))

Solution (Python):
S=input()
if len(S)%2==0:
    black="01"*(len(S)//2)
    white="10"*(len(S)//2)
    countb=0
    countw=0
else:
    black="01"*(len(S)//2)+"0"
    white="10"*(len(S)//2)+"1"
countb=0
countw=0
for i in range(len(S)):
    if S[i]!=black[i]:
        countb=countb+1
    elif S[i]!=white[i]:
        countw=countw+1
    else:
        pass
if countb>=countw:
    print(countw)
else:
    print(countb)

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

Solution (Python):
S = input()
T1 = len(S)*"01"
T2 = len(S)*"10"
ans = []
dif = 0

for s,t in zip(S,T1):
  if s!=t:
    dif+=1

ans+=[dif]
dif = 0

for s,t in zip(S,T2):
  if s!=t:
    dif+=1

ans+=[dif]
print(min(ans))

Solution (Python):
S = input()
N = len(S)
a = 0
b = 0
ans = 0
for i in range(0,N,2):
    if S[i] == '0':
        a += 1
    else:
        b += 1
for i in range(1,N,2):
    if S[i] == '1':
        a += 1
    else:
        b += 1
c = max(a,b)
if c == a:
    for i in range(0,N,2):
        if S[i] != '0':
            ans += 1
    for i in range(1,N,2):
        if S[i] != '1':
            ans += 1
else:
    for i in range(0,N,2):
        if S[i] == '0':
            ans += 1
    for i in range(1,N,2):
        if S[i] == '1':
            ans += 1
print(ans)

Solution (Python):
S=input()
s1="01"*(len(S)//2+1)
ans1=0
ans2=0
for x in range(len(S)):
  if S[x]==s1[x]:
    ans2 +=1
  else:
    ans1 +=1
print(min(ans1,ans2))

Solution (Python):
S=input()

cost1 = 0
cost2 = 0
for i in range(len(S)):
  if i % 2 == int(S[i]):
    cost1 += 1
  else:
    cost2 += 1

print(min(cost1,cost2))

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

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

print(ans)

Solution (Python):
S = input()
ss0 = []
ss1 = []
for i in range(len(S)):
    ss0.append(str(i%2))
    ss1.append(str((i+1)%2))

c0 = 0
c1 = 0
for s, s0, s1 in zip(S, ss0, ss1):
    if s != s0:
        c0 += 1
    if s != s1:
        c1 += 1

print(min(c0, c1))

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


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(min(count,len(s)-count))

Solution (Python):













































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    line = lines[0]
    
    
    
    
    
    
    
    
    
    

    result = 0

    n_even_kuro = 0
    n_even_shiro = 0
    n_odd_kuro = 0
    n_odd_shiro = 0

    
    for i, char in enumerate(line):
        if i % 2 == 0:
            if char == '0':
                n_even_kuro += 1
            else:
                n_even_shiro += 1
        else:
            if char == '0':
                n_odd_kuro += 1
            else:
                n_odd_shiro += 1

    log(n_even_kuro)
    log(n_even_shiro)
    log(n_odd_kuro)
    log(n_odd_shiro)

    
    dif_even_kuro = n_even_kuro - n_even_shiro
    dif_odd_kuro = n_odd_kuro - n_odd_shiro

    
    if dif_even_kuro > dif_odd_kuro:
        
        result = n_even_shiro + n_odd_kuro
    else:
        
        result = n_odd_shiro + n_even_kuro

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['000']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['10010010']
        lines_export = [3]
    if pattern == 3:
        lines_input = ['0']
        lines_export = [0]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
n = input()
num = len(n)
one_s = 0
zero_s = 0

for i in range(num):
    if i % 2 == 0:
        if n[i] == "0":
            one_s += 1
        else:
            zero_s += 1
    else:
        if n[i] == "0":
            zero_s += 1
        else:
            one_s += 1

print(min(zero_s, one_s))

Solution (Python):
s = input()
count = 0
tmp = s[0]
for i in range(1, len(s)):
    if s[i] == tmp:
        count += 1
        if s[i] == "0":
            tmp = "1"
        else:
            tmp = "0"
    else:
        tmp = s[i]

print(count)

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

p=['1']
q=['0']

for x in range(1,n):
  if p[x-1]=='0':
    p.append('1')
  else:
    p.append('0')
    
  if q[x-1]=='0':
    q.append('1')
  else:
    q.append('0')
  
ans=0
ans1=0
for i in range(n):
  if s[i]!=p[i]:
    ans+=1
  if s[i]!=q[i]:
    ans1+=1
    
print(min(ans,ans1))

Solution (Python):
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))

S = LI2()
N = len(S)
print(min(sum(S[i] for i in range(0,N,2)) + sum(1-S[i] for i in range(1,N,2)),sum(1-S[i] for i in range(0,N,2))+sum(S[i] for i in range(1,N,2))))

Solution (Python):
S=list(input())
cnt=0
for n in range(1,len(S)):
    if S[n]==S[n-1]:
        if S[n]=="1":
            S[n]="0"
        else:
            S[n]="1"
        cnt+=1
print(cnt)

Solution (Python):
s=input()
b=c=0
for i in s:
  c+=(int(i)==b)
  b^=1
print(min(c,len(s)-c))

Solution (Python):
s=input()
b=l=r=0
for i in s:
  l+=(int(i)==b)
  r+=(int(i)!=b)
  b^=1
print(min(l,r))

Solution (Python):
S = str(input())
if len(S) == 1:
    print(0)
    exit()
if len(S) % 2 == 0:
    ans1 = "10" * (len(S)//2)
    ans2 = "01" * (len(S)//2)
else:
    ans1 = "10" * (len(S)//2) + "1"
    ans2 = "01" * (len(S)//2) + "0"

result1 = 0
result2 = 0
for x,y in zip(S,ans1):
    if x != y:
        result1 += 1
for x,y in zip(S, ans2):
    if x != y:
        result2 += 1
print(min(result1,result2))

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

print(ans)

Solution (Python):
a=list(input())
n=[]
for i in range(1,len(a)+1):
    if i%2==0:
        n.append(0)
    else:
        n.append(1)
m=[]
for i in range(1,len(a)+1):
    if i%2==0:
        m.append(1)
    else:
        m.append(0)
ans1=0
for i in range(len(a)):
    if n[i]!=int(a[i]):
        ans1+=1
ans2=0
for i in range(len(a)):
    if m[i]!=int(a[i]):
        ans2+=1
print(min(ans1,ans2))

Solution (Python):
S = input()
length = len(S)
p1 = [0 if i % 2 == 0 else 1 for i in range(length)]
p2 = [1 if i % 2 == 0 else 0 for i in range(length)]
ans1 = 0
ans2 = 0
for index,s in enumerate(S):
  if int(s) != p1[index]:
    ans1 += 1
  if int(s) != p2[index]:
    ans2 += 1
  
print(min(ans1,ans2))

Solution (Python):

s=list(str(input()))
ans=len(s)
cntx=0
cnty=0
for j in range(len(s)):
  if (int(s[j])==j%2):
    cntx+=1
  if (int(s[j])!=j%2):
    cnty+=1
  ans=min(cntx,cnty)
print(ans)

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

Solution (Python):
def main():
    s=input()
    a=0  
    b=0  
    for i, v in enumerate(s):
        if i % 2 == 0:
            if v == "0":
                a+=1
            else:
                b+=1
        else:
            if v == "0":
                b+=1
            else:
                a+=1
    print(min(a,b))

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    s = input()
    tmp1 = 0
    tmp2 = 0
    mae = 0

    for i in range(len(s)):
        if s[i] == mae:
            tmp1 += 1
            if s[i] == "0":
                mae = "1"
            else:
                mae = "0"
        else:
            if s[i] == "0":
                mae = "0"
            else:
                mae = "1"

    mae = 1

    for i in range(len(s)):
        if s[i] == mae:
            tmp2 += 1
            if s[i] == "0":
                mae = "1"
            else:
                mae = "0"
        else:
            if s[i] == "0":
                mae = "0"
            else:
                mae = "1"
    
    print(min(tmp1, tmp2))


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
n = len(S)
pattern1 = [i % 2 for i in range(n)]
pattern2 = [i % 2 for i in range(1, n+1)]
ans1 = 0
ans2 = 0
for i in range(n):
    s = S[i]
    if s == str(pattern1[i]):
        ans1 += 1
    if s == str(pattern2[i]):
        ans2 += 1
else:
    ans = min(ans1, ans2)
print(ans)

Solution (Python):
s=input()
leng=len(s)
a=0 
b=0 
for i in range(leng):
  if i%2==0:
    if s[i]=="1":
      a+=1
    if s[i]=="0":
      b+=1
  if i%2==1:
    if s[i]=="0":
      a+=1
    if s[i]=="1":
      b+=1
if a>=b:
  print(b)
else:
  print(a)

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



sum_1 = 0

sum_2 = 0


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

    

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

print(min(sum_1, sum_2))

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

ans = L
for m in range(2):
  t = 0
  for i in range(L):
    s = S[i]
    if i % 2 == m:
      if s == '0':
        t += 1
    else:
      if s == '1':
        t += 1
  ans = min(ans,t)
  
print(ans)

Solution (Python):
s=input()
a,b=0,0
for i in range(len(s)):
    if i%2==0 and s[i]=="1":
        a+=1
    elif i%2==1 and s[i]=="0":
        a+=1
for i in range(len(s)):
    if i%2==0 and s[i]=="0":
        b+=1
    elif i%2==1 and s[i]=="1":
        b+=1
print(min(a,b))

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


ans1 = 0
for i in range(N):
    if i%2==0 and S[i] == '0':
        ans1 += 1
    elif i%2==1 and S[i] == '1':
        ans1 += 1


ans2 = 0
for i in range(N):
    if i%2==0 and S[i] == '1':
        ans2 += 1
    elif i%2==1 and S[i] == '0':
        ans2 += 1

print(min(ans1, ans2))

Solution (Python):
S = input()
N = len(S)

ans1 = 0
ans2 = 0

for i in range(N):
  if i%2 == 0:
    if S[i] != "0":
      ans1 += 1
    else:
      ans2 += 1
  else:
    if S[i] != "1":
      ans1 += 1
    else:
      ans2 += 1

print(min(ans1, ans2))

Solution (Python):
S = input()
N = len(S)

ans1 = "".join(["1" if i%2 == 0 else "0" for i in range(N)])
ans2 = "".join(["0" if i%2 == 0 else "1" for i in range(N)])

print(min(bin(int(S, 2)^int(ans1, 2)).count("1"), bin(int(S, 2)^int(ans2, 2)).count("1")))

Solution (Python):
S = input()
c = 0
for i in range(len(S)):
    if i&1:
        c += S[i] == "0"
    else:
        c += S[i] == "1"
print(min(c, len(S) - c))

Solution (Python):
s=input()


ans_0=0
count=0
for i in s:
    if int(i) != count % 2: ans_0+=1
    count+=1


ans_1=0
count=1
for i in s:
    if int(i) != count %2: ans_1+=1
    count+=1

print(min(ans_0,ans_1))

Solution (Python):

s=str(input())
n=len(s)
c1=0
c2=0
for i in range(n): 
  if i%2==0:
    if s[i]=="1":
      c1+=1
  else:
    if s[i]=="0":
      c1+=1
for i in range(n): 
  if i%2==0:
    if s[i]=="0":
      c2+=1
  else:
    if s[i]=="1":
      c2+=1
print(min(c1, c2))

Solution (Python):
s = list(input())
cnt = 0
if s[0] == "0":
    for i in range(len(s)):
        if s[i] != str(i % 2):
            cnt += 1
else:
    for i in range(1, len(s) + 1):
        if s[i - 1] != str(i % 2):
            cnt += 1
print(cnt)

Solution (Python):
s = list(input())
n = len(s)
a = ['0'] * n
b = ['0'] * n
for i in range(n):
    if i % 2 ==1:
        a[i] = '1'
    else:
        b[i] = '1'

cnt_a, cnt_b = 0, 0
for i in range(n):
    if s[i] != a[i]:
        cnt_a += 1
    if s[i] != b[i]:
        cnt_b += 1
print(min(cnt_a, cnt_b))

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

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

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):
s = list(input())
n = s[0]
p = 0
for i in range(1,len(s)):
    if s[i] == n:
        p += 1
        if s[i] == '0':
            s[i] = '1'
            n = '1'
        else:
            s[i] = '0'
            n = '0'
    else:
        n = s[i] 

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

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

pattern1, pattern2 = [], []
for i in range(len(S)):
  if i % 2 == 0:
    pattern1.append('0')
    pattern2.append('1')
  else:
    pattern1.append('1')
    pattern2.append('0')

ham1, ham2 = 0, 0
for i in range(len(S)):
  if pattern1[i] != S[i]:
    ham1 += 1
  if pattern2[i] != S[i]:
    ham2 += 1
print(min(ham1, ham2))

Solution (Python):

S = input()
cou1,cou2 = 0,0
a,b = "",""
if len(S)%2 ==0:
    for i in range(int(len(S)/2)):
        a+="01"
        b+="10"
else:
    for i in range(int(len(S)/2)+1):
        a+="01"
        b+="10"
        
for i in range(len(S)):
    if S[i] != a[i]:
        cou1 +=1
    if S[i] != b[i]:
        cou2 +=1
if cou1 <= cou2:
    cou = cou1
else:
    cou = cou2
        
print(cou)