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()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))
  

    
    



s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
a.append('0')
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
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):
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**10)

def operation(s,memo=-1,ans=0):
    if len(s) <= 0:
        return ans
    elif s[0] == memo == "0": 
        return operation(s[1:],"1",ans+1)
    elif s[0] == memo == "1": 
        return operation(s[1:],"0",ans+1)
    else:
        return operation(s[1:],s[0],ans)

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


if __name__ == '__main__':
    main()


#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**6)

def operation(s,f):
    c = 0
    for i in range(len(s)):
        if (s[i] == f and i % 2 == 1) or (s[i] != f and i % 2 == 0):
            c += 1
    return c

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


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):
a = [int(n) for n in input()]
counter=1
for n in range(1, len(a)):
  if a[n-1]==a[n]:
    if a[n-1]==1:
      a[n]=0
    else:
      a[n]=1
    counter+=1
print(counter)

a = [int(n) for n in input()]
counter=0
for n in range(1, len(a)):
  if a[n-1]==a[n]:
    if a[n-1]==1:
      a[n]=0
    else:
      a[n]=1
    counter+=1
print(counter)

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()
x = [s[j] for j in range(0,len(s10))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)


s = input()
x = [s[j] for j in range(0,len(s))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)


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):
deata = list(input())
count = 0
for i in range(1, len(data)):
  if data[i] == data[i-1]:
    if data[i] == "0":
      data[i] = "1"
    else:
      data[i] = "0"
    count += 1
print(count)

data = list(input())
count = 0
for i in range(1, len(data)):
  if data[i] == data[i-1]:
    if data[i] == "0":
      data[i] = "1"
    else:
      data[i] = "0"
    count += 1
print(count)

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

#input S
S=input()

count=0
l=len(S)

for i in range(1,len(S)):
    iS=int(S[i])
    if S[i]==S[i-1]:
        if S[i]=='0':
            S=S[:i-1]+'1'+S[i:]
        else:
            S=S[:i-1]+'0'+S[i:]
        count=count+1

print(count)




#input S
S=input()

count=0
for i in range(1,len(S)):
    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:]
        count=count+1

print(count)



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):
# ABC124C

s = input()
s = [int(t) for t in list(s)]
repaint = 0
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        repaint += 1
        s[i] = 1 - s[i]
paint(repaint)


# ABC124C

s = input()
s = [int(t) for t in list(s)]
repaint = 0
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        repaint += 1
        s[i] = 1 - s[i]
print(repaint)


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 = list(input())
S1 = []
S2 = []
if i in range(len(S)):
    if i % 2 ==0 :
        S1.append('0')
        S2.append('0')
    else :
        S1.append('1')
        S2.append('2')
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))

S = input()
S1 = ''
S2 = ''
if i in range(len(S)):
    if i % 2 ==0 :
        S1 += '0'
        S2 += '1'
    else :
        S1 += '1'
        S2 += '0'
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))


S = list(input())
S1 = []
S2 = []
if i in range(len(S)):
    if i % 2 ==0 :
        S1.append('0')
        S2.append('1')
    else :
        S1.append('1')
        S2.append('0')
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))


S = input()
S1 = ''
S2 = ''
if i in range(len(S)):
    if i % 2 ==0 :
        S1 += '0'
        S2 += '1'
    else :
        S1 += '1'
        S2 += '0'
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S2[i]:
        min2 += 1 
print(min(min1,min2))


S = input()
S1 = ''
S2 = ''
for i in range(len(S)):
    if i % 2 ==0 :
        S1 += '0'
        S2 += '1'
    else :
        S1 += '1'
        S2 += '0'
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S2[i]:
        min2 += 1 
print(min(min1,min2))


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):
import math
tile=int(input())
if len(str(tile))==1:
    print(0)
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)))
    tile2=int("10"*int(math.ceil(len(str(tile))/2)))
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
print(tile_10)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))


import math
tile=int(input())
if len(str(tile))==1:
    print(0)
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)))
    tile2=int("10"*int(math.ceil(len(str(tile))/2)))
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))


import math
tile=int(input())
if len(str(tile))==1:
    print(0)
    exit()
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)),2)
    tile2=int("10"*int(math.ceil(len(str(tile))/2)),2)
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))


number=list(input())

paturn1=list("10"*(10**5))
paturn2=list("01"*(10**5))
convert1=[int(x)^int(y) for x,y in zip(number,paturn1)]
convert2=[int(x)^int(y) for x,y in zip(number,paturn2)]

print(min([convert1.count(1),convert2.count(1)]))


Verdicts: 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):
s=list(input())
bw=0 
for i in range(len(s)):
	if (i%2==0 and s[i]==1) or (i%2==1 and s[i]==0):
		bw+=1
wb=0
for i in range(len(s)):
	if (i%2==0 and s[i]==0) or (i%2==1 and s[i]==1):
		wb+=1
print(min(bw,wb))

s=list(map(int,input()))
bw=0 
for i in range(len(s)):
	if (i%2==0 and s[i]==1) or (i%2==1 and s[i]==0):
		bw+=1
wb=0
for i in range(len(s)):
	if (i%2==0 and s[i]==0) or (i%2==1 and s[i]==1):
		wb+=1
print(min(bw,wb))

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(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0 and S[i] == 0:
      ans1 += 1
  elif i %2 ==1 and S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0 and S[i] == 1:
      ans2 += 1
  elif i % 2 ==1 and S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



S = list(input().split())
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0 and S[i] == "0":
      ans1 += 1
  elif i %2 ==1 and S[i] == "1":
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0 and S[i] == "1":
      ans2 += 1
  elif i % 2 ==1 and S[i] == "0":
      ans2 += 1
print(min(ans1, ans2))



S = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



S = list(int, map(input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



S = list(int, map(input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)-1):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)-1):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



S = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0 and S[i] == 0:
      ans1 += 1
  elif i %2 ==1 and S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0 and S[i] == 1:
      ans2 += 1
  elif i % 2 ==1 and S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

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):
s = input()
lb = 0
lw = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            lb += 1
        else:
            lw += 1
    else:
        if s[i] == '0':
            lw += 1
        else:
            lb += 1
print(max(lb,lw))

s = input()
lb = 0
lw = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            lb += 1
        else:
            lw += 1
    else:
        if s[i] == '0':
            lw += 1
        else:
            lb += 1
print(min(lb,lw))

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)

s1 = [0]*n
s2 = [1]*n
for i in range(1,n,2):
  s1[i] = 1
  s2[i] = 0

count1 = 0
count2 = 0
for i in range(n):
  if s[i]!=s1[i]: count1 += 1
  if s[i]!=s2[i]: count2 += 1
print(min(count1,count2))


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

s1 = [0]*n
s2 = [1]*n
for i in range(1,n,2):
  s1[i] = 1
  s2[i] = 0

count1 = 0
count2 = 0
for i in range(n):
  if s[i]!=s1[i]: count1 += 1
  if s[i]!=s2[i]: count2 += 1
print(min(count1,count2))


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()
cnt = [[0,0],[0,0]]
for i, s in enumerate(S):
    x = int(i) % 2
    y = int(s)
    cnt[x][y] += 1
print(cnt)
if cnt[0][0] >= cnt[1][0]:
    print(cnt[0][1] + cnt[1][0])
else:
    print(cnt[0][0] + cnt[1][1])

S = input()
cnt = [[0,0],[0,0]]
for i, s in enumerate(S):
    x = int(i) % 2
    y = int(s)
    cnt[x][y] += 1
print(min(cnt[0][1] + cnt[1][0], cnt[0][0] + cnt[1][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):
# -*- coding: utf-8 -*-
*s, = map(int,input())
print(s)


ans = len(s)


for i in range(2):
    
    cnt = 0

    for j in range(len(s)):
        if (j % 2 == 0) ^ (s[j] == i):
            cnt = cnt +1
    ans = min(ans, cnt)

print(ans)

# -*- coding: utf-8 -*-
*s, = map(int,input())


ans = len(s)


for i in range(2):
    
    cnt = 0

    for j in range(len(s)):
        if (j % 2 == 0) ^ (s[j] == i):
            cnt = cnt +1
    ans = min(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 Levenshtein

S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    print(S[x])
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
    

S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
    

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

#C 
S =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:
        s0+=1
    elif i%2!=0 and S[i]=="0":
        s0+=1
    elif i%2!=0:
        s1+=1
print(min(s0,s1))

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

middle = S[1:-1]
white = middle.count('.')
black = middle.count('#')

if (S.count('.') == 0 or S.count('#') == 0) or ((S.count('.') == 1 and S[0] == '.') or (S.count('#') == 1 and S[-1] == '#')):
  print('0')
else:
  if white < black:
    if S[-1] == '.':
      print(white+1)
    else:
      print(white)
  else:
    if S[0] == '#':
      print(black+1)
    else:
      print(black)


s=list(input())
odd,even=s[1::2],s[0::2]
print(min(even.count('0') + odd.count('1'), even.count('1') + odd.count('0')))


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

# coding: utf-8

# In[17]:

import sys
input = sys.stdin.readline
S = input()


# In[18]:

#a = "01"
#b = "10"
if len(S)%2==0:
    a = "01"*(len(S)//2)
    b = "10"*(len(S)//2)
else:
    a = "01"*(len(S)//2)+"0"
    b = "10"*(len(S)//2)+"1"
#print(a, b)


# In[19]:

ac = 0
bc = 0
for i in range(len(S)):
    if S[i] != a[i]:
        ac += 1
    if S[i] != b[i]:
        bc += 1
print(min(ac, bc))


# In[ ]:






# coding: utf-8

# In[20]:

import sys
#input = sys.stdin.readline
S = input()


# In[21]:

if len(S)%2==0:
    a = "01"*(len(S)//2)
    b = "10"*(len(S)//2)
else:
    a = "01"*(len(S)//2)+"0"
    b = "10"*(len(S)//2)+"1"


# In[22]:

ac = 0
bc = 0
for i in range(len(S)):
    if S[i] != a[i]:
        ac += 1
    if S[i] != b[i]:
        bc += 1
print(min(ac, bc))


# In[ ]:





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()
option1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 = 0
print(min(ans_1, ans_2))

s = input()
option_1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option_2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 += 1
print(min(ans_1, ans_2))

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

a = input()
result = -500000

privious_list = ["0", "1"]
#print(len(a))

if len(a) == 1 or 0:
    print(0)
else:
    for x in privious_list:
        new_result = 0
        privious = x
        for i in a:
            if i == "0":
                if privious == "0":
                    new_result += 1
                    privious = "1"
                else:
                    privious = "0"
            else:
                if privious == "0":
                    privious = "1"
                else:
                    new_result += 1
                    privious = "0"
        print(result, new_result)
        if result == -500000:
            result = new_result
        elif new_result < result:
            result = new_result
    
    print(result)










a = input()
result = -500000

privious_list = ["0", "1"]
#print(len(a))

if len(a) == 1 or 0:
    print(0)
else:
    for x in privious_list:
        new_result = 0
        privious = x
        for i in a:
            if i == "0":
                if privious == "0":
                    new_result += 1
                    privious = "1"
                else:
                    privious = "0"
            else:
                if privious == "0":
                    privious = "1"
                else:
                    new_result += 1
                    privious = "0"
        #print(result, new_result)
        if result == -500000:
            result = new_result
        elif new_result < result:
            result = new_result
    
    if result == -500000:
        result = 0
    print(result)









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):
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	s=io()
	num_st=[0,0]
	for i, c in enumerate(list(s)):
		if int(c) == i % 2:
			num_st[0]+=1
		else:
			num_st[1]+=1
	
	return min(num_st)

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	s=io()
	num_st=[0,0]
	for i, c in enumerate(list(s)):
		if int(c) == i % 2:
			num_st[0]+=1
		else:
			num_st[1]+=1
	
	return min(num_st)

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

s=input()
num_st=[0,0]
for i, c in enumerate(list(s)):
	if int(c) == i % 2:
		num_st[0]+=1
	else:
		num_st[1]+=1

ret = min(num_st)
print(int(ret))

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):
s = list(input())

len_s = len(s)
change_cnt = 0
i = 1
while len_s > 2:
    left = s[i-1]
    right = s[i+1]
    if s[i] == left and s[i] == right:
        
        # 000
        change_cnt += 1
        if s[i] == '0':
            s[i] = '1'
        else:
            s[i] = '0'
    elif s[i] == left:
        
        # 110
        change_cnt += 1
        if s[i-1] == '0':
            s[i-1] = '1'
        else:
            s[i-1] = '0'
    elif s[i] == right:
        
        # 011
        change_cnt += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
    i += 1
    if i == len_s-1:
        break

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


s = input()

even_position_nums = s[::2]
len_even = len(even_position_nums)
odd_position_nums = s[1::2]
len_odd = len(odd_position_nums)



tmp = len_even - even_position_nums.count('1')
tmp1 = len_odd - odd_position_nums.count('0')
first = tmp + tmp1

tmp = len_even - even_position_nums.count('0')
tmp1 = len_odd - odd_position_nums.count('1')
second = tmp + tmp1
print(min(first, second))


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()
even = true
ans1=0
ans2=1
for c in s:
  if even:
    if c == '0':
      ans2 += 1
    else:
      ans1 += 1
  else:
    if c == '0':
      ans1 += 1
    else:
      ans2 += 1
print(min([ans1,ans2]))




s = input()
even = True
ans1=0
ans2=0
for c in s:
  if even:
    even = False
    if c == '0':
      ans2 += 1
    else:
      ans1 += 1
  else:
    even = True
    if c == '0':
      ans1 += 1
    else:
      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):
import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
else:
    for u in range(len(s)):
        if s[u] != b[u]:
            c+=1
print(c)

s=str(input())
a=[0]
b=''
c=0
d=int(len(s)/2)
if a=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

s=str(input())
a=[0]
b=''
c=0
d=int(len(s)/2)
if d == 0:
    print(0)
elif a=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

s=str(input())
b=''
c=0
d=int(round(len(s)/2))
if len(s) == 1:
    print(0)
elif s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
    print(b)
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Verdicts: Wrong Answer

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):
s=input()
ans1=0
ans2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            ans1+=1
    else:
        if s[i]=="1":
            ans1+=1
for k in range(len(s)):
    if k%2==0:
        if s[i]=="1":
            ans2+=1
    else:
        if s[i]=="0":
            ans2+=1
print(ans1,ans2)


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


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


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):
gen = get_input()

S = list(input())

count = 0
s1 = S[:]
for i in range(1, len(S)):
    if s1[i - 1] == s1[i]:
        s1[i] = '0' if s1[i-1] == '1' else '1'
        count += 1

count2 = 0
s2 = S[:]
for i in reversed(range(len(S)-1)):
    if s2[i] == s2[i +1]:
        s2[i] = '0' if s2[i+1] == '1' else '1'
        count2 += 1

print(min(count, count2))

S = list(input())
 
count = 0
s1 = S[:]
for i in range(1, len(S)):
    if s1[i - 1] == s1[i]:
        s1[i] = '0' if s1[i-1] == '1' else '1'
        count += 1
 
count2 = 0
s2 = S[:]
for i in reversed(range(len(S)-1)):
    if s2[i] == s2[i +1]:
        s2[i] = '0' if s2[i+1] == '1' else '1'
        count2 += 1
 
print(min(count, count2))

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=[]
for i in range(len(s)):
  if i%2==0:
    a.append(0)
  else:
    a.append(1)
b=[]
for j in range(len(s)):
  if j%2==0:
    b.append(1)
  else:
    b.append(0)
cnt=0
for k in range(len(s)):
  if s[k]!=a[k]:
    cnt+=1
ans=0
for l in range(len(s)):
  if s[l]!=b[l]:
    ans+=1
print(min(cnt,ans))

s=input()
a=[]
for i in range(len(s)):
  if i%2==0:
    a.append('0')
  else:
    a.append('1')
b=[]
for j in range(len(s)):
  if j%2==0:
    b.append('1')
  else:
    b.append('0')
cnt=0
for k in range(len(s)):
  if s[k]!=a[k]:
    cnt+=1
ans=0
for l in range(len(s)):
  if s[l]!=b[l]:
    ans+=1
print(min(cnt,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 math

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

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

import math

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

even_0 = S_list[1::2].count('0')
odd_0 = S_list[::2].count('0')
print(max(min(even_0+math.ceil(N/2)-odd_0, odd_0+math.trunc(N/2)-even_0), 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=input()
N=len(S)
A=len([_ for i in range(N) if str(i%2)==S[i]])
print(min(A,N-A))

S=input()
N=len(S)
A=len([i for i in range(N) if str(i%2)==S[i]])
print(min(A,N-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()
S = list(s)

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        print(S)
        ans += 1
print(ans)

s = input()
S = list(s)

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        ans += 1
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 = input()
ans = s[0]

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

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

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=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count(0)
a1=a.count(1)
b0=b.count(0)
b1=b.count(1)
x=max(a0+b1,a1+b0)
print(l-x)

s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0)
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)

s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0')
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)

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):
S = int(input())

S_string = str(S)

S_half_integer = len(S_string)//2

list_01 = list('1' for i in range(S_half_integer))
list_10 = list('0' for i in range(S_half_integer))

for i in range(S_half_integer+1):
	list_01.insert(2*i, '0')
	list_10.insert(2*i, '1')

n2l_1 = ''
n2l_2 = ''

for (i, j) in zip(list_01, list_10):
	n2l_1 += i
	n2l_2 += j

S_renew_1 = S + int(n2l_1)
S_renew_2 = S + int(n2l_2)

S_renew_11 = str(S_renew_1)
S_renew_22 = str(S_renew_2)

count_1 = S_renew_11.count('1')
count_2 = S_renew_22.count('1')

print(min(count_1, count_2))

S = input()

length_S = len(S)

wrong_10 = 0
wrong_01 = 0

for i in range(length_S):
	if i%2 == 0:
		if S[i] == '1':
			wrong_01 += 1
		else:
			wrong_10 += 1
	else:
		if S[i] == '1':
			wrong_10 += 1
		else:
			wrong_01 += 1
			
print(min(wrong_01, wrong_10))

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):
string=list(input())
if int(string[1]==0):
  c=1
else:
  c=0
a=0
for s in string:
  if int(s)==0 and c==1:
    c-=1
  elif int(s)==0 and c==0:
    c+=1
    a+=1
  elif int(s)==1 and c==0:
	c+=1
  elif int(s)==1 and c==1:
	c-=1
    a+=1
print(a)

string=list(input())
c=0
a=0
for s in string:
  if int(s)==0 and c=1:
    c-=1
  elif int(s)==0 and c=0:
    c+=1
    a+=1
  elif int(s)==1 and c=0:
	c+=1
  elif int(s)==1 and c=1:
	c-=1
    a+=1
print(a)

string=list(input())
if int(string[1])==0:
  c=1
else:
  c=0
a=0
for s in string:
  if int(s)==0 and c==1:
    c-=1
  elif int(s)==0 and c==0:
    c+=1
    a+=1
  elif int(s)==1 and c==0:
	c+=1
  elif int(s)==1 and c==1:
	c-=1
    a+=1
print(a)

string=list(input())
if int(string[0])==1:
    c=0
else:
    c=1
a=0
for s in string:
    if int(s)==0 and c==1:
        c-=1
    elif int(s)==0 and c==0:
        c+=1
        a+=1
    elif int(s)==1 and c==0:
        c+=1
    elif int(s)==1 and c==1:
        c-=1
        a+=1
print(a)

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

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

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

S=list(input())
N=len(S)
S_int_1=list(S)
S_int_2=list(S)
for i in range(N):
    S_int_1[i]=int(S[i])
    S_int_2[i]=int(S[i])
cnt_1=0
cnt_2=0
for i in range(N):
    if i%2==0 and S_int_1[i]==0:
        S_int_1[i]=1
        cnt_1+=1
    elif i%2==1 and S_int_1[i]==1:
        S_int_1[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int_2[i]==1:
        S_int_2[i]=0
        cnt_2+=1
    elif i%2==1 and S_int_2[i]==0:
        S_int_2[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))

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 = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans1[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2)
    ans.append('0')

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Verdicts: Runtime Error

Runtime Error

Accepted