TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
s = input().strip()
n = len(s)
one = s.count('0')
l = [one]
for i in range(n):
  if s[i] == '0':
     one-=1
  else:
     one+=1
  l.append(one)
print(min(l))

# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
        e =s[i]

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))

s = input().strip()
n = len(s)
one = s.count('0')
l = []
for i in range(n):
  if s[i] == '0':
    one-=1
  else:
    one+=1
  l.append(one)
print(min(l))

# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
if k == '1':
    e = '0'
else :
    e = '1'

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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')))

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


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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

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)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
st = list(input())
s = [int(i) for i st]

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

s = list(input())

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

s = list(int(input()))

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

st = list(input())
s = [int(i) for i in st]

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s = str(input())
c1 = 0
c2 = 0
x = 1
def hen(n):
  if n == 1:
    return 0
  else:
    return 1
for i in range(len(s)):
  si = int(s[i])
  if si == x:
    c1 += 1
  else:
    c2 + = 1
  x = hen(x)
print(min(c1,c2))

s = str(input())
c1 = 0
c2 = 0
x = 1
def hen(n):
  if n == 1:
    return 0
  else:
    return 1
for i in range(len(s)):
  si = int(s[i])
  if si == x:
    c1 += 1
  else:
    c2 += 1
  x = hen(x)
print(min(c1,c2))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
n = len(s)
cnt = 0
for i in range(n - 1):
  c1 = s[i:i+1]
  c2 = s[i+1:i+2]
  if(c1 == c2):
    t = s
    if(c1 == '0'):
      s = t[ :i] + "1" + t[i+1: ]
    else:
      s = t[ :i] + "0" + t[i+1: ]
    cnt += 1
print(cnt)
      
    
  

s = input()
cnt = 0
if(s[:1] == '0'):
  for i in range(len(s) // 2):
    if(s[2*i+1:2*i+2] == '0'):
      cnt += 1
    if(s[2*i+2:2*i+3] == '1'):
      cnt += 1
else:
  for i in range(len(s) // 2):
    if(s[2*i+1:2*i+2] == '1'):
      cnt += 1
    if(s[2*i+2:2*i+3] == '0'):
      cnt += 1  
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def resolve():
    S = list(input())

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

            if S[i] == '0':
                S[i] = '1'
            else:
                S[i] = '0'

    print(ans)

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

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

            if S[i] == '0':
                S[i] = '1'
            else:
                S[i] = '0'

    print(ans)


resolve()

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

S=input()
c=S[::2].count('0')+S[1::2].count('1')
print(min(c,len(S)-c))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = str(input())

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

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

s = str(input())

test0 = [x%2 for x in range(len(s))]
test1 = [x%2 for x in range(len(s) - 1)]
test1.insert(0, 1)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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))

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


S = input()
nS = len(S)
white = ("01"*100000)[:nS]
black = ("10"*100000)[: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))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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))
        

import sys
S = input()
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))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
n=s[::2].count("0")+s[1::2].count("1")
print(min(n,lens(s)-n))

s=input()
n=s[::2].count("0")+s[1::2].count("1")
print(min(n,len(s)-n))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
#import numpy as np

n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size-1):
  if (int(n[i]) == new_list[i]):
    count+=1

if n_size == 1:
  print(0)
else:
  ans = n_size-count    
  print(ans)    
    


#import numpy as np

n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size):
  if (int(n[i]) != int(new_list[i])):
    count+=1

print(new_list)    
if n_size == 1:
  print(0)
else:
#  ans = n_size-count    
  print(count)    
    


n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size):
  if (int(n[i]) != int(new_list[i])):
    count+=1

print(new_list)    
if n_size == 1:
  print(0)
else:
#  ans = n_size-count    
  print(count)   

import numpy as np

n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size-1):
#  print(i)
  if int(n[i]) == new_list[i]:
    count+=1

ans = n_size-count    
print(ans)    
    


#import numpy as np

n = list(input())
n_size = len(n)
count = 0
#print(n_size)  
new_list = []
new_list.append(int(n[0]))
for i in range(n_size-1):
  if new_list[i] == 0:
    new_list.append(1)
  else:
    new_list.append(0)

#print(new_list)
    
for i in range(n_size):
  if (int(n[i]) != int(new_list[i])):
    count+=1

#print(new_list)    
if n_size == 1:
  print(0)
else:
#  ans = n_size-count    
  print(count) 

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n = input()

counta = 0
countb = 0
if N%2==0:
  for i in range(0,len(n)-2,2):
    if n[i]=="0":
      counta+=1
    elif n[i]=="1":
      countb+=1
  for i in range(1,len(n)-1,2):
    if n[i]=="1":
      counta+=1
    elif n[i]=="0":
      countb+=1
  print(min(counta,countb))

counta = 0
countb = 0
if N%2==1:
  for i in range(0,len(n)-1,2):
    if n[i]=="0":
      counta+=1
    elif n[i]=="1":
      countb+=1
  for i in range(1,len(n)-2,2):
    if n[i]=="1":
      counta+=1
    elif n[i]=="0":
      countb+=1
  print(min(counta,countb))

n = input()
N = len(n)

counta = 0
countb = 0
if N%2==0:
  for i in range(0,N-2,2):
    if n[i]=="0":
      counta+=1
    elif n[i]=="1":
      countb+=1
  for i in range(1,N-1,2):
    if n[i]=="1":
      counta+=1
    elif n[i]=="0":
      countb+=1
  print(min(counta,countb))
  
countc = 0
countd = 0
if N%2==1:
  for i in range(0,N-1,2):
    if n[i]=="0":
      countc+=1
    elif n[i]=="1":
      countd+=1
  for i in range(1,N-2,2):
    if n[i]=="1":
      countc+=1
    elif n[i]=="0":
      countd+=1
  print(min(countc,countd))

n = input()
N = len(n)
 
counta = 0
countb = 0
if N%2==0:
  for i in range(0,N-2,2):
    if n[i]=="0":
      counta+=1
    elif n[i]=="1":
      countb+=1
  for i in range(1,N-1,2):
    if n[i]=="1":
      counta+=1
    elif n[i]=="0":
      countb+=1
  print(min(counta,countb))
    
elif N%2==1:
  countc = 0
  countd = 0
  for i in range(0,N-1,2):
    if n[i]=="0":
      countc+=1
    elif n[i]=="1":
      countd+=1
  for i in range(1,N-2,2):
    if n[i]=="1":
      countc+=1
    elif n[i]=="0":
      countd+=1
  print(min(countc,countd))

n = input()
s = n[::2].count("0")+n[1::2].count("1")
print(min(s,len(n)-s))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, n):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(abs(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)


s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, n):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(-(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)

s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, len(s)):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(-(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import sys
input = sys.stdin.readline

bool_zeroone = True
count = 0
sl = list(input())
for c in sl:
    if bool_zeroone and c == '0':
        count += 1
    elif not bool_zeroone and c == '1':
        count += 1
    bool_zeroone = not bool_zeroone

answer = min(count, len(sl) - count)
print(answer)


import sys
input = sys.stdin.readline

bool_zeroone = True
count = 0
sl = list(input())
for c in sl:
    if bool_zeroone and c == '0':
        count += 1
    elif not bool_zeroone and c == '1':
        count += 1
    bool_zeroone = not bool_zeroone

answer = min(count, len(sl) - count)
print(answer)

bool_zeroone = True
count = 0
sl = list(input())
for c in sl:
    if bool_zeroone and c == '0':
        count += 1
    elif not bool_zeroone and c == '1':
        count += 1
    bool_zeroone = not bool_zeroone

answer = min(count, len(sl) - count)
print(answer)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
h_list = list(map(int,input()))

print(h_list)

score_z = 0
score_o = 0



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


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


print(min(score_z,score_o))


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

score_z = 0
score_o = 0


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


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


print(min(score_z,score_o))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = input()

min(S[::2].count("0")+S[1::2].count("1"), S[::2].count("1")+S[1::2].count("0"))

S = input()

print(min(S[::2].count("0")+S[1::2].count("1"), S[::2].count("1")+S[1::2].count("0")))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S=list(input())
N=len(S)

A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1
print(max(countA,countB))

S=list(input())
N=len(S)
print(S)
A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1

print(A)
print(B)
print(min(countA,countB))

S=list(input())
N=len(S)
A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1

print(min(countA,countB))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
color = input()

l1 = [str(i % 2) for i in range(len(color))]
l2 = [str((i + 1) % 2) for i in range(len(color))]

print(color)
print(l1, l2)
s1 = s2 = 0
for c, n1, n2 in zip(color, l1, l2):
    s1 += (c != n1)
    s2 += (c != n2)

print(min(s1, s2))

color = input().rstrip("\n")

l1 = [str(i % 2) for i in range(len(color))]
l2 = [str((i + 1) % 2) for i in range(len(color))]

s1 = s2 = 0
for c, n1, n2 in zip(color, l1, l2):
    s1 += (c != n1)
    s2 += (c != n2)

print(min(s1, s2))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))

ans = 0
if N > 1:
  for i in range(1, N):
    if (H[i] >= H[i - 1]:
      ans += 1

print(ans + 1)

import itertools
S = input()

p1 = itertools.cycle('01')
p2 = itertools.cycle('10')

ans1=0
ans2=0
for s,P1,P2 in zip(S,p1,p2):
  if s == P1:
    ans1 += 1
  if s == P2:
    ans2 += 1
print(min(ans1,ans2))
  

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
def d201(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='0'):
                count+=1
        else:
            if(a[i]=='1'):
                count+=1
    return count

                
def d210(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='1'):
                count+=1
        else:
            if(a[i]=='0'):
                count+=1
    return count

a=input()
print(min(d210(a),d201(a))
                




def d201(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='0'):
                count+=1
        else:
            if(a[i]=='1'):
                count+=1
    return count

                
def d210(a):
    count=0
    N=len(a)
    for i in range(N):
        if(i%2==0):
            if(a[i]=='1'):
                count+=1
        else:
            if(a[i]=='0'):
                count+=1
    return count

a=input()
print(min(d210(a),d201(a)))
                




Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
a=0
for i in range(len(s)):
  if i%2==0:
    if s[i]==0:
      a+=1
  if i%2==1:
    if s[i]==1:
      a+=1
print(min(a,len(s)-a)

s=input()
a=0
for i in range(len(s)):
  if i%2==0 and s[i]=="0":
  	a+=1
  if i%2==1 and s[i]=="1":
  	a+=1  
print(min(a,(len(s)-a)))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
l = [int(i) for i in s[0::2]]
r = [int(i) for i in s[1::2]]
print(l)
print(r)
if len(s) == 1:
    print(0)
else:
    l_count1 = l.count(1)
    l_count0 = len(l)-l_count1
    r_count1 = r.count(1)
    r_count0 = len(r)-r_count1
    l_1 = l_count0+r_count1
    l_0 = l_count1+r_count0
    if (l_count1==len(l) and r_count0==len(r)) or (l_count0==len(l) and r_count1==len(r)):
        print(0)
    elif l_1 < l_0:
        print(l_1)
    else:
        print(l_0)


s = input()
l = [int(i) for i in s[0::2]]
r = [int(i) for i in s[1::2]]

if len(s) == 1:
    print(0)
else:
    l_count1 = l.count(1)
    l_count0 = len(l)-l_count1
    r_count1 = r.count(1)
    r_count0 = len(r)-r_count1
    l_1 = l_count0+r_count1
    l_0 = l_count1+r_count0
    if (l_count1==len(l) and r_count0==len(r)) or (l_count0==len(l) and r_count1==len(r)):
        print(0)
    elif l_1 < l_0:
        print(l_1)
    else:
        print(l_0)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import numpy as np
tile=str(input())
a=['01','10'][int(tile[0])]*(10**5//2)
sum(np.array(list(tile),dtype=int)^np.array(list(a[:len(tile)]),dtype=int))

import numpy as np
tile=str(input())
a=['01','10'][int(tile[0])]*(10**5//2)
print(sum(np.array(list(tile),dtype=int)^np.array(list(a[:len(tile)]),dtype=int)))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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))

s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 0:
    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))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def main(n):
	n = input()
	r = 0
	f = n[0]
	if(f =="0"):
		
		for i in range(1, len(n)):
			if(i % 2 == 0): 
				# 1
				if(n[i]=="1"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="0"):
					r+=1
	else:
		# one mode
		for i in range(1, len(n)):
			if(i % 2 == 0): 
				# 1
				if(n[i]=="0"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="1"):
					r+=1
	# sum(result)
	return r

print(main(input()))




n=input()
r=n[0::2].count("0")+n[1::2].count("1")
print(min(r,len(n-r))

data = input()
a,b = data.split()
if(a==b):
  print(a+b)
elif(a>b):
  print(2*a-1)
else:
  print(2*b-1)

def main(n):
	odd = "1"
	even= "0"
	if(n[0] =="0"):
		
		odd = "0"
		even= "1"
	a = sum((((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n),2))
	b = sum((((i % 2 == 0) and n[i] == even)) for i in range(0, len(n),2))
	return sum(a,b)

print(main(input()))

n=input()
r=n[0::2].count("0")+n[1::2].count("1")
print(min(r,len(n)-r))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
def main():
  import sys
  input = sys.stdin.readline
  s=list(input())
  count1,count2,l=0,0,len(s)
  for i in range(l):
    count1=count1+1 if (i%2==0 and int(s[i])==1) or (i%2==1 and int(s[i])==0) else count1
    count2=count2+1 if (i%2==1 and int(s[i])==1) or (i%2==0 and int(s[i])==0) else count2
  print(min(count1,count2))

if __name__=='__main__':
  main()

def main():
  s=list(input())
  count1,count2,l=0,0,len(s)
  for i in range(l):
    count1=count1+1 if (i%2==0 and int(s[i])==1) or (i%2==1 and int(s[i])==0) else count1
    count2=count2+1 if (i%2==1 and int(s[i])==1) or (i%2==0 and int(s[i])==0) else count2
  print(min(count1,count2))

if __name__=='__main__':
  main()


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
S = str(input())
N = len(S)
K = []
H = []
for i in range(N):
  K.append(i%2)
  H.append((i+1)%2)
count_K=0
count_H=0
for i in range(N):
  if (K[i]!=S[i]):
    count_K=count_K+1
  elif (H[i]!=S[i]):
    count_H=count_H+1
  else:
    None
M = min(count_K,count_H)
print(M)
    
  
  

S = str(input())
N = len(S)
c_K = 0
c_H = 0
for i in range(N):
  K = str(i%2)
  if(S[i]==K):
    c_K+=1
  else:
    c_H+=1
M = max(c_K,c_H)
G = N-M
print(G)

    
  
  

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = input()
T = []
tmp = '1'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
tmp = '0'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
print(T)
ans = float('inf')
for j in range(2):
    cnt = 0
    for i in range(len(S)):
        if S[i] != T[j][i]:
            cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)


S = input()
T = []
tmp = '1'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
tmp = '0'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
ans = float('inf')
for j in range(2):
    cnt = 0
    for i in range(len(S)):
        if S[i] != T[j][i]:
            cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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()


import sys

input = sys.stdin.readline


def main():
    s = input().strip()
    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()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = input()
N = len(S)
ans1 = 0
ans2 = 0
for i in range(N):
  x = a[i]
  if i % 2 == 0:
    if x == '0':
      ans1 += 1
    else:
      ans2 += 1
  else:
    if x == '1':
      ans1 += 1
    else:
      ans2 += 1
ans = min(ans1,ans2)
print(ans)

S = input()
N = len(S)
ans1 = 0
ans2 = 0
for i in range(N):
  x = S[i]
  if i % 2 == 0:
    if x == '0':
      ans1 += 1
    else:
      ans2 += 1
  else:
    if x == '1':
      ans1 += 1
    else:
      ans2 += 1
ans = min(ans1,ans2)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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?

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

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
n = len(s)
count = 0
count2 = 0
for i in range(n):
    if i % 2 == 0:
        x = "0"
    else:
        x = "1"
    if s[i] == x:
        count2 += 1
        #print(i, s[i], x, "OK")
    else:
        count += 1
        #print(i, s[i], x)
print(count,count2)


s = input()
n = len(s)
count = 0
count2 = 0
for i in range(n):
    if i % 2 == 0:
        x = "0"
    else:
        x = "1"
    if s[i] == x:
        count2 += 1
        print(i, s[i], x, "OK")
    else:
        count += 1
        print(i, s[i], x)
print(count, "回または", count2, "でいけます")



s = input()
n = len(s)
count = 0
count2 = 0
for i in range(n):
    if i % 2 == 0:
        x = "0"
    else:
        x = "1"
    if s[i] == x:
        count2 += 1
        #print(i, s[i], x, "OK")
    else:
        count += 1
        #print(i, s[i], x)
print(min(count,count2))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = input()
n = len(S)
S = int(S, 2)
a = sum([2 ** i for i in range(0, n, 2)])
b = a << 1

an = bin(a ^ S).count("1")
bn = bin(b ^ S).count("1")
print(min(an, bn))

S = input()
len_S = len(S)
n = len_S // 2
A = "01" * n
if len_S % 2 == 1:
    A += "0"
an, bn = 0, 0
for s, a in zip(S, A):
    if s == a:
        bn += 1
    else:
        an += 1
print(min(an, bn))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
n = len(s)



# 0...
err1 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == 1:
        err1 += 1
    elif i % 2 == 1 and s[i] == 0:
        err1 += 1

# 1...
err2 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == 0:
        err2 += 1
    elif i % 2 == 1 and s[i] == 1:
        err2 += 1

print(min(err1, err2))

s = input()
n = len(s)



# 0...
err1 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == "1":
        err1 += 1
    elif i % 2 == 1 and s[i] == "0":
        err1 += 1

# 1...
err2 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == "0":
        err2 += 1
    elif i % 2 == 1 and s[i] == "1":
        err2 += 1

print(min(err1, err2))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s=input()

a=int(s)

print(a)

s=input()
l=len(s)
sum1=0
sum2=0

a=[0 for i in range(l)]
c=[0 for i in range(l)]
d=[0 for i in range(l)]

for i in range(l):
  a[i]=int(s[i])

for i in range(l):
  if i%2==0:
    c[i]=1

for i in range(l):
  if i%2==1:
    d[i]=1
    
for i in range(l):
  sum1+=abs(a[i]-c[i])
  sum2+=abs(a[i]-d[i])
  

print(min(sum1,sum2))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import sys
import math

mat = list(sys.stdin.readline())

odd = 0
even = 0
l = len(mat)
for i, x in enumerate(mat):
    if int(x) == 1:
        if i % 2 == 0:
            even += 1
        else:
            odd += 1

if odd > even:
    print(even + math.ceil(l / 2) - odd)
else:
    print(odd + math.floor(l/2) - even)


import sys
import math

mat = list(sys.stdin.readline().strip())

odd = 0
even = 0
for i, x in enumerate(mat):
    flg = i % 2
    if flg:
        if int(x) == 1:
            even += 1
        else:
            odd += 1
    else:
        if int(x) == 1:
            odd += 1
        else:
            even += 1

print(min(odd, even))


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
n=len(s)
s = bin(int(s, 2))
s_10 = '1' * (n % 2) + '01' * (n // 2)
s_01 = '0' * (n % 2) + '10' * (n // 2)
s_10 = bin(int(s_10, 2))
s_01 = bin(int(s_01, 2))
r = s ^ s_01
l = s ^ s_10
print(min(r.count('1'), l.count('1')))

s=input()
n=len(s)
s = int(s, 2)
s_10 = '1' * (n % 2) + '01' * (n // 2)
s_01 = '0' * (n % 2) + '10' * (n // 2)
s_10 = int(s_10, 2)
s_01 = int(s_01, 2)
r = bin(s ^ s_01)
l = bin(s ^ s_10)
print(min(r.count('1'), l.count('1')))


Verdicts: Runtime Error

Accepted