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:
S = [int(i) for i in input()]
l = len(S)

# Patern.1
if l < 3:
    print("0")
    start = -1
elif (S[:3] == [1,1,0]) or (S[:3] == [0,0,1]):
    start = 0
elif (S[:3] == [1,1,1]) or (S[:3] == [0,0,0]):
    start = 1
elif (S[:3] == [1,0,0]) or (S[:3] == [0,1,1]):
    start = 2
elif (S[:3] == [0,1,0]) or (S[:3] == [1,0,1]):
    start = 3

if start >= 0:
    cnt = 0
    c_prev = S[start]
    for i in range(start, l):
        if c_prev == S[i]:
            cnt += 1
            S[i] = (S[i]+1)%2
        c_prev = S[i]
    print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    s = list(input())

    cnt_0 = 0

    if len(s) >= 3:
        for i in range(0, len(s)):
            pair_s = ''.join(s[i:i+3])
            if pair_s == '000':
                s[i+1] = '1'
                cnt_0 += 1
            elif pair_s == '111':
                s[i+1] = '0'
                cnt_0 += 1
            elif pair_s == '110':
                s[i] = '0'
                cnt_0 += 1
            elif pair_s == '001':
                s[i] = '0'
                cnt_0 += 1
            elif pair_s == '011':
                s[i+2] = '0'
                cnt_0 += 1
            elif pair_s == '100':
                s[i+2] = '1'
                cnt_0 += 1
    elif len(s) == 2:
        if ''.join(s) == '00' or ''.join(s) == '11':
            cnt_0 = 1

    print(cnt_0)
    
main()

Submission status: Wrong Answer

Solution code:
S = input()
sum01 = 0
sum10 = 0

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

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == 0:
      sum01 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 1:
      sum01 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
char_S=list(S)
x=int (0)
y=int (0)

if N%2==0:
  for i in range(0,N,2):
    	if S[i]=='0':
        	x+=1
    	if S[i+1]=='1':
        	x+=1
    	if S[i]=='1':
        	y+=1
    	if S[i+1]=='0':
        	y+=1
else:
  for i in range(0,N-1,2):
    	if S[i]=='0':
        	x+=1
    	if S[i+1]=='1':
        	x+=1
    	if S[i]=='1':
        	y+=1
    	if S[i+1]=='0':
        	y+=1

if x>y:
    print(y)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
s=input().split()
a=len(s)
i=0
ans=0
for count in s:
    if s[i]==s[i+1:]:
        if s[i]==0:
            s[i+1]==1
            ans+=1
        else:
            s[i+1]==0
            ans+=1
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
88

Submission status: Wrong Answer

Solution code:
S = input()
T = list(S)
L = len(T)
C = 0

for i in range(0,L-2,1):
	if T[i] == '1':
		if T[i+1] == '1':
			T[i+1] = '0'
			C += 1
	else:
		if T[i+1] == '0':
			T[i+1] = '1'
			C += 1
print(C)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
s = list(stdin.readline().rstrip())
odd = Counter(s[0::2])
even = Counter(s[1::2])
if odd['1'] > even['1']:
    print(odd['0']+even['1'])
elif odd['1'] < even['1']:
    print(odd['1']+even['0'])
else:
    if odd['0'] > even['0']:
        print(odd['1']+even['0'])
    elif odd['0'] < even['0']:
        print(odd['0']+even['1'])
    else:
        print(odd['1']+even['1'])

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
start = S[0]
end = S[N-1]
def alg1(S):
  if N == 1:
    return 0
  num1 = 0 
  for i in range(1,N):
    if start == '0':
      if (i % 2 == 0 and S[i] == '0') or (i % 2 == 1 and S[i] == '1'):
        num1 += 1
    else:
      if (i % 2 == 1 and S[i] == '1') or (i % 2 == 0 and S[i] == '0'):
        num1 += 1
  return num1

def alg2(S):
  if N == 1:
    return 0
  num2 = 0
  for i in range(1,N):
    if end == '0':
      if ((N-i-1)% 2 == 0 and S[N-i-1] == '0') or ((N-i-1) % 2 == 1 and S[N-1-i] == '1'):
        num2 += 1
    else:
      if ((N-i-1) % 2 == 1 and S[N-i-1] == '1') or ((N-i-1) % 2 == 0 and S[N-1-i] == '0'):
        num2 += 1
  return num2
A = alg1(S)
B = alg2(S)
print(min(A,B))

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
char_S=list(S)
x=int (0)
y=int (0)

if N%2==0:
  for i in range(0,N,2):
    	if S[i]=='0':
        	x+=1
    	if S[i+1]=='1':
        	x+=1
    	if S[i]=='1':
        	y+=1
    	if S[i]=='0':
        	y+=1
else:
  for i in range(0,N-1,2):
    	if S[i]=='0':
        	x+=1
    	if S[i+1]=='1':
        	x+=1
    	if S[i]=='1':
        	y+=1
    	if S[i]=='0':
        	y+=1

if x>y:
    print(y)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
from sys import stdin

tile = input()
tile_length = len(tile)
tile_color = list(tile)

count_start_zero = 0
count_start_one = 0

""" START ZERO """
if tile_color[0] is '1':
	tile_color[0] = '0'
	count_start_zero += 1

for i in range(tile_length-1):
	if tile_color[i+1] is tile_color[i]:
		if tile_color[i] is '0':
			tile_color[i+1] = '1'
		else: tile_color[i+1] = '0'

		count_start_zero += 1

""" START ONE """
if tile_color[0] is '0':
	tile_color[0] = '1'
	count_start_one += 1

for i in range(tile_length-1):
	if tile_color[i+1] is tile_color[i]:
		if tile_color[i] is '1':
			tile_color[i+1] = '0'
		else: tile_color[i+1] = '1'

		count_start_one += 1

print(min(count_start_one, count_start_zero))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import re

a = input()

preans1 = 0
preans2 = 1000000
if(a[0] == "0"):
    for i in range(1,len(a)):
        if(i%2 == 0):
            if(a[i] != "1"):
                preans1 += 1
        elif(i%2 == 1):
            if(a[i] != "0"):
                preans1 += 1
    if(a[-1] == "1"):
        preans2 = 0
        for i in range(2,len(a)+1):
            if(i%2 == 0):
                if(a[-i] != "0"):
                    preans2 += 1
            elif(i%2 == 1):
                if(a[-i] != "1"):
                    preans2 += 1
elif(a[0] == "1"):
    for i in range(1,len(a)):
        if(i%2 == 1):
            if(a[i] != "0"):
                preans1 += 1
        elif(i%2 == 0):
            if(a[i] != "1"):
                preans1 += 1
    if(a[-1] == "0"):
        preans2 = 0
        for i in range(2,len(a)+1):
            if(i%2 == 0):
                if(a[-i] != "1"):
                    preans2 += 1
            elif(i%2 == 1):
                if(a[-i] != "0"):
                    preans2 += 1
print(min(preans1,preans2))

Submission status: Wrong Answer

Solution code:
tiles = list(map(int, input()))
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        counts = counts + 1 if tile != color else counts
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Submission status: Wrong Answer

Solution code:
string = str(input())
lis = []

for s in string:
  lis.append(int(s))
  
ans = 0
itr = 0
j = 0
for i in lis:
  if len(lis) == 1:
    print(ans)
    
  if itr == 0:
    itr += 1
    j = i
    continue
    
  if  j == i:
    ans += 1
    if i == 1:
      j = 0
    else:
      j = 1
  else:
    j = i
    continue

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 1:
    a <<= 2
    a += 1
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))

Submission status: Wrong Answer

Solution code:
n = list(map(int, input()))

count_one = 0
count_zero = 0
for i in range(int(len(n)/2)):
    if n[2*i] == 1:
        count_one += 1
    if n[2*i+1] == 0:
        count_one +=1

for j in range(int(len(n)/2)):
    if n[2*j] == 0:
        count_zero += 1
    if n[2*j+1] == 1:
        count_zero += 1

print(min(count_one, count_zero))

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
start = S[0]
end = S[N-1]
def alg1(S):
  if N == 1:
    return 0
  num1 = 0 
  for i in range(1,N):
    if start == '0':
      if (i % 2 == 0 and S[i] == '0') or (i % 2 == 1 and S[i] == '1'):
        num1 += 1
    else:
      if (i % 2 == 1 and S[i] == '1') or (i % 2 == 0 and S[i] == '0'):
        num1 += 1
  return num1

def alg2(S):
  if N == 1:
    return 0
  num2 = 0
  for i in range(1,N):
    if end == '0':
      if ((N-i)% 2 == 0 and S[N-i] == '0') or ((N-i) % 2 == 1 and S[N-i] == '1'):
        num2 += 1
    else:
      if ((N-i) % 2 == 1 and S[N-i] == '1') or ((N-i) % 2 == 0 and S[N-i] == '0'):
        num2 += 1
  return num2
A = alg1(S)
B = alg2(S)
print(min(A,B))

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 1:
    a <<= 2
    a += 1
print(bin(a))
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))

Submission status: Wrong Answer

Solution code:
tiles = list(map(int, input()))
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        counts = counts + 1 if tile != color else 0
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Submission status: Wrong Answer

Solution code:
raw = input()
s = bin(int(raw, 2))
n = len(raw)
m1 = bin(int("1010101010101"[:n],2))

a = bin((int(s,2))^int(m1,2)).count("1")
b = n-a

print(a if a < b else b)

Submission status: Wrong Answer

Solution code:
def main():
  S=input()
  char = list(S)
  char2= list(S)
  num =len(char)
  count=0
  
  if num ==1:
    print(0)
  
  elif num>1:
    for i in range(0,num-1,2):
      if(char[i]=='0'):
        char[i]='1'
        count=count+1
    for j in range(1,num-1,2):
      if(char[j]=='1'):
        char[j]='0'
        count=count+1
    count_even=count
  
    count=0
    for i in range(0,num-1,2):
      if(char2[i]=='1'):
        char2[i]='0'
        count=count+1
    for j in range(1,num-1,2):
      if(char2[j]=='0'):
        char2[j]='1'
        count=count+1
    count_odd=count
    print(min(count_even,count_odd))
  
main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import re

a = input()

preans1 = 0
preans2 = 0
if(a[0] == "0"):
    for i in range(1,len(a)):
        if(i%2 == 0):
            if(a[i] != "1"):
                preans1 += 1
        elif(i%2 == 1):
            if(a[i] != "0"):
                preans1 += 1
    if(a[-1] == "1"):
        for i in range(2,len(a)+1):
            if(i%2 == 0):
                if(a[-i] != "0"):
                    preans2 += 1
            elif(i%2 == 1):
                if(a[-i] != "1"):
                    preans2 += 1
elif(a[0] == "1"):
    for i in range(1,len(a)):
        if(i%2 == 1):
            if(a[i] != "0"):
                preans1 += 1
        elif(i%2 == 0):
            if(a[i] != "1"):
                preans1 += 1
    if(a[-1] == "0"):
        for i in range(2,len(a)+1):
            if(i%2 == 0):
                if(a[-i] != "1"):
                    preans2 += 1
            elif(i%2 == 1):
                if(a[-i] != "0"):
                    preans2 += 1
print(min(preans1,preans2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
S = str(input())

ans=0

if len(S)==1:
  ans=0
elif len(S)==2:
  if S[0]==S[1]:
    ans=1
  else:
    ans=0
else: #3枚以上はちゃんと読み込む
  string=[]
  
  for i in range(len(S)):
    string.append(S[i])
  
  for i in range(len(S)-2):
    gramed = str(string[i])+str(string[i+1])+str(string[i+2])
    
    if gramed=="000":
      string[i+1]="1"
      ans=ans+1
    if gramed=="001":
      string[i]="1"
      ans=ans+1
    if gramed=="011":
      string[i+2]="0"
      ans=ans+1
    if gramed=="110":
      string[i]="0"
      ans=ans+1
    if gramed=="100":
      string[i+2]="1"
      ans=ans+1
    if gramed=="111":
      string[i+1]="1"
      ans=ans+1
      
  #print(string)
print(ans)

Submission status: Wrong Answer

Solution code:
raw = input()
s = bin(int(raw, 2))
n = len(raw)
m1 = bin(int("10101010101010101"[:n],2))
m2 = bin(int("01010101010101010"[:n],2))

a = bin((int(s,2))^int(m1,2)).count("1")
b = bin((int(s,2))^int(m2,2)).count("1")

print(a if a < b else b)

Submission status: Wrong Answer

Solution code:
S = input()

a = int("".join(["0" if i%2 == 0 else "1" for i in range(len(S))]), 2)
b = -~a


a_ = int(S, 2) ^ a
b_ = int(S, 2) ^ b

cnt1 = 0
cnt2 = 0

for c1 in bin(a_)[2:]:
    if c1 == "1":
        cnt1 += 1

for c2 in bin(b_)[2:]:
    if c2 == "1":
        cnt2 += 1

if cnt1 > cnt2:
    print(cnt2)
else:
    print(cnt1)

Submission status: Wrong Answer

Solution code:
raw = input()
s = bin(int(raw, 2))
n = len(raw)
m1 = bin(int("101010101"[:n],2))
m2 = bin(int("010101010"[:n],2))

a = bin((int(s,2))^int(m1,2)).count("1")
b = bin((int(s,2))^int(m2,2)).count("1")

print(a if a < b else b)

Submission status: Wrong Answer

Solution code:
def color(s):
    k = 0
    for i in range(len(s)-1):
        if s[i+1]==s[i]:
            if s[i]=='0':
                s[i+1]='1'
            if s[i]=='1':
                s[i+1]='0'
            k = k+1
    return k
    
s=list(input())
color(s)

Submission status: Wrong Answer

Solution code:

n = list(input())
n_2 = n.copy()
ex = 0
ex_2 = 0

if len(n) <= 1:
    print(0)
elif len(n)==2:
    b = (int)(n[1 - 1])
    m = (int)(n[1])
    if b == 0 and m == 0:
        ex += 1
    if b == 1 and m == 1:
        ex += 1
else:
    b = (int)(n[0])
    m = (int)(n[1])
    if b == 0 and m == 0:
        n[0] = 1
        ex += 1
    elif b == 1 and m == 1:
        n[0] = 0
        ex += 1
    for i, l in enumerate(n):
        if i >= 1:
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
    ex_2 = ex
    ex = 0
    n = n_2
    b = (int)(n[0])
    m = (int)(n[1])
    if b == 0 and m == 0:
        n[1] = 1
        ex += 1
    elif b == 1 and m == 1:
        n[1] = 0
        ex += 1

    for i, l in enumerate(n):
        if i >= 1:
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
if ex<ex_2:
    print(ex)
else:
    print(ex_2)

Submission status: Wrong Answer

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

def poe(b):
  res = 0
  for i in range(size):
    if b:
      a = '1' if i % 2 == 0 else '0'
    else:
      a = '0' if i % 2 == 0 else '1'
 
    if a != s[i]:
      res+=1

  return res

print (poe(True), poe(False))

Submission status: Wrong Answer

Solution code:
S=[]
for char in input():
  S.append(char)
#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=='1':
      C1+=1
  else:
    if S[i]=='0':
      C1+=1

#route 2
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]=='0':
      C2+=1
  else:
    if S[n]=='1':
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S) // 2
ll = 0
oo = 0
lo = 0
ol = 0
if n > 0:
    for i in range(n):
        if S[i:i+2] == "00":
            oo += 1
        elif S[i:i+2] == "10":
            lo += 1
        elif S[i:i+2] == "01":
            ol += 1
        elif S[i:i+2] == "11":
            ll += 1

if len(S) % 2 == 0:
    if lo >= ol:
        print(oo + ll + 2*ol)
    else:
        print(oo + ll + 2*lo)
else:
    if lo > ol:
        ans = oo + ll + 2*ol + (1 if S[-1] == "0" else 0)
    elif lo < ol:
        ans = oo + ll + 2*lo + (1 if S[-1] == "1" else 0)
    elif lo == ol:
        ans = oo + ll + 2*lo
    ll = 0
    oo = 0
    lo = 0
    ol = 0
    if n > 0:
        for i in range(n):
            if S[i+1:i+3] == "00":
                oo += 1
            elif S[i+1:i+3] == "10":
                lo += 1
            elif S[i+1:i+3] == "01":
                ol += 1
            elif S[i+1:i+3] == "11":
                ll += 1
    if lo > ol:
        ans = min(ans, oo + ll + 2*ol + (1 if S[0] == "1" else 0))
    elif lo < ol:
        ans = min(ans, oo + ll + 2*lo + (1 if S[0] == "0" else 0))
    elif lo == ol:
        ans = min(ans, oo + ll + 2*lo)
    print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
S = [int(i) for i in S]
sum1,sum2 = 0,0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            sum1 += 1
    else:
        if S[i] == 1:
            sum1 += 1

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 1:
            sum2 += 1
    else:
        if S[i] == 0:
            sum2 += 1
print(sum1,sum2)
if sum1 <= sum2:
    print(sum1)
else:
    print(sum2)

Submission status: Wrong Answer

Solution code:
S=[]
for char in input():
  S.append(char)

#route 2
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]==0:
      S[n]=1
      C2+=1
  else:
    if S[n]==1:
      S[n]=0
      C2+=1
      
#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Wrong Answer

Solution code:
data = [int(s) for s in input()]
count1 = 0
if data[0] == 0:
  
  
  for s in range(1,len(data)-1):
    
    
    
    if s % 2 == 0:
        if data[s] != 0:
            count1 += 1
            
    else :
        if data[s] != 1:
            count1 += 1
            
else:
  
  
  for s in range(1,len(data)-1):
    
    if s % 2 == 0:
      if data[s] != 1:
        count1 += 1
        
    else:
      if data[s] != 0:
        count1 += 1
          


print(count1)

Submission status: Wrong Answer

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

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 1:
            sum2 += 1
    else:
        if S[i] == 0:
            sum2 += 1
print(sum1,sum2)
if sum1 <= sum2:
    print(sum1)
else:
    print(sum2)

Submission status: Wrong Answer

Solution code:
def main():
  S=input()
  char = list(S)
  char2= list(S)
  num =len(char)
  count=0
  
  for i in range(0,num-1,2):
    if(char[i]=='0'):
      char[i]='1'
      count=count+1
  for j in range(1,num-1,2):
    if(char[j]=='1'):
      char[j]='0'
      count=count+1
  count_even=count
  
  count=0

  for i in range(0,num-1,2):
    if(char2[i]=='1'):
      char2[i]='0'
      count=count+1
  for j in range(1,num-1,2):
    if(char2[j]=='0'):
      char2[j]='1'
      count=count+1
  count_odd=count


  print(min(count_even,count_odd))
  
main()

Submission status: Wrong Answer

Solution code:
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

#cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse_first+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

result = [change, change_first, change_reverse, change_reverse_first]
print(min(result))

Submission status: Wrong Answer

Solution code:

n = list(input())
n_2 = n.copy()
ex = 0
ex_2 = 0

if len(n) <= 1:
    print(0)
elif len(n)==2:
    b = (int)(n[1 - 1])
    m = (int)(n[1])
    if b == 0 and m == 0:
        ex += 1
    if b == 1 and m == 1:
        ex += 1
else:
    for i, l in enumerate(n):
        if i >= 1:
            b = (int)(n[i - 1])
            m = (int)(n[i])
            if b == 0 and m == 0:
                n[i - 1] = 1
                ex += 1
            elif b == 1 and m == 1:
                n[i - 1] = 0
                ex += 1
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
    ex_2 = ex
    ex = 0
    n = n_2
    for i, l in enumerate(n):
        if i >= 1:
            b = (int)(n[i - 1])
            m = (int)(n[i])
            if b == 0 and m == 0:
                n[i] = 1
                ex += 1
            elif b == 1 and m == 1:
                n[i] = 0
                ex += 1
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
if ex<ex_2:
    print(ex)
else:
    print(ex_2)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S) // 2
ll = 0
oo = 0
lo = 0
ol = 0
if n > 0:
    for i in range(n):
        if S[i:i+2] == "00":
            oo += 1
        elif S[i:i+2] == "10":
            lo += 1
        elif S[i:i+2] == "01":
            ol += 1
        elif S[i:i+2] == "11":
            ll += 1

if len(S) % 2 == 0:
    if lo >= ol:
        print(oo + ll + 2*ol)
    else:
        print(oo + ll + 2*lo)
else:
    if lo > ol:
        ans = oo + ll + 2*ol + (1 if S[-1] == "0" else 0)
    elif lo < ol:
        ans = oo + ll + 2*lo + (1 if S[-1] == "1" else 0)
    elif lo == ol:
        ans = oo + ll + 2*lo
    ll = 0
    oo = 0
    lo = 0
    ol = 0
    if n > 0:
        for i in range(n):
            if S[i+1:i+3] == "00":
                oo += 1
            elif S[i+1:i+3] == "10":
                lo += 1
            elif S[i+1:i+3] == "01":
                ol += 1
            elif S[i+1:i+3] == "11":
                ll += 1
    if lo > ol:
        ans = min(ans, oo + ll + 2*ol + (1 if S[-1] == "0" else 0))
    elif lo < ol:
        ans = min(ans, oo + ll + 2*lo + (1 if S[-1] == "1" else 0))
    elif lo == ol:
        ans = min(ans, oo + ll + 2*lo)
    print(ans)

Submission status: Wrong Answer

Solution code:
def Change(a):
    if a == '0':
        s = '1'
    else:
        s = '0'
    return s


count = 0
S = list(input())
if len(S) >= 3:
    if S[0] == S[1] == S[2]:
        S[1] = Change(S[1])
        count += 1
if len(S) >= 2 and S[0] == S[1]:
    S[0] = Change(S[0])
    count += 1
if len(S) >= 3:
    for i in range(len(S)-2):
        if S[i] == S[i+1] == S[i+2]:
            S[i+1] = Change(S[i+1])
            count += 1
        if S[i] == S[i + 1]:
            S[i + 1] = Change(S[i + 1])
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

S = str(input())

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

flg = True
if S[0]=="0":
    for i in range(len(S)):
        if i == 0:
            continue
        if i%2 == 0:
            if S[i]!="0":
                flg = False
                break
        else:
            if S[i]!="1":
                flg = False
                break
else:
    for i in range(len(S)):
        if i == 0:
            continue
        if i%2 == 0:
            if S[i]!="1":
                flg = False
                break
        else:
            if S[i]!="0":
                flg = False
                break

if flg:
    print(0)
else:
    one = S.count("1")
    zero = S.count("0")

    a1 = int(one / 2)
    a2 = int(zero / 2)

    print(a1 + a2)

Submission status: Wrong Answer

Solution code:
S = input()
sum01 = 0
sum10 = 0

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

else:
  for i in range(len(S)-1):
    if (i % 2) == 0:
      if S[i+1:i+2] == '0':
        sum10 += 1
    if (i % 2) == 1:
      if S[i+1:i+2] == '1':
        sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)

Submission status: Wrong Answer

Solution code:
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(1, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

result = [change, change_first, change_reverse]
print(min(result))

Submission status: Wrong Answer

Solution code:
n = input()
answer = 0
if len(n)<=1:
    print(0)
else:
    for i in range(1,len(n)):
        if n[i]==n[i-1]:
            answer+=1
            if n[i]=='0':
                n = n[:i]+'1'+n[i+1:]
            else:
                n = n[:i]+'0'+n[i+1:]
    print(answer)
print(n)

Submission status: Wrong Answer

Solution code:
S=list(input())
N=len(S)
S_int=list(S)
for i in range(N):
    S_int[i]=int(S[i])
cnt_1=0
cnt_2=0
if all([S_int[i]!=S_int[i+1] for i in range(N-1)]):
    print(0)
else:
    for i in range(N):
        if i%2==0 and S_int[i]==0:
            S_int[i]=1
            cnt_1+=1
        elif i%2==1 and S_int[i]==1:
            S_int[i]=0
            cnt_1+=1
    for i in range(N):
        if i%2==0 and S_int[i]==1:
            S_int[i]=0
            cnt_2+=1
        elif i%2==1 and S_int[i]==0:
            S_int[i]=1
            cnt_2+=1
    print(min(cnt_1,cnt_2))

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
str_1 = list(s)
str_2 = list(s)
for i in range(len(str_1)-1):
	if str_1[i] ==str_1[i+1]:
		str_1[i+1] = "1" if str_1[i] == "0" else "0"
		ans += 1

ans_2 = 0
str_2[0] = "1" if str_2[0] == "0" else "0"
for i in range(len(str_2)-1):
	if str_2[i] ==str_2[i+1]:
		str_2[i+1] = "1" if str_2[i] == "0" else "0"
		ans_2 += 1

print(ans if ans <= ans_2 else ans_2)

Submission status: Wrong Answer

Solution code:
data = [int(s) for s in input()]
count1 = 0
if data[0] == 0:
  
  
  for s in range(1,len(data)-1):
    
    
    
    if s % 2 == 0:
        if data[s] != 0:
            count1 += 1
            
    else :
        if data[s] != 1:
            count1 += 1
            
else:
  
  
  for s in range(1,len(data)-1):
    
    if s % 2 == 0:
      if data[s] != 0:
        count1 += 1
        
      else:
        if data[s] != 1:
          count1 += 1
          


print(count1)