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 = [int(x) for x in list(input())]

counter1 = 0
current_value = 0
for _ in S:
    if not _ == current_value:
        counter1 += 1
    if current_value == 0:
        current_value = 1
    else:
        current_value = 0

counter2 = 0
current_value = 1
for _ in S:
    if not _ == current_value:
        counter2 += 1
    if current_value == 0:
        current_value = 1
    else:
        current_value = 0

print(min([counter1, counter2]))

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

Solution (Python):
S = input()
fbcnt = 0
fwcnt = 0

for i in range(len(S)):
    val = S[i]
    if i%2==0:
        if val == '1':
            fbcnt += 1
        else:
            fwcnt += 1
    else:
        if val == '1':
            fwcnt += 1
        else:
            fbcnt += 1
print(min(fbcnt, fwcnt))

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, groupby
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

S = input()

if len(S) == 1:
	print(0)
	exit()

S1 = []
S2 = []

cnt1 = 0
cnt2 = 0

for i in range(len(S)):
	if i%2 == 0:
		S1.append("0")
		S2.append("1") 
	else:
		S1.append("1")
		S2.append("0") 

	if S[i] == S1[i]:
		cnt1 += 1

	if S[i] == S2[i]:
		cnt2 += 1

print(min(cnt1, cnt2))

Solution (Python):

import io
import math

data = input()
qwe = data[::2].count('0') + data[1::2].count('1')
print(min(qwe, len(data)-qwe))

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

cnt_1 = 0
cnt_2 = 0

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

Solution (Python):

s = input()
n = len(s)
b = 0
w = 0


if n % 2 == 0:
    black = '01' * (n // 2)
    white = '10' * (n // 2)
else:
    black = '01' * (n // 2) + '0'
    white = '10' * (n // 2) + '1'



for i in range(n):
    if s[i] != black[i]:
        b += 1
    if s[i] != white[i]:
        w += 1

print(min(b, w))

Solution (Python):
def main():
    S = list(input())
    even = [ "0" if (i + 1) % 2 == 0 else "1" for i in range(len(S))]
    odd  = [ "0" if (i + 1) % 2 != 0 else "1" for i in range(len(S))]
    n_even = 0
    n_odd = 0
    for i in range(len(S)):
        if S[i] != even[i]:
            n_even += 1
        if S[i] != odd[i]:
            n_odd += 1
    print(min(n_odd, n_even))
main()

Solution (Python):
def main():
    S = input()
    L = len(S)
    a, b = 0, 0
    for i in range(L):
        if i % 2 == 0:
            if S[i] == '0':
                a += 1
            else:
                b += 1
        else:
            if S[i] == '1':
                a += 1
            else:
                b += 1
    print(min(a, b))


if __name__ == '__main__':
    main()

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

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

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

t1 = ["0" if i % 2 == 0 else "1" for i in range(len(s))]
t2 = ["1" if i % 2 == 0 else "0" for i in range(len(s))]

c1 = 0
c2 = 0

for i in range(len(s)):
    if s[i] != t1[i]:
        c1 += 1

for i in range(len(s)):
    if s[i] != t2[i]:
        c2 += 1

print(min(c1,c2))

Solution (Python):
from operator import sub
s = list(map(int,input()))
l0 = [0] * len(s)
l1 = [0] * len(s)
for i in range(len(s)):
    if (i & 1) == 1: l0[i] += 1
    else: l1[i] += 1
c0 = list(map(sub,s,l0))
c1 = list(map(sub,s,l1))
cnt0 = 0
cnt1 = 0
for i in range(len(s)):
    if c0[i] == 0: pass
    else: cnt0 += 1
    if c1[i] == 0: pass
    else: cnt1 += 1
print(min(cnt0,cnt1))

Solution (Python):
def main():
    S = list(map(int, list(input())))
    cnt1, cnt2 = 0, 0
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s:
                cnt1 += 1
            else:
                cnt2 += 1
        else:
            if s:
                cnt2 += 1
            else:
                cnt1 += 1
    print(min(cnt1, cnt2))


if __name__ == '__main__':
    main()

Solution (Python):
s = list(map(int,input()))
n = len(s)
cnt1 = 0
cnt0 = 0
s1 = s[:]
s2 = s[:]
if s1[0] == 0:
    for i in range(n-1):
        if s1[i] == 0:
            if s1[i+1] == 1:
                pass
            else:
                s1[i+1] = 1
                cnt0 += 1
        else:
            if s1[i+1] == 0:
                pass
            else:
                s1[i+1] = 0
                cnt0 += 1
else:
    s1[0] = 0
    cnt0 += 1
    for i in range(n-1):
        if s1[i] == 0:
            if s1[i+1] == 1:
                pass
            else:
                s1[i+1] = 1
                cnt0 += 1
        else:
            if s1[i+1] == 0:
                pass
            else:
                s1[i+1] = 0
                cnt0 += 1
if s2[0] == 1:
    for i in range(n-1):
        if s2[i] == 0:
            if s2[i+1] == 1:
                pass
            else:
                s2[i+1] = 1
                cnt1 += 1
        else:
            if s2[i+1] == 0:
                pass
            else:
                s2[i+1] = 0
                cnt1 += 1
else:
    s2[0] = 0
    cnt1 += 1
    for i in range(n-1):
        if s2[i] == 0:
            if s2[i+1] == 1:
                pass
            else:
                s2[i+1] = 1
                cnt1 += 1
        else:
            if s2[i+1] == 0:
                pass
            else:
                s2[i+1] = 0
                cnt1 += 1


l = [cnt0,cnt1]
print(min(l))

Solution (Python):
s = [-1 if s=='0' else 1 for s in list(input())]

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

Solution (Python):

s = list(input())

t1 = ["0" if i % 2 == 0 else "1" for i in range(len(s))]
t2 = ["1" if i % 2 == 0 else "0" for i in range(len(s))]

c1 = 0
c2 = 0

for i in range(len(s)):
    if s[i] != t1[i]:
        c1 += 1

for i in range(len(s)):
    if s[i] != t2[i]:
        c2 += 1

print(min(c1,c2))

Solution (Python):
S = input()
ans = 0
for i in range(len(S)):
  tmp = S[i]
  if(i == 0):
    tmp2 = tmp
  else:
    if(i % 2 == 0 and tmp2 != tmp):
      ans += 1
    elif(i % 2 != 0 and tmp2 == tmp):
      ans += 1
print(str(ans))

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

sf = []
sb = []
for i in range(len(s)):
  if i % 2 == 0:
    sf.append("1")
    sb.append("0")
  else:
    sf.append("0")
    sb.append("1")
    
cntf = 0
cntb = 0
for i in range(len(s)):
  if sf[i] != s[i]:
    cntf += 1
  if sb[i] != s[i]:
    cntb += 1
print(min(cntf, cntb))

Solution (Python):

s = list(input())

count1 = 0

count2 = 0

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

print(min(count1,count2))

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

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

s = load(str)

n = len(s)

s1 = ["0" for _ in range(n)]
s2 = ["1" for _ in range(n)]

def hanten(c):
    if c == "0":
        return "1"
    return "0"

for i in range(1, n):
    s1[i] = hanten(s1[i-1])
    s2[i] = hanten(s2[i-1])

ans1 = 0
ans2 = 0
for i in range(0, n):
    if s[i] != s1[i]:
        ans1 += 1
    if s[i] != s2[i]:
        ans2 += 1

print(min(ans1, ans2))

Solution (Python):
s=list(input())
p=['1' if i%2==0 else "0" for i in range(len(s))]
q=['0' if i%2==0 else "1" for i in range(len(s))]
print(min(len([0 for i in range(len(s)) if s[i]!=p[i]]),len([0 for i in range(len(s)) if s[i]!=q[i]])))

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


def flip(c):
    return '1' if c == '0' else '0'


a, b = 0, 1
pre_a, pre_b = s[0], flip(s[0])

for i in range(1, len(s)):
    if pre_a == s[i]:
        a += 1
        pre_a = flip(s[i])
    else:
        pre_a = s[i]

    if pre_b == s[i]:
        b += 1
        pre_b = flip(s[i])
    else:
        pre_b = s[i]

print(min(a, b))

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

Solution (Python):
s=input()

a=["0","1"]

one=0
two=0
for i,tail in enumerate(s):
    if a[i%2]!=tail:
        one+=1
    else:
        two+=1
print(min(one,two))

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

string = '0'
ans1 = 0
for i in range(n):
	if s[i] != string:
		ans1 += 1
	if string == '0':
		string = '1'
	else:
		string = '0'

string = '1'
ans2 = 0
for i in range(n):
	if s[i] != string:
		ans2 += 1
	if string == '0':
		string = '1'
	else:
		string = '0'

print(min(ans1,ans2))

Solution (Python):
s = input()
n = len(s)
white_start = ["0" if i%2==0 else "1" for i in range(n)]



Wcnt = 0


for i in range(n):
  if s[i]!=white_start[i]:
    Wcnt +=1
  
    
print(min(Wcnt,n-Wcnt))

Solution (Python):
S=list(input())
t=S[0]
count=0
for i in range(1,len(S)):
	if t==S[i]:
		S[i]=str(1-int(S[i]))
		count+=1
	t=S[i]
	
print(count)

Solution (Python):
S = input()

if len(S)%2 == 1:
    T = "10"*(len(S)//2) + "1"
    U = "01"*(len(S)//2) + "0"
else:
    T = "10"*(len(S)//2)
    U = "01"*(len(S)//2)

t_ans = 0
u_ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        t_ans += 1
    if S[i] != U[i]:
        u_ans += 1

print(min(t_ans, u_ans))

Solution (Python):
S = input()

is_even = lambda number: number % 2 == 0
is_odd = lambda number: not is_even(number)

even = S[0]
odd = '1' if even == '0' else '0'

answer = 0
for i, Si in enumerate(S):
    if is_even(i) and Si != even:
        answer += 1
    elif is_odd(i) and Si != odd:
        answer += 1

print(answer)

Solution (Python):
S = input()

if S[0::2].count('0') > S[1::2].count('0'):
    print(S[0::2].count('1') + S[1::2].count('0'))
else:
    print(S[0::2].count('0') + S[1::2].count('1'))

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

Solution (Python):
s=input()
l=len(s)
c1=-(-l//2)
c2=l//2
c1b=0
c2b=0

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

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




print(count)

Solution (Python):
S = input()

if S[0::2].count('0') > S[1::2].count('0'):
    print(S[0::2].count('1') + S[1::2].count('0'))
else:
    print(S[0::2].count('0') + S[1::2].count('1'))

Solution (Python):
S = list(map(int, input()))
N = len(S)
count1 = 0
count2 = 0
if N == 1:
    print(0)
    exit()
for a in range(N):
    if a % 2 == 0:
        if S[a] != 0:
            count1 += 1
    else:
        if S[a] != 1:
            count1 += 1

for a in range(N):
    if a % 2 == 0:
        if S[a] != 1:
            count2 += 1
    else:
        if S[a] != 0:
            count2 += 1

print(min(count1, count2))

Solution (Python):













S = input()

zerokara = S[0::2]
onekara = S[1::2]

ans1 = zerokara.count("1")+onekara.count("0")
ans2 = zerokara.count("0")+onekara.count("1")
ans = min(ans1,ans2)

print(ans)

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

Solution (Python):

s = input()

n = len(s)
ans1 = [i % 2 for i in range(n)]
ans2 = [i % 2 for i in range(1,n+1)]


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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

ss = [int(i) for i in STR()]
s = deepcopy(ss)
ans1 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        ans1 += 1
s = deepcopy(s)
s[0] = int(not s[0])
ans2 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

s = [int(i) for i in STR()]
flag = False
ans = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        if flag:
            flag = False
            ans += 1
        else:
            flag = False
            ans += 1
    if flag:
        ans += 1
print(ans)

Solution (Python):
import sys

s = sys.stdin.readline().rstrip()

def main():
    c1 = s[::2].count('1') + s[1::2].count('0')
    c2 = s[::2].count('0') + s[1::2].count('1')
    print(min(c1, c2))

if __name__ ==  '__main__':
    main()

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

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

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

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = np.array(list(sr()), np.int8)
length = len(S)
complete = np.arange(length) & 1
r1 = (S == complete).sum()
r2 = (S != complete).sum()
answer = min(r1, r2)
print(answer)

Solution (Python):










mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    pr = S[0] 
    cnt = 0
    for i in range(1,len(S)):
        if S[i] != pr:
            pr = S[i]
        else:
            cnt += 1
            if pr == '0':
                pr = '1'
            else:
                pr = '0'
    print(cnt)
if __name__ == '__main__':
  main()

Solution (Python):
s = list(input())
cnt0 = 0
cnt1 = 0
for i, ss in enumerate(s):
    if i % 2 == 0 :
        if ss == '0':
            cnt1 += 1
        else:
            cnt0 += 1
    else:
        if ss == '1':
            cnt1 += 1
        else:
            cnt0 += 1
print(min(cnt0,cnt1))

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(map(int, list(sr())))
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        S[i+1] = 1 - S[i+1]
        count += 1

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

Solution (Python):
S=input()
ans=[0]*2
for i,s in enumerate(S):
  i%=2
  if int(s)==i:
    ans[1]+=1
  else:
    ans[0]+=1
print(min(ans))

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

Solution (Python):
s = input()

z_g = 0
z_k = 0
o_g = 0
o_k = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            z_g += 1
        else:
            o_g += 1
    else:
        if s[i] == "0":
            z_k += 1
        else:
            o_k += 1

if (z_g + o_k) > (z_k + o_g):
    print(z_k + o_g)
else:
    print(z_g + o_k)

Solution (Python):
S = input()
N = len(S)
even = S[0::2]
odd = S[1::2]
ptn0 = N - (even.count('0') + odd.count('1'))
ptn1 = N - (even.count('1') + odd.count('0'))
print(min(ptn0, ptn1))

Solution (Python):
S = input()

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

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

print(min(cost1, cost2))

Solution (Python):

s = input()
ans = len(s)
for i in range(0, 2):
    cnt = 0
    for j in range(0, 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(ans, cnt)
print(ans)

Solution (Python):

s = input()
ans = len(s)
for i in range(0, 2):
    cnt = 0
    for j in range(0, 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(ans, cnt)
print(ans)

Solution (Python):
def modelAnswer(s:list) -> int:
   white = "1"
   ans_w = 0
   black = "0"
   ans_b = 0
   for i in s:
      if(i != white):
         ans_w +=1
      else:
         ans_b += 1
      white = "0" if(white == "1") else "1"
      black = "0" if(black == "1") else "1"
   return min(ans_b,ans_w)

def main():
   s = list(input())
   print(modelAnswer(s))

if __name__ == '__main__':
   main()

Solution (Python):

def myAnswer(s:list) -> str:
   ans = 0
   pre =s.pop(0)
   for i in s:
      if(pre == i):
         ans += 1
      pre = "1" if(pre == "0") else "0"
   return ans

def modelAnswer():
   tmp=1
def main():
   s = list(input())
   print(myAnswer(s))

if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer(s:list) -> str:
   ans = 0
   pre =s.pop(0)
   for i in s:
      if(pre == i):
         ans += 1
         pre = "1" if(i == "0") else "0"
      else:
         pre = i
   return ans

def modelAnswer():
   tmp=1
def main():
   s = list(input())
   print(myAnswer(s))

if __name__ == '__main__':
   main()

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

print(min(count,tmp))

Solution (Python):
S = input()

ans = 0
if S[0] == '0':
    ans += S[2::2].count('1')
    ans += S[1::2].count('0')
else:
    ans += S[2::2].count('0')
    ans += S[1::2].count('1')

print(ans)

Solution (Python):
s=input();a=int(("10"*10**5)[:len(s)],2);s=int(s,2);c=lambda x: str(bin(x^s)).count("1");print(min(c(a),c(a>>1)))

Solution (Python):
s = input()
a = int(("10"*10**5)[:len(s)], 2)
s = int(s, 2)
c = lambda x: str(bin(x^s)).count("1")
print(min(c(a), c(a>>1)))

Solution (Python):
S = input()

S1 = S
count1 = 0
prev1 = '0'
for s in S1:
    if prev1 == s == '0':
        s = '1'
        count1 += 1
    if prev1 == s == '1':
        s = '0'
        count1 += 1
    prev1 = s

S2 = S
count2 = 0
prev2 = '1'
for s in S2:
    if prev2 == s == '0':
        s = '1'
        count2 += 1
    if prev2 == s == '1':
        s = '0'
        count2 += 1
    prev2 = s

print(min(count1, count2))

Solution (Python):
receber = input()
contador = 0
contaor = 0
casoUm=""
casoDois=""
if receber[0] == "1":
    for i in range(len(receber)):
        if i%2==0:
            casoUm+="1"
        else:
            casoUm+="0"
    for k in range(len(receber)):
        if receber[k] != casoUm[k]:
            contador+=1
else:
    for i in range(len(receber)):
        if i%2==0:
            casoDois+="0"
        else:
            casoDois+="1"
    for k in range(len(receber)):
        if receber[k] != casoDois[k]:
            contador+=1

print(contador)

Solution (Python):
s = [int(x) for x in input()]
correto_0 = []
correto_1 = []
for i in range(len(s)):
    if i % 2 != 0:
        correto_0.append(0)
        correto_1.append(1)
    else:
        correto_0.append(1)
        correto_1.append(0)
for i in range(len(s)):
    correto_0[i] = correto_0[i] - s[i]
    correto_1[i] = correto_1[i] - s[i]
resp_0 = [abs(x) for x in correto_0]
resp_1 = [abs(x) for x in correto_1]
print(min(sum(resp_0),sum(resp_1)))

Solution (Python):
def main():
    s = input()
    mudancas=0;
    mudancasn=0;
    s=list(s)
    n=[]
    for i in range(0, len(s)):
        n.append(s[len(s)-1-i])
    
    if(len(s)==1):
        print("0")
        return;

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

        if(n[i]==n[i-1]):
            mudancasn+=1
            if(n[i]=='0'):
                n[i]='1'
            else:
                n[i]='0'

    if(mudancas>mudancasn):
        print(mudancasn)
    else:
        print(mudancas)
        
    return 0
    
main()

Solution (Python):
s = input()
s = list(s)
to_black = 0
to_white = 0
last = '0' if s[0] == '1' else '1'
pos = 0
for c in s:
    if c == last and c == '0':
        to_white+=1
        s[pos] = '1'
        c = '1'
    elif c == last and c == '1':
        to_black+=1
        s[pos] = '0'
        c = '0'
    last = c
    pos+=1
print(to_black+to_white)

Solution (Python):
string = input()
predicted_value = 0
last_colour = bool(int(string[0]))
for s in string[1:]:
    was_white = bool(int(s))
    if last_colour == was_white:
        predicted_value += 1
        last_colour = not was_white
    else:
        last_colour = was_white
print(predicted_value)

Solution (Python):
s = input()

count = 0
previous = ''
for c in s:
    if c == previous:
        count += 1
        if c == '1':
            previous = '0'
        if c == '0':
            previous = '1'
    else:
        previous = c

print(count)

Solution (Python):
def mismatch(S, T, n):
    count = 0
    for i in range(n):
        if S[i] != T[i]:
            count += 1
    return count

S = input()
n = len(S)
T1 = ""
T2 = ""
for i in range(n):
    if i % 2 == 0:
        T1 += "0"
        T2 += "1"
    else:
        T1 += "1"
        T2 += "0"
print(min(mismatch(S, T1, n), mismatch(S, T2, n)))

Solution (Python):

s = input()
p1 = 0
p2 = 0
for i in range(len(s)):
    if i%2==0:
        if s[i]!="0":
            p1 += 1
    else:
        if s[i]!="1":
            p1 += 1

for i in range(len(s)):
    if i%2==0:
        if s[i]!="1":
            p2 += 1
    else:
        if s[i]!="0":
            p2 += 1
            
print(min(p1, p2))

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt1=0
    for i,ss in enumerate(s):
        if int(ss)==i%2:cunt1+=1
    cunt2=0
    for i,ss in enumerate(s):
        if int(ss)!=i%2:cunt2+=1   
    print(min(cunt1,cunt2))

if __name__=='__main__':
    main()

Solution (Python):
S = input()
N = len(S)
cnt = 0
color = ['0', '1']
for i in range(N):
    if color[i%2] == S[i]:
        cnt += 1
print(min(cnt, N-cnt))

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

Solution (Python):
S = input()

ans = 10e9

prev = '1'
res = 0
for s in S:
    if prev == s:
        res += 1
        prev = '1' if s == '0' else '0'
    else:
        prev = s
ans = min(ans, res)

prev = '0'
res = 0
for s in S:
    if prev == s:
        res += 1
        prev = '1' if s == '0' else '0'
    else:
        prev = s
ans = min(ans, res)

print(ans)

Solution (Python):
S = input()
odd, even = '', ''
for i, s in enumerate(S):
    if i % 2:
        odd += s
    else:
        even += s
n = odd.count('1')+even.count('0')
print(min(n, len(S)-n))

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


s1 = ['0']
s2 = ['1']
for i in range(2,digit+1):
  if i%2==0:
    s1.append('1')
    s2.append('0')
  else:
    s1.append('0')
    s2.append('1')
count1 = 0
count2 = 0
for i in range(digit):
  if n[i]!=s1[i]:
    count1 += 1
  if n[i]!=s2[i]:
    count2 += 1
print(min(count1,count2))

Solution (Python):
s = input()

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

print(min(a, b))

Solution (Python):
s=list(input())
s1=len(s)
c=[]
k=[]
c1=0
k1=0
for i in range(s1):
    if i%2==0:
        c.append('1')
        k.append('0')
        if s[i]==c[i]:k1+=1
        else:c1+=1
    else:
        c.append('0')
        k.append('1')
        if s[i]==c[i]:k1+=1
        else:c1+=1
print(min(c1,k1))