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):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    t = S[::2].count("0") + S[1::2].count("1")
    print(min(t, len(S) - t))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
S = input()
N = len(S)
x = int(S[0])
c = 0
for i in range(1,N):
  if int(S[i]) == x:
    c +=1
    if x == 0:
      x = 1
    else:
      x = 0
  else:
    x = int(S[i])
print(c)

Solution (Python):
s = input()

cnt1 = 0
cnt2 = 0

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

print(min(cnt1, cnt2))

Solution (Python):
S = input()
ex1 = ''
while len(ex1) < len(S):
    ex1 += '1'
    if len(ex1) < len(S):
  	    ex1 += '0'
ex2 = ''
while len(ex2) < len(S):
    ex2 += '0'
    if len(ex2) < len(S):
        ex2 += '1'
ans1 = 0
ans2 = 0
for i in range(len(S)):
    if ex1[i] == S[i]:
        ans2 += 1
    else:
        ans1 += 1
print(min(ans1,ans2))

Solution (Python):
S = input()
k = []
for i in range(len(S)):
    k.append(S[i])
position = 0
ans = 0
for i in range(10**6):
    if position >= len(S)-1:
        break
    else:
        if k[position] == k[position+1]:
            if k[position+1] == "0":
                k[position+1] = "1"
            else:
                k[position+1] = "0"
            ans += 1
        position += 1
print(ans)

Solution (Python):
n = input()
n_l = list(n)
a = [str(i % 2) for i in range(0, len(n))]
b = [str(i % 2) for i in range(1, len(n) + 1)]

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

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

print(min(count_a, count_b))

Solution (Python):
s = input()
 
y1 = [0 if x % 2 ==0 else 1 for x in range(len(s))]
y2 = [0 if x % 2 !=0 else 1 for x in range(len(s))]
 
ans1 = sum([1 for i,j in zip(s,y1) if int(i)==j])
ans2 = sum([1 for i,j in zip(s,y2) if int(i)==j])
print(min([ans1,ans2]))

Solution (Python):
s = input()

y1 = [0 if x % 2 ==0 else 1 for x in range(len(s))]
y2 = [0 if x % 2 !=0 else 1 for x in range(len(s))]

ans1 = sum([1 for i,j in zip(s,y1) if int(i)==j])
ans2 = sum([1 for i,j in zip(s,y2) if int(i)==j])
print(min([ans1,ans2]))

Solution (Python):
s = input()
a = s[1::2].count("0") + s[::2].count("1")
b = s[1::2].count("1") + s[::2].count("0")

print(min(a, b))

Solution (Python):
s = input()
cnt = len(s)
R = s[1::2]
L = s[::2]

cntL = L.count("0")
cntR = R.count("0")

paintL0 = 0 - -cnt//2 - cntL
paintR0 = cnt//2 - cntR

paintLR0 = paintL0 + cntR
paintLR1 = cntL + paintR0

print(min(paintLR0, paintLR1))

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]


'''
S = input()
n = len(S)

ans_0 = '01'*(n//2) + '0'*(n%2)
ans_1 = '10'*(n//2) + '1'*(n%2)

c_0 = c_1 = 0

for i in range(n):
    if ans_0[i] != S[i]:
        c_0 += 1
    if ans_1[i] != S[i]:
        c_1 += 1

print(min(c_0, c_1))
'''
S = input()
n = len(S)
a = 0
cnt_0 = cnt_1 = 0
for moji in S:
    cnt_0 += int(moji) ^ a
    a ^= 1

a = 1
for moji in S:
    cnt_1 += int(moji) ^ a
    a ^= 1

print(min(cnt_0, cnt_1))

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



S = input()
n = len(S)

ans_0 = '01'*(n//2) + '0'*(n%2)
ans_1 = '10'*(n//2) + '1'*(n%2)

c_0 = c_1 = 0

for i in range(n):
    if ans_0[i] != S[i]:
        c_0 += 1
    if ans_1[i] != S[i]:
        c_1 += 1

print(min(c_0, c_1))

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



s = input()
S = s[0]
N = len(s)
cnt = 0
for i in range(N-1):
    if S[i]=='0':
        if s[i+1] == '0':
            
            cnt += 1
        S += '1'

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

print(cnt)

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

counter=0

pre = N.pop(0)
for n in N:
    if(pre == n):
        counter+=1
    if(pre == "0"):
        pre="1"
    else:
        pre="0"

print(counter)

Solution (Python):
s = list(input())
cnt = 0
for i in range(1,len(s)):

    if s[i] == s[i-1]:
        cnt += 1
        if s[i] == '1':
            s[i] = '0'
        else:
            s[i] = '1'
print(cnt)

Solution (Python):
x = input()
N = len(x)
x1 = "01" * (N//2)
x2 = "10" * (N//2)
if N%2 == 1:
  x1 = x1 + "0"
  x2 = x2 + "1"
count1 = 0
count2 = 0
for x, y, z in zip(x, x1, x2):
  if x != y:
	  count1 += 1
  if x != z:
	  count2 += 1
count = min(count1, count2)
print(count)

Solution (Python):
s = input()
n = len(s)
s1 = ''.join(str(i%2) for i in range(n))
s2 = ''.join(str((i+1)%2) for i in range(n))
s1cnt = 0
s2cnt = 0
for i in range(n):
    if s[i] != s1[i]:
        s1cnt += 1
    if s[i] != s2[i]:
        s2cnt += 1
print(min(s1cnt, s2cnt))

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

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

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

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

print(min(sum_a, sum_b))

Solution (Python):
s = str(input())
c = 0
for i in range(len(s)):
  if int(s[i]) == i%2:
    c += 1
print(min(c,len(s)-c))

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

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

flip = sum( 1 ^ int(S[i]) for i in range(0, N, 2))
flip += sum( 0 ^ int(S[i]) for i in range(1, N, 2))

print(min(flip, N - flip))

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

a = sum((1 << i) for i in range(0, N, 2)) 
a_flip = bin(a ^ int(S, base = 2))[2:].count('1')

print(min(a_flip, N - a_flip))

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

a = sum((1 << i) for i in range(0, N, 2)) 
b = sum((1 << i) for i in range(1, N, 2)) 

a_flip = bin(a ^ int(S, base = 2))
b_flip = bin(b ^ int(S, base = 2))

print(min(a_flip[2:].count('1'), b_flip[2:].count('1')))

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

Solution (Python):
s = input()
cand1 = '10' * (len(s)//2) + '1' * (len(s)%2)
cand2 = '01' * (len(s)//2) + '0' * (len(s)%2)

print(min(sum([x != y for x, y in zip(s, cand1)]), sum([x != y for x, y in zip(s, cand2)])))

Solution (Python):
s = input()
count1 = 0
count2 = 0
for i in range(0, len(s)):
    if(i%2 == 0):
        if(s[i] == "0"):
            count1 += 1
    if(i%2 == 1):
        if(s[i] == "1"):
            count1 += 1

for i in range(0, len(s)):
    if(i%2 == 0):
        if(s[i] == "1"):
            count2 += 1
    if(i%2 == 1):
        if(s[i] == "0"):
            count2 += 1    
print(min(count1,count2))

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def func(q, S):
    ret = 0
    for s in S:
        if q == s:
            ret += 1
        q = '1' if q == '0' else '0'
    return ret


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    print(min(func('0', S), func('1', S)))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def func(S):
    tmp = ""
    ret = 0
    for s in S:
        if tmp == s:
            ret += 1
            tmp = '1' if s == '0' else '0'
        else:
            tmp = s
    return ret


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    ret = func(S)
    SS = S[::-1]
    ret = min(ret, func(SS))
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
S=list(map(int,list(input())))
ans=0
for i in range(len(S)):
  if S[i]!=i%2:
    ans+=1
print(min(ans,len(S)-ans))

Solution (Python):

import sys
input = sys.stdin.readline
import numpy as np









S = input().rstrip()

N = len(S)
ans0 = 0 
ans1 = 0 

for i in range(N):
    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))

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

Solution (Python):
import copy

s = list(map(int,list(input())))
n = len(s)
temp_1 = copy.deepcopy(s)
temp_0 = copy.deepcopy(s)
count_0 = 0
count_1 = 0

if s[0] == 0:
  temp_1[0] = 1
  count_1 = 1
elif s[0] == 1:
  temp_0[0] = 0
  count_0 = 1

for i in range(1,n):
  if temp_1[i-1] == temp_1[i]:
    count_1 = count_1 + 1
    temp_1[i] = not(temp_1[i-1]) 
  
  if temp_0[i-1] == temp_0[i]:
    count_0 = count_0 + 1
    temp_0[i] = not(temp_0[i-1])

print(min(count_0,count_1))

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def count(s, start):
    cnt = 0
    n = len(s)
    e = str(start) 
    o = str((1,0)[start]) 
    for i in range(n):
        if i%2==0 and s[i] != e: cnt += 1
        elif i%2==1 and s[i] != o: cnt += 1
    return cnt

def main():
    S = input()
    cnt_0 = count(S, 0)
    cnt_1 = count(S, 1)
    print(min(cnt_0, cnt_1))

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
x = sum([c=='0' for c in S[::2]]) + sum([c=='1' for c in S[1::2]])
y = sum([c=='1' for c in S[::2]]) + sum([c=='0' for c in S[1::2]])
print(min(x, y))

Solution (Python):
s = input()

ans=0
slist= [int(i) for i in s]

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

print(ans)

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

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)
ans1 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == '0':
            ans1 += 1
    else:
        if s[i] == '1':
            ans1 += 1
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == '1':
            ans2 += 1
    else:
        if s[i] == '0':
            ans2 += 1
ans = min(ans1,ans2)
print(ans)

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

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

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

print(min(res, res2))

Solution (Python):
import numpy as np
s = input()
n = len(s)
ans = 0
for i in range(n // 2 + 1):
	if 2 * i == n:
		break
	if s[2 * i] == "0":
		ans += 1
	if 2 * i + 1 == n:
		break
	if s[2 * i + 1] == "1":
		ans += 1
print(min(ans, n - ans))

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  s = input()
  count_01 = 0
  count_10 = 0
  n = len(s)
  for i in range(n):
    if i%2==0:
      if s[i] == '0':
        count_01 += 1
      else:
        count_10 +=1
    else:
      if s[i] == '1':
        count_01 += 1
      else:
        count_10 += 1
  print(min(n-count_01,n-count_10))
        
  
  
if __name__ == '__main__':
  main()

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

Solution (Python):
S = input()

n_01 = 0
S_0 = S[0::2]
S_1 = S[1::2]
n_01 = S_0.count("1") + S_1.count("0")
n_10 = S_0.count("0") + S_1.count("1")
print(min(n_01, n_10))

Solution (Python):
S=input()
n=len(S)
c0=0
c1=0
for i in range(n):
    if i%2==0:
        if S[i]=="0":
            c1+=1
        else:
            c0+=1
    else:
        if S[i]=="0":
            c0+=1
        else:
            c1+=1
print(min(c0,c1))

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

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

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

    c0, c1 = 0, 0
    for i, c in enumerate(s):
        if i % 2 == 0:
            if c == '0':
                c1 += 1

            else:
                c0 += 1

        else:
            if c == '0':
                c0 += 1

            else:
                c1 += 1

    print(min(c0, c1))

if __name__ == "__main__":
    main()

Solution (Python):
s = input()
ans = 0
t = "01" * len(s)

for i in range(len(s)):
  if s[i] != t[i]:
    ans = ans + 1  
  
print(min(ans, abs(len(s)-ans)))

Solution (Python):
s=str(input())
l=len(s)
cnt1=0
cnt2=0
for i in range(l):
  if i%2==0:
    if s[i]=='0':
      cnt1+=1
    else:
      cnt2+=1
  else:
    if s[i]=='0':
      cnt2+=1
    else:
      cnt1+=1
print(min(cnt1,cnt2))

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

S = input()

if len(S) == 1:
    goal_1 = '1'
    goal_2 = '0'

elif len(S) % 2 == 1:
    goal_1 = "10" * (len(S) // 2) + "1"
    goal_2 = "01" * (len(S) // 2) + "0"

else:
    goal_1 = "10" * (len(S) // 2)
    goal_2 = "01" * (len(S) // 2)

ans_1 = 0
ans_2 = 0
for i in range(len(S)):
    if S[i] != goal_1[i]:
        ans_1 += 1
    if S[i] != goal_2[i]:
        ans_2 += 1

print(min(ans_1, ans_2))

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

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

print(min(ans1,ans2))

Solution (Python):
S=input()
cnt=0
for i in range(len(S)):
    if i%2==0 and S[i]=="0":
        cnt+=1
    if i%2==1 and S[i]=="1":
        cnt+=1  

print(min(cnt,(len(S)-cnt)))

Solution (Python):
import sys, math, itertools, collections, bisect,copy
s=list(input())
s2=copy.deepcopy(s)
ans=0
if len(s)=="1":
    print(0)
    exit()
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        if s[i]=="0":
            s[i+1]="1"
        else:
            s[i+1]="0"
        ans+=1
if s2[0]=="0":
    s2[0]="1"
    ans2=1
else:
    s2[0]="0"
    ans2=1
for i in range(len(s2)-1):
    if s2[i]==s2[i+1]:
        if s2[i]=="0":
            s2[i+1]="1"
        else:
            s2[i+1]="0"
        ans2+=1
print(min(ans,ans2))

Solution (Python):
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    
    n = len(s)
    
    cnt = 0
    for i in range(n):
        if i%2 == 1 and s[i] == '1':
            cnt += 1
        if i%2 == 0 and s[i] == '0':
            cnt += 1
    print(min(cnt, n-cnt))
    return

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
L = len(S)
oioi =""
ioio =""
Aoi = 0
Aio = 0
for i in range(L):
  if i%2 == 0:
    oioi = oioi+"0"
    ioio = ioio+"1"
  else:
    oioi = oioi + "1"
    ioio = ioio + "0"

for j in range(L):
  if S[j] != oioi[j]:
    Aoi = Aoi+1
  
  if S[j] != ioio[j]:
    Aio = Aio+1

print(min(Aoi,Aio))

Solution (Python):
color = [int(i) for i in input()]
n = len(color)
ans = 0

if n%2==1:
    arfa = [1,0]*(n//2) + [1]
    beta = [0,1]*(n//2) + [0]
else:
    arfa = [1,0]*(n//2)
    beta = [0,1]*(n//2)

ansa=0;ansb=0
for i in range(n):
    if color[i]!=arfa[i]:
        ansa += 1
    if color[i]!=beta[i]:
        ansb += 1
print(min([ansa,ansb]))

Solution (Python):
s = input()

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

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

if ct1 <= ct2:
    print(ct1)
else:
    print(ct2)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

    s = input().rstrip()
    n = len(s)
    a,b = 0,0
    for i in range(n):
        if i%2==0:
            if s[i]=='0':
                a += 1
        else:
            if s[i]=='1':
                a += 1

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

    print(min(a,b))

if __name__ == '__main__':
    main()

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

change_a=0
for i in range(length):
    if i%2==0 and S[i]=='1':
        change_a+=1
    if i%2==1 and S[i]=='0':
        change_a+=1

change_b=0
for i in range(length):
    if i%2==0 and S[i]=='0':
        change_b+=1
    if i%2==1 and S[i]=='1':
        change_b+=1

print(min(change_a, change_b))

Solution (Python):
S = input()
nS = len(S)
white = ("01"*100000)[:nS]
black = ("10"*100000)[:nS]
sa_white = len([1 for x,y in zip(S, white) if x!=y])
sa_black = len([1 for x,y in zip(S, black) if x!=y])
print(min(sa_white, sa_black))

Solution (Python):
s = list(input())
s10 = ['1' if i%2 != 0 else '0' for i in range(len(s))]
s01 = ['0' if i%2 != 0 else '1' for i in range(len(s))]
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
  if s[i] == s10[i]:
    cnt1 += 1
  if s[i] == s01[i]:
    cnt2 += 1
print(min(cnt1,cnt2))

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

Solution (Python):
def main():
    S = input()
    cnt = 0
    if(S[0] == "0"):
        if(len(S)%2 == 0):
            ans = "01"*(len(S)//2)
        else:
            ans = "01"*(len(S)//2)+"0"
    else:
        if(len(S)%2 == 0):
            ans = "10"*(len(S)//2)
        else:
            ans = "10"*(len(S)//2)+"1"
    
    for i in range(len(S)):
        if(S[i] != ans[i]):
            cnt += 1
    print(cnt)
main()

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

Solution (Python):
s_list1 = list(input())
n = len(s_list1)
s_list2 = s_list1.copy()
dic = {"0": "1", "1": "0"}

ans1 = 0
for i in range(n):
    if i == 0:
        if s_list1[i] == 1:
            s_list1[i] = 0
            ans1 += 1
    else:
        if s_list1[i - 1] == s_list1[i]:
            s_list1[i] = dic[s_list1[i - 1]]
            ans1 += 1


ans2 = 0
for i in range(n):
    if i == 0:
        if s_list2[i] == 0:
            s_list2[i] = 1
            ans2 += 1
    else:
        if s_list2[i - 1] == s_list2[i]:
            s_list2[i] = dic[s_list2[i - 1]]
            ans2 += 1
print(min(ans1, ans2))

Solution (Python):
S = str(input())
SL = []
count = 0
for i in range(len(S)):
  SL.append(S[i])
for i in range(1,len(SL)):
  if SL[i] == SL[i-1]:
    if SL[i] == '0':
      SL[i] = '1'
    else:
      SL[i] = '0'
    count += 1
print(count)

Solution (Python):
s = input()
n = len(s)
count = 0
for i in range(n):
    if (i & 1) ^ int(s[i]):
        count += 1
print(min(count,n-count))

Solution (Python):
s = str(input())
ans_0 = 0
ans_1 = 0
for i in range(len(s)):
    if (i+1)%2 == int(s[i]):
        ans_0 += 1
    else:
        ans_1 += 1
print(min(ans_0,ans_1))

Solution (Python):
s=input();z=sum([int(s[i])==i%2 for i in range(len(s))]);print(min(z,len(s)-z))

Solution (Python):
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

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

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

print(min(count, count2))

Solution (Python):
s = input()
first_white = 0
first_brack = 0
for si in s[::2]:
    if si == '0':
        first_brack += 1
    else:
        first_white += 1
for si in s[1::2]:
    if si == '0':
        first_white += 1
    else:
        first_brack += 1
print(min(first_brack, first_white))

Solution (Python):
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()

cnt1, cnt2 = 0, 0
for i, c in enumerate(S):
    if i % 2 == 0:
        if c == '1':
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if c == '1':
            cnt2 += 1
        else:
            cnt1 += 1
print(min(cnt1, cnt2))

Solution (Python):
a = input()
l1 = a[::2]
l2 = a[1::2]
x, y = 0, 0
for i in range(len(l1)):
  if l1[i] =='1':
    x +=1
for i in range(len(l2)):
  if l2[i] =='0':
    y +=1
print(min(x +y,len(l1)-x + len(l2)-y))

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

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

print(min(x1, x2))

Solution (Python):
s = input()

s_01 = ''
s_10 = ''

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

for i in range(1,len(s)+1):
    if i % 2 == 1:
        s_10 += '1'
    
    else:
        s_10 += '0'
    
c_01 = 0
c_10 = 0

for i in range(len(s)):
    if s[i] != s_01[i]:
        c_01 += 1
    
    if s[i] != s_10[i]:
        c_10 += 1

print(min(c_10,c_01))

Solution (Python):
S = input()
list_S = [int(x) for x in S]

N = len(S)
if N % 2 == 0:
  op1 = [0, 1] * int(N//2)
  op2 = [1, 0] * int(N//2)
else:
  op1 = [0, 1] * int(N//2) + [0]
  op2 = [1, 0] * int(N//2) + [1]
  
cnt_op1 = 0
cnt_op2 = 0
for i in range(N):
  if list_S[i] != op1[i]:
    cnt_op1 += 1
  if list_S[i] != op2[i]:
    cnt_op2 += 1

print(min(cnt_op1, cnt_op2))

Solution (Python):
s = input()

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

Solution (Python):
A = list(input())
count = 0
if int(A[0]) == 1:
    flg = 1
else:
    flg = 0
for i in A:
    if int(i) == flg:
        if flg == 0:
            flg = 1
        else:
            flg = 0
    else:
        count += 1
        if flg == 0:
            flg = 1
        else:
            flg = 0
print(count)

Solution (Python):
s=input()
if s.count('01')>s.count('10') or (s.count('01')==s.count('10') and s[0]=='0'):
    cvf='0'
    cvb='1'
else:
    cvf='1'
    cvb='0'
c=0
for i in range(0,len(s),2):
    if s[i] != cvf:
        c+=1
    try:
        if s[i+1] != cvb:
            c+=1
    except IndexError:
        break
print(c)

Solution (Python):
S = list(map(int,(input())))
N = len(S)
pa = [None]*N
pb = [None]*N

for i in range(N):
    if i%2 == 0:
        pa[i] = 0
    else:
        pa[i] = 1

for i in range(N):
    if i%2 == 0:
        pb[i] = 1
    else:
        pb[i] = 0

ca = 0
cb = 0
for i in range(N):
    ca += abs(pa[i] - S[i])
    cb += abs(pb[i] - S[i])

print(min(ca,cb))

Solution (Python):








def resolve():
    S = input()
    A = [int(c) for c in S]

    temp1=[0]*len(S)
    for i in range(0,len(S),2):
        temp1[i]=1

    temp2=[0]*len(S)
    for i in range(1,len(S),2):
        temp2[i]=1

    cnt1=0
    cnt2=0
    for i in range(len(S)):
        if A[i]!=temp1[i]:
            cnt1+=1
        if A[i]!=temp2[i]:
            cnt2+=1

    print(min(cnt1,cnt2))





resolve()

Solution (Python):
s = input()

c = s[::2].count('0') + s[1::2].count('1')
print(min(c, len(s)-c))

Solution (Python):
S = input()
n = len(S)
ans1, ans2 = 0, 0
for i, s in enumerate(S):
    m = int(s)
    if i % 2:
        ans1 += 1 - m
        ans2 += m
    else:
        ans1 += m
        ans2 += 1 - m
print(min(ans1, ans2))

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    S=readline().strip()
    N=len(S)

    
    count0=0
    count1=0
    for i in range(N):
        if i%2==0:
            if S[i]=="0":
                count0+=1
            elif S[i]=="1":
                count1+=1
        else:
            if S[i]=="1":
                count0+=1
            elif S[i]=="0":
                count1+=1

    print(min(count0,count1))
        
if __name__=="__main__":
    main()

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

Solution (Python):
S = input()
l = len(S)
ideal1 = '10' * (l // 2)
ideal2 = '01' * (l // 2)
if l % 2 == 1:
    ideal1 += '1'
    ideal2 += '0'
cnt1 = 0
cnt2 = 0

for i in range(l):
    if ideal1[i] != S[i]:
        cnt1 += 1
    if ideal2[i] != S[i]:
        cnt2 += 1
print(min(cnt1,cnt2))