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 = 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] == '1'):
            ans1 += 1
        else:
            ans2 += 1
print(min(ans2, ans1))

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

cnt = [0] * 2
for i in range(n):
	m = i % 2
	if s[i] == 1:
		cnt[m] = cnt[m] + 1

ans = min((n // 2 + n % 2 - cnt[0]) + cnt[1], cnt[0] + (n // 2 - cnt[1]))
print(ans)

Solution (Python):
S = input()
A = [str(i%2) for i in range(len(S))]
B = [str(1-i%2) for i in range(len(S))]
a = b = 0
for i in range(len(S)):
    if S[i] != A[i]:
        a += 1
    if S[i] != B[i]:
        b += 1

print(min(a, b))

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

Solution (Python):

S=raw_input()


s="0"
A0=0
for c in S:
    if s!=c:A0+=1
    if(s=="0"):s="1"
    else: s="0"

s="1"
A1=0
for c in S:
    if s!=c:A1+=1
    if(s=="0"):s="1"
    else: s="0"
print(min(A0,A1))

Solution (Python):
s = input()

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

ans = 0

tmp = s[0]

for i in s[1:]:
    if(tmp == i):
        ans += 1
        if(i == "0"): tmp = "1"
        else: tmp = "0"
    else:
        tmp = i

print(ans)

Solution (Python):
s = input()

ans1 = 0
ans2 = 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
  if i%2==0 and s[i]=="1":
    ans2 += 1
  if i%2==1 and s[i]=="0":
    ans2 += 1

print(min(ans1, ans2))

Solution (Python):
S = input()

form = -1
ans = 0
for s in S:
    s = int(s)
    if form == -1:
        form = s
    elif form+s == 1:
        form = s
    else:
        if s == 1:
            form = 0
        else:
            form = 1
        ans += 1
print(ans)

Solution (Python):
S = list(input())
N = len(S)
ans1, ans2 = 0, 0

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

print(min(ans1, ans2))

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

Solution (Python):
s = input()

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

print(min(n1, n2))

Solution (Python):



import sys


s = list(str(input()))
ret1 = 0
ret2 = 0

for i in range(len(s)):
  t = int(s[i])
  if i&1 == t:
    ret1 += 1
  if i&1 != t:
    ret2 += 1

print(min(ret1, ret2))

Solution (Python):
s=input()
n=len(s)
s1=""
for i in range(n//2):
  s1+="01"
if n%2>0:
  s1+="0"
ans1=0
for i in range(n):
  if s[i]!=s1[i]:
    ans1+=1
s2=""
for i in range(n//2):
  s2+="10"
if n%2>0:
  s2+="1"
ans2=0
for i in range(n):
  if s[i]!=s2[i]:
    ans2+=1
print(min(ans1,ans2))

Solution (Python):


def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  S = input()
  ans1 = 0
  ans2 = 0
  for i, c in enumerate(S):
    d = '0' if i % 2 == 0 else '1'
    d2 = '1' if i % 2 == 0 else '0'
    if c != d:
      ans1 += 1
    if c != d2:
      ans2 += 1
  print(min(ans1, ans2))

if __name__ == "__main__":
  main()

Solution (Python):



S = input()


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


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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    cnt_01 = 0
    cnt_10 = 0
    for i in range(len(S)):
        s = S[i]

        if i % 2 == 0:
            if s != '0':
                cnt_01 += 1
            else:
                cnt_10 += 1
        else:
            if s != '0':
                cnt_10 += 1
            else:
                cnt_01 += 1

    return min(cnt_01, cnt_10)


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

Solution (Python):
s=input()
st0=0
st1=1
ans0=0
ans1=0
for i in s:
    if(int(i)==st0):
        ans1+=1
    else:
        ans0+=1
    st0,st1=st1,st0
print(min(ans0,ans1))

Solution (Python):
S = input()
N = len(S)
zeroStart = 0
oneStart = 0
for i in range(N):
    if i%2 == 0:
        if S[i] == "1":
            zeroStart += 1
        else:
            oneStart += 1
    else:
        if S[i] == "1":
            oneStart += 1
        else:
            zeroStart += 1

print(min(zeroStart,oneStart))

Solution (Python):
def main():
    s = input()
    target = 0
    cost0 = 0
    cost1 = 0
    
    for c in s:
        if int(c) != target:
            cost0 += 1
        else:
            pass
        target = 0 if target == 1 else 1
    target = 1
    for c in s:
        if int(c) != target:
            cost1 += 1
        else:
            pass
        target = 0 if target == 1 else 1
    print(min(cost0, cost1))
if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
s=input()
ct1=0;ct2=0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='0':
      ct1+=1
  else:
    if s[i]=='1':
      ct1+=1
for i in range(len(s)):
  if i%2==0:
    if s[i]=='1':
      ct2+=1
  else:
    if s[i]=='0':
      ct2+=1
print(len(s)-max(ct1,ct2))

Solution (Python):
s=input()
flip='0'
a=0
for c in s:
    if c==flip:
        a+=1
    if flip=='0':
        flip='1'
    else:
        flip='0'
print(min(a,len(s)-a))

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    s = SI()

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

    return min(r, t)


print(main())

Solution (Python):
S=input()
ans0=0
ans1=0

for i in range(len(S)):
    if int(S[i])!=i%2:
        ans0+=1
    if int(S[i])!=(i+1)%2:
        ans1+=1

print(min(ans0,ans1))

Solution (Python):
s = input().strip()
p = [['0', '1'], ['1', '0']]
ans = [0, 0]
for i, v in enumerate(s):
    for j in range(2):
        ans[j] = ans[j]+1 if p[j][i % 2] == v else ans[j]
print(min(ans))

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

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

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

count1 = 0
count2 = 0

for i in range(len(s)):
  if s[i] != ideal1[i]:
    count1 += 1
  elif s[i] != ideal2[i]:
    count2 += 1

print(min(count1, count2))

Solution (Python):
s = list(input())
e = s[0::2]
o = s[1::2]
e_0 = e.count("0")
e_1 = e.count("1")
o_0 = o.count("0")
o_1 = o.count("1")
ans_a = e_1 + o_0
ans_b = e_0 + o_1
ans = min(ans_a, ans_b)
print(ans)

Solution (Python):
s=input()
p="10"*len(s)
q="01"*len(s)
r=0
t=0
for i in range(len(s)):
    if p[i]!=s[i]:
        r+=1
    if q[i]!=s[i]:
        t+=1  
print(min(r,t))

Solution (Python):
S=input()
N=len(S)
A="01"*(N//2)
A+="0" if N%2==1 else ""
B="10"*(N//2)
B+="1" if N%2==1 else ""
ansA=0
ansB=0
for i in range(N):
  if S[i]!=A[i]:
    ansA+=1
  if S[i]!=B[i]:
    ansB+=1
print(min(ansA,ansB))

Solution (Python):
s=input()
c1=c2=0
f1='0'
f2='1'
for x in s:
  if f1==x:
    pass
  else:
    c1+=1
  if f1=='0':
    f1='1'
  else:
    f1='0'
for x in s:
  if f2==x:
    pass
  else:
    c2+=1
  if f2=='0':
    f2='1'
  else:
    f2='0'
print(min(c1,c2))

Solution (Python):
S = input()

c1 = 0
cur = 0
for s in S:
  if cur != int(s):
    c1 += 1
  cur = (cur + 1) % 2

c2 = 0
cur = 1
for s in S:
  if cur != int(s):
    c2 += 1
  cur = (cur + 1) % 2
print(min(c1, c2))

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

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

Solution (Python):
s=input()
x=[i%2 for i in range(len(s))]
y=[~i%2 for i in range(len(s))]

c=0
e=0
for i in range(len(s)):
    
    if int(s[i])!=x[i]:
        c+=1
    if int(s[i])!=y[i]:
        e+=1
print(min(c,e))

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()
N=len(S)

T1=''
for i in range(N):
    if i%2==0:
        T1+='0'
    else:
        T1+='1'
T2=''
for i in range(N):
    if i%2==0:
        T2+='1'
    else:
        T2+='0'

cnt1=0
for i in range(N):
    if S[i]!=T1[i]:
        cnt1+=1
cnt2=0
for i in range(N):
    if S[i]!=T2[i]:
        cnt2+=1
print(min(cnt1, cnt2))

Solution (Python):
S = input()
p1,p2=0,0
for i,s in enumerate(S):
    if i%2==0:
        if s=="0":
            p1+=1
        else:
            p2+=1
    else:
        if s=="0":
            p2+=1
        else:
            p1+=1
print(min(p1,p2))

Solution (Python):
S = list(input())
cou_0s = 0
cou_1s = 0
i = -1

for s in S:
    i += 1
    if i % 2 == 0 and s == "0":
        cou_1s += 1
    elif i % 2 == 0:
        cou_0s += 1
    elif s == "1":
        cou_1s += 1
    else:
        cou_0s += 1

print(min(cou_0s, cou_1s))

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

S = input()
l = len(S) - 1
cnt1, cnt2 = 0, 0
for i in range(l):
    if i % 2:
        if S[i] != '0':
            cnt1 += 1
    else:
        if S[i] != '1':
            cnt1 += 1
for i in range(l):
    if i % 2:
        if S[i] != '1':
            cnt2 += 1
    else:
        if S[i] != '0':
            cnt2 += 1
print(min(cnt1, cnt2))

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

Solution (Python):
from sys import exit

S = str(input())
L = len(S)


st0 = 0
st1 = 0
pari = True
for i in range(L):
    if(S[i] == "0" and i%2 == 0):
        st1+=1
    elif(S[i] == "1" and i%2 == 0):
        st0+=1
    elif(S[i] == "0" and i%2 == 1):
        st0+=1
    elif(S[i] == "1" and i%2 == 1):
        st1+=1

print(min(st0,st1))

Solution (Python):
s = input()
count = 0
for k,i in enumerate(s):
    if k % 2 == 0:
        if i == '0':
            count += 1
    if k % 2 == 1:
        if i == '1':
            count += 1

count1 = 0
for k, i in enumerate(s):
    if k % 2 == 0:
        if i == '1':
            count1 += 1
    if k % 2 == 1:
        if i == '0':
            count1 += 1

print(min(count, count1))

Solution (Python):
import numpy as np



s = np.array([int(a) for a in input()])
n = len(s)
ans1 = np.zeros(n)
ans2 = np.zeros(n)
ans1[::2] = 1
ans2[1::2] = 1
print(min(np.sum(ans1 == s),np.sum(ans2 == s)))

Solution (Python):
S = list(input())
M = len(S)
k1 = ['0']*M
k2 = ['1']*M

for i in range(1, M, 2):
    k1[i] = '1'
    k2[i] = '0'

cnt1 = 0
cnt2 = 0

for i in range(M):
    if k1[i] != S[i]:
        cnt1 += 1
    if k2[i] != S[i]:
        cnt2 += 1

print(min(cnt1, cnt2))

Solution (Python):
S = input()
ch = '0'
ans = 0
for s in S:
	if s == ch:
		ans += 1
	if ch == '0':
		ch = '1'
	else:
		ch = '0'

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

Solution (Python):
def coloring_colorfully(S: str)->int:
    
    
    black, white = 0, 0

    for i, c in enumerate(S):
        if i % 2 == 0:
            if c == '0':
                white += 1
            else:
                black += 1
        else:
            if c == '0':
                black += 1
            else:
                white += 1

    return min(black, white)


if __name__ == "__main__":
    S = input()
    ans = coloring_colorfully(S)
    print(ans)

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

cnt0 = 0
cnt1 = 0
key = 0
for i in range(len(S)):
    if key == 1:
        if S[i] == "0":
            cnt0 += 1
        else:
            cnt1 += 1
        key = 0
    else:
        if S[i] == "1":
            cnt0 += 1
        else:
            cnt1 += 1
        key = 1

print(min(cnt0, cnt1))

Solution (Python):
S = input()
N = len(S)
now = S[0]

a = 0
b = 0
for i in range(1,N):
    if S[i] == now:
        a += 1
        now = str((int(now)+1)%2)
    else:
        now = S[i]

for i in reversed(range(N)):
    if S[i] == now:
        b += 1
        now = str((int(now)+1)%2)
    else:
        now = S[i]
print(min(a,b))

Solution (Python):
S = input()


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


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

print(min(bw,wb))

Solution (Python):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



S = li()
N = len(S)
bw = []
for i in range(N):
    if i % 2 == 0:
        bw.append(1)
    else:
        bw.append(0)


cnt = 0
for i in range(N):
    if S[i] != str(bw[i]):
        cnt += 1


if cnt >= N // 2 + 1:
    print(N - cnt)
else:
    print(cnt)

Solution (Python):
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

S = input()
S = list(S)
def ans():
    ans =0

    for i in range(1,len(S)):
        if S[i-1]==S[i]:
            ans+=1
            S[i] = "1" if S[i]=="0" else "0"
    return ans

print(ans())

Solution (Python):
def main():
    s = input()
    n = len(s)
    a = 0
    b = 0
    for i in range(n):
        if i & 1:
            if s[i] == '1':
                a += 1
            else:
                b += 1
        else:
            if s[i] == '1':
                b += 1
            else:
                a += 1
    print(min(a, b))
    return 0
main()

Solution (Python):
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

s = raw_input()
cnt1 = 0
cnt2 = 0
l1 = []
l2 = []
for i in xrange(len(s)):
	if i%2 == 0:
		l1.append('1')
		l2.append('0')
	else:
		l1.append('0')
		l2.append('1')
for i in xrange(len(s)):
	if l1[i] != s[i]:
		cnt1 += 1
	if l2[i] != s[i]:
		cnt2 += 1
print min(cnt1, cnt2)

Solution (Python):
s = str(input())
w1,w2,b1,b2 = 0,0,0,0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      w1 += 1
    else:
      b1 += 1
  else:
    if s[i] == "0":
      w2 += 1
    else:
      b2 += 1
print(min(w1+b2,w2+b1))

Solution (Python):
ans = [0, 0]

S = input()

colorA = ['0', '1']
colorB = ['1', '0']
idx = 0

for s in S:
    if colorA[idx] != s:
        ans[0] += 1
    if colorB[idx] != s:
        ans[1] += 1
    idx = (idx+1) % 2

print(min(ans))

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

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

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

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

Solution (Python):

def main():
    n = input()
    
    n1 = ""
    n2 = ""
    for i in range(len(n)):
        if i % 2 == 0:
            n1 += n[i]
        else:
            n2 += n[i]

    a0 = n1.count("0")
    a1 = n1.count("1")
    b0 = n2.count("0")
    b1 = n2.count("1")

    print(min ( a1 + b0, a0 + b1))
main()

Solution (Python):
s = input()

counter1 = 0
counter2 = 0
for i in range(len(s)):
    if i % 2 == 1 and s[i] != '0':
        counter1 += 1
    if i % 2 == 0 and s[i] != '1':
        counter1 += 1
    if i % 2 == 1 and s[i] != '1':
        counter2 += 1
    if i % 2 == 0 and s[i] != '0':
        counter2 += 1
print(min([counter1, counter2]))

Solution (Python):
S = input()
ans1 = 0
ans2 = 0
for i, c in enumerate(S):
  if str(i % 2) == c:
    ans1 += 1
  else:
    ans2 += 1
print(min(ans1, ans2))

Solution (Python):
S = raw_input()
ans = 999999
for i in range(2):
  c = 0
  for j in range(len(S)):
    if S[j]!="01"[(i+j)%2]:
      c += 1
  ans = min(ans, c)
print ans

Solution (Python):
S = input()

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

print(min(ans1, ans2))

Solution (Python):
s = input()

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

print(min([a,b]))

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

Solution (Python):
S = input()
L1 = "".join(["1" if i % 2 == 0 else "0" for i in range(len(S))])
L2 = "".join(["0" if i % 2 == 0 else "1" for i in range(len(S))])
num1 = sum([1 if s != l else 0 for s, l in zip(S, L1)])
num2 = sum([1 if s != l else 0 for s, l in zip(S, L2)])
print(min(num1, num2))

Solution (Python):
s=str(input())
if len(s)%2==0:
  char1='01'*(int(len(s)/2))
  char2='10'*(int(len(s)/2))
else:
  char1='01'*(int(len(s)/2))+'0'
  char2='10'*(int(len(s)/2))+'1'
count1=0
count2=0
for i in range(len(s)):
  if char1[i]!=s[i]:
    count1+=1
  if char2[i]!=s[i]:
    count2+=1
print(min(count1,count2))

Solution (Python):
a = list(input())
su = 0
ko = 0
p = 0

for i in range(len(a)):
    if i % 2 == 0:
        if a[i] != "0":
            su += 1
    else:
        if a[i] != "1":
            su += 1

for i in range(len(a)):
    if i % 2 == 0:
        if a[i] != "1":
            ko += 1
    else:
        if a[i] != "0":
            ko += 1

print(min(su,ko))

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

Solution (Python):
s = input()

ans = float('inf')
for init in '01':
    t = 0
    x = init
    for ss in s:
        
        if ss != x:
            t += 1
        if x == '0':
            x = '1'
        else:
            x = '0'
    ans = min(ans, t)
print(ans)

Solution (Python):


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

pat0 = []
pat1 = []
for i in range(len(s)):
    if i % 2 == 0:
        pat0.append(0)
        pat1.append(1)
    else:
        pat0.append(1)
        pat1.append(0)

cnt0 = 0
cnt1 = 0
for i in range(len(s)):
    if s[i] != pat0[i]:
        cnt0 += 1
    else:
        cnt1 += 1

print(min(cnt0,cnt1))

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

answ, ansb = 0, 0
prevw, prevb = '1', '0'
for _s in s:
  if prevw == '1':
    if _s == '1':
      answ += 1
    prevw = '0'
  elif prevw == '0':
    if _s == '0':
      answ += 1
    prevw = '1'
  if prevb == '1':
    if _s == '1':
      ansb += 1
    prevb = '0'
  elif prevb == '0':
    if _s == '0':
      ansb += 1
    prevb = '1'

print(min(answ, ansb))

Solution (Python):

import sys

def count(s, t):
    ret = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ret += 1
    return ret


def solve(S: int):
    t1 = []
    t2 = []
    for i in range(len(S)):
        t1.append(str(i % 2))
        t2.append(str((i + 1) % 2))
    t1 = ''.join(t1)
    t2 = ''.join(t2)
    ret = min(count(S, t1), count(S, t2))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):

def kakaka():
    a = list(map(int, input().split()))
    b = map(int, input().split())
    c = int(input())

def start_process():
    return
def main():
    a = list(input())
    data = a[0]
    count = 0
    dic = {'0': '1', '1':'0'
           }
    for i in range(1, len(a)):
        if a[i] == data:
            count += 1
        data = dic[data]
    print(count)





if __name__ == '__main__':
    main()

Solution (Python):
S = input()

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

print(min(n-count, count))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    if a < b:
        a, b = b, a
    ans = a
    a -= 1
    ans += max(a, b)
    print(ans)
    return


def B():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    ans = 0
    for i in range(n):
        dp[i] = max(dp[i - 1], h[i])
        if dp[i - 1] <= h[i]:
            ans += 1
    print(ans)
    return


def C():
    s = S()
    ans = 0
    for num, i in enumerate(s):
        if num % 2:
            if i == "0":
                ans += 1
        else:
            if i == "1":
                ans += 1
    ansb = 0
    for num, i in enumerate(s):
        if not num % 2:
            if i == "0":
                ansb += 1
        else:
            if i == "1":
                ansb += 1
    print(min(ans, ansb))
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

Solution (Python):
s = input()
s1 = [i % 2 for i in range(len(s))]
s2 = [(i + 1) % 2 for i in range(len(s))]
c1 = 0
c2 = 0

for i in range(len(s)):
    if int(s[i]) != s1[i]:
        c1 += 1
    else:
        c2 += 1

print(min(c1, c2))

Solution (Python):
s = input()
v = 1
c = 0
cc = 0
for i in s:
    if i == '0' and v == -1:
        c+=1
    if i == '1' and v == 1:
        c+=1
    v*=-1

v = -1
for i in s:
    if i == '0' and v == -1:
        cc+=1
    if i == '1' and v == 1:
        cc+=1
    v*=-1
print(min(c,cc))

Solution (Python):
Ss = input()

ans1 = 0
for i, S in enumerate(Ss):
    if S != '01'[i%2]:
        ans1 += 1

ans2 = 0
for i, S in enumerate(Ss):
    if S != '10'[i%2]:
        ans2 += 1

print(min(ans1, ans2))

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

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

print(min(e,o))

Solution (Python):
S = input()

count_0101 = 0
count_1010 = 0

for i, s in enumerate(S):
	if i & 1:
		if '1' == s:
			count_1010 += 1
		else:
			count_0101 += 1
	else:
		if '1' == s:
			count_0101 += 1
		else:
			count_1010 += 1

print(min(count_0101, count_1010))

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

Solution (Python):


import itertools
from collections import Counter
import bisect

def main():
    S = list(input())

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

    print(min(even_black, even_white))


if __name__ == '__main__':
    main()

Solution (Python):
S = input()

n = len(S)

start_0 = ""
start_1 = ""

for i in range(n):
    if i % 2 == 0:
        start_0 += "0"
        start_1 += "1"
    else:
        start_0 += "1"
        start_1 += "0"

ans_0 = 0
ans_1 = 0

for i in range(n):
    t1 = start_0[i]
    t2 = start_1[i]
    s = S[i]
    if t1 != s:
        ans_0 += 1
    if t2 != s:
        ans_1 += 1

print(min(ans_1, ans_0))

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

Solution (Python):
S=input()

a1=('01'*len(S))[:len(S)]
a2=('10'*len(S))[:len(S)]

answer1 = 0
for s, a in zip(S,a1):
  if s!=a:
    answer1 +=1
  
answer2 = 0
for s, a in zip(S,a2):
  if s!=a:
    answer2 +=1
    
print(min(answer1,answer2))

Solution (Python):
String = input();

num0_odd = 0;
num1_odd = 0;
num0_even = 0;
num1_even = 0;

odd_check=1;
num_of_tile=0;

for i in String:
    num_of_tile+=1;
    if(odd_check==0):
        if(i=="0"):
            num0_odd+=1;
        else:
            num1_odd+=1;
    else:
        if(i=="0"):
            num0_even+=1;
        else:
            num1_even+=1;

    odd_check+=1;
    if(odd_check==2):
        odd_check=0;

answer = max(num0_odd+num1_even, num0_even+num1_odd);
print(num_of_tile - answer);

Solution (Python):
listS=list(input())
odd1=0
odd0=0
even1=0
even0=0
index=0
while index < len(listS):
    if index%2==0:
        if listS[index]=="1":
            even1+=1
        else:
            even0+=1
    else:
        if listS[index] == "1":
            odd1 += 1
        else:
            odd0 += 1
    index+=1

print(min(even0+odd1, even1+odd0))

Solution (Python):
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

cnt = 0
for i in range(N):
    if i%2==0:
        if s[i]=="0":
            cnt += 1
    else:
        if s[i]=="1":
            cnt += 1
print(min(cnt,N-cnt))

Solution (Python):
S = input()

x = y = 0
for i,c in enumerate(S):
    if i%2:
        a,b = 0,1
    else:
        a,b = 1,0
    if int(c) == a:
        x += 1
    if int(c) == b:
        y += 1
print(min(x,y))

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

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

print(min(ans1, ans2))

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

Solution (Python):
x=input()

ans1,ans2=0,0

for n,i in enumerate(x):
    if n%2==0: gg='0'
    else: gg='1'
    if i!=gg: ans1+=1

for n,i in enumerate(x):
    if n%2==1: gg='0'
    else: gg='1'
    if i!=gg: ans2+=1

print(min(ans1,ans2))

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

start = '0'
ans = 0
for idx, c in enumerate(s):
    if idx % 2 == 0 and c != start:
        ans += 1
    elif idx % 2 != 0 and c == start:
        ans += 1

start = '1'
ans1 = 0
for idx, c in enumerate(s):
    if idx % 2 == 0 and c != start:
        ans1 += 1
    elif idx % 2 != 0 and c == start:
        ans1 += 1
    
print(min(ans, ans1))

Solution (Python):
s = input()
n = len(s)
ev = ('01' * n)[:n]
od = ('10' * n)[:n]
ans = [0, 0]
for si, a, b in zip(s, ev, od):
    if si != a:
        ans[0] += 1
    elif si != b:
        ans[1] += 1
print(min(ans))

Solution (Python):
S = input()

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


tmp_ans1 = 0
for s, p in zip(S, p1):
    if s != p:
        tmp_ans1 += 1

tmp_ans2 = 0
for s, p in zip(S, p2):
    if s != p:
        tmp_ans2 += 1

print(min(tmp_ans1, tmp_ans2))

Solution (Python):
S=input()


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


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

print(min(c,d))

Solution (Python):

S=str(input())
Slist=list(S)
Slen=len(Slist)
count=0
for i in range(Slen-1):
    if Slist[i] == Slist[i+1]:
        if Slist[i+1] == "0":
            Slist[i+1] = "1"
        else:
            Slist[i+1] = "0"
        count+=1
print(count)