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



Sample input:
000


Sample output:
1

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    mudancas=0;
    s=list(s)
    if(len(s)==1):
        print("0")
        return;
    for i in range(1, len(s)-1):
        if(s[i]==s[i-1]):
            mudancas+=1
            if(s[i]=='0'):
                s[i]='1'
            else:
                s[i]='0'
    print(mudancas)
    
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==0:
      s+=1
  else:
    if S[i]==1:
      s+=1
for j in range(len(S)):
  if j%2==0:
    if S[j]==1:
      t+=1
  else:
    if S[j]==0:
      t+=1
print(min(s,t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = str(input())
S = [int(s[i]) for i in range(len(s))]
a = []
b = []
counta = 0
countb = 0
for i in range(len(S)):
    if i == 0 or i%2==0:
        a.append(0)
        b.append(1)
    else:
        a.append(1)
        b.append(0)
print(a)
print(b)
for i in range(len(S)):
    if S[i] != a[i]:
        counta += 1
    elif S[i] != b[i]:
        countb += 1
print(min(counta,countb))

Submission status: Wrong Answer

Solution code:
N=list(input())

counter=0

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

print(pre)
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n-2):
    a = color[i]
    b = color[i+1]
    c = color[i+2]
    if a==b==c:
        color[i+1] = (b+1)%2
        ans += 1
    elif a==b and a!=c:
        color[i] = (a+1)%2
        ans += 1
    elif a!=b and b==c:
        color[i+2] = (c+1)%2
        ans += 1
    else:
        continue
if n==2 and color[0]==color[1]:
    print(1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
color = [int(i) for i in input()]
n = len(color)
ans = 0
for i in range(n-2):
    a = color[i]
    b = color[i+1]
    c = color[i+2]
    if a==b==c:
        color[i+1] = (b+1)%2
        ans += 1
    elif a==b and a!=c:
        color[i] = (a+1)%2
        ans += 1
    elif a!=b and b==c:
        color[i+2] = (c+1)%2
        ans += 1
    else:
        continue
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
S = str(input())
S_ = Counter(S)
v,c =zip(*S_.most_common())
ans = 0
if len(c) == 1 and len(S) == 1:
  ans = 0
elif len(c) == 1 and len(S) > 1:
  ans = c[0]//2
elif len(c) > 1 and abs(c[1]-c[0]) == 1:
  ans = 0
elif len(c) > 1 and abs(c[1]-c[0]) != 1:
  ans = abs(c[1] - c[0])//2
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
S = str(input())
S_ = Counter(S)
v,c =zip(*S_.most_common())
ans = 0
if len(c) == 1 and len(S) == 1:
  ans = 0
elif len(c) == 1 and len(S) > 1:
  ans = c[0]//2
elif len(c) > 1 and abs(c[1]-c[0]) == 1:
  ans = 0
elif len(c) > 1 and abs(c[1]-c[0]) != 1:
  ans = abs(c[1] - c[0])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
S = str(input())
S_ = Counter(S)
v,c =zip(*S_.most_common())
ans = 0
if len(c) == 1 and len(S) == 1:
  ans = 0
elif len(c) == 1 and len(S) > 1:
  ans = c[0]//2
elif len(c) > 1:
  ans = abs(c[1] - c[0] + 1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = list(input())

def rev(tile: str):
    if tile == "0":
        return "1"
    else:
        return "0"

temp1 = 0
S_ = S[::-1]
if S_[0] == "1":
    temp1 += 1
    S_[0] = "0"
for i in range(1, len(S_)):
    if S_[i] == S_[i-1]:
        S_[i] = rev(S_[i])
        temp1 += 1

temp2 = 0
if S[0] == "0":
    temp2 += 1
    S[0] = "1"
for i in range(1, len(S)):
    if S[i] == S[i-1]:
        S[i] = rev(S[i])
        temp2 += 1
print(min(temp1, temp2))

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
w = 0
for i in range(n):
  w += (s[i]!="0")**(i%2)
print(min(w,n-w))

Submission status: Wrong Answer

Solution code:
#124
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(len(n)//2)
    exit()
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else check(n,"10")+1)

Submission status: Wrong Answer

Solution code:
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(len(n)//2)
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else check(n,"10")+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
    
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else check(n,"10")+1)

Submission status: Wrong Answer

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

def change():
    global kk
    if kk == "1":
        kk = "0"
    else:
        kk = "1"

# case 1
count_1 = 0
kk = "1"
for c in range(L):
    print(kk)
    if kk == S[c]:
        pass
    else:
        count_1 += 1
    change()
    

# case 2
count_2 = 0
kk = "0"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)

Submission status: Wrong Answer

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

def change():
    global moji
    if moji == "1":
        moij = "0"
    else:
        moji = "1"

# case 1
count_1 = 0
moji = "1"
for c in range(L):
    if moji == S[c]:
        pass
    else:
        count_1 += 1
    change()

# case 2
count_2 = 0
moji = "0"
for c in range(L):
    if moji == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)

Submission status: Wrong Answer

Solution code:
S = input()
 
n = len(S)
cnt = 0
 
for i in range(n):
  if int(S[i])%2 == i%2:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
ans=0
for i in range(n-1):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n-1):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))

Submission status: Wrong Answer

Solution code:
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0:
    if S[i]!=0:
      s+=1
    else:
      s=s
  if i%2==1:
    if S[i]!=1:
      s+=1
    else:
      s=s
for i in range(len(S)):
  if i%2==0:
    if S[i]!=1:
      t+=1
    else:
      t=t
  if i%2==1:
    if S[i]!=0:
      t+=1
    else:
      t=t
print(min(s,t))

Submission status: Wrong Answer

Solution code:
S=input()
S=list(S)
s=0
for i in range(len(S)-2):
  if S[i]==S[i+1]==S[i+2]==0:
    s+=1
    S[i+1]=1
  elif S[i]==S[i+1]==S[i+2]==1:
    s+=1
    S[i+1]=0
  elif S[i]==S[i+1] and S[i+1]!=S[i+2]:
    s+=1
    S[i]=S[i+2]
  elif S[i]!=S[i+1] and S[i+1]==S[i+2]:
    s+=1
    S[i+2]=S[i]
  else:
    s=s
print(s)

Submission status: Wrong Answer

Solution code:
import sys
S = "10010010"
S_list = list(S)

l = len(S)


if len(S) % 2 == 0:
  ideal1 = list('01' * int(l / 2))
  ideal2 = list('10' * int(l / 2))
else:
  ideal1 = list('01' * (l // 2) + '0')
  ideal2 = list('10' * (l // 2) + '1')

ans = 0
ans1 = 0

for base,compe1 in zip(S_list,ideal1):
    if base != compe1:
        ans = ans + 1

for base,compe2 in zip(S_list,ideal2):
    if base != compe2:
        ans1 = ans1 + 1

print(min(ans,ans1))

Submission status: Wrong Answer

Solution code:
import sys
S = input()
S_list = list(S)




ans = 0 

for i in range(0,(len(S)-2),2):
    if S[i] == S[i+2] and S[i] != S[i+1]:
        pass
    else:
        ans = ans + 1
        if S[i+2] == "1":
            S_list[i+2] ="0"
        else:
            S_list[i+2] = "1"

        if S[i] != S[i+1] and S[i+2] != S[i+1]:
            pass
        else:
            if S_list[i+1] == "1":
                S_list[i+1] == "0"
            else:
                S_list[i+1] == "1"




print(ans)

Submission status: Wrong Answer

Solution code:
S=list(input())
cnt=0
tmp=S[0]
for i in range(len(S)):
    if i == 0:continue
    if S[i] == tmp:
        cnt += 1
    tmp = S[i]        
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
if len(s) == 1:
    print(0)
    quit()
c = 0
for i in range(len(s) - 1):
    if s[i] == '0' and s[i + 1] == '0':
        s = s[:i + 1] + '1' + s[i:]
        c += 1
    elif s[i] == '1' and s[i + 1] == '1':
        s = s[:i + 1] + '0' + s[i:]
        c += 1
print(c)

Submission status: Wrong Answer

Solution code:
s = input()
if len(s) == 1:
    print(0)
    quit()
c = 0
for i in range(1, len(s) - 1):
    if s[i] == '0' and s[i - 1] == '0':
        s = s[:i] + '1' + s[i + 1:]
        c += 1
    elif s[i] == '1' and s[i - 1] == '1':
        s = s[:i] + '0' + s[i + 1:]
        c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import sys

inputs = [row.split() for row in sys.stdin.readlines()]
cards = list(inputs[0][0])

def reverse_card(card):
    if card == "0":
        return "1"
    else:
        return "0"

reverse_count = 0
counting_index = 1

while True:
    # print(cards)
    card_length = len(cards)
    if card_length-1 <= counting_index:
        break

    before_card = cards[counting_index-1]
    current_card = cards[counting_index]
    after_card = cards[counting_index+1]
    
    if current_card == before_card:
        cards[counting_index] = reverse_card(cards[counting_index])        
        current_card = cards[counting_index]
    if current_card == after_card:
        cards[counting_index+1] = reverse_card(cards[counting_index+1])
        reverse_count+=1
    counting_index += 1
print(reverse_count)

Submission status: Wrong Answer

Solution code:
S = list(input())

res = 0

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

Submission status: Wrong Answer

Solution code:
s = list(input())
s2 = s.copy()
if s2[0] == '1':
    s2[0] = '0'
else:
    s2[0] = '1'
s_cnt, s2_cnt = 0, 0
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        s_cnt += 1
        if s[i-1] == '1':
            s[i] = '0'
        else:
            s[i] = '1'
    if s2[i] == s2[i-1]:
        s2_cnt += 1
        if s2[i-1] == '1':
            s2[i] = '0'
        else:
            s2[i] = '1'
print(min(s_cnt, s2_cnt))

Submission status: Wrong Answer

Solution code:
import copy
s = list(input())
c = copy.copy(s)
n = len(s)
cnt1 = cnt2 = 0
for i in range(n-1):
    if c[i+1]==c[i]:
        cnt1 += 1
        c[i+1] = '0' if c[i+1]=='1' else '1'
s[0] = '0' if s[0]=='1' else '1'
for i in range(1,n):
    if s[i-1]==s[i]:
        cnt2 += 1
        s[i] = '0' if s[i]=='1' else '1'
print(min(cnt1,cnt2))

Submission status: Wrong Answer

Solution code:
S = input()
odd = S[1::2]
even = S[::2]
print(min(odd.count("1") + even.count("0"), even.count("0") + odd.count("1")))

Submission status: Wrong Answer

Solution code:
S = list(str(input()))
if S[0] == "1":
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "0":
            S[i] = "1"
        elif i % 2 == 1 and j == "1":
            S[i] = "0"
else:
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "1":
            S[i] = "0"
        elif i % 2 == 1 and j == "0":
            S[i] = "1"
print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
d = int(S[0])
T = []
U = []
for i in range(len(S)):
  T.append(d)
  d = (d + 1) % 2
  U.append(d)
count1 = 0
count2 = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count1 += 1
  if S[i] != U[i]:
    count2 += 1
print(min(count1, count2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = list(input())
a=0
b=0
if S[0]=="0":
    for i in S[::2]:
        print(i)
        if i=="1":
            a+=1
    for k in S[1::2]:
        if k=="0":
            a+=1

if S[0]=="1":
    for i in S[::2]:
        if i=="0":
            b+=1
    for k in S[1::2]:
        if k=="1":
            b+=1
print(max(a,b))

Submission status: Wrong Answer

Solution code:
s = list(input())

len_s = len(s)
change_cnt = 0
i = 1
while len_s > 2:
    left = s[i-1]
    right = s[i+1]
    if s[i] == left and s[i] == right:
        # 左右両方同じ
        # 000
        change_cnt += 1
        if s[i] == '0':
            s[i] = '1'
        else:
            s[i] = '0'
    elif s[i] == left:
        # 左だけ同じ
        # 110
        change_cnt += 1
        if s[i-1] == '0':
            s[i-1] = '1'
        else:
            s[i-1] = '0'
    elif s[i] == right:
        # 右だけ同じ
        # 011
        change_cnt += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
    i += 1
    if i == len_s-1:
        break

if len_s > 2:
    print(change_cnt)
elif len_s == 2:
    if len(set(s)) == 1:
        print(1)
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
s = list(input())

len_s = len(s)
change_cnt = 0
i = 1
while len_s > 2:
    left = s[i-1]
    right = s[i+1]
    if s[i] == left and s[i] == right:
        # 左右両方同じ
        # 000
        change_cnt += 1
        if s[i] == '0':
            s[i] = '1'
        else:
            s[i] = '0'
    elif s[i] == left:
        # 左だけ同じ
        # 110
        change_cnt += 1
        if s[i-1] == '0':
            s[i-1] = '1'
        else:
            s[i-1] = '0'
    elif s[i] == right:
        # 右だけ同じ
        # 011
        change_cnt += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
    i += 1
    if i == len_s-1:
        break

if len_s > 2:
    print(''.join(s))
    print(change_cnt)
elif len_s == 2:
    if len(set(s)) == 1:
        print(1)
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
S = list(input())
n = len(S)

s1 = 0
s2 = 0

for i in range(n):
    if i%2 == 0:
        if S[i] == '1':
            s1 += 1
        else:
            s2 += 1
    else:
        if S[i] == '0':
            s2 += 1
        else:
            s1 += 1
print(min(s1, s2))

Submission status: Wrong Answer

Solution code:
S = list(input())
n = len(S)

s1 = 0
s2 = 0

for i, j in enumerate(S):
    if i%2 == 0:
        if j == '1':
            s1 += 1
        else:
            s2 += 1
    else:
        if j == '0':
            s2 += 1
        else:
            s1 += 1
print(min(s1, s2))

Submission status: Wrong Answer

Solution code:
a = input()
x = 0
y = 0
for t in range(0,len(a)):
    if t%2 == 0 and a[t] == "1":
        x = x+1
    if a[t] == "0" and t%2 == 0:
        x = x+1
        
for t in range(0,len(a)):
    if t%2 == 0 and a[t] == "0":
        y = y+1
    if  t%2 == 1 and a[t] == "1":
        y= y+1
        
print (min(y,x))

Submission status: Wrong Answer

Solution code:
s=list(input())
bw=0 #0101との差異
for i in range(len(s)):
	if (i%2==0 and s[i]==1) or (i%2==1 and s[i]==0):
		bw+=1
wb=0
for i in range(len(s)):
	if (i%2==0 and s[i]==0) or (i%2==1 and s[i]==1):
		wb+=1
print(min(bw,wb))

Submission status: Wrong Answer

Solution code:
s=list(input())
t=[s[0]]
count=0
for i in range(1,len(s)):
	if s[i]==t[i-1]:
		if s[i]==0:
			t.append(1)
		else:
			t.append(0)
		count+=1
	else:
		t.append(s[i])
print(count)

Submission status: Wrong Answer

Solution code:
s = input()

n = len(s)
p = s[::2].count("1") + s[1::2].count("0")

ans = min(n-p, n)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans10 = 10**12
ans01 = 10**12
for i in range(len(s)):
  if i%2==0:
    if s[i]=="0":
      ans10+=1
    if s[i]=="1":
      ans01+=1
  if i%2==1:
    if s[i]=="1":
      ans10+=1
    if s[i]=="0":
      ans01+=1
print(min(ans10,ans01))

Submission status: Wrong Answer

Solution code:
l=list(str(input()))
l=[int(i) for i in l]
cnt=0
for i in range(len(l)-1):
  if(l[i]==l[i+1]):
    cnt+=1
    if(l[i]==0):
      l[i+1]=1
    elif(l[i]==1):
      l[i+1]=0
print(l,cnt)

Submission status: Wrong Answer

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

counter_bw = 0
counter_wb = 0

if n % 2 == 0:
  bw = "01" * (n // 2)
  wb = "10" * (n // 2)
else:
  bw = "01" * (n // 2) + "b"
  wb = "10" * (n // 2) + "w"

for i in range(n):
  if s[i] == bw[i]:
    counter_bw += 1
  if s[i] == wb[i]:
    counter_wb += 1

print(min(counter_bw, counter_wb))

Submission status: Wrong Answer

Solution code:
import copy
import sys
S = list(input())
SS = copy.deepcopy(S)
s = 0
ss = 0
if len(S) == 1:
    print(0)
    sys.exit()

for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i] = '1'
        s += 1
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                s += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                s += 1
        break
    elif S[i] == S[i+1] == '1':
        S[i] = '0'
        s += 1
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                s += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                s += 1
        break

S = SS
for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i+1] = '1'
        ss += 1
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                ss += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                ss += 1
        break
    elif S[i] == S[i+1] == '1':
        S[i+1] = '0'
        ss += 1
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                ss += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                ss += 1
        break

print(min(s,ss))

Submission status: Wrong Answer

Solution code:
import copy
import sys
S = list(input())
SS = copy.deepcopy(S)
s = 1
ss = 1
if len(S) == 1:
    print(0)
    sys.exit()

for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i] = '1'
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                s += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                s += 1
        break
    elif S[i] == S[i+1] == '1':
        S[i] = '0'
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                s += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                s += 1
        break

S = SS
for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i+1] = '1'
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                ss += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                ss += 1
        break
    elif S[i] == S[i+1] == '1':
        S[i+1] = '0'
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                ss += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                ss += 1
        break

print(min(s,ss))

Submission status: Wrong Answer

Solution code:
S = input()
ans_0 = 0
ans_1 = 0
check = "0"
for i in S:
    if i == check:
        ans_1 += 1
    else:
        ans_0 += 1
    
    if check == "0":
        check = "1"
    else:
        check == "0"
print(min(ans_0,ans_1))

Submission status: Wrong Answer

Solution code:
S = input()
previous_num = int(S[0])
previous_idx = 0
same_flag = False
same_count = 1
even_count = 0
separate_list = []
start_idx = 1

for i in range(1,len(S)):
    if previous_num != int(S[i]):
        start_idx = i
        even_count += same_count//2
        same_count = 0
        break
    else:
        same_count +=1
    if i +1 == len(S):
        print(same_count//2)
        exit(0)

for i in range(start_idx,len(S)):
    if same_flag and previous_num == int(S[i]):
        same_count +=1
        continue
    if same_flag and previous_num != int(S[i]):
        same_flag = False
        previous_num = int(S[i])
        if same_count%2 == 1:
            even_count += same_count//2
        else:
            separate_list.append(S[previous_idx:i - same_count//2])
            previous_idx = i - same_count//2
        same_count = 0
        continue
    if previous_num != int(S[i]):
        previous_num = int(S[i])
    else:
        same_flag = True
        same_count = 2
separate_list.append(S[previous_idx:len(S)])
if same_flag:
    even_count += same_count//2
#print(separate_list)
even = 0
odd = 0
if len(separate_list) == 1:
    print(even_count)
    exit(0)
for i in range(len(separate_list)):
    if i%2 == 0:
        odd += len(separate_list[i])
    else:
        even += len(separate_list[i])
print(even_count + min(even,odd))

Submission status: Wrong Answer

Solution code:
S = input()
previous_num = int(S[0])
previous_idx = 0
same_flag = False
same_count = 1
even_count = 0
separate_list = []
start_idx = 1

for i in range(1,len(S)):
    if previous_num != int(S[i]):
        start_idx = i
        even_count += same_count//2
        same_count = 0
        break
    else:
        same_count +=1
    if i +1 == len(S):
        print(same_count//2)
        exit(0)

for i in range(start_idx,len(S)):
    if same_flag and previous_num == int(S[i]):
        same_count +=1
        continue
    if same_flag and previous_num != int(S[i]):
        same_flag = False
        previous_num = int(S[i])
        if same_count%2 == 1:
            even_count += same_count//2
        else:
            separate_list.append(S[previous_idx:i - same_count//2])
            previous_idx = i - same_count//2
        same_count = 0
        continue
    if previous_num != int(S[i]):
        previous_num = int(S[i])
    else:
        same_flag = True
        same_count = 2
separate_list.append(S[previous_idx:len(S)])
if same_flag:
    same_count += same_count//2
#print(separate_list)
even = 0
odd = 0
if len(separate_list) == 1:
    print(even_count)
    exit(0)
for i in range(len(separate_list)):
    if i%2 == 0:
        odd += len(separate_list[i])
    else:
        even += len(separate_list[i])
print(even_count + min(even,odd))

Submission status: Wrong Answer

Solution code:
S=list(map(int,list(input())))
even=S[0::2]
odd=S[1::2]

sum_even=sum(even)
sum_odd=sum(odd)
len_even=int(len(S)//2)
len_odd=int(len(S)//2)+1

if sum_odd<sum_even:
  ans=len_even-sum_even+sum_odd
elif sum_odd>sum_even:
  ans=len_odd-sum_odd+sum_even
else:
  ans=len_even-sum_even

print(ans)

Submission status: Wrong Answer

Solution code:
S=list(map(int,list(input())))
even=S[0::2]
odd=S[1::2]

sum_even=sum(even)
sum_odd=sum(odd)

if len(S)%2:	#odd
  if sum_odd<=sum_even:
    ans=int(len(S)//2)-sum_even+sum_odd
  else:
    ans=int(len(S)//2)+1-sum_odd+sum_even
else:	#even
  if sum_odd<=sum_even:
    ans=int(len(S)//2)-sum_even+sum_odd
  else:
    ans=int(len(S)//2)-sum_odd+sum_even
print(ans)

Submission status: Wrong Answer

Solution code:
S=list(map(int,list(input())))
even=S[0::2]
odd=S[1::2]

sum_even=sum(even)
sum_odd=sum(odd)

if sum_odd<=sum_even:
  ans=int(len(S)//2)-sum_even+sum_odd
else:
  ans=int(len(S)//2)+1-sum_odd+sum_even
print(ans)

Submission status: Wrong Answer

Solution code:
s = input().strip()
odd_black_cnt = 0
odd_white_cnt = 0
even_black_cnt = 0
even_white_cnt = 0
len_s = len(s)

for i in range(0, len_s, 2):
    if (s[i] == "0"):
        odd_black_cnt += 1
    else:
        odd_white_cnt += 1

for i in range(1, len_s, 2):
    if (s[i] == "0"):
        even_black_cnt += 1
    else:
        even_white_cnt += 1

# odd_white, even_black
odd_diff = (odd_black_cnt - odd_white_cnt)
even_diff = (even_black_cnt - even_white_cnt)

if (0 <= odd_diff and 0 <= even_diff):
    if (odd_diff <= even_diff):
        # odd: white, even: black
        print(odd_black_cnt + even_white_cnt)
    else:
        # odd: black, even: white
        print(odd_white_cnt + even_black_cnt)
elif (odd_diff < 0 and 0 <= even_diff):
    # odd: white, even: black
    print(even_white_cnt + odd_black_cnt)
elif (0 <= odd_diff and even_diff < 0):
    # odd: black, even: white
    print(odd_white_cnt + even_black_cnt)
else:
    if (odd_diff <= even_diff):
        # odd: black, even: white
        print(odd_white_cnt + even_black_cnt)
    else:
        # odd: white, even: black
        print(odd_black_cnt + even_white_cnt)

Submission status: Wrong Answer

Solution code:
n=input()
cnt=0
for i in range(len(n)):
    if n[0]=="0":
        if i%2==0 and n[i]=="1" :
            cnt+=1
        if i&2==1 and n[i]=="0" :
            cnt+=1
    else:
        if i%2==0 and n[i]=="0" :
            cnt+=1
        if i%2==1 and n[i]=="1" :
            cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=input()
cnt=0
for i in range(len(n)):
    if n[0]==0:
        if i%2==0 and n[i]!=0 :
            cnt+=1
        if i&2==1 and n[i]!=1 :
            cnt+=1
    else:
        if i%2==0 and n[i]!=1 :
            cnt+=1
        if i&2==1 and n[i]!=0 :
            cnt+=1
print(cnt-1)

Submission status: Wrong Answer

Solution code:
s = str(input())

test0 = [x%2 for x in range(len(s))]
test1 = [x%2+1 for x in range(len(s))]

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1
        
print(min(cnt0, cnt1))

Submission status: Wrong Answer

Solution code:
s=list(input())
x=0
y=0
for i in range(0,len(s)):
  if i%2==0:
    if s[i]=="0":
      x+=1
  else:
    if s[i]=="1":
      x+=1
      
for j in range(0,len(s)):
  if i%2==0:
    if s[i]=="1":
      y+=1
  else:
    if s[i]=="0":
      y+=1
      
print(min(x,y))

Submission status: Wrong Answer

Solution code:
import math

S = input()
S_list = []
N = len(S)
for i in range(N):
    S_list.append(S[i])

even_0 = S_list[1::2].count('0')
odd_0 = S_list[::2].count('0')
print(max(min(even_0+math.trunc(N/2)-odd_0, odd_0+math.ceil(N/2)-even_0), 0))

Submission status: Wrong Answer

Solution code:
mask_str0 = ""
mask_str1 = ""
flag = False
for i in range(len(bin(10 ** 5))):
    mask_str0 += "1" if flag else "0"
    mask_str1 += "0" if flag else "1"
    flag = not flag
mask0 = int(mask_str0, 2)
mask1 = int(mask_str1, 2)

s = input()
n = int(s, 2)
count0 = 0
count1 = 0
masked0 = n ^ mask0
masked1 = n ^ mask1
for i in range(len(s)):
    count0 += masked0 & 1
    masked0 = masked0 >> 1
    count1 += masked1 & 1
    masked1 = masked1 >> 1

print(min(count0, count1))