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 = input()
count = 0
for i in range(len(S)):
    if S[i: i+3] == '000':
        S = S[:i+1] + '1' + S[i+2:]
        count += 1
    elif S[i: i+3] == '001':
        if i > 0:
            S = S[:i] + '1' + S[i+1:]
        else:
            S = '1' + S[i+1:]
        count += 1
    elif S[i: i+3] == '011':
        S = S[:i+2] + '0' + S[i+3:]
        count += 1
    elif S[i: i+3] == '100':
        S = S[:i+2] + '1' + S[i+3:]
        count += 1
    elif S[i: i+3] == '110':
        if i > 0:
            S = S[:i] + '0' + S[i+1:]
        else:
            S = '0' + S[i+1:]
        count += 1
    elif S[i: i+3] == '111':
        S = S[:i+1] + '0' + S[i+2:]
        count += 1
    else:
        pass
if len(S) == 2:
    if S[0] == S[1]:
        count += 1
print(count)

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:
s=input()
l=len(s)
a=("10"*10000)[:l]
b=("01"*10000)[:l]
diff=lambda a,b: sum(s!=t for s,t in zip(a,b))
print(min(diff(a,s),diff(b,s)))

Submission status: Wrong Answer

Solution code:
s = list(input())
pattern_a_count = 0
pattern_b_count = 0

# 1010パターン
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == 0:
      pattern_a_count += 1
  if index % 2 == 1:
    if value == 1:
      pattern_a_count += 1

# 0101
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == 1:
      pattern_b_count += 1
  if index % 2 == 1:
    if value == 0:
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(res)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input()))
 
S_1 = [S[2*i] for i in range(len(S)//2) if S[2*i]==1]
S_0 = [S[2*i] for i in range(len(S)//2) if S[2*i]==0]
 
S_min = min(len(S)-len(S_1), len(S)-len(S_0))
 
print(S_min)

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):
    
    
    print(s)
    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)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
s0 = 0
s1 = 0
for s in S:
    if s == "0":
        s0 += 1
    else:
        s1 += 1

d = abs(s0 - s1)
dd = int(d / 2)
if (d % 2 == 0):
    dd += 2

print(dd)

Submission status: Wrong Answer

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

import re

a = input()

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

Submission status: Wrong Answer

Solution code:
X=[];S=[]
for char in input():
  X.append(char)
#route 1
S=X
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

#route 2
S=X
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

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

Submission status: Wrong Answer

Solution code:
X=[]
for char in input():
  X.append(char)
#route 1
S=X
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

#route 2
S=X
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

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

Submission status: Wrong Answer

Solution code:
S = list(input())
loop = len(S)//2
if len(S)%2 == 1:
    odd = 1
else:
    odd = 0
A = 0
B = 0
for x in range(loop):
    if S[x*2] == "0":
        A += 1
    if S[1+x*2] == "1":
        A += 1
    if odd == 1:
        if S[-1] == "0":
            A += 1
for x in range(loop):
    if S[x*2] == "1":
        B += 1
    if S[1+x*2] == "0":
        B += 1
    if odd == 1:
        if S[-1] == "1":
            A += 1   
if A < B:
    ans = A
else:
    ans = B
print(ans)

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):
    
    
    print(s)
    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)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
s0 = 0
s1 = 0
for s in S:
    if s == "0":
        s0 += 1
    else:
        s1 += 1

d = abs(s0 - s1)
dd = int(d / 2)
if (d % 2 == 0):
    dd += 2

print(d)

Submission status: Wrong Answer

Solution code:
S = list(input())
S2 = S[:]
now = S[0]
ans = 0
ans2 = 0
for i in range(len(S)-1):
  if now == "1":
    if S[i+1] == "0":
      now = "0"
    else:
      ans += 1
      now = "0"
      S[i+1] = "0"
  else:
    if S[i+1] == "1":
      now = "1"
    else:
      ans += 1
      now = "1"
      S[i+1] = "1"
S2.reverse()
for i in range(len(S2)-1):
  if now == "1":
    if S2[i+1] == "0":
      now = "0"
    else:
      ans2 += 1
      now = "0"
      S2[i+1] = "0"
  else:
    if S2[i+1] == "1":
      now = "1"
    else:
      ans2 += 1
      now = "1"
      S2[i+1] = "1"
print(min(ans, ans2))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
s0 = 0
s1 = 0
for s in S:
    if s == "0":
        s0 += 1
    else:
        s1 += 1

d = int(abs(s0 - s1) / 2)
if (d % 2 == 0):
    d += 2

print(d)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input()))
 
S_1 = [S[i] for i in range(len(S)) if S[i]==1]
S_0 = [S[i] for i in range(len(S)) if S[i]==0]
 
S_min = min(len(S_1), len(S_0))
 
print(S_min)

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
    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:
ans=0
check=0
X=[int(i) for i in input()]
p=X.pop()

for i in X:
    if p!=i:
        p=i
    else:
        check+=1
        p=1 if p==0 else 0

print(min(check,len(X)-check))

Submission status: Wrong Answer

Solution code:
a = input()
n = len(a)
if n == 1:
    print(0)
else:
    count0 = 0    #start from 0
    count1 = 0    #start from 1
    for i in range(n):
        if i % 2 == 0:
            if a[i] ==1:
                count0 = count0 +1
            if a[i] ==0:
                count1 = count1 +1
        if i % 2 == 1:
            if a[i] ==1:
                count1 = count1 +1
            if a[i] ==0:
                count0 = count0 +1

    print(max(count0, count1))
    print(n, a[2])

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))

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(1, 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:
S = int(input())
S_list = [int(x) for x in list(str(S))]
S_str = str(S)
S_list_1 = S_str.split('0')
S_list_2 = S_str.split('1')
output = 0

for i in range(len(S_list_1)):
  output += len(S_list_1[i])//2
for i in range(len(S_list_2)):
  output += len(S_list_2[i])//2
  
print(output)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
if n % 2 == 1:
    n += 1
pattern = '01' * (n // 2)

ans_a = 0
ans_b = 0
for i, (a, b) in enumerate(zip(pattern[1:], pattern[:-1])):
    if s[i] != a:
        ans_a += 1
    if s[i] != b:
        ans_b += 1
print(min(ans_a, ans_b))

Submission status: Wrong Answer

Solution code:
s=input()
l=len(s)
a=("10"*1000)[:l]
b=("10"*1000)[1:l+1]
diff=lambda a,b: sum(s!=t for s,t in zip(a,b))
print(min(diff(a,s),diff(b,s)))

Submission status: Wrong Answer

Solution code:
import numpy

s = list(input())
N = len(s)
count_A = 0
count_B = 0

for i in range(N):
    s[i] = int(str(s[i]))

A = numpy.empty(N)
B = numpy.empty(N)

for j in range(N):
    if j % 2 == 0 :
        A[j] = 1
        B[j] = 0
    else:
        A[j] = 0
        B[j] = 1

for k in range(N):
    A[k]=s[k]-A[k]
    B[k]=s[k]-B[k]
    if A[k] != 0:
        count_A = count_A + 1
    if B[k] != 0:
        count_B = count_B + 1

print(A)
print(B)

if count_A > count_B :
    print(count_B)
else :
    print(count_A)

Submission status: Wrong Answer

Solution code:
a = list(str(input()))
counter = 0
if len(a) == 1:
    counter = 0
else:
    for i in range(1,len(a)):
        if a[i] == a[i-1]:
            counter += 1
        else:
            pass
print(counter)

Submission status: Wrong Answer

Solution code:

S = input()

count = S.count("00") + S.count("11")

if len(S) % 2 == 0:
    print(count+1)
else :
    print(count)

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0
for i in range(len(S)-1):
    
    if S[i] == S[i+1]:
        if S[i] == '0':
            S = S[:i] + '1' + S[i+1:]
        else:
            S = S[:i] + '0' + S[i+1:]
        ans += 1

print(ans)

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
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)
s0 = 0
s1 = 0
for s in S:
    if s == "0":
        s0 += 1
    else:
        s1 += 1

d = int(abs(s0 - s1) / 2)
if (n % 2 == 0):
    d += 2

print(d)

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(N-1,-1,-1):
    if end == '0':
      if (i % 2 == 0 and S[i] == '0') or (i % 2 == 1 and S[i] == '1'):
        num2 += 1
    else:
      if (i % 2 == 1 and S[i] == '1') or (i % 2 == 0 and S[i] == '0'):
        num2 += 1
  return num2
A = alg1(S)
B = alg2(S)
print(min(A,B))

Submission status: Wrong Answer

Solution code:
s = list(input())
pattern_a_count = 0
pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 == 0:
    if value == 0:
      pattern_a_count += 1
  if index % 2 == 1:
    if value == 1:
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == 1:
      pattern_b_count += 1
  if index % 2 == 1:
    if value == 0:
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(pattern_a_count)

Submission status: Wrong Answer

Solution code:

paint = input();
cout=0;
if(paint[0]=='0'):
    temp=""
    for i in range(len(paint)):
        if(i%2==0 and paint[i]!='0'):
            temp+='0';
            cout+=1;
        else : temp+=paint[i]
    for j in range(len(paint)-1):
        if(temp[j]==temp[j+1]):
            cout+=1;
    print(cout) if len(paint)==1 else print(cout-1)
else:
    temp=""
    for i in range(len(paint)):
        if(i%2==0 and paint[i]!='1'):
            temp+='1'
            cout+=1;
        else : temp+=paint[i]
    for j in range(len(paint)-1):
        if(temp[j]==temp[j+1]):
            cout+=1;
    print(cout) if len(paint)==1 else print(cout-1)
#print(white)

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
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()
ls=[c for c in s]
ct=0
j=0
for i in range(len(ls)):
    if ls[i]==ls[j]:
        if (i-j)%2!=0 and i-j!=0 and i-j!=1:
            ct+=int((i-j-1)/2)+1
            ls[i]=ls[j+1]
            j=i
            
        elif (i-j)%2==0 and i-j!=0 and i-j!=2:
            ct+=int((i-j)/2)
            j=i
            
        elif i-j==1:
            ct+=1
            if ls[i]=='0':
                ls[i]='1'
            else:
                ls[i]='0'
            j=i
            
        elif i-j==2:
            j=i
            
        else:pass
if j<len(ls)-2:
    if (len(ls)-1-j)%2==0:
        ct+=int((len(ls)-1-j)/2)
    else:
        ct+=int((len(ls)-2-j)/2)
print(ct)

Submission status: Wrong Answer

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

s = list(map(int, list(input())))
s2 = s[:]

ans1 = 0
ans2 = 1

for i in range(1, len(s)):
    if (s[i-1] + s[i]) % 2 == 0:
        s[i] = abs(s[i]-1)
        ans1 += 1

if s2[0] == 0:
    s2[0] = 1
else:
    s2[0] = 0


for i in range(1, len(s)):
    if (s2[i-1] + s2[i]) % 2 == 0:
        s2[i] = abs(s[i]-1)
        ans1 += 1



print(ans1 if ans1 <= ans2 else ans2)

Submission status: Wrong Answer

Solution code:
a=str(input())
odd0,even0=0,0
odd1,even1=0,0
for i in range(len(a)):
  if i%2==0:#奇数
    if a[i]=="0":
      odd0+=1
  else:
    if a[i]=="0":
      even0+=1
odd1=int(len(a)/2)+1-odd0
even1=int(len(a)/2)-even0
print(min(odd1+even0,odd0+even1))

Submission status: Wrong Answer

Solution code:
S = list(input())

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
b = reversed(a)

if len(a)%2==0:
  if a[0]==a[-1]:
    print(len(a)//2)
  else:
  	print(len(a)//2-1)
else:
  if len(list(set(a)))==1:
  	print(len(a)//2)
  else:
    print(len(a)//2-1)

Submission status: Wrong Answer

Solution code:
S=[]
for char in '000':
  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:
S = input()
S = list(S)
S_ = []
for s in S:
    S_.append(int(s))

if len(S_) == 0: 
    ans = 0
    
elif S_[0] == 1:
    r, l = 0, 1 # 右端と左端のインデックス
    ans = 0
    while l < len(S_):
        #print(l)
        if S_[r] > S_[l]:
            r += 1
            l += 1
        elif S_[r] == S_[l]:
            if S_[r-1] == 1:
                S_[l] = 1
                r += 1
                l += 1
                ans += 1
            else:
                S_[l] = 0
                r += 1
                l += 1
                ans += 1
        else:
            r += 1
            l += 1

elif S_[0] == 0:
    r, l = 0, 1 # 右端と左端のインデックス
    ans = 0
    while l < len(S_):
        if S_[r] < S_[l]:
            r += 1
            l += 1
        elif S_[r] == S_[l]:
            if S_[r-1] == 0:
                S_[l] = 1
                r += 1
                l += 1
                ans += 1
            else:
                S_[l] = 0
                r += 1
                l += 1
                ans += 1
        else:
            r += 1
            l += 1
            
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
if n % 2 == 1:
    n += 1
pattern = '01' * (n // 2)

ans_a = 0
ans_b = 0
for i, (a, b) in enumerate(zip(pattern[1:], pattern[:-1])):
    if pattern[i] != a:
        ans_a += 1
    if pattern[i] != b:
        ans_b += 1
print(min(ans_a, ans_b))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    s = input()
    length = len(s)
    o = "10" * (length // 2 + (length % 2))
    o_len = len([i for i, j in zip(s, o) if i == j])
    z_len = len([i for i, j in zip(s, o[::-1]) if i == j])
    print(length - max([z_len, o_len]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
b = reversed(a)

if len(a)%2==0:
  if a[0]==a[-1]:
    print(len(a)//2)
  else:
  	print(len(a)//2-1)
elif len(list(set(a)))==1:
    print(len(a)//2)
else:
  print(len(a)//2-1)

Submission status: Wrong Answer

Solution code:
tiles = input()

even_0 = 0
even_1 = 0
odd_0 = 0
odd_1 = 0

for i, t in enumerate(tiles):
    if i % 2 == 0:
        if t == '0':
            even_0 += 1
        else:
            even_1 += 1
    else:
        if t == '0':
            even_0 += 1
        else:
            even_1 += 1

if even_0 + odd_1 >= even_1 + odd_0:
    print(even_1 + odd_0)
else:
    print(even_0 + odd_1)

Submission status: Wrong Answer

Solution code:
S = str(input())
s0=0
s1=0
for i in range(len(S)):
    if i%2==0 and S[i]=="0":
        s1+=1
    elif i%2==0 and S[i]=="1" :
        s0+=1
        print("B")
    elif i%2==1 and S[i]=="0":
        s0+=1
        print("C")
    elif i%2==1 and S[i]=="1":
        s1+=1
        print("D")
print(min(s0,s1))

Submission status: Wrong Answer

Solution code:
str=input()
n=len(str)
evenzero=0
evenone=0
oddzero=0
oddone=0
count=0
for x in range(n):
    if x%2==0:
        if str[x]=="0":
            evenzero +=1
        else:
            evenone +=1
    else:
        if str[x]=="0":
            oddzero +=1
        else:
            oddone +=1

t=max(evenzero,evenone,oddzero,oddone)

if t==evenzero:
    for x in range(n):
        if x % 2 == 0:
            if str[x] != "0":
                count += 1
        else:
            if str[x] != "1":
                count += 1
elif t==evenone:
    for x in range(n):
        if x % 2 == 0:
            if str[x] != "1":
                count += 1
        else:
            if str[x] != "0":
                count += 1
elif t==oddzero:
    for x in range(n):
        if x % 2 == 0:
            if str[x] != "1":
                count += 1
        else:
            if str[x] != "0":
                count += 1
elif t==evenzero:
    for x in range(n):
        if x % 2 == 0:
            if str[x] != "0":
                count += 1
        else:
            if str[x] != "1":
                count += 1
print(count)

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_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))

if change < change_reverse:
    print(str(change))
else:
    print(str(change_reverse))

Submission status: Wrong Answer

Solution code:
li = list(input())
sums = 0
leng = int(len(li))

for i in range(leng):
    now = i
    print(now)
    if (now + 1) >= leng:
        print(now)
        break
    if(li[now] == li[now + 1]):
        if(li[now + 1] == '0'):
            li[now + 1] = '1'
        else:
            li[now + 1] = '0'
        sums += 1
print(sums)

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:
        print(oo + ll + 2*ol + (1 if S[-1] == "0" else 0))
    elif lo < ol:
        print(oo + ll + 2*lo + (1 if S[-1] == "1" else 0))
    else:
        print(oo + ll + 2*lo)

Submission status: Wrong Answer

Solution code:
mozi = input()

front = mozi[0]
result = 0
for temp in mozi[1:-1]:
    if temp == front:
        result += 1
        if front == '1':
            front = '0'
        else:
            front = '1'
    else:
        front = temp
        

    
print(result)

Submission status: Wrong Answer

Solution code:
print("0")

Submission status: Wrong Answer

Solution code:
def f(s,a):
    ans=0
    for i in range(len(s)):
        if i%2==0:
            if s[i]!=a:
                ans+=1
                print(1)
        else:
            if s[i]==a:
                ans+=1
    return ans


s=list(input())
print(min(f(s,'0'),f(s,'1')))

Submission status: Wrong Answer

Solution code:
pat = input()
if len(pat) == 1:
    print(0)
else:
    #generate
    pat1 = "0"
    pat2 = "1"

    for i in range(len(pat)-1):
        if pat1[-1:]=="0":
            pat1 = pat1+"1"
        else:
            pat1 = pat1+"0"
        
    for i in range(len(pat)-1):
        if pat2[-1:]=="0":
            pat2 = pat2+"1"
        else:
            pat2 = pat2+"0"

    count1 = 0
    count2 = 0
    for s in range(len(pat)-1):
        if pat[s] != pat1[s]:
            count1 = count1 + 1
        if pat[s] != pat2[s]:
            count2 = count2 + 1
    
    if count1 <= count2:
        print(count1)

    else:
        print(count2)

Submission status: Wrong Answer

Solution code:
S = input()
count = 0
for i in range(len(S)):
    if S[i: i+3] == '000':
        S = S[:i+1] + '1' + S[i+2:]
        count += 1
    elif S[i: i+3] == '001':
        if i > 0:
            S = S[:i] + '1' + S[i+1:]
        else:
            S = '1' + S[i+1:]
        count += 1
    elif S[i: i+3] == '011':
        S = S[:i+2] + '0' + S[i+3:]
        count += 1
    elif S[i: i+3] == '100':
        S = S[:i+2] + '1' + S[i+3:]
        count += 1
    elif S[i: i+3] == '110':
        if i > 0:
            S = S[:i] + '0' + S[i+1:]
        else:
            S = '0' + S[i+1:]
        count += 1
    elif S[i: i+3] == '111':
        S = S[:i+1] + '0' + S[i+2:]
        count += 1
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
import math

s=input()
ans0=0
ans1=0
if len(s)>2:
    for i in range(math.ceil(len(s)/2)):
    #    print(i)
        if s[2*i]!="0":
            ans0+=1
        if i>0:
            if s[2*i-1]!="1":
                ans0+=1

    for i in range(math.ceil(len(s)/2)):
    #    print(i)
        if s[2*i]!="1":
            ans1+=1
        if i>0:
            if s[2*i-1]!="0":
                ans1+=1

elif len(s)==2:
    if s=="00" or s=="11":
        ans0=1
        ans1=1
        
print(min(ans0,ans1))

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_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))

if change < change_reverse:
    print(change)
else:
    print(change_reverse)