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

Solution (Python):
def main() -> None:
    S = input()
    a1 = cou(S, '0', '1')
    a2 = cou(S, '1', '0')
    print(min(a1, a2))


def cou(S, f, s):
    num = 0
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == f:
                num += 1
            else:
                pass
        elif i % 2 != 0:
            if S[i] == s:
                num += 1
            else:
                pass
    return num


if __name__ == '__main__':
    main()

Solution (Python):

import copy
import numpy as np
import random
import bisect 
import math

S = str(input())

ans_S = [str(0) for i in range(len(S))]
ans_1 = 0
for i in range(len(S)):
    if i%2==0:
        ans_S[i] = str(1)

    if ans_S[i]!=S[i]:
        ans_1 += 1

ans_2 = 0
ans_S = [str(0) for i in range(len(S))]
for i in range(len(S)):
    if i%2==1:
        ans_S[i] = str(1)

    if ans_S[i]!=S[i]:
        ans_2 += 1

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

Solution (Python):
S_list = list(input())
result = 0
level = S_list.pop(0)
for s in S_list:
    if level == s and s == "0":
        level = "1"
        result += 1
    elif level == s and s == "1":
        level = "0"
        result += 1
    else:
        level = s
print(result)

Solution (Python):
l=list(map(int,input()))
le=len(l)
p1,p2=[],[]
a,b=1,0
for i in range(le):
    p1.append(a)
    p2.append(b)
    a,b=b,a
m1,m2=0,0
for i in range(le):
    m1+=abs(l[i]-p1[i])
    m2+=abs(l[i]-p2[i])
print(min(m1,m2))

Solution (Python):
S_str = input()
S_lists=[ int(S) for S in S_str]
print(min(sum([ abs(S-i)%2 for i,S in enumerate(S_lists)]),sum([ abs(S-i+1)%2 for i,S in enumerate(S_lists)])))

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

Solution (Python):
S = input()

if S[0] == "1":
  print(S[::2].count("0")+S[1::2].count("1"))
else:
  print(S[::2].count("1")+S[1::2].count("0"))

Solution (Python):
S = input()

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

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

print(min(count1, count2))

Solution (Python):

"""
AtCoder
"""

def main():
    S=list(map(str,input().split()))
    
    S=S[0]
    
    N=len(S)

    s0=0
    s1=0
    for i in range(N):
        if i%2==0:
            if S[i]=="0":
                s1+=1
            else:
                s0+=1
        else:
            if S[i]=="1":
                s1+=1
            else:
                s0+=1
    print(min(s0,s1))

if __name__ == "__main__":
    main()

Solution (Python):
def count(li, first):
    if first == '0':
        isZero = True
    else:
        isZero = False
    counter = 0
    for i in li[1:]:
        if i == '0' and isZero:
            counter += 1
            isZero = False
        elif i == '1' and (not isZero):
            counter += 1
            isZero = True
        else:
            isZero = not isZero
    return counter


S = input()

print(min([count(list(S), S[0]), count(list(S)[::-1], list(S)[::-1][0])]))

Solution (Python):
S = input()
z_o_cnt = 0
o_z_cnt = 0

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

print(len(S) - (z_o_cnt if z_o_cnt > o_z_cnt else o_z_cnt))

Solution (Python):
S = input()

if len(S) == 1:
    print(0)
else:
    S0 = S[::2]
    S1 = S[1::2]

    tmp1 = sum([int(c) for c in S0]) + len(S1) - sum([int(c) for c in S1])
    tmp2 = len(S0) - sum([int(c) for c in S0]) + sum([int(c) for c in S1])
    
    print(min(tmp1,tmp2))

Solution (Python):
import sys

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

if len(S) <= 1:
    print(0)
    sys.exit()

S2 = [s for s in S]
S2[0] ^= 1

res1 = 0
res2 = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        S[i+1] ^= 1
        res1 += 1
    if S2[i] == S2[i+1]:
        S2[i+1] ^= 1
        res2 += 1

print(min([res1, res2]))

Solution (Python):
import numpy as np
x = list(input())
x = [int(y) for y in x]
x = np.array(x)
A = [i % 2 for i in range(len(x))]
A = np.array(A)
B = [(i+1) % 2 for i in range(len(x))]
B = np.array(B)
dA = np.sum((x - A)**2)
dB = np.sum((x - B)**2)
print(min(dA,dB))

Solution (Python):
def generate(len, origin):
    lis = []
    for i in range(len):
        if i % 2 == 0:
            lis.append(origin)
        else:
            lis.append(abs(origin - 1))
    return lis

a = list(map(int, list(input())))
data = list(a)
origin = a[0]
risou = generate(len(data), origin)
res = 0

for i in range(len(data)):
    if data[i] != risou[i]:
        res = res + 1
print(res)

Solution (Python):
x=list(map(int,input()))
count=0
if len(x)>0:
  for i in range(1,len(x)):
    if x[i-1]==x[i]:
      x[i]=1-x[i]
      count+=1
  print(count)
else:
  print(0)

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

s = list(input().rstrip())

s_odd = [s[x] for x in range(len(s)) if x % 2 != 0]
s_even = [s[x] for x in range(len(s)) if x % 2 == 0]


print(min([s_odd.count('1')+s_even.count('0'),s_odd.count('0')+s_even.count('1')]))

Solution (Python):
N = input()
zero_one = 0
one_zero = 0

for key, v in enumerate(N):
    if (key+1) % 2 == 1:
        if v == "0":
            zero_one += 1
        elif v == "1":
            one_zero += 1
    elif (key+1) % 2 == 0:
        if v == "0":
            one_zero += 1
        elif v == "1":
            zero_one += 1

print(min(one_zero, zero_one))

Solution (Python):
S=input()
N=len(S)
c=0
c2=0

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

for j in range(N):
  if j % 2 == 0:
    if S[j] == "1":
      c2 += 1
  else:
    if S[j] == "0":
      c2 += 1
print(c if c<=c2 else c2)

Solution (Python):
S = list(input())
stlen = len(S) 
if len(S)%2 == 0:
    a = '10'*(int(stlen/2))
    b = '01'*(int(stlen/2))
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
else:
    a = '10'*(int(stlen/2))+'1'
    b = '01'*(int(stlen/2))+'0'
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))

Solution (Python):
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    s = list(input_string[0][:])
    c_1 = 0
    for i in range(len(s))[1:]:
        if s[i] == s[i-1]:
            if s[i] == "1":
                s[i] = "0"
            else:
                s[i] = "1"
            c_1 += 1
    c_2 = 0
    for i in range(len(s))[::-1][1:]:
        if s[i] == s[i+1]:
            if s[i] == "1":
                s[i] = "0"
            else:
                s[i] = "1"
            c_2 += 1
    return c_2 if c_2 > c_1 else c_1



def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin






S = stdin.readline().rstrip().split()[0]
N = len(S)

B = []
one_zero = "1"
for i, s in enumerate(S):
  B.append(s==one_zero)
  if one_zero=="1":
    one_zero = "0"
  else:
    one_zero = "1"

one = sum(B)
zero = N -one
if one < zero:
  print(one)
else:
  print(zero)

Solution (Python):
s = input()

c1 = s[::2].count("1")
c2 = s[1::2].count("0")

total = c1 + c2

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

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

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

print(min(dist1, dist2))

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

if lenS % 2 == 0:
    target1 = [str(0), str(1)] * int(lenS / 2)
    target2 = [str(1), str(0)] * int(lenS / 2)
else:
    target1 = [str(0), str(1)] * int(lenS / 2) + ['0']
    target2 = [str(1), str(0)] * int(lenS / 2) + ['1']


diff1 = 0
diff2 = 0

for i in range(len(S)):
    if target1[i] != S[i]:
        diff1 += 1
    if target2[i] != S[i]:
        diff2 += 1
        
print(min(diff1, diff2))

Solution (Python):




s=list(input())
n=len(s)
compare=["0","1"]
compare_reverse=["1","0"]
if n%2==0:
    compare=compare*(n//2)
    compare_reverse=compare_reverse*(n//2)
else:
    compare=compare*(n//2)
    compare.append("0")
    compare_reverse=compare_reverse*(n//2)
    compare_reverse.append("1")
ans=0
ans_reverse=0
for i,j in zip(s,compare):
    if i!=j:
        ans+=1
for i,j in zip(s,compare_reverse):
    if i!=j:
        ans_reverse+=1
print(min(ans,ans_reverse))

Solution (Python):
from sys import exit

S = input()

ans1 = 0
ans2 = 0

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

ans = len(S) - max(ans1, ans2)
print(ans)

Solution (Python):




s = input()

cnt_a = 0
cnt_b = 0

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


print(min(cnt_a, cnt_b))

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

Solution (Python):
S = input()
hS = int(len(S) / 2)
if len(S) == 1:
  s1 = '1'
  s2 = '0'
elif len(S) % 2 == 1:
  s1 = '10' * hS
  s1 = s1 + '1'
  s2 = '01' * hS
  s2 = s2 + '0'
else:
  s1 = '10' * hS
  s2 = '01' * hS
  
ns1, ns2 = 0, 0

for i, s in enumerate(S):
  if s != s1[i]:
    ns1 += 1

for i, s in enumerate(S):
  if s != s2[i]:
    ns2 += 1

print([ns1, ns2][ns2 < ns1])

Solution (Python):
_s = input()
_s = list(map(int, _s[:]))

ans = 0
for i, s in enumerate(_s):
    if i == 0:
        continue
    
    if s == _s[i-1]:
        ans = ans + 1
        if s == 0:
            _s[i] = 1
        else:
            _s[i] = 0

print(ans)

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

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):
t1 = ['0', '1'] * 50000
t2 = ['1', '0'] * 50000

s = input()
sl = list(s)

a1 = 0
a2 = 0

for i in range(len(sl)):
    if sl[i] != t1[i]:
        a1 += 1
    if sl[i] != t2[i]:
        a2 += 1

print(min(a1, a2))

Solution (Python):
s = input() 
answer1 = '10'*50000
answer2 = '01'*50000 

count1 = 0
for i in range(len(s)):
    if s[i] != answer1[i]:
        count1 += 1

count2 = 0
for i in range(len(s)):
    if s[i] != answer2[i]:
        count2 += 1

print(count1) if count1 < count2 else print(count2)

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

score_z = 0
score_o = 0


counter = 0
for n in h_list:
    
    if counter%2 == 0:
        if 0 != n:
            score_z += 1
    if counter%2 == 1:
        if 1 != n:
            score_z += 1
    counter+=1


counter = 0
for n in h_list:
    if counter%2 == 1:
        if 0 != n:
            score_o += 1
    if counter%2 == 0:
        if 1 != n:
            score_o += 1
    counter+=1


print(min(score_z,score_o))

Solution (Python):

l = [x for x in input()]

r = len(l)

l1 = []
l2 = []

cnt1 = 0
cnt2 = 0

for i in range(r):
	if i % 2 == 0:
		l1.append('0')
		l2.append('1')
	else:
		l1.append('1')
		l2.append('0')

for i in range(r):
	if l[i] != l1[i]:
		cnt1 += 1
	if l[i] != l2[i]:
		cnt2 += 1

print(min(cnt1,cnt2))

Solution (Python):
S = input()
N = len(S)
if N%2==0:
    C1 = "10" * (N//2)
    C2 = "01" * (N//2)
else:
    C1 = "10" * (N//2) + "1"
    C2 = "01" * (N//2) + "0"

count1 = 0
count2 = 0
for i in range(N):
    char = S[i]
    if char != C1[i]:
        count1 += 1
    elif char != C2[i]:
        count2 += 1
print(min(count1,count2))

Solution (Python):
S = input()
N = len(S)
odd = 0
even = 0

for i in range(0,N,2):
    odd += int(S[i])

for i in range(1,N,2):
    even += int(S[i])

print(min(N-int(N/2) - odd + even,int(N/2) - even + odd))

Solution (Python):
inp = []
n = [int(w) for w in list(input())]
first = []
sec = []
fres = 0
sres = 0


for f in range(len(n)):
    if f % 2 == 1:
        first.append(1)
    else:
        first.append(0)
for f in range(len(n)):
    if f % 2 == 0:
        sec.append(1)
    else:
        sec.append(0)
for x in range(len(n)):
    if n[x] != first[x]:

        fres += 1

for x in range(len(n)):
    if n[x] != sec[x]:

        sres += 1

if sres >= fres:
    print(fres)
else:
    print(sres)

Solution (Python):


S=input()
N=len(S)
X=""
Y=""
for i in range(N):
    if i%2==0:
        X=X+"0"
        Y=Y+"1"
    else:
        X=X+"1"
        Y=Y+"0"
A=0
B=0
for i in range(N):
    if X[i]!=S[i]:
        A+=1
    if Y[i]!=S[i]:
        B+=1
print(min(A,B))

Solution (Python):
import copy
S = list(input())
Ss = copy.deepcopy(S)
ans0 = 0
ans1 = 0
for i in range(1, len(S)):
    if S[i-1] == "0" and S[i] == "0":
        ans0 += 1
        S[i] = "1"
    elif S[i-1] == "1" and S[i] == "1":
        ans0 += 1
        S[i] = "0"

for i in range(1, len(Ss)):
    if Ss[0] == "0":
        Ss[0] = "1"
        ans1 += 1
    elif Ss[0] == "1":
        Ss[0] == "0"
        ans1 += 1
            
    if Ss[i-1] == "0" and Ss[i] == "0":
        ans1 += 1
        Ss[i] = "1"
    elif Ss[i-1] == "1" and Ss[i] == "1":
        ans1 += 1
        Ss[i] = "0"

print(min(ans0, ans1))

Solution (Python):
S = input()
Sfrom0 = S[::2]
Sfrom1 = S[1::2]
S0_1,S0_0,S1_1,S1_0 = Sfrom0.count('1'),Sfrom0.count('0'),Sfrom1.count('1'),Sfrom1.count('0')
move1 = S0_1 + S1_0
move2 = S0_0 + S1_1
if move1 < move2:
    print(move1)
else:print(move2)

Solution (Python):
s = input()

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

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

Solution (Python):
import numpy as np

s = input()
n = len(s)

ans = 0

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

print(min(ans, n - ans))

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

for i in range(len(s)):
    if i==0:
        x=s[i]
        ans=0
        continue
    if x==s[i]:
        x=("1" if x=="0" else "0")
        ans+=1
    else:
        x=s[i]
print(ans)

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

num_0_even = 0
num_0_odd = 0

for i in range(n // 2):
    if S[2 * i] == 0:
        num_0_even += 1
    if S[2 * i + 1] == 0:
        num_0_odd += 1
if n % 2:
    if S[n - 1] == 0:
        num_0_even += 1

a = n // 2 + n % 2 - num_0_even + num_0_odd
b = num_0_even + n // 2 - num_0_odd

if a > b:
    print(b)
else:
    print(a)

Solution (Python):
s = input()


c = 0
for i in range(len(s)):
  b = i % 2
  if int(s[i]) == b:
    c += 1



d = 0
for i in range(len(s)):
  b = (i+1) % 2
  if int(s[i]) == b:
    d += 1
    
print(min(c, d))

Solution (Python):
s=list(input())
for i in range(0,len(s),2):
  s[i]=str((int(s[i])+1)&1)
print(min(s.count("0"),s.count("1")))

Solution (Python):


S = input()

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

change_number_0 = 0
change_number_1 = 0
for i in range(len(S)):
    if S[i] != s0[i]:
        change_number_0 += 1
    if S[i] != s1[i]:
        change_number_1 += 1

if change_number_0 > change_number_1:
    print (change_number_1)
else:
    print (change_number_0)

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

count = 0
if len(s) == 1:
    print(0)
    exit()
while(True):
    if s[i-1] == s[i]:
        s[i] = str(1 - int(s[i]))
        count = count +1
    if i == len(s)-1:
        break
    i = i+1

print(count)

Solution (Python):
input_str = input()

blocks = list(input_str)


color_change_count = 0
for i in range(0,len(blocks)):
    color = blocks[i]
    color_should_be = i % 2 + 48
    if color_should_be != ord(color):
        color_change_count += 1


color_change_count2 = 0
for i in range(0,len(blocks)):
    color = blocks[i]
    color_should_be = 1 if i % 2 == 0 else 0
    color_should_be += 48
    if color_should_be != ord(color):
        color_change_count2 += 1

print(min(color_change_count,color_change_count2))

Solution (Python):
s = input()

a = s[::2]
b = s[1::2]

print(min([a.count('0') + b.count('1'), a.count('1') + b.count('0')]))

Solution (Python):
S = input()
ptn1 = "".join(["1" if i%2==0 else "0" for i in range(len(S))])
ptn2 = "".join(["0" if i%2==0 else "1" for i in range(len(S))])

sum1 = sum([1 if s!=p else 0 for s,p in zip(S,ptn1)])
sum2 = sum([1 if s!=p else 0 for s,p in zip(S,ptn2)])

print(min(sum1,sum2))

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

Solution (Python):
import math

s=input()
l=len(s)
ans1=0
r="10"*(l//2)+"1" 
if l%2==1:
  r+="1"
  
for i in range(l):
    if s[i]!=r[i]:
	    ans1+=1
		
r="01"*(l//2)+"0" 
if l%2==1:
  r+="1"
ans2=0
for i in range(l):
    if s[i]!=r[i]:
	    ans2+=1
		
print(min(ans1,ans2))

Solution (Python):
S = input()
S = list(map(int, list(S)))
t1 = [x % 2 for x in range(len(S))]
t2 = [abs(x % 2 - 1) for x in range(len(S))]

t1c = sum([abs(S[i] - t1[i]) for i in range(len(S))])
t2c = sum([abs(S[i] - t2[i]) for i in range(len(S))])

print(min(t1c, t2c))

Solution (Python):
import sys
import math


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

count1 = 0
count2 = 0

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

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

if count1 < count2:
    ans = count1
else:
    ans = count2

print(ans)

Solution (Python):
s = input()
ls = len(s)
sl = list(s)
ol = [0 if i%2 ==0 else 1 for i in range(ls)]
el = [1 if i%2 ==0 else 0 for i in range(ls)]




go = 0
for c,i in zip(sl,ol):
    if int(c) != i:
        go += 1

ge = 0
for c,i in zip(sl,el):
    if int(c) != i:
        ge += 1

print(min(go,ge))

Solution (Python):
s = input()

n = len(s)

s1 = "01" * n

s1 = s1[:len(s)]

s2 = "10" * n
s2 = s2[:len(s)]


s1n, s2n = 0 , 0
for i in range(len(s)):
    if s[i] != s1[i]:
        s1n += 1
    if s[i] != s2[i]:
        s2n += 1
print(min(s1n, s2n))

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

Solution (Python):
S = input()

bit = '0'
ans = [0, 0]
for i in S:
  if i == bit:
    ans[0] += 1
  if bit == '0':
    bit = '1'
  else:
    bit = '0'

bit = '1'
for i in S:
  if i == bit:
    ans[1] += 1
  if bit == '0':
    bit = '1'
  else:
    bit = '0'

print(min(ans))

Solution (Python):

def make_hikaku(num, n):
    org = num
    retval = []
    for i in range(n):
        retval.append(org)
        if org == 0:
            org = 1
        elif org == 1:
            org = 0
    return retval

def hikaku(a, b):
    if a == b:
        return 0
    else:
        return 1
    

def main(s):
    n = len(s)
    hikaku_a = make_hikaku(0, n)
    hikaku_b = make_hikaku(1, n)
    s_bit = 0
    s_l = list(map(int, list(s)))
    s_a = []
    s_b = []
    for i in range(n):
        s_a.append(hikaku(s_l[i], hikaku_a[i]))
        s_b.append(hikaku(s_l[i], hikaku_b[i]))
    
    print(min(sum(s_a), sum(s_b)))
    
if __name__ == '__main__':
    try:
        s = input().strip()
        main(s)
    except EOFError:
        pass

Solution (Python):
s = input()
num_list = []
a_list = []
b_list = []
a_count = 0
b_count = 0

for i in range(len(s)):
    num_list.append(s[i])
    if i % 2 == 0:
        a_list.append('0')
        b_list.append('1')
    else:
        a_list.append('1')
        b_list.append('0')

for i in range(len(s)):
    if s[i] != a_list[i]:
        a_count += 1
    if s[i] != b_list[i]:
        b_count += 1

print(min(a_count, b_count))

Solution (Python):
import numpy as np

S = list(input())

zero_one = list('01'*(len(S)//2))
if len(S)%2 == 1:
    zero_one.append('0')
 
one_zero = list('10'*(len(S)//2))
if len(S)%2 == 1:
    one_zero.append('1')
    
S = np.array(S)
zero_one = np.array(zero_one)
one_zero = np.array(one_zero)

ans = min(np.sum(S==zero_one),np.sum(S==one_zero))

print(ans)

Solution (Python):
s = input()
count_0 = 0
count_1 = 0
for i, si in enumerate(s):
    if i % 2 == 0 and si == '1':
        count_0 += 1
    elif i % 2 == 1 and si == '0':
        count_0 += 1

for i, si in enumerate(s):
    if i % 2 == 0 and si == '0':
        count_1 += 1
    elif i % 2 == 1 and si == '1':
        count_1 += 1

print(min(count_0, count_1))

Solution (Python):

def get_input():
    S = list(input())
    return S

def solve(S):
    length = len(S)
    pattern1 = ["0" if i %2 ==0 else "1" for i in range(length)]
    pattern2 = ["1" if i %2 ==0 else "0" for i in range(length)]
    count1 = get_diff(S,pattern1)
    count2 = get_diff(S,pattern2 )
    return min(count1,count2) 

def get_diff(S1,S2):
    count =0
    for s1,s2 in zip(S1,S2):
        if s1 != s2:
            count +=1
    return count


if __name__ == "__main__":
    S = get_input()
    ans = solve(S)
    print(ans)

Solution (Python):
def cnt(S):
  S = [s for s in S]
  count = 0

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

Solution (Python):
S = list(input())
case10 = 0
case01 = 0
if len(S) == 0:
    print(0)
    exit()

for i,val in enumerate(S):
    if i % 2 == 0:
        if val == '1':
            case01 += 1
        else:
            case10 += 1
    else:
        if val == '1':
            case10 += 1
        else:
            case01 += 1

print(min(case01,case10))

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

count = 0

for i in range(len(S)):
    try:
        if S[i] == S[i+1]:
            if S[i] == '1':
                S[i+1] = '0'
            else:
                S[i+1] = '1'
            count += 1
    except IndexError:
        pass
print(count)

Solution (Python):
S = list(input())
ideal = [str(i % 2) for i in range(len(S))]

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

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

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

first0 = 0

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


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

ans = min(first0, first1)

print(ans)

Solution (Python):
S = input()
N = len(S)
l_1 = [0 if i%2==0 else 1 for i in range(N)]
l_2 = [1 if i%2==0 else 0 for i in range(N)]

l_s = [int(i) for i in S]

a1 = 0
a2 = 0
for i in range(N):
    d = l_s[i] - l_1[i]
    if d!=0:
        a1+=1
for i in range(N):
    d = l_s[i] - l_2[i]
    if d!=0:
        a2+=1
if a1>a2:
    print(a2)
else:
    print(a1)

Solution (Python):
S = input()

count_A = 0
count_B = 0

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

Solution (Python):
s = input()
n = len(s)
ans1 = 0
ans2 = 0
for i in range(n):
    if s[i] == '0' and i % 2 == 0:
        ans1 += 1
    elif s[i] == '1' and i % 2 == 1:
        ans1 += 1
for i in range(n):
    if s[i] == '1' and i % 2 == 0:
        ans2 += 1
    elif s[i] == '0' and i % 2 == 1:
        ans2 += 1
if ans1 < ans2:
    ans2 = ans1
print(ans2)

Solution (Python):
S=list(input())
N=int(len(S))
c0=0
c1=0
for i in range(N):
  if i%2==0 and S[i]=="1":
    c1=c1+1
  elif i%2!=0 and S[i]=="0":
    c0=c0+1
ch0=N-c0-c1
ch1=N-ch0
print(ch0 if ch0<=ch1 else ch1)

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

Solution (Python):
s = input()

result1, result2 = 0, 0

for ss in range(len(s)):
  
  
  if ss % 2 - int(s[ss]) != 0:
      result1 += 1
  
  
  if abs(ss % 2 - int(s[ss])) != 1:
      result2 += 1
      
print(min(result1, result2))

Solution (Python):
S = input()
from collections import Counter as c

od,ev = [],[]
for s,i in zip(S,range(1,len(S)+1)):
    if i%2 == 0:
        ev.append(s)
    else:
        od.append(s)
odd = c(od).most_common(2)
eve = c(ev).most_common(2)
N = len(S)
N,odd,eve
if len(odd) != 2:
    odd.append(('9',0))
if len(eve) != 2:
    eve.append(('9',0))
if N == 1:
    ans = 0
elif odd[0][0] != eve[0][0]:
    ans = N-odd[0][1]-eve[0][1]
else:
    if len(odd) == len(eve) == 1:
        ans = N//2
    else:
        ans = N-max(odd[0][1]+eve[1][1],odd[1][1]+eve[0][1])
print(ans)

Solution (Python):
S = input()
count = 0
S = [c for c in S]

for i, c in enumerate(S):
    if i != 0:
        if S[i-1] == c:
            if S[i-1] == '0':
                S[i] = '1'
            else :
                S[i] = '0'
            count += 1
print(count)

Solution (Python):
S = input()
S = S+"A"
SL = [i for i in S]
top = SL[0]
ans = 0
for i in range(1,len(SL)):
    if top == SL[i]:
        ans += 1
        if SL[i] == "0":
            SL[i] = "1"
        else:
            SL[i] = "0"
        top = SL[i]
    else:
        top = SL[i]

print(ans)

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

Solution (Python):
def main():
    s = input()
    n = len(s)
    s = int(s, 2)
    p = [
        int(('10'*int(((10**5))/2))[:n], 2),
        int(('01'*int(((10**5))/2))[:n], 2),
    ]
    print(min(bin(s ^ p[0]).count('1'), bin(s ^ p[1]).count('1')))

if __name__ == '__main__':
    main()

Solution (Python):

s = input()

s0 = 0
s1 = 0
zero = False

for c in s:
    if c == '0' and zero:
        s0 += 1
    elif c == '0' and not zero:
        s1 += 1
    elif c == '1' and zero:
        s1 += 1
    else:
        s0 += 1
    zero = not zero


print(min(s0, s1))

Solution (Python):
S = list(input())
N = len(S)
A,B = '',''
if N%2 == 0:
    for i in range(N//2):
        A += '01'
        B += '10'
else:
    for i in range(N//2):
        A += '01'
        B += '10'
    A += '0'
    B += '1'

Aans,Bans = 0,0
for i in range(N):
    if S[i] != A[i]:
        Aans += 1
    if S[i] != B[i]:
        Bans += 1

print(min(Aans, Bans))

Solution (Python):
S = input()
Slen = len(S)
zo = [str(i%2) for i in range(Slen)]
zeroone = (Slen - sum([zo[i] == S[i] for i in range(len(S))]))
oz = [str((i+1)%2) for i in range(Slen)]
onezero = (Slen - sum([oz[i] == S[i] for i in range(len(S))]))
print(min(zeroone, onezero))

Solution (Python):
S = input()
count = 0

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

print(count)

Solution (Python):
s = list(str(input()))
a = [int(i) for i in s]
count1 = 0
count2 = 0
for t in range(0, len(a), 2):
	if a[t] == 0:
		count1 += 1
	else:
		count2 += 1
for u in range(1, len(a), 2):
	if a[u] == 1:
		count1 += 1
	else:
		count2 += 1
print(min(count1, count2))

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

even_zero_list = list('0' * len(S))
odd_zero_list = list('0' * len(S))
for i in range(len(S)):
    if i % 2 != 0:
        even_zero_list[i] = '1'
    else:
        odd_zero_list[i] = '1'

even_diff = 0
odd_diff = 0
for i in range(len(S)):
    if S[i] != even_zero_list[i]:
        even_diff += 1
    if S[i] != odd_zero_list[i]:
        odd_diff += 1
print(min(even_diff, odd_diff))

Solution (Python):
*s,=map(int,input());a=0
for i in range(1,len(s)):a+=s[i]==s[i-1];s[i]=1-s[i-1]
print(a)

Solution (Python):
import sys

n=0
sodd=""
seven=""
while True:
	c=sys.stdin.read(1)
	if c=="\n":
		break
	if n % 2 == 0:
		seven=seven+c
	else:
		sodd=sodd+c
	n=n+1


nflip=seven.count('1')
nflip=nflip+sodd.count('0')


nflip2=seven.count('0')
nflip2=nflip2+sodd.count('1')

print(min((nflip, nflip2)))

Solution (Python):
import numpy

tmp = [int(i) for i in list(input())]
tile = numpy.array(tmp,dtype = int)

length = tile.shape[0]

zero_st = numpy.zeros(length,dtype = int)
zero_st[1::2] = 1
one_st = numpy.zeros(length,dtype = int)
one_st[0::2] = 1

zeros = sum(tile == zero_st)
ones = sum(tile == one_st)

if zeros > ones:
    print(ones)
else:
    print(zeros)